-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsync.py
57 lines (48 loc) · 1.51 KB
/
sync.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
from readFileLocations import *
from downloadSavesToGit import download
from uploadSavesToGit import upload
import shutil
import time
os.system("")
class bcolors:
LINE = '\033[90m'
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKCYAN = '\033[96m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
def remove_folder(path):
try:
shutil.rmtree(path, True)
except Exception as e:
print(f"{bcolors.WARNING}Error removing folder {path}: {e}{bcolors.ENDC}")
def print_separator():
print(f"{bcolors.LINE}==========================================================================={bcolors.ENDC}")
def main():
# update local files and times
print_separator()
print(f"\n{bcolors.OKCYAN}Checking each application's save data for changes\n{bcolors.ENDC}")
print_separator()
saveLocations = readLocationsFile()
is_altered, changed = saveData(saveLocations)
# download synced files to see if they're newer
print_separator()
print(f"\n{bcolors.OKCYAN}DOWNLOAD{bcolors.ENDC}\n")
try:
download()
except:
remove_folder("temp")
# upload the changes
print(f"\n{bcolors.OKCYAN}UPLOAD{bcolors.ENDC}\n")
print_separator()
upload(is_altered, changed, False)
print(f"{bcolors.OKBLUE}Done!{bcolors.ENDC}")
print(f"{bcolors.WARNING}Closing in 5 seconds...{bcolors.ENDC}")
print_separator()
time.sleep(5)
if __name__ == "__main__":
main()