22
22
tailingFilename = str (uuid .uuid4 ())
23
23
24
24
folder_name = 'cron_output'
25
- dir_path = os .path .dirname (os .path .realpath (__file__ ))
25
+ dir_path = os .path .abspath (os .getcwd ())+ "/OPT/pingTester/Test/Temp/cron_job"
26
+ print ("DIR: " , dir_path )
27
+
26
28
# Create the folder, skip if exists
27
29
if not os .path .exists (folder_name ):
28
30
os .makedirs (folder_name )
@@ -152,14 +154,14 @@ def preprocess(s):
152
154
153
155
154
156
def getFileData ():
155
- with io .open (os .path .join (folder_name , "Results_" + tailingFilename + ".txt" ), 'r' , newline = '' ) as flhndl :
157
+ with io .open (os .path .join (dir_path , folder_name , "Results_" + tailingFilename + ".txt" ), 'r' , newline = '' ) as flhndl :
156
158
return flhndl .readlines ()
157
159
158
160
159
161
def extractToCSV (listData ):
160
162
header = ['HOST IP' , 'PING STATUS' , 'TELNET STATUS' ,
161
163
'MIN' , 'MAX' , 'AVG' , 'LATENCY' , 'LOSS %' ]
162
- with io .open (os .path .join (folder_name , "Output_ResultsCSV_" + tailingFilename + ".csv" ), 'wb' ) as myfile :
164
+ with io .open (os .path .join (dir_path , folder_name , "Output_ResultsCSV_" + filename . split ( "/" )[ - 1 ] + "_ "+ tailingFilename + ".csv" ), 'wb' ) as myfile :
163
165
wr = csv .writer (myfile , quoting = csv .QUOTE_ALL )
164
166
wr .writerow (header )
165
167
for lines in listData :
@@ -168,14 +170,15 @@ def extractToCSV(listData):
168
170
print ("{}" .format (first ))
169
171
170
172
wr .writerow (first )
173
+
171
174
def read_cmd_args ():
172
175
filename = sys .argv [0 ] # This will have the filename being executed
173
176
csv_input = sys .argv [1 ] # This shall contain the csv data input filename.
174
177
print "Reading data from file: " + csv_input
175
178
return csv_input
179
+ filename = read_cmd_args ()
176
180
177
181
178
- filename = read_cmd_args ()
179
182
print (filename )
180
183
readFromCSV (filename )
181
184
with io .open (os .path .join (dir_path ,folder_name , "Results_" + tailingFilename + ".txt" ), 'w' , newline = '' ) as file :
@@ -185,6 +188,7 @@ def read_cmd_args():
185
188
print ("[ RUN {} ]" .format (index + 1 ))
186
189
get_lst = list ()
187
190
get_lst = checkHost (ips_get [0 ], port )
191
+ print ("FLAG: " ,get_lst )
188
192
file .write (
189
193
unicode (ips_get [0 ]+ "\t " +
190
194
str (get_lst [0 ])+ "\t " +
@@ -201,5 +205,4 @@ def read_cmd_args():
201
205
202
206
printHeader ()
203
207
data = getFileData ()
204
- extractToCSV (data )
205
-
208
+ extractToCSV (data )
0 commit comments