Skip to content

Commit

Permalink
Merge pull request scrapinghub#725 from deademo/xvbf_screen_size_para…
Browse files Browse the repository at this point in the history
…meter

Added --xvbf_screen_size parameter.
  • Loading branch information
kmike authored Feb 8, 2018
2 parents aada55e + c6d1d5f commit 9281be8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion splash/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def parse_opts(jupyter=False, argv=sys.argv):
help="comma-separated list of allowed URI schemes (defaut: %default)")
op.add_option("--filters-path",
help="path to a folder with network request filters")
op.add_option('--xvfb-screen-size',
help="screen size for xvfb (default: %default)", default=defaults.VIEWPORT_SIZE)
op.add_option("--disable-private-mode", action="store_true", default=not defaults.PRIVATE_MODE,
help="disable private mode (WARNING: data may leak between requests)" + _bool_default[not defaults.PRIVATE_MODE])
op.add_option("--disable-xvfb", action="store_true", default=False,
Expand Down Expand Up @@ -355,7 +357,7 @@ def main(jupyter=False, argv=sys.argv, server_factory=splash_server):
log_splash_version()
bump_nofile_limit()

with xvfb.autostart(opts.disable_xvfb) as x:
with xvfb.autostart(opts.disable_xvfb, opts.xvfb_screen_size) as x:
xvfb.log_options(x)

install_qtreactor(opts.verbosity >= 5)
Expand Down
9 changes: 5 additions & 4 deletions splash/xvfb.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
from twisted.python import log


def autostart(disable=False):
def autostart(disable=False, screen_size=None):
if disable:
return _dummy()
return _get_xvfb() or _dummy()
return _get_xvfb(screen_size=screen_size) or _dummy()


def log_options(xvfb):
Expand All @@ -27,13 +27,14 @@ def _dummy():
yield


def _get_xvfb():
def _get_xvfb(screen_size=None):
if not sys.platform.startswith('linux'):
return None

try:
from xvfbwrapper import Xvfb
width, height = map(int, defaults.VIEWPORT_SIZE.split("x"))
screen_size = screen_size or defaults.VIEWPORT_SIZE
width, height = map(int, screen_size.split("x"))
return Xvfb(width, height, nolisten="tcp")
except ImportError:
return None

0 comments on commit 9281be8

Please sign in to comment.