Files
zulip/tools/install-phantomjs
Tim Abbott 52fc1c71bc provision: Rewrite using subprocess module instead of sh.
The `with sh.sudo` pattern that we were using in python-sh was
deprecated, and emperically hangs on Ubuntu xenial.  Since in general
the use of python-sh/python-pbs caused trouble (requiring extra
dependencies, confusing syntax), this just removes it.

We replace it with a new zulip_tools.py library function that echoes
the command line and streams the output.

We do the same to install-phantomjs so we can remove that dependency.
2016-04-10 17:33:19 -07:00

30 lines
1.1 KiB
Python
Executable File

#!/usr/bin/env python2.7
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"
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,)
run(["sudo", "mkdir", "-p", PHANTOMJS_PATH])
if not os.path.exists(PHANTOMJS_TARBALL):
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"])