Beispiel #1
0
 def get(self):
     unique_id = self.get_argument("job").encode("utf-8")
     param = {"id": unique_id}
     mysql = mysqlLib()
     datalist = mysql.query_task(param)
     mysql.close()
     # print datalist
     datalist_info = {}
     datalist_info["submit"] = datalist[0][1]
     datalist_info["url"] = datalist[0][2]
     datalist_info["jobname"] = datalist[0][3]
     datalist_info["status"] = datalist[0][5]
     datalist_info["build_number"] = datalist[0][6]
     # print datalist_info
     cmdstr = (
         "curl "
         + datalist_info["url"]
         + "job/"
         + datalist_info["jobname"]
         + "/"
         + str(datalist_info["build_number"])
         + "/logText/progressiveText?start=0"
     )
     # print cmdstr
     if datalist_info["status"] == 3 or datalist_info["status"] == 4:
         status, output = cmd_execute(cmdstr)
     else:
         output = "INFO, job is running now"
     datalist_info["output"] = output
     self.write(json.dumps(datalist_info))
Beispiel #2
0
    def post(self):
        post_param = urlparse.parse_qs(self.request.body, True)
        limit = int(post_param['limit'][0])
        offset = int(post_param['offset'][0])
        belong = post_param['belong'][0]

        param = {"belong": belong, "limit": limit, "offset": offset}
        mysql = mysqlLib()
        serverlist = mysql.query_server(param)

        param = {"belong": belong}
        server_totalcnt = mysql.query_server_totalcnt(param)
        mysql.close()

        serverlist_info = {}
        serverlist_info['server_totalcnt'] = server_totalcnt
        ret_dict = []
        for index, item in enumerate(serverlist):
            sub_ret_dict = {}
            sub_ret_dict['id'] = str(int(item[0]))
            sub_ret_dict['name'] = item[1]
            sub_ret_dict['ip'] = item[2]
            sub_ret_dict['workspace'] = item[3]
            sub_ret_dict['belong'] = item[4]
            sub_ret_dict['descpt'] = item[5]
            ret_dict.append(sub_ret_dict)
        serverlist_info['ret_dict'] = ret_dict

        self.write(json.dumps(serverlist_info))
    def post(self):
        post_param=urlparse.parse_qs(self.request.body,True)
        limit=int(post_param['limit'][0])
        offset=int(post_param['offset'][0])
        belong=post_param['belong'][0]

        param={"limit":limit,"offset":offset}
        mysql=mysqlLib()
        tasklist=mysql.query_task(param)

        param={}
        task_totalcnt=mysql.query_task_totalcnt(param)
        mysql.close()

        serverlist_info={}
        serverlist_info['task_totalcnt']=task_totalcnt
        ret_dict=[]
        for index,item in enumerate(tasklist):
            sub_ret_dict={}
            sub_ret_dict['id']=str(int(item[0]))
            sub_ret_dict['submit']=item[1]
            sub_ret_dict['jenkinsurl']=item[2]
            sub_ret_dict['jobname']=item[3]
            sub_ret_dict['build_params']=item[4]
            sub_ret_dict['status']=item[5]
            sub_ret_dict['build_number']=item[6]
            ret_dict.append(sub_ret_dict)
        serverlist_info['ret_dict']=ret_dict

        self.write(json.dumps(serverlist_info))
Beispiel #4
0
    def post(self):
        param = {}
        mysql = mysqlLib()
        downloadstat_week = mysql.query_downloadstat(1, param)
        downloadstat_all = mysql.query_downloadstat(0, param)
        mysql.close()

        datalist_info = {}
        ret_dict = []
        tmp = {}
        for index, item in enumerate(downloadstat_week):
            tmp[int(item[0])] = int(item[1])
        for i in xrange(1, 5):
            if (i not in tmp):
                ret_dict.append(0)
            else:
                ret_dict.append(tmp[i])
        datalist_info['week'] = ret_dict

        ret_dict = []
        for index, item in enumerate(downloadstat_all):
            ret_dict.append(int(item[1]))
        datalist_info['all'] = ret_dict

        self.write(json.dumps(datalist_info))
Beispiel #5
0
 def get(self):
     unique_id = self.get_argument("job").encode('utf-8')
     param={"id":unique_id}
     mysql=mysqlLib()
     datalist=mysql.query_task(param)
     mysql.close()
     #print datalist
     datalist_info={}
     datalist_info['submit'] = datalist[0][1]
     datalist_info['url'] = datalist[0][2]
     datalist_info['jobname'] = datalist[0][3]
     datalist_info['status'] = datalist[0][5]
     datalist_info['build_number'] = datalist[0][6]
     #print datalist_info
     cmdstr = "curl " + datalist_info['url'] + "job/" + datalist_info['jobname'] + "/" + str(datalist_info['build_number']) + "/logText/progressiveText?start=0"
     #print cmdstr
     if (datalist_info['status'] == 3 or datalist_info['status'] == 4 or datalist_info['status'] == 5):
         status,output=cmd_execute(cmdstr)
         jobname = datalist_info['jobname']
         if (jobname == "pbdownload" or jobname == "addnode" or jobname == "delnode") :
             output = "INFO, task execute success."
         else:
             tmp = output.split("]'\r\n")[1].split("Notifying")[0]
             output = tmp
     else:
         output = "INFO, job is running now"
     datalist_info['output'] = output
     self.write(json.dumps(datalist_info))
