Example #1
0
def generateConfig(req):
    try:
        conf = BuildConfig(defaultconfig)
        conf.importForm(req.form)
        return "0\n" + conf.getValuesString()
    except Exception as e:
        return "-1\nFailed to parse config!\n" + str(e);
Example #2
0
def buildHexFile(req):
    hash = makeConfigHash(req.form)

    ret = 0
    stderr = ""
    output = ""

    if not hasCache(hash):
        conf = None
        try:
            conf = BuildConfig(defaultconfig)
            conf.importForm(req.form)

            import builder
            ret, output, stderr = builder.build(basedir, os.path.join(cachedir, hash), conf);
        except Exception as e:
            ret = -1
            stderr = "Failed to parse config!\n" + str(e)

    res = str(ret) + "\n"
    if ret == 0:
        res += hash
    else:
        res += output + stderr
    return res