Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 55 lines (47 sloc) 1.393 kb
ca5fdb6 @n1k0 say back hello to python exec - see https://groups.google.com/forum/?pli...
n1k0 authored
1 #!/usr/bin/env python
2
3 import os
4 import subprocess
5 import sys
6
7
8 def resolve(path):
9 if os.path.islink(path):
349044f @n1k0 fixes #88 - Can't open 'bootstrap.js' using symbolic links (@anthony-tei...
n1k0 authored
10 path = os.path.join(os.path.dirname(path), os.readlink(path))
11 return resolve(path)
ca5fdb6 @n1k0 say back hello to python exec - see https://groups.google.com/forum/?pli...
n1k0 authored
12 return path
13
bfd295f @n1k0 refs #49, #50 - casperjs python executable wasn't passing native phantom...
n1k0 authored
14 PHANTOMJS_NATIVE_ARGS = [
15 'cookies-file',
16 'config',
17 'disk-cache',
18 'ignore-ssl-errors',
19 'load-images',
20 'load-plugins',
21 'local-to-remote-url-access',
22 'max-disk-cache-size',
23 'output-encoding',
d17faf0 @n1k0 ensured compatibility with phantomjs 1.5
n1k0 authored
24 'remote-debugger-port',
25 'remote-debugger-autorun',
bfd295f @n1k0 refs #49, #50 - casperjs python executable wasn't passing native phantom...
n1k0 authored
26 'proxy',
d17faf0 @n1k0 ensured compatibility with phantomjs 1.5
n1k0 authored
27 'proxy-auth',
bfd295f @n1k0 refs #49, #50 - casperjs python executable wasn't passing native phantom...
n1k0 authored
28 'proxy-type',
29 'script-encoding',
d17faf0 @n1k0 ensured compatibility with phantomjs 1.5
n1k0 authored
30 'web-security',
bfd295f @n1k0 refs #49, #50 - casperjs python executable wasn't passing native phantom...
n1k0 authored
31 ]
32 CASPER_ARGS = []
33 PHANTOMJS_ARGS = []
34
35 for arg in sys.argv[1:]:
3c03103 @n1k0 refs #49, #50 - fixed ordering of passed phantomjs native options
n1k0 authored
36 found = False
bfd295f @n1k0 refs #49, #50 - casperjs python executable wasn't passing native phantom...
n1k0 authored
37 for native in PHANTOMJS_NATIVE_ARGS:
38 if arg.startswith('--%s' % native):
39 PHANTOMJS_ARGS.append(arg)
40 found = True
41 if not found:
42 CASPER_ARGS.append(arg)
43
ca5fdb6 @n1k0 say back hello to python exec - see https://groups.google.com/forum/?pli...
n1k0 authored
44 CASPER_PATH = os.path.abspath(os.path.join(os.path.dirname(resolve(__file__)), '..'))
bfd295f @n1k0 refs #49, #50 - casperjs python executable wasn't passing native phantom...
n1k0 authored
45 CASPER_COMMAND = os.environ.get('PHANTOMJS_EXECUTABLE', 'phantomjs').split(' ')
46 CASPER_COMMAND.extend(PHANTOMJS_ARGS)
47 CASPER_COMMAND.extend([os.path.join(CASPER_PATH, 'bin', 'bootstrap.js'), '--casper-path=%s' % CASPER_PATH, '--cli'])
48 CASPER_COMMAND.extend(CASPER_ARGS)
ca5fdb6 @n1k0 say back hello to python exec - see https://groups.google.com/forum/?pli...
n1k0 authored
49
50 try:
ca07f6e make python launcher use os.execvp() instead of subprocess.Popen()
Justine Tunney authored
51 os.execvp(CASPER_COMMAND[0], CASPER_COMMAND)
6cc9c8e @n1k0 fixes #84 - friendlier error message when phantomjs isn't installed
n1k0 authored
52 except OSError, err:
53 print('Fatal: %s; did you install phantomjs?' % err)
ca07f6e make python launcher use os.execvp() instead of subprocess.Popen()
Justine Tunney authored
54 sys.exit(1)
Something went wrong with that request. Please try again.