-
Notifications
You must be signed in to change notification settings - Fork 0
/
zm_checkout_bot.py
86 lines (52 loc) · 2.52 KB
/
zm_checkout_bot.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import datetime
import logging
import bot_modules as m
# from authenticator import Authenticator as Auth
# from database_setup_and_seed import DbSetup, DbInterface
# from parse_stills_txt_to_path import m.StillDamDirs
# from zoom_checkout import m.ZmCheckoutSession
# from zoom_ls_to_text import m.ZmLsToText
def return_strf_now():
return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
if __name__ == "__main__":
logged_in = False
auth = m.Authenticator()
while (not logged_in):
logged_in = auth.login()
if (not logged_in):
auth.enter_credentials()
db_name = 'current_batch.db'
current_targets_txt = 'current_targets.txt'
current_db = m.DbSetup(db_name)
current_db.create_table()
dbMonitor = m.DbInterface(db_name)
raw_local_dir_path = raw_input("Please specify the local path to download to: ")
local_dir_path = raw_local_dir_path.strip()
if (dbMonitor.db_monitor(db_name)[0] == 0):
dam_checkout_target = raw_input("Please paste the DAM path to target for subdirectory checkout: ")
target_dirs = m.ZmLsToText(dam_checkout_target, current_targets_txt)
target_dirs.generate_ls_txt()
current_data = m.StillDamDirs()
current_data.parse_txt(current_targets_txt)
insert_data = current_db.insert_dirs(current_data.dirs)
else:
print("Continuintinuing to download directory in progress.\n")
logging.basicConfig(filename='zm_checkout_log.log',level=logging.DEBUG)
# logging.info("Downloads started at {}".format(return_strf_now()))
while (dbMonitor.db_monitor(db_name)[0] > 0):
try:
print('{} Directories Remaining'.format(dbMonitor.db_monitor(db_name)[0]))
db_dir_record = dbMonitor.return_single_directory(db_name)
directory = db_dir_record[0]
dbMonitor.set_download_initiated(directory, 1, db_name)
# downloaded = download_from_dirs_list(directory, args)
downloaded = m.ZmCheckoutSession.checkout_a_dir(local_dir_path, directory)
if downloaded == 0:
dbMonitor.set_download_complete(directory, 1, db_name)
elif downloaded == 234:
dbMonitor.set_download_initiated(directory, 0, db_name)
auth.login()
except KeyboardInterrupt:
print("\n\nDownload stopped manually, restart process to resume")
logging.info("Downloads manually stopped at {}".format(return_strf_now()))
break