-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
55 lines (47 loc) · 1.7 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
import sys
import argparse
from pprint import pprint
from workflow import loadConfig
from os import path
UNDERLINE = ('\n' + '-'*100)
def main(config):
"""
This is the main runner
:return:
"""
# pprint(config)
for step in config['Steps']:
print "\n\n"
print "Doing '{1}' step: {0}".format(step['attr']['name'], step['attr']['type']) + UNDERLINE
if 'Cmd' in step:
print " Executing: {0} with arguments:".format(step['Cmd']['Value'])
if 'Cwd' in step:
print " in folder: {0}".format(step['Cwd']['Value'])
if 'Module' in step:
print " in python Module: {0}".format(step['Module']['Value'])
if 'items' in step['Args']:
print " with arguments:"
for arg in step['Args']['items']:
print ' {0} --> {1}'.format(arg['attr']['id'], arg['attr']['type'])
"""
This function handles the argument parsing and calls our main function
"""
if __name__ == '__main__':
#parse command line options
parser = argparse.ArgumentParser()
parser.add_argument('input_xml',
help='Path to the input GCD (xml) file.',
type=argparse.FileType('r'))
parser.add_argument('--workflow', type=argparse.FileType('r'), default=path.join('xml', 'SAMPLEWorkflow.xml'),
help='Path to the workflow GCD file (optional)')
args = parser.parse_args()
print args
try:
# Load the XML into a simple dictionary
config = loadConfig(args.workflow)
# Now kick things off
main(config)
except:
print 'Unxexpected error: {0}'.format(sys.exc_info()[0])
raise
sys.exit(0)