Beispiel #6
0
 def get(self):
     unique_id = self.get_argument("job").encode('utf-8')
     param = {"id": unique_id}
     mysql = mysqlLib()
     datalist = mysql.query_task(param)
     mysql.close()
     #print datalist
     datalist_info = {}
     datalist_info['submit'] = datalist[0][1]
     datalist_info['url'] = datalist[0][2]
     datalist_info['jobname'] = datalist[0][3]
     datalist_info['status'] = datalist[0][5]
     datalist_info['build_number'] = datalist[0][6]
     #print datalist_info
     cmdstr = "curl " + datalist_info['url'] + "job/" + datalist_info[
         'jobname'] + "/" + str(datalist_info['build_number']
                                ) + "/logText/progressiveText?start=0"
     #print cmdstr
     if (datalist_info['status'] == 3 or datalist_info['status'] == 4
             or datalist_info['status'] == 5):
         status, output = cmd_execute(cmdstr)
     else:
         output = "INFO, job is running now"
     datalist_info['output'] = output
     self.write(json.dumps(datalist_info))
Beispiel #7
0
    def post(self):
        param = {}
        mysql = mysqlLib()
        downloadstat_week = mysql.query_downloadstat(1, param)
        downloadstat_all = mysql.query_downloadstat(0, param)
        mysql.close()

        datalist_info = {}
        ret_dict = []
        tmp = {}
        for index, item in enumerate(downloadstat_week):
            tmp[int(item[0])] = int(item[1])
        for i in xrange(1, 5):
            if i not in tmp:
                ret_dict.append(0)
            else:
                ret_dict.append(tmp[i])
        datalist_info["week"] = ret_dict

        ret_dict = []
        for index, item in enumerate(downloadstat_all):
            ret_dict.append(int(item[1]))
        datalist_info["all"] = ret_dict

        self.write(json.dumps(datalist_info))
Beispiel #8
0
    def post(self):
        post_param = urlparse.parse_qs(self.request.body, True)
        limit = int(post_param['limit'][0])
        offset = int(post_param['offset'][0])
        belong = post_param['belong'][0]

        param = {"limit": limit, "offset": offset}
        mysql = mysqlLib()
        tasklist = mysql.query_task(param)

        param = {}
        task_totalcnt = mysql.query_task_totalcnt(param)
        mysql.close()

        serverlist_info = {}
        serverlist_info['task_totalcnt'] = task_totalcnt
        ret_dict = []
        for index, item in enumerate(tasklist):
            sub_ret_dict = {}
            sub_ret_dict['id'] = str(int(item[0]))
            sub_ret_dict['submit'] = item[1]
            sub_ret_dict['jenkinsurl'] = item[2]
            sub_ret_dict['jobname'] = item[3]
            sub_ret_dict['build_params'] = item[4]
            sub_ret_dict['status'] = item[5]
            sub_ret_dict['build_number'] = item[6]
            ret_dict.append(sub_ret_dict)
        serverlist_info['ret_dict'] = ret_dict

        self.write(json.dumps(serverlist_info))
    def post(self):
        post_param=urlparse.parse_qs(self.request.body,True)
        limit=int(post_param['limit'][0])
        offset=int(post_param['offset'][0])
        #belong=post_param['belong'][0]

        param={"limit":limit,"offset":offset}
        mysql=mysqlLib()
        serverlist=mysql.query_server(param)

        param={}
        server_totalcnt=mysql.query_server_totalcnt(param)
        mysql.close()

        serverlist_info={}
        serverlist_info['server_totalcnt']=server_totalcnt
        ret_dict=[]
        for index,item in enumerate(serverlist):
            sub_ret_dict={}
            sub_ret_dict['id']=str(int(item[0]))
            sub_ret_dict['name']=item[1]
            sub_ret_dict['exenum']=str(int(item[2]))
            sub_ret_dict['workspace']=item[3]
            sub_ret_dict['ip']=item[4]
            sub_ret_dict['username']=item[5]
            sub_ret_dict['password']=item[6]
            sub_ret_dict['belong']=item[7]
            sub_ret_dict['descpt']=item[8]
            ret_dict.append(sub_ret_dict)
        serverlist_info['ret_dict']=ret_dict

        self.write(json.dumps(serverlist_info))
Beispiel #10
0
    def post(self):
        post_param = urlparse.parse_qs(self.request.body, True)
        limit = int(post_param["limit"][0])
        offset = int(post_param["offset"][0])
        belong = post_param["belong"][0]

        param = {"belong": belong, "limit": limit, "offset": offset}
        mysql = mysqlLib()
        serverlist = mysql.query_server(param)

        param = {"belong": belong}
        server_totalcnt = mysql.query_server_totalcnt(param)
        mysql.close()

        serverlist_info = {}
        serverlist_info["server_totalcnt"] = server_totalcnt
        ret_dict = []
        for index, item in enumerate(serverlist):
            sub_ret_dict = {}
            sub_ret_dict["id"] = str(int(item[0]))
            sub_ret_dict["name"] = item[1]
            sub_ret_dict["ip"] = item[2]
            sub_ret_dict["workspace"] = item[3]
            sub_ret_dict["belong"] = item[4]
            sub_ret_dict["descpt"] = item[5]
            ret_dict.append(sub_ret_dict)
        serverlist_info["ret_dict"] = ret_dict

        self.write(json.dumps(serverlist_info))
Beispiel #11
0
    def post(self):
        post_param = urlparse.parse_qs(self.request.body, True)
        server_id = post_param["id"][0]

        param = (server_id,)
        mysql = mysqlLib()
        n = mysql.del_server(param)
        mysql.close()
        ret_dict = {"errcode": n}
        self.write(json.dumps(ret_dict))
