Ejemplo n.º 1
0
 def sendGetQueueCountAsync(self):
     """
     请求排队接口
     :return:
     """
     urls = self.session.urls["getQueueCountAsync"]
     data = self.data_par()
     getQueueCountAsyncResult = self.session.httpClint.send(urls, data)
     if getQueueCountAsyncResult.get("status", False) and getQueueCountAsyncResult.get("data", False):
         if "status" in getQueueCountAsyncResult and getQueueCountAsyncResult["status"] is True:
             if "countT" in getQueueCountAsyncResult["data"]:
                 ticket_data = getQueueCountAsyncResult["data"]["ticket"]
                 ticket_split = sum(map(self.conversion_int, ticket_data.split(","))) if ticket_data.find(
                     ",") != -1 else ticket_data
                 print(u"排队成功, 当前余票还剩余: {0} 张".format(ticket_split))
                 c = confirmSingleForQueueAsys(session=self.session,
                                               passengerTicketStr=self.passengerTicketStr,
                                               oldPassengerStr=self.oldPassengerStr,
                                               result=self.result,)
                 print(u"验证码提交安全期,等待{}MS".format(self.ifShowPassCodeTime))
                 time.sleep(self.ifShowPassCodeTime)
                 c.sendConfirmSingleForQueueAsys()
             else:
                 print(u"排队发现未知错误{0},将此列车 {1}加入小黑屋".format(getQueueCountAsyncResult, self.train_no))
                 wrapcache.set(key=self.train_no, value=datetime.datetime.now(),
                               timeout=int(_get_yaml()["ticket_black_list_time"]) * 60)
         elif "messages" in getQueueCountAsyncResult and getQueueCountAsyncResult["messages"]:
             print(u"排队异常,错误信息:{0}, 将此列车 {1}加入小黑屋".format(getQueueCountAsyncResult["messages"][0], self.train_no))
             wrapcache.set(key=self.train_no, value=datetime.datetime.now(),
                           timeout=int(_get_yaml()["ticket_black_list_time"]) * 60)
         else:
             if "validateMessages" in getQueueCountAsyncResult and getQueueCountAsyncResult["validateMessages"]:
                 print(str(getQueueCountAsyncResult["validateMessages"]))
Ejemplo n.º 2
0
 def sendGetQueueCountAsync(self):
     """
     请求排队接口
     :return:
     """
     urls = self.session.urls["getQueueCountAsync"]
     data = self.data_par()
     getQueueCountAsyncResult = self.session.httpClint.send(urls, data)
     if getQueueCountAsyncResult.get("status", False) and getQueueCountAsyncResult.get("data", False):
         if "status" in getQueueCountAsyncResult and getQueueCountAsyncResult["status"] is True:
             if "countT" in getQueueCountAsyncResult["data"]:
                 ticket_data = getQueueCountAsyncResult["data"]["ticket"]
                 ticket_split = sum(map(self.conversion_int, ticket_data.split(","))) if ticket_data.find(
                     ",") != -1 else ticket_data
                 print(u"排队成功, 当前余票还剩余: {0} 张".format(ticket_split))
                 c = confirmSingleForQueueAsys(session=self.session,
                                               passengerTicketStr=self.passengerTicketStr,
                                               oldPassengerStr=self.oldPassengerStr,
                                               result=self.result,)
                 print(u"验证码提交安全期,等待{}MS".format(self.ifShowPassCodeTime))
                 time.sleep(self.ifShowPassCodeTime)
                 c.sendConfirmSingleForQueueAsys()
             else:
                 print(u"排队发现未知错误{0},将此列车 {1}加入小黑屋".format(getQueueCountAsyncResult, self.train_no))
                 wrapcache.set(key=self.train_no, value=datetime.datetime.now(),
                               timeout=TickerConfig.TICKET_BLACK_LIST_TIME * 60)
         elif "messages" in getQueueCountAsyncResult and getQueueCountAsyncResult["messages"]:
             print(u"排队异常,错误信息:{0}, 将此列车 {1}加入小黑屋".format(getQueueCountAsyncResult["messages"][0], self.train_no))
             wrapcache.set(key=self.train_no, value=datetime.datetime.now(),
                           timeout=TickerConfig.TICKET_BLACK_LIST_TIME * 60)
         else:
             if "validateMessages" in getQueueCountAsyncResult and getQueueCountAsyncResult["validateMessages"]:
                 print(str(getQueueCountAsyncResult["validateMessages"]))
Ejemplo n.º 3
0
 def sendGetQueueCountAsync(self, log_info=[]):
     """
     请求排队接口
     :return:
     """
     urls = self.session.urls["getQueueCountAsync"]
     data = self.data_par()
     getQueueCountAsyncResult = self.session.httpClint.send(urls, data)
     if getQueueCountAsyncResult.get(
             "status", False) and getQueueCountAsyncResult.get(
                 "data", False):
         if "status" in getQueueCountAsyncResult and getQueueCountAsyncResult[
                 "status"] is True:
             if "countT" in getQueueCountAsyncResult["data"]:
                 ticket_data = getQueueCountAsyncResult["data"]["ticket"]
                 ticket_split = sum(
                     map(self.conversion_int, ticket_data.split(","))
                 ) if ticket_data.find(",") != -1 else ticket_data
                 countT = getQueueCountAsyncResult["data"]["countT"]
                 if int(countT) is 0:
                     if int(ticket_split) < self.users:
                         log_info.append(u"当前余票数小于乘车人数,放弃订票")
                         print(u"当前余票数小于乘车人数,放弃订票")
                     else:
                         log_info.append(
                             u"排队成功, 当前余票还剩余: {0} 张".format(ticket_split))
                         print(u"排队成功, 当前余票还剩余: {0} 张".format(ticket_split))
                         c = confirmSingleForQueueAsys(
                             session=self.session,
                             passengerTicketStr=self.passengerTicketStr,
                             oldPassengerStr=self.oldPassengerStr,
                             result=self.result,
                         )
                         print(u"验证码提交安全期,等待{}MS".format(
                             self.ifShowPassCodeTime))
                         log_info.append(u"验证码提交安全期,等待{}MS".format(
                             self.ifShowPassCodeTime))
                         time.sleep(self.ifShowPassCodeTime)
                         c.sendConfirmSingleForQueueAsys()
             else:
                 log_info.append(u"排队发现未知错误{0},将此列车 {1}加入小黑屋".format(
                     getQueueCountAsyncResult, self.train_no))
                 print(u"排队发现未知错误{0},将此列车 {1}加入小黑屋".format(
                     getQueueCountAsyncResult, self.train_no))
                 # wrapcache.set(key=self.train_no, value=datetime.datetime.now(),
                 #               timeout=int(_get_yaml()["ticket_black_list_time"]) * 60)
         elif "messages" in getQueueCountAsyncResult and getQueueCountAsyncResult[
                 "messages"]:
             log_info.append(u"排队异常,错误信息:{0}, 将此列车 {1}加入小黑屋".format(
                 getQueueCountAsyncResult["messages"][0], self.train_no))
             print(u"排队异常,错误信息:{0}, 将此列车 {1}加入小黑屋".format(
                 getQueueCountAsyncResult["messages"][0], self.train_no))
             wrapcache.set(
                 key=self.train_no,
                 value=datetime.datetime.now(),
                 timeout=int(_get_yaml()["ticket_black_list_time"]) * 60)
         else:
             if "validateMessages" in getQueueCountAsyncResult and getQueueCountAsyncResult[
                     "validateMessages"]:
                 log_info.append(
                     str(getQueueCountAsyncResult["validateMessages"]))
                 print(str(getQueueCountAsyncResult["validateMessages"]))