Пример #1
0
 def delete_ftp_event(ftp_event_id):
     """删除调度详情"""
     for item in ftp_event_id:
         try:
             run_id = 'ftp_event_%s' % item
             detail = FtpEventModel.get_ftp_event_detail(db.etl_db, item)
             FtpEventModel.delete_ftp_event_detail(db.etl_db, item)
             FtpEventModel.delete_file_event_interface(db.etl_db, item)
             if detail['status'] != 0:
                 EventHandler.remove_job(run_id)
         except Exception as e:
             log.error('删除调度异常[ERROR: %s]' % e, exc_info=True)
             abort(400, **make_result(status=400, msg='删除调度错误, 该调度不存在'))
     return Response(ftp_event_id=ftp_event_id)
Пример #2
0
 def update_ftp_event_detail(ftp_event_id, event_name, event_desc, ftp_id,
                             data_path, file_name, interface_id, start_time,
                             end_time, date_time, interval_value,
                             old_status, new_status, user_id):
     """修改文件事件详情"""
     # 修改事件详情
     FtpEventModel.update_ftp_event_detail(db.etl_db, ftp_event_id,
                                           event_name, event_desc, ftp_id,
                                           data_path, file_name,
                                           interval_value, start_time,
                                           end_time, date_time, new_status,
                                           user_id)
     # 修改任务流依赖
     interface_id = interface_id.split(',')
     insert_data = []
     for item in interface_id:
         insert_data.append({
             'ftp_event_id': ftp_event_id,
             'interface_id': item
         })
     FtpEventModel.delete_file_event_interface(db.etl_db, ftp_event_id)
     FtpEventModel.add_file_event_interface(db.etl_db, insert_data)
     # 修改文件事件状态
     run_id = 'ftp_event_%s' % ftp_event_id
     minute = '*/%s' % interval_value
     hour = '%d-%d' % (start_time, end_time)
     # 新增调度
     # 仍失效
     if old_status == 0 and new_status == 0:
         pass
     # 新增 or 先新增后暂停
     elif old_status == 0 and new_status == 1 or old_status == 0 and new_status == 2:
         EventHandler.add_event(run_id, ftp_event_id, minute, hour)
     # 修改
     else:
         EventHandler.modify_event(run_id, ftp_event_id, minute, hour)
     # 先新增后暂停
     if old_status == 0 and new_status == 2:
         EventHandler.pause_job(run_id)
     # 暂停
     elif old_status == 1 and new_status == 2:
         EventHandler.pause_job(run_id)
     # 失效
     elif old_status == 1 and new_status == 0 or old_status == 2 and new_status == 0:
         EventHandler.remove_job(run_id)
     # 恢复
     elif old_status == 2 and new_status == 1:
         EventHandler.resume_job(run_id)
     return Response(ftp_event_id=ftp_event_id)