Exemplo n.º 1
0
 def _set_users(self, name, mode):
     """
     统一设置run_status。
     mode = 0:完成并清除Error
     mode = 1:清除Error
     mode = 2:重置
     """
     for _, nam, b, _, rec in self.SL:
         if nam == name or name is None:
             parsed = parse_batch(AutomatorRecorder.getbatch(b))
             for _, acc, _, _ in parsed:
                 AR = AutomatorRecorder(acc, rec)
                 rs = AR.get_run_status()
                 if mode == 0:
                     rs["finished"] = True
                     rs["error"] = None
                 if mode == 1:
                     if rs["error"] is not None:
                         rs["error"] = None
                         rs["finished"] = False
                 if mode == 2:
                     if name is None and nam in self.not_restart_name:
                         continue
                     if name is None or name == nam:
                         if os.path.isdir(rec):
                             self.del_file_in_path(rec)
                         if rs["error"] is None:
                             rs["finished"] = False
                             rs["current"] = "..."
                 AR.set_run_status(rs)
Exemplo n.º 2
0
def ContinueBatch(batch):
    global PCR
    if PCR is None:
        StartPCR()
    bj = AutomatorRecorder.getbatch(batch)
    parsed = parse_batch(bj)
    PCR.add_tasks(parsed, True, f"rec/__batch__/{batch}")
Exemplo n.º 3
0
def get_batches_info(filename):
    try:
        r = AutomatorRecorder.getbatch(filename)
        if r:
            return ListReply(r, 0)
        else:
            return 500
    except Exception as e:
        return 500
Exemplo n.º 4
0
 def _add(self, name, batch):
     """
     将一个schedule添加到PCR中
     运行路径:
     rec/<schedules_name>/<schedule_name>/<batch_name>
     """
     rec_addr = os.path.join("rec", self.name, name, batch)
     os.makedirs(rec_addr, exist_ok=True)
     parsed = parse_batch(AutomatorRecorder.getbatch(batch))
     self.pcr.add_tasks(parsed, True, rec_addr)
Exemplo n.º 5
0
def save_batches():
    # '{"batch": [{"group": "\u88c5\u5907\u519c\u573a","taskfile": "n11\u88c5\u5907\u519c\u573a","priority": 0}]}'
    try:
        obj = request.json
        BatchesFileName = request.json.get("filename")
        obj.pop("filename")
        save_dict = {"batch": [obj]}
        if check_valid_batch(save_dict, is_raise=False):
            AutomatorRecorder.setbatch(BatchName, save_dict)
            old_batch = AutomatorRecorder.getbatch(BatchesFileName)
            return jsonify({"code": 200, "msg": f"{old_batch}-保存成功"})
        else:
            return jsonify({"code": 500, "msg": f"{save_dict}-保存失败"})
    except Exception as e:
        return jsonify({"code": 500, "msg": f"{e}-保存失败"})
Exemplo n.º 6
0
 def is_complete(rec):
     """
     判断记录Rec是否已经全部完成
     :param rec: 存档目录
     """
     if os.path.exists(os.path.join(rec, "_fin")):
         return True
     _, bat = os.path.split(rec)
     parsed = parse_batch(AutomatorRecorder.getbatch(bat))
     for _, acc, _, _ in parsed:
         rs = AutomatorRecorder(acc, rec).get_run_status()
         if not rs["finished"] or rs["error"] is not None:
             return False
     with open(os.path.join(rec, "_fin"), "w") as f:
         f.write("出现这个文件表示该文件夹内的记录已经刷完。")
     return True
Exemplo n.º 7
0
 def count_complete(rec):
     """
     统计记录Rec中完成账号的数量
     输出:完成数 / 总数
     """
     _, bat = os.path.split(rec)
     parsed = parse_batch(AutomatorRecorder.getbatch(bat))
     L = len(parsed)
     if os.path.exists(os.path.join(rec, "_fin")):
         return L, L
     else:
         cnt = 0
         for _, acc, _, _ in parsed:
             rs = AutomatorRecorder(acc, rec).get_run_status()
             if rs["finished"] and rs["error"] is None:
                 cnt += 1
         return cnt, L