-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathquick_start.py
43 lines (38 loc) · 1.43 KB
/
quick_start.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
import urllib.request
import json
import tempfile
import zipfile
import os
import glob
import subprocess
import shutil
from sys import platform
dist_dir = "mongodb-datasource"
if os.path.isdir(dist_dir):
shutil.rmtree(dist_dir)
# Download the latest release build
with urllib.request.urlopen(
"https://api.github.com/repos/haohanyang/mongodb-datasource/releases/latest"
) as response:
data = json.loads(response.read())
for asset in data["assets"]:
if asset["content_type"] == "application/zip":
with tempfile.NamedTemporaryFile() as temp_file:
print("Downloading " + asset["name"] + "...")
urllib.request.urlretrieve(
asset["browser_download_url"], temp_file.name
)
print("Extracting files to " + dist_dir)
with zipfile.ZipFile(temp_file.name, "r") as zip_ref:
zip_ref.extractall(os.getcwd())
os.rename("haohanyang-mongodb-datasource", "mongodb-datasource")
# Grant execute permission go binaries
for bin in glob.glob("mongodb-datasource/gpx_mongodb_datasource_*"):
os.chmod(bin, os.stat(bin).st_mode | 755)
if platform == "linux" or platform == "linux2":
# "sudo" only for linux
subprocess.call(
["sudo", "docker", "compose", "-f", "docker-compose.prod.yaml", "up", "-d"]
)
else:
subprocess.call(["docker", "compose", "-f", "docker-compose.prod.yaml", "up", "-d"])