def match_created(self, login, status):
     post_data = {}
     headers = {
         "Cache - Control": "no - cache",
         "Content - Type": "text / html;charset = UTF - 8",
         'Accept': 'application/json',
         'Authorization': login["data"]["auth_token"],
         "Date": "%s" % GetCurrentTime().getHeaderTime(),
         "Proxy - Connection": "Keep - alive",
         "Server": "nginx / 1.9.3(Ubuntu)",
         "Transfer - Encoding": "chunked"
     }
     match_created_url = "http://%s/activity/found/%d" % (
         ConfigFile().host(), status)
     request = requests.get(match_created_url, post_data, headers=headers)
     time = GetCurrentTime().getCurrentTime()
     status_code = request.status_code
     try:
         if status_code in (200, 422):
             json = request.json()
             info = json["info"]
             return json
         else:
             info = request.reason
     finally:
         log_list = [
             u'我发布的比赛', u"get", match_created_url,
             str(post_data), time, status_code, info
         ]  # 单条日志记录
         GetReport().get_report()  # 生成或打开日志文件
         GetReport().record_into_report(log_list)  # 逐条写入日志
Example #2
0
 def sendCode(self, mobile, type):
     """
     发送验证码:注册、修改密码
     :param mobile:
     :param type: 1:用户注册;2:忘记密码(默认值为1)
     :return:
     """
     post_data = {"mobile": "%s" % mobile,
                  "type": "%s" % type}  # 1:用户注册;2:忘记密码(默认值为1)
     headers = {"Cache - Control": "no - cache",
                "Content - Type": "text / html;charset = UTF - 8",
                'Accept': 'application/json',
                "Date": "%s" % GetCurrentTime().getHeaderTime(),
                "Proxy - Connection": "Keep - alive",
                "Server": "nginx / 1.9.3(Ubuntu)",
                "Transfer - Encoding": "chunked"}
     send_code_url = "http://%s/user/sendcode" % ConfigFile().host()
     request = requests.post(send_code_url, data=post_data, headers=headers)
     time = GetCurrentTime().getCurrentTime()
     status_code = request.status_code
     try:
         if status_code in (200, 422):
             json = request.json()
             info = json["info"]
             return json
         else:
             info = request.reason
     finally:
         log_list = [u'发送验证码', u"post", send_code_url, str(post_data), time, status_code, info]
         GetReport().get_report()  # 生成或打开日志文件
         GetReport().record_into_report(log_list)  # 逐条写入日志
Example #3
0
 def game_region(self, game_id):
     """
     获取大区
     :return:
     """
     post_data = {"gameId": "%d" % game_id}
     headers = {
         "Cache - Control": "no - cache",
         "Content - Type": "text / html;charset = UTF - 8",
         'Accept': 'application/json',
         "Date": "%s" % GetCurrentTime().getHeaderTime(),
         "Proxy - Connection": "Keep - alive",
         "Server": "nginx / 1.9.3(Ubuntu)",
         "Transfer - Encoding": "chunked"
     }
     game_region_url = "http://%s/games/service" % ConfigFile().host()
     request = requests.get(game_region_url, post_data, headers=headers)
     time = GetCurrentTime().getCurrentTime()
     status_code = request.status_code
     try:
         if status_code in (200, 422):
             json = request.json()
             info = json["info"]
             return json
         else:
             info = request.reason
     finally:
         log_list = [
             u'获取游戏大区', u"get", game_region_url,
             str(post_data), time, status_code, info
         ]  # 单条日志记录
         GetReport().get_report()  # 生成或打开日志文件
         GetReport().record_into_report(log_list)  # 逐条写入日志
Example #4
0
 def check_password(self, token):
     post_data = {"password": "******" % self.password}
     headers = {
         "Cache - Control": "no - cache",
         "Content - Type": "text / html;charset = UTF - 8",
         'Accept': 'application/json',
         'Authorization': token,
         "Date": "%s" % GetTime().getHeaderTime(),
         "Proxy - Connection": "Keep - alive",
         "Server": "nginx / 1.9.3(Ubuntu)",
         "Transfer - Encoding": "chunked"
     }
     check_password_url = "http://%s/activity/%d/checkpassword" % (
         ConfigFile().host(), self.match_id)
     request = requests.post(check_password_url, post_data, headers=headers)
     time = GetTime().getCurrentTime()
     status_code = request.status_code
     print(check_password_url)
     try:
         if status_code in (200, 422):
             json = request.json()
             info = json["info"]
             return json
         else:
             info = request.reason
     finally:
         log_list = [
             u'提交房间密码', u"post", check_password_url,
             str(post_data), time, status_code, info
         ]  # 单条日志记录
         GetReport().get_report()  # 生成或打开日志文件
         GetReport().record_into_report(log_list)  # 逐条写入日志
