Пример #1
0
def run(id):
    if not allow():
        LOGS.error('系统激活失败,请联系厂家获取支持')
        return
    #解析任务
    db.connect()
    task = Task.get(Task.finger == id)
    if task is None:
        LOGS.error('找不到对应任务:'+str(id))
        exit(-1)
    # 增加运行次数
    task.count = task.count + 1
    task.save()
    db.close()
    LOGS.info('开始任务:' + str(id)+":"+task.name)

    #执行任务
    files =getDataFile(task)
    if len(files) == 0:
        LOGS.info('未获取到任何数据:' + str(id) + ':' + task.name)
        return 0

    #发送文件
    r = redis.Redis()
    for f in files:
        #subprocess.call('./transfer_file -s '+f, shell=True)
        #改为发送文件列表到redis
        print(f)
        r.lpush('file',f)
        #记录日志
    LOGS.info('数据加入发送队列,等待发送:'+str(id)+':'+task.name)
Пример #2
0
def run(file):
    list = file.split('.')
    id = int(list[-1])
    #file_name = file.split('/')[-1]
    new_file = file[:-(len(list[-1]) + 1)]
    os.rename(file, new_file)
    pass
    #解析任务
    db.connect()
    try:
        task = Task.get(Task.finger == id)
    except:
        LOGR.debug('找不到对应任务:' + str(id))
        task = Task()
        task.finger = id
        task.name = ''
        task.dataType = '0'
        task.dir = ''
        task.username = ''
        task.password = ''
        task.target = ''
        task.port = ''
        task.tables = ''
        task.count = 0
        task.save()
        LOGR.info('发现新任务:' + str(id))
        exit(-1)
    #增加运行次数
    task.count = task.count + 1
    task.save()
    db.close()
    LOGR.info('开始任务:' + str(id) + ":" + task.name)
    result = putData(task, new_file)
    os.remove(new_file)
    if result:
        LOGR.info('任务执行完成:' + file)
    else:
        LOGR.info('任务执行失败:' + file)
Пример #3
0
def after_request(response):
    db.close()
    return response
Пример #4
0
def create_table():
    db.connect()
    db.create_tables([User, Secret, SubSecret, ResetPassword])
    db.close()
Пример #5
0
def after_request(response):
    response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
    db.close()
    return response
Пример #6
0
def after_request(resp):
    db.close()
    return resp