-
Notifications
You must be signed in to change notification settings - Fork 0
/
gzPreviousHours.py
executable file
·38 lines (34 loc) · 1016 Bytes
/
gzPreviousHours.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python3
# IMPORTS
import os
import datetime
import sys
import re
#import time
if __name__ == '__main__':
# get time in YYYYMMDDHH format
args = sys.argv
if (len(args) < 3):
print("Usage:",args[0]," PATH_TO_LOG PATH_TO_GZ_DIRECTORY")
exit()
parseToGZpath = "/home/programs/fnfw/parseToCSV-GZ.py"
logDir = str(args[1])
gzDir = str(args[2])
currentDT = datetime.datetime.now().strftime("%Y%m%d%H")
#print(currentDT, logDir, gzDir)
logList = os.listdir(path=logDir)
#print(logList)
for logFile in logList:
# if (re.search(currentDT,logFile)): print("GOTCHA")
if (re.search(currentDT,logFile)): continue
zipTimeStart = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
print("Start",zipTimeStart)
logPath = logDir+logFile
print(logPath)
commandToRun = parseToGZpath + " " + logPath + " " + gzDir
# time.sleep(1)
print(commandToRun)
os.system(commandToRun)
os.unlink(logPath)
zipTimeEnd = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
print("End",zipTimeEnd)