def _parse_file(filepath):
    source_text, line_offset = get_source(filepath)
    appname = os.environ.get('TM_FILENAME', 'untitled')
    # Prevent . from appearing in appname (crashes deployer)
    appname = appname.split('.')[0]
    deployable, issuetracker = calvin_codegen(source_text, appname)
    return deployable, issuetracker, line_offset
Esempio n. 2
0
def app_from_script(script, script_name):
    deployable, issuetracker = calvin_codegen(script, script_name, verify=False)
    errors = issuetracker.errors(sort_key='reason')
    warnings = issuetracker.warnings(sort_key='reason')
    if errors:
        return {}, errors, warnings

    actors = {}
    for name, setup in deployable['actors'].iteritems():
        a_type = setup['actor_type']
        a_args = setup['args']
        a_args.update({"name":name}) # Optional, for human readability only
        a = create_actor(a_type, a_args)
        actors[name] = a

    for src, dests in deployable['connections'].iteritems():
        for dest in dests:
            a_name, p_name = src.split('.')
            outport = actors[a_name].outports[p_name]
            # FIXME: setup port properties (queue) from deployable info
            outport.set_queue(queue.fanout_fifo.FanoutFIFO({'queue_length': 4, 'direction': "out"}, {}))

            a_name, p_name = dest.split('.')
            inport = actors[a_name].inports[p_name]
            # FIXME: setup port properties (queue) from deployable info
            inport.set_queue(queue.fanout_fifo.FanoutFIFO({'queue_length': 4, 'direction': "in"}, {}))

            outport.attach_endpoint(LocalOutEndpoint(outport, inport))
            inport.attach_endpoint(LocalInEndpoint(inport, outport))


    return actors, errors, warnings
Esempio n. 3
0
    def parse(self, test, source_text=None, verify=True):
        if not source_text:
            test = self.test_script_dir + test + '.calvin'
            source_text = self._read_file(test)

        deployable, issuetracker = calvin_codegen(source_text, test, verify=verify)
        errors = issuetracker.errors(sort_key='reason')
        warnings = issuetracker.warnings(sort_key='reason')

        return deployable, errors, warnings