ChromeController.manager_base
index
/media/Scripts/ChromeController/ChromeController/manager_base.py

 
Modules
       
base64
ChromeController.cr_exceptions
gc
logging
pprint
time
uuid

 
Classes
       
builtins.object
ChromeListenerMixin
ChromeInterface

 
class ChromeInterface(ChromeListenerMixin)
    Document me, maybe?
 
 
Method resolution order:
ChromeInterface
ChromeListenerMixin
builtins.object

Methods defined here:
__init__(self, binary, dbg_port, use_execution_manager, additional_options, *args, **kwargs)
Base chromium transport initialization.
 
The binary to execute is assumed to be named `chromium`, and on $PATH
if not specified in the `binary` parameter.
 
The chromium binary is launched with the arg `--remote-debugging-port={dbg_port}` if found.
 
Note that the dbg_port must be GLOBALLY unique on a PER-COMPUTER basis. If not specified, it
will default to an unused port >= 9222.
 
Duplication of the dbg_port parameter can often lead to cr_exceptions.ChromeStartupException
exceptions. If these happen, you may need to call ChromeInterface.close() to force shutdown
of chromium instances, if you are not trying to instantiate multiple instances of chromium
at once.
 
 
All arguments that are not explicitly handled by ChromeInterface() are forwarded to the
underlying ChromeExecutionManager() instace. This is how you can control the behaviour
of the execution manager, including things like whether chromium is run in headless
mode, etc...
asynchronous_command(self, command, **kwargs)
Forward a command to the remote chrome instance via the transport
connection, returning the send_id for the sent command.
 
This is primarily useful for writing intentionally async code that
handles it's own responses via the install_message_handler facilities.
close(self)
drain_transport(self)
"Drain" the transport connection.
 
This command simply returns all waiting messages sent from the remote chrome
instance. This can be useful when waiting for a specific asynchronous message
from chrome, but higher level calls are better suited for managing wait-for-message
type needs.
new_tab(self, *args, **kwargs)
process_available(self)
Process all messages in the socket rx queue.
 
Will block for at least 100 milliseconds.
synchronous_command(self, *args, **kwargs)
Forward a command to the remote chrome instance via the transport
connection, and check the return for an error.
 
If the command resulted in an error, a `ChromeController.ChromeError` is raised,
with the error string containing the response from the remote
chrome instance describing the problem and it's cause.
 
Otherwise, the decoded json data-structure returned from the remote instance is
returned.

Methods inherited from ChromeListenerMixin:
clear_content_listener_cache(self)
The handlers installed by install_listener_for_content() have some persistant
storage in the class to allow tracking request-id -> response body mappings.
 
These shouldn't take much RAM, but extremely long chromium execution times can
conceivably cause them to grow excessively.
 
This call clears them. Note that calling this while a request is in-flight may cause
strange callback errors.
install_listener_for_content(self, handler)
Install a content handler.
`handler` will be called for each received content item.
Internally, this involves a larger set of handlers to track the mappings of request-id to actual URL,
and asynchronously invoked Network.getResponseBody against the chromium tab instance.
 
The handler is invoked as:
`handler(self, req_url, response_body)` where self is the pointer to the local ChromeInterface instance.
install_message_handler(self, handler)
Add handler `handler` to the list of message handlers that will be called on all received messages.
 
The handler will be called with the tab context for each message the tab generates.
 
NOTE: Handler call order is not specified!
remove_all_handlers(self)
Remove all message handlers for the current tab.
remove_handlers(self, handler)
Remove handler `handler` from the list of message handlers that will be called
on all received messages for the current tab.
 
If the the handler is not present, a KeyError will be raised.
set_filter_func(self, func)
Specify a function with a signature `func(url, meta)` to be used as the precondition filter
for requesting full fetch results from the browser.
 
Precondition check before executing the fetch of content for url `url` from the browser.
This is mostly useful for preventing the overhead of requesting large binary files multiple times.
 
Overriding and returning false on later requests prevents additionl `Network.getResponseBody` invocations
being set to the browser.
 
Note that specifying func=None is a special case where a empty pass function that always returns true will
be used.
 
Additionally, this function is *per tab*, and not automatically copied to a new tab when it is created.

Data descriptors inherited from ChromeListenerMixin:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class ChromeListenerMixin(builtins.object)
    Docs plzzzz
 
  Methods defined here:
__init__(self, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.
clear_content_listener_cache(self)
The handlers installed by install_listener_for_content() have some persistant
storage in the class to allow tracking request-id -> response body mappings.
 
These shouldn't take much RAM, but extremely long chromium execution times can
conceivably cause them to grow excessively.
 
This call clears them. Note that calling this while a request is in-flight may cause
strange callback errors.
install_listener_for_content(self, handler)
Install a content handler.
`handler` will be called for each received content item.
Internally, this involves a larger set of handlers to track the mappings of request-id to actual URL,
and asynchronously invoked Network.getResponseBody against the chromium tab instance.
 
The handler is invoked as:
`handler(self, req_url, response_body)` where self is the pointer to the local ChromeInterface instance.
install_message_handler(self, handler)
Add handler `handler` to the list of message handlers that will be called on all received messages.
 
The handler will be called with the tab context for each message the tab generates.
 
NOTE: Handler call order is not specified!
remove_all_handlers(self)
Remove all message handlers for the current tab.
remove_handlers(self, handler)
Remove handler `handler` from the list of message handlers that will be called
on all received messages for the current tab.
 
If the the handler is not present, a KeyError will be raised.
set_filter_func(self, func)
Specify a function with a signature `func(url, meta)` to be used as the precondition filter
for requesting full fetch results from the browser.
 
Precondition check before executing the fetch of content for url `url` from the browser.
This is mostly useful for preventing the overhead of requesting large binary files multiple times.
 
Overriding and returning false on later requests prevents additionl `Network.getResponseBody` invocations
being set to the browser.
 
Note that specifying func=None is a special case where a empty pass function that always returns true will
be used.
 
Additionally, this function is *per tab*, and not automatically copied to a new tab when it is created.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Functions
       
decode_chrome_getResponseBody(message)
Given a response dict from a Network.getResponseBody command,
return either the properly decoded binary object, or the unicode
string.
filter_stub(url, meta)