@@ -66,15 +66,6 @@ def finalize_options(self):
66
66
def run (self ):
67
67
run_test_suite ()
68
68
69
- def get_python_files (files ):
70
- """Utility function to get .py files from a list"""
71
- python_files = []
72
- for file_name in files :
73
- if file_name .endswith (".py" ):
74
- python_files .append (file_name )
75
-
76
- return python_files
77
-
78
69
class DistCommand (Command ):
79
70
"""setup.py command to create .spl files for modular input examples"""
80
71
description = "Build modular input example .spl files."
@@ -86,44 +77,53 @@ def initialize_options(self):
86
77
def finalize_options (self ):
87
78
pass
88
79
80
+ @staticmethod
81
+ def get_python_files (files ):
82
+ """Utility function to get .py files from a list"""
83
+ python_files = []
84
+ for file_name in files :
85
+ if file_name .endswith (".py" ):
86
+ python_files .append (file_name )
87
+
88
+ return python_files
89
+
89
90
def run (self ):
90
91
app_names = ["random_numbers" , "github_forks" ]
91
92
92
93
splunklib_dir = "splunklib"
93
94
modinput_dir = os .path .join (splunklib_dir , "modularinput" )
94
95
95
96
for app in app_names :
96
- spl = tarfile .open (os .path .join ("build" , app + ".spl" ), "w" )
97
-
98
- spl .add (
99
- os .path .join ("examples" , app , app + ".py" ),
100
- arcname = os .path .join (app , "bin" , app + ".py" )
101
- )
102
-
103
- spl .add (
104
- os .path .join ("examples" , app , "default" , "app.conf" ),
105
- arcname = os .path .join (app , "default" , "app.conf" )
106
- )
107
- spl .add (
108
- os .path .join ("examples" , app , "README" , "inputs.conf.spec" ),
109
- arcname = os .path .join (app , "README" , "inputs.conf.spec" )
110
- )
111
-
112
- splunklib_files = get_python_files (os .listdir (splunklib_dir ))
113
- for file_name in splunklib_files :
97
+ with tarfile .open (os .path .join ("build" , app + ".spl" ), "w" ) as spl :
114
98
spl .add (
115
- os .path .join (splunklib_dir , file_name ),
116
- arcname = os .path .join (app , "bin" , splunklib_dir , file_name )
99
+ os .path .join ("examples" , app , app + ".py" ),
100
+ arcname = os .path .join (app , "bin" , app + ".py" )
117
101
)
118
102
119
- modinput_files = get_python_files (os .listdir (modinput_dir ))
120
- for file_name in modinput_files :
121
103
spl .add (
122
- os .path .join (modinput_dir , file_name ),
123
- arcname = os .path .join (app , "bin" , modinput_dir , file_name )
104
+ os .path .join ("examples" , app , "default" , "app.conf" ),
105
+ arcname = os .path .join (app , "default" , "app.conf" )
106
+ )
107
+ spl .add (
108
+ os .path .join ("examples" , app , "README" , "inputs.conf.spec" ),
109
+ arcname = os .path .join (app , "README" , "inputs.conf.spec" )
124
110
)
125
111
126
- spl .close ()
112
+ splunklib_files = self .get_python_files (os .listdir (splunklib_dir ))
113
+ for file_name in splunklib_files :
114
+ spl .add (
115
+ os .path .join (splunklib_dir , file_name ),
116
+ arcname = os .path .join (app , "bin" , splunklib_dir , file_name )
117
+ )
118
+
119
+ modinput_files = self .get_python_files (os .listdir (modinput_dir ))
120
+ for file_name in modinput_files :
121
+ spl .add (
122
+ os .path .join (modinput_dir , file_name ),
123
+ arcname = os .path .join (app , "bin" , modinput_dir , file_name )
124
+ )
125
+
126
+ spl .close ()
127
127
128
128
setup (
129
129
author = "Splunk, Inc." ,
0 commit comments