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