Beispiel #12
0
    def post(self):
        post_param = urlparse.parse_qs(self.request.body, True)
        server_id = post_param['id'][0]

        param = (server_id, )
        mysql = mysqlLib()
        n = mysql.del_server(param)
        mysql.close()
        ret_dict = {"errcode": n}
        self.write(json.dumps(ret_dict))
    def post(self):
        #post_param=urlparse.parse_qs(self.request.body,True)
        #print self.request.body
        jsonobj = json.loads(self.request.body)
        unique_id = jsonobj['build']['parameters']['UNIQUE_ID']
        number = jsonobj['build']['number']
        phase = jsonobj['build']['phase']
        if (phase == "STARTED"):
            mysql = mysqlLib()
            param=(2, unique_id)
            mysql.update_task_status(param)
            print(u"#RUNNING, job running, 2")

            param=(number, unique_id)
            mysql.update_task_build_number(param)
            mysql.close()
        elif (phase == "FINALIZED" or phase == "COMPLETED"):
            status = jsonobj['build']['status']
            if (status == "SUCCESS"):
                mysql = mysqlLib()
                param=(3, unique_id)
                mysql.update_task_status(param)
                print(u"#SUCCESS, job complete, 3")
                mysql.close()
            elif (status == "ABORTED"):
                mysql = mysqlLib()
                param=(5, unique_id)
                mysql.update_task_status(param)
                print(u"#ABORTED, job aborted, 3")
                mysql.close()
            else:
                mysql = mysqlLib()
                param=(4, unique_id)
                mysql.update_task_status(param)
                print(u"#ERROR, job failed, 4")
                mysql.close()
        else:
            mysql = mysqlLib()
            param=(4, unique_id)
            mysql.update_task_status(param)
            print(u"#ERROR, job failed, 4")
            mysql.close()
Beispiel #14
0
    def post(self):
        #post_param=urlparse.parse_qs(self.request.body,True)
        #print self.request.body
        jsonobj = json.loads(self.request.body)
        unique_id = jsonobj['build']['parameters']['UNIQUE_ID']
        number = jsonobj['build']['number']
        phase = jsonobj['build']['phase']
        if (phase == "STARTED"):
            mysql = mysqlLib()
            param = (2, unique_id)
            mysql.update_task_status(param)
            print(u"#RUNNING, job running, 2")

            param = (number, unique_id)
            mysql.update_task_build_number(param)
            mysql.close()
        elif (phase == "FINALIZED" or phase == "COMPLETED"):
            status = jsonobj['build']['status']
            if (status == "SUCCESS"):
                mysql = mysqlLib()
                param = (3, unique_id)
                mysql.update_task_status(param)
                print(u"#SUCCESS, job complete, 3")
                mysql.close()
            elif (status == "ABORTED"):
                mysql = mysqlLib()
                param = (5, unique_id)
                mysql.update_task_status(param)
                print(u"#ABORTED, job aborted, 3")
                mysql.close()
            else:
                mysql = mysqlLib()
                param = (4, unique_id)
                mysql.update_task_status(param)
                print(u"#ERROR, job failed, 4")
                mysql.close()
        else:
            mysql = mysqlLib()
            param = (4, unique_id)
            mysql.update_task_status(param)
            print(u"#ERROR, job failed, 4")
            mysql.close()
Beispiel #15
0
    def post(self):
        post_param = urlparse.parse_qs(self.request.body, True)
        testdata_id = post_param["id"][0]

        param = (testdata_id,)
        mysql = mysqlLib()
        n = mysql.del_testdata(param)
        m = mysql.del_datafile(param)
        mysql.close()
        ret_dict = {"errcoden": n, "errcodem": m}
        self.write(json.dumps(ret_dict))
Beispiel #16
0
    def post(self):
        post_param = urlparse.parse_qs(self.request.body, True)
        testdata_id = post_param['id'][0]

        param = (testdata_id, )
        mysql = mysqlLib()
        n = mysql.del_testdata(param)
        m = mysql.del_datafile(param)
        mysql.close()
        ret_dict = {"errcoden": n, "errcodem": m}
        self.write(json.dumps(ret_dict))
def get_monitor_task_date():
    mysql=mysqlLib()
    task_list=mysql.query_task({"offset":0,"row_cnt":1,"status":1,"type":'map_category'})
    mysql.close()
    latest_date=task_list[0][5]
    latest_date_time=datetime.datetime.strptime(latest_date,"%Y%m%d")
    print(u"最新任务时间:"+str(latest_date_time))
    #date=task_list[0][2].strftime('%Y%m%d')
    #date=task_list[0][2].date()
    monitor_date=latest_date_time+datetime.timedelta(days=1)
    print(u"检测任务时间:"+str(monitor_date))
    return latest_date,monitor_date.strftime('%Y%m%d')
Beispiel #18
0
    def post(self):
        post_param = urlparse.parse_qs(self.request.body, True)
        datatype = post_param['type'][0]
        name = post_param['name'][0]
        belong = post_param['belong'][0]
        filenum = post_param['filenum'][0]
        descpt = post_param['desc'][0]

        param = (datatype, name, belong, filenum, descpt)
        mysql = mysqlLib()
        n, last_id = mysql.add_testdata(param)
        mysql.close()
        ret_dict = {"errcode": n, "last_id": last_id}
        self.write(json.dumps(ret_dict))
Beispiel #19
0
    def post(self):
        post_param = urlparse.parse_qs(self.request.body, True)
        datatype = post_param["type"][0]
        name = post_param["name"][0]
        belong = post_param["belong"][0]
        filenum = post_param["filenum"][0]
        descpt = post_param["desc"][0]

        param = (datatype, name, belong, filenum, descpt)
        mysql = mysqlLib()
        n, last_id = mysql.add_testdata(param)
        mysql.close()
        ret_dict = {"errcode": n, "last_id": last_id}
        self.write(json.dumps(ret_dict))
