def title_sign(self, token, match_id):
     post_data = {}
     headers = {
         "Cache - Control": "no - cache",
         "Content - Type": "text / html;charset = UTF - 8",
         'Accept': 'application/json',
         'Authorization': token,
         "Date": "%s" % GetCurrentTime().getHeaderTime(),
         "Proxy - Connection": "Keep - alive",
         "Server": "nginx / 1.9.3(Ubuntu)",
         "Transfer - Encoding": "chunked"
     }
     title_sign_url = "http://%s/activity/%d/signtitle" % (
         ConfigFile().host(), match_id)
     request = requests.get(title_sign_url, data=post_data, headers=headers)
     time = GetCurrentTime().getCurrentTime()
     status_code = request.status_code
     print(title_sign_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"get", title_sign_url,
             str(post_data), time, status_code, info
         ]  # 单条日志记录
Exemple #2
0
 def special_character(self):
     post_data = {}
     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"
     }
     special_character_url = "http://%s/activity/characters" % ConfigFile(
     ).host()
     request = requests.get(special_character_url, headers=headers)
     time = GetCurrentTime().getCurrentTime()
     status_code = request.status_code
     print(request)
     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", special_character_url,
             str(post_data), time, status_code, info
         ]  # 单条日志记录
 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)  # 逐条写入日志
Exemple #4
0
 def match_info(self, id):
     """
     比赛详情
     :param id:
     :return:
     """
     post_data = {}
     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"
     }
     match_info_url = "http://%s/activity/%d/info" % (ConfigFile().host(),
                                                      id)
     request = requests.get(match_info_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_info_url,
             str(post_data), time, status_code, info
         ]  # 单条日志记录
Exemple #5
0
 def ranking_all(self, ranking_type=1):
     """
     获取排行榜
     :param ranking_type: 1(总榜);2(周榜)
     :return:
     """
     post_data = {}
     headers = {
         "Cache - Control": "no - cache",
         "Content - Type": "text / html;charset = UTF - 8",
         'Accept': 'application/json',
         'Authorization': self.judgement_token,
         "Date": "%s" % GetCurrentTime().getHeaderTime(),
         "Proxy - Connection": "Keep - alive",
         "Server": "nginx / 1.9.3(Ubuntu)",
         "Transfer - Encoding": "chunked"
     }
     ranking_all_url = "http://%s/activity/activityrank?type=%d" % (
         ConfigFile().host(), ranking_type)
     request = requests.get(ranking_all_url, headers=headers)
     time = GetCurrentTime().getCurrentTime()
     status_code = request.status_code
     print(request)
     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", ranking_all_url,
             str(post_data), time, status_code, info
         ]  # 单条日志记录
 def match_rule(self, judgement_token, game_id):
     post_data = {"gameId": "%d" % game_id}  # 游戏ID
     headers = {
         "Cache - Control": "no - cache",
         "Content - Type": "text / html;charset = UTF - 8",
         'Accept': 'application/json',
         'Authorization': judgement_token,
         "Date": "%s" % GetCurrentTime().getHeaderTime(),
         "Proxy - Connection": "Keep - alive",
         "Server": "nginx / 1.9.3(Ubuntu)",
         "Transfer - Encoding": "chunked"
     }
     match_rule_url = "http://%s/activity/rule" % ConfigFile().host()
     request = requests.get(match_rule_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_rule_url,
             str(post_data), time, status_code, info
         ]  # 单条日志记录
Exemple #7
0
    def match_judged(self, token, match_status, page):
        """

        :param token:
        :param match_status: 1-报名中  2-比赛中  3-已结束
        :param page:分页
        :return:
        """
        post_data = {}
        headers = {"Cache - Control": "no - cache",
                   "Content - Type": "text / html;charset = UTF - 8",
                   'Accept': 'application/json',
                   'Authorization': token,
                   "Date": "%s" % GetCurrentTime().getHeaderTime(),
                   "Proxy - Connection": "Keep - alive",
                   "Server": "nginx / 1.9.3(Ubuntu)",
                   "Transfer - Encoding": "chunked"}
        match_judged_url = "http://%s/activity/referee/%d?p=%d" % (ConfigFile().host(), match_status, page)
        request = requests.get(match_judged_url, headers=headers)
        time = GetCurrentTime().getCurrentTime()
        status_code = request.status_code
        print(match_judged_url)
        try:
            if status_code in (200, 422):
                json = request.json()
                info = json["info"]
                return json
            else:
                info = request.reason
                print(info)
        finally:
            log_list = [u'我裁定的', u"get", match_judged_url, str(post_data), time, status_code, info]  # 单条日志记录
    def dispute_judge(self, judgement_token, id, dispute_id, winner_id):
        """

        :param login:
        :param id:
        :param dispute_id:
        :param winner_id:获胜者id
        :return:
        """
        post_data = {"won": "%d" % winner_id}
        headers = {"Cache - Control": "no - cache",
                   "Content - Type": "text / html;charset = UTF - 8",
                   'Accept': 'application/json',
                   'Authorization': judgement_token,
                   "Date": "%s" % GetCurrentTime().getHeaderTime(),
                   "Proxy - Connection": "Keep - alive",
                   "Server": "nginx / 1.9.3(Ubuntu)",
                   "Transfer - Encoding": "chunked"}
        dispute_judge_url = "http://%s/activity/%d/dispute/%d/judgment" % (ConfigFile().host(), id, dispute_id)
        request = requests.post(dispute_judge_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"post", dispute_judge_url, str(post_data), time, status_code, info]  # 单条日志记录
Exemple #9
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)  # 逐条写入日志
Exemple #10
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 delete_role(self, login, role_id):
     """
     删除角色
     :param login:
     :return:
     """
     post_data = {"roleId": "%d" % role_id}
     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"
     }
     delete_role_url = "http://%s/usergmaes/deleteRole" % ConfigFile().host(
     )
     request = requests.delete(delete_role_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"delete", delete_role_url,
             str(post_data), time, status_code, info
         ]  # 单条日志记录
         GetReport().get_report()  # 生成或打开日志文件
         GetReport().record_into_report(log_list)  # 逐条写入日志
Exemple #12
0
 def lose(self, token, id, screenings):
     post_data = {"screenings": "%d" % screenings}
     headers = {"Cache - Control": "no - cache",
                 "Content - Type": "text / html;charset = UTF - 8",
                 'Accept': 'application/json',
                 'Authorization': token,
                 "Date": "%s" % GetCurrentTime().getHeaderTime(),
                 "Proxy - Connection": "Keep - alive",
                 "Server": "nginx / 1.9.3(Ubuntu)",
                 "Transfer - Encoding": "chunked"}
     lose_url = "http://%s/activity/%d/transport" % (ConfigFile().host(), id)
     request = requests.post(lose_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
             print(info)
     finally:
         log_list = [u'提交结果为负', u"post", lose_url, str(post_data), time, status_code, info]  # 单条日志记录