Example #1
0
    def __create(self, args):
        result = {"status": "success", "msg": "创建文件成功"}
        user_path = self.app.config[
            "AUTO_HOME"] + "/workspace/%s/%s/%s/%s%s" % (
                session["username"], args["project_name"], args["suite_name"],
                args["name"], args["category"])
        if not exists_path(user_path):
            make_nod(user_path)
        else:
            result["status"] = "fail"
            result["msg"] = "文件名称重复,创建失败"

        return result
Example #2
0
def reset_next_build_numb(output):
    next_build_number = output + "/nextBuildNumber"
    index = 1
    data = "%d" % (index + 1)
    if not exists_path(next_build_number):
        make_nod(next_build_number)
    else:
        index = int(read_file(next_build_number)["data"])
        data = "%d" % (index + 1)
    write_file(next_build_number, data)

    out = output + "/%d" % index
    if not exists_path(output):
        mk_dirs(output)

    return (out, index)
Example #3
0
    def __create(self, args):

        self.log.info("***create***name:{} **cat:{}".format(
            args['name'], args['category']))
        if args['name'].endswith(args['category']):
            args['name'] = args['name'].split('.')[0]
        if args['category'] == '.oth':
            user_path = args["key"] + '/' + args['name']
        else:
            user_path = args["key"] + '/' + args['name'] + args['category']

        result = {
            "status": "success",
            "msg":
            "创建测试模型成功" + ":" + os.path.basename(user_path) + ":" + user_path
        }
        if not exists_path(user_path):
            make_nod(user_path)
            mod = '''
{ "class": "GraphLinksModel",
  "nodeKeyProperty": "id",
  "linkKeyProperty": "key",
  "nodeDataArray": [ 
    {"id":-1, "loc":"-256 -210", "category":"Start", "text":"开始节点", "description":"这里也可以定义变量", "outputvariable":"产品列表", "disabled":false, "properties":""},
    {"id":0, "loc":"-113 -126", "text":"Shopping页", "description":"", "outputvariable":"", "disabled":false, "properties":"产品列表=产品列表"},
    {"id":2, "loc":"82 -127", "text":"购买", "description":"", "outputvariable":"", "disabled":false, "properties":"购物列表=手表"},
    {"text":"页面关闭", "id":-5, "loc":"71.0 -74.0"}
  ],
  "linkDataArray": [ 
    {"key":-1, "from":-1, "to":0, "text":"打开网站", "points":[-187,-166,-161,-159,-140,-146,-124,-126], "description":"", "parameters":"", "mainpath":true},
    {"key":0, "from":0, "to":2, "progress":"true", "text":"买手表", "points":[-70,-122,-30,-131,13,-131,60,-118], "description":"", "parameters":"手表", "weight":"2.0", "mainpath":true, "action":"buy"},
    {"key":1, "from":0, "to":-5, "points":[-70,-111,-27,-111,13,-98,49,-74], "text":"关闭", "description":"", "action":"close", "parameters":"window", "mainpath":false}
  ],
  "modelData": {"version":1, "nodes":4, "links":3, "actions":3, "variables":5, "variable":[], "init_actions":"模块的初始化条件"}
}
            '''
            with open(user_path, 'w') as f:
                f.write(mod)
        else:
            result["status"] = "fail"
            result["msg"] = "失败: 文件已存在 !"

        self.app.config['DB'].insert_loginfo(session['username'], 'model',
                                             'create', user_path,
                                             result['status'])

        return result
Example #4
0
def reset_last_status(result, output, index):
    stats = result.statistics
    fail = stats.total.critical.failed

    last_fail = output + "/lastFail"
    last_passed = output + "/lastPassed"
    data = "%d" % index

    if fail != 0:
        if not exists_path(last_fail):
            make_nod(last_fail)

        write_file(last_fail, data)
    else:
        if not exists_path(last_passed):
            make_nod(last_passed)
        write_file(last_passed, data)
Example #5
0
    def reset_last_status(self, index):
        stats = self.result.statistics
        fail = stats.total.critical.failed

        lock = threading.Lock()

        lock.acquire()
        last_fail = self.output + "/lastFail"
        last_passed = self.output + "/lastPassed"
        data = "%d" % index

        if fail != 0:
            if not exists_path(last_fail):
                make_nod(last_fail)

            write_file(last_fail, data)
        else:
            if not exists_path(last_passed):
                make_nod(last_passed)
            write_file(last_passed, data)

        lock.release()
Example #6
0
    def __create(self, args):
        result = {"status": "success", "msg": "创建用户成功"}
        user_path = self.app.config["AUTO_HOME"] + "/users/%s" % (
            args["username"])
        if not exists_path(user_path):
            mk_dirs(user_path)

            make_nod(user_path + "/config.json")

            user = {
                "fullname": args["fullname"],
                "email": args["email"],
                "passwordHash": generate_password_hash(args["password"]),
                "data": []
            }
            json.dump(user,
                      codecs.open(user_path + '/config.json', 'w', 'utf-8'))
        else:
            result["status"] = "fail"
            result["msg"] = "用户名称重复,创建失败"

        return result
Example #7
0
    def __create(self, args):

        if args['name'].endswith(args['category']):
            args['name'] = args['name'].split('.')[0]
        if args['category'] == '.oth':
            user_path = args["key"] + '/' + args['name']
        else:
            user_path = args["key"] + '/' + args['name'] + args['category']

        result = {
            "status": "success",
            "msg": "创建成功" + ":" + os.path.basename(user_path) + ":" + user_path
        }
        if not exists_path(user_path):
            make_nod(user_path)
        else:
            result["status"] = "fail"
            result["msg"] = "失败: 文件已存在 !"

        self.app.config['DB'].insert_loginfo(session['username'], 'suite',
                                             'create', user_path,
                                             result['status'])

        return result
Example #8
0
    def __smtp(self, args):
        result = {"status": "success", "msg": "Config smtp success."}
        conf_path = self.app.config["AUTO_HOME"] + "/auto.json"
        if not exists_path(conf_path):
            make_nod(conf_path)
        try:
            config = json.load(codecs.open(conf_path, 'r', 'utf-8'))
            config["smtp"]["ssl"] = args["ssl"]
            config["smtp"]["server"] = args["server"]
            config["smtp"]["port"] = args["port"]
            config["smtp"]["username"] = args["username"]
            config["smtp"]["password"] = args["password"]
            json.dump(config, codecs.open(conf_path, 'w', 'utf-8'))

            self.app.config["MAIL_SERVER"] = args["server"]
            self.app.config["MAIL_PORT"] = args["port"]
            self.app.config["MAIL_USERNAME"] = args["username"]
            self.app.config["MAIL_PASSWORD"] = args["password"]
            self.app.config["MAIL_USE_SSL"] = args["ssl"]
        except Exception as e:
            result["status"] = "fail"
            result["msg"] = str(e)

        return result