-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscupdate.py
More file actions
42 lines (38 loc) · 1.53 KB
/
scupdate.py
File metadata and controls
42 lines (38 loc) · 1.53 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
import sys
print("Preparing Libraries (1/2)",end="\r")
import requests
print("Preparing Libraries (2/2)")
import os
#This is for updating Basic Utilities source code
print("Checking connection...")
try:
rtest = requests.get("https://www.google.com")
except (requests.ConnectionError,requests.HTTPError):
print("ERROR: You are not connected to the internet. Please try this again when you are")
sys.exit(1)
print("Getting Data (1/2) [Changelog]",end="\r")
try:
chl = requests.get("https://raw.githubusercontent.com/Enderbyte-Programs/Basic-Utilities/main/changelog.txt").text.splitlines()[-1].split(" ")
while '' in chl:
chl.remove('')
ver = chl[0].replace(":","")
except (requests.ConnectionError,requests.HTTPError):
print("An unexpected connection error occured.")
sys.exit(1)
print("Getting Data (2/2) [Data] ")
try:
dat = requests.get("https://raw.githubusercontent.com/Enderbyte-Programs/Basic-Utilities/main/BasicUtilities.py").text.splitlines()
except (requests.ConnectionError,requests.HTTPError):
print("An unexpected connection error occured.")
sys.exit(1)
ins = input(f"The newest version of Basic Utilities source is {ver}. Do you want to download (and replace the old version)?")
if ins.lower().startswith("y"):
try:
print("Replacing file")
with open("BasicUtilities.py","w+") as f:
for line in dat:
f.write(line+"\n")
except:
print("A file error occured.")
sys.exit(2)
input("All finished. Press enter to exit")