-
Notifications
You must be signed in to change notification settings - Fork 152
/
update.py
37 lines (34 loc) · 1.2 KB
/
update.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
import os
import requests
red = '\033[1;31m'
green = '\033[1;32m'
white = '\033[1;37m'
reset = '\033[0m'
abs_dir = os.path.dirname(os.path.abspath(__file__))
print(green+'[*] trying to update cheetah'+reset)
if os.path.exists(os.path.join(abs_dir, '.git')) is True:
print(green+'[*] the .git directory is existing.'+reset)
os.chdir(abs_dir)
print(white+'[^] trying use git pull to update cheetah'+reset)
try:
os.system('git pull origin master')
except Exception as e:
print(red+'[!] '+str(e)+reset)
exit(1)
print(red+'[=] update completed'+reset)
exit(0)
else:
print(green+'[*] the .git directory is not existing.'+reset)
os.chdir(abs_dir)
print(white+'[^] trying use git clone to clone latest cheetah'+reset)
try:
os.system('git clone https://github.com/sunnyelf/cheetah.git')
except Exception as e:
print(red+'[!] '+str(e)+reset)
print(green+'[*] trying to download latest cheetah.zip')
url = 'https://github.com/sunnyelf/cheetah/archive/master.zip'
r = requests.get(url)
with open("cheetah.zip", "wb") as file:
file.write(r.content)
print(red+'[=] update completed'+reset)
exit(0)