@@ -31,18 +31,17 PREFIX = 'experiment' | |||||
31 |
|
31 | |||
32 | @click.command() |
|
32 | @click.command() | |
33 | @click.option('--version', '-v', is_flag=True, callback=print_version, help='SChain version', type=str) |
|
33 | @click.option('--version', '-v', is_flag=True, callback=print_version, help='SChain version', type=str) | |
34 | @click.option('--xml', '-x', default=None, help='run an XML file', type=click.Path(exists=True, resolve_path=True)) |
|
|||
35 | @click.argument('command', default='run', required=True) |
|
34 | @click.argument('command', default='run', required=True) | |
36 | @click.argument('nextcommand', default=None, required=False, type=str) |
|
35 | @click.argument('nextcommand', default=None, required=False, type=str) | |
37 |
def main(command, nextcommand, version |
|
36 | def main(command, nextcommand, version): | |
38 | """COMMAND LINE INTERFACE FOR SIGNAL CHAIN - JICAMARCA RADIO OBSERVATORY \n |
|
37 | """COMMAND LINE INTERFACE FOR SIGNAL CHAIN - JICAMARCA RADIO OBSERVATORY \n | |
39 | Available commands.\n |
|
38 | Available commands.\n | |
40 | --xml: runs a schain XML generated file\n |
|
39 | --xml: runs a schain XML generated file\n | |
41 | run: runs any python script starting 'experiment_'\n |
|
40 | run: runs any python script starting 'experiment_'\n | |
42 | generate: generates a template schain script\n |
|
41 | generate: generates a template schain script\n | |
43 | search: return avilable operations, procs or arguments of the give operation/proc\n""" |
|
42 | search: return avilable operations, procs or arguments of the give operation/proc\n""" | |
44 | if xml is not None: |
|
43 | if command == 'xml': | |
45 |
runFromXML( |
|
44 | runFromXML(nextcommand) | |
46 | elif command == 'generate': |
|
45 | elif command == 'generate': | |
47 | generate() |
|
46 | generate() | |
48 | elif command == 'test': |
|
47 | elif command == 'test': | |
@@ -54,6 +53,7 def main(command, nextcommand, version, xml): | |||||
54 | else: |
|
53 | else: | |
55 | log.error('Command {} is not defined'.format(command)) |
|
54 | log.error('Command {} is not defined'.format(command)) | |
56 |
|
55 | |||
|
56 | ||||
57 | def check_module(possible, instance): |
|
57 | def check_module(possible, instance): | |
58 | def check(x): |
|
58 | def check(x): | |
59 | try: |
|
59 | try: | |
@@ -77,19 +77,23 def search(nextcommand): | |||||
77 | log.error('There is no Operation/ProcessingUnit to search') |
|
77 | log.error('There is no Operation/ProcessingUnit to search') | |
78 | elif nextcommand == 'procs': |
|
78 | elif nextcommand == 'procs': | |
79 | procs = paramsFinder.getProcs() |
|
79 | procs = paramsFinder.getProcs() | |
80 | log.success('Current ProcessingUnits are:\n\033[1m{}\033[0m'.format('\n'.join(procs))) |
|
80 | log.success( | |
|
81 | 'Current ProcessingUnits are:\n\033[1m{}\033[0m'.format('\n'.join(procs))) | |||
81 |
|
82 | |||
82 | elif nextcommand == 'operations': |
|
83 | elif nextcommand == 'operations': | |
83 | operations = paramsFinder.getOperations() |
|
84 | operations = paramsFinder.getOperations() | |
84 |
log.success('Current Operations are:\n\033[1m{}\033[0m'.format( |
|
85 | log.success('Current Operations are:\n\033[1m{}\033[0m'.format( | |
|
86 | '\n'.join(operations))) | |||
85 | else: |
|
87 | else: | |
86 | try: |
|
88 | try: | |
87 | args = paramsFinder.getArgs(nextcommand) |
|
89 | args = paramsFinder.getArgs(nextcommand) | |
88 | log.warning('Use this feature with caution. It may not return all the allowed arguments') |
|
90 | log.warning( | |
|
91 | 'Use this feature with caution. It may not return all the allowed arguments') | |||
89 | if len(args) == 0: |
|
92 | if len(args) == 0: | |
90 | log.success('{} has no arguments'.format(nextcommand)) |
|
93 | log.success('{} has no arguments'.format(nextcommand)) | |
91 | else: |
|
94 | else: | |
92 |
log.success('Showing arguments |
|
95 | log.success('Showing {} arguments:\n\033[1m{}\033[0m'.format( | |
|
96 | nextcommand, '\n'.join(args))) | |||
93 | except Exception as e: |
|
97 | except Exception as e: | |
94 | log.error('Module {} does not exists'.format(nextcommand)) |
|
98 | log.error('Module {} does not exists'.format(nextcommand)) | |
95 | allModules = paramsFinder.getAll() |
|
99 | allModules = paramsFinder.getAll() | |
@@ -117,12 +121,18 def runschain(nextcommand): | |||||
117 |
|
121 | |||
118 | def basicInputs(): |
|
122 | def basicInputs(): | |
119 | inputs = {} |
|
123 | inputs = {} | |
120 | inputs['desc'] = click.prompt('Enter a description', default="A schain project", type=str) |
|
124 | inputs['desc'] = click.prompt( | |
121 | inputs['name'] = click.prompt('Name of the project', default="project", type=str) |
|
125 | 'Enter a description', default="A schain project", type=str) | |
122 | inputs['path'] = click.prompt('Data path', default=os.getcwd(), type=click.Path(exists=True, resolve_path=True)) |
|
126 | inputs['name'] = click.prompt( | |
123 | inputs['startDate'] = click.prompt('Start date', default='1970/01/01', type=str) |
|
127 | 'Name of the project', default="project", type=str) | |
124 |
inputs[' |
|
128 | inputs['path'] = click.prompt('Data path', default=os.getcwd( | |
125 | inputs['startHour'] = click.prompt('Start hour', default='00:00:00', type=str) |
|
129 | ), type=click.Path(exists=True, resolve_path=True)) | |
|
130 | inputs['startDate'] = click.prompt( | |||
|
131 | 'Start date', default='1970/01/01', type=str) | |||
|
132 | inputs['endDate'] = click.prompt( | |||
|
133 | 'End date', default='2017/12/31', type=str) | |||
|
134 | inputs['startHour'] = click.prompt( | |||
|
135 | 'Start hour', default='00:00:00', type=str) | |||
126 | inputs['endHour'] = click.prompt('End hour', default='23:59:59', type=str) |
|
136 | inputs['endHour'] = click.prompt('End hour', default='23:59:59', type=str) | |
127 | inputs['figpath'] = inputs['path'] + '/figs' |
|
137 | inputs['figpath'] = inputs['path'] + '/figs' | |
128 | return inputs |
|
138 | return inputs | |
@@ -132,7 +142,8 def generate(): | |||||
132 | inputs = basicInputs() |
|
142 | inputs = basicInputs() | |
133 | inputs['multiprocess'] = click.confirm('Is this a multiprocess script?') |
|
143 | inputs['multiprocess'] = click.confirm('Is this a multiprocess script?') | |
134 | if inputs['multiprocess']: |
|
144 | if inputs['multiprocess']: | |
135 |
inputs['nProcess'] = click.prompt( |
|
145 | inputs['nProcess'] = click.prompt( | |
|
146 | 'How many process?', default=cpu_count(), type=int) | |||
136 | current = templates.multiprocess.format(**inputs) |
|
147 | current = templates.multiprocess.format(**inputs) | |
137 | else: |
|
148 | else: | |
138 | current = templates.basic.format(**inputs) |
|
149 | current = templates.basic.format(**inputs) |
General Comments 0
You need to be logged in to leave comments.
Login now