Example #5
0
 def banner(self):
     """
     获取banner列表
     :return: 接口返回的json数据
     """
     # post_data = {"delivery": "%s" % random.randint(1, 7)}  # 1-首页弹窗 2-资讯 3-蟠桃园 4-赛事 5-附近 6- new-投票 7-启动页
     post_data = {"delivery": "7"}
     headers = {
         "Cache - Control": "no - cache",
         "Content - Type": "text / html;charset = UTF - 8",
         'Accept': 'application/json',
         "Date": "%s" % GetCurrentTime().getHeaderTime(),
         "Proxy - Connection": "Keep - alive",
         "Server": "nginx / 1.9.3(Ubuntu)",
         "Transfer - Encoding": "chunked"
     }
     banner_url = "http://%s/banner/list" % ConfigFile().host()
     request = requests.get(banner_url, post_data, headers=headers)
     time = GetCurrentTime().getCurrentTime()
     status_code = request.status_code
     try:
         if status_code in (200, 422):
             json = request.json()
             info = json["info"]
             return json
         else:
             info = request.reason
     finally:
         # print(info)
         log_list = [
             u'获取banner', u"get", banner_url,
             str(post_data), time, status_code, info
         ]  # 单条日志记录
         GetReport().get_report()  # 生成或打开日志文件
         GetReport().record_into_report(log_list)  # 逐条写入日志
Example #6
0
 def complain_context(self, content, type):
     """
     提交用户反馈
     :param content: 反馈内容
     :return:
     """
     post_data = {
         "content": "%s" % content,
         "type": "%d" % type
     }  # 1:功能建议;2:产品BUG
     headers = {
         "Cache - Control":
         "no - cache",
         "Content - Type":
         "text / html;charset = UTF - 8",
         'Accept':
         'application/json',
         'Authorization':
         Login().login("18708125570", "aaaaaa")["data"]["auth_token"],
         "Date":
         "%s" % GetCurrentTime().getHeaderTime(),
         "Proxy - Connection":
         "Keep - alive",
         "Server":
         "nginx / 1.9.3(Ubuntu)",
         "Transfer - Encoding":
         "chunked"
     }
     complain_type_url = "http://%s/complaint/opinion" % ConfigFile().host()
     request = requests.post(complain_type_url,
                             data=post_data,
                             headers=headers)
     time = GetCurrentTime().getCurrentTime()
     status_code = request.status_code
     try:
         if status_code in (200, 422):
             json = request.json()
             info = json["info"]
             return json
         else:
             info = request.reason
     finally:
         log_list = [
             u'提交用户反馈', u"post", complain_type_url,
             str(post_data), time, status_code, info
         ]  # 单条日志记录
         GetReport().get_report()  # 生成或打开日志文件
         GetReport().record_into_report(log_list)  # 逐条写入日志
Example #7
0
 def weixin_login(self, openid):
     """
     微信登录
     :param openid:
     :return:
     """
     post_data = {
         "type": "weixin",  # QQ: 'qq'; 微信: 'weixin'
         "openid": openid,  # 第三方平台的唯一标识
         "auth_token": ""
     }  # 第三方平台的授权码
     headers = {
         "Cache - Control": "no - cache",
         "Content - Type": "text / html;charset = UTF - 8",
         'Accept': 'application/json',
         "Date": "%s" % GetCurrentTime().getHeaderTime(),
         "Proxy - Connection": "Keep - alive",
         "Server": "nginx / 1.9.3(Ubuntu)",
         "Transfer - Encoding": "chunked"
     }
     third_login_url = "http://%s/user/thirdlogin" % ConfigFile().host()
     request = requests.post(third_login_url,
                             data=post_data,
                             headers=headers)
     time = GetCurrentTime().getCurrentTime()
     status_code = request.status_code
     try:
         if status_code in (200, 422):
             json = request.json()
             info = json["info"]
             return json
         else:
             info = request.reason
     finally:
         log_list = [
             u'微信登录', u"post", third_login_url,
             str(post_data), time, status_code, info
         ]  # 单条日志记录
         GetReport().get_report()  # 生成或打开日志文件
         GetReport().record_into_report(log_list)  # 逐条写入日志
 def game_backgroud_image(self, login, game_id):
     """
     获取游戏背景图
     :param login:
     :return:
     """
     post_data = {"gameId": "%d" % game_id}  # 选填,填写后选择的游戏优先显示
     headers = {
         "Cache - Control": "no - cache",
         "Content - Type": "text / html;charset = UTF - 8",
         'Accept': 'application/json',
         'Authorization': login["data"]["auth_token"],
         "page": "",  # 分页,有默认值
         "Date": "%s" % GetCurrentTime().getHeaderTime(),
         "Proxy - Connection": "Keep - alive",
         "Server": "nginx / 1.9.3(Ubuntu)",
         "Transfer - Encoding": "chunked"
     }
     game_backgroud_image_url = "http://%s/games/image" % ConfigFile().host(
     )
     request = requests.get(game_backgroud_image_url,
                            post_data,
                            headers=headers)
     time = GetCurrentTime().getCurrentTime()
     status_code = request.status_code
     try:
         if status_code in (200, 422):
             json = request.json()
             info = json["info"]
             return json
         else:
             info = request.reason
     finally:
         log_list = [
             u'获取游戏背景图', u"get", game_backgroud_image_url,
             str(post_data), time, status_code, info
         ]  # 单条日志记录
         GetReport().get_report()  # 生成或打开日志文件
         GetReport().record_into_report(log_list)  # 逐条写入日志