def clean(cls, attr): if cache.get('Field::ID::%s' % attr.attr_id): cache.delete('Field::ID::%s' % attr.attr_id) cache.delete('Field::Name::%s' % attr.attr_name) cache.delete('Field::Alias::%s' % attr.attr_alias)
def clean(cls, key): ct = CITypeCache.get(key) if ct is not None: cache.delete("CIType::Name::%s" % ct.type_name) cache.delete("CIType::ID::%s" % ct.type_id)
def clean(cls, key): ct = CITypeCache.get(key) if ct is not None: cache.delete("CITypeSPEC::ID::%d" % ct.type_id)
def clean(cls, key): citype = CITypeCache.get(key) attrs = CITypeAttributeCache.get(key) if attrs is not None and citype: cache.delete("CITypeAttribute::ID::%s" % citype.type_id) cache.delete("CITypeAttribute::Name::%s" % citype.type_name)
# @File : cmdline.py # @Software: PyCharm import os import logging from extensions import cache from toolkit.cmdline import cmdline from toolkit.initlogs import log_init __author__ = 'blackmatrix' # 初始化日志配置文件 log_init(file=os.path.abspath('logging.cfg')) if __name__ == '__main__': if cmdline.command == 'hunter': logging.info('[猎手] 已运行') from hunter import hunting hunting() elif cmdline.command == 'falcon': logging.info('[猎鹰] 已运行') cache.delete('buyers') cache.delete('apple_stores') # itchat.auto_login(hotReload=True) import falcon falcon.start() elif cmdline.command == 'courier': logging.info('[信使] 已运行') from courier import send_msg send_msg()
def clean(cls, role): cache.delete("Role::rid::%s" % role.rid, role) cache.delete("Role::role_name::%s" % role.role_name, role)
def clean(cls, user): cache.delete("User::uid::%s" % user.uid) cache.delete("User::username::%s" % user.username) cache.delete("User::nickname::%s" % user.nickname)
def send_reg_code(self): """ 申请注册码 :return: """ logging.info('[猎手] 当前链接:{}'.format(self.driver.current_url)) # 注册码,暂时没什么用,最终是通过缓存获取到用于验证的注册码 reg_code = '123456' # 手机号,暂时没什么用,最终是通过缓存获取到用于验证的手机号码 phone_number = '18858888888' # 获取页面元素 validate_reg_code = self.wait_find_element_by_xpath( current_config.VALIDATE_REG_CODE) btn_continue = current_config.BTN_NEED_REG_CODE_XPATH # 需要申请注册码的情况 if validate_reg_code.text == '申请并验证你的注册码。': # 说明验证码已经过期,清理掉 cache.delete(self.apple_id) # 重新申请一个 logging.info('[猎手] 需要申请注册码') btn_continue = current_config.BTN_NEED_SEND_SMS_XPATH # 验证码 sms_code = self.wait_find_element_by_xpath( current_config.SMS_CODE_XPATH) logging.info('[猎手] 页面验证码为{}'.format(sms_code.text)) # 发送短信 rabbit.connect() self.send_message( messages={ 'content': sms_code.text, 'target': current_config.SEND_TO, 'apple_id': self.apple_id }) logging.info('[猎手] 将验证码发送给消息队列') rabbit.disconnect() # 遍历获取缓存注册码 logging.info('[猎手] 等待获取注册码短信') while True: sms_list = cache.get(self.apple_id) if sms_list: logging.info('[猎手] 已获取到短信:{}'.format(sms_list)) break # 排序 sms_list.sort(key=itemgetter('datetime')) for sms in sms_list: if '注册码' in sms['text']: phone_number = sms['send_from'] reg_code = sms['text'][6:15] logging.info('[猎手] 解析短信完成,apple id:{0},注册码:{1}'.format( self.apple_id, reg_code)) break # 填写手机号码 input_phone_number = self.wait_find_element_by_xpath( current_config.PHONE_NUMBER_XPATH) input_phone_number.send_keys(phone_number) logging.info('[猎手] 已填写手机号码:{}'.format(phone_number)) # 填写注册码 input_reg_code = self.wait_find_element_by_xpath( current_config.REG_CODE_XPATH) input_reg_code.send_keys(reg_code) logging.info('[猎手] 已填写注册码:{}'.format(reg_code)) # 继续 btn_continue = self.wait_find_element_by_xpath(btn_continue) btn_continue.click() logging.info('[猎手] 点击继续按钮') # 如果出现注册码错误,清理缓存并重试 # if self.is_elements_by_xpath(current_config.ERR_REG_CODE): # err_reg_code = self.wait_find_element_by_xpath(current_config.ERR_REG_CODE) # if err_reg_code.is_displayed() is True: # cache.delete(current_config.APPLE_ID) # raise ErrorBuy logging.info('[猎手] 准备进行最后一步预约') self.last_step()