Ejemplo n.º 1
0
def compile_script(scriptfile):
    _log.debug("Compiling %s ..." % file)
    from calvin.Tools import cscompiler
    app_info, errors, _ = cscompiler.compile_file(scriptfile)
    if errors:
        _log.error("{reason} {script} [{line}:{col}]".format(script=file, **errors[0]))
        return False
    return app_info
Ejemplo n.º 2
0
def compile_script(scriptfile):
    _log.debug("Compiling %s ..." % file)
    from calvin.Tools import cscompiler
    app_info, errors, _ = cscompiler.compile_file(scriptfile)
    if errors:
        _log.error("{reason} {script} [{line}:{col}]".format(script=file,
                                                             **errors[0]))
        return False
    return app_info
Ejemplo n.º 3
0
def compile_script(scriptfile, credentials):
    _log.debug("Compiling %s ..." % scriptfile)
    from calvin.Tools.cscompiler import compile_file
    app_info, issuetracker = compile_file(scriptfile, credentials)
    if issuetracker.error_count:
        fmt = "{type!c}: {reason} {script} {line}:{col}"
        for error in issuetracker.formatted_errors(sort_key='line', custom_format=fmt, script=scriptfile, line=0, col=0):
            _log.error(error)
        return False
    return app_info
Ejemplo n.º 4
0
def compile_script(scriptfile, credentials):
    _log.debug("Compiling %s ..." % scriptfile)
    from calvin.Tools.cscompiler import compile_file
    app_info, issuetracker = compile_file(scriptfile, False, False, credentials)
    if issuetracker.error_count:
        fmt = "{type!c}: {reason} {script} {line}:{col}"
        for error in issuetracker.formatted_errors(sort_key='line', custom_format=fmt, script=scriptfile, line=0, col=0):
            _log.error(error)
        return False
    return app_info
Ejemplo n.º 5
0
    def testFileScript(self):
        scriptname = 'test1'
        scriptfile = absolute_filename("scripts/%s.calvin" % (scriptname, ))
        app_info, errors, warnings = compiler.compile_file(scriptfile)
        d = deployer.Deployer(self.rt1, app_info)
        d.deploy()
        time.sleep(1)
        src = d.actor_map['%s:src' % scriptname]
        snk = d.actor_map['%s:snk' % scriptname]

        actual = utils.report(self.rt1, snk)
        self.assert_lists_equal(range(1, 20), actual)
    def testFileScript(self):
        scriptname = 'test1'
        scriptfile = absolute_filename("scripts/%s.calvin" % (scriptname, ))
        app_info, errors, warnings = compiler.compile_file(scriptfile)
        d = deployer.Deployer(self.rt1, app_info)
        d.deploy()
        time.sleep(1)
        src = d.actor_map['%s:src' % scriptname]
        snk = d.actor_map['%s:snk' % scriptname]

        actual = utils.report(self.rt1, snk)
        self.assert_lists_equal(range(1, 20), actual)
Ejemplo n.º 7
0
def _codegen(testname, ds, credentials):
    test_file = _filepath(testname, "calvin")
    # code, issuetracker = compile_file(filename, ds, ir, credentials=None)
    code, it = compile_file(test_file, ds, ir=False, credentials=credentials)
    code = json.loads(json.dumps(code)) # FIXME: Is there no other way of making this unicode???
    ref_file = _filepath(testname, "deployjson" if ds else "ref")
    ref_code = _read_file(ref_file)
    # print "ref_code", type(ref_code)
    ref_code = json.loads(ref_code)
    ref_code.setdefault('valid', True)
    # print code, ref_code

    return code, it, ref_code
Ejemplo n.º 8
0
def _codegen(testname, ds, credentials):
    test_file = _filepath(testname, "calvin")
    # code, issuetracker = compile_file(filename, ds, ir, credentials=None)
    code, it = compile_file(test_file, ds, ir=False, credentials=credentials)
    code = json.loads(json.dumps(
        code))  # FIXME: Is there no other way of making this unicode???
    ref_file = _filepath(testname, "deployjson" if ds else "ref")
    ref_code = _read_file(ref_file)
    # print "ref_code", type(ref_code)
    ref_code = json.loads(ref_code)
    ref_code.setdefault('valid', True)
    # print code, ref_code

    return code, it, ref_code
Ejemplo n.º 9
0
def visualize_deployment(filename):
    deployable, errors, warnings = cscompiler.compile_file(filename)
    return AppViz(deployable).render()