mirror of https://github.com/zulip/zulip.git
35 lines
1.3 KiB
Python
Executable File
35 lines
1.3 KiB
Python
Executable File
#!/usr/bin/env python
|
|
from __future__ import print_function
|
|
import os
|
|
import sys
|
|
import platform
|
|
import subprocess
|
|
|
|
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..'))
|
|
from zulip_tools import run
|
|
|
|
if platform.architecture()[0] == '64bit':
|
|
phantomjs_arch = 'x86_64'
|
|
elif platform.architecture()[0] == '32bit':
|
|
phantomjs_arch = 'i686'
|
|
|
|
|
|
PHANTOMJS_PATH = "/srv/phantomjs"
|
|
if "--travis" in sys.argv:
|
|
PHANTOMJS_PATH = os.path.join(os.environ['HOME'], "phantomjs")
|
|
PHANTOMJS_BASENAME = "phantomjs-1.9.8-linux-%s" % (phantomjs_arch,)
|
|
PHANTOMJS_TARBALL_BASENAME = PHANTOMJS_BASENAME + ".tar.bz2"
|
|
PHANTOMJS_TARBALL = os.path.join(PHANTOMJS_PATH, PHANTOMJS_TARBALL_BASENAME)
|
|
PHANTOMJS_URL = "https://github.com/zulip/zulip-dist-phantomjs/blob/master/%s?raw=true" % (PHANTOMJS_TARBALL_BASENAME,)
|
|
|
|
if not os.path.exists(PHANTOMJS_TARBALL):
|
|
run(["sudo", "mkdir", "-p", PHANTOMJS_PATH])
|
|
run(["sudo", "curl", '-J', '-L', PHANTOMJS_URL, "-o", PHANTOMJS_TARBALL])
|
|
run(["sudo", "tar", "-xj", "--directory", PHANTOMJS_PATH,
|
|
"--file", PHANTOMJS_TARBALL])
|
|
run(["sudo", "ln", "-sf", os.path.join(PHANTOMJS_PATH, PHANTOMJS_BASENAME,
|
|
"bin", "phantomjs"),
|
|
"/usr/local/bin/phantomjs"])
|
|
else:
|
|
print("Using cached PhantomJS")
|