def splash_server(portnum, slots, network_manager_factory, max_timeout, splash_proxy_factory_cls=None, js_profiles_path=None, ui_enabled=True, lua_enabled=True, lua_sandbox_enabled=True, lua_package_path="", lua_sandbox_allowed_modules=(), argument_cache_max_entries=None, verbosity=None): from twisted.internet import reactor from twisted.web.server import Site from splash.resources import Root from splash.pool import RenderPool from twisted.python import log from splash import lua verbosity = defaults.VERBOSITY if verbosity is None else verbosity log.msg("verbosity=%d" % verbosity) slots = defaults.SLOTS if slots is None else slots log.msg("slots=%s" % slots) if argument_cache_max_entries: log.msg("argument_cache_max_entries=%s" % argument_cache_max_entries) pool = RenderPool( slots=slots, network_manager_factory=network_manager_factory, splash_proxy_factory_cls=splash_proxy_factory_cls, js_profiles_path=js_profiles_path, verbosity=verbosity, ) if not lua.is_supported() and lua_enabled: lua_enabled = False log.msg("WARNING: Lua is not available, but --disable-lua option is not passed") # HTTP API onoff = {True: "enabled", False: "disabled"} log.msg( "Web UI: %s, Lua: %s (sandbox: %s)" % ( onoff[ui_enabled], onoff[lua_enabled], onoff[lua_sandbox_enabled], ) ) root = Root( pool=pool, ui_enabled=ui_enabled, lua_enabled=lua_enabled, lua_sandbox_enabled=lua_sandbox_enabled, lua_package_path=lua_package_path, lua_sandbox_allowed_modules=lua_sandbox_allowed_modules, max_timeout=max_timeout, argument_cache_max_entries=argument_cache_max_entries, ) factory = Site(root) reactor.listenTCP(portnum, factory)
def splash_server(portnum, ip, slots, network_manager_factory, max_timeout, splash_proxy_factory_cls=None, js_profiles_path=None, ui_enabled=True, lua_enabled=True, lua_sandbox_enabled=True, lua_package_path="", lua_sandbox_allowed_modules=(), strict_lua_runner=False, argument_cache_max_entries=None, disable_browser_caches=False, verbosity=None): from twisted.internet import reactor from twisted.web.server import Site from splash.resources import Root from splash.pool import RenderPool from twisted.python import log from splash import lua verbosity = defaults.VERBOSITY if verbosity is None else verbosity slots = defaults.SLOTS if slots is None else slots log.msg("verbosity={}, slots={}, argument_cache_max_entries={}, max-timeout={}".format( verbosity, slots, argument_cache_max_entries, max_timeout )) pool = RenderPool( slots=slots, network_manager_factory=network_manager_factory, splash_proxy_factory_cls=splash_proxy_factory_cls, js_profiles_path=js_profiles_path, verbosity=verbosity, ) if not lua.is_supported() and lua_enabled: lua_enabled = False log.msg("WARNING: Lua is not available, but --disable-lua option is not passed") # HTTP API log.msg( "Web UI: %s, Lua: %s (sandbox: %s)" % ( ONOFF[ui_enabled], ONOFF[lua_enabled], ONOFF[lua_sandbox_enabled], ) ) root = Root( pool=pool, ui_enabled=ui_enabled, lua_enabled=lua_enabled, lua_sandbox_enabled=lua_sandbox_enabled, lua_package_path=lua_package_path, lua_sandbox_allowed_modules=lua_sandbox_allowed_modules, max_timeout=max_timeout, argument_cache_max_entries=argument_cache_max_entries, strict_lua_runner=strict_lua_runner, ) factory = Site(root) reactor.listenTCP(portnum, factory, interface=ip) log.msg("Server listening on http://%s:%s" % (ip, portnum))
def test_render_ui_available(self): ui_main = self.request({}, endpoint="") self.assertStatusCode(ui_main, 200) self.assertIn("Splash", ui_main.text) if lua.is_supported(): self.assertIn('"lua_enabled": true', ui_main.text) else: self.assertIn('"lua_enabled": false', ui_main.text)
def test_render_ui_available(self): ui_main = self.request({}, endpoint="") self.assertStatusCode(ui_main, 200) self.assertIn("Splash", ui_main.text) if lua.is_supported(): self.assertIn("<textarea", ui_main.text) else: self.assertNotIn("<textarea", ui_main.text)
def log_splash_version(): import twisted from twisted.python import log import sip from PyQt4.QtCore import PYQT_VERSION_STR, QT_VERSION_STR from PyQt4.QtWebKit import qWebKitVersion from splash import lua log.msg("Splash version: %s" % __version__) versions = [ "Qt %s" % QT_VERSION_STR, "PyQt %s" % PYQT_VERSION_STR, "WebKit %s" % qWebKitVersion(), "sip %s" % sip.SIP_VERSION_STR, "Twisted %s" % twisted.version.short(), ] if lua.is_supported(): versions.append(lua.get_version()) log.msg(", ".join(versions))
def log_splash_version(): import twisted from twisted.python import log from splash import lua from splash.qtutils import get_versions log.msg("Splash version: %s" % __version__) verdict = get_versions() versions = [ "Qt %s" % verdict['qt'], "PyQt %s" % verdict['pyqt'], "WebKit %s" % verdict['webkit'], "sip %s" % verdict['sip'], "Twisted %s" % twisted.version.short(), ] if lua.is_supported(): versions.append(lua.get_version()) log.msg(", ".join(versions)) log.msg("Python %s" % sys.version.replace("\n", ""))
# -*- coding: utf-8 -*- from __future__ import absolute_import from splash import lua collect_ignore = [] if not lua.is_supported(): collect_ignore = [ 'lua.py', 'lua_runner.py', 'lua_runtime.py', 'qtrender_lua.py', 'kernel/completer.py', 'kernel/kernel.py', 'kernel/__main__.py', 'kernel/__init__.py', ]