-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
79 lines (70 loc) · 2.86 KB
/
main.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
'''
File name: main.py
Description: Run scripts that end user run... this use classes exists in libs
Author: z.raddani
Date created: 06 October 2018
Python Version: 2.7
Example : python /u01/bashes/BIPublisher/main.py report run RFND1600 '{"a":"a"}'
python main.py catalog trans RFND1600 report
python main.py schedule
'''
#import zeep
import sys
import re
import datetime
from libs import *
from libs import Report
from libs import Catalog
from libs import Schedule
from libs import Security
all_services = {'report' : {'run'}, 'catalog' : {'trans'},'schedule' : {}}
if __name__ == '__main__':
#try:
if sys.argv[1] == 'report':
if sys.argv[2] == 'run':
# 3: FND, 4: RFND1600, 5:/ISSUITE/, 6:pdf, 7:layout-def 8:stored_path, 9:user, 10:doc_file_name , 11:params => '{"p3":"v1","p1":"v2"}', 12:log_file_name
# report run FND RFND1600 /ISSUITE/ pdf def /u01/bashes/ irisa_radani abc '{"p3":"v1","p1":"v2"}' def.log
rep = Report.Report(sys.argv[3],sys.argv[4],sys.argv[5],sys.argv[6],sys.argv[7],sys.argv[8],sys.argv[9],sys.argv[10])
###########run report ################
if rep.run(sys.argv[11]):
log_info.info(log_id+rep.result)
else:
log_error.error(log_id+rep.result)
# make result file
#f = open(sys.argv[8] + sys.argv[12], "w")
f = open(log_path + sys.argv[12], "w")
f.write(rep.result)
f.close()
else:
log_error.error(log_id+'''Error:2nd parameter should be in ''' + json.dumps(list(all_services[sys.argv[1]])))
elif sys.argv[1] == 'schedule':
if sys.argv[2] == 'run':
# 3: FND, 4: RFND1600, 5:/ISSUITE/, 6:pdf, 7:layout-def 8:stored_path, 9:user, 10:doc_file_name , 11:params => '{"p3":"v1","p1":"v2"}', 12:start_date 13:log_file_name
# report run FND RFND1600 /ISSUITE/ pdf def /u01/bashes/ irisa_radani abc '{"p3":"v1","p1":"v2"}' '' def.log
############ schedule #############
sch = Schedule.Schedule(sys.argv[9])
if sch.run(sys.argv[3],sys.argv[4],sys.argv[5],sys.argv[6],sys.argv[7],sys.argv[8],sys.argv[10],sys.argv[11],sys.argv[12],sys.argv[13],sys.argv[14],sys.argv[15],sys.argv[16],sys.argv[17]):
log_info.info(log_id+sch.result)
else:
log_error.error(log_id+sch.result)
# make result file
#f = open(sys.argv[8] + sys.argv[18], "w")
f = open(log_path + sys.argv[18], "w")
f.write(sch.result)
f.close()
elif sys.argv[2] == 'history':
# 3: irisa_radani, 4:job_id, 5:out_path, 6: out_name, 7:log_name
sch = Schedule.Schedule(sys.argv[3])
if sch.job_history(sys.argv[4],sys.argv[5],sys.argv[6]):
log_info.info(log_id+sch.result)
else:
log_error.error(log_id+sch.result)
# make result file
#f = open(sys.argv[5] + sys.argv[7], "w")
f = open(log_path + sys.argv[7], "w")
f.write(sch.result)
f.close()
else:
log_error.error(log_id+'Error to choose type from '+ json.dumps(all_services.keys()))
# except:
# log_error.error('error')