-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlessons.py
More file actions
67 lines (58 loc) · 2.31 KB
/
Copy pathlessons.py
File metadata and controls
67 lines (58 loc) · 2.31 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
import datetime, time, webbrowser, os, requests, json
from pathlib import Path
from tkinter import *
from tkinter import messagebox
from configparser import ConfigParser
def loadtext(language):
with open(f"{Path.home()}\\Documents\\Under the Pebble\\School Connect\\Languages\\{language}.json") as file:
return json.load(file)
def checkforupdates():
res = requests.get("https://raw.githubusercontent.com/PodkamykStudio/School-Connect/main/version")
version = res.text
dziala = settings["general settings"]["checkforupdates"]
if dziala == "1":
if version.strip() != ver.strip():
window = Tk()
window.eval('tk::PlaceWindow %s center' % window.winfo_toplevel())
window.withdraw()
if messagebox.askyesno('Update', text["askforupdates"]) == True:
webbrowser.open(text["askforupdateslink"])
else:
pass
def shutdown(godzina1, godzina2):
czas = datetime.datetime.now().strftime("%H:%M")
if godzina1 <= czas <= godzina2:
print(text["askforshutdown"])
for i in range(1, 31):
time.sleep(1)
print("\r", i, end="")
else:
print(text["shutdown"])
os.system("shutdown /s /t 5")
def function(day):
dziala = settings[day]["active"]
shutdown_now = settings[day]["shutdown"]
link = settings[day]["link"]
godzina1 = settings[day]["time1"]
godzina2 = settings[day]["time2"]
if dziala == "1":
if shutdown_now == "1":
shutdown(godzina1,godzina2)
elif godzina1 <= czas <= godzina2:
if link.strip() == "":
pass
else:
webbrowser.open(link)
if shutdown_now == "0":
checkforupdates()
day = datetime.datetime.today().weekday()
czas = datetime.datetime.now().strftime("%H:%M")
days = ["Monday","Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
file = open(f"{Path.home()}\\Documents\\Under the Pebble\\School Connect\\version")
settings = ConfigParser()
settings.read(f"{Path.home()}\\Documents\\Under the Pebble\\School Connect\\settings.ini")
text = loadtext(settings["general settings"]["language"])
ver = file.readlines()
ver = ver[0]
file.close()
function(days[day])