#NEWLINE# def parse_opts( jupyter = False , argv = sys . argv ) : #NEWLINE# #INDENT# _bool_default = { #NEWLINE# #INDENT# True : ' (default)' , #NEWLINE# False : '' , #NEWLINE# #UNINDENT# } #NEWLINE# op = optparse . OptionParser ( ) #NEWLINE# op . add_option ( '-f' , '--logfile' , help = 'log file' ) #NEWLINE# op . add_option ( '-m' , '--maxrss' , type = float , default = 0 , help = 'exit if max RSS reaches this value (in MB or ratio of physical mem) (default: %default)' ) #NEWLINE# op . add_option ( '--proxy-profiles-path' , help = 'path to a folder with proxy profiles' ) #NEWLINE# op . add_option ( '--js-profiles-path' , help = 'path to a folder with javascript profiles' ) #NEWLINE# op . add_option ( '--no-js-cross-domain-access' , action = 'store_false' , dest = 'js_cross_domain_enabled' , default = ( not defaults . JS_CROSS_DOMAIN_ENABLED ) , help = ( 'disable support for cross domain access when executing custom javascript' + _bool_default [ ( not defaults . JS_CROSS_DOMAIN_ENABLED ) ] ) ) #NEWLINE# op . add_option ( '--js-cross-domain-access' , action = 'store_true' , dest = 'js_cross_domain_enabled' , default = defaults . JS_CROSS_DOMAIN_ENABLED , help = ( 'enable support for cross domain access when executing custom javascript (WARNING: it could break rendering for some of the websites)' + _bool_default [ defaults . JS_CROSS_DOMAIN_ENABLED ] ) ) #NEWLINE# op . add_option ( '--allowed-schemes' , default = ',' . join ( defaults . ALLOWED_SCHEMES ) , help = 'comma-separated list of allowed URI schemes (defaut: %default)' ) #NEWLINE# op . add_option ( '--filters-path' , help = 'path to a folder with network request filters' ) #NEWLINE# 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 ) ] ) ) #NEWLINE# op . add_option ( '--disable-xvfb' , action = 'store_true' , default = False , help = 'disable Xvfb auto start' ) #NEWLINE# op . add_option ( '--disable-lua-sandbox' , action = 'store_true' , default = False , help = 'disable Lua sandbox' ) #NEWLINE# op . add_option ( '--lua-package-path' , default = '' , help = "semicolon-separated places to add to Lua package.path. Each place can have a ? in it that's replaced with the module name." ) #NEWLINE# op . add_option ( '--lua-sandbox-allowed-modules' , default = '' , help = 'semicolon-separated list of Lua module names allowed to be required from a sandbox.' ) #NEWLINE# op . add_option ( '-v' , '--verbosity' , type = int , default = defaults . VERBOSITY , help = 'verbosity level; valid values are integers from 0 to 5 (default: %default)' ) #NEWLINE# op . add_option ( '--version' , action = 'store_true' , help = 'print Splash version number and exit' ) #NEWLINE# if ( not jupyter ) : #NEWLINE# #INDENT# op . add_option ( '-p' , '--port' , type = 'int' , default = defaults . SPLASH_PORT , help = 'port to listen to (default: %default)' ) #NEWLINE# op . add_option ( '-s' , '--slots' , type = 'int' , default = defaults . SLOTS , help = 'number of render slots (default: %default)' ) #NEWLINE# op . add_option ( '--max-timeout' , type = 'float' , default = defaults . MAX_TIMEOUT , help = 'maximum allowed value for timeout (default: %default)' ) #NEWLINE# op . add_option ( '--manhole' , action = 'store_true' , help = 'enable manhole server' ) #NEWLINE# op . add_option ( '--disable-ui' , action = 'store_true' , default = False , help = 'disable web UI' ) #NEWLINE# op . add_option ( '--disable-lua' , action = 'store_true' , default = False , help = 'disable Lua scripting' ) #NEWLINE# op . add_option ( '--argument-cache-max-entries' , type = 'int' , default = defaults . ARGUMENT_CACHE_MAX_ENTRIES , help = 'maximum number of entries in arguments cache (default: %default)' ) #NEWLINE# #UNINDENT# ( opts , args ) = op . parse_args ( op ) #NEWLINE# if jupyter : #NEWLINE# #INDENT# opts . manhole = False #NEWLINE# opts . disable_ui = True #NEWLINE# opts . disable_lua = False #NEWLINE# opts . port = None #NEWLINE# opts . slots = None #NEWLINE# opts . max_timeout = None #NEWLINE# opts . argument_cache_max_entries = None #NEWLINE# #UNINDENT# return ( opts , args )