MCPcopy Create free account
hub / github.com/smallfawn/QLScriptPublic / save_token_to_cache

Method save_token_to_cache

daily/chinaUnicom.py:551–574  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

549 return False
550
551 def save_token_to_cache(self):
552 if not self.account_mobile:
553 return
554 cache = {}
555 if os.path.exists(UNICOM_TOKEN_CACHE_PATH):
556 try:
557 with open(UNICOM_TOKEN_CACHE_PATH, 'r', encoding='utf-8') as f:
558 cache = json.load(f)
559 except: pass
560 now = datetime.now()
561 cache[self.account_mobile] = {
562 "token_online": self.token_online,
563 "appId": self.appId,
564 "city_info": getattr(self, 'city_info', []),
565 "cookieString": "",
566 "timestamp": int(now.timestamp() * 1000),
567 "time": now.strftime('%Y-%m-%d %H:%M:%S')
568 }
569 try:
570 with open(UNICOM_TOKEN_CACHE_PATH, 'w', encoding='utf-8') as f:
571 json.dump(cache, f, indent=2, ensure_ascii=False)
572 self.log("💾 [缓存保存] Token 已写入本地文件")
573 except Exception as e:
574 self.log(f"❌ 保存缓存失败: {str(e)}")
575
576 def get_city_info(self):
577 try:

Callers 2

mainFunction · 0.95
run_grab_taskFunction · 0.80

Calls 1

logMethod · 0.95

Tested by

no test coverage detected