Beispiel #20
0
    def post(self):
        post_param = urlparse.parse_qs(self.request.body, True)
        srv_id = int(post_param['id'][0])

        param = {"id": srv_id}
        mysql = mysqlLib()
        serverlist = mysql.query_server(param)
        mysql.close()

        ret_dict = {}
        workspace = serverlist[0][3]
        ret_dict['workspace'] = workspace

        self.write(json.dumps(ret_dict))
Beispiel #21
0
    def post(self):
        post_param = urlparse.parse_qs(self.request.body, True)
        srv_id = int(post_param["id"][0])

        param = {"id": srv_id}
        mysql = mysqlLib()
        serverlist = mysql.query_server(param)
        mysql.close()

        ret_dict = {}
        workspace = serverlist[0][3]
        ret_dict["workspace"] = workspace

        self.write(json.dumps(ret_dict))
Beispiel #22
0
    def post(self):
        # post_param=urlparse.parse_qs(self.request.body,True)
        # print self.request.body
        jsonobj = json.loads(self.request.body)
        unique_id = jsonobj["build"]["parameters"]["UNIQUE_ID"]
        number = jsonobj["build"]["number"]
        phase = jsonobj["build"]["phase"]
        if phase == "STARTED":
            mysql = mysqlLib()
            param = (2, unique_id)
            mysql.update_task_status(param)
            print(u"#RUNNING, job running, 2")

            param = (number, unique_id)
            mysql.update_task_build_number(param)
            mysql.close()
        elif phase == "FINALIZED" or phase == "COMPLETED":
            status = jsonobj["build"]["status"]
            if status == "SUCCESS":
                mysql = mysqlLib()
                param = (3, unique_id)
                mysql.update_task_status(param)
                print(u"#SUCCESS, job complete, 3")
                mysql.close()
            else:
                mysql = mysqlLib()
                param = (4, unique_id)
                mysql.update_task_status(param)
                print(u"#ERROR, job failed, 4")
                mysql.close()
        else:
            mysql = mysqlLib()
            param = (4, unique_id)
            mysql.update_task_status(param)
            print(u"#ERROR, job failed, 4")
            mysql.close()
Beispiel #23
0
    def post(self):
        post_param = urlparse.parse_qs(self.request.body, True)
        name = post_param['name'][0]
        ip = post_param['ip'][0]
        username = post_param['username'][0]
        password = post_param['password'][0]
        workspace = post_param['workspace'][0]
        belong = post_param['belong'][0]
        descpt = post_param['descpt'][0]

        param = (name, ip, username, password, workspace, belong, descpt)
        mysql = mysqlLib()
        n, last_id = mysql.add_server(param)
        mysql.close()
        ret_dict = {"errcode": n}
        self.write(json.dumps(ret_dict))
Beispiel #24
0
    def post(self):
        post_param = urlparse.parse_qs(self.request.body, True)
        name = post_param["name"][0]
        ip = post_param["ip"][0]
        username = post_param["username"][0]
        password = post_param["password"][0]
        workspace = post_param["workspace"][0]
        belong = post_param["belong"][0]
        descpt = post_param["descpt"][0]

        param = (name, ip, username, password, workspace, belong, descpt)
        mysql = mysqlLib()
        n, last_id = mysql.add_server(param)
        mysql.close()
        ret_dict = {"errcode": n}
        self.write(json.dumps(ret_dict))
