-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminecraft_backupper_auto.py
More file actions
117 lines (95 loc) · 7.93 KB
/
minecraft_backupper_auto.py
File metadata and controls
117 lines (95 loc) · 7.93 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
from datetime import timedelta
import os
import zipfile
import datetime
import time
import winsound
import platform
import readchar
#### CONFIG
BACKGROUND_COLOR = '1' #You can only use this values: 0 to 9, A, B, C, D, E, F'
TEXT_COLOR = 'f' #You can only use this values: 0 to 9, A, B, C, D, E, F'
INTERVAL = 15 #minutes
PATH = r"" # insert a path (for instance r"C:\Users\username\AppData\Roaming\.minecraft\saves\MyWorld")
BEEP = True #if True will beep, if False will not
assert int(hex(int('0x' + BACKGROUND_COLOR.upper(), 16)), 16) <= 15, 'You can only use this values: 0 to 9, A, B, C, D, E, F'
assert int(hex(int('0x' + TEXT_COLOR.upper(), 16)), 16) <= 15, 'You can only use this values: 0 to 9, A, B, C, D, E, F'
os.system('color ' + BACKGROUND_COLOR.upper() + TEXT_COLOR.upper())
screen_text = '''
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░███╗░░░███╗██╗███╗░░░██╗███████╗░██████╗██████╗░░█████╗░███████╗████████╗░░░░
░░░░████╗░████║██║████╗░░██║██╔════╝██╔════╝██╔══██╗██╔══██╗██╔════╝╚══██╔══╝░░░░
░░░░██╔████╔██║██║██╔██╗░██║█████╗░░██║░░░░░██████╔╝███████║█████╗░░░░░██║░░░░░░░
░░░░██║╚██╔╝██║██║██║╚██╗██║██╔══╝░░██║░░░░░██╔══██╗██╔══██║██╔══╝░░░░░██║░░░░░░░
░░░░██║░╚═╝░██║██║██║░╚████║███████╗╚██████╗██║░░██║██║░░██║██║░░░░░░░░██║░░░░░░░
░░░░╚═╝░░░░░╚═╝╚═╝╚═╝░░╚═══╝╚══════╝░╚═════╝╚═╝░░╚═╝╚═╝░░╚═╝╚═╝░░░░░░░░╚═╝░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░██████╗░░█████╗░░██████╗██╗░░██╗██╗░░░██╗██████╗░███████╗██████╗░░░░░░░░░░░░░
░░░░██╔══██╗██╔══██╗██╔════╝██║░██╔╝██║░░░██║██╔══██╗██╔════╝██╔══██╗░░░░░░░░░░░░
░░░░██████╔╝███████║██║░░░░░█████╔╝░██║░░░██║██████╔╝█████╗░░██████╔╝░░░░░░░░░░░░
░░░░██╔══██╗██╔══██║██║░░░░░██╔═██╗░██║░░░██║██╔═══╝░██╔══╝░░██╔══██╗░░░░░░░░░░░░
░░░░██████╔╝██║░░██║╚██████╗██║░░██╗╚██████╔╝██║░░░░░███████╗██║░░██║░░░░░░░░░░░░
░░░░╚═════╝░╚═╝░░╚═╝░╚═════╝╚═╝░░╚═╝░╚═════╝░╚═╝░░░░░╚══════╝╚═╝░░╚═╝░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░█████╗░██╗░░░██╗████████╗░██████╗░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░██╔══██╗██║░░░██║╚══██╔══╝██╔═══██╗░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░███████║██║░░░██║░░░██║░░░██║░░░██║░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░██╔══██║██║░░░██║░░░██║░░░██║░░░██║░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░██║░░██║╚██████╔╝░░░██║░░░╚██████╔╝░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░╚═╝░░╚═╝░╚═════╝░░░░╚═╝░░░░╚═════╝░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n
'''
screen_state = ''
def screen_state_update(new):
global screen_state
screen_state += new
def clear_screen():
command = "cls" if platform.system().lower()=="windows" else "clear"
os.system(command)
def printed(text):
global screen_state
clear_screen()
screen_state_update(text)
print(screen_state)
def beepboop(): # you can change the melody by changing freq and time in winsound.Beep(freq, time)
if BEEP: # and smart use of time.sleep()
winsound.Beep(300, 100)
time.sleep(0.1)
winsound.Beep(200, 100)
time.sleep(0.1)
winsound.Beep(500, 100)
time.sleep(0.1)
def zipdir(path, ziph):
for root, dirs, files in os.walk(path):
for file in files:
ziph.write(os.path.join(root, file))
def the_job():
text = 'Auto:\tBacking up '
post = '.zip'
global PATH
if BEEP:
winsound.Beep(300, 100)
now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
file_name = str(now) + '_' + PATH.split('\\')[-1] + post
file_name = file_name.replace(' ', '_').replace(':', '-')
_log = text + file_name + '... '
printed(_log)
zipf = zipfile.ZipFile(file_name, 'w', zipfile.ZIP_DEFLATED)
zipdir(PATH, zipf)
zipf.close()
beepboop()
printed('\tDone.\n')
now = datetime.datetime.now()
_first_line = 'This program will back up your world "' + PATH.split('\\')[-1] +'" folder' +\
' every ' + str(INTERVAL) + ' ' + ' minute(s) from ' +\
now.strftime("%Y-%m-%d %H:%M:%S") + '\n'
_second_line = '\nLog:\n'
printed(screen_text + _first_line + _second_line)
_time_to_act = now + timedelta(minutes=INTERVAL)
time_to_act = _time_to_act.strftime("%Y-%m-%d %H:%M")
while True:
_now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
if _now == time_to_act:
the_job()
_time_to_act = _time_to_act + timedelta(minutes=INTERVAL)
time_to_act = _time_to_act.strftime("%Y-%m-%d %H:%M")