-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.py
executable file
·50 lines (44 loc) · 1.66 KB
/
install.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
38
39
40
41
42
43
44
45
46
47
48
49
50
# Licensed under Apache Version 2.0
# Please see the LICENSE file in the root directory of the project for more
# information
import subprocess
import sys
def install(package):
subprocess.check_call([sys.executable, "-m", "pip", "install", package, "-q", "-q"])
print ("Downloading latest versions of dependencies")
install("requests")
import platform
import requests
import os
from os.path import expanduser
def make_executable(path):
mode = os.stat(path).st_mode
mode |= (mode & 0o444) >> 2
os.chmod(path, mode)
homeDir = expanduser("~")
system = platform.system()
if system == "Windows":
print ("Windows is currently not supported, please try again later or install with npm")
sys.exit()
try:
apiInfo = requests.get("https://api.github.com/repos/Megapixel99/GAM/releases/latest").json()
except requests.exceptions.Timeout:
print ("A timeout error occured, please try again later")
except requests.exceptions.RequestException as e:
print ("Unkown error occured")
raise SystemExit(e)
print ("Downloading version: " + apiInfo["tag_name"])
if system == "Darwin":
r = requests.get("https://github.com/Megapixel99/GAM/releases/download/" + apiInfo["tag_name"] + "/manager-macos")
with open('/usr/bin/gam', 'wb') as f:
f.write(r.content)
make_executable('/usr/bin/gam')
pass
else:
r = requests.get("https://github.com/Megapixel99/GAM/releases/download/" + apiInfo["tag_name"] + "/manager-linux")
with open('/usr/bin/gam', 'wb') as f:
f.write(r.content)
make_executable('/usr/bin/gam')
pass
print ("Successfully downloaded version: " + apiInfo["tag_name"])
print ("Please type gam to begin using the tool")