Пример #1
0
    time_period = DATA['time_period']
    # 首次启动先执行一次
    crontab_tasks()
    while True:
        if time_period <= 0:
            try:
                crontab_tasks()
            except Exception as e:
                print_error(e.__str__())
            finally:
                time_period = DATA['time_period']
        else:
            time_period -= 1
        time.sleep(1)


(ThreadPoolExecutor(1)).submit(crontab)

is_RESIDENT = DATA['config']['RESIDENT']
while True:
    client.tasks = load_task()
    if len(client.tasks) <= 0:
        if not is_RESIDENT:
            suicide(0)
        else:
            print_info('当前无任务,等待新的任务队列中', 0)
            time.sleep(5)
            continue
    distribute_thread(client.tasks)
Пример #2
0
    raise e
# 命令行参数上传
if len(sys.argv) == 2:
    abspath = os.path.abspath(sys.argv[1])
    if os.path.isdir(abspath):
        # 目录上传
        FILE_PATH = abspath
        file_list = get_all_file_relative(FILE_PATH)
    else:
        # 单文件上传
        FILE_PATH = os.path.dirname(abspath)
        file_list = [os.path.basename(abspath)]
    common.DATA['tasks'] = {}
else:
    file_list = get_all_file_relative(FILE_PATH)
    common.DATA['tasks'] = common.load_task()

FILE_PATH = FILE_PATH.replace('/', os.sep).replace('\\\\', os.sep).rstrip(
    os.sep) + os.sep

if MULTITHREADING:
    with ThreadPoolExecutor(max_workers=MAX_WORKERS) as executor:
        future_list = []
        for file in file_list:
            tmp = {
                "filepath": file,
                "upload_time": 0,
                "drive_id": 0,
                "file_id": 0,
                "upload_id": 0,
                "part_number": 0,
Пример #3
0
        file_list = [os.path.basename(abspath)]
    DATA['tasks'] = {}
elif len(sys.argv) == 2:
    abspath = os.path.abspath(sys.argv[1])
    if os.path.isdir(abspath):
        # 目录上传
        FILE_PATH = abspath
        file_list = get_all_file_relative(FILE_PATH)
    else:
        # 单文件上传
        FILE_PATH = os.path.dirname(abspath)
        file_list = [os.path.basename(abspath)]
    DATA['tasks'] = {}
else:
    file_list = get_all_file_relative(DATA['FILE_PATH'])
    DATA['tasks'] = load_task()

DATA['FILE_PATH'] = qualify_path(DATA['FILE_PATH'])

task_template = {
    "filepath": None,
    "upload_time": 0,
    "drive_id": 0,
    "file_id": 0,
    "upload_id": 0,
    "part_number": 0,
    "chunk_size": 0,
}
if DATA['MULTITHREADING']:
    with ThreadPoolExecutor(max_workers=DATA['MAX_WORKERS']) as executor:
        future_list = []