-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathb1k1.py
79 lines (63 loc) · 1.99 KB
/
b1k1.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
from core.filehandler import File, Handler
from core.misc import Misc
from core.threadmanager import ThreadManager
from core.cloudhelper import GoogleDrive
from core.version import Version
from pathlib import Path
import datetime
config = Misc
config.LoadConfig()
root_paths = config.paths
backup_path = config.backup_path
gd_sk_path = config.gd_sk_path
timeout = config.timeout
version = Version()
print('*'*20)
print(f'Current version: {version.currentVersion}')
if not version.IsUpdated():
if version.updatedVersion is None:
pass
else:
print(f'Update available: {version.updatedVersion}')
print('*'*20)
print(f'Start time: {datetime.datetime.now().strftime("%Y-%m-%d-%H:%M:%S")}')
print('*'*20)
print('Following Paths are being backed up...')
for path in root_paths:
print(path)
print('*'*20)
print(f'Backup Path: {backup_path}')
print('*'*20)
def driver(path_list, backup_path):
for path in path_list:
handler = Handler(path[0],backup_path)
handler.compressData()
file_list = handler.fileFactory()
handler.logFileInfo(file_list)
handler.finalZip()
thread_manager = ThreadManager()
thread_manager.CalculateThreads(len(root_paths))
path_iter = thread_manager.Slice(root_paths, thread_manager.calculated_threads)
thread_list = thread_manager.ThreadFactory(path_iter,backup_path,driver)
print('*'*20)
print(f'Total Threads: {thread_manager.calculated_threads}')
print('*'*20)
def main():
for thread in thread_list:
thread.start()
thread.join()
path = Path(backup_path)
for x in path.iterdir():
if x.name.startswith('backup') and x.name.endswith('.zip'):
print(x.name)
print('Upload to Google Drive\nCtrl + c to cancel')
try:
z = input('Enter file name:')
z = path.joinpath(z)
google_drive = GoogleDrive(gd_sk_path,timeout)
google_drive.authHandler()
google_drive.uploadFile(z)
except KeyboardInterrupt:
print('\nBye...')
quit()
main()