Beispiel #25
0
    def post(self):
        post_param=urlparse.parse_qs(self.request.body,True)
        json_postdata={}
        try:
            for i in post_param[' name']:
                json_postdata[i.split("\r\n")[0].strip("\"")]=i.split("\r\n")[2]
        except Exception:
            pass
        #print json_postdata
        mysql=mysqlLib()
        param=(json_postdata['last_id'],self.request.files['Filedata'][0]['filename'],self.request.files['Filedata'][0]['body'])
        n,last_id=mysql.add_datastr(param)
        mysql.close()
        ret_dict={"errcode":n}
        self.write(json.dumps(ret_dict))

        '''file_dict_list = self.request.files['Filedata']
    def post(self):
        post_param=urlparse.parse_qs(self.request.body,True)
        name=post_param['name'][0]
        exenum=post_param['exenum'][0]
        ip=post_param['ip'][0]
        username=post_param['username'][0]
        password=post_param['password'][0]
        workspace=post_param['workspace'][0]
        belong=post_param['belong'][0]
        descpt=post_param['descpt'][0]

        param=(name,exenum,workspace,ip,username,password,belong,descpt)
        mysql=mysqlLib()
        n,last_id=mysql.add_server(param)
        mysql.close()
        ret_dict={"errcode":n}
        self.write(json.dumps(ret_dict))
Beispiel #27
0
    def post(self):
        post_param = urlparse.parse_qs(self.request.body, True)
        limit = int(post_param['limit'][0])
        offset = int(post_param['offset'][0])
        belong = post_param['belong'][0]
        datatype = post_param['datatype'][0]

        if (datatype == -1):
            param = {"belong": belong, "limit": limit, "offset": offset}
        else:
            param = {
                "belong": belong,
                "type": datatype,
                "limit": limit,
                "offset": offset
            }
        mysql = mysqlLib()
        datalist = mysql.query_testdata(param)

        if (datatype == -1):
            param = {"belong": belong}
        else:
            param = {"belong": belong, "type": datatype}
        data_totalcnt = mysql.query_testdata_totalcnt(param)
        mysql.close()

        datalist_info = {}
        datalist_info['data_totalcnt'] = data_totalcnt
        ret_dict = []
        for index, item in enumerate(datalist):
            sub_ret_dict = {}
            sub_ret_dict['id'] = str(int(item[0]))
            sub_ret_dict['name'] = item[1]
            sub_ret_dict['type'] = item[2]
            sub_ret_dict['belong'] = item[3]
            sub_ret_dict['filenum'] = item[4]
            sub_ret_dict['descpt'] = item[5]
            ret_dict.append(sub_ret_dict)
        datalist_info['ret_dict'] = ret_dict

        self.write(json.dumps(datalist_info))
Beispiel #28
0
    def post(self):
        post_param = urlparse.parse_qs(self.request.body, True)
        json_postdata = {}
        try:
            for i in post_param[" name"]:
                json_postdata[i.split("\r\n")[0].strip('"')] = i.split("\r\n")[2]
        except Exception:
            pass
        # print json_postdata
        mysql = mysqlLib()
        param = (
            json_postdata["last_id"],
            self.request.files["Filedata"][0]["filename"],
            self.request.files["Filedata"][0]["body"],
        )
        n, last_id = mysql.add_datastr(param)
        mysql.close()
        ret_dict = {"errcode": n}
        self.write(json.dumps(ret_dict))

        """file_dict_list = self.request.files['Filedata']
Beispiel #29
0
 def get(self):
     unique_id = self.get_argument("job").encode('utf-8')
     param={"id":unique_id}
     mysql=mysqlLib()
     datalist=mysql.query_task(param)
     mysql.close()
     #print datalist
     datalist_info={}
     datalist_info['submit'] = datalist[0][1]
     datalist_info['url'] = datalist[0][2]
     datalist_info['jobname'] = datalist[0][3]
     datalist_info['status'] = datalist[0][5]
     datalist_info['build_number'] = datalist[0][6]
     #print datalist_info
     cmdstr = "curl " + datalist_info['url'] + "job/" + datalist_info['jobname'] + "/" + str(datalist_info['build_number']) + "/logText/progressiveText?start=0"
     #print cmdstr
     if (datalist_info['status'] == 3 or datalist_info['status'] == 4 or datalist_info['status'] == 5):
         status,output=cmd_execute(cmdstr)
     else:
         output = "INFO, job is running now"
     datalist_info['output'] = output
     self.write(json.dumps(datalist_info))
    def __init__(self):
        self.mysql=mysqlLib()
        monitor_test=self.mysql.query_test_management_monitor()
        #print monitor_test
        monitor_task=self.mysql.query_task_management({"id":monitor_test[0][1]})
        self.task_id=monitor_task[0][0]
        self.pjt_id=monitor_task[0][1]
        self.processtype=monitor_task[0][4]
        self.testtype=monitor_task[0][5]
        self.filepath=monitor_task[0][6]
        self.test_id=monitor_test[0][0]
        self.download_dir="./download/"+str(self.task_id)+"/"+str(self.test_id)+"/"
        self.status=0
        self.logstr=''

        self.script_dir="/home/users/yangjun03/webRoot/tornado/autotestPlatform/scripts/"
        self.benchmark_dir="/home/users/yangjun03/webRoot/tornado/autotestPlatform/benchmark/easyBenchmarkTesttool/"
        #初始化monitor信息
        print self.task_id,self.test_id,self.processtype,self.testtype,self.filepath,self.download_dir
        self.logstr+=u"检测到任务,开始执行....\n"
        self.mysql.update_test_management_log((self.logstr,self.test_id))
        time.sleep(10)
Beispiel #31
0
    def get(self):
        userid=self.get_cookie_user()
        unique_id = self.get_argument("job").encode('utf-8')
        param={"id":unique_id}
        mysql=mysqlLib()
        datalist=mysql.query_task(param)
        mysql.close()
        #print datalist
        datalist_info={}
        datalist_info['submit'] = datalist[0][1]
        datalist_info['url'] = datalist[0][2]
        datalist_info['jobname'] = datalist[0][3]
        datalist_info['status'] = datalist[0][5]
        datalist_info['build_number'] = datalist[0][6]
        #print datalist_info
        cmdstr = "curl " + datalist_info['url'] + "job/" + datalist_info['jobname'] + "/" + str(datalist_info['build_number']) + "/logText/progressiveText?start=0"
        #print cmdstr
        if (datalist_info['status'] == 3 or datalist_info['status'] == 4 or datalist_info['status'] == 5):
            status,output=cmd_execute(cmdstr)
            jobname = datalist_info['jobname']
            if (jobname == "pbdownload" or jobname == "addnode" or jobname == "delnode") :
                output = "INFO, task execute success."
            else:
                tmp = output.split("]'\r\n")[1].split("Notifying")[0]
                output = tmp
                output = output.replace("\n","<br/>")
        else:
            output = "INFO, job is running now"
        datalist_info['output'] = output
        #self.write(json.dumps(datalist_info))

        if(userid):
            self.render("./taskmanagement/taskdetail.html",usrname=userid,datalist_info=datalist_info)
        else:
            redirect_url=CAS_SETTINGS[ 'cas_server' ] + '/login?service=' + CAS_SETTINGS[ 'service_url' ]
            self.redirect(redirect_url)
Beispiel #32
0
    def post(self):
        post_param = urlparse.parse_qs(self.request.body, True)
        limit = int(post_param["limit"][0])
        offset = int(post_param["offset"][0])
        belong = post_param["belong"][0]
        datatype = post_param["datatype"][0]

        if datatype == -1:
            param = {"belong": belong, "limit": limit, "offset": offset}
        else:
            param = {"belong": belong, "type": datatype, "limit": limit, "offset": offset}
        mysql = mysqlLib()
        datalist = mysql.query_testdata(param)

        if datatype == -1:
            param = {"belong": belong}
        else:
            param = {"belong": belong, "type": datatype}
        data_totalcnt = mysql.query_testdata_totalcnt(param)
        mysql.close()

        datalist_info = {}
        datalist_info["data_totalcnt"] = data_totalcnt
        ret_dict = []
        for index, item in enumerate(datalist):
            sub_ret_dict = {}
            sub_ret_dict["id"] = str(int(item[0]))
            sub_ret_dict["name"] = item[1]
            sub_ret_dict["type"] = item[2]
            sub_ret_dict["belong"] = item[3]
            sub_ret_dict["filenum"] = item[4]
            sub_ret_dict["descpt"] = item[5]
            ret_dict.append(sub_ret_dict)
        datalist_info["ret_dict"] = ret_dict

        self.write(json.dumps(datalist_info))
Beispiel #33
0
def map_category_taskrun(event_day):
    #任务时间
    print(u"任务时间为:"+str(event_day))

    #任务初始化
    map_category=class_map_category(event_day)
    mysql=mysqlLib()
    now=datetime.datetime.now().strftime("%y-%m-%d %H:%M:%S")
    param=("map_category",now,0,event_day)
    n,last_id=mysql.add_task(param)
    print n,last_id
    mysql.close()

    #多进程随机取样
    map_category.batch_rand_sample()
    #取样二次过滤
    map_category.secondary_filter()
    print map_category.sample_list
    mysql=mysqlLib()
    for sample in map_category.sample_list:
        sample=sample.strip()
        param=(last_id,sample,0)
        mysql.add_sample(param)
    mysql.close()

    #线程池下发历史信息查询任务
    map_category.batch_get_history_cuid_info()
    print map_category.history_info_list,len(map_category.history_info_list)
    fp=open(map_category.data_directory+map_category.event_day+map_category.history_info_filepath,"w")
    for line in map_category.history_info_list:
        fp.write(line)
    fp.close()

    filepath=map_category.data_directory+map_category.event_day+map_category.history_info_filepath
    lines=get_file_lines(filepath)
    mysql=mysqlLib()
    for line in lines:
        line=line.strip()
        line_list=re.split(r'\t',line.rstrip('\t'))
        #print(str(len(line_list)))
        if(len(line_list) == 6):
            param=(last_id,line_list[0],line_list[1],line_list[2],line_list[3],line_list[4],'','','browse_rawdata',line_list[5],)
        if(len(line_list) == 7):
            param=(last_id,line_list[0],line_list[1],line_list[2],line_list[3],line_list[4],'','',line_list[5],line_list[6],)
        if(len(line_list) == 9):
            param=(last_id,line_list[0],line_list[1],line_list[2],line_list[3],line_list[4],'','','traj_rawdata',line_list[8],)
        mysql.add_history_info(param)
    mysql.close()
    '''mysql=mysqlLib()
    for line in map_category.history_info_list:
        line = line.strip()
        line_list=re.split(r'\t',line.rstrip('\t'))
        param=(last_id,line_list[0],line_list[1],line_list[2],line_list[3],line_list[4],line_list[5],line_list[6],line_list[7],line_list[8],)
        mysql.add_history_info(param)
    mysql.close()'''

    #构造线程池,源数据文件批量下载
    map_category.batch_download_upps_src_data()
    #源数据文件解析
    map_category.get_src_data_info()
    #推荐信息查询
    map_category.batch_get_recommend_cuid_info("tuangou","10af214253a015b8ffdfbac9f98077b4","userpreference",12)
    print map_category.recommend_info_list
    #推荐信息入库
    mysql=mysqlLib()
    for recommend_info in map_category.recommend_info_list:
        recommend_info_list=recommend_info.split("\t")
        param=(last_id,recommend_info_list[0],recommend_info_list[1])
        mysql.add_recommend_info(param)
    mysql.close()
    #源数据信息入库
    mysql=mysqlLib()
    for cuid in map_category.src_data_info:
        param=(str(map_category.src_data_info[cuid]),last_id,cuid)
        mysql.update_recommend_info(param)
    mysql.close()


    #任务结束
    mysql=mysqlLib()
    now=datetime.datetime.now().strftime("%y-%m-%d %H:%M:%S")
    param=(now,1,last_id)
    mysql.update_task_endtime_status(param)

    #任务结束,短信通知
    msgSend(['18665817689','15220056030','15019478061'],u'TASK FINISHED:map_category badcase mining.')
Beispiel #34
0
    def post(self):
        post_param = urlparse.parse_qs(self.request.body, True)
        tooltype = post_param["tooltype"][0]
        proto = post_param["proto"][0]
        srv = post_param["srv"][0]
        path = post_param["path"][0]
        belong = post_param["belong"][0]
        cutime = datetime.datetime.now().strftime("%y-%m-%d %H:%M:%S")

        param = (tooltype, belong, cutime)
        mysql = mysqlLib()
        n, last_id = mysql.add_downloadstat(param)
        """param={}
        downloadstat=mysql.query_downloadstat(1,param)
        print downloadstat
        downloadstat=mysql.query_downloadstat(0,param)
        print downloadstat"""
        mysql.close()

        if int(tooltype) == 1 or int(tooltype) == 3:
            param = {"testdata_id": proto}
            mysql = mysqlLib()
            datafilelist = mysql.query_datafile(param)
            mysql.close()
            for item in datafilelist:
                filename = item[0]
                filestr = item[1]
                # print filename
                # print filestr
                f = open("../proto/" + filename, "w")
                f.write(filestr)
                f.close()
            cmdstr = "cd ../proto/ && ./build.sh"
            status, output = cmd_execute(cmdstr)
            cmdstr = "cd .. && comake2 && make"
            status, output = cmd_execute(cmdstr)
            if int(tooltype) == 1:
                cmdstr = "cd .. && tar -czvf pb.tar.gz conf data log pbrpcbenchmark proto README"
                status, output = cmd_execute(cmdstr)
            if int(tooltype) == 3:
                cmdstr = "cd .. && tar -czvf pb.tar.gz case conf data log pbrpcclient pbunittest.py proto pub README"
                status, output = cmd_execute(cmdstr)

            param = {"id": srv}
            mysql = mysqlLib()
            srvlist = mysql.query_server(param)
            ip = srvlist[0][2]
            username = srvlist[0][6]
            password = srvlist[0][7]
            # workspace=srvlist[0][3]
            mysql.close()
            rootdir = (
                "/home/users/yangjun03/protobuf/workspace/app-test/search/lbs-stat/upps_test/jenkinsFramework/protobuf/"
            )
            filepath = "pb.tar.gz"
            remotepath = path + "/pb/"
            ssh_cmd(ip, 22, username, password, "mkdir -p " + remotepath)
            put_file(ip, 22, username, password, rootdir + filepath, remotepath + "/" + filepath)
            ssh_cmd(ip, 22, username, password, "cd " + remotepath + " && tar -xzvf " + filepath)
            # 删除tar包
            ssh_cmd(ip, 22, username, password, "cd " + remotepath + " && rm " + filepath)
            # 删除所有.svn
            ssh_cmd(ip, 22, username, password, "cd " + remotepath + " && find . -type d -name '.svn' | xargs rm -rf")

            sub_ret_dict = {}
            ret = u"测试工具下载成功"
            sub_ret_dict["msg"] = ret
            self.write(json.dumps(sub_ret_dict))
        else:
            if int(tooltype) == 2:
                cmdstr = "cd ~/httpclient/ && tar -czvf http.tar.gz conf data dep httpbenchmark.jar log README simplehttpserver.jar"
                status, output = cmd_execute(cmdstr)
            if int(tooltype) == 4:
                cmdstr = "cd ~/httpclient/ && tar -czvf http.tar.gz case com conf data dep httpclient.jar httpunittest.py log README simplehttpserver.jar"
                status, output = cmd_execute(cmdstr)

            param = {"id": srv}
            mysql = mysqlLib()
            srvlist = mysql.query_server(param)
            ip = srvlist[0][2]
            username = srvlist[0][6]
            password = srvlist[0][7]
            # workspace=srvlist[0][3]
            mysql.close()
            rootdir = "/home/users/yangjun03/httpclient/"
            filepath = "http.tar.gz"
            remotepath = path + "/http/"
            ssh_cmd(ip, 22, username, password, "mkdir -p " + remotepath)
            put_file(ip, 22, username, password, rootdir + filepath, remotepath + "/" + filepath)
            ssh_cmd(ip, 22, username, password, "cd " + remotepath + " && tar -xzvf " + filepath)
            # 删除tar包
            ssh_cmd(ip, 22, username, password, "cd " + remotepath + " && rm " + filepath)
            # 删除所有.svn
            ssh_cmd(ip, 22, username, password, "cd " + remotepath + " && find . -type d -name '.svn' | xargs rm -rf")

            sub_ret_dict = {}
            ret = u"测试工具下载成功"
            sub_ret_dict["msg"] = ret
            self.write(json.dumps(sub_ret_dict))
Beispiel #35
0
    def post(self):
        post_param = urlparse.parse_qs(self.request.body, True)
        tooltype = post_param['tooltype'][0]
        proto = post_param['proto'][0]
        srv = post_param['srv'][0]
        path = post_param['path'][0]
        belong = post_param['belong'][0]
        cutime = datetime.datetime.now().strftime("%y-%m-%d %H:%M:%S")

        param = (tooltype, belong, cutime)
        mysql = mysqlLib()
        n, last_id = mysql.add_downloadstat(param)
        '''param={}
        downloadstat=mysql.query_downloadstat(1,param)
        print downloadstat
        downloadstat=mysql.query_downloadstat(0,param)
        print downloadstat'''
        mysql.close()

        if (int(tooltype) == 1 or int(tooltype) == 3):
            param = {"testdata_id": proto}
            mysql = mysqlLib()
            datafilelist = mysql.query_datafile(param)
            mysql.close()
            for item in datafilelist:
                filename = item[0]
                filestr = item[1]
                #print filename
                #print filestr
                f = open("../proto/" + filename, "w")
                f.write(filestr)
                f.close()
            cmdstr = "cd ../proto/ && ./build.sh"
            status, output = cmd_execute(cmdstr)
            cmdstr = "cd .. && comake2 && make"
            status, output = cmd_execute(cmdstr)
            if (int(tooltype) == 1):
                cmdstr = "cd .. && tar -czvf pb.tar.gz conf data log pbrpcbenchmark proto README"
                status, output = cmd_execute(cmdstr)
            if (int(tooltype) == 3):
                cmdstr = "cd .. && tar -czvf pb.tar.gz case conf data log pbrpcclient pbunittest.py proto pub README"
                status, output = cmd_execute(cmdstr)

            param = {"id": srv}
            mysql = mysqlLib()
            srvlist = mysql.query_server(param)
            ip = srvlist[0][2]
            username = srvlist[0][6]
            password = srvlist[0][7]
            #workspace=srvlist[0][3]
            mysql.close()
            rootdir = "/home/users/yangjun03/protobuf/workspace/app-test/search/lbs-stat/upps_test/jenkinsFramework/protobuf/"
            filepath = "pb.tar.gz"
            remotepath = path + "/pb/"
            ssh_cmd(ip, 22, username, password, "mkdir -p " + remotepath)
            put_file(ip, 22, username, password, rootdir + filepath,
                     remotepath + "/" + filepath)
            ssh_cmd(ip, 22, username, password,
                    "cd " + remotepath + " && tar -xzvf " + filepath)
            #删除tar包
            ssh_cmd(ip, 22, username, password,
                    "cd " + remotepath + " && rm " + filepath)
            #删除所有.svn
            ssh_cmd(
                ip, 22, username, password, "cd " + remotepath +
                " && find . -type d -name '.svn' | xargs rm -rf")

            sub_ret_dict = {}
            ret = u"测试工具下载成功"
            sub_ret_dict['msg'] = ret
            self.write(json.dumps(sub_ret_dict))
        else:
            if (int(tooltype) == 2):
                cmdstr = "cd ~/httpclient/ && tar -czvf http.tar.gz conf data dep httpbenchmark.jar log README simplehttpserver.jar"
                status, output = cmd_execute(cmdstr)
            if (int(tooltype) == 4):
                cmdstr = "cd ~/httpclient/ && tar -czvf http.tar.gz case com conf data dep httpclient.jar httpunittest.py log README simplehttpserver.jar"
                status, output = cmd_execute(cmdstr)

            param = {"id": srv}
            mysql = mysqlLib()
            srvlist = mysql.query_server(param)
            ip = srvlist[0][2]
            username = srvlist[0][6]
            password = srvlist[0][7]
            #workspace=srvlist[0][3]
            mysql.close()
            rootdir = "/home/users/yangjun03/httpclient/"
            filepath = "http.tar.gz"
            remotepath = path + "/http/"
            ssh_cmd(ip, 22, username, password, "mkdir -p " + remotepath)
            put_file(ip, 22, username, password, rootdir + filepath,
                     remotepath + "/" + filepath)
            ssh_cmd(ip, 22, username, password,
                    "cd " + remotepath + " && tar -xzvf " + filepath)
            #删除tar包
            ssh_cmd(ip, 22, username, password,
                    "cd " + remotepath + " && rm " + filepath)
            #删除所有.svn
            ssh_cmd(
                ip, 22, username, password, "cd " + remotepath +
                " && find . -type d -name '.svn' | xargs rm -rf")

            sub_ret_dict = {}
            ret = u"测试工具下载成功"
            sub_ret_dict['msg'] = ret
            self.write(json.dumps(sub_ret_dict))
Beispiel #36
0
def tuangou_brand_taskrun(event_day):
    #任务时间
    print(u"任务时间为:"+str(event_day))

    #任务初始化
    tuangou_brand=class_tuangou_brand(event_day)
    mysql=mysqlLib()
    now=datetime.datetime.now().strftime("%y-%m-%d %H:%M:%S")
    param=("tuandan_pinpai",now,0,event_day)
    n,last_id=mysql.add_task(param)
    print n,last_id
    mysql.close()

    #多进程随机取样
    tuangou_brand.batch_rand_sample()
    #取样二次过滤
    tuangou_brand.secondary_filter()
    print tuangou_brand.sample_list
    mysql=mysqlLib()
    for sample in tuangou_brand.sample_list:
        sample=sample.strip()
        param=(last_id,sample,0)
        mysql.add_sample(param)
    mysql.close()

    #线程池下发历史信息查询任务
    tuangou_brand.batch_get_history_cuid_info()
    print tuangou_brand.history_info_list,len(tuangou_brand.history_info_list)
    fp=open(tuangou_brand.data_directory+tuangou_brand.event_day+tuangou_brand.history_info_filepath,"w")
    for line in tuangou_brand.history_info_list:
        fp.write(line)
    fp.close()
    mysql=mysqlLib()
    for line in tuangou_brand.history_info_list:
        line = line.strip()
        line_list=re.split(r'\t',line.rstrip('\t'))
        param=(last_id,line_list[0],line_list[1],line_list[2],line_list[3],line_list[4],line_list[5],line_list[6],line_list[7],line_list[8],)
        mysql.add_history_info(param)
    mysql.close()

    #构造线程池,源数据文件批量下载
    tuangou_brand.batch_download_upps_src_data()
    #源数据文件解析
    tuangou_brand.get_src_data_info()
    #推荐信息查询
    tuangou_brand.batch_get_recommend_cuid_info("tuangou","10af214253a015b8ffdfbac9f98077b4","userpreference",12)
    print tuangou_brand.recommend_info_list
    #推荐信息入库
    mysql=mysqlLib()
    for recommend_info in tuangou_brand.recommend_info_list:
        recommend_info_list=recommend_info.split("\t")
        param=(last_id,recommend_info_list[0],recommend_info_list[1])
        mysql.add_recommend_info(param)
    mysql.close()
    #源数据信息入库
    mysql=mysqlLib()
    for cuid in tuangou_brand.src_data_info:
        param=(str(tuangou_brand.src_data_info[cuid]),last_id,cuid)
        mysql.update_recommend_info(param)
    mysql.close()


    #任务结束
    mysql=mysqlLib()
    now=datetime.datetime.now().strftime("%y-%m-%d %H:%M:%S")
    param=(now,1,last_id)
    mysql.update_task_endtime_status(param)

    #任务结束,短信通知
    msgSend(['18665817689','15220056030'],u'TASK FINISHED:tuangou_brand badcase mining.')