print("If you are attempting to run multiple bots, this is not supported.") print("You are on your own to figure this out.") exit(0) import time from notifications.notifications import NotificationHandler, TIME_FORMAT from stores.amazon import Amazon from stores.bestbuy import BestBuyHandler from utils import selenium_utils from utils.logger import log from utils.version import check_version notification_handler = NotificationHandler() try: check_version() except Exception as e: log.error(e) def handler(signal, frame): log.info("Caught the stop, exiting.") exit(0) def notify_on_crash(func): @wraps(func) def decorator(*args, **kwargs): try: func(*args, **kwargs) except KeyboardInterrupt:
# do sync do_sync(syncer_name, syncer_delays=syncer_delays) except Exception: log.exception( "Unexpected exception occurred while processing syncer: %s", syncer_name) ############################################################ # MAIN ############################################################ if __name__ == "__main__": # show latest version info from git version.check_version() # init multiprocessing manager = Manager() uploader_delay = manager.dict() syncer_delay = manager.dict() # run chosen mode try: # init notifications init_notifications() if conf.args['cmd'] == 'clean': log.info("Started in clean mode") do_hidden() elif conf.args['cmd'] == 'upload':
def __init__(self): INFO("欢迎执行JD全自动退会程序,如有使用问题请加TG群https://t.me/jdMemberCloseAccount进行讨论") INFO("↓ " * 30) # 检查版本 INFO("开始检查项目是否有更新") check_version(logger) # 检查配置 INFO("开始检查项目配置完整性") verify_configuration(logger) # 初始化基础配置 self.config = get_config() self.selenium_cfg = get_config()["selenium"] self.shop_cfg = get_config()["shop"] self.sms_captcha_cfg = get_config()["sms_captcha"] self.image_captcha_cfg = get_config()["image_captcha"] self.ocr_cfg = self.sms_captcha_cfg["ocr"] self.debug = self.config["debug"] # 初始化selenium配置 self.browser = get_browser(self.config) self.wait = WebDriverWait(self.browser, self.selenium_cfg["timeout"]) self.wait_check = WebDriverWait(self.browser, self.selenium_cfg["check_wait"]) # 初始化短信验证码配置 if not self.sms_captcha_cfg["is_ocr"]: if not self.sms_captcha_cfg["jd_wstool"]: from utils.listener import SmsSocket self.sms = SmsSocket() elif self.sms_captcha_cfg["is_ocr"]: self.ocr_type = self.ocr_cfg["type"] if self.ocr_type == "": WARN("当前已开启OCR模式,但是并未选择OCR类型,请在config.yaml补充ocr.type") sys.exit(1) if self.ocr_type == "baidu": from captcha.baidu_ocr import BaiduOCR self.baidu_ocr = BaiduOCR(self.ocr_cfg, self.debug) elif self.ocr_type == "aliyun": from captcha.aliyun_ocr import AliYunOCR self.aliyun_ocr = AliYunOCR(self.ocr_cfg, self.debug) elif self.ocr_type == "easyocr": from captcha.easy_ocr import EasyOCR self.easy_ocr = EasyOCR(self.debug) elif self.ocr_type == "baidu_fanyi": from captcha.baidu_fanyi import BaiduFanYi self.baidu_fanyi = BaiduFanYi(self.ocr_cfg, self.debug) self.ws_conn_url = self.sms_captcha_cfg["ws_conn_url"] self.ws_timeout = self.sms_captcha_cfg["ws_timeout"] # 初始化图形验证码配置 if self.image_captcha_cfg["type"] == "cjy": self.cjy = ChaoJiYing(self.image_captcha_cfg) elif self.image_captcha_cfg["type"] == "tj": self.tj = TuJian(self.image_captcha_cfg) elif self.image_captcha_cfg["type"] == "local": pass elif self.image_captcha_cfg["type"] == "yolov4": self.JDyolo = JDyolocaptcha(self.image_captcha_cfg) else: WARN("请在config.yaml中补充image_captcha.type") sys.exit(1) # 初始化店铺变量 # 错误店铺页面数量 self.wrong_store_page_count = 0 # 黑名单店铺缓存 self.black_list_shops = [] # 会员关闭最大数量 self.member_close_max_number = self.shop_cfg["member_close_max_number"] # 注销成功店铺数量 self.member_close_count = 0 # 需要跳过的店铺 self.need_skip_shops = [] # 指定注销的店铺 self.specify_shops = [] # 页面失效打不开的店铺 self.failure_store = [] # 云端数据执行状态 self.add_remote_shop_data = self.shop_cfg["add_remote_shop_data"]