def act_egg(self): ''' 登高 :return: ''' for key in self.account_list: try: value = self.__class__.account_http_dic[key] except KeyError: continue base_url = commons.getUrl(constant.ACTEGG,value) post_data = { 'act':4 } content_page = value.get_response(base_url,post_data).read().decode('utf-8') count = int(json.loads(content_page)['free_cnt']) zy_old_count = int(json.loads(content_page)['vt26']) base_url = commons.getUrl(constant.ACTEGG,value) post_data = { 'act':5 } for i in range(count): page_content = value.get_response(base_url,post_data).read().decode('utf-8') logging.info(page_content) if 'sucess' in page_content: zy_count = int(json.loads(page_content)['vt26']) wx.CallAfter(self.operateLogUpdate,str(key)+u'获得茱萸:'+str(zy_count-zy_old_count)) zy_old_count = zy_count else: wx.CallAfter(self.operateLogUpdate,str(key)+u'今天已经玩过登高了') break wx.CallAfter(self.operateLogUpdate,u'一键任务完成')
def receive_gift(self): ''' 接收礼物 :return: ''' self.get_theme_card_num(self.src_theme_id, self.src_price) if self.card_num >= self.flash_num: return limit_receive_time = self.flash_num - self.card_num base_url = commons.getUrl(constant.GETGIFTLISTURL, self.myHttpRequest) base_url = base_url.replace('USERNAME', str(constant.USERNAME)) page_content = self.myHttpRequest.get_response(base_url).read().decode( "utf-8") # print page_content page_content = page_content[10:-4] gift_list = json.loads(page_content)['freegifts'] base_url = commons.getUrl(constant.GIFTRECEIVE, self.myHttpRequest) for i, gift_dic in enumerate(gift_list): post_data = { 'appid': 365, 'action': 1, 'index_id': gift_dic['index_id'], 'uin': constant.USERNAME, 'cb': 1, 'r': '0.4827874337788671', 'qzreferrer': 'http://qzs.qq.com/snsapp/app/free_gift/index.htm?appid=365&page=receive' } page_content = self.myHttpRequest.get_response( base_url, post_data).read().decode('utf-8') print page_content if u"系统繁忙" in page_content: wx.CallAfter(self.window.updateLog, u'卡箱已满') logging.info(u'卡箱已满') elif u'上限' in page_content: wx.CallAfter(self.window.updateLog, u'收卡上限') logging.info(u'卡箱已满') break else: logging.info(u'接收好友一个礼物') wx.CallAfter(self.window.updateLog, u'接收好友一个礼物') if i >= (limit_receive_time - 1): break
def send_card_gift(self): ''' 送礼物卡 :return: ''' send_count = 0 for key in self.account_list: try: value = self.__class__.account_http_dic[key] except KeyError: continue base_url = commons.getUrl(constant.SENDCARD,value) post_data = { 'appid':365, 'friends':self.account_send_gift_text.GetValue(), 'freegift_id':random.randint(75,80), 'sfcount':0, 'uin':key, 'cb':1, 'r':'0.'+commons.getRandomNum(16), 'qzreferrer':'http://qzs.qq.com/snsapp/app/free_gift/index.htm?appid=365&page=receive' } page_content = value.get_response(base_url,post_data).read().decode('utf-8') logging.info(page_content) if '"msg":"ok"' in page_content: send_count +=1 wx.CallAfter(self.operateLogUpdate,str(key)+u'送礼物卡成功') else: wx.CallAfter(self.operateLogUpdate,str(key)+u'送礼物卡失败') if send_count>=45: break wx.CallAfter(self.operateLogUpdate,u'一键任务完成')
def getZCGInfo(self): base_url = commons.getUrl(constant.ZCGINFOURL,self.myHttpRequest) postData = { 'opuin':constant.USERNAME, 'act':1 } return self.myHttpRequest.get_response(base_url,postData).read()
def refineCardInZCG(self): for k, czgComplete in enumerate(self.windows.czgComplete): if czgComplete == -1: cardIdTemp = 0 cardPos = -1 for i, cardId in enumerate(self.windows.exchangeBox): if cardId == 0: continue if self.windows.database.getCardInfo(cardId)[2] == 10: cardIdTemp = cardId cardPos = i break if cardIdTemp == 0: wx.CallAfter(self.windows.buyCard, constant.DEFAULTBYCARDID) time.sleep(1) cardIdTemp = constant.DEFAULTBYCARDID cardPos = self.windows.exchangeBox.index( constant.DEFAULTBYCARDID) base_url = commons.getUrl(constant.ZCGINFOURL, self.windows.myHttpRequest) postData = { 'puzi_id': self.windows.zcgInfoDic[k], 'slot_id': cardPos, 'card_id': cardIdTemp, 'act': 2 } content_page = self.windows.myHttpRequest.get_response( base_url, postData).read().decode('utf-8') self.windows.exchangeBox[cardPos] = 0 print content_page logging.info(u'珍藏阁炼卡信息' + content_page)
def refineCardInZCG(self): for k,czgComplete in enumerate(self.windows.czgComplete): if czgComplete==-1: cardIdTemp = 0 cardPos = -1 for i,cardId in enumerate(self.windows.exchangeBox): if cardId==0: continue if self.windows.database.getCardInfo(cardId)[2]==10: cardIdTemp = cardId cardPos = i break if cardIdTemp==0: wx.CallAfter(self.windows.buyCard,constant.DEFAULTBYCARDID) time.sleep(1) cardIdTemp = constant.DEFAULTBYCARDID cardPos = self.windows.exchangeBox.index(constant.DEFAULTBYCARDID) base_url =commons.getUrl(constant.ZCGINFOURL,self.windows.myHttpRequest) postData = { 'puzi_id':self.windows.zcgInfoDic[k], 'slot_id':cardPos, 'card_id':cardIdTemp, 'act':2 } content_page = self.windows.myHttpRequest.get_response(base_url,postData).read().decode('utf-8') self.windows.exchangeBox[cardPos] = 0 print content_page logging.info(u'珍藏阁炼卡信息'+content_page)
def get_card_gift(self): for key in self.account_list: try: value = self.accout_sid_dic[key] except KeyError: continue myhttps = self.__class__.account_http_dic[key] base_url = commons.getUrl(constant.GETCARD,myhttps) post_data = { 'sid':value, 'loginuin':key, 'actid':3006, 'appid':200, 'packid':612 } print post_data pagecontent = myhttps.get_response(base_url,post_data).read().decode('utf-8') logging.info(pagecontent) if '"ecode":0' in pagecontent: wx.CallAfter(self.operateLogUpdate,u'领取100面值卡成功') elif '"ecode":9' in pagecontent: wx.CallAfter(self.operateLogUpdate,u'领取100达到限制') else: wx.CallAfter(self.operateLogUpdate,u'领取100面值卡失败') wx.CallAfter(self.operateLogUpdate,u'一键任务完成')
def get_user_info(self,user): base_url = commons.getUrl(constant.CARDLOGINURL,self.myHttpRequest) postData = { 'uin':constant.USERNAME, 'opuin':user, } result = self.myHttpRequest.get_response(base_url,postData).read() return result
def main_page_info(self): postData = {'code': '', 'uin': constant.USERNAME} base_url = commons.getUrl(constant.CARDLOGINURL, self.myHttpRequest) page_content = self.myHttpRequest.get_response(base_url, postData) magicCardInfo = page_content.read().decode('utf-8') self.get_type_info(constant.STOREBOX, magicCardInfo) self.get_type_info(constant.EXCHANGEBOX, magicCardInfo) pass
def get_user_info(self, user): base_url = commons.getUrl(constant.CARDLOGINURL, self.myHttpRequest) postData = { 'uin': constant.USERNAME, 'opuin': user, } result = self.myHttpRequest.get_response(base_url, postData).read() return result
def receive_gift(self): ''' 接收礼物 :return: ''' self.get_theme_card_num(self.src_theme_id,self.src_price) if self.card_num >=self.flash_num: return limit_receive_time = self.flash_num-self.card_num base_url = commons.getUrl(constant.GETGIFTLISTURL,self.myHttpRequest) base_url = base_url.replace('USERNAME',str(constant.USERNAME)) page_content = self.myHttpRequest.get_response(base_url).read().decode("utf-8") # print page_content page_content = page_content[10:-4] gift_list = json.loads(page_content)['freegifts'] base_url = commons.getUrl(constant.GIFTRECEIVE,self.myHttpRequest) for i,gift_dic in enumerate(gift_list): post_data = { 'appid':365, 'action':1, 'index_id':gift_dic['index_id'], 'uin':constant.USERNAME, 'cb':1, 'r':'0.4827874337788671', 'qzreferrer':'http://qzs.qq.com/snsapp/app/free_gift/index.htm?appid=365&page=receive' } page_content = self.myHttpRequest.get_response(base_url,post_data).read().decode('utf-8') print page_content if u"系统繁忙" in page_content: wx.CallAfter(self.window.updateLog,u'卡箱已满') logging.info(u'卡箱已满') elif u'上限' in page_content: wx.CallAfter(self.window.updateLog,u'收卡上限') logging.info(u'卡箱已满') break else: logging.info(u'接收好友一个礼物') wx.CallAfter(self.window.updateLog,u'接收好友一个礼物') if i>=(limit_receive_time-1): break
def main_page_info(self): postData = { 'code':'', 'uin':constant.USERNAME } base_url = commons.getUrl(constant.CARDLOGINURL,self.myHttpRequest) page_content = self.myHttpRequest.get_response(base_url,postData) magicCardInfo= page_content.read().decode('utf-8') self.get_type_info(constant.STOREBOX,magicCardInfo) self.get_type_info(constant.EXCHANGEBOX,magicCardInfo) pass
def transfer_card(self, des_price, src_price): ''' 变卡 :return: ''' normal_flash_dict = {} if self.types == 0: theme_list = self.window.database.canFlashCardTheme() flash_theme_list = [] for theme_id in theme_list: flash_theme_list.append(theme_id[0]) else: theme_list = self.window.database.get_flash_card_list() flash_theme_list = [] for theme_id in theme_list: flash_theme_list.append(theme_id[2]) normal_flash_dict[theme_id[2]] = theme_id[0] base_url = commons.getUrl(constant.TRANSFER_CARD, self.myHttpRequest) for i, card_id in enumerate(self.exchange_box): if card_id != 0: card_info = self.window.database.getCardInfo(card_id) card_theme = self.window.database.getCardThemeid(card_id) if card_theme in flash_theme_list and int( card_info[2]) == src_price: if self.types == 0: des_theme = card_theme else: des_theme = normal_flash_dict[card_theme] des_card_id = self.get_random_flash_card_id( des_theme, des_price) if des_card_id is not False: self.flashCard(base_url, card_id, des_card_id, 0, i, card_info[0]) for i, card_id in enumerate(self.store_box): if card_id != 0: card_info = self.window.database.getCardInfo(card_id) card_theme = self.window.database.getCardThemeid(card_id) if card_theme in flash_theme_list and int( card_info[2]) == src_price: if self.types == 0: des_theme = card_theme else: des_theme = normal_flash_dict[card_theme] des_card_id = self.get_random_flash_card_id( des_theme, des_price) if des_card_id is not False: self.flashCard(base_url, card_id, des_card_id, 1, i, card_info[0]) wx.CallAfter(self.window.updateLog, u'变卡结束')
def run(self): self.window.database.cu.execute("select * from cardtheme where type=?", (0, )) result = self.window.database.cu.fetchall() logging.basicConfig(filename='error.log') #创建搜索的excel表 for i in range(len(result)): print type(result) themeItem = random.choice(result) result.remove(themeItem) if self.thread_stop: break base_url = commons.getUrl(constant.THEMELISTURL, self.myHttpRequest) postData = {'uin': constant.USERNAME, 'tid': int(themeItem[1])} wx.CallAfter(self.window.updateLog, u'搜索正在炼制' + themeItem[2] + u'套卡的卡友') try: searchCardUserNum = 0 while searchCardUserNum <= constant.CARDUSERNUM: if self.thread_stop: break results = self.myHttpRequest.get_response( base_url, postData).read() soup = BeautifulSoup(results) nodeList = soup.find_all('node') #print u'线程个数',len(nodeList) searchCardUserNum += 10 * len(nodeList) #wx.CallAfter(self.window.updateLog,u'共有'+str(10*len(nodeList))+u'卡友') for i in range(len(nodeList)): mythread = MyThread(self.window, self.myHttpRequest, self.cardtheme, self.cardPrice, nodeList[i], self.searchCardId) mythread.start() self.threadList.append(mythread) for mythread in self.threadList: mythread.join() mythread = [] except: s = traceback.format_exc() logging.error(s) continue print 'stop' wx.CallAfter(self.window.searchComplete)
def transfer_card(self,des_price,src_price): ''' 变卡 :return: ''' normal_flash_dict = {} if self.types==0: theme_list = self.window.database.canFlashCardTheme() flash_theme_list = [] for theme_id in theme_list: flash_theme_list.append(theme_id[0]) else: theme_list = self.window.database.get_flash_card_list() flash_theme_list = [] for theme_id in theme_list: flash_theme_list.append(theme_id[2]) normal_flash_dict[theme_id[2]] = theme_id[0] base_url = commons.getUrl(constant.TRANSFER_CARD,self.myHttpRequest) for i,card_id in enumerate(self.exchange_box): if card_id!=0: card_info = self.window.database.getCardInfo(card_id) card_theme = self.window.database.getCardThemeid(card_id) if card_theme in flash_theme_list and int(card_info[2])==src_price: if self.types==0: des_theme = card_theme else: des_theme =normal_flash_dict[card_theme] des_card_id = self.get_random_flash_card_id(des_theme,des_price) if des_card_id is not False: self.flashCard(base_url,card_id,des_card_id,0,i,card_info[0]) for i,card_id in enumerate(self.store_box): if card_id!=0: card_info = self.window.database.getCardInfo(card_id) card_theme = self.window.database.getCardThemeid(card_id) if card_theme in flash_theme_list and int(card_info[2])==src_price: if self.types==0: des_theme = card_theme else: des_theme =normal_flash_dict[card_theme] des_card_id = self.get_random_flash_card_id(des_theme,des_price) if des_card_id is not False: self.flashCard(base_url,card_id,des_card_id,1,i,card_info[0]) wx.CallAfter(self.window.updateLog,u'变卡结束')
def saleCard(self,cardId,slotNo): if cardId!=1162: postData = { 'slot_no':slotNo, 'uin':self.current_account, 'type':0, 'cardid':cardId } base_url = commons.getUrl(constant.SALECARD,self.myHttpRequest) page_content = self.myHttpRequest.get_response(base_url,postData).read().decode('utf-8') print page_content self.operateLogUpdate(u'出售卡片 :'+self.exchangeBoxlist.GetItemText(slotNo,1)) for i in range(1,4): self.exchangeBoxlist.SetStringItem(slotNo,i,"") self.exchangeBox[slotNo] = 0 else: self.operateLogUpdate(u'无法出售百变卡')
def run(self): self.window.database.cu.execute("select * from cardtheme where type=?",(0,)) result =self.window.database.cu.fetchall() logging.basicConfig(filename='error.log') #创建搜索的excel表 for i in range(len(result)): print type(result) themeItem = random.choice(result) result.remove(themeItem) if self.thread_stop: break base_url = commons.getUrl(constant.THEMELISTURL,self.myHttpRequest) postData = { 'uin':constant.USERNAME, 'tid':int(themeItem[1]) } wx.CallAfter(self.window.updateLog,u'搜索正在炼制'+themeItem[2]+u'套卡的卡友') try: searchCardUserNum = 0; while searchCardUserNum<=constant.CARDUSERNUM: if self.thread_stop: break results = self.myHttpRequest.get_response(base_url,postData).read() soup = BeautifulSoup(results) nodeList = soup.find_all('node') #print u'线程个数',len(nodeList) searchCardUserNum +=10*len(nodeList) #wx.CallAfter(self.window.updateLog,u'共有'+str(10*len(nodeList))+u'卡友') for i in range(len(nodeList)): mythread = MyThread(self.window,self.myHttpRequest,self.cardtheme,self.cardPrice,nodeList[i],self.searchCardId) mythread.start() self.threadList.append(mythread) for mythread in self.threadList: mythread.join() mythread = [] except : s = traceback.format_exc() logging.error(s) continue print 'stop' wx.CallAfter(self.window.searchComplete)
def gq_login(self): ''' 国庆登陆礼包领取 :return: ''' for key in self.account_list: try: value = self.__class__.account_http_dic[key] except KeyError: continue base_url = commons.getUrl(constant.GQGETGIFTS,value) post_data = { 'act':1 } page_content = value.get_response(base_url,post_data).read().decode('utf-8') logging.info(page_content) result = '' if 'pack_str' in page_content: card_list = re.findall('(\d+)_(.*?)_(\d+)',page_content,re.S) for list_item in card_list: if list_item[0] in constant.GIFTDICT: result += constant.GIFTDICT[list_item[0]]+'*'+list_item[2] elif list_item[0] =='48': if list_item[1]=='19': result+=u'积分'+'*'+list_item[2] elif list_item[1]=='14': result+= u'7天租铺卡'+'*'+list_item[2] elif list_item[1]=='8': result+= u'3天累计卡'+'*'+list_item[2] elif list_item[1]=='17': result+= u'3天经验卡'+'*'+list_item[2] elif list_item[1]=='18': result+= u'7天经验卡'+'*'+list_item[2] else: result+= u'未知',list_item logging.info(list_item[0]+','+list_item[1]+','+list_item[2]) result+=',' else: wx.CallAfter(self.operateLogUpdate,str(key)+u'今天已经领取过了') if result!='': wx.CallAfter(self.operateLogUpdate,str(key)+result) wx.CallAfter(self.operateLogUpdate,u'一键任务完成')
def act_get_score(self): ''' 查看茱萸个数 :return: ''' for key in self.account_list: try: value = self.__class__.account_http_dic[key] except KeyError: continue base_url = commons.getUrl(constant.ACTEGG,value) post_data = { 'act':4 } content_page = value.get_response(base_url,post_data).read().decode('utf-8') xf_dian = int(json.loads(content_page)['vt26']) wx.CallAfter(self.operateLogUpdate,str(key)+u'茱萸个数:'+str(xf_dian)) wx.CallAfter(self.operateLogUpdate,u'一键任务完成')
def act_open_happy_card(self): ''' 一键打开幸福卡 :return: ''' for account in self.account_list: try: value = self.__class__.account_http_dic[account] except KeyError: continue base_url = commons.getUrl(constant.GQACTIVITY,value) post_data = { 'act':7, } page_content = value.get_response(base_url,post_data).read().decode('utf-8') result = '' if 'pack_str' in page_content: card_list = re.findall('(\d+)_(.*?)_(\d+)',page_content,re.S) for list_item in card_list: if list_item[0] in constant.GIFTDICT: result += constant.GIFTDICT[list_item[0]]+'*'+list_item[2] elif list_item[0] =='48': if list_item[1]=='19': result+=u'积分'+'*'+list_item[2] elif list_item[1]=='14': result+= u'7天租铺卡'+'*'+list_item[2] elif list_item[1]=='8': result+= u'3天累计卡'+'*'+list_item[2] elif list_item[1]=='17': result+= u'3天经验卡'+'*'+list_item[2] elif list_item[1]=='18': result+= u'7天经验卡'+'*'+list_item[2] else: result+= u'未知',list_item logging.info(list_item[0]+','+list_item[1]+','+list_item[2]) result+=',' if result!='': wx.CallAfter(self.operateLogUpdate,str(account)+result) else: wx.CallAfter(self.operateLogUpdate,str(account)+u'无幸福卡打开') wx.CallAfter(self.operateLogUpdate,u'一键任务完成')
def get_gq_gift(self,gq_id): ''' 领取国庆累计登录礼包 :param gq_id: :return: ''' for key in self.account_list: try: value = self.__class__.account_http_dic[key] except KeyError: continue base_url = commons.getUrl(constant.GQGETGIFTS,value) post_data = { 'act':2, 'id':gq_id, } page_content = value.get_response(base_url,post_data).read().decode('utf--8') if 'sucess' in page_content: wx.CallAfter(self.operateLogUpdate,str(key)+u'领取国庆累计登录礼包成功') else: wx.CallAfter(self.operateLogUpdate,str(key)+u'领取国庆累计登录礼包失败') wx.CallAfter(self.operateLogUpdate,u'一键任务完成')
def card_user_storage_exchange(self,type,src,cardId): des = -1 if type==0: logging.info(self.storeBox) for i,cardIdTemp in enumerate(self.storeBox): if cardIdTemp == 0: des = i break else: des = self.exchangeBoxEmpty() postData = { 'dest':des, 'src':src, 'type':type, 'uin':self.current_account, } base_url = commons.getUrl(constant.CARDINPUTSTOREBOX,self.myHttpRequest) self.myHttpRequest.get_response(base_url,postData) if type==0: self.operateLogUpdate(u'卡片 :'+self.exchangeBoxlist.GetItemText(src,1)+u'放入保险箱') self.storeBox[des] = cardId self.exchangeBox[src]=0 else: self.operateLogUpdate(u'卡片 :'+self.safeBoxlist.GetItemText(src,1)+u'放入换卡箱') self.exchangeBox[des] = cardId self.storeBox[src]=0 for i in range(1,4): if type==0: #print 'src',str(src),'des',str(des),'col',str(i),self.exchangeBoxlist.GetItemText(src,i) self.safeBoxlist.SetStringItem(des,i,self.exchangeBoxlist.GetItemText(src,i)) self.exchangeBoxlist.SetStringItem(src,i,"") else: #print 'src',str(src),'des',str(des),'col',str(i),self.safeBoxlist.GetItemText(src,i) self.exchangeBoxlist.SetStringItem(des,i,self.safeBoxlist.GetItemText(src,i)) self.safeBoxlist.SetStringItem(src,i,"")
def act_exchange_score(self,m_id,is_complete=False): ''' 积分兑换礼物 :param m_id: :return: ''' for account in self.account_list: try: value = self.__class__.account_http_dic[account] except KeyError: continue base_url = commons.getUrl(constant.ACTEGG,value) post_data = { 'act':6, 'id':m_id } page_content = value.get_response(base_url,post_data).read().decode('utf-8') if 'sucess' in page_content: wx.CallAfter(self.operateLogUpdate,str(account)+u'兑换成功') if m_id==2 and is_complete: base_url =constant.COMMITCARD base_url = base_url.replace('SID', urllib.quote(self.accout_sid_dic[account])) base_url = base_url.replace('THEMEID',str(428)) page_content = value.get_response(base_url) result_content = page_content.read().decode('utf-8') print result_content logging.info(result_content) if u'成功放入集卡册' in result_content: wx.CallAfter(self.operateLogUpdate,u'提交套卡成功') elif u'找不到相应的记录' in result_content: wx.CallAfter(self.operateLogUpdate,u'提交失败,请检查卡片是否齐全') else: wx.CallAfter(self.operateLogUpdate,str(account)+u'兑换失败') wx.CallAfter(self.operateLogUpdate,u'一键任务完成')
def getRefineCard(self): print u'卡炉卡片完成情况',self.slovelist print u'偷炉信息',self.windows.stealFriend #这里需要增加收获czg的卡片 for i, czg in enumerate(self.windows.czgComplete): if czg == 1: base_url = commons.getUrl(constant.ZCGINFOURL, self.windows.myHttpRequest) postData = { 'act': 5, 'puzi_id': self.windows.zcgInfoDic[i] } result = self.windows.myHttpRequest.get_response(base_url, postData).read().decode('utf-8') logging.info(u'收取珍藏阁卡片'+result) print result mojing_list = json.loads(result) for item in constant.MOJINGDICT.keys(): if mojing_list[item]!=0: wx.CallAfter(self.windows.operateLogUpdate,u'收获珍藏阁物品,获得'+constant.MOJINGDICT[item]+str(mojing_list[item])+u'个') self.windows.czgComplete[i] = -1 for i,cardId in enumerate(self.windows.stoveBox): if cardId==0: self.emptySlove +=1 #myslovelist.append(0) elif self.slovelist[i]==1: if i==(len(self.slovelist)-1): print 'get steal ',self.windows.stealFriend[-1] self.postData = { 'ver':1, 'slotid':i, 'code':'', 'slottype':1, 'uin':constant.USERNAME, 'opuin':self.windows.stealFriend[-1] } base_url = self.windows.getUrl(constant.GETSTEALCARD) del self.windows.stealFriend[-1] elif constant.ISRED==1 and i==(len(self.slovelist)-2): if len(self.windows.stealFriend)<=1: friend = self.windows.stealFriend[0] index = 0 else: friend = self.windows.stealFriend[1] index =1 print 'get steal ',friend self.postData = { 'ver':1, 'slotid':i, 'code':'', 'slottype':1, 'uin':constant.USERNAME, 'opuin':friend } base_url = self.windows.getUrl(constant.GETSTEALCARD) del self.windows.stealFriend[index] else: self.postData = { 'ver':1, 'slotid':i, 'code':'', 'slottype':1, 'uin':constant.USERNAME } base_url = self.windows.getUrl(constant.REFINEDCARD) page_content = self.windows.myHttpRequest.get_response(base_url,self.postData) result = page_content.read().decode('utf-8') print u'收获卡片返回信息',result logging.info(u'收获卡片返回信息'+result) if i!=(len(self.slovelist)-1): self.fanpai() soup = BeautifulSoup(result) wx.CallAfter(self.windows.operateLogUpdate,u'收获卡片 :'+self.windows.database.getCardInfo(soup.card['id'])[0]) self.windows.stoveBox[i] = 0 self.windows.storeBox[int(soup.card['slot'])] = int(soup.card['id']) wx.CallAfter(self.windows.updateStoreBox,soup.card['id'],soup.card['slot'],i) time.sleep(2) self.emptySlove+=1
def run(self): self.window.database.cu.execute( "select * from cardtheme where type=? or type=? or type=? or type=? or type=?", (0, 9, 5, 1, 2)) result = self.window.database.cu.fetchall() #创建搜索的excel表 result_list = dict.fromkeys(result, True) len1 = len(result) for i in xrange(len1): if i == 0 or self.search_range_theme_id != -1: if self.search_range_theme_id == -1: self.window.database.cu.execute( "select * from cardtheme where pid=?", (self.cardtheme, )) else: self.window.database.cu.execute( "select * from cardtheme where pid=?", (self.search_range_theme_id, )) searchResult = self.window.database.cu.fetchall() themeItem = searchResult[0] if themeItem not in result_list: themeItem = random.choice(result) result.remove(themeItem) del result_list[themeItem] else: themeItem = random.choice(result) result.remove(themeItem) del result_list[themeItem] if self.thread_stop: break base_url = commons.getUrl(constant.THEMELISTURL, self.myHttpRequest) print base_url postData = {'uin': constant.USERNAME, 'tid': int(themeItem[1])} print 'themeItem', themeItem[1] wx.CallAfter(self.window.updateLog, u'搜索正在炼制' + themeItem[2] + u'套卡的卡友') try: searchCardUserNum = 0 searchCardNum = int(constant.CARDUSERNUM) while searchCardUserNum < searchCardNum: # wx.CallAfter(self.window.update_search_progress,searchCardUserNum) if self.thread_stop: break results = self.myHttpRequest.get_response( base_url, postData).read() soup = BeautifulSoup(results) nodeList = soup.find_all('node') if len(nodeList) == 0: break #print u'线程个数',len(nodeList) searchCardUserNum += 10 * len(nodeList) #wx.CallAfter(self.window.updateLog,u'共有'+str(10*len(nodeList))+u'卡友') len2 = len(nodeList) for i in xrange(len2): mythread = MyThread(self.window, self.myHttpRequest, self.cardtheme, self.cardPrice, nodeList[i], self.searchCardId, self.is_show_flash_card) mythread.start() self.threadList.append(mythread) for mythread in self.threadList: mythread.join(30) print searchCardUserNum wx.CallAfter(self.window.update_search_progress, searchCardUserNum) self.threadList = [] except: s = traceback.format_exc() logging.error(s) continue print 'stop' wx.CallAfter(self.window.searchComplete)
def run(self): userList = [] soup = BeautifulSoup(str(self.nodeItem)) uinlist = soup.node['uin'] uinList = uinlist.split('|') for uin in uinList: userList.append(uin) for user in userList: try: print 'search user', user if user == '': continue base_url = commons.getUrl(constant.CARDLOGINURL, self.myHttpRequest) postData = { 'uin': constant.USERNAME, 'opuin': user, } result = self.myHttpRequest.get_response(base_url, postData).read() soup = BeautifulSoup(result) soup2 = BeautifulSoup(str(soup.changebox)) collectThemelist = soup2.changebox['exch'].split(',') #print collectThemelist cardlist = soup2.find_all('card') for item in cardlist: soup3 = BeautifulSoup(str(item)) pid = int(soup3.card['id']) cardThemeId = self.database.getCardThemeid(pid) if cardThemeId == self.cardtheme: print 'cardPrice', self.cardPrice if self.cardPrice == u'全部': exchStr = u'对方设置的交换主题:' exchCardTheme = '' hasSetExch = False for collectTheme in collectThemelist: if int(collectTheme) != 0: hasSetExch = True exchCardTheme += self.database.getCardThemeName( int(collectTheme)) + ',' exchStr += exchCardTheme if not hasSetExch: exchStr = u'对方设置的交换主题:无' exchCardTheme = u'无' wx.CallAfter(self.window.updateCardFriend, user, exchCardTheme) msg = user + ',' + exchStr wx.CallAfter(self.window.updateLog, msg) else: if self.database.getCardInfo( pid)[2] == self.cardPrice and ( self.searchCardId == -1 or pid == self.searchCardId): exchStr = u'对方设置的交换主题:' exchCardTheme = '' hasSetExch = False for collectTheme in collectThemelist: if int(collectTheme) != 0: hasSetExch = True exchCardTheme += self.database.getCardThemeName( int(collectTheme)) + ',' exchStr += exchCardTheme if not hasSetExch: exchStr = u'对方设置的交换主题:无' exchCardTheme = u'无' msg = user + ',' + exchStr wx.CallAfter(self.window.updateCardFriend, user, exchCardTheme) wx.CallAfter(self.window.updateLog, msg) break cardlist = [] if self.thread_stop: return time.sleep(0.3) except: s = traceback.format_exc() logging.error(s) userList = []
def getZCGInfo(self): base_url = commons.getUrl(constant.ZCGINFOURL, self.myHttpRequest) postData = {'opuin': constant.USERNAME, 'act': 1} return self.myHttpRequest.get_response(base_url, postData).read()
def send_card(self): ''' 小号送祝福卡 :return: ''' flag = False send_friend = self.account_send_gift_text.GetValue() if send_friend=='': j = 0 for account in self.account_list: try: value = self.__class__.account_http_dic[account] except KeyError: continue base_url = commons.getUrl(constant.GQACTIVITY,value) post_data = { 'act':1 } content_page = value.get_response(base_url,post_data).read().decode('utf-8') count = int(json.loads(content_page)['jf']) for i in range(0,count): post_data = { 'act':6, 'opuin':int(self.account_list[j]) } content_page = value.get_response(base_url,post_data).read().decode('utf-8') if u'10份'in content_page: wx.CallAfter(self.operateLogUpdate,str(send_friend)+u'该好友已经收满10份祝福卡') j +=1 else: wx.CallAfter(self.operateLogUpdate,str(account)+u'送祝福卡成功') else: for key in self.account_list: try: value = self.__class__.account_http_dic[key] except KeyError: continue base_url = commons.getUrl(constant.GQACTIVITY,value) post_data = { 'act':1 } content_page = value.get_response(base_url,post_data).read().decode('utf-8') count = int(json.loads(content_page)['jf']) # wx.CallAfter(self.operateLogUpdate,str(key)+u'有'+str(count)+u'祝福卡') for i in range(0,count): post_data = { 'act':6, 'opuin':int(send_friend) } content_page = value.get_response(base_url,post_data).read().decode('utf-8') print content_page if u'10份'in content_page: wx.CallAfter(self.operateLogUpdate,str(send_friend)+u'该好友已经收满10份祝福卡') flag = True break else: wx.CallAfter(self.operateLogUpdate,str(key)+u'送祝福卡成功') if flag: break
def transfer_card(self,des_card_theme,src_card_theme,des_price,src_price,is_flash_card,): ''' 变卡 :return: ''' base_url = commons.getUrl(constant.TRANSFER_CARD,self.myHttpRequest) for k in range(self.flash_num): src_card_id = -1 slottype = -1 slotid = -1 for i,exchang_card_id in enumerate(self.exchange_box): if exchang_card_id!=0: # print exchang_card_id,self.window.database.getCardThemeid(exchang_card_id),self.window.database.getCardInfo(exchang_card_id)[2] if int(self.window.database.getCardThemeid(exchang_card_id))==int(src_card_theme) and int(self.window.database.getCardInfo(exchang_card_id)[2])==int(src_price) : slottype = 0 src_card_id = exchang_card_id slotid = i break if slotid ==-1: for i,store_card_id in enumerate(self.store_box): if store_card_id!=0: # print store_card_id,src_card_theme,self.window.database.getCardThemeid(store_card_id),self.window.database.getCardInfo(store_card_id)[2],src_price if int(self.window.database.getCardThemeid(store_card_id))==int(src_card_theme) and int(self.window.database.getCardInfo(store_card_id)[2])==int(src_price) : slottype = 1 src_card_id = store_card_id slotid = i break if slotid==-1: break #是否变闪卡 if is_flash_card: flash_card_str = u'(闪)' kind = 1 types = 5 else: flash_card_str = u'' kind = 0 types = 2 des_card_id = self.get_random_flash_card_id(des_card_theme,des_price) # print des_card_id,slottype,kind,src_card_id,slotid,types post_data = { 'dstid':des_card_id, 'slottype':slottype, 'kind':kind, 'srcid':src_card_id, 'uin':constant.USERNAME, 'slotid':slotid, 'type':types } page_content = self.myHttpRequest.get_response(base_url,post_data).read().decode('utf-8') logging.info(u'变卡结果'+page_content) if '-33087' in page_content: wx.CallAfter(self.window.updateLog,u'该普卡您还未收集齐') logging.info(u'该普卡您还未收集齐') break elif 'result=\"1\"' in page_content: if slottype==0: self.exchange_box[slotid] = des_card_id else: self.store_box[slotid] = des_card_id wx.CallAfter(self.window.updateLog,u'变'+flash_card_str+self.window.database.getCardInfo(des_card_id)[0]+u'成功') logging.info(u'变'+flash_card_str+self.window.database.getCardInfo(des_card_id)[0]+u'成功') else: if slottype==0: self.exchange_box[slotid] = 0 else: self.store_box[slotid] = 0 wx.CallAfter(self.window.updateLog,u'变'+flash_card_str+self.window.database.getCardInfo(des_card_id)[0]+u'失败') logging.info(u'变'+flash_card_str+self.window.database.getCardInfo(des_card_id)[0]+u'失败')
def account_commission(self): ''' 国庆任务提交 :return: ''' for key in self.account_list: try: value = self.__class__.account_http_dic[key] except KeyError: continue try: levelup = commons.getUrl(constant.LEVELUP,value) post_data = { 'uin':key } value.get_response(levelup,post_data).read().decode('utf-8') mobileHttp = myhttp.MyHttpRequest() base_url = commons.getUrl(constant.GQACTIVITY,value) post_data={ 'act':1, } value.get_response(base_url,post_data).read().decode('utf-8') post_data={ 'act':2, } logging.info(value.get_response(base_url,post_data).read().decode('utf-8')) wx.CallAfter(self.operateLogUpdate,str(key)+u'接受国庆任务') post_data = { 'act':3, 'id':13, } page_content = value.get_response(base_url,post_data).read().decode('utf-8') if u'没有完成' in page_content or u'系统繁忙' in page_content : wx.CallAfter(self.operateLogUpdate,str(key)+u'完成每日登陆游戏失败') else: wx.CallAfter(self.operateLogUpdate,str(key)+u'每日登陆任务已完成') wx.CallAfter(self.operateLogUpdate,str(key)+u'检查卡炉是否有可收的卡') mobile_url = constant.MOBILEMAINPAGE mobile_url = mobile_url.replace('SID',urllib.quote(self.accout_sid_dic[key])) page_content = mobileHttp.get_response(mobile_url).read().decode('utf-8') cardcomplete = commons.getStoveBoxInfo(commons.getMagicInfo(value,key)) if u'取卡' in page_content and 1 in cardcomplete: wx.CallAfter(self.operateLogUpdate,str(key)+u'有卡可以收获') mobile_url = constant.MOBILEREFINEDCARD mobile_url.replace('SID',self.accout_sid_dic[key]) position = cardcomplete.index(1) mobile_refined_url = constant.MOBILEREFINEDCARD.replace('SID',urllib.quote(self.accout_sid_dic[key])) mobile_refined_url +=str(position) print mobile_refined_url wx.CallAfter(self.operateLogUpdate,str(key)+u'收获卡片') mobileHttp.get_response(mobile_refined_url).read().decode('utf-8') wx.CallAfter(self.operateLogUpdate,str(key)+u'提交任务收获卡片任务') post_data = { 'act':3, 'id':2, } page_content = value.get_response(base_url,post_data).read().decode('utf-8') print page_content if u'没有完成' in page_content or u'系统繁忙' in page_content : wx.CallAfter(self.operateLogUpdate,str(key)+u'取卡任务失败') else: wx.CallAfter(self.operateLogUpdate,str(key)+u'取卡任务已完成') wx.CallAfter(self.operateLogUpdate,str(key)+u'进行翻牌') commons.fanpai(value) post_data = { 'act':3, 'id':3, } page_content = value.get_response(base_url,post_data).read().decode('utf-8') if u'没有完成' in page_content or u'系统繁忙' in page_content : wx.CallAfter(self.operateLogUpdate,str(key)+u'翻牌任务失败') else: wx.CallAfter(self.operateLogUpdate,str(key)+u'翻牌任务已完成') else: wx.CallAfter(self.operateLogUpdate,str(key)+u'没有可收获的先进行炼卡,请一小时后重新进行任务') mobile_card_url = constant.MOBILELIANCARD.replace('SID',urllib.quote(self.accout_sid_dic[key])) mobileHttp.get_response(mobile_card_url).read() except: wx.CallAfter(self.operateLogUpdate,str(key)+u'做任务出现异常') wx.CallAfter(self.operateLogUpdate,u'一键任务完成')
def run(self): userList = [] soup = BeautifulSoup(str(self.nodeItem)) uinlist = soup.node['uin'] uinList = uinlist.split('|') for uin in uinList: userList.append(uin) for user in userList: try: print 'search user',user if user=='': continue base_url = commons.getUrl(constant.CARDLOGINURL,self.myHttpRequest) postData = { 'uin':constant.USERNAME, 'opuin':user, } result = self.myHttpRequest.get_response(base_url,postData).read() soup = BeautifulSoup(result) soup2 = BeautifulSoup(str(soup.changebox)) collectThemelist = soup2.changebox['exch'].split(',') #print collectThemelist cardlist = soup2.find_all('card') for item in cardlist: soup3 = BeautifulSoup(str(item)) pid = int(soup3.card['id']) cardThemeId = self.database.getCardThemeid(pid) if cardThemeId==self.cardtheme: print 'cardPrice',self.cardPrice if self.cardPrice==u'全部': exchStr = u'对方设置的交换主题:' exchCardTheme = '' hasSetExch = False for collectTheme in collectThemelist: if int(collectTheme)!=0: hasSetExch = True exchCardTheme +=self.database.getCardThemeName(int(collectTheme))+',' exchStr +=exchCardTheme if not hasSetExch: exchStr = u'对方设置的交换主题:无' exchCardTheme = u'无' wx.CallAfter(self.window.updateCardFriend,user,exchCardTheme) msg = user+','+exchStr wx.CallAfter(self.window.updateLog,msg) else: if self.database.getCardInfo(pid)[2]==self.cardPrice and (self.searchCardId==-1 or pid==self.searchCardId) : exchStr = u'对方设置的交换主题:' exchCardTheme = '' hasSetExch = False for collectTheme in collectThemelist: if int(collectTheme)!=0: hasSetExch = True exchCardTheme +=self.database.getCardThemeName(int(collectTheme))+',' exchStr +=exchCardTheme if not hasSetExch: exchStr = u'对方设置的交换主题:无' exchCardTheme = u'无' msg = user+','+exchStr wx.CallAfter(self.window.updateCardFriend,user,exchCardTheme) wx.CallAfter(self.window.updateLog,msg) break cardlist = [] if self.thread_stop: return time.sleep(0.3) except: s = traceback.format_exc() logging.error(s) userList = []
def run(self): self.window.database.cu.execute("select * from cardtheme where type=? or type=? or type=? or type=? or type=?",(0,9,5,1,2)) result =self.window.database.cu.fetchall() #创建搜索的excel表 result_list = dict.fromkeys(result,True) len1 = len(result) for i in xrange(len1): if i==0 or self.search_range_theme_id!=-1: if self.search_range_theme_id==-1: self.window.database.cu.execute("select * from cardtheme where pid=?",(self.cardtheme,)) else: self.window.database.cu.execute("select * from cardtheme where pid=?",(self.search_range_theme_id,)) searchResult =self.window.database.cu.fetchall() themeItem = searchResult[0] if themeItem not in result_list: themeItem = random.choice(result) result.remove(themeItem) del result_list[themeItem] else: themeItem = random.choice(result) result.remove(themeItem) del result_list[themeItem] if self.thread_stop: break base_url = commons.getUrl(constant.THEMELISTURL,self.myHttpRequest) print base_url postData = { 'uin':constant.USERNAME, 'tid':int(themeItem[1]) } print 'themeItem',themeItem[1] wx.CallAfter(self.window.updateLog,u'搜索正在炼制'+themeItem[2]+u'套卡的卡友') try: searchCardUserNum = 0 searchCardNum = int(constant.CARDUSERNUM) while searchCardUserNum<searchCardNum: # wx.CallAfter(self.window.update_search_progress,searchCardUserNum) if self.thread_stop: break results = self.myHttpRequest.get_response(base_url,postData).read() soup = BeautifulSoup(results) nodeList = soup.find_all('node') if len(nodeList)==0: break #print u'线程个数',len(nodeList) searchCardUserNum +=10*len(nodeList) #wx.CallAfter(self.window.updateLog,u'共有'+str(10*len(nodeList))+u'卡友') len2 = len(nodeList) for i in xrange(len2): mythread = MyThread(self.window,self.myHttpRequest,self.cardtheme,self.cardPrice,nodeList[i],self.searchCardId,self.is_show_flash_card) mythread.start() self.threadList.append(mythread) for mythread in self.threadList: mythread.join(30) print searchCardUserNum wx.CallAfter(self.window.update_search_progress,searchCardUserNum) self.threadList = [] except : s = traceback.format_exc() logging.error(s) continue print 'stop' wx.CallAfter(self.window.searchComplete)
def exchange_card(self, position, dst_card_id, card_price, card_name, account, types): """ 卡片交换 :param position: :param card_id: :param card_price: :param account: :param type: :return: """ base_url = commons.getUrl(constant.EXCHANGECARD, self.myHttpRequest) src_card_id = -1 src_type = -1 src_position = -1 src_card_name = "" for i, card_id in enumerate(self.user_exchange_box): if int(card_id) != 0: card_info = self.window.database.getCardInfo2(card_id) if ( not self.window.database.isOffCard(card_id) and card_info[2] != self.cardtheme and card_info[1] == card_price ): src_card_name = card_info[0] src_card_id = card_id src_type = 0 src_position = i break if src_card_id == -1: for i, card_id in enumerate(self.user_store_box): if int(card_id) != 0: card_info = self.window.database.getCardInfo2(card_id) if ( not self.window.database.isOffCard(card_id) and card_info[2] != self.cardtheme and card_info[1] == card_price ): src_card_name = card_info[0] src_card_id = card_id src_type = 1 src_position = i break if src_card_id != -1: src = str(src_card_id) + "_" + str(src_position) + "_" + str(src_type) dst = str(dst_card_id) + "_" + str(position) + "_" + str(types) post_data = { "cmd": 1, "isFriend": 1, "frnd": str(account), "uin": str(constant.USERNAME), "dst": dst, "src": src, } print post_data page_content = self.myHttpRequest.get_response(base_url, post_data).read().decode("utf-8") print page_content if 'code="0"' in page_content: wx.CallAfter(self.window.updateLog, u"与卡友" + str(account) + u"交换卡片" + src_card_name + "->" + card_name) if src_type == 0: self.user_exchange_box[src_position] = dst_card_id else: self.user_store_box[src_position] = dst_card_id else: wx.CallAfter(self.window.updateLog, u"与卡友" + str(account) + u"交换卡片失败") return page_content else: return -1 pass
def getRefineCard(self): print u'卡炉卡片完成情况', self.slovelist print u'偷炉信息', self.windows.stealFriend #这里需要增加收获czg的卡片 for i, czg in enumerate(self.windows.czgComplete): if czg == 1: base_url = commons.getUrl(constant.ZCGINFOURL, self.windows.myHttpRequest) postData = {'act': 5, 'puzi_id': self.windows.zcgInfoDic[i]} result = self.windows.myHttpRequest.get_response( base_url, postData).read().decode('utf-8') logging.info(u'收取珍藏阁卡片' + result) print result mojing_list = json.loads(result) for item in constant.MOJINGDICT.keys(): if mojing_list[item] != 0: wx.CallAfter( self.windows.operateLogUpdate, u'收获珍藏阁物品,获得' + constant.MOJINGDICT[item] + str(mojing_list[item]) + u'个') self.windows.czgComplete[i] = -1 for i, cardId in enumerate(self.windows.stoveBox): if cardId == 0: self.emptySlove += 1 #myslovelist.append(0) elif self.slovelist[i] == 1: if i == (len(self.slovelist) - 1): print 'get steal ', self.windows.stealFriend[-1] self.postData = { 'ver': 1, 'slotid': i, 'code': '', 'slottype': 1, 'uin': constant.USERNAME, 'opuin': self.windows.stealFriend[-1] } base_url = self.windows.getUrl(constant.GETSTEALCARD) del self.windows.stealFriend[-1] elif constant.ISRED == 1 and i == (len(self.slovelist) - 2): if len(self.windows.stealFriend) <= 1: friend = self.windows.stealFriend[0] index = 0 else: friend = self.windows.stealFriend[1] index = 1 print 'get steal ', friend self.postData = { 'ver': 1, 'slotid': i, 'code': '', 'slottype': 1, 'uin': constant.USERNAME, 'opuin': friend } base_url = self.windows.getUrl(constant.GETSTEALCARD) del self.windows.stealFriend[index] else: self.postData = { 'ver': 1, 'slotid': i, 'code': '', 'slottype': 1, 'uin': constant.USERNAME } base_url = self.windows.getUrl(constant.REFINEDCARD) page_content = self.windows.myHttpRequest.get_response( base_url, self.postData) result = page_content.read().decode('utf-8') print u'收获卡片返回信息', result logging.info(u'收获卡片返回信息' + result) if i != (len(self.slovelist) - 1): self.fanpai() soup = BeautifulSoup(result) wx.CallAfter( self.windows.operateLogUpdate, u'收获卡片 :' + self.windows.database.getCardInfo(soup.card['id'])[0]) self.windows.stoveBox[i] = 0 self.windows.storeBox[int(soup.card['slot'])] = int( soup.card['id']) wx.CallAfter(self.windows.updateStoreBox, soup.card['id'], soup.card['slot'], i) time.sleep(2) self.emptySlove += 1
def MenuSelectionCb(self, event ): print event.GetId() card_info = commons.getMagicInfo2(main.RefinedCard.main_http_request,self.selectAccount) self.httpRequest = accountManage.AccountManage.account_http_dic[self.selectAccount] exchange_box = commons.get_type_info(constant.EXCHANGEBOX,card_info) store_box = commons.get_type_info(constant.STOREBOX,card_info) dst_card_id = self.windows.select_card_id dst_type = 0 dst_position = -1 if self.windows.select_card_id in exchange_box: dst_position = exchange_box.index(self.windows.select_card_id) elif self.windows.select_card_id in store_box: src_position = store_box.index(self.windows.select_card_id) if 0 in exchange_box: dst_position = exchange_box.index(0) postData = { 'dest':dst_position, 'src':src_position, 'type':1, 'uin':self.selectAccount, } base_url = commons.getUrl(constant.CARDINPUTSTOREBOX,self.httpRequest) self.httpRequest.get_response(base_url,postData).read().decode('utf-8') if dst_position != -1: base_url1 = commons.getUrl(constant.SETTHEME,self.httpRequest) post_data = { 'themes':0 } self.httpRequest.get_response(base_url1,post_data).read().decode('utf-8') dst = str(dst_card_id)+"_"+str(dst_position)+"_"+str(dst_type) card_info = self.windows.exchang_card_info_dic[event.GetId()] src = str(card_info[2])+"_"+str(card_info[1])+"_"+str(card_info[0]) base_url = commons.getUrl(constant.EXCHANGECARD,main.RefinedCard.main_http_request) post_data ={ 'cmd':1, 'isFriend':0, 'frnd':str(self.selectAccount), 'uin':str(constant.USERNAME), 'dst':dst, 'src':src } page_content = main.RefinedCard.main_http_request.get_response(base_url,post_data).read().decode('utf-8') post_data = { 'themes':153 } self.httpRequest.get_response(base_url1,post_data).read().decode('utf-8') if 'code="0"' in page_content: dlg = wx.MessageDialog(None, u"换卡成功", u"提示", wx.OK | wx.ICON_QUESTION) else: dlg = wx.MessageDialog(None, u"换卡成功", u"提示", wx.OK | wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: self.Close(True) dlg.Destroy() else: dlg = wx.MessageDialog(None, u"换卡箱已满或卡片不存在", u"提示", wx.OK | wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: self.Close(True) dlg.Destroy() #accountManage.AccountManage.account_http_dic.items() if 1==event.GetId(): pass
def transfer_card( self, des_card_theme, src_card_theme, des_price, src_price, is_flash_card, ): ''' 变卡 :return: ''' base_url = commons.getUrl(constant.TRANSFER_CARD, self.myHttpRequest) for k in range(self.flash_num): src_card_id = -1 slottype = -1 slotid = -1 for i, exchang_card_id in enumerate(self.exchange_box): if exchang_card_id != 0: print exchang_card_id, self.window.database.getCardThemeid( exchang_card_id), self.window.database.getCardInfo( exchang_card_id)[2] if int(self.window.database.getCardThemeid( exchang_card_id)) == int(src_card_theme) and int( self.window.database.getCardInfo( exchang_card_id)[2]) == int(src_price): slottype = 0 src_card_id = exchang_card_id slotid = i break if slotid == -1: for i, store_card_id in enumerate(self.store_box): if store_card_id != 0: print store_card_id, self.window.database.getCardThemeid( store_card_id), self.window.database.getCardInfo( store_card_id)[2] if int( self.window.database.getCardThemeid( store_card_id) ) == int(src_card_theme) and int( self.window.database.getCardInfo(store_card_id) [2]) == int(src_price): slottype = 1 src_card_id = store_card_id slotid = i break if slotid == -1: break #是否变闪卡 if is_flash_card: flash_card_str = u'(闪)' kind = 1 types = 5 else: flash_card_str = u'' kind = 0 types = 2 des_card_id = self.get_random_flash_card_id( des_card_theme, des_price) post_data = { 'dstid': des_card_id, 'slottype': slottype, 'kind': kind, 'srcid': src_card_id, 'uin': constant.USERNAME, 'slotid': slotid, 'type': types } page_content = self.myHttpRequest.get_response( base_url, post_data).read().decode('utf-8') logging.info(u'变卡结果' + page_content) if '-33087' in page_content: wx.CallAfter(self.window.updateLog, u'该普卡您还未收集齐') logging.info(u'该普卡您还未收集齐') break elif 'result=\"1\"' in page_content: if slottype == 0: self.exchange_box[slotid] = des_card_id else: self.store_box[slotid] = des_card_id wx.CallAfter( self.window.updateLog, u'变' + flash_card_str + self.window.database.getCardInfo(des_card_id)[0] + u'成功') logging.info(u'变' + flash_card_str + self.window.database.getCardInfo(des_card_id)[0] + u'成功') else: if slottype == 0: self.exchange_box[slotid] = 0 else: self.store_box[slotid] = 0 wx.CallAfter( self.window.updateLog, u'变' + flash_card_str + self.window.database.getCardInfo(des_card_id)[0] + u'失败') logging.info(u'变' + flash_card_str + self.window.database.getCardInfo(des_card_id)[0] + u'失败')