This repository has been archived by the owner on Mar 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
install_sync_gateway.py
75 lines (53 loc) · 2.09 KB
/
install_sync_gateway.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import os
import requests
import tarfile
import sys
from optparse import OptionParser
def install_local_sync_gateway(version):
print("Installing {} sync_gateway".format(version))
version_parts = version.split("-")
if len(version_parts) != 2:
print("Your version string must follow the format: 1.2.0-79")
sys.exit(1)
version_number = version_parts[0]
build_number = version_parts[1]
print("Version: {}".format(version_number))
if version_number == "1.1.1":
# http://latestbuilds.hq.couchbase.com/couchbase-sync-gateway/release/1.1.0/1.1.0-28/couchbase-sync-gateway-enterprise_1.1.0-28_x86_64.tar.gz
url = "http://latestbuilds.hq.couchbase.com/couchbase-sync-gateway/release/{}/{}/couchbase-sync-gateway-enterprise_{}_x86_64.tar.gz".format(
version_number,
version,
version
)
else:
url = "http://latestbuilds.service.couchbase.com/builds/latestbuilds/sync_gateway/{0}/{1}/couchbase-sync-gateway-enterprise_{2}_x86_64.tar.gz".format(
version_number,
build_number,
version
)
print os.getcwd()
os.chdir("binaries/")
r = requests.get(url)
file_name = "sync_gateway.tar.gz"
with open(file_name, "wb") as f:
f.write(r.content)
with tarfile.open(file_name) as tar_f:
tar_f.extractall()
os.chdir("../")
if __name__ == '__main__':
usage = "usage: install_sync_gateway.py --version=1.2.0-79"
parser = OptionParser(usage=usage)
parser.add_option(
"", "--version",
action="store",
type="string",
dest="version",
help="sync_gateway version to install and run tests against",
default=None
)
cmd_args = sys.argv[1:]
(opts, args) = parser.parse_args(cmd_args)
if opts.version is None:
print("You must provide a version of sync_gateway to download (ex. 1.2.0-79)")
sys.exit(1)
install_local_sync_gateway(opts.version)