示例#1
0
def play_file(filename):
    with open(filename) as fid:
        template_json = json.loads(fid.read())

    # Make sure instrument is available
    template_module = template_json['modules'][0]['module']
    instrument_id = template_module.split('.')[1]
    load_instrument(instrument_id)

    node = max(find_leaves(template_json))
    node_module = lookup_module(template_json['modules'][node]['module'])
    terminal = node_module.outputs[0]['id']

    #print(json.dumps(template_json, indent=2))

    template = Template(**template_json)
    template_config = {}
    target = node, terminal
    retval = process_template(template, template_config, target=target)
    export = retval.get_export()

    if export['values']:
        basename = export['values'][0].get('name', 'replay')
        ext = export['values'][0].get('file_suffix', '.refl') 
        filename = basename + ext
    else:
        filename = 'replay.dat'

    template_data = {
        'template': template_json,
        'node': node,
        'terminal': terminal,
        'server_git_hash': None,
        'server_mtime': None,
        #server_git_hash: result.server_git_hash,
        #server_mtime: new Date((result.server_mtime || 0.0) * 1000).toISOString()
    }
    first_line = '# ' + json.dumps({'template_data': template_data})[1:-1]
    new_content = '\n\n'.join(v['export_string'] for v in export['values'])
    with open(filename, 'wb') as file:
        print("writing", filename)
        file.write(encode(first_line))
        file.write(b'\n')
        file.write(encode(new_content))
示例#2
0
def play_file(filename):
    with open(filename) as fid:
        template_json = json.loads(fid.read())

    # Make sure instrument is available
    template_module = template_json['modules'][0]['module']
    instrument_id = template_module.split('.')[1]
    load_instrument(instrument_id)

    node = max(find_leaves(template_json))
    node_module = lookup_module(template_json['modules'][node]['module'])
    terminal = node_module.outputs[0]['id']

    #print(json.dumps(template_json, indent=2))

    template = Template(**template_json)
    template_config = {}
    target = node, terminal
    retval = process_template(template, template_config, target=target)
    export = retval.get_export()

    if export['values']:
        basename = export['values'][0].get('name', 'replay')
        ext = export['values'][0].get('file_suffix', '.refl')
        filename = basename + ext
    else:
        filename = 'replay.dat'

    template_data = {
        'template': template_json,
        'node': node,
        'terminal': terminal,
        'server_git_hash': None,
        'server_mtime': None,
        #server_git_hash: result.server_git_hash,
        #server_mtime: new Date((result.server_mtime || 0.0) * 1000).toISOString()
    }
    first_line = '# ' + json.dumps({'template_data': template_data})[1:-1]
    new_content = '\n\n'.join(v['export_string'] for v in export['values'])
    with open(filename, 'wb') as file:
        print("writing", filename)
        file.write(encode(first_line))
        file.write(b'\n')
        file.write(encode(new_content))
示例#3
0
def play_file(filename):
    export_type = 'column'
    concatenate = True

    with open(filename) as fid:
        json_data = json.loads(fid.read())

    if 'template_data' in json_data:
        template_data = json_data['template_data']
        if 'template_data' in template_data:
            # an extra nesting level for reasons unknown...
            warnings.warn(f"template_data is nested in template_data in {filename}")
            template_data = template_data['template_data']
        template = template_data['template']
        prepare_dataflow(template)
    else:
        template = json_data
        prepare_dataflow(template)

        #node = 0
        node = max(find_leaves(template))
        node_module = lookup_module(template['modules'][node]['module'])
        terminal = node_module.outputs[0]['id']
        revision = revision_info()
        template_data = {
            'template': template,
            'config': {},
            'node': node,
            'terminal': terminal,
            'server_git_hash': revision,
            'export_type': export_type,
        }

    output, export = run_template(template_data, concatenate=concatenate)

    if export:
        save_content(export['values'])
    plot_content(output)
示例#4
0
def play_file(filename):
    with open(filename) as fid:
        template_json = json.loads(fid.read())

    # Make sure instrument is available
    template_module = template_json['modules'][0]['module']
    instrument_id = template_module.split('.')[1]
    load_instrument(instrument_id)

    node = max(*find_leaves(template_json))
    node_module = lookup_module(template_json['modules'][node]['module'])
    terminal = node_module.outputs[0]['id']

    #print(json.dumps(template_json, indent=2))

    template = Template(**template_json)
    template_config = {}
    target = node, terminal
    retval = process_template(template, template_config, target=target)
    export = retval.get_export()

    template_data = {
        'template': template_json,
        'node': node,
        'terminal': terminal,
        'server_git_hash': None,
        'server_mtime': None,
        #server_git_hash: result.server_git_hash,
        #server_mtime: new Date((result.server_mtime || 0.0) * 1000).toISOString()
    }
    first_line = '# ' + json.dumps({'template_data': template_data})[1:-1]
    with open('replay.dat', 'wb') as file:
        print(first_line, file=file)
        for section in export['values']:
            print(section, file=file)
            print(file=file)
示例#5
0
def diag_to_WireIt_str(diagram):
    underlying_module = core.lookup_module('joinMod')
    print underlying_module.icon
    diag_str = ''
示例#6
0
def diag_to_WireIt_str(diagram):
	underlying_module = core.lookup_module('joinMod')
	print underlying_module.icon	
	diag_str = ''