partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
MultizoneManager.register_listener
Register a listener for audio group changes of cast uuid. On update will call: listener.added_to_multizone(group_uuid) The cast has been added to group uuid listener.removed_from_multizone(group_uuid) The cast has been removed from group uuid ...
pychromecast/controllers/multizone.py
def register_listener(self, member_uuid, listener): """ Register a listener for audio group changes of cast uuid. On update will call: listener.added_to_multizone(group_uuid) The cast has been added to group uuid listener.removed_from_multizone(group_uuid) ...
def register_listener(self, member_uuid, listener): """ Register a listener for audio group changes of cast uuid. On update will call: listener.added_to_multizone(group_uuid) The cast has been added to group uuid listener.removed_from_multizone(group_uuid) ...
[ "Register", "a", "listener", "for", "audio", "group", "changes", "of", "cast", "uuid", ".", "On", "update", "will", "call", ":", "listener", ".", "added_to_multizone", "(", "group_uuid", ")", "The", "cast", "has", "been", "added", "to", "group", "uuid", "l...
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/multizone.py#L117-L133
[ "def", "register_listener", "(", "self", ",", "member_uuid", ",", "listener", ")", ":", "member_uuid", "=", "str", "(", "member_uuid", ")", "if", "member_uuid", "not", "in", "self", ".", "_casts", ":", "self", ".", "_casts", "[", "member_uuid", "]", "=", ...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
MultizoneManager.deregister_listener
Deregister listener for audio group changes of cast uuid.
pychromecast/controllers/multizone.py
def deregister_listener(self, member_uuid, listener): """ Deregister listener for audio group changes of cast uuid.""" self._casts[str(member_uuid)]['listeners'].remove(listener)
def deregister_listener(self, member_uuid, listener): """ Deregister listener for audio group changes of cast uuid.""" self._casts[str(member_uuid)]['listeners'].remove(listener)
[ "Deregister", "listener", "for", "audio", "group", "changes", "of", "cast", "uuid", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/multizone.py#L135-L137
[ "def", "deregister_listener", "(", "self", ",", "member_uuid", ",", "listener", ")", ":", "self", ".", "_casts", "[", "str", "(", "member_uuid", ")", "]", "[", "'listeners'", "]", ".", "remove", "(", "listener", ")" ]
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
MultizoneController.receive_message
Called when a multizone message is received.
pychromecast/controllers/multizone.py
def receive_message(self, message, data): # noqa: E501 pylint: disable=too-many-return-statements """ Called when a multizone message is received. """ if data[MESSAGE_TYPE] == TYPE_DEVICE_ADDED: uuid = data['device']['deviceId'] name = data['device']['name'] self._ad...
def receive_message(self, message, data): # noqa: E501 pylint: disable=too-many-return-statements """ Called when a multizone message is received. """ if data[MESSAGE_TYPE] == TYPE_DEVICE_ADDED: uuid = data['device']['deviceId'] name = data['device']['name'] self._ad...
[ "Called", "when", "a", "multizone", "message", "is", "received", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/multizone.py#L200-L247
[ "def", "receive_message", "(", "self", ",", "message", ",", "data", ")", ":", "# noqa: E501 pylint: disable=too-many-return-statements", "if", "data", "[", "MESSAGE_TYPE", "]", "==", "TYPE_DEVICE_ADDED", ":", "uuid", "=", "data", "[", "'device'", "]", "[", "'devic...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
_get_chromecast_from_host
Creates a Chromecast object from a zeroconf host.
pychromecast/__init__.py
def _get_chromecast_from_host(host, tries=None, retry_wait=None, timeout=None, blocking=True): """Creates a Chromecast object from a zeroconf host.""" # Build device status from the mDNS info, this information is # the primary source and the remaining will be fetched # late...
def _get_chromecast_from_host(host, tries=None, retry_wait=None, timeout=None, blocking=True): """Creates a Chromecast object from a zeroconf host.""" # Build device status from the mDNS info, this information is # the primary source and the remaining will be fetched # late...
[ "Creates", "a", "Chromecast", "object", "from", "a", "zeroconf", "host", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/__init__.py#L29-L45
[ "def", "_get_chromecast_from_host", "(", "host", ",", "tries", "=", "None", ",", "retry_wait", "=", "None", ",", "timeout", "=", "None", ",", "blocking", "=", "True", ")", ":", "# Build device status from the mDNS info, this information is", "# the primary source and th...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
_get_chromecast_from_service
Creates a Chromecast object from a zeroconf service.
pychromecast/__init__.py
def _get_chromecast_from_service(services, tries=None, retry_wait=None, timeout=None, blocking=True): """Creates a Chromecast object from a zeroconf service.""" # Build device status from the mDNS service name info, this # information is the primary source and the remaining ...
def _get_chromecast_from_service(services, tries=None, retry_wait=None, timeout=None, blocking=True): """Creates a Chromecast object from a zeroconf service.""" # Build device status from the mDNS service name info, this # information is the primary source and the remaining ...
[ "Creates", "a", "Chromecast", "object", "from", "a", "zeroconf", "service", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/__init__.py#L48-L64
[ "def", "_get_chromecast_from_service", "(", "services", ",", "tries", "=", "None", ",", "retry_wait", "=", "None", ",", "timeout", "=", "None", ",", "blocking", "=", "True", ")", ":", "# Build device status from the mDNS service name info, this", "# information is the p...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
get_chromecasts
Searches the network for chromecast devices. If blocking = True, returns a list of discovered chromecast devices. If blocking = False, triggers a callback for each discovered chromecast, and returns a function which can be executed to stop discovery. May r...
pychromecast/__init__.py
def get_chromecasts(tries=None, retry_wait=None, timeout=None, blocking=True, callback=None): """ Searches the network for chromecast devices. If blocking = True, returns a list of discovered chromecast devices. If blocking = False, triggers a callback for each discovered chromecast...
def get_chromecasts(tries=None, retry_wait=None, timeout=None, blocking=True, callback=None): """ Searches the network for chromecast devices. If blocking = True, returns a list of discovered chromecast devices. If blocking = False, triggers a callback for each discovered chromecast...
[ "Searches", "the", "network", "for", "chromecast", "devices", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/__init__.py#L68-L119
[ "def", "get_chromecasts", "(", "tries", "=", "None", ",", "retry_wait", "=", "None", ",", "timeout", "=", "None", ",", "blocking", "=", "True", ",", "callback", "=", "None", ")", ":", "if", "blocking", ":", "# Thread blocking chromecast discovery", "hosts", ...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
Chromecast.ignore_cec
Returns whether the CEC data should be ignored.
pychromecast/__init__.py
def ignore_cec(self): """ Returns whether the CEC data should be ignored. """ return self.device is not None and \ any([fnmatch.fnmatchcase(self.device.friendly_name, pattern) for pattern in IGNORE_CEC])
def ignore_cec(self): """ Returns whether the CEC data should be ignored. """ return self.device is not None and \ any([fnmatch.fnmatchcase(self.device.friendly_name, pattern) for pattern in IGNORE_CEC])
[ "Returns", "whether", "the", "CEC", "data", "should", "be", "ignored", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/__init__.py#L210-L214
[ "def", "ignore_cec", "(", "self", ")", ":", "return", "self", ".", "device", "is", "not", "None", "and", "any", "(", "[", "fnmatch", ".", "fnmatchcase", "(", "self", ".", "device", ".", "friendly_name", ",", "pattern", ")", "for", "pattern", "in", "IGN...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
Chromecast.is_idle
Returns if there is currently an app running.
pychromecast/__init__.py
def is_idle(self): """ Returns if there is currently an app running. """ return (self.status is None or self.app_id in (None, IDLE_APP_ID) or (not self.status.is_active_input and not self.ignore_cec))
def is_idle(self): """ Returns if there is currently an app running. """ return (self.status is None or self.app_id in (None, IDLE_APP_ID) or (not self.status.is_active_input and not self.ignore_cec))
[ "Returns", "if", "there", "is", "currently", "an", "app", "running", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/__init__.py#L217-L221
[ "def", "is_idle", "(", "self", ")", ":", "return", "(", "self", ".", "status", "is", "None", "or", "self", ".", "app_id", "in", "(", "None", ",", "IDLE_APP_ID", ")", "or", "(", "not", "self", ".", "status", ".", "is_active_input", "and", "not", "self...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
Chromecast.new_cast_status
Called when a new status received from the Chromecast.
pychromecast/__init__.py
def new_cast_status(self, status): """ Called when a new status received from the Chromecast. """ self.status = status if status: self.status_event.set()
def new_cast_status(self, status): """ Called when a new status received from the Chromecast. """ self.status = status if status: self.status_event.set()
[ "Called", "when", "a", "new", "status", "received", "from", "the", "Chromecast", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/__init__.py#L274-L278
[ "def", "new_cast_status", "(", "self", ",", "status", ")", ":", "self", ".", "status", "=", "status", "if", "status", ":", "self", ".", "status_event", ".", "set", "(", ")" ]
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
Chromecast.start_app
Start an app on the Chromecast.
pychromecast/__init__.py
def start_app(self, app_id, force_launch=False): """ Start an app on the Chromecast. """ self.logger.info("Starting app %s", app_id) self.socket_client.receiver_controller.launch_app(app_id, force_launch)
def start_app(self, app_id, force_launch=False): """ Start an app on the Chromecast. """ self.logger.info("Starting app %s", app_id) self.socket_client.receiver_controller.launch_app(app_id, force_launch)
[ "Start", "an", "app", "on", "the", "Chromecast", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/__init__.py#L280-L284
[ "def", "start_app", "(", "self", ",", "app_id", ",", "force_launch", "=", "False", ")", ":", "self", ".", "logger", ".", "info", "(", "\"Starting app %s\"", ",", "app_id", ")", "self", ".", "socket_client", ".", "receiver_controller", ".", "launch_app", "(",...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
Chromecast.volume_up
Increment volume by 0.1 (or delta) unless it is already maxed. Returns the new volume.
pychromecast/__init__.py
def volume_up(self, delta=0.1): """ Increment volume by 0.1 (or delta) unless it is already maxed. Returns the new volume. """ if delta <= 0: raise ValueError( "volume delta must be greater than zero, not {}".format(delta)) return self.set_volume(self...
def volume_up(self, delta=0.1): """ Increment volume by 0.1 (or delta) unless it is already maxed. Returns the new volume. """ if delta <= 0: raise ValueError( "volume delta must be greater than zero, not {}".format(delta)) return self.set_volume(self...
[ "Increment", "volume", "by", "0", ".", "1", "(", "or", "delta", ")", "unless", "it", "is", "already", "maxed", ".", "Returns", "the", "new", "volume", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/__init__.py#L296-L304
[ "def", "volume_up", "(", "self", ",", "delta", "=", "0.1", ")", ":", "if", "delta", "<=", "0", ":", "raise", "ValueError", "(", "\"volume delta must be greater than zero, not {}\"", ".", "format", "(", "delta", ")", ")", "return", "self", ".", "set_volume", ...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
Chromecast.volume_down
Decrement the volume by 0.1 (or delta) unless it is already 0. Returns the new volume.
pychromecast/__init__.py
def volume_down(self, delta=0.1): """ Decrement the volume by 0.1 (or delta) unless it is already 0. Returns the new volume. """ if delta <= 0: raise ValueError( "volume delta must be greater than zero, not {}".format(delta)) return self.set_volume(sel...
def volume_down(self, delta=0.1): """ Decrement the volume by 0.1 (or delta) unless it is already 0. Returns the new volume. """ if delta <= 0: raise ValueError( "volume delta must be greater than zero, not {}".format(delta)) return self.set_volume(sel...
[ "Decrement", "the", "volume", "by", "0", ".", "1", "(", "or", "delta", ")", "unless", "it", "is", "already", "0", ".", "Returns", "the", "new", "volume", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/__init__.py#L306-L313
[ "def", "volume_down", "(", "self", ",", "delta", "=", "0.1", ")", ":", "if", "delta", "<=", "0", ":", "raise", "ValueError", "(", "\"volume delta must be greater than zero, not {}\"", ".", "format", "(", "delta", ")", ")", "return", "self", ".", "set_volume", ...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
Chromecast.wait
Waits until the cast device is ready for communication. The device is ready as soon a status message has been received. If the worker thread is not already running, it will be started. If the status has already been received then the method returns immediately. :param timeout:...
pychromecast/__init__.py
def wait(self, timeout=None): """ Waits until the cast device is ready for communication. The device is ready as soon a status message has been received. If the worker thread is not already running, it will be started. If the status has already been received then the method ret...
def wait(self, timeout=None): """ Waits until the cast device is ready for communication. The device is ready as soon a status message has been received. If the worker thread is not already running, it will be started. If the status has already been received then the method ret...
[ "Waits", "until", "the", "cast", "device", "is", "ready", "for", "communication", ".", "The", "device", "is", "ready", "as", "soon", "a", "status", "message", "has", "been", "received", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/__init__.py#L315-L331
[ "def", "wait", "(", "self", ",", "timeout", "=", "None", ")", ":", "if", "not", "self", ".", "socket_client", ".", "isAlive", "(", ")", ":", "self", ".", "socket_client", ".", "start", "(", ")", "self", ".", "status_event", ".", "wait", "(", "timeout...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
Chromecast.disconnect
Disconnects the chromecast and waits for it to terminate. :param timeout: a floating point number specifying a timeout for the operation in seconds (or fractions thereof). Or None to block forever. :param blocking: If True it will block until the disconne...
pychromecast/__init__.py
def disconnect(self, timeout=None, blocking=True): """ Disconnects the chromecast and waits for it to terminate. :param timeout: a floating point number specifying a timeout for the operation in seconds (or fractions thereof). Or None to block for...
def disconnect(self, timeout=None, blocking=True): """ Disconnects the chromecast and waits for it to terminate. :param timeout: a floating point number specifying a timeout for the operation in seconds (or fractions thereof). Or None to block for...
[ "Disconnects", "the", "chromecast", "and", "waits", "for", "it", "to", "terminate", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/__init__.py#L340-L352
[ "def", "disconnect", "(", "self", ",", "timeout", "=", "None", ",", "blocking", "=", "True", ")", ":", "self", ".", "socket_client", ".", "disconnect", "(", ")", "if", "blocking", ":", "self", ".", "join", "(", "timeout", "=", "timeout", ")" ]
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
_json_from_message
Parses a PB2 message into JSON format.
pychromecast/socket_client.py
def _json_from_message(message): """ Parses a PB2 message into JSON format. """ try: return json.loads(message.payload_utf8) except ValueError: logger = logging.getLogger(__name__) logger.warning("Ignoring invalid json in namespace %s: %s", message.namespace, m...
def _json_from_message(message): """ Parses a PB2 message into JSON format. """ try: return json.loads(message.payload_utf8) except ValueError: logger = logging.getLogger(__name__) logger.warning("Ignoring invalid json in namespace %s: %s", message.namespace, m...
[ "Parses", "a", "PB2", "message", "into", "JSON", "format", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L84-L92
[ "def", "_json_from_message", "(", "message", ")", ":", "try", ":", "return", "json", ".", "loads", "(", "message", ".", "payload_utf8", ")", "except", "ValueError", ":", "logger", "=", "logging", ".", "getLogger", "(", "__name__", ")", "logger", ".", "warn...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
_message_to_string
Gives a string representation of a PB2 message.
pychromecast/socket_client.py
def _message_to_string(message, data=None): """ Gives a string representation of a PB2 message. """ if data is None: data = _json_from_message(message) return "Message {} from {} to {}: {}".format( message.namespace, message.source_id, message.destination_id, data)
def _message_to_string(message, data=None): """ Gives a string representation of a PB2 message. """ if data is None: data = _json_from_message(message) return "Message {} from {} to {}: {}".format( message.namespace, message.source_id, message.destination_id, data)
[ "Gives", "a", "string", "representation", "of", "a", "PB2", "message", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L95-L101
[ "def", "_message_to_string", "(", "message", ",", "data", "=", "None", ")", ":", "if", "data", "is", "None", ":", "data", "=", "_json_from_message", "(", "message", ")", "return", "\"Message {} from {} to {}: {}\"", ".", "format", "(", "message", ".", "namespa...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
new_socket
Create a new socket with OS-specific parameters Try to set SO_REUSEPORT for BSD-flavored systems if it's an option. Catches errors if not.
pychromecast/socket_client.py
def new_socket(): """ Create a new socket with OS-specific parameters Try to set SO_REUSEPORT for BSD-flavored systems if it's an option. Catches errors if not. """ new_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) new_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) ...
def new_socket(): """ Create a new socket with OS-specific parameters Try to set SO_REUSEPORT for BSD-flavored systems if it's an option. Catches errors if not. """ new_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) new_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) ...
[ "Create", "a", "new", "socket", "with", "OS", "-", "specific", "parameters" ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L1099-L1122
[ "def", "new_socket", "(", ")", ":", "new_sock", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ")", "new_sock", ".", "setsockopt", "(", "socket", ".", "SOL_SOCKET", ",", "socket", ".", "SO_REUSEADDR", ",", ...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
SocketClient.initialize_connection
Initialize a socket to a Chromecast, retrying as necessary.
pychromecast/socket_client.py
def initialize_connection(self): # noqa: E501 pylint:disable=too-many-statements, too-many-branches """Initialize a socket to a Chromecast, retrying as necessary.""" tries = self.tries if self.socket is not None: self.socket.close() self.socket = None # Make su...
def initialize_connection(self): # noqa: E501 pylint:disable=too-many-statements, too-many-branches """Initialize a socket to a Chromecast, retrying as necessary.""" tries = self.tries if self.socket is not None: self.socket.close() self.socket = None # Make su...
[ "Initialize", "a", "socket", "to", "a", "Chromecast", "retrying", "as", "necessary", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L215-L354
[ "def", "initialize_connection", "(", "self", ")", ":", "# noqa: E501 pylint:disable=too-many-statements, too-many-branches", "tries", "=", "self", ".", "tries", "if", "self", ".", "socket", "is", "not", "None", ":", "self", ".", "socket", ".", "close", "(", ")", ...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
SocketClient.connect
Connect socket connection to Chromecast device. Must only be called if the worker thread will not be started.
pychromecast/socket_client.py
def connect(self): """ Connect socket connection to Chromecast device. Must only be called if the worker thread will not be started. """ try: self.initialize_connection() except ChromecastConnectionError: self._report_connection_status( ...
def connect(self): """ Connect socket connection to Chromecast device. Must only be called if the worker thread will not be started. """ try: self.initialize_connection() except ChromecastConnectionError: self._report_connection_status( ...
[ "Connect", "socket", "connection", "to", "Chromecast", "device", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L356-L367
[ "def", "connect", "(", "self", ")", ":", "try", ":", "self", ".", "initialize_connection", "(", ")", "except", "ChromecastConnectionError", ":", "self", ".", "_report_connection_status", "(", "ConnectionStatus", "(", "CONNECTION_STATUS_DISCONNECTED", ",", "NetworkAddr...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
SocketClient.register_handler
Register a new namespace handler.
pychromecast/socket_client.py
def register_handler(self, handler): """ Register a new namespace handler. """ self._handlers[handler.namespace] = handler handler.registered(self)
def register_handler(self, handler): """ Register a new namespace handler. """ self._handlers[handler.namespace] = handler handler.registered(self)
[ "Register", "a", "new", "namespace", "handler", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L373-L377
[ "def", "register_handler", "(", "self", ",", "handler", ")", ":", "self", ".", "_handlers", "[", "handler", ".", "namespace", "]", "=", "handler", "handler", ".", "registered", "(", "self", ")" ]
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
SocketClient.new_cast_status
Called when a new cast status has been received.
pychromecast/socket_client.py
def new_cast_status(self, cast_status): """ Called when a new cast status has been received. """ new_channel = self.destination_id != cast_status.transport_id if new_channel: self.disconnect_channel(self.destination_id) self.app_namespaces = cast_status.namespaces s...
def new_cast_status(self, cast_status): """ Called when a new cast status has been received. """ new_channel = self.destination_id != cast_status.transport_id if new_channel: self.disconnect_channel(self.destination_id) self.app_namespaces = cast_status.namespaces s...
[ "Called", "when", "a", "new", "cast", "status", "has", "been", "received", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L379-L396
[ "def", "new_cast_status", "(", "self", ",", "cast_status", ")", ":", "new_channel", "=", "self", ".", "destination_id", "!=", "cast_status", ".", "transport_id", "if", "new_channel", ":", "self", ".", "disconnect_channel", "(", "self", ".", "destination_id", ")"...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
SocketClient.run
Connect to the cast and start polling the socket.
pychromecast/socket_client.py
def run(self): """ Connect to the cast and start polling the socket. """ try: self.initialize_connection() except ChromecastConnectionError: self._report_connection_status( ConnectionStatus(CONNECTION_STATUS_DISCONNECTED, N...
def run(self): """ Connect to the cast and start polling the socket. """ try: self.initialize_connection() except ChromecastConnectionError: self._report_connection_status( ConnectionStatus(CONNECTION_STATUS_DISCONNECTED, N...
[ "Connect", "to", "the", "cast", "and", "start", "polling", "the", "socket", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L420-L439
[ "def", "run", "(", "self", ")", ":", "try", ":", "self", ".", "initialize_connection", "(", ")", "except", "ChromecastConnectionError", ":", "self", ".", "_report_connection_status", "(", "ConnectionStatus", "(", "CONNECTION_STATUS_DISCONNECTED", ",", "NetworkAddress"...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
SocketClient.run_once
Use run_once() in your own main loop after you receive something on the socket (get_socket()).
pychromecast/socket_client.py
def run_once(self): """ Use run_once() in your own main loop after you receive something on the socket (get_socket()). """ # pylint: disable=too-many-branches, too-many-return-statements try: if not self._check_connection(): return 0 e...
def run_once(self): """ Use run_once() in your own main loop after you receive something on the socket (get_socket()). """ # pylint: disable=too-many-branches, too-many-return-statements try: if not self._check_connection(): return 0 e...
[ "Use", "run_once", "()", "in", "your", "own", "main", "loop", "after", "you", "receive", "something", "on", "the", "socket", "(", "get_socket", "()", ")", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L441-L506
[ "def", "run_once", "(", "self", ")", ":", "# pylint: disable=too-many-branches, too-many-return-statements", "try", ":", "if", "not", "self", ".", "_check_connection", "(", ")", ":", "return", "0", "except", "ChromecastConnectionError", ":", "return", "1", "# poll the...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
SocketClient._check_connection
Checks if the connection is active, and if not reconnect :return: True if the connection is active, False if the connection was reset.
pychromecast/socket_client.py
def _check_connection(self): """ Checks if the connection is active, and if not reconnect :return: True if the connection is active, False if the connection was reset. """ # check if connection is expired reset = False if self._force_recon: ...
def _check_connection(self): """ Checks if the connection is active, and if not reconnect :return: True if the connection is active, False if the connection was reset. """ # check if connection is expired reset = False if self._force_recon: ...
[ "Checks", "if", "the", "connection", "is", "active", "and", "if", "not", "reconnect" ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L515-L548
[ "def", "_check_connection", "(", "self", ")", ":", "# check if connection is expired", "reset", "=", "False", "if", "self", ".", "_force_recon", ":", "self", ".", "logger", ".", "warning", "(", "\"[%s:%s] Error communicating with socket, resetting \"", "\"connection\"", ...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
SocketClient._route_message
Route message to any handlers on the message namespace
pychromecast/socket_client.py
def _route_message(self, message, data): """ Route message to any handlers on the message namespace """ # route message to handlers if message.namespace in self._handlers: # debug messages if message.namespace != NS_HEARTBEAT: self.logger.debug( ...
def _route_message(self, message, data): """ Route message to any handlers on the message namespace """ # route message to handlers if message.namespace in self._handlers: # debug messages if message.namespace != NS_HEARTBEAT: self.logger.debug( ...
[ "Route", "message", "to", "any", "handlers", "on", "the", "message", "namespace" ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L550-L584
[ "def", "_route_message", "(", "self", ",", "message", ",", "data", ")", ":", "# route message to handlers", "if", "message", ".", "namespace", "in", "self", ".", "_handlers", ":", "# debug messages", "if", "message", ".", "namespace", "!=", "NS_HEARTBEAT", ":", ...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
SocketClient._cleanup
Cleanup open channels and handlers
pychromecast/socket_client.py
def _cleanup(self): """ Cleanup open channels and handlers """ for channel in self._open_channels: try: self.disconnect_channel(channel) except Exception: # pylint: disable=broad-except pass for handler in self._handlers.values(): ...
def _cleanup(self): """ Cleanup open channels and handlers """ for channel in self._open_channels: try: self.disconnect_channel(channel) except Exception: # pylint: disable=broad-except pass for handler in self._handlers.values(): ...
[ "Cleanup", "open", "channels", "and", "handlers" ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L586-L608
[ "def", "_cleanup", "(", "self", ")", ":", "for", "channel", "in", "self", ".", "_open_channels", ":", "try", ":", "self", ".", "disconnect_channel", "(", "channel", ")", "except", "Exception", ":", "# pylint: disable=broad-except", "pass", "for", "handler", "i...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
SocketClient._report_connection_status
Report a change in the connection status to any listeners
pychromecast/socket_client.py
def _report_connection_status(self, status): """ Report a change in the connection status to any listeners """ for listener in self._connection_listeners: try: self.logger.debug("[%s:%s] connection listener: %x (%s)", self.fn or self.host, se...
def _report_connection_status(self, status): """ Report a change in the connection status to any listeners """ for listener in self._connection_listeners: try: self.logger.debug("[%s:%s] connection listener: %x (%s)", self.fn or self.host, se...
[ "Report", "a", "change", "in", "the", "connection", "status", "to", "any", "listeners" ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L610-L621
[ "def", "_report_connection_status", "(", "self", ",", "status", ")", ":", "for", "listener", "in", "self", ".", "_connection_listeners", ":", "try", ":", "self", ".", "logger", ".", "debug", "(", "\"[%s:%s] connection listener: %x (%s)\"", ",", "self", ".", "fn"...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
SocketClient._read_bytes_from_socket
Read bytes from the socket.
pychromecast/socket_client.py
def _read_bytes_from_socket(self, msglen): """ Read bytes from the socket. """ chunks = [] bytes_recd = 0 while bytes_recd < msglen: if self.stop.is_set(): raise InterruptLoop("Stopped while reading from socket") try: chunk = self.s...
def _read_bytes_from_socket(self, msglen): """ Read bytes from the socket. """ chunks = [] bytes_recd = 0 while bytes_recd < msglen: if self.stop.is_set(): raise InterruptLoop("Stopped while reading from socket") try: chunk = self.s...
[ "Read", "bytes", "from", "the", "socket", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L623-L644
[ "def", "_read_bytes_from_socket", "(", "self", ",", "msglen", ")", ":", "chunks", "=", "[", "]", "bytes_recd", "=", "0", "while", "bytes_recd", "<", "msglen", ":", "if", "self", ".", "stop", ".", "is_set", "(", ")", ":", "raise", "InterruptLoop", "(", ...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
SocketClient._read_message
Reads a message from the socket and converts it to a message.
pychromecast/socket_client.py
def _read_message(self): """ Reads a message from the socket and converts it to a message. """ # first 4 bytes is Big-Endian payload length payload_info = self._read_bytes_from_socket(4) read_len = unpack(">I", payload_info)[0] # now read the payload payload = self._read...
def _read_message(self): """ Reads a message from the socket and converts it to a message. """ # first 4 bytes is Big-Endian payload length payload_info = self._read_bytes_from_socket(4) read_len = unpack(">I", payload_info)[0] # now read the payload payload = self._read...
[ "Reads", "a", "message", "from", "the", "socket", "and", "converts", "it", "to", "a", "message", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L646-L659
[ "def", "_read_message", "(", "self", ")", ":", "# first 4 bytes is Big-Endian payload length", "payload_info", "=", "self", ".", "_read_bytes_from_socket", "(", "4", ")", "read_len", "=", "unpack", "(", "\">I\"", ",", "payload_info", ")", "[", "0", "]", "# now rea...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
SocketClient.send_message
Send a message to the Chromecast.
pychromecast/socket_client.py
def send_message(self, destination_id, namespace, data, inc_session_id=False, callback_function=False, no_add_request_id=False, force=False): """ Send a message to the Chromecast. """ # namespace is a string containing namespace # data is a dict that wi...
def send_message(self, destination_id, namespace, data, inc_session_id=False, callback_function=False, no_add_request_id=False, force=False): """ Send a message to the Chromecast. """ # namespace is a string containing namespace # data is a dict that wi...
[ "Send", "a", "message", "to", "the", "Chromecast", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L662-L719
[ "def", "send_message", "(", "self", ",", "destination_id", ",", "namespace", ",", "data", ",", "inc_session_id", "=", "False", ",", "callback_function", "=", "False", ",", "no_add_request_id", "=", "False", ",", "force", "=", "False", ")", ":", "# namespace is...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
SocketClient.send_platform_message
Helper method to send a message to the platform.
pychromecast/socket_client.py
def send_platform_message(self, namespace, message, inc_session_id=False, callback_function_param=False): """ Helper method to send a message to the platform. """ return self.send_message(PLATFORM_DESTINATION_ID, namespace, message, inc_sess...
def send_platform_message(self, namespace, message, inc_session_id=False, callback_function_param=False): """ Helper method to send a message to the platform. """ return self.send_message(PLATFORM_DESTINATION_ID, namespace, message, inc_sess...
[ "Helper", "method", "to", "send", "a", "message", "to", "the", "platform", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L721-L725
[ "def", "send_platform_message", "(", "self", ",", "namespace", ",", "message", ",", "inc_session_id", "=", "False", ",", "callback_function_param", "=", "False", ")", ":", "return", "self", ".", "send_message", "(", "PLATFORM_DESTINATION_ID", ",", "namespace", ","...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
SocketClient.send_app_message
Helper method to send a message to current running app.
pychromecast/socket_client.py
def send_app_message(self, namespace, message, inc_session_id=False, callback_function_param=False): """ Helper method to send a message to current running app. """ if namespace not in self.app_namespaces: raise UnsupportedNamespace( ("Namespace {} is...
def send_app_message(self, namespace, message, inc_session_id=False, callback_function_param=False): """ Helper method to send a message to current running app. """ if namespace not in self.app_namespaces: raise UnsupportedNamespace( ("Namespace {} is...
[ "Helper", "method", "to", "send", "a", "message", "to", "current", "running", "app", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L727-L737
[ "def", "send_app_message", "(", "self", ",", "namespace", ",", "message", ",", "inc_session_id", "=", "False", ",", "callback_function_param", "=", "False", ")", ":", "if", "namespace", "not", "in", "self", ".", "app_namespaces", ":", "raise", "UnsupportedNamesp...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
SocketClient._ensure_channel_connected
Ensure we opened a channel to destination_id.
pychromecast/socket_client.py
def _ensure_channel_connected(self, destination_id): """ Ensure we opened a channel to destination_id. """ if destination_id not in self._open_channels: self._open_channels.append(destination_id) self.send_message( destination_id, NS_CONNECTION, {...
def _ensure_channel_connected(self, destination_id): """ Ensure we opened a channel to destination_id. """ if destination_id not in self._open_channels: self._open_channels.append(destination_id) self.send_message( destination_id, NS_CONNECTION, {...
[ "Ensure", "we", "opened", "a", "channel", "to", "destination_id", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L745-L762
[ "def", "_ensure_channel_connected", "(", "self", ",", "destination_id", ")", ":", "if", "destination_id", "not", "in", "self", ".", "_open_channels", ":", "self", ".", "_open_channels", ".", "append", "(", "destination_id", ")", "self", ".", "send_message", "(",...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
SocketClient.disconnect_channel
Disconnect a channel with destination_id.
pychromecast/socket_client.py
def disconnect_channel(self, destination_id): """ Disconnect a channel with destination_id. """ if destination_id in self._open_channels: try: self.send_message( destination_id, NS_CONNECTION, {MESSAGE_TYPE: TYPE_CLOSE, 'origin': {}}, ...
def disconnect_channel(self, destination_id): """ Disconnect a channel with destination_id. """ if destination_id in self._open_channels: try: self.send_message( destination_id, NS_CONNECTION, {MESSAGE_TYPE: TYPE_CLOSE, 'origin': {}}, ...
[ "Disconnect", "a", "channel", "with", "destination_id", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L764-L780
[ "def", "disconnect_channel", "(", "self", ",", "destination_id", ")", ":", "if", "destination_id", "in", "self", ".", "_open_channels", ":", "try", ":", "self", ".", "send_message", "(", "destination_id", ",", "NS_CONNECTION", ",", "{", "MESSAGE_TYPE", ":", "T...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
SocketClient.handle_channel_disconnected
Handles a channel being disconnected.
pychromecast/socket_client.py
def handle_channel_disconnected(self): """ Handles a channel being disconnected. """ for namespace in self.app_namespaces: if namespace in self._handlers: self._handlers[namespace].channel_disconnected() self.app_namespaces = [] self.destination_id = None ...
def handle_channel_disconnected(self): """ Handles a channel being disconnected. """ for namespace in self.app_namespaces: if namespace in self._handlers: self._handlers[namespace].channel_disconnected() self.app_namespaces = [] self.destination_id = None ...
[ "Handles", "a", "channel", "being", "disconnected", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L782-L790
[ "def", "handle_channel_disconnected", "(", "self", ")", ":", "for", "namespace", "in", "self", ".", "app_namespaces", ":", "if", "namespace", "in", "self", ".", "_handlers", ":", "self", ".", "_handlers", "[", "namespace", "]", ".", "channel_disconnected", "("...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
ConnectionController.receive_message
Called when a connection message is received.
pychromecast/socket_client.py
def receive_message(self, message, data): """ Called when a connection message is received. """ if self._socket_client.is_stopped: return True if data[MESSAGE_TYPE] == TYPE_CLOSE: # The cast device is asking us to acknowledge closing this channel. self._socke...
def receive_message(self, message, data): """ Called when a connection message is received. """ if self._socket_client.is_stopped: return True if data[MESSAGE_TYPE] == TYPE_CLOSE: # The cast device is asking us to acknowledge closing this channel. self._socke...
[ "Called", "when", "a", "connection", "message", "is", "received", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L799-L813
[ "def", "receive_message", "(", "self", ",", "message", ",", "data", ")", ":", "if", "self", ".", "_socket_client", ".", "is_stopped", ":", "return", "True", "if", "data", "[", "MESSAGE_TYPE", "]", "==", "TYPE_CLOSE", ":", "# The cast device is asking us to ackno...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
HeartbeatController.receive_message
Called when a heartbeat message is received.
pychromecast/socket_client.py
def receive_message(self, message, data): """ Called when a heartbeat message is received. """ if self._socket_client.is_stopped: return True if data[MESSAGE_TYPE] == TYPE_PING: try: self._socket_client.send_message( PLATFORM_DESTINATI...
def receive_message(self, message, data): """ Called when a heartbeat message is received. """ if self._socket_client.is_stopped: return True if data[MESSAGE_TYPE] == TYPE_PING: try: self._socket_client.send_message( PLATFORM_DESTINATI...
[ "Called", "when", "a", "heartbeat", "message", "is", "received", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L825-L846
[ "def", "receive_message", "(", "self", ",", "message", ",", "data", ")", ":", "if", "self", ".", "_socket_client", ".", "is_stopped", ":", "return", "True", "if", "data", "[", "MESSAGE_TYPE", "]", "==", "TYPE_PING", ":", "try", ":", "self", ".", "_socket...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
HeartbeatController.ping
Send a ping message.
pychromecast/socket_client.py
def ping(self): """ Send a ping message. """ self.last_ping = time.time() try: self.send_message({MESSAGE_TYPE: TYPE_PING}) except NotConnected: self._socket_client.logger.error("Chromecast is disconnected. " + "Cannot ...
def ping(self): """ Send a ping message. """ self.last_ping = time.time() try: self.send_message({MESSAGE_TYPE: TYPE_PING}) except NotConnected: self._socket_client.logger.error("Chromecast is disconnected. " + "Cannot ...
[ "Send", "a", "ping", "message", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L848-L855
[ "def", "ping", "(", "self", ")", ":", "self", ".", "last_ping", "=", "time", ".", "time", "(", ")", "try", ":", "self", ".", "send_message", "(", "{", "MESSAGE_TYPE", ":", "TYPE_PING", "}", ")", "except", "NotConnected", ":", "self", ".", "_socket_clie...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
HeartbeatController.is_expired
Indicates if connection has expired.
pychromecast/socket_client.py
def is_expired(self): """ Indicates if connection has expired. """ if time.time() - self.last_ping > HB_PING_TIME: self.ping() return (time.time() - self.last_pong) > HB_PING_TIME + HB_PONG_TIME
def is_expired(self): """ Indicates if connection has expired. """ if time.time() - self.last_ping > HB_PING_TIME: self.ping() return (time.time() - self.last_pong) > HB_PING_TIME + HB_PONG_TIME
[ "Indicates", "if", "connection", "has", "expired", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L861-L866
[ "def", "is_expired", "(", "self", ")", ":", "if", "time", ".", "time", "(", ")", "-", "self", ".", "last_ping", ">", "HB_PING_TIME", ":", "self", ".", "ping", "(", ")", "return", "(", "time", ".", "time", "(", ")", "-", "self", ".", "last_pong", ...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
ReceiverController.receive_message
Called when a receiver-message has been received.
pychromecast/socket_client.py
def receive_message(self, message, data): """ Called when a receiver-message has been received. """ if data[MESSAGE_TYPE] == TYPE_RECEIVER_STATUS: self._process_get_status(data) return True elif data[MESSAGE_TYPE] == TYPE_LAUNCH_ERROR: self._process_launch_e...
def receive_message(self, message, data): """ Called when a receiver-message has been received. """ if data[MESSAGE_TYPE] == TYPE_RECEIVER_STATUS: self._process_get_status(data) return True elif data[MESSAGE_TYPE] == TYPE_LAUNCH_ERROR: self._process_launch_e...
[ "Called", "when", "a", "receiver", "-", "message", "has", "been", "received", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L896-L908
[ "def", "receive_message", "(", "self", ",", "message", ",", "data", ")", ":", "if", "data", "[", "MESSAGE_TYPE", "]", "==", "TYPE_RECEIVER_STATUS", ":", "self", ".", "_process_get_status", "(", "data", ")", "return", "True", "elif", "data", "[", "MESSAGE_TYP...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
ReceiverController.update_status
Sends a message to the Chromecast to update the status.
pychromecast/socket_client.py
def update_status(self, callback_function_param=False): """ Sends a message to the Chromecast to update the status. """ self.logger.debug("Receiver:Updating status") self.send_message({MESSAGE_TYPE: TYPE_GET_STATUS}, callback_function=callback_function_param)
def update_status(self, callback_function_param=False): """ Sends a message to the Chromecast to update the status. """ self.logger.debug("Receiver:Updating status") self.send_message({MESSAGE_TYPE: TYPE_GET_STATUS}, callback_function=callback_function_param)
[ "Sends", "a", "message", "to", "the", "Chromecast", "to", "update", "the", "status", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L922-L926
[ "def", "update_status", "(", "self", ",", "callback_function_param", "=", "False", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"Receiver:Updating status\"", ")", "self", ".", "send_message", "(", "{", "MESSAGE_TYPE", ":", "TYPE_GET_STATUS", "}", ",", ...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
ReceiverController.launch_app
Launches an app on the Chromecast. Will only launch if it is not currently running unless force_launch=True.
pychromecast/socket_client.py
def launch_app(self, app_id, force_launch=False, callback_function=False): """ Launches an app on the Chromecast. Will only launch if it is not currently running unless force_launch=True. """ if not force_launch and self.app_id is None: self.update_status(lambda res...
def launch_app(self, app_id, force_launch=False, callback_function=False): """ Launches an app on the Chromecast. Will only launch if it is not currently running unless force_launch=True. """ if not force_launch and self.app_id is None: self.update_status(lambda res...
[ "Launches", "an", "app", "on", "the", "Chromecast", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L928-L939
[ "def", "launch_app", "(", "self", ",", "app_id", ",", "force_launch", "=", "False", ",", "callback_function", "=", "False", ")", ":", "if", "not", "force_launch", "and", "self", ".", "app_id", "is", "None", ":", "self", ".", "update_status", "(", "lambda",...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
ReceiverController.stop_app
Stops the current running app on the Chromecast.
pychromecast/socket_client.py
def stop_app(self, callback_function_param=False): """ Stops the current running app on the Chromecast. """ self.logger.info("Receiver:Stopping current app '%s'", self.app_id) return self.send_message( {MESSAGE_TYPE: 'STOP'}, inc_session_id=True, callback_function=callbac...
def stop_app(self, callback_function_param=False): """ Stops the current running app on the Chromecast. """ self.logger.info("Receiver:Stopping current app '%s'", self.app_id) return self.send_message( {MESSAGE_TYPE: 'STOP'}, inc_session_id=True, callback_function=callbac...
[ "Stops", "the", "current", "running", "app", "on", "the", "Chromecast", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L969-L974
[ "def", "stop_app", "(", "self", ",", "callback_function_param", "=", "False", ")", ":", "self", ".", "logger", ".", "info", "(", "\"Receiver:Stopping current app '%s'\"", ",", "self", ".", "app_id", ")", "return", "self", ".", "send_message", "(", "{", "MESSAG...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
ReceiverController.set_volume
Allows to set volume. Should be value between 0..1. Returns the new volume.
pychromecast/socket_client.py
def set_volume(self, volume): """ Allows to set volume. Should be value between 0..1. Returns the new volume. """ volume = min(max(0, volume), 1) self.logger.info("Receiver:setting volume to %.1f", volume) self.send_message({MESSAGE_TYPE: 'SET_VOLUME', ...
def set_volume(self, volume): """ Allows to set volume. Should be value between 0..1. Returns the new volume. """ volume = min(max(0, volume), 1) self.logger.info("Receiver:setting volume to %.1f", volume) self.send_message({MESSAGE_TYPE: 'SET_VOLUME', ...
[ "Allows", "to", "set", "volume", ".", "Should", "be", "value", "between", "0", "..", "1", ".", "Returns", "the", "new", "volume", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L976-L985
[ "def", "set_volume", "(", "self", ",", "volume", ")", ":", "volume", "=", "min", "(", "max", "(", "0", ",", "volume", ")", ",", "1", ")", "self", ".", "logger", ".", "info", "(", "\"Receiver:setting volume to %.1f\"", ",", "volume", ")", "self", ".", ...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
ReceiverController._parse_status
Parses a STATUS message and returns a CastStatus object. :type data: dict :param cast_type: Type of Chromecast. :rtype: CastStatus
pychromecast/socket_client.py
def _parse_status(data, cast_type): """ Parses a STATUS message and returns a CastStatus object. :type data: dict :param cast_type: Type of Chromecast. :rtype: CastStatus """ data = data.get('status', {}) volume_data = data.get('volume', {}) try...
def _parse_status(data, cast_type): """ Parses a STATUS message and returns a CastStatus object. :type data: dict :param cast_type: Type of Chromecast. :rtype: CastStatus """ data = data.get('status', {}) volume_data = data.get('volume', {}) try...
[ "Parses", "a", "STATUS", "message", "and", "returns", "a", "CastStatus", "object", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L994-L1025
[ "def", "_parse_status", "(", "data", ",", "cast_type", ")", ":", "data", "=", "data", ".", "get", "(", "'status'", ",", "{", "}", ")", "volume_data", "=", "data", ".", "get", "(", "'volume'", ",", "{", "}", ")", "try", ":", "app_data", "=", "data",...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
ReceiverController._process_get_status
Processes a received STATUS message and notifies listeners.
pychromecast/socket_client.py
def _process_get_status(self, data): """ Processes a received STATUS message and notifies listeners. """ status = self._parse_status(data, self.cast_type) is_new_app = self.app_id != status.app_id and self.app_to_launch self.status = status self.logger.debug("Received status: %s...
def _process_get_status(self, data): """ Processes a received STATUS message and notifies listeners. """ status = self._parse_status(data, self.cast_type) is_new_app = self.app_id != status.app_id and self.app_to_launch self.status = status self.logger.debug("Received status: %s...
[ "Processes", "a", "received", "STATUS", "message", "and", "notifies", "listeners", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L1027-L1042
[ "def", "_process_get_status", "(", "self", ",", "data", ")", ":", "status", "=", "self", ".", "_parse_status", "(", "data", ",", "self", ".", "cast_type", ")", "is_new_app", "=", "self", ".", "app_id", "!=", "status", ".", "app_id", "and", "self", ".", ...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
ReceiverController._report_status
Reports the current status to all listeners.
pychromecast/socket_client.py
def _report_status(self): """ Reports the current status to all listeners. """ for listener in self._status_listeners: try: listener.new_cast_status(self.status) except Exception: # pylint: disable=broad-except self.logger.exception( ...
def _report_status(self): """ Reports the current status to all listeners. """ for listener in self._status_listeners: try: listener.new_cast_status(self.status) except Exception: # pylint: disable=broad-except self.logger.exception( ...
[ "Reports", "the", "current", "status", "to", "all", "listeners", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L1044-L1051
[ "def", "_report_status", "(", "self", ")", ":", "for", "listener", "in", "self", ".", "_status_listeners", ":", "try", ":", "listener", ".", "new_cast_status", "(", "self", ".", "status", ")", "except", "Exception", ":", "# pylint: disable=broad-except", "self",...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
ReceiverController._parse_launch_error
Parses a LAUNCH_ERROR message and returns a LaunchFailure object. :type data: dict :rtype: LaunchFailure
pychromecast/socket_client.py
def _parse_launch_error(data): """ Parses a LAUNCH_ERROR message and returns a LaunchFailure object. :type data: dict :rtype: LaunchFailure """ return LaunchFailure( data.get(ERROR_REASON, None), data.get(APP_ID), data.get(REQUEST_ID),...
def _parse_launch_error(data): """ Parses a LAUNCH_ERROR message and returns a LaunchFailure object. :type data: dict :rtype: LaunchFailure """ return LaunchFailure( data.get(ERROR_REASON, None), data.get(APP_ID), data.get(REQUEST_ID),...
[ "Parses", "a", "LAUNCH_ERROR", "message", "and", "returns", "a", "LaunchFailure", "object", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L1054-L1065
[ "def", "_parse_launch_error", "(", "data", ")", ":", "return", "LaunchFailure", "(", "data", ".", "get", "(", "ERROR_REASON", ",", "None", ")", ",", "data", ".", "get", "(", "APP_ID", ")", ",", "data", ".", "get", "(", "REQUEST_ID", ")", ",", ")" ]
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
ReceiverController._process_launch_error
Processes a received LAUNCH_ERROR message and notifies listeners.
pychromecast/socket_client.py
def _process_launch_error(self, data): """ Processes a received LAUNCH_ERROR message and notifies listeners. """ launch_failure = self._parse_launch_error(data) self.launch_failure = launch_failure if self.app_to_launch: self.app_to_launch = None ...
def _process_launch_error(self, data): """ Processes a received LAUNCH_ERROR message and notifies listeners. """ launch_failure = self._parse_launch_error(data) self.launch_failure = launch_failure if self.app_to_launch: self.app_to_launch = None ...
[ "Processes", "a", "received", "LAUNCH_ERROR", "message", "and", "notifies", "listeners", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L1067-L1085
[ "def", "_process_launch_error", "(", "self", ",", "data", ")", ":", "launch_failure", "=", "self", ".", "_parse_launch_error", "(", "data", ")", "self", ".", "launch_failure", "=", "launch_failure", "if", "self", ".", "app_to_launch", ":", "self", ".", "app_to...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
ReceiverController.tear_down
Called when controller is destroyed.
pychromecast/socket_client.py
def tear_down(self): """ Called when controller is destroyed. """ super(ReceiverController, self).tear_down() self.status = None self.launch_failure = None self.app_to_launch = None self.app_launch_event.clear() self._status_listeners[:] = []
def tear_down(self): """ Called when controller is destroyed. """ super(ReceiverController, self).tear_down() self.status = None self.launch_failure = None self.app_to_launch = None self.app_launch_event.clear() self._status_listeners[:] = []
[ "Called", "when", "controller", "is", "destroyed", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L1087-L1096
[ "def", "tear_down", "(", "self", ")", ":", "super", "(", "ReceiverController", ",", "self", ")", ".", "tear_down", "(", ")", "self", ".", "status", "=", "None", "self", ".", "launch_failure", "=", "None", "self", ".", "app_to_launch", "=", "None", "self"...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
DashCastController.load_url
Starts loading a URL with an optional reload time in seconds. Setting force to True may load pages which block iframe embedding, but will prevent reload from working and will cause calls to load_url() to reload the app.
pychromecast/controllers/dashcast.py
def load_url(self, url, force=False, reload_seconds=0, callback_function=None): """ Starts loading a URL with an optional reload time in seconds. Setting force to True may load pages which block iframe embedding, but will prevent reload from working and ...
def load_url(self, url, force=False, reload_seconds=0, callback_function=None): """ Starts loading a URL with an optional reload time in seconds. Setting force to True may load pages which block iframe embedding, but will prevent reload from working and ...
[ "Starts", "loading", "a", "URL", "with", "an", "optional", "reload", "time", "in", "seconds", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/dashcast.py#L36-L62
[ "def", "load_url", "(", "self", ",", "url", ",", "force", "=", "False", ",", "reload_seconds", "=", "0", ",", "callback_function", "=", "None", ")", ":", "def", "launch_callback", "(", ")", ":", "\"\"\"Loads requested URL after app launched.\"\"\"", "should_reload...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
_get_status
:param host: Hostname or ip to fetch status from :type host: str :return: The device status as a named tuple. :rtype: pychromecast.dial.DeviceStatus or None
pychromecast/dial.py
def _get_status(host, services, zconf, path): """ :param host: Hostname or ip to fetch status from :type host: str :return: The device status as a named tuple. :rtype: pychromecast.dial.DeviceStatus or None """ if not host: for service in services.copy(): service_info = ...
def _get_status(host, services, zconf, path): """ :param host: Hostname or ip to fetch status from :type host: str :return: The device status as a named tuple. :rtype: pychromecast.dial.DeviceStatus or None """ if not host: for service in services.copy(): service_info = ...
[ ":", "param", "host", ":", "Hostname", "or", "ip", "to", "fetch", "status", "from", ":", "type", "host", ":", "str", ":", "return", ":", "The", "device", "status", "as", "a", "named", "tuple", ".", ":", "rtype", ":", "pychromecast", ".", "dial", ".",...
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/dial.py#L44-L73
[ "def", "_get_status", "(", "host", ",", "services", ",", "zconf", ",", "path", ")", ":", "if", "not", "host", ":", "for", "service", "in", "services", ".", "copy", "(", ")", ":", "service_info", "=", "get_info_from_service", "(", "service", ",", "zconf",...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
get_device_status
:param host: Hostname or ip to fetch status from :type host: str :return: The device status as a named tuple. :rtype: pychromecast.dial.DeviceStatus or None
pychromecast/dial.py
def get_device_status(host, services=None, zconf=None): """ :param host: Hostname or ip to fetch status from :type host: str :return: The device status as a named tuple. :rtype: pychromecast.dial.DeviceStatus or None """ try: status = _get_status( host, services, zconf, ...
def get_device_status(host, services=None, zconf=None): """ :param host: Hostname or ip to fetch status from :type host: str :return: The device status as a named tuple. :rtype: pychromecast.dial.DeviceStatus or None """ try: status = _get_status( host, services, zconf, ...
[ ":", "param", "host", ":", "Hostname", "or", "ip", "to", "fetch", "status", "from", ":", "type", "host", ":", "str", ":", "return", ":", "The", "device", "status", "as", "a", "named", "tuple", ".", ":", "rtype", ":", "pychromecast", ".", "dial", ".",...
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/dial.py#L76-L108
[ "def", "get_device_status", "(", "host", ",", "services", "=", "None", ",", "zconf", "=", "None", ")", ":", "try", ":", "status", "=", "_get_status", "(", "host", ",", "services", ",", "zconf", ",", "\"/setup/eureka_info?options=detail\"", ")", "friendly_name"...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
get_multizone_status
:param host: Hostname or ip to fetch status from :type host: str :return: The multizone status as a named tuple. :rtype: pychromecast.dial.MultizoneStatus or None
pychromecast/dial.py
def get_multizone_status(host, services=None, zconf=None): """ :param host: Hostname or ip to fetch status from :type host: str :return: The multizone status as a named tuple. :rtype: pychromecast.dial.MultizoneStatus or None """ try: status = status = _get_status( host,...
def get_multizone_status(host, services=None, zconf=None): """ :param host: Hostname or ip to fetch status from :type host: str :return: The multizone status as a named tuple. :rtype: pychromecast.dial.MultizoneStatus or None """ try: status = status = _get_status( host,...
[ ":", "param", "host", ":", "Hostname", "or", "ip", "to", "fetch", "status", "from", ":", "type", "host", ":", "str", ":", "return", ":", "The", "multizone", "status", "as", "a", "named", "tuple", ".", ":", "rtype", ":", "pychromecast", ".", "dial", "...
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/dial.py#L111-L146
[ "def", "get_multizone_status", "(", "host", ",", "services", "=", "None", ",", "zconf", "=", "None", ")", ":", "try", ":", "status", "=", "status", "=", "_get_status", "(", "host", ",", "services", ",", "zconf", ",", "\"/setup/eureka_info?params=multizone\"", ...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
YouTubeController.start_session_if_none
Starts a session it is not yet initialized.
pychromecast/controllers/youtube.py
def start_session_if_none(self): """ Starts a session it is not yet initialized. """ if not (self._screen_id and self._session): self.update_screen_id() self._session = YouTubeSession(screen_id=self._screen_id)
def start_session_if_none(self): """ Starts a session it is not yet initialized. """ if not (self._screen_id and self._session): self.update_screen_id() self._session = YouTubeSession(screen_id=self._screen_id)
[ "Starts", "a", "session", "it", "is", "not", "yet", "initialized", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/youtube.py#L29-L35
[ "def", "start_session_if_none", "(", "self", ")", ":", "if", "not", "(", "self", ".", "_screen_id", "and", "self", ".", "_session", ")", ":", "self", ".", "update_screen_id", "(", ")", "self", ".", "_session", "=", "YouTubeSession", "(", "screen_id", "=", ...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
YouTubeController.play_video
Play video(video_id) now. This ignores the current play queue order. :param video_id: YouTube video id(http://youtube.com/watch?v=video_id) :param playlist_id: youtube.com/watch?v=video_id&list=playlist_id
pychromecast/controllers/youtube.py
def play_video(self, video_id, playlist_id=None): """ Play video(video_id) now. This ignores the current play queue order. :param video_id: YouTube video id(http://youtube.com/watch?v=video_id) :param playlist_id: youtube.com/watch?v=video_id&list=playlist_id """ self.sta...
def play_video(self, video_id, playlist_id=None): """ Play video(video_id) now. This ignores the current play queue order. :param video_id: YouTube video id(http://youtube.com/watch?v=video_id) :param playlist_id: youtube.com/watch?v=video_id&list=playlist_id """ self.sta...
[ "Play", "video", "(", "video_id", ")", "now", ".", "This", "ignores", "the", "current", "play", "queue", "order", ".", ":", "param", "video_id", ":", "YouTube", "video", "id", "(", "http", ":", "//", "youtube", ".", "com", "/", "watch?v", "=", "video_i...
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/youtube.py#L37-L44
[ "def", "play_video", "(", "self", ",", "video_id", ",", "playlist_id", "=", "None", ")", ":", "self", ".", "start_session_if_none", "(", ")", "self", ".", "_session", ".", "play_video", "(", "video_id", ",", "playlist_id", ")" ]
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
YouTubeController.update_screen_id
Sends a getMdxSessionStatus to get the screenId and waits for response. This function is blocking If connected we should always get a response (send message will launch app if it is not running).
pychromecast/controllers/youtube.py
def update_screen_id(self): """ Sends a getMdxSessionStatus to get the screenId and waits for response. This function is blocking If connected we should always get a response (send message will launch app if it is not running). """ self.status_update_event.clear()...
def update_screen_id(self): """ Sends a getMdxSessionStatus to get the screenId and waits for response. This function is blocking If connected we should always get a response (send message will launch app if it is not running). """ self.status_update_event.clear()...
[ "Sends", "a", "getMdxSessionStatus", "to", "get", "the", "screenId", "and", "waits", "for", "response", ".", "This", "function", "is", "blocking", "If", "connected", "we", "should", "always", "get", "a", "response", "(", "send", "message", "will", "launch", ...
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/youtube.py#L77-L91
[ "def", "update_screen_id", "(", "self", ")", ":", "self", ".", "status_update_event", ".", "clear", "(", ")", "# This gets the screenId but always throws. Couldn't find a better way.", "try", ":", "self", ".", "send_message", "(", "{", "MESSAGE_TYPE", ":", "TYPE_GET_SCR...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
YouTubeController.receive_message
Called when a media message is received.
pychromecast/controllers/youtube.py
def receive_message(self, message, data): """ Called when a media message is received. """ if data[MESSAGE_TYPE] == TYPE_STATUS: self._process_status(data.get("data")) return True return False
def receive_message(self, message, data): """ Called when a media message is received. """ if data[MESSAGE_TYPE] == TYPE_STATUS: self._process_status(data.get("data")) return True return False
[ "Called", "when", "a", "media", "message", "is", "received", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/youtube.py#L93-L99
[ "def", "receive_message", "(", "self", ",", "message", ",", "data", ")", ":", "if", "data", "[", "MESSAGE_TYPE", "]", "==", "TYPE_STATUS", ":", "self", ".", "_process_status", "(", "data", ".", "get", "(", "\"data\"", ")", ")", "return", "True", "return"...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
YouTubeController._process_status
Process latest status update.
pychromecast/controllers/youtube.py
def _process_status(self, status): """ Process latest status update. """ self._screen_id = status.get(ATTR_SCREEN_ID) self.status_update_event.set()
def _process_status(self, status): """ Process latest status update. """ self._screen_id = status.get(ATTR_SCREEN_ID) self.status_update_event.set()
[ "Process", "latest", "status", "update", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/youtube.py#L101-L104
[ "def", "_process_status", "(", "self", ",", "status", ")", ":", "self", ".", "_screen_id", "=", "status", ".", "get", "(", "ATTR_SCREEN_ID", ")", "self", ".", "status_update_event", ".", "set", "(", ")" ]
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
start_discovery
Start discovering chromecasts on the network. This method will start discovering chromecasts on a separate thread. When a chromecast is discovered, the callback will be called with the discovered chromecast's zeroconf name. This is the dictionary key to find the chromecast metadata in listener.services...
pychromecast/discovery.py
def start_discovery(add_callback=None, remove_callback=None): """ Start discovering chromecasts on the network. This method will start discovering chromecasts on a separate thread. When a chromecast is discovered, the callback will be called with the discovered chromecast's zeroconf name. This is t...
def start_discovery(add_callback=None, remove_callback=None): """ Start discovering chromecasts on the network. This method will start discovering chromecasts on a separate thread. When a chromecast is discovered, the callback will be called with the discovered chromecast's zeroconf name. This is t...
[ "Start", "discovering", "chromecasts", "on", "the", "network", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/discovery.py#L87-L114
[ "def", "start_discovery", "(", "add_callback", "=", "None", ",", "remove_callback", "=", "None", ")", ":", "listener", "=", "CastListener", "(", "add_callback", ",", "remove_callback", ")", "service_browser", "=", "False", "try", ":", "service_browser", "=", "ze...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
discover_chromecasts
Discover chromecasts on the network.
pychromecast/discovery.py
def discover_chromecasts(max_devices=None, timeout=DISCOVER_TIMEOUT): """ Discover chromecasts on the network. """ from threading import Event browser = False try: # pylint: disable=unused-argument def callback(name): """Called when zeroconf has discovered a new chromecast.""...
def discover_chromecasts(max_devices=None, timeout=DISCOVER_TIMEOUT): """ Discover chromecasts on the network. """ from threading import Event browser = False try: # pylint: disable=unused-argument def callback(name): """Called when zeroconf has discovered a new chromecast.""...
[ "Discover", "chromecasts", "on", "the", "network", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/discovery.py#L122-L144
[ "def", "discover_chromecasts", "(", "max_devices", "=", "None", ",", "timeout", "=", "DISCOVER_TIMEOUT", ")", ":", "from", "threading", "import", "Event", "browser", "=", "False", "try", ":", "# pylint: disable=unused-argument", "def", "callback", "(", "name", ")"...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
get_info_from_service
Resolve service_info from service.
pychromecast/discovery.py
def get_info_from_service(service, zconf): """ Resolve service_info from service. """ service_info = None try: service_info = zconf.get_service_info('_googlecast._tcp.local.', service) if service_info: _LOGGER.debug( "...
def get_info_from_service(service, zconf): """ Resolve service_info from service. """ service_info = None try: service_info = zconf.get_service_info('_googlecast._tcp.local.', service) if service_info: _LOGGER.debug( "...
[ "Resolve", "service_info", "from", "service", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/discovery.py#L147-L159
[ "def", "get_info_from_service", "(", "service", ",", "zconf", ")", ":", "service_info", "=", "None", "try", ":", "service_info", "=", "zconf", ".", "get_service_info", "(", "'_googlecast._tcp.local.'", ",", "service", ")", "if", "service_info", ":", "_LOGGER", "...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
get_host_from_service_info
Get hostname or IP from service_info.
pychromecast/discovery.py
def get_host_from_service_info(service_info): """ Get hostname or IP from service_info. """ host = None port = None if (service_info and service_info.port and (service_info.server or service_info.address)): if service_info.address: host = socket.inet_ntoa(service_info.add...
def get_host_from_service_info(service_info): """ Get hostname or IP from service_info. """ host = None port = None if (service_info and service_info.port and (service_info.server or service_info.address)): if service_info.address: host = socket.inet_ntoa(service_info.add...
[ "Get", "hostname", "or", "IP", "from", "service_info", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/discovery.py#L162-L173
[ "def", "get_host_from_service_info", "(", "service_info", ")", ":", "host", "=", "None", "port", "=", "None", "if", "(", "service_info", "and", "service_info", ".", "port", "and", "(", "service_info", ".", "server", "or", "service_info", ".", "address", ")", ...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
CastListener.remove_service
Remove a service from the collection.
pychromecast/discovery.py
def remove_service(self, zconf, typ, name): """ Remove a service from the collection. """ _LOGGER.debug("remove_service %s, %s", typ, name) service = self.services.pop(name, None) if not service: _LOGGER.debug("remove_service unknown %s, %s", typ, name) return ...
def remove_service(self, zconf, typ, name): """ Remove a service from the collection. """ _LOGGER.debug("remove_service %s, %s", typ, name) service = self.services.pop(name, None) if not service: _LOGGER.debug("remove_service unknown %s, %s", typ, name) return ...
[ "Remove", "a", "service", "from", "the", "collection", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/discovery.py#L32-L42
[ "def", "remove_service", "(", "self", ",", "zconf", ",", "typ", ",", "name", ")", ":", "_LOGGER", ".", "debug", "(", "\"remove_service %s, %s\"", ",", "typ", ",", "name", ")", "service", "=", "self", ".", "services", ".", "pop", "(", "name", ",", "None...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
CastListener.add_service
Add a service to the collection.
pychromecast/discovery.py
def add_service(self, zconf, typ, name): """ Add a service to the collection. """ service = None tries = 0 _LOGGER.debug("add_service %s, %s", typ, name) while service is None and tries < 4: try: service = zconf.get_service_info(typ, name) ...
def add_service(self, zconf, typ, name): """ Add a service to the collection. """ service = None tries = 0 _LOGGER.debug("add_service %s, %s", typ, name) while service is None and tries < 4: try: service = zconf.get_service_info(typ, name) ...
[ "Add", "a", "service", "to", "the", "collection", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/discovery.py#L44-L84
[ "def", "add_service", "(", "self", ",", "zconf", ",", "typ", ",", "name", ")", ":", "service", "=", "None", "tries", "=", "0", "_LOGGER", ".", "debug", "(", "\"add_service %s, %s\"", ",", "typ", ",", "name", ")", "while", "service", "is", "None", "and"...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
SpotifyController.receive_message
Currently not doing anything with received messages.
pychromecast/controllers/spotify.py
def receive_message(self, message, data): """ Currently not doing anything with received messages. """ if data['type'] == TYPE_RESPONSE_STATUS: self.is_launched = True return True
def receive_message(self, message, data): """ Currently not doing anything with received messages. """ if data['type'] == TYPE_RESPONSE_STATUS: self.is_launched = True return True
[ "Currently", "not", "doing", "anything", "with", "received", "messages", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/spotify.py#L36-L40
[ "def", "receive_message", "(", "self", ",", "message", ",", "data", ")", ":", "if", "data", "[", "'type'", "]", "==", "TYPE_RESPONSE_STATUS", ":", "self", ".", "is_launched", "=", "True", "return", "True" ]
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
SpotifyController.launch_app
Launch Spotify application. Will raise a LaunchError exception if there is no response from the Spotify app within timeout seconds.
pychromecast/controllers/spotify.py
def launch_app(self, timeout=10): """ Launch Spotify application. Will raise a LaunchError exception if there is no response from the Spotify app within timeout seconds. """ def callback(): """Callback function""" self.send_message({"type": TYPE_...
def launch_app(self, timeout=10): """ Launch Spotify application. Will raise a LaunchError exception if there is no response from the Spotify app within timeout seconds. """ def callback(): """Callback function""" self.send_message({"type": TYPE_...
[ "Launch", "Spotify", "application", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/spotify.py#L42-L65
[ "def", "launch_app", "(", "self", ",", "timeout", "=", "10", ")", ":", "def", "callback", "(", ")", ":", "\"\"\"Callback function\"\"\"", "self", ".", "send_message", "(", "{", "\"type\"", ":", "TYPE_STATUS", ",", "\"credentials\"", ":", "self", ".", "access...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
BaseController.launch
If set, launches app related to the controller.
pychromecast/controllers/__init__.py
def launch(self, callback_function=None): """ If set, launches app related to the controller. """ self._check_registered() self._socket_client.receiver_controller.launch_app( self.supporting_app_id, callback_function=callback_function)
def launch(self, callback_function=None): """ If set, launches app related to the controller. """ self._check_registered() self._socket_client.receiver_controller.launch_app( self.supporting_app_id, callback_function=callback_function)
[ "If", "set", "launches", "app", "related", "to", "the", "controller", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/__init__.py#L39-L44
[ "def", "launch", "(", "self", ",", "callback_function", "=", "None", ")", ":", "self", ".", "_check_registered", "(", ")", "self", ".", "_socket_client", ".", "receiver_controller", ".", "launch_app", "(", "self", ".", "supporting_app_id", ",", "callback_functio...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
BaseController.registered
Called when a controller is registered.
pychromecast/controllers/__init__.py
def registered(self, socket_client): """ Called when a controller is registered. """ self._socket_client = socket_client if self.target_platform: self._message_func = self._socket_client.send_platform_message else: self._message_func = self._socket_client.send_ap...
def registered(self, socket_client): """ Called when a controller is registered. """ self._socket_client = socket_client if self.target_platform: self._message_func = self._socket_client.send_platform_message else: self._message_func = self._socket_client.send_ap...
[ "Called", "when", "a", "controller", "is", "registered", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/__init__.py#L46-L53
[ "def", "registered", "(", "self", ",", "socket_client", ")", ":", "self", ".", "_socket_client", "=", "socket_client", "if", "self", ".", "target_platform", ":", "self", ".", "_message_func", "=", "self", ".", "_socket_client", ".", "send_platform_message", "els...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
BaseController.send_message
Send a message on this namespace to the Chromecast. Will raise a NotConnected exception if not connected.
pychromecast/controllers/__init__.py
def send_message(self, data, inc_session_id=False, callback_function=None): """ Send a message on this namespace to the Chromecast. Will raise a NotConnected exception if not connected. """ self._check_registered() if not self.target_platform and \ ...
def send_message(self, data, inc_session_id=False, callback_function=None): """ Send a message on this namespace to the Chromecast. Will raise a NotConnected exception if not connected. """ self._check_registered() if not self.target_platform and \ ...
[ "Send", "a", "message", "on", "this", "namespace", "to", "the", "Chromecast", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/__init__.py#L64-L84
[ "def", "send_message", "(", "self", ",", "data", ",", "inc_session_id", "=", "False", ",", "callback_function", "=", "None", ")", ":", "self", ".", "_check_registered", "(", ")", "if", "not", "self", ".", "target_platform", "and", "self", ".", "namespace", ...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
MediaStatus.adjusted_current_time
Returns calculated current seek time of media in seconds
pychromecast/controllers/media.py
def adjusted_current_time(self): """ Returns calculated current seek time of media in seconds """ if self.player_state == MEDIA_PLAYER_STATE_PLAYING: # Add time since last update return (self.current_time + (datetime.utcnow() - self.last_updated).total_seconds...
def adjusted_current_time(self): """ Returns calculated current seek time of media in seconds """ if self.player_state == MEDIA_PLAYER_STATE_PLAYING: # Add time since last update return (self.current_time + (datetime.utcnow() - self.last_updated).total_seconds...
[ "Returns", "calculated", "current", "seek", "time", "of", "media", "in", "seconds" ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/media.py#L99-L106
[ "def", "adjusted_current_time", "(", "self", ")", ":", "if", "self", ".", "player_state", "==", "MEDIA_PLAYER_STATE_PLAYING", ":", "# Add time since last update", "return", "(", "self", ".", "current_time", "+", "(", "datetime", ".", "utcnow", "(", ")", "-", "se...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
MediaStatus.images
Return a list of MediaImage objects for this media.
pychromecast/controllers/media.py
def images(self): """ Return a list of MediaImage objects for this media. """ return [ MediaImage(item.get('url'), item.get('height'), item.get('width')) for item in self.media_metadata.get('images', []) ]
def images(self): """ Return a list of MediaImage objects for this media. """ return [ MediaImage(item.get('url'), item.get('height'), item.get('width')) for item in self.media_metadata.get('images', []) ]
[ "Return", "a", "list", "of", "MediaImage", "objects", "for", "this", "media", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/media.py#L205-L210
[ "def", "images", "(", "self", ")", ":", "return", "[", "MediaImage", "(", "item", ".", "get", "(", "'url'", ")", ",", "item", ".", "get", "(", "'height'", ")", ",", "item", ".", "get", "(", "'width'", ")", ")", "for", "item", "in", "self", ".", ...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
MediaStatus.update
New data will only contain the changed attributes.
pychromecast/controllers/media.py
def update(self, data): """ New data will only contain the changed attributes. """ if not data.get('status', []): return status_data = data['status'][0] media_data = status_data.get('media') or {} volume_data = status_data.get('volume', {}) self.current_time...
def update(self, data): """ New data will only contain the changed attributes. """ if not data.get('status', []): return status_data = data['status'][0] media_data = status_data.get('media') or {} volume_data = status_data.get('volume', {}) self.current_time...
[ "New", "data", "will", "only", "contain", "the", "changed", "attributes", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/media.py#L252-L282
[ "def", "update", "(", "self", ",", "data", ")", ":", "if", "not", "data", ".", "get", "(", "'status'", ",", "[", "]", ")", ":", "return", "status_data", "=", "data", "[", "'status'", "]", "[", "0", "]", "media_data", "=", "status_data", ".", "get",...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
MediaController.receive_message
Called when a media message is received.
pychromecast/controllers/media.py
def receive_message(self, message, data): """ Called when a media message is received. """ if data[MESSAGE_TYPE] == TYPE_MEDIA_STATUS: self._process_media_status(data) return True return False
def receive_message(self, message, data): """ Called when a media message is received. """ if data[MESSAGE_TYPE] == TYPE_MEDIA_STATUS: self._process_media_status(data) return True return False
[ "Called", "when", "a", "media", "message", "is", "received", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/media.py#L331-L338
[ "def", "receive_message", "(", "self", ",", "message", ",", "data", ")", ":", "if", "data", "[", "MESSAGE_TYPE", "]", "==", "TYPE_MEDIA_STATUS", ":", "self", ".", "_process_media_status", "(", "data", ")", "return", "True", "return", "False" ]
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
MediaController._send_command
Send a command to the Chromecast on media channel.
pychromecast/controllers/media.py
def _send_command(self, command): """ Send a command to the Chromecast on media channel. """ if self.status is None or self.status.media_session_id is None: self.logger.warning( "%s command requested but no session is active.", command[MESSAGE_TYPE]) ...
def _send_command(self, command): """ Send a command to the Chromecast on media channel. """ if self.status is None or self.status.media_session_id is None: self.logger.warning( "%s command requested but no session is active.", command[MESSAGE_TYPE]) ...
[ "Send", "a", "command", "to", "the", "Chromecast", "on", "media", "channel", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/media.py#L350-L360
[ "def", "_send_command", "(", "self", ",", "command", ")", ":", "if", "self", ".", "status", "is", "None", "or", "self", ".", "status", ".", "media_session_id", "is", "None", ":", "self", ".", "logger", ".", "warning", "(", "\"%s command requested but no sess...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
MediaController.thumbnail
Deprecated as of June 8, 2015. Use self.status.images. Return thumbnail url of current playing item.
pychromecast/controllers/media.py
def thumbnail(self): """ Deprecated as of June 8, 2015. Use self.status.images. Return thumbnail url of current playing item. """ if not self.status: return None images = self.status.images return images[0].url if images else None
def thumbnail(self): """ Deprecated as of June 8, 2015. Use self.status.images. Return thumbnail url of current playing item. """ if not self.status: return None images = self.status.images return images[0].url if images else None
[ "Deprecated", "as", "of", "June", "8", "2015", ".", "Use", "self", ".", "status", ".", "images", ".", "Return", "thumbnail", "url", "of", "current", "playing", "item", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/media.py#L387-L395
[ "def", "thumbnail", "(", "self", ")", ":", "if", "not", "self", ".", "status", ":", "return", "None", "images", "=", "self", ".", "status", ".", "images", "return", "images", "[", "0", "]", ".", "url", "if", "images", "else", "None" ]
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
MediaController._process_media_status
Processes a STATUS message.
pychromecast/controllers/media.py
def _process_media_status(self, data): """ Processes a STATUS message. """ self.status.update(data) self.logger.debug("Media:Received status %s", data) # Update session active threading event if self.status.media_session_id is None: self.session_active_event.clear()...
def _process_media_status(self, data): """ Processes a STATUS message. """ self.status.update(data) self.logger.debug("Media:Received status %s", data) # Update session active threading event if self.status.media_session_id is None: self.session_active_event.clear()...
[ "Processes", "a", "STATUS", "message", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/media.py#L459-L471
[ "def", "_process_media_status", "(", "self", ",", "data", ")", ":", "self", ".", "status", ".", "update", "(", "data", ")", "self", ".", "logger", ".", "debug", "(", "\"Media:Received status %s\"", ",", "data", ")", "# Update session active threading event", "if...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
MediaController._fire_status_changed
Tells listeners of a changed status.
pychromecast/controllers/media.py
def _fire_status_changed(self): """ Tells listeners of a changed status. """ for listener in self._status_listeners: try: listener.new_media_status(self.status) except Exception: # pylint: disable=broad-except _LOGGER.exception("Exception thrown w...
def _fire_status_changed(self): """ Tells listeners of a changed status. """ for listener in self._status_listeners: try: listener.new_media_status(self.status) except Exception: # pylint: disable=broad-except _LOGGER.exception("Exception thrown w...
[ "Tells", "listeners", "of", "a", "changed", "status", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/media.py#L473-L480
[ "def", "_fire_status_changed", "(", "self", ")", ":", "for", "listener", "in", "self", ".", "_status_listeners", ":", "try", ":", "listener", ".", "new_media_status", "(", "self", ".", "status", ")", "except", "Exception", ":", "# pylint: disable=broad-except", ...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
MediaController.play_media
Plays media on the Chromecast. Start default media receiver if not already started. Parameters: url: str - url of the media. content_type: str - mime type. Example: 'video/mp4'. title: str - title of the media. thumb: str - thumbnail image url. current_time: floa...
pychromecast/controllers/media.py
def play_media(self, url, content_type, title=None, thumb=None, current_time=0, autoplay=True, stream_type=STREAM_TYPE_BUFFERED, metadata=None, subtitles=None, subtitles_lang='en-US', subtitles_mime='text/vtt', subtitle_id=1): """ ...
def play_media(self, url, content_type, title=None, thumb=None, current_time=0, autoplay=True, stream_type=STREAM_TYPE_BUFFERED, metadata=None, subtitles=None, subtitles_lang='en-US', subtitles_mime='text/vtt', subtitle_id=1): """ ...
[ "Plays", "media", "on", "the", "Chromecast", ".", "Start", "default", "media", "receiver", "if", "not", "already", "started", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/media.py#L483-L523
[ "def", "play_media", "(", "self", ",", "url", ",", "content_type", ",", "title", "=", "None", ",", "thumb", "=", "None", ",", "current_time", "=", "0", ",", "autoplay", "=", "True", ",", "stream_type", "=", "STREAM_TYPE_BUFFERED", ",", "metadata", "=", "...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
get_possible_app_ids
Returns all possible app ids.
pychromecast/config.py
def get_possible_app_ids(): """ Returns all possible app ids. """ try: req = requests.get( "https://clients3.google.com/cast/chromecast/device/baseconfig") data = json.loads(req.text[4:]) return [app['app_id'] for app in data['applications']] + \ data["enabled_a...
def get_possible_app_ids(): """ Returns all possible app ids. """ try: req = requests.get( "https://clients3.google.com/cast/chromecast/device/baseconfig") data = json.loads(req.text[4:]) return [app['app_id'] for app in data['applications']] + \ data["enabled_a...
[ "Returns", "all", "possible", "app", "ids", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/config.py#L16-L29
[ "def", "get_possible_app_ids", "(", ")", ":", "try", ":", "req", "=", "requests", ".", "get", "(", "\"https://clients3.google.com/cast/chromecast/device/baseconfig\"", ")", "data", "=", "json", ".", "loads", "(", "req", ".", "text", "[", "4", ":", "]", ")", ...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
get_app_config
Get specific configuration for 'app_id'.
pychromecast/config.py
def get_app_config(app_id): """ Get specific configuration for 'app_id'. """ try: req = requests.get( ("https://clients3.google.com/" "cast/chromecast/device/app?a={}").format(app_id)) return json.loads(req.text[4:]) if req.status_code == 200 else {} except ValueEr...
def get_app_config(app_id): """ Get specific configuration for 'app_id'. """ try: req = requests.get( ("https://clients3.google.com/" "cast/chromecast/device/app?a={}").format(app_id)) return json.loads(req.text[4:]) if req.status_code == 200 else {} except ValueEr...
[ "Get", "specific", "configuration", "for", "app_id", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/config.py#L32-L43
[ "def", "get_app_config", "(", "app_id", ")", ":", "try", ":", "req", "=", "requests", ".", "get", "(", "(", "\"https://clients3.google.com/\"", "\"cast/chromecast/device/app?a={}\"", ")", ".", "format", "(", "app_id", ")", ")", "return", "json", ".", "loads", ...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
ArtifactLoader.get_contents
Loads the contents of the file specified by path Args: path (string): The relative or absolute path to the file to be loaded. If the path is relative, then it is combined with the base_path to generate a full path string Returns: string: The con...
ansible_runner/loader.py
def get_contents(self, path): ''' Loads the contents of the file specified by path Args: path (string): The relative or absolute path to the file to be loaded. If the path is relative, then it is combined with the base_path to generate a full path st...
def get_contents(self, path): ''' Loads the contents of the file specified by path Args: path (string): The relative or absolute path to the file to be loaded. If the path is relative, then it is combined with the base_path to generate a full path st...
[ "Loads", "the", "contents", "of", "the", "file", "specified", "by", "path" ]
ansible/ansible-runner
python
https://github.com/ansible/ansible-runner/blob/8ce485480a5d0b602428d9d64a752e06fb46cdb8/ansible_runner/loader.py#L80-L105
[ "def", "get_contents", "(", "self", ",", "path", ")", ":", "try", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "raise", "ConfigurationError", "(", "'specified path does not exist %s'", "%", "path", ")", "with", "open", "(", ...
8ce485480a5d0b602428d9d64a752e06fb46cdb8
train
ArtifactLoader.abspath
Transform the path to an absolute path Args: path (string): The path to transform to an absolute path Returns: string: The absolute path to the file
ansible_runner/loader.py
def abspath(self, path): ''' Transform the path to an absolute path Args: path (string): The path to transform to an absolute path Returns: string: The absolute path to the file ''' if not path.startswith(os.path.sep) or path.startswith('~'): ...
def abspath(self, path): ''' Transform the path to an absolute path Args: path (string): The path to transform to an absolute path Returns: string: The absolute path to the file ''' if not path.startswith(os.path.sep) or path.startswith('~'): ...
[ "Transform", "the", "path", "to", "an", "absolute", "path" ]
ansible/ansible-runner
python
https://github.com/ansible/ansible-runner/blob/8ce485480a5d0b602428d9d64a752e06fb46cdb8/ansible_runner/loader.py#L107-L119
[ "def", "abspath", "(", "self", ",", "path", ")", ":", "if", "not", "path", ".", "startswith", "(", "os", ".", "path", ".", "sep", ")", "or", "path", ".", "startswith", "(", "'~'", ")", ":", "path", "=", "os", ".", "path", ".", "expanduser", "(", ...
8ce485480a5d0b602428d9d64a752e06fb46cdb8
train
ArtifactLoader.load_file
Load the file specified by path This method will first try to load the file contents from cache and if there is a cache miss, it will load the contents from disk Args: path (string): The full or relative path to the file to be loaded encoding (string): The file content...
ansible_runner/loader.py
def load_file(self, path, objtype=None, encoding='utf-8'): ''' Load the file specified by path This method will first try to load the file contents from cache and if there is a cache miss, it will load the contents from disk Args: path (string): The full or relative...
def load_file(self, path, objtype=None, encoding='utf-8'): ''' Load the file specified by path This method will first try to load the file contents from cache and if there is a cache miss, it will load the contents from disk Args: path (string): The full or relative...
[ "Load", "the", "file", "specified", "by", "path" ]
ansible/ansible-runner
python
https://github.com/ansible/ansible-runner/blob/8ce485480a5d0b602428d9d64a752e06fb46cdb8/ansible_runner/loader.py#L132-L184
[ "def", "load_file", "(", "self", ",", "path", ",", "objtype", "=", "None", ",", "encoding", "=", "'utf-8'", ")", ":", "path", "=", "self", ".", "abspath", "(", "path", ")", "debug", "(", "'file path is %s'", "%", "path", ")", "if", "path", "in", "sel...
8ce485480a5d0b602428d9d64a752e06fb46cdb8
train
RunnerConfig.prepare
Performs basic checks and then properly invokes - prepare_inventory - prepare_env - prepare_command It's also responsible for wrapping the command with the proper ssh agent invocation and setting early ANSIBLE_ environment variables.
ansible_runner/runner_config.py
def prepare(self): """ Performs basic checks and then properly invokes - prepare_inventory - prepare_env - prepare_command It's also responsible for wrapping the command with the proper ssh agent invocation and setting early ANSIBLE_ environment variables. ...
def prepare(self): """ Performs basic checks and then properly invokes - prepare_inventory - prepare_env - prepare_command It's also responsible for wrapping the command with the proper ssh agent invocation and setting early ANSIBLE_ environment variables. ...
[ "Performs", "basic", "checks", "and", "then", "properly", "invokes" ]
ansible/ansible-runner
python
https://github.com/ansible/ansible-runner/blob/8ce485480a5d0b602428d9d64a752e06fb46cdb8/ansible_runner/runner_config.py#L127-L197
[ "def", "prepare", "(", "self", ")", ":", "# ansible_path = find_executable('ansible')", "# if ansible_path is None or not os.access(ansible_path, os.X_OK):", "# raise ConfigurationError(\"Ansible not found. Make sure that it is installed.\")", "if", "self", ".", "private_data_dir", "is...
8ce485480a5d0b602428d9d64a752e06fb46cdb8
train
RunnerConfig.prepare_inventory
Prepares the inventory default under ``private_data_dir`` if it's not overridden by the constructor.
ansible_runner/runner_config.py
def prepare_inventory(self): """ Prepares the inventory default under ``private_data_dir`` if it's not overridden by the constructor. """ if self.inventory is None: self.inventory = os.path.join(self.private_data_dir, "inventory")
def prepare_inventory(self): """ Prepares the inventory default under ``private_data_dir`` if it's not overridden by the constructor. """ if self.inventory is None: self.inventory = os.path.join(self.private_data_dir, "inventory")
[ "Prepares", "the", "inventory", "default", "under", "private_data_dir", "if", "it", "s", "not", "overridden", "by", "the", "constructor", "." ]
ansible/ansible-runner
python
https://github.com/ansible/ansible-runner/blob/8ce485480a5d0b602428d9d64a752e06fb46cdb8/ansible_runner/runner_config.py#L199-L204
[ "def", "prepare_inventory", "(", "self", ")", ":", "if", "self", ".", "inventory", "is", "None", ":", "self", ".", "inventory", "=", "os", ".", "path", ".", "join", "(", "self", ".", "private_data_dir", ",", "\"inventory\"", ")" ]
8ce485480a5d0b602428d9d64a752e06fb46cdb8
train
RunnerConfig.prepare_env
Manages reading environment metadata files under ``private_data_dir`` and merging/updating with existing values so the :py:class:`ansible_runner.runner.Runner` object can read and use them easily
ansible_runner/runner_config.py
def prepare_env(self): """ Manages reading environment metadata files under ``private_data_dir`` and merging/updating with existing values so the :py:class:`ansible_runner.runner.Runner` object can read and use them easily """ try: passwords = self.loader.load_file('e...
def prepare_env(self): """ Manages reading environment metadata files under ``private_data_dir`` and merging/updating with existing values so the :py:class:`ansible_runner.runner.Runner` object can read and use them easily """ try: passwords = self.loader.load_file('e...
[ "Manages", "reading", "environment", "metadata", "files", "under", "private_data_dir", "and", "merging", "/", "updating", "with", "existing", "values", "so", "the", ":", "py", ":", "class", ":", "ansible_runner", ".", "runner", ".", "Runner", "object", "can", ...
ansible/ansible-runner
python
https://github.com/ansible/ansible-runner/blob/8ce485480a5d0b602428d9d64a752e06fb46cdb8/ansible_runner/runner_config.py#L206-L276
[ "def", "prepare_env", "(", "self", ")", ":", "try", ":", "passwords", "=", "self", ".", "loader", ".", "load_file", "(", "'env/passwords'", ",", "Mapping", ")", "self", ".", "expect_passwords", "=", "{", "re", ".", "compile", "(", "pattern", ",", "re", ...
8ce485480a5d0b602428d9d64a752e06fb46cdb8
train
RunnerConfig.prepare_command
Determines if the literal ``ansible`` or ``ansible-playbook`` commands are given and if not calls :py:meth:`ansible_runner.runner_config.RunnerConfig.generate_ansible_command`
ansible_runner/runner_config.py
def prepare_command(self): """ Determines if the literal ``ansible`` or ``ansible-playbook`` commands are given and if not calls :py:meth:`ansible_runner.runner_config.RunnerConfig.generate_ansible_command` """ try: cmdline_args = self.loader.load_file('args', string_...
def prepare_command(self): """ Determines if the literal ``ansible`` or ``ansible-playbook`` commands are given and if not calls :py:meth:`ansible_runner.runner_config.RunnerConfig.generate_ansible_command` """ try: cmdline_args = self.loader.load_file('args', string_...
[ "Determines", "if", "the", "literal", "ansible", "or", "ansible", "-", "playbook", "commands", "are", "given", "and", "if", "not", "calls", ":", "py", ":", "meth", ":", "ansible_runner", ".", "runner_config", ".", "RunnerConfig", ".", "generate_ansible_command" ...
ansible/ansible-runner
python
https://github.com/ansible/ansible-runner/blob/8ce485480a5d0b602428d9d64a752e06fb46cdb8/ansible_runner/runner_config.py#L278-L288
[ "def", "prepare_command", "(", "self", ")", ":", "try", ":", "cmdline_args", "=", "self", ".", "loader", ".", "load_file", "(", "'args'", ",", "string_types", ")", "self", ".", "command", "=", "shlex", ".", "split", "(", "cmdline_args", ".", "decode", "(...
8ce485480a5d0b602428d9d64a752e06fb46cdb8
train
RunnerConfig.generate_ansible_command
Given that the ``RunnerConfig`` preparation methods have been run to gather the inputs this method will generate the ``ansible`` or ``ansible-playbook`` command that will be used by the :py:class:`ansible_runner.runner.Runner` object to start the process
ansible_runner/runner_config.py
def generate_ansible_command(self): """ Given that the ``RunnerConfig`` preparation methods have been run to gather the inputs this method will generate the ``ansible`` or ``ansible-playbook`` command that will be used by the :py:class:`ansible_runner.runner.Runner` object to start the p...
def generate_ansible_command(self): """ Given that the ``RunnerConfig`` preparation methods have been run to gather the inputs this method will generate the ``ansible`` or ``ansible-playbook`` command that will be used by the :py:class:`ansible_runner.runner.Runner` object to start the p...
[ "Given", "that", "the", "RunnerConfig", "preparation", "methods", "have", "been", "run", "to", "gather", "the", "inputs", "this", "method", "will", "generate", "the", "ansible", "or", "ansible", "-", "playbook", "command", "that", "will", "be", "used", "by", ...
ansible/ansible-runner
python
https://github.com/ansible/ansible-runner/blob/8ce485480a5d0b602428d9d64a752e06fb46cdb8/ansible_runner/runner_config.py#L290-L365
[ "def", "generate_ansible_command", "(", "self", ")", ":", "if", "self", ".", "binary", "is", "not", "None", ":", "base_command", "=", "self", ".", "binary", "self", ".", "execution_mode", "=", "ExecutionMode", ".", "RAW", "elif", "self", ".", "module", "is...
8ce485480a5d0b602428d9d64a752e06fb46cdb8
train
RunnerConfig.build_process_isolation_temp_dir
Create a temporary directory for process isolation to use.
ansible_runner/runner_config.py
def build_process_isolation_temp_dir(self): ''' Create a temporary directory for process isolation to use. ''' path = tempfile.mkdtemp(prefix='ansible_runner_pi_', dir=self.process_isolation_path) os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) atexit.register(...
def build_process_isolation_temp_dir(self): ''' Create a temporary directory for process isolation to use. ''' path = tempfile.mkdtemp(prefix='ansible_runner_pi_', dir=self.process_isolation_path) os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) atexit.register(...
[ "Create", "a", "temporary", "directory", "for", "process", "isolation", "to", "use", "." ]
ansible/ansible-runner
python
https://github.com/ansible/ansible-runner/blob/8ce485480a5d0b602428d9d64a752e06fb46cdb8/ansible_runner/runner_config.py#L367-L374
[ "def", "build_process_isolation_temp_dir", "(", "self", ")", ":", "path", "=", "tempfile", ".", "mkdtemp", "(", "prefix", "=", "'ansible_runner_pi_'", ",", "dir", "=", "self", ".", "process_isolation_path", ")", "os", ".", "chmod", "(", "path", ",", "stat", ...
8ce485480a5d0b602428d9d64a752e06fb46cdb8
train
RunnerConfig.wrap_args_with_process_isolation
Wrap existing command line with bwrap to restrict access to: - self.process_isolation_path (generally, /tmp) (except for own /tmp files)
ansible_runner/runner_config.py
def wrap_args_with_process_isolation(self, args): ''' Wrap existing command line with bwrap to restrict access to: - self.process_isolation_path (generally, /tmp) (except for own /tmp files) ''' cwd = os.path.realpath(self.cwd) pi_temp_dir = self.build_process_isolation_...
def wrap_args_with_process_isolation(self, args): ''' Wrap existing command line with bwrap to restrict access to: - self.process_isolation_path (generally, /tmp) (except for own /tmp files) ''' cwd = os.path.realpath(self.cwd) pi_temp_dir = self.build_process_isolation_...
[ "Wrap", "existing", "command", "line", "with", "bwrap", "to", "restrict", "access", "to", ":", "-", "self", ".", "process_isolation_path", "(", "generally", "/", "tmp", ")", "(", "except", "for", "own", "/", "tmp", "files", ")" ]
ansible/ansible-runner
python
https://github.com/ansible/ansible-runner/blob/8ce485480a5d0b602428d9d64a752e06fb46cdb8/ansible_runner/runner_config.py#L376-L430
[ "def", "wrap_args_with_process_isolation", "(", "self", ",", "args", ")", ":", "cwd", "=", "os", ".", "path", ".", "realpath", "(", "self", ".", "cwd", ")", "pi_temp_dir", "=", "self", ".", "build_process_isolation_temp_dir", "(", ")", "new_args", "=", "[", ...
8ce485480a5d0b602428d9d64a752e06fb46cdb8
train
RunnerConfig.wrap_args_with_ssh_agent
Given an existing command line and parameterization this will return the same command line wrapped with the necessary calls to ``ssh-agent``
ansible_runner/runner_config.py
def wrap_args_with_ssh_agent(self, args, ssh_key_path, ssh_auth_sock=None, silence_ssh_add=False): """ Given an existing command line and parameterization this will return the same command line wrapped with the necessary calls to ``ssh-agent`` """ if ssh_key_path: ssh...
def wrap_args_with_ssh_agent(self, args, ssh_key_path, ssh_auth_sock=None, silence_ssh_add=False): """ Given an existing command line and parameterization this will return the same command line wrapped with the necessary calls to ``ssh-agent`` """ if ssh_key_path: ssh...
[ "Given", "an", "existing", "command", "line", "and", "parameterization", "this", "will", "return", "the", "same", "command", "line", "wrapped", "with", "the", "necessary", "calls", "to", "ssh", "-", "agent" ]
ansible/ansible-runner
python
https://github.com/ansible/ansible-runner/blob/8ce485480a5d0b602428d9d64a752e06fb46cdb8/ansible_runner/runner_config.py#L432-L448
[ "def", "wrap_args_with_ssh_agent", "(", "self", ",", "args", ",", "ssh_key_path", ",", "ssh_auth_sock", "=", "None", ",", "silence_ssh_add", "=", "False", ")", ":", "if", "ssh_key_path", ":", "ssh_add_command", "=", "args2cmdline", "(", "'ssh-add'", ",", "ssh_ke...
8ce485480a5d0b602428d9d64a752e06fb46cdb8
train
configure
Configures the logging facility This function will setup an initial logging facility for handling display and debug outputs. The default facility will send display messages to stdout and the default debug facility will do nothing. :returns: None
ansible_runner/output.py
def configure(): ''' Configures the logging facility This function will setup an initial logging facility for handling display and debug outputs. The default facility will send display messages to stdout and the default debug facility will do nothing. :returns: None ''' root_logger = ...
def configure(): ''' Configures the logging facility This function will setup an initial logging facility for handling display and debug outputs. The default facility will send display messages to stdout and the default debug facility will do nothing. :returns: None ''' root_logger = ...
[ "Configures", "the", "logging", "facility" ]
ansible/ansible-runner
python
https://github.com/ansible/ansible-runner/blob/8ce485480a5d0b602428d9d64a752e06fb46cdb8/ansible_runner/output.py#L67-L91
[ "def", "configure", "(", ")", ":", "root_logger", "=", "logging", ".", "getLogger", "(", ")", "root_logger", ".", "addHandler", "(", "logging", ".", "NullHandler", "(", ")", ")", "root_logger", ".", "setLevel", "(", "99", ")", "_display_logger", ".", "setL...
8ce485480a5d0b602428d9d64a752e06fb46cdb8
train
Runner.event_callback
Invoked for every Ansible event to collect stdout with the event data and store it for later use
ansible_runner/runner.py
def event_callback(self, event_data): ''' Invoked for every Ansible event to collect stdout with the event data and store it for later use ''' self.last_stdout_update = time.time() job_events_path = os.path.join(self.config.artifact_dir, 'job_events') if not os.pa...
def event_callback(self, event_data): ''' Invoked for every Ansible event to collect stdout with the event data and store it for later use ''' self.last_stdout_update = time.time() job_events_path = os.path.join(self.config.artifact_dir, 'job_events') if not os.pa...
[ "Invoked", "for", "every", "Ansible", "event", "to", "collect", "stdout", "with", "the", "event", "data", "and", "store", "it", "for", "later", "use" ]
ansible/ansible-runner
python
https://github.com/ansible/ansible-runner/blob/8ce485480a5d0b602428d9d64a752e06fb46cdb8/ansible_runner/runner.py#L39-L78
[ "def", "event_callback", "(", "self", ",", "event_data", ")", ":", "self", ".", "last_stdout_update", "=", "time", ".", "time", "(", ")", "job_events_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "config", ".", "artifact_dir", ",", "'job_...
8ce485480a5d0b602428d9d64a752e06fb46cdb8
train
Runner.run
Launch the Ansible task configured in self.config (A RunnerConfig object), returns once the invocation is complete
ansible_runner/runner.py
def run(self): ''' Launch the Ansible task configured in self.config (A RunnerConfig object), returns once the invocation is complete ''' self.status_callback('starting') stdout_filename = os.path.join(self.config.artifact_dir, 'stdout') command_filename = os.path...
def run(self): ''' Launch the Ansible task configured in self.config (A RunnerConfig object), returns once the invocation is complete ''' self.status_callback('starting') stdout_filename = os.path.join(self.config.artifact_dir, 'stdout') command_filename = os.path...
[ "Launch", "the", "Ansible", "task", "configured", "in", "self", ".", "config", "(", "A", "RunnerConfig", "object", ")", "returns", "once", "the", "invocation", "is", "complete" ]
ansible/ansible-runner
python
https://github.com/ansible/ansible-runner/blob/8ce485480a5d0b602428d9d64a752e06fb46cdb8/ansible_runner/runner.py#L88-L228
[ "def", "run", "(", "self", ")", ":", "self", ".", "status_callback", "(", "'starting'", ")", "stdout_filename", "=", "os", ".", "path", ".", "join", "(", "self", ".", "config", ".", "artifact_dir", ",", "'stdout'", ")", "command_filename", "=", "os", "."...
8ce485480a5d0b602428d9d64a752e06fb46cdb8
train
Runner.stdout
Returns an open file handle to the stdout representing the Ansible run
ansible_runner/runner.py
def stdout(self): ''' Returns an open file handle to the stdout representing the Ansible run ''' stdout_path = os.path.join(self.config.artifact_dir, 'stdout') if not os.path.exists(stdout_path): raise AnsibleRunnerException("stdout missing") return open(os.pa...
def stdout(self): ''' Returns an open file handle to the stdout representing the Ansible run ''' stdout_path = os.path.join(self.config.artifact_dir, 'stdout') if not os.path.exists(stdout_path): raise AnsibleRunnerException("stdout missing") return open(os.pa...
[ "Returns", "an", "open", "file", "handle", "to", "the", "stdout", "representing", "the", "Ansible", "run" ]
ansible/ansible-runner
python
https://github.com/ansible/ansible-runner/blob/8ce485480a5d0b602428d9d64a752e06fb46cdb8/ansible_runner/runner.py#L231-L238
[ "def", "stdout", "(", "self", ")", ":", "stdout_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "config", ".", "artifact_dir", ",", "'stdout'", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "stdout_path", ")", ":", "raise", ...
8ce485480a5d0b602428d9d64a752e06fb46cdb8
train
Runner.events
A generator that will return all ansible job events in the order that they were emitted from Ansible Example: { "event":"runner_on_ok", "uuid":"00a50d9c-161a-4b74-b978-9f60becaf209", "stdout":"ok: [localhost] => {\\r\\n \\" msg\\":\\"Test!\\"\\r\\n...
ansible_runner/runner.py
def events(self): ''' A generator that will return all ansible job events in the order that they were emitted from Ansible Example: { "event":"runner_on_ok", "uuid":"00a50d9c-161a-4b74-b978-9f60becaf209", "stdout":"ok: [localhost] => {\\...
def events(self): ''' A generator that will return all ansible job events in the order that they were emitted from Ansible Example: { "event":"runner_on_ok", "uuid":"00a50d9c-161a-4b74-b978-9f60becaf209", "stdout":"ok: [localhost] => {\\...
[ "A", "generator", "that", "will", "return", "all", "ansible", "job", "events", "in", "the", "order", "that", "they", "were", "emitted", "from", "Ansible" ]
ansible/ansible-runner
python
https://github.com/ansible/ansible-runner/blob/8ce485480a5d0b602428d9d64a752e06fb46cdb8/ansible_runner/runner.py#L241-L292
[ "def", "events", "(", "self", ")", ":", "event_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "config", ".", "artifact_dir", ",", "'job_events'", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "event_path", ")", ":", "raise",...
8ce485480a5d0b602428d9d64a752e06fb46cdb8
train
Runner.stats
Returns the final high level stats from the Ansible run Example: {'dark': {}, 'failures': {}, 'skipped': {}, 'ok': {u'localhost': 2}, 'processed': {u'localhost': 1}}
ansible_runner/runner.py
def stats(self): ''' Returns the final high level stats from the Ansible run Example: {'dark': {}, 'failures': {}, 'skipped': {}, 'ok': {u'localhost': 2}, 'processed': {u'localhost': 1}} ''' last_event = list(filter(lambda x: 'event' in x and x['event'] == 'playbook_...
def stats(self): ''' Returns the final high level stats from the Ansible run Example: {'dark': {}, 'failures': {}, 'skipped': {}, 'ok': {u'localhost': 2}, 'processed': {u'localhost': 1}} ''' last_event = list(filter(lambda x: 'event' in x and x['event'] == 'playbook_...
[ "Returns", "the", "final", "high", "level", "stats", "from", "the", "Ansible", "run" ]
ansible/ansible-runner
python
https://github.com/ansible/ansible-runner/blob/8ce485480a5d0b602428d9d64a752e06fb46cdb8/ansible_runner/runner.py#L295-L311
[ "def", "stats", "(", "self", ")", ":", "last_event", "=", "list", "(", "filter", "(", "lambda", "x", ":", "'event'", "in", "x", "and", "x", "[", "'event'", "]", "==", "'playbook_on_stats'", ",", "self", ".", "events", ")", ")", "if", "not", "last_eve...
8ce485480a5d0b602428d9d64a752e06fb46cdb8
train
Runner.host_events
Given a host name, this will return all task events executed on that host
ansible_runner/runner.py
def host_events(self, host): ''' Given a host name, this will return all task events executed on that host ''' all_host_events = filter(lambda x: 'event_data' in x and 'host' in x['event_data'] and x['event_data']['host'] == host, self.events) ret...
def host_events(self, host): ''' Given a host name, this will return all task events executed on that host ''' all_host_events = filter(lambda x: 'event_data' in x and 'host' in x['event_data'] and x['event_data']['host'] == host, self.events) ret...
[ "Given", "a", "host", "name", "this", "will", "return", "all", "task", "events", "executed", "on", "that", "host" ]
ansible/ansible-runner
python
https://github.com/ansible/ansible-runner/blob/8ce485480a5d0b602428d9d64a752e06fb46cdb8/ansible_runner/runner.py#L313-L319
[ "def", "host_events", "(", "self", ",", "host", ")", ":", "all_host_events", "=", "filter", "(", "lambda", "x", ":", "'event_data'", "in", "x", "and", "'host'", "in", "x", "[", "'event_data'", "]", "and", "x", "[", "'event_data'", "]", "[", "'host'", "...
8ce485480a5d0b602428d9d64a752e06fb46cdb8
train
Runner.handle_termination
Internal method to terminate a subprocess spawned by `pexpect` representing an invocation of runner. :param pid: the process id of the running the job. :param is_cancel: flag showing whether this termination is caused by instance's cancel_flag.
ansible_runner/runner.py
def handle_termination(cls, pid, is_cancel=True): ''' Internal method to terminate a subprocess spawned by `pexpect` representing an invocation of runner. :param pid: the process id of the running the job. :param is_cancel: flag showing whether this termination is caused by ...
def handle_termination(cls, pid, is_cancel=True): ''' Internal method to terminate a subprocess spawned by `pexpect` representing an invocation of runner. :param pid: the process id of the running the job. :param is_cancel: flag showing whether this termination is caused by ...
[ "Internal", "method", "to", "terminate", "a", "subprocess", "spawned", "by", "pexpect", "representing", "an", "invocation", "of", "runner", "." ]
ansible/ansible-runner
python
https://github.com/ansible/ansible-runner/blob/8ce485480a5d0b602428d9d64a752e06fb46cdb8/ansible_runner/runner.py#L322-L343
[ "def", "handle_termination", "(", "cls", ",", "pid", ",", "is_cancel", "=", "True", ")", ":", "try", ":", "main_proc", "=", "psutil", ".", "Process", "(", "pid", "=", "pid", ")", "child_procs", "=", "main_proc", ".", "children", "(", "recursive", "=", ...
8ce485480a5d0b602428d9d64a752e06fb46cdb8