diff --git a/schain-cli/asdasd.py b/schain-cli/asdasd.py new file mode 100644 index 0000000..ca5629d --- /dev/null +++ b/schain-cli/asdasd.py @@ -0,0 +1,34 @@ +from schainpy.controller import Project + +desc = "asdasddsad" + +controller = Project() +controller.setup(id='191', name="asdasd", description=desc) + +readUnitConf = controller.addReadUnit(datatype='VoltageReader', + path="/home/nanosat/schain/schain-cli", + startDate="1970/01/01", + endDate="2017/12/31", + startTime="00:00:00", + endTime="23:59:59", + online=0, + verbose=1, + walk=1, + ) + +procUnitConf1 = controller.addProcUnit(datatype='VoltageProc', inputId=readUnitConf.getId()) + +opObj11 = procUnitConf1.addOperation(name='ProfileSelector', optype='other') +opObj11.addParameter(name='profileRangeList', value='120,183', format='intlist') + +opObj11 = procUnitConf1.addOperation(name='RTIPlot', optype='other') +opObj11.addParameter(name='wintitle', value='Jicamarca Radio Observatory', format='str') +opObj11.addParameter(name='showprofile', value='0', format='int') +opObj11.addParameter(name='xmin', value='0', format='int') +opObj11.addParameter(name='xmax', value='24', format='int') +opObj11.addParameter(name='figpath', value="/home/nanosat/schain/schain-cli/figs", format='str') +opObj11.addParameter(name='wr_period', value='5', format='int') +opObj11.addParameter(name='exp_code', value='22', format='int') + + +controller.start() diff --git a/schain-cli/schain.xml b/schain-cli/schain.xml index 304456a..baf01d2 100644 --- a/schain-cli/schain.xml +++ b/schain-cli/schain.xml @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/schain-cli/schaincli/cli.py b/schain-cli/schaincli/cli.py index 2fd6978..2248ed7 100644 --- a/schain-cli/schaincli/cli.py +++ b/schain-cli/schaincli/cli.py @@ -3,7 +3,9 @@ import schainpy import subprocess from multiprocessing import cpu_count from schaincli import templates -import os, sys +import os +import sys +import glob def print_version(ctx, param, value): if not value or ctx.resilient_parsing: @@ -14,9 +16,10 @@ def print_version(ctx, param, value): @click.command() @click.option('--version', '-v', is_flag=True, callback=print_version, help='SChain version', type=str) -@click.option('--xml', '-x', default=None, help='xml file', type=click.Path(exists=True, resolve_path=True)) +@click.option('--xml', '-x', default=None, help='run an XML file', type=click.Path(exists=True, resolve_path=True)) @click.argument('command', default='run', required=True) -def main(command, version, xml): +@click.argument('nextcommand', default=None, required=False, type=click.Path(exists=True, resolve_path=True)) +def main(command, nextcommand, version, xml): """COMMAND LINE INTERFACE FOR SIGNAL CHAIN - JICAMARCA RADIO OBSERVATORY""" if xml is not None: subprocess.call(['schain --file=' + xml], shell=True) @@ -24,8 +27,21 @@ def main(command, version, xml): generate() elif command == 'test': test() + elif command == 'run': + if nextcommand is None: + currentfiles = glob.glob('./*.py') + numberfiles = len(currentfiles) + print currentfiles + if numberfiles > 1: + click.echo('\x1b[6;37;41m[ERROR] - There is more than one file to run\x1b[0m') + elif numberfiles == 1: + subprocess.call(['python ' + currentfiles[0]], shell=True) + else: + click.echo('\x1b[6;37;41m[ERROR] - There is no file to run.\x1b[0m') + else: + subprocess.call(['python ' + nextcommand], shell=True) else: - click.echo('\x1b[0;37;41m[ERROR] - Command is not defined.\x1b[0m') + click.echo('\x1b[6;37;41m[ERROR] - Command is not defined.\x1b[0m') def basicInputs(): inputs = {} @@ -51,9 +67,9 @@ def generate(): script = open(scriptname, 'w') try: script.write(current) - click.echo('\x1b[0;37;42m[SUCCESS] Script {file} generated\x1b[0m'.format(file=scriptname)) + click.echo('\x1b[6;37;42m[SUCCESS] Script {file} generated\x1b[0m'.format(file=scriptname)) except Exception as e: - click.echo('\x1b[0;37;41m[ERROR] I cannot create the file. Do you have writing permissions?\x1b[0m') + click.echo('\x1b[6;37;41m[ERROR] I cannot create the file. Do you have writing permissions?\x1b[0m') def test(): diff --git a/schain-cli/schaincli/templates.py b/schain-cli/schaincli/templates.py index 748ab72..ce08f4c 100644 --- a/schain-cli/schaincli/templates.py +++ b/schain-cli/schaincli/templates.py @@ -44,8 +44,8 @@ def fiber(cursor, skip, q, day): readUnitConf = controller.addReadUnit(datatype='SpectraReader', path="{path}", - startDate="day", - endDate="day", + startDate=day, + endDate=day, startTime="{startHour}", endTime="{endHour}", online=0, diff --git a/schainpy/scripts/project.py b/schainpy/scripts/project.py new file mode 100644 index 0000000..17237bd --- /dev/null +++ b/schainpy/scripts/project.py @@ -0,0 +1,33 @@ +from schainpy.controller import Project + +desc = "A schain project" + +controller = Project() +controller.setup(id='191', name="project", description=desc) + +readUnitConf = controller.addReadUnit(datatype='VoltageReader', + path="/home/nanosat/schain/schainpy/scripts", + startDate="1970/01/01", + endDate="2017/12/31", + startTime="00:00:00", + endTime="23:59:59", + online=0, + walk=1, + ) + +procUnitConf1 = controller.addProcUnit(datatype='VoltageProc', inputId=readUnitConf.getId()) + +opObj11 = procUnitConf1.addOperation(name='ProfileSelector', optype='other') +opObj11.addParameter(name='profileRangeList', value='120,183', format='intlist') + +opObj11 = procUnitConf1.addOperation(name='RTIPlot', optype='other') +opObj11.addParameter(name='wintitle', value='Jicamarca Radio Observatory', format='str') +opObj11.addParameter(name='showprofile', value='0', format='int') +opObj11.addParameter(name='xmin', value='0', format='int') +opObj11.addParameter(name='xmax', value='24', format='int') +opObj11.addParameter(name='figpath', value="/home/nanosat/schain/schainpy/scripts/figs", format='str') +opObj11.addParameter(name='wr_period', value='5', format='int') +opObj11.addParameter(name='exp_code', value='22', format='int') + + +controller.start()