Skip to content

Commit 7722c8d

Browse files
committed
fix: cronjob
1 parent 0dfee27 commit 7722c8d

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

cron_job/python2port.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
tailingFilename = str(uuid.uuid4())
2323

2424
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+
2628
# Create the folder, skip if exists
2729
if not os.path.exists(folder_name):
2830
os.makedirs(folder_name)
@@ -152,14 +154,14 @@ def preprocess(s):
152154

153155

154156
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:
156158
return flhndl.readlines()
157159

158160

159161
def extractToCSV(listData):
160162
header = ['HOST IP', 'PING STATUS', 'TELNET STATUS',
161163
'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:
163165
wr = csv.writer(myfile, quoting=csv.QUOTE_ALL)
164166
wr.writerow(header)
165167
for lines in listData:
@@ -168,14 +170,15 @@ def extractToCSV(listData):
168170
print("{}".format(first))
169171

170172
wr.writerow(first)
173+
171174
def read_cmd_args():
172175
filename=sys.argv[0] # This will have the filename being executed
173176
csv_input=sys.argv[1] # This shall contain the csv data input filename.
174177
print "Reading data from file: "+csv_input
175178
return csv_input
179+
filename = read_cmd_args()
176180

177181

178-
filename = read_cmd_args()
179182
print(filename)
180183
readFromCSV(filename)
181184
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():
185188
print("[ RUN {} ]".format(index+1))
186189
get_lst = list()
187190
get_lst = checkHost(ips_get[0], port)
191+
print("FLAG: ",get_lst)
188192
file.write(
189193
unicode(ips_get[0]+"\t" +
190194
str(get_lst[0])+"\t" +
@@ -201,5 +205,4 @@ def read_cmd_args():
201205

202206
printHeader()
203207
data = getFileData()
204-
extractToCSV(data)
205-
208+
extractToCSV(data)

0 commit comments

Comments
 (0)