示例#1
0
    def _do_work(self):
        start_time = time.time()
        try:
            username = "******" % uuid.uuid4().hex
            pwd = "123456"
            reg_post_data = post_reg % (self.suToken, pwd, username)
            regCode, regData = openUrlCurl(_conf.DOCSVR_REGISTER_URL, reg_post_data, self.header)
            reg_time = time.time()
            reg_cost = reg_time - start_time
            code = self.getresult(regData)

            if code != "ok":
                self.result = "UnhandleError : docsvr register %s" % regData, start_time, reg_cost
                print self.result
                return
            else:
                deviceid = uuid.uuid4().hex
                login_post_data = post_login % (pwd, username, deviceid)
                loginCode, loginData = openUrlCurl(_conf.DOCSVR_LOGIN_URL, login_post_data, self.header)
                login_time = time.time()
                login_cost = login_time - start_time
                code = self.getresult(loginData)
                if code != "ok":
                    self.result = "UnhandleError : docsvr login %s" % loginData, start_time, login_cost
                    print self.result
                    return

            cost_time = time.time() - start_time
            self.result = "ok", start_time, cost_time
        except Exception, e:
            print str(e)
            cost_time = time.time() - start_time
            self.result = "UnhandleError : %s" % str(e), start_time, cost_time
示例#2
0
 def login(self, username, pwd):
     login_post_data = {
         "_params_": {"username": username, "password": pwd, "deviceid": "dev-1", "ip": "127.0.0.1", "secureflag": 0}
     }
     login_post_data = json.dumps(login_post_data)
     login = openUrlCurl(_conf.LOGINSVR_URI + _conf.LOGINSVR_LOGIN_URI, login_post_data)
     return login
示例#3
0
 def __init__(self):
     self.params = {}
     self.result = False, 0, _conf.WORKER_UNHANDLE_ERROR
     deviceid = uuid.uuid4().hex
     post_data = post_login % (_conf.SUPER_PWD, _conf.SUPER_USERNAME, deviceid)
     self.header = {"v": 2}
     resCode, regData = openUrlCurl(_conf.DOCSVR_LOGIN_URL, post_data, self.header)
     self.suToken = self.getattr(regData, "token")
示例#4
0
    def _do_work(self, post_data):
        start_time = time.time()

        try:          
#            print post_data  
            headers = {'Content-type' : 'application/json'}
            data = openUrlCurl(_conf.SOLR_UPDATE_URL, post_data, headers)            #print path,parents
#            print data
            cost_time = time.time() - start_time
            self.result = 'ok', start_time, cost_time
        except Exception, e:
            cost_time = time.time() - start_time
            self.result =  'UnhandleError : %s' % str(e), start_time, cost_time
示例#5
0
 def register(self, username, pwd):
     reg_post_data = {
         "_params_": {
             "username": username,
             "password": pwd,
             "ip": "127.0.0.1",
             "nickname": username,
             "activationstate": 1,
             "registfrom": "X",
         }
     }
     reg_post_data = json.dumps(reg_post_data)
     reg = openUrlCurl(_conf.LOGINSVR_URI + _conf.LOGINSVR_REGISTER_URI, reg_post_data)
     return reg
示例#6
0
 def querysid(self, token):
     query_post_data = {"_params_": {"token": token, "secureflag": 0}}
     query_post_data = json.dumps(query_post_data)
     query = openUrlCurl(_conf.LOGINSVR_URI + _conf.LOGINSVR_QUERYSIDINFO_URI, query_post_data)
     return query
示例#7
0
 def getuserinfo(self, userid):
     userinfo_post_data = {"_params_": {"userid": userid}}
     userinfo_post_data = json.dumps(userinfo_post_data)
     userinfo = openUrlCurl(_conf.LOGINSVR_URI + _conf.LOGINSVR_GETUSERINFO_URI, userinfo_post_data)
     return userinfo