def list_account(): """ 获取账号列表 --- tags: - 账号 description: responses: 2xx: description: 成功 4xx: description: 参数有误等 """ data = [] count = 0 all_users = list_all_users() count = len(all_users) for username in all_users: try: user = AutomatorRecorder(username).getuser() except Exception as e: return NotFoundError(e) if user is not None: data.append({ 'username': user.get('account'), 'password': '******', 'taskname': user.get('taskfile'), 'tags': '-' }) return ListReply(data, count)
def CheckTuitu(): users = list_all_users(0) for acc in users: AR = AutomatorRecorder(acc) ts = AR.get("tuitu_status", UDD["tuitu_status"]) if ts['max'] is not None: print("USER: "******" Normal: ", ts['max'])
def _check(cond: dict) -> bool: """ 检查某个计划是否满足全部condition """ tm = time.time() st = time.localtime(tm) if "start_hour" in cond: # 时间段条件 sh = cond["start_hour"] eh = cond["end_hour"] ch = st.tm_hour if sh <= eh: flag = sh <= ch <= eh else: flag = (0 <= ch <= eh) or (sh <= ch <= 23) if not flag: return False if "can_juanzeng" in cond: # 可以捐赠条件 AR = AutomatorRecorder(cond["can_juanzeng"], None) ts = AR.get("time_status", UDD["time_status"]) tm = ts["juanzeng"] diff = time.time() - tm if diff < 8 * 3600 + 60: return False if "_last_rec" in cond: # 前置batch条件 if not Schedule.is_complete(cond["_last_rec"]): return False return True
def CheckTuitu(): users = list_all_users(0) for acc in users: AR = AutomatorRecorder(acc) ts = AR.get("tuitu_status", UDD["tuitu_status"]) if ts['max'] is not None or ts["Hmax"] is not None: print("USER: "******" ") if ts['max'] is not None: print("Normal ", ts["max"], end=" ") if ts["Hmax"] is not None: print("Hard ", ts["Hmax"], end=" ") print("")
def retrieve_account(username): """ 获取单条账号 --- tags: - 账号 description: parameters: - name: username in: path type: string required: true description: 用户名 responses: 2xx: description: 成功 4xx: description: 参数有误等 """ if username == '': return BadRequestError(f'参数不合法, 用户名:{username}') data = { 'username': '', 'password': '******', 'taskname': '', 'tags': '-' } try: user = AutomatorRecorder(username).getuser() if user is not None: data['username'] = user.get('account') data['taskname'] = user.get('taskfile') return Reply(data) except Exception as e: return NotFoundError(f"获取用户 {username} 失败, {e}")