-
Notifications
You must be signed in to change notification settings - Fork 0
/
kuaipan.py
68 lines (49 loc) · 1.48 KB
/
kuaipan.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/python2.7
# -*- coding: utf-8 -*-
import oauthkuaipan
import thread
import time
import Queue
import hdnotify
# global configure
task_queue = Queue.Queue()
configure_dict = {
'root_path': "/root/kuaipan",
'filter_list': "~|.tmp|.swp|.swx|.swpx",
}
LOCAL_PATH = "/root/kuaipan"
def main():
global configure_dict
global task_queue
kuaipan = oauthkuaipan.KuaiPan(configure_dict)
# start monitor locale folder
monitor_locale_folder = hdnotify.MonitorLocaleFolder(configure_dict, task_queue)
monitor_locale_folder.start()
# Login
kuaipan.get_access_token()
# kuaipan.get_account_info()
# test
# task_queue.put(('test/1', 'UPLOAD'))
# start main task handle thread
kuaipan.handle_task_mainloop(task_queue)
# sync every 5min+
while True:
# FIX: change get locale and remote
# get locale list
kuaipan.build_locale_list(configure_dict['root_path'])
# get remote list
thread.start_new_thread(kuaipan.build_remote_list, ("wallpaper",))
while True:
time.sleep(10)
if kuaipan.remote_folder_queue.qsize() == 0:
break
# get diffs
kuaipan.add_task(kuaipan.compare_diffs(), task_queue)
time.sleep(300)
# stop threads
kuaipan.handle_task_worker.join()
monitor_locale_folder.join()
kuaipan.remote_folder_queue.join()
task_queue.join()
if __name__ == '__main__':
main()