def parse_rpn_value(value, variable_list): variables = {x['name']: x['value'] for x in variable_list} depends = build_variable_dependency(value, variables, []) #TODO(robnagler) scan variable values for strings. Need to be parsable var_list = ' '.join( map(lambda x: '{} sto {}'.format(variables[x], x), depends)) #TODO(pjm): security - need to scrub field value # execn send top of string stack to UNIX and put result on numerical stack # execs send top of string stack to UNIX and put output on string stack # csh start and enter C shell subprocess # cshs send top of string stack to C shell # gets get string from input file # seems like this would be bad, because you could construct a string that could be executed # mudf make user defined function from string stack (name commands mudf) # open open input/output file # puts put string to file # sleep sleep for number of seconds # @ push command input file pkdc('rpn variables={} expr="{}"', var_list, value) out = elegant_common.subprocess_output( ['rpnl', '{} {}'.format(var_list, value)]) if out is None: return None, 'invalid' if len(out): return float(out.strip()), None return None, 'empty'
def _sdds(filename): path = run_dir.join(filename) assert path.check(file=True, exists=True), \ '{}: not found'.format(path) if not options.suffix: with open(str(path)) as f: return path.basename, f.read(), 'application/octet-stream' if options.suffix == 'csv': out = elegant_common.subprocess_output(['sddsprintout', '-columns', '-spreadsheet=csv', str(path)]) assert out, \ '{}: invalid or empty output from sddsprintout'.format(path) return path.purebasename + '.csv', out, 'text/csv' raise AssertionError('{}: invalid suffix for download path={}'.format(options.suffix, path))
def _sdds(filename): path = run_dir.join(filename) assert path.check(file=True, exists=True), \ '{}: not found'.format(path) if not options.suffix: with open(str(path)) as f: return path.basename, f.read(), 'application/octet-stream' if options.suffix == 'csv': out = elegant_common.subprocess_output( ['sddsprintout', '-columns', '-spreadsheet=csv', str(path)]) assert out, \ '{}: invalid or empty output from sddsprintout'.format(path) return path.purebasename + '.csv', out, 'text/csv' raise AssertionError('{}: invalid suffix for download path={}'.format( options.suffix, path))
def _sdds(filename): path = run_dir.join(filename) assert path.check(file=True, exists=True), \ '{}: not found'.format(path) if not options.suffix: return path if options.suffix == 'csv': out = elegant_common.subprocess_output( ['sddsprintout', '-columns', '-spreadsheet=csv', str(path)]) assert out, \ '{}: invalid or empty output from sddsprintout'.format(path) return PKDict( uri=path.purebasename + '.csv', content=out, ) raise AssertionError('{}: invalid suffix for download path={}'.format( options.suffix, path))
def parse_rpn_value(value, variable_list): variables = {x['name']: x['value'] for x in variable_list} depends = build_variable_dependency(value, variables, []) #TODO(robnagler) scan variable values for strings. Need to be parsable var_list = ' '.join(map(lambda x: '{} sto {}'.format(variables[x], x), depends)) #TODO(pjm): security - need to scrub field value # execn send top of string stack to UNIX and put result on numerical stack # execs send top of string stack to UNIX and put output on string stack # csh start and enter C shell subprocess # cshs send top of string stack to C shell # gets get string from input file # seems like this would be bad, because you could construct a string that could be executed # mudf make user defined function from string stack (name commands mudf) # open open input/output file # puts put string to file # sleep sleep for number of seconds # @ push command input file pkdc('rpn variables={} expr="{}"', var_list, value) out = elegant_common.subprocess_output(['rpnl', '{} {}'.format(var_list, value)]) if out is None: return None, 'invalid' if len(out): return float(out.strip()), None return None, 'empty'