This repository was archived by the owner on Feb 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathupdates.py
33 lines (30 loc) · 1.54 KB
/
updates.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
def check_for_updates():
from utils.globals import gc
from os import path
if not path.exists(".git"):
print(gc.term.red("Error: client not started from repo location! Cancelling..."))
print(gc.term.yellow("You must start the client from its folder to get automatic updates. \n"))
return
try:# git pull at start as to automatically update to master repo
from subprocess import Popen,PIPE
print(gc.term.green + "Checking for updates..." + gc.term.normal)
process = Popen(["git", "pull", "--force"], stdout=PIPE)
output = process.communicate()[0].decode('utf-8').strip()
if "Already up to date" not in output:
# print(gc.term.yellow("Updates downloaded! Please restart."))
print("\n \n")
# This quit() call is breaking the client on MacOS and Linux Mint
# The if statement above is being triggered, even when the output IS
# "Already up to date". Why is this happening?
# quit()
else:
print("Already up to date!" + "\n")
except KeyboardInterrupt: print("Call to cancel update received, skipping.")
except SystemExit: pass
except OSError: # (file not found)
# They must not have git installed, no automatic updates for them!
print(gc.term.red + "Error fetching automatic updates! Do you \
have git installed?" + gc.term.normal)
except:
print(gc.term.red + "Unkown error occurred during retrieval \
of updates." + gc.term.normal)