Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def media_vol(self, volume):
vol = volume / 100
try:
self.cast.set_volume(vol)
except PyChromecastError:
pass
"""
Errors to be used by PyChromecast.
"""
class PyChromecastError(Exception):
""" Base error for PyChromecast. """
class NoChromecastFoundError(PyChromecastError):
"""
When a command has to auto-discover a Chromecast and cannot find one.
"""
class MultipleChromecastsFoundError(PyChromecastError):
"""
When getting a singular chromecast results in getting multiple chromecasts.
"""
class ChromecastConnectionError(PyChromecastError):
""" When a connection error occurs within PyChromecast. """
class LaunchError(PyChromecastError):
""" When an app fails to launch. """
class PyChromecastStopped(PyChromecastError):
""" Raised when a command is invoked while the Chromecast's socket_client
is stopped.
"""
When a command has to auto-discover a Chromecast and cannot find one.
"""
class MultipleChromecastsFoundError(PyChromecastError):
"""
When getting a singular chromecast results in getting multiple chromecasts.
"""
class ChromecastConnectionError(PyChromecastError):
""" When a connection error occurs within PyChromecast. """
class LaunchError(PyChromecastError):
""" When an app fails to launch. """
class PyChromecastStopped(PyChromecastError):
""" Raised when a command is invoked while the Chromecast's socket_client
is stopped.
"""
class NotConnected(PyChromecastError):
"""
Raised when a command is invoked while not connected to a Chromecast.
"""
"""
Errors to be used by PyChromecast.
"""
class PyChromecastError(Exception):
""" Base error for PyChromecast. """
class NoChromecastFoundError(PyChromecastError):
"""
When a command has to auto-discover a Chromecast and cannot find one.
"""
class MultipleChromecastsFoundError(PyChromecastError):
"""
When getting a singular chromecast results in getting multiple chromecasts.
"""
class ChromecastConnectionError(PyChromecastError):
""" When a connection error occurs within PyChromecast. """
class LaunchError(PyChromecastError):
def poll(self):
''' Helper for `_poll` to handle errors and reconnects. '''
try:
if not self.cast:
click.echo('Reconnecting to cast device `%s`...' % self.cast_name)
self._connect_chromecast()
else:
self._poll()
# This could happen due to network hiccups, Chromecast
# restarting, race conditions, etc...
except (PyChromecastError, pylast.NetworkError):
logger.info('poll(%s) failed', self.cast_name, exc_info=True)
self.cast = None
class ChromecastConnectionError(PyChromecastError):
""" When a connection error occurs within PyChromecast. """
class LaunchError(PyChromecastError):
""" When an app fails to launch. """
class PyChromecastStopped(PyChromecastError):
""" Raised when a command is invoked while the Chromecast's socket_client
is stopped.
"""
class NotConnected(PyChromecastError):
"""
Raised when a command is invoked while not connected to a Chromecast.
"""
class UnsupportedNamespace(PyChromecastError):
"""
Raised when trying to send a message with a namespace that is not
supported by the current running app.
"""
class ControllerNotRegistered(PyChromecastError):
"""
Raised when trying to interact with a controller while it is
""" Base error for PyChromecast. """
class NoChromecastFoundError(PyChromecastError):
"""
When a command has to auto-discover a Chromecast and cannot find one.
"""
class MultipleChromecastsFoundError(PyChromecastError):
"""
When getting a singular chromecast results in getting multiple chromecasts.
"""
class ChromecastConnectionError(PyChromecastError):
""" When a connection error occurs within PyChromecast. """
class LaunchError(PyChromecastError):
""" When an app fails to launch. """
class PyChromecastStopped(PyChromecastError):
""" Raised when a command is invoked while the Chromecast's socket_client
is stopped.
"""
class NotConnected(PyChromecastError):
"""
class MultipleChromecastsFoundError(PyChromecastError):
"""
When getting a singular chromecast results in getting multiple chromecasts.
"""
class ChromecastConnectionError(PyChromecastError):
""" When a connection error occurs within PyChromecast. """
class LaunchError(PyChromecastError):
""" When an app fails to launch. """
class PyChromecastStopped(PyChromecastError):
""" Raised when a command is invoked while the Chromecast's socket_client
is stopped.
"""
class NotConnected(PyChromecastError):
"""
Raised when a command is invoked while not connected to a Chromecast.
"""
class UnsupportedNamespace(PyChromecastError):
"""
Raised when trying to send a message with a namespace that is not
supported by the current running app.
class NotConnected(PyChromecastError):
"""
Raised when a command is invoked while not connected to a Chromecast.
"""
class UnsupportedNamespace(PyChromecastError):
"""
Raised when trying to send a message with a namespace that is not
supported by the current running app.
"""
class ControllerNotRegistered(PyChromecastError):
"""
Raised when trying to interact with a controller while it is
class PyChromecastStopped(PyChromecastError):
""" Raised when a command is invoked while the Chromecast's socket_client
is stopped.
"""
class NotConnected(PyChromecastError):
"""
Raised when a command is invoked while not connected to a Chromecast.
"""
class UnsupportedNamespace(PyChromecastError):
"""
Raised when trying to send a message with a namespace that is not
supported by the current running app.
"""
class ControllerNotRegistered(PyChromecastError):
"""
Raised when trying to interact with a controller while it is