repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
rytilahti/python-songpal
songpal/device.py
Device.set_bluetooth_settings
async def set_bluetooth_settings(self, target: str, value: str) -> None: """Set bluetooth settings.""" params = {"settings": [{"target": target, "value": value}]} return await self.services["avContent"]["setBluetoothSettings"](params)
python
async def set_bluetooth_settings(self, target: str, value: str) -> None: """Set bluetooth settings.""" params = {"settings": [{"target": target, "value": value}]} return await self.services["avContent"]["setBluetoothSettings"](params)
Set bluetooth settings.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L295-L298
rytilahti/python-songpal
songpal/device.py
Device.set_custom_eq
async def set_custom_eq(self, target: str, value: str) -> None: """Set custom EQ settings.""" params = {"settings": [{"target": target, "value": value}]} return await self.services["audio"]["setCustomEqualizerSettings"](params)
python
async def set_custom_eq(self, target: str, value: str) -> None: """Set custom EQ settings.""" params = {"settings": [{"target": target, "value": value}]} return await self.services["audio"]["setCustomEqualizerSettings"](params)
Set custom EQ settings.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L304-L307
rytilahti/python-songpal
songpal/device.py
Device.get_supported_playback_functions
async def get_supported_playback_functions( self, uri="" ) -> List[SupportedFunctions]: """Return list of inputs and their supported functions.""" return [ SupportedFunctions.make(**x) for x in await self.services["avContent"]["getSupportedPlaybackFunction"]( ...
python
async def get_supported_playback_functions( self, uri="" ) -> List[SupportedFunctions]: """Return list of inputs and their supported functions.""" return [ SupportedFunctions.make(**x) for x in await self.services["avContent"]["getSupportedPlaybackFunction"]( ...
Return list of inputs and their supported functions.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L309-L318
rytilahti/python-songpal
songpal/device.py
Device.get_playback_settings
async def get_playback_settings(self) -> List[Setting]: """Get playback settings such as shuffle and repeat.""" return [ Setting.make(**x) for x in await self.services["avContent"]["getPlaybackModeSettings"]({}) ]
python
async def get_playback_settings(self) -> List[Setting]: """Get playback settings such as shuffle and repeat.""" return [ Setting.make(**x) for x in await self.services["avContent"]["getPlaybackModeSettings"]({}) ]
Get playback settings such as shuffle and repeat.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L320-L325
rytilahti/python-songpal
songpal/device.py
Device.set_playback_settings
async def set_playback_settings(self, target, value) -> None: """Set playback settings such a shuffle and repeat.""" params = {"settings": [{"target": target, "value": value}]} return await self.services["avContent"]["setPlaybackModeSettings"](params)
python
async def set_playback_settings(self, target, value) -> None: """Set playback settings such a shuffle and repeat.""" params = {"settings": [{"target": target, "value": value}]} return await self.services["avContent"]["setPlaybackModeSettings"](params)
Set playback settings such a shuffle and repeat.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L327-L330
rytilahti/python-songpal
songpal/device.py
Device.get_schemes
async def get_schemes(self) -> List[Scheme]: """Return supported uri schemes.""" return [ Scheme.make(**x) for x in await self.services["avContent"]["getSchemeList"]() ]
python
async def get_schemes(self) -> List[Scheme]: """Return supported uri schemes.""" return [ Scheme.make(**x) for x in await self.services["avContent"]["getSchemeList"]() ]
Return supported uri schemes.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L332-L337
rytilahti/python-songpal
songpal/device.py
Device.get_source_list
async def get_source_list(self, scheme: str = "") -> List[Source]: """Return available sources for playback.""" res = await self.services["avContent"]["getSourceList"](scheme=scheme) return [Source.make(**x) for x in res]
python
async def get_source_list(self, scheme: str = "") -> List[Source]: """Return available sources for playback.""" res = await self.services["avContent"]["getSourceList"](scheme=scheme) return [Source.make(**x) for x in res]
Return available sources for playback.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L339-L342
rytilahti/python-songpal
songpal/device.py
Device.get_content_count
async def get_content_count(self, source: str): """Return file listing for source.""" params = {"uri": source, "type": None, "target": "all", "view": "flat"} return ContentInfo.make( **await self.services["avContent"]["getContentCount"](params) )
python
async def get_content_count(self, source: str): """Return file listing for source.""" params = {"uri": source, "type": None, "target": "all", "view": "flat"} return ContentInfo.make( **await self.services["avContent"]["getContentCount"](params) )
Return file listing for source.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L344-L349
rytilahti/python-songpal
songpal/device.py
Device.get_contents
async def get_contents(self, uri) -> List[Content]: """Request content listing recursively for the given URI. :param uri: URI for the source. :return: List of Content objects. """ contents = [ Content.make(**x) for x in await self.services["avContent"]["g...
python
async def get_contents(self, uri) -> List[Content]: """Request content listing recursively for the given URI. :param uri: URI for the source. :return: List of Content objects. """ contents = [ Content.make(**x) for x in await self.services["avContent"]["g...
Request content listing recursively for the given URI. :param uri: URI for the source. :return: List of Content objects.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L351-L371
rytilahti/python-songpal
songpal/device.py
Device.get_volume_information
async def get_volume_information(self) -> List[Volume]: """Get the volume information.""" res = await self.services["audio"]["getVolumeInformation"]({}) volume_info = [Volume.make(services=self.services, **x) for x in res] if len(volume_info) < 1: logging.warning("Unable to g...
python
async def get_volume_information(self) -> List[Volume]: """Get the volume information.""" res = await self.services["audio"]["getVolumeInformation"]({}) volume_info = [Volume.make(services=self.services, **x) for x in res] if len(volume_info) < 1: logging.warning("Unable to g...
Get the volume information.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L373-L381
rytilahti/python-songpal
songpal/device.py
Device.get_sound_settings
async def get_sound_settings(self, target="") -> List[Setting]: """Get the current sound settings. :param str target: settings target, defaults to all. """ res = await self.services["audio"]["getSoundSettings"]({"target": target}) return [Setting.make(**x) for x in res]
python
async def get_sound_settings(self, target="") -> List[Setting]: """Get the current sound settings. :param str target: settings target, defaults to all. """ res = await self.services["audio"]["getSoundSettings"]({"target": target}) return [Setting.make(**x) for x in res]
Get the current sound settings. :param str target: settings target, defaults to all.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L383-L389
rytilahti/python-songpal
songpal/device.py
Device.get_soundfield
async def get_soundfield(self) -> List[Setting]: """Get the current sound field settings.""" res = await self.services["audio"]["getSoundSettings"]({"target": "soundField"}) return Setting.make(**res[0])
python
async def get_soundfield(self) -> List[Setting]: """Get the current sound field settings.""" res = await self.services["audio"]["getSoundSettings"]({"target": "soundField"}) return Setting.make(**res[0])
Get the current sound field settings.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L391-L394
rytilahti/python-songpal
songpal/device.py
Device.set_sound_settings
async def set_sound_settings(self, target: str, value: str): """Change a sound setting.""" params = {"settings": [{"target": target, "value": value}]} return await self.services["audio"]["setSoundSettings"](params)
python
async def set_sound_settings(self, target: str, value: str): """Change a sound setting.""" params = {"settings": [{"target": target, "value": value}]} return await self.services["audio"]["setSoundSettings"](params)
Change a sound setting.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L400-L403
rytilahti/python-songpal
songpal/device.py
Device.get_speaker_settings
async def get_speaker_settings(self) -> List[Setting]: """Return speaker settings.""" speaker_settings = await self.services["audio"]["getSpeakerSettings"]({}) return [Setting.make(**x) for x in speaker_settings]
python
async def get_speaker_settings(self) -> List[Setting]: """Return speaker settings.""" speaker_settings = await self.services["audio"]["getSpeakerSettings"]({}) return [Setting.make(**x) for x in speaker_settings]
Return speaker settings.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L405-L408
rytilahti/python-songpal
songpal/device.py
Device.set_speaker_settings
async def set_speaker_settings(self, target: str, value: str): """Set speaker settings.""" params = {"settings": [{"target": target, "value": value}]} return await self.services["audio"]["setSpeakerSettings"](params)
python
async def set_speaker_settings(self, target: str, value: str): """Set speaker settings.""" params = {"settings": [{"target": target, "value": value}]} return await self.services["audio"]["setSpeakerSettings"](params)
Set speaker settings.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L410-L413
rytilahti/python-songpal
songpal/device.py
Device.listen_notifications
async def listen_notifications(self, fallback_callback=None): """Listen for notifications from the device forever. Use :func:on_notification: to register what notifications to listen to. """ tasks = [] async def handle_notification(notification): if type(notificatio...
python
async def listen_notifications(self, fallback_callback=None): """Listen for notifications from the device forever. Use :func:on_notification: to register what notifications to listen to. """ tasks = [] async def handle_notification(notification): if type(notificatio...
Listen for notifications from the device forever. Use :func:on_notification: to register what notifications to listen to.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L438-L469
rytilahti/python-songpal
songpal/device.py
Device.stop_listen_notifications
async def stop_listen_notifications(self): """Stop listening on notifications.""" _LOGGER.debug("Stopping listening for notifications..") for serv in self.services.values(): await serv.stop_listen_notifications() return True
python
async def stop_listen_notifications(self): """Stop listening on notifications.""" _LOGGER.debug("Stopping listening for notifications..") for serv in self.services.values(): await serv.stop_listen_notifications() return True
Stop listening on notifications.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L471-L477
rytilahti/python-songpal
songpal/device.py
Device.get_notifications
async def get_notifications(self) -> List[Notification]: """Get available notifications, which can then be subscribed to. Call :func:activate: to enable notifications, and :func:listen_notifications: to loop forever for notifications. :return: List of Notification objects """ ...
python
async def get_notifications(self) -> List[Notification]: """Get available notifications, which can then be subscribed to. Call :func:activate: to enable notifications, and :func:listen_notifications: to loop forever for notifications. :return: List of Notification objects """ ...
Get available notifications, which can then be subscribed to. Call :func:activate: to enable notifications, and :func:listen_notifications: to loop forever for notifications. :return: List of Notification objects
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L479-L491
rytilahti/python-songpal
songpal/device.py
Device.raw_command
async def raw_command(self, service: str, method: str, params: Any): """Call an arbitrary method with given parameters. This is useful for debugging and trying out commands before implementing them properly. :param service: Service, use list(self.services) to get a list of availables. ...
python
async def raw_command(self, service: str, method: str, params: Any): """Call an arbitrary method with given parameters. This is useful for debugging and trying out commands before implementing them properly. :param service: Service, use list(self.services) to get a list of availables. ...
Call an arbitrary method with given parameters. This is useful for debugging and trying out commands before implementing them properly. :param service: Service, use list(self.services) to get a list of availables. :param method: Method to call. :param params: Parameters as a pyt...
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L493-L504
rytilahti/python-songpal
songpal/group.py
GroupControl.connect
async def connect(self): requester = AiohttpRequester() factory = UpnpFactory(requester) device = await factory.async_create_device(self.url) self.service = device.service('urn:schemas-sony-com:service:Group:1') if not self.service: _LOGGER.error("Unable to find grou...
python
async def connect(self): requester = AiohttpRequester() factory = UpnpFactory(requester) device = await factory.async_create_device(self.url) self.service = device.service('urn:schemas-sony-com:service:Group:1') if not self.service: _LOGGER.error("Unable to find grou...
Available actions INFO:songpal.upnpctl:Action: <UpnpService.Action(X_GetDeviceInfo)> ([]) INFO:songpal.upnpctl:Action: <UpnpService.Action(X_GetState)> ([]) INFO:songpal.upnpctl:Action: <UpnpService.Action(X_GetStateM)> ([]) INFO:songpal.upnpctl:Action: <UpnpService.Action(X_SetGroupNam...
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/group.py#L83-L124
rytilahti/python-songpal
songpal/group.py
GroupControl.call
async def call(self, action, **kwargs): """Make an action call with given kwargs.""" act = self.service.action(action) _LOGGER.info("Calling %s with %s", action, kwargs) res = await act.async_call(**kwargs) _LOGGER.info(" Result: %s" % res) return res
python
async def call(self, action, **kwargs): """Make an action call with given kwargs.""" act = self.service.action(action) _LOGGER.info("Calling %s with %s", action, kwargs) res = await act.async_call(**kwargs) _LOGGER.info(" Result: %s" % res) return res
Make an action call with given kwargs.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/group.py#L125-L133
rytilahti/python-songpal
songpal/group.py
GroupControl.info
async def info(self): """Return device info.""" """ {'MasterCapability': 9, 'TransportPort': 3975} """ act = self.service.action("X_GetDeviceInfo") res = await act.async_call() return res
python
async def info(self): """Return device info.""" """ {'MasterCapability': 9, 'TransportPort': 3975} """ act = self.service.action("X_GetDeviceInfo") res = await act.async_call() return res
Return device info.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/group.py#L136-L143
rytilahti/python-songpal
songpal/group.py
GroupControl.state
async def state(self) -> GroupState: """Return the current group state""" act = self.service.action("X_GetState") res = await act.async_call() return GroupState.make(**res)
python
async def state(self) -> GroupState: """Return the current group state""" act = self.service.action("X_GetState") res = await act.async_call() return GroupState.make(**res)
Return the current group state
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/group.py#L145-L149
rytilahti/python-songpal
songpal/group.py
GroupControl.get_group_memory
async def get_group_memory(self): """Return group memory.""" # Returns an XML with groupMemoryList act = self.service.action("X_GetAllGroupMemory") res = await act.async_call() return res
python
async def get_group_memory(self): """Return group memory.""" # Returns an XML with groupMemoryList act = self.service.action("X_GetAllGroupMemory") res = await act.async_call() return res
Return group memory.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/group.py#L157-L162
rytilahti/python-songpal
songpal/group.py
GroupControl.update_group_memory
async def update_group_memory(self, memory_id, mode, name, slaves, codectype=0x0040, bitrate=0x0003): """Update existing memory? Can be used to create new ones, too?""" act = self.service.action("X_UpdateGroupMemory") res = await act.async_call(MemoryID=memory_id, ...
python
async def update_group_memory(self, memory_id, mode, name, slaves, codectype=0x0040, bitrate=0x0003): """Update existing memory? Can be used to create new ones, too?""" act = self.service.action("X_UpdateGroupMemory") res = await act.async_call(MemoryID=memory_id, ...
Update existing memory? Can be used to create new ones, too?
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/group.py#L164-L174
rytilahti/python-songpal
songpal/group.py
GroupControl.delete_group_memory
async def delete_group_memory(self, memory_id): """Delete group memory.""" act = self.service.action("X_DeleteGroupMemory") res = await act.async_call(MemoryID=memory_id)
python
async def delete_group_memory(self, memory_id): """Delete group memory.""" act = self.service.action("X_DeleteGroupMemory") res = await act.async_call(MemoryID=memory_id)
Delete group memory.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/group.py#L176-L179
rytilahti/python-songpal
songpal/group.py
GroupControl.get_codec
async def get_codec(self): """Get codec settings.""" act = self.service.action("X_GetCodec") res = await act.async_call() return res
python
async def get_codec(self): """Get codec settings.""" act = self.service.action("X_GetCodec") res = await act.async_call() return res
Get codec settings.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/group.py#L181-L185
rytilahti/python-songpal
songpal/group.py
GroupControl.set_codec
async def set_codec(self, codectype=0x0040, bitrate=0x0003): """Set codec settings.""" act = self.service.action("X_SetCodec") res = await act.async_call(CodecType=codectype, CodecBitrate=bitrate) return res
python
async def set_codec(self, codectype=0x0040, bitrate=0x0003): """Set codec settings.""" act = self.service.action("X_SetCodec") res = await act.async_call(CodecType=codectype, CodecBitrate=bitrate) return res
Set codec settings.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/group.py#L187-L191
rytilahti/python-songpal
songpal/group.py
GroupControl.abort
async def abort(self): """Abort current group session.""" state = await self.state() res = await self.call("X_Abort", MasterSessionID=state.MasterSessionID) return res
python
async def abort(self): """Abort current group session.""" state = await self.state() res = await self.call("X_Abort", MasterSessionID=state.MasterSessionID) return res
Abort current group session.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/group.py#L193-L197
rytilahti/python-songpal
songpal/group.py
GroupControl.stop
async def stop(self): """Stop playback?""" state = await self.state() res = await self.call("X_Stop", MasterSessionID=state.MasterSessionID) return res
python
async def stop(self): """Stop playback?""" state = await self.state() res = await self.call("X_Stop", MasterSessionID=state.MasterSessionID) return res
Stop playback?
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/group.py#L199-L203
rytilahti/python-songpal
songpal/group.py
GroupControl.play
async def play(self): """Start playback?""" state = await self.state() res = await self.call("X_Play", MasterSessionID=state.MasterSessionID) return res
python
async def play(self): """Start playback?""" state = await self.state() res = await self.call("X_Play", MasterSessionID=state.MasterSessionID) return res
Start playback?
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/group.py#L205-L209
rytilahti/python-songpal
songpal/group.py
GroupControl.create
async def create(self, name, slaves): """Create a group.""" # NOTE: codectype and codecbitrate were simply chosen from an example.. res = await self.call("X_Start", GroupMode="GROUP", GroupName=name, SlaveList=",".join(slaves), ...
python
async def create(self, name, slaves): """Create a group.""" # NOTE: codectype and codecbitrate were simply chosen from an example.. res = await self.call("X_Start", GroupMode="GROUP", GroupName=name, SlaveList=",".join(slaves), ...
Create a group.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/group.py#L211-L219
rytilahti/python-songpal
songpal/service.py
Service.fetch_signatures
async def fetch_signatures(endpoint, protocol, idgen): """Request available methods for the service.""" async with aiohttp.ClientSession() as session: req = { "method": "getMethodTypes", "params": [''], "version": "1.0", "id": n...
python
async def fetch_signatures(endpoint, protocol, idgen): """Request available methods for the service.""" async with aiohttp.ClientSession() as session: req = { "method": "getMethodTypes", "params": [''], "version": "1.0", "id": n...
Request available methods for the service.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/service.py#L41-L60
rytilahti/python-songpal
songpal/service.py
Service.from_payload
async def from_payload(cls, payload, endpoint, idgen, debug, force_protocol=None): """Create Service object from a payload.""" service_name = payload["service"] if "protocols" not in payload: raise SongpalException( "Unable to find protocols from payload: %s" % paylo...
python
async def from_payload(cls, payload, endpoint, idgen, debug, force_protocol=None): """Create Service object from a payload.""" service_name = payload["service"] if "protocols" not in payload: raise SongpalException( "Unable to find protocols from payload: %s" % paylo...
Create Service object from a payload.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/service.py#L63-L124
rytilahti/python-songpal
songpal/service.py
Service.call_method
async def call_method(self, method, *args, **kwargs): """Call a method (internal). This is an internal implementation, which formats the parameters if necessary and chooses the preferred transport protocol. The return values are JSON objects. Use :func:__call__: provides exter...
python
async def call_method(self, method, *args, **kwargs): """Call a method (internal). This is an internal implementation, which formats the parameters if necessary and chooses the preferred transport protocol. The return values are JSON objects. Use :func:__call__: provides exter...
Call a method (internal). This is an internal implementation, which formats the parameters if necessary and chooses the preferred transport protocol. The return values are JSON objects. Use :func:__call__: provides external API leveraging this.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/service.py#L126-L197
rytilahti/python-songpal
songpal/service.py
Service.wrap_notification
def wrap_notification(self, data): """Convert notification JSON to a notification class.""" if "method" in data: method = data["method"] params = data["params"] change = params[0] if method == "notifyPowerStatus": return PowerChange.make(**...
python
def wrap_notification(self, data): """Convert notification JSON to a notification class.""" if "method" in data: method = data["method"] params = data["params"] change = params[0] if method == "notifyPowerStatus": return PowerChange.make(**...
Convert notification JSON to a notification class.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/service.py#L199-L223
rytilahti/python-songpal
songpal/service.py
Service.listen_all_notifications
async def listen_all_notifications(self, callback): """Enable all exposed notifications. :param callback: Callback to call when a notification is received. """ everything = [noti.asdict() for noti in self.notifications] if len(everything) > 0: await self._methods["sw...
python
async def listen_all_notifications(self, callback): """Enable all exposed notifications. :param callback: Callback to call when a notification is received. """ everything = [noti.asdict() for noti in self.notifications] if len(everything) > 0: await self._methods["sw...
Enable all exposed notifications. :param callback: Callback to call when a notification is received.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/service.py#L266-L277
rytilahti/python-songpal
songpal/service.py
Service.asdict
def asdict(self): """Return dict presentation of this service. Useful for dumping the device information into JSON. """ return { "methods": {m.name: m.asdict() for m in self.methods}, "protocols": self.protocols, "notifications": {n.name: n.asdict() f...
python
def asdict(self): """Return dict presentation of this service. Useful for dumping the device information into JSON. """ return { "methods": {m.name: m.asdict() for m in self.methods}, "protocols": self.protocols, "notifications": {n.name: n.asdict() f...
Return dict presentation of this service. Useful for dumping the device information into JSON.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/service.py#L283-L292
scivision/lowtran
lowtran/scenarios.py
horizrad
def horizrad(infn: Path, outfn: Path, c1: dict) -> xarray.Dataset: """ read CSV, simulate, write, plot """ if infn is not None: infn = Path(infn).expanduser() if infn.suffix == '.h5': TR = xarray.open_dataset(infn) return TR c1.update({'model': 0, # 0: user...
python
def horizrad(infn: Path, outfn: Path, c1: dict) -> xarray.Dataset: """ read CSV, simulate, write, plot """ if infn is not None: infn = Path(infn).expanduser() if infn.suffix == '.h5': TR = xarray.open_dataset(infn) return TR c1.update({'model': 0, # 0: user...
read CSV, simulate, write, plot
https://github.com/scivision/lowtran/blob/9954d859e53437436103f9ab54a7e2602ecaa1b7/lowtran/scenarios.py#L50-L85
scivision/lowtran
lowtran/base.py
nm2lt7
def nm2lt7(short_nm: float, long_nm: float, step_cminv: float = 20) -> Tuple[float, float, float]: """converts wavelength in nm to cm^-1 minimum meaningful step is 20, but 5 is minimum before crashing lowtran short: shortest wavelength e.g. 200 nm long: longest wavelength e.g. 30000 nm step: step s...
python
def nm2lt7(short_nm: float, long_nm: float, step_cminv: float = 20) -> Tuple[float, float, float]: """converts wavelength in nm to cm^-1 minimum meaningful step is 20, but 5 is minimum before crashing lowtran short: shortest wavelength e.g. 200 nm long: longest wavelength e.g. 30000 nm step: step s...
converts wavelength in nm to cm^-1 minimum meaningful step is 20, but 5 is minimum before crashing lowtran short: shortest wavelength e.g. 200 nm long: longest wavelength e.g. 30000 nm step: step size in cm^-1 e.g. 20 output in cm^-1
https://github.com/scivision/lowtran/blob/9954d859e53437436103f9ab54a7e2602ecaa1b7/lowtran/base.py#L12-L27
scivision/lowtran
lowtran/base.py
loopuserdef
def loopuserdef(c1: Dict[str, Any]) -> xarray.DataArray: """ golowtran() is for scalar parameters only (besides vector of wavelength, which Lowtran internally loops over) wmol, p, t must all be vector(s) of same length """ wmol = np.atleast_2d(c1['wmol']) P = np.atleast_1d(c1['p']) T =...
python
def loopuserdef(c1: Dict[str, Any]) -> xarray.DataArray: """ golowtran() is for scalar parameters only (besides vector of wavelength, which Lowtran internally loops over) wmol, p, t must all be vector(s) of same length """ wmol = np.atleast_2d(c1['wmol']) P = np.atleast_1d(c1['p']) T =...
golowtran() is for scalar parameters only (besides vector of wavelength, which Lowtran internally loops over) wmol, p, t must all be vector(s) of same length
https://github.com/scivision/lowtran/blob/9954d859e53437436103f9ab54a7e2602ecaa1b7/lowtran/base.py#L30-L60
scivision/lowtran
lowtran/base.py
loopangle
def loopangle(c1: Dict[str, Any]) -> xarray.Dataset: """ loop over "ANGLE" """ angles = np.atleast_1d(c1['angle']) TR = xarray.Dataset(coords={'wavelength_nm': None, 'angle_deg': angles}) for a in angles: c = c1.copy() c['angle'] = a TR = TR.merge(golowtran(c)) retu...
python
def loopangle(c1: Dict[str, Any]) -> xarray.Dataset: """ loop over "ANGLE" """ angles = np.atleast_1d(c1['angle']) TR = xarray.Dataset(coords={'wavelength_nm': None, 'angle_deg': angles}) for a in angles: c = c1.copy() c['angle'] = a TR = TR.merge(golowtran(c)) retu...
loop over "ANGLE"
https://github.com/scivision/lowtran/blob/9954d859e53437436103f9ab54a7e2602ecaa1b7/lowtran/base.py#L63-L75
scivision/lowtran
lowtran/base.py
golowtran
def golowtran(c1: Dict[str, Any]) -> xarray.Dataset: """directly run Fortran code""" # %% default parameters c1.setdefault('time', None) defp = ('h1', 'h2', 'angle', 'im', 'iseasn', 'ird1', 'range_km', 'zmdl', 'p', 't') for p in defp: c1.setdefault(p, 0) c1.setdefault('wmol', [0]*12) # %% ...
python
def golowtran(c1: Dict[str, Any]) -> xarray.Dataset: """directly run Fortran code""" # %% default parameters c1.setdefault('time', None) defp = ('h1', 'h2', 'angle', 'im', 'iseasn', 'ird1', 'range_km', 'zmdl', 'p', 't') for p in defp: c1.setdefault(p, 0) c1.setdefault('wmol', [0]*12) # %% ...
directly run Fortran code
https://github.com/scivision/lowtran/blob/9954d859e53437436103f9ab54a7e2602ecaa1b7/lowtran/base.py#L78-L121
scivision/lowtran
lowtran/plots.py
plotradtime
def plotradtime(TR: xarray.Dataset, c1: Dict[str, Any], log: bool = False): """ make one plot per time for now. TR: 3-D array: time, wavelength, [transmittance, radiance] radiance is currently single-scatter solar """ for t in TR.time: # for each time plotirrad(TR.sel(time=t), c1, lo...
python
def plotradtime(TR: xarray.Dataset, c1: Dict[str, Any], log: bool = False): """ make one plot per time for now. TR: 3-D array: time, wavelength, [transmittance, radiance] radiance is currently single-scatter solar """ for t in TR.time: # for each time plotirrad(TR.sel(time=t), c1, lo...
make one plot per time for now. TR: 3-D array: time, wavelength, [transmittance, radiance] radiance is currently single-scatter solar
https://github.com/scivision/lowtran/blob/9954d859e53437436103f9ab54a7e2602ecaa1b7/lowtran/plots.py#L90-L100
rytilahti/python-songpal
songpal/method.py
Method.asdict
def asdict(self) -> Dict[str, Union[Dict, Union[str, Dict]]]: """Return a dictionary describing the method. This can be used to dump the information into a JSON file. """ return { "service": self.service.name, **self.signature.serialize(), }
python
def asdict(self) -> Dict[str, Union[Dict, Union[str, Dict]]]: """Return a dictionary describing the method. This can be used to dump the information into a JSON file. """ return { "service": self.service.name, **self.signature.serialize(), }
Return a dictionary describing the method. This can be used to dump the information into a JSON file.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/method.py#L107-L115
rytilahti/python-songpal
songpal/common.py
DeviceError.error
def error(self): """Return user-friendly error message.""" try: errcode = DeviceErrorCode(self.error_code) return "%s (%s): %s" % (errcode.name, errcode.value, self.error_message) except: return "Error %s: %s" % (self.error_code, self.error_message)
python
def error(self): """Return user-friendly error message.""" try: errcode = DeviceErrorCode(self.error_code) return "%s (%s): %s" % (errcode.name, errcode.value, self.error_message) except: return "Error %s: %s" % (self.error_code, self.error_message)
Return user-friendly error message.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/common.py#L29-L35
rytilahti/python-songpal
songpal/main.py
err
def err(msg): """Pretty-print an error.""" click.echo(click.style(msg, fg="red", bold=True))
python
def err(msg): """Pretty-print an error.""" click.echo(click.style(msg, fg="red", bold=True))
Pretty-print an error.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L33-L35
rytilahti/python-songpal
songpal/main.py
coro
def coro(f): """Run a coroutine and handle possible errors for the click cli. Source https://github.com/pallets/click/issues/85#issuecomment-43378930 """ f = asyncio.coroutine(f) def wrapper(*args, **kwargs): loop = asyncio.get_event_loop() try: return loop.run_until_co...
python
def coro(f): """Run a coroutine and handle possible errors for the click cli. Source https://github.com/pallets/click/issues/85#issuecomment-43378930 """ f = asyncio.coroutine(f) def wrapper(*args, **kwargs): loop = asyncio.get_event_loop() try: return loop.run_until_co...
Run a coroutine and handle possible errors for the click cli. Source https://github.com/pallets/click/issues/85#issuecomment-43378930
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L38-L59
rytilahti/python-songpal
songpal/main.py
traverse_settings
async def traverse_settings(dev, module, settings, depth=0): """Print all available settings.""" for setting in settings: if setting.is_directory: print("%s%s (%s)" % (depth * " ", setting.title, module)) return await traverse_settings(dev, module, setting.settings, depth + 2) ...
python
async def traverse_settings(dev, module, settings, depth=0): """Print all available settings.""" for setting in settings: if setting.is_directory: print("%s%s (%s)" % (depth * " ", setting.title, module)) return await traverse_settings(dev, module, setting.settings, depth + 2) ...
Print all available settings.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L62-L73
rytilahti/python-songpal
songpal/main.py
print_settings
def print_settings(settings, depth=0): """Print all available settings of the device.""" # handle the case where a single setting is passed if isinstance(settings, Setting): settings = [settings] for setting in settings: cur = setting.currentValue print( "%s* %s (%s, ...
python
def print_settings(settings, depth=0): """Print all available settings of the device.""" # handle the case where a single setting is passed if isinstance(settings, Setting): settings = [settings] for setting in settings: cur = setting.currentValue print( "%s* %s (%s, ...
Print all available settings of the device.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L76-L102
rytilahti/python-songpal
songpal/main.py
cli
async def cli(ctx, endpoint, debug, websocket, post): """Songpal CLI.""" lvl = logging.INFO if debug: lvl = logging.DEBUG click.echo("Setting debug level to %s" % debug) logging.basicConfig(level=lvl) if ctx.invoked_subcommand == "discover": ctx.obj = {"debug": debug} ...
python
async def cli(ctx, endpoint, debug, websocket, post): """Songpal CLI.""" lvl = logging.INFO if debug: lvl = logging.DEBUG click.echo("Setting debug level to %s" % debug) logging.basicConfig(level=lvl) if ctx.invoked_subcommand == "discover": ctx.obj = {"debug": debug} ...
Songpal CLI.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L115-L147
rytilahti/python-songpal
songpal/main.py
status
async def status(dev: Device): """Display status information.""" power = await dev.get_power() click.echo(click.style("%s" % power, bold=power)) vol = await dev.get_volume_information() click.echo(vol.pop()) play_info = await dev.get_play_info() if not play_info.is_idle: click.echo...
python
async def status(dev: Device): """Display status information.""" power = await dev.get_power() click.echo(click.style("%s" % power, bold=power)) vol = await dev.get_volume_information() click.echo(vol.pop()) play_info = await dev.get_play_info() if not play_info.is_idle: click.echo...
Display status information.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L157-L177
rytilahti/python-songpal
songpal/main.py
discover
async def discover(ctx): """Discover supported devices.""" TIMEOUT = 5 async def print_discovered(dev): pretty_name = "%s - %s" % (dev.name, dev.model_number) click.echo(click.style("\nFound %s" % pretty_name, bold=True)) click.echo("* API version: %s" % dev.version) click....
python
async def discover(ctx): """Discover supported devices.""" TIMEOUT = 5 async def print_discovered(dev): pretty_name = "%s - %s" % (dev.name, dev.model_number) click.echo(click.style("\nFound %s" % pretty_name, bold=True)) click.echo("* API version: %s" % dev.version) click....
Discover supported devices.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L183-L204
rytilahti/python-songpal
songpal/main.py
power
async def power(dev: Device, cmd, target, value): """Turn on and off, control power settings. Accepts commands 'on', 'off', and 'settings'. """ async def try_turn(cmd): state = True if cmd == "on" else False try: return await dev.set_power(state) except SongpalExcept...
python
async def power(dev: Device, cmd, target, value): """Turn on and off, control power settings. Accepts commands 'on', 'off', and 'settings'. """ async def try_turn(cmd): state = True if cmd == "on" else False try: return await dev.set_power(state) except SongpalExcept...
Turn on and off, control power settings. Accepts commands 'on', 'off', and 'settings'.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L213-L237
rytilahti/python-songpal
songpal/main.py
input
async def input(dev: Device, input, output): """Get and change outputs.""" inputs = await dev.get_inputs() if input: click.echo("Activating %s" % input) try: input = next((x for x in inputs if x.title == input)) except StopIteration: click.echo("Unable to find...
python
async def input(dev: Device, input, output): """Get and change outputs.""" inputs = await dev.get_inputs() if input: click.echo("Activating %s" % input) try: input = next((x for x in inputs if x.title == input)) except StopIteration: click.echo("Unable to find...
Get and change outputs.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L245-L271
rytilahti/python-songpal
songpal/main.py
zone
async def zone(dev: Device, zone, activate): """Get and change outputs.""" if zone: zone = await dev.get_zone(zone) click.echo("%s %s" % ("Activating" if activate else "Deactivating", zone)) await zone.activate(activate) else: click.echo("Zones:") for zone in await d...
python
async def zone(dev: Device, zone, activate): """Get and change outputs.""" if zone: zone = await dev.get_zone(zone) click.echo("%s %s" % ("Activating" if activate else "Deactivating", zone)) await zone.activate(activate) else: click.echo("Zones:") for zone in await d...
Get and change outputs.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L279-L291
rytilahti/python-songpal
songpal/main.py
googlecast
async def googlecast(dev: Device, target, value): """Return Googlecast settings.""" if target and value: click.echo("Setting %s = %s" % (target, value)) await dev.set_googlecast_settings(target, value) print_settings(await dev.get_googlecast_settings())
python
async def googlecast(dev: Device, target, value): """Return Googlecast settings.""" if target and value: click.echo("Setting %s = %s" % (target, value)) await dev.set_googlecast_settings(target, value) print_settings(await dev.get_googlecast_settings())
Return Googlecast settings.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L299-L304
rytilahti/python-songpal
songpal/main.py
source
async def source(dev: Device, scheme): """List available sources. If no `scheme` is given, will list sources for all sc hemes. """ if scheme is None: schemes = await dev.get_schemes() schemes = [scheme.scheme for scheme in schemes] # noqa: T484 else: schemes = [scheme] ...
python
async def source(dev: Device, scheme): """List available sources. If no `scheme` is given, will list sources for all sc hemes. """ if scheme is None: schemes = await dev.get_schemes() schemes = [scheme.scheme for scheme in schemes] # noqa: T484 else: schemes = [scheme] ...
List available sources. If no `scheme` is given, will list sources for all sc hemes.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L311-L340
rytilahti/python-songpal
songpal/main.py
volume
async def volume(dev: Device, volume, output): """Get and set the volume settings. Passing 'mute' as new volume will mute the volume, 'unmute' removes it. """ vol = None vol_controls = await dev.get_volume_information() if output is not None: click.echo("Using output: %s" % output) ...
python
async def volume(dev: Device, volume, output): """Get and set the volume settings. Passing 'mute' as new volume will mute the volume, 'unmute' removes it. """ vol = None vol_controls = await dev.get_volume_information() if output is not None: click.echo("Using output: %s" % output) ...
Get and set the volume settings. Passing 'mute' as new volume will mute the volume, 'unmute' removes it.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L348-L383
rytilahti/python-songpal
songpal/main.py
schemes
async def schemes(dev: Device): """Print supported uri schemes.""" schemes = await dev.get_schemes() for scheme in schemes: click.echo(scheme)
python
async def schemes(dev: Device): """Print supported uri schemes.""" schemes = await dev.get_schemes() for scheme in schemes: click.echo(scheme)
Print supported uri schemes.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L389-L393
rytilahti/python-songpal
songpal/main.py
check_update
async def check_update(dev: Device, internet: bool, update: bool): """Print out update information.""" if internet: print("Checking updates from network") else: print("Not checking updates from internet") update_info = await dev.get_update_info(from_network=internet) if not update_in...
python
async def check_update(dev: Device, internet: bool, update: bool): """Print out update information.""" if internet: print("Checking updates from network") else: print("Not checking updates from internet") update_info = await dev.get_update_info(from_network=internet) if not update_in...
Print out update information.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L401-L417
rytilahti/python-songpal
songpal/main.py
bluetooth
async def bluetooth(dev: Device, target, value): """Get or set bluetooth settings.""" if target and value: await dev.set_bluetooth_settings(target, value) print_settings(await dev.get_bluetooth_settings())
python
async def bluetooth(dev: Device, target, value): """Get or set bluetooth settings.""" if target and value: await dev.set_bluetooth_settings(target, value) print_settings(await dev.get_bluetooth_settings())
Get or set bluetooth settings.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L425-L430
rytilahti/python-songpal
songpal/main.py
sysinfo
async def sysinfo(dev: Device): """Print out system information (version, MAC addrs).""" click.echo(await dev.get_system_info()) click.echo(await dev.get_interface_information())
python
async def sysinfo(dev: Device): """Print out system information (version, MAC addrs).""" click.echo(await dev.get_system_info()) click.echo(await dev.get_interface_information())
Print out system information (version, MAC addrs).
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L436-L439
rytilahti/python-songpal
songpal/main.py
settings
async def settings(dev: Device): """Print out all possible settings.""" settings_tree = await dev.get_settings() for module in settings_tree: await traverse_settings(dev, module.usage, module.settings)
python
async def settings(dev: Device): """Print out all possible settings.""" settings_tree = await dev.get_settings() for module in settings_tree: await traverse_settings(dev, module.usage, module.settings)
Print out all possible settings.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L453-L458
rytilahti/python-songpal
songpal/main.py
storage
async def storage(dev: Device): """Print storage information.""" storages = await dev.get_storage_list() for storage in storages: click.echo(storage)
python
async def storage(dev: Device): """Print storage information.""" storages = await dev.get_storage_list() for storage in storages: click.echo(storage)
Print storage information.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L464-L468
rytilahti/python-songpal
songpal/main.py
sound
async def sound(dev: Device, target, value): """Get or set sound settings.""" if target and value: click.echo("Setting %s to %s" % (target, value)) click.echo(await dev.set_sound_settings(target, value)) print_settings(await dev.get_sound_settings())
python
async def sound(dev: Device, target, value): """Get or set sound settings.""" if target and value: click.echo("Setting %s to %s" % (target, value)) click.echo(await dev.set_sound_settings(target, value)) print_settings(await dev.get_sound_settings())
Get or set sound settings.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L476-L482
rytilahti/python-songpal
songpal/main.py
soundfield
async def soundfield(dev: Device, soundfield: str): """Get or set sound field.""" if soundfield is not None: await dev.set_sound_settings("soundField", soundfield) soundfields = await dev.get_sound_settings("soundField") print_settings(soundfields)
python
async def soundfield(dev: Device, soundfield: str): """Get or set sound field.""" if soundfield is not None: await dev.set_sound_settings("soundField", soundfield) soundfields = await dev.get_sound_settings("soundField") print_settings(soundfields)
Get or set sound field.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L489-L494
rytilahti/python-songpal
songpal/main.py
playback
async def playback(dev: Device, cmd, target, value): """Get and set playback settings, e.g. repeat and shuffle..""" if target and value: dev.set_playback_settings(target, value) if cmd == "support": click.echo("Supported playback functions:") supported = await dev.get_supported_playb...
python
async def playback(dev: Device, cmd, target, value): """Get and set playback settings, e.g. repeat and shuffle..""" if target and value: dev.set_playback_settings(target, value) if cmd == "support": click.echo("Supported playback functions:") supported = await dev.get_supported_playb...
Get and set playback settings, e.g. repeat and shuffle..
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L511-L526
rytilahti/python-songpal
songpal/main.py
speaker
async def speaker(dev: Device, target, value): """Get and set external speaker settings.""" if target and value: click.echo("Setting %s to %s" % (target, value)) await dev.set_speaker_settings(target, value) print_settings(await dev.get_speaker_settings())
python
async def speaker(dev: Device, target, value): """Get and set external speaker settings.""" if target and value: click.echo("Setting %s to %s" % (target, value)) await dev.set_speaker_settings(target, value) print_settings(await dev.get_speaker_settings())
Get and set external speaker settings.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L534-L540
rytilahti/python-songpal
songpal/main.py
notifications
async def notifications(dev: Device, notification: str, listen_all: bool): """List available notifications and listen to them. Using --listen-all [notification] allows to listen to all notifications from the given subsystem. If the subsystem is omited, notifications from all subsystems are request...
python
async def notifications(dev: Device, notification: str, listen_all: bool): """List available notifications and listen to them. Using --listen-all [notification] allows to listen to all notifications from the given subsystem. If the subsystem is omited, notifications from all subsystems are request...
List available notifications and listen to them. Using --listen-all [notification] allows to listen to all notifications from the given subsystem. If the subsystem is omited, notifications from all subsystems are requested.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L548-L581
rytilahti/python-songpal
songpal/main.py
list_all
def list_all(dev: Device): """List all available API calls.""" for name, service in dev.services.items(): click.echo(click.style("\nService %s" % name, bold=True)) for method in service.methods: click.echo(" %s" % method.name)
python
def list_all(dev: Device): """List all available API calls.""" for name, service in dev.services.items(): click.echo(click.style("\nService %s" % name, bold=True)) for method in service.methods: click.echo(" %s" % method.name)
List all available API calls.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L594-L599
rytilahti/python-songpal
songpal/main.py
command
async def command(dev, service, method, parameters): """Run a raw command.""" params = None if parameters is not None: params = ast.literal_eval(parameters) click.echo("Calling %s.%s with params %s" % (service, method, params)) res = await dev.raw_command(service, method, params) click.e...
python
async def command(dev, service, method, parameters): """Run a raw command.""" params = None if parameters is not None: params = ast.literal_eval(parameters) click.echo("Calling %s.%s with params %s" % (service, method, params)) res = await dev.raw_command(service, method, params) click.e...
Run a raw command.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L608-L615
rytilahti/python-songpal
songpal/main.py
dump_devinfo
async def dump_devinfo(dev: Device, file): """Dump developer information. Pass `file` to write the results directly into a file. """ import attr methods = await dev.get_supported_methods() res = { "supported_methods": {k: v.asdict() for k, v in methods.items()}, "settings": [at...
python
async def dump_devinfo(dev: Device, file): """Dump developer information. Pass `file` to write the results directly into a file. """ import attr methods = await dev.get_supported_methods() res = { "supported_methods": {k: v.asdict() for k, v in methods.items()}, "settings": [at...
Dump developer information. Pass `file` to write the results directly into a file.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L622-L640
rytilahti/python-songpal
songpal/main.py
state
async def state(gc: GroupControl): """Current group state.""" state = await gc.state() click.echo(state) click.echo("Full state info: %s" % repr(state))
python
async def state(gc: GroupControl): """Current group state.""" state = await gc.state() click.echo(state) click.echo("Full state info: %s" % repr(state))
Current group state.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L667-L671
rytilahti/python-songpal
songpal/main.py
create
async def create(gc: GroupControl, name, slaves): """Create new group""" click.echo("Creating group %s with slaves: %s" % (name, slaves)) click.echo(await gc.create(name, slaves))
python
async def create(gc: GroupControl, name, slaves): """Create new group""" click.echo("Creating group %s with slaves: %s" % (name, slaves)) click.echo(await gc.create(name, slaves))
Create new group
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L697-L700
rytilahti/python-songpal
songpal/main.py
add
async def add(gc: GroupControl, slaves): """Add speakers to group.""" click.echo("Adding to existing group: %s" % slaves) click.echo(await gc.add(slaves))
python
async def add(gc: GroupControl, slaves): """Add speakers to group.""" click.echo("Adding to existing group: %s" % slaves) click.echo(await gc.add(slaves))
Add speakers to group.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L715-L718
rytilahti/python-songpal
songpal/main.py
remove
async def remove(gc: GroupControl, slaves): """Remove speakers from group.""" click.echo("Removing from existing group: %s" % slaves) click.echo(await gc.remove(slaves))
python
async def remove(gc: GroupControl, slaves): """Remove speakers from group.""" click.echo("Removing from existing group: %s" % slaves) click.echo(await gc.remove(slaves))
Remove speakers from group.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L724-L727
rytilahti/python-songpal
songpal/main.py
volume
async def volume(gc: GroupControl, volume): """Adjust volume [-100, 100]""" click.echo("Setting volume to %s" % volume) click.echo(await gc.set_group_volume(volume))
python
async def volume(gc: GroupControl, volume): """Adjust volume [-100, 100]""" click.echo("Setting volume to %s" % volume) click.echo(await gc.set_group_volume(volume))
Adjust volume [-100, 100]
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L733-L736
rytilahti/python-songpal
songpal/main.py
mute
async def mute(gc: GroupControl, mute): """(Un)mute group.""" click.echo("Muting group: %s" % mute) click.echo(await gc.set_mute(mute))
python
async def mute(gc: GroupControl, mute): """(Un)mute group.""" click.echo("Muting group: %s" % mute) click.echo(await gc.set_mute(mute))
(Un)mute group.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L742-L745
rytilahti/python-songpal
songpal/discovery.py
Discover.discover
async def discover(timeout, debug=0, callback=None): """Discover supported devices.""" ST = "urn:schemas-sony-com:service:ScalarWebAPI:1" _LOGGER.info("Discovering for %s seconds" % timeout) from async_upnp_client import UpnpFactory from async_upnp_client.aiohttp import AiohttpR...
python
async def discover(timeout, debug=0, callback=None): """Discover supported devices.""" ST = "urn:schemas-sony-com:service:ScalarWebAPI:1" _LOGGER.info("Discovering for %s seconds" % timeout) from async_upnp_client import UpnpFactory from async_upnp_client.aiohttp import AiohttpR...
Discover supported devices.
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/discovery.py#L21-L68
kanboard/python-api-client
kanboard/client.py
Kanboard.execute
def execute(self, method, **kwargs): """ Call remote API procedure Args: method: Procedure name kwargs: Procedure named arguments Returns: Procedure result Raises: urllib2.HTTPError: Any HTTP error (Python 2) urllib.e...
python
def execute(self, method, **kwargs): """ Call remote API procedure Args: method: Procedure name kwargs: Procedure named arguments Returns: Procedure result Raises: urllib2.HTTPError: Any HTTP error (Python 2) urllib.e...
Call remote API procedure Args: method: Procedure name kwargs: Procedure named arguments Returns: Procedure result Raises: urllib2.HTTPError: Any HTTP error (Python 2) urllib.error.HTTPError: Any HTTP error (Python 3)
https://github.com/kanboard/python-api-client/blob/a1e81094bb399a9a3f4f14de67406e1d2bbee393/kanboard/client.py#L106-L135
bwesterb/py-tarjan
src/tc.py
tc
def tc(g): """ Given a graph @g, returns the transitive closure of @g """ ret = {} for scc in tarjan(g): ws = set() ews = set() for v in scc: ws.update(g[v]) for w in ws: assert w in r...
python
def tc(g): """ Given a graph @g, returns the transitive closure of @g """ ret = {} for scc in tarjan(g): ws = set() ews = set() for v in scc: ws.update(g[v]) for w in ws: assert w in r...
Given a graph @g, returns the transitive closure of @g
https://github.com/bwesterb/py-tarjan/blob/60b0e3a1a7b925514fdce2ffbd84e1e246aba6d8/src/tc.py#L3-L20
manolomartinez/greg
greg/classes.py
Session.list_feeds
def list_feeds(self): """ Output a list of all feed names """ feeds = configparser.ConfigParser() feeds.read(self.data_filename) return feeds.sections()
python
def list_feeds(self): """ Output a list of all feed names """ feeds = configparser.ConfigParser() feeds.read(self.data_filename) return feeds.sections()
Output a list of all feed names
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/classes.py#L52-L58
manolomartinez/greg
greg/classes.py
Session.retrieve_config_file
def retrieve_config_file(self): """ Retrieve config file """ try: if self.args["configfile"]: return self.args["configfile"] except KeyError: pass return os.path.expanduser('~/.config/greg/greg.conf')
python
def retrieve_config_file(self): """ Retrieve config file """ try: if self.args["configfile"]: return self.args["configfile"] except KeyError: pass return os.path.expanduser('~/.config/greg/greg.conf')
Retrieve config file
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/classes.py#L60-L69
manolomartinez/greg
greg/classes.py
Session.retrieve_data_directory
def retrieve_data_directory(self): """ Retrieve the data directory Look first into config_filename_global then into config_filename_user. The latter takes preeminence. """ args = self.args try: if args['datadirectory']: aux.ensure_dir(a...
python
def retrieve_data_directory(self): """ Retrieve the data directory Look first into config_filename_global then into config_filename_user. The latter takes preeminence. """ args = self.args try: if args['datadirectory']: aux.ensure_dir(a...
Retrieve the data directory Look first into config_filename_global then into config_filename_user. The latter takes preeminence.
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/classes.py#L71-L91
manolomartinez/greg
greg/classes.py
Feed.retrieve_config
def retrieve_config(self, value, default): """ Retrieves a value (with a certain fallback) from the config files (looks first into config_filename_global then into config_filename_user. The latest takes preeminence) if the command line flag for the value is used, that overrides e...
python
def retrieve_config(self, value, default): """ Retrieves a value (with a certain fallback) from the config files (looks first into config_filename_global then into config_filename_user. The latest takes preeminence) if the command line flag for the value is used, that overrides e...
Retrieves a value (with a certain fallback) from the config files (looks first into config_filename_global then into config_filename_user. The latest takes preeminence) if the command line flag for the value is used, that overrides everything else
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/classes.py#L119-L136
manolomartinez/greg
greg/classes.py
Feed.retrieve_download_path
def retrieve_download_path(self): """ Retrieves the download path (looks first into config_filename_global then into the [DEFAULT], then the [feed], section of config_filename_user. The latest takes preeminence) """ section = self.name if self.config.has_section( ...
python
def retrieve_download_path(self): """ Retrieves the download path (looks first into config_filename_global then into the [DEFAULT], then the [feed], section of config_filename_user. The latest takes preeminence) """ section = self.name if self.config.has_section( ...
Retrieves the download path (looks first into config_filename_global then into the [DEFAULT], then the [feed], section of config_filename_user. The latest takes preeminence)
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/classes.py#L146-L158
manolomartinez/greg
greg/classes.py
Feed.will_tag
def will_tag(self): """ Check whether the feed should be tagged """ wanttags = self.retrieve_config('Tag', 'no') if wanttags == 'yes': if aux.staggerexists: willtag = True else: willtag = False print(("You wa...
python
def will_tag(self): """ Check whether the feed should be tagged """ wanttags = self.retrieve_config('Tag', 'no') if wanttags == 'yes': if aux.staggerexists: willtag = True else: willtag = False print(("You wa...
Check whether the feed should be tagged
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/classes.py#L202-L217
manolomartinez/greg
greg/classes.py
Feed.how_many
def how_many(self): """ Ascertain where to start downloading, and how many entries. """ if self.linkdates != []: # What follows is a quick sanity check: if the entry date is in the # future, this is probably a mistake, and we just count the entry # dat...
python
def how_many(self): """ Ascertain where to start downloading, and how many entries. """ if self.linkdates != []: # What follows is a quick sanity check: if the entry date is in the # future, this is probably a mistake, and we just count the entry # dat...
Ascertain where to start downloading, and how many entries.
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/classes.py#L219-L243
manolomartinez/greg
greg/classes.py
Feed.fix_linkdate
def fix_linkdate(self, entry): """ Give a date for the entry, depending on feed.sync_by_date Save it as feed.linkdate """ if self.sync_by_date: try: entry.linkdate = list(entry.published_parsed) self.linkdate = list(entry.published_pars...
python
def fix_linkdate(self, entry): """ Give a date for the entry, depending on feed.sync_by_date Save it as feed.linkdate """ if self.sync_by_date: try: entry.linkdate = list(entry.published_parsed) self.linkdate = list(entry.published_pars...
Give a date for the entry, depending on feed.sync_by_date Save it as feed.linkdate
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/classes.py#L245-L265
manolomartinez/greg
greg/classes.py
Feed.retrieve_mime
def retrieve_mime(self): """ Check the mime-type to download """ mime = self.retrieve_config('mime', 'audio') mimedict = {"number": mime} # the input that parse_for_download expects return aux.parse_for_download(mimedict)
python
def retrieve_mime(self): """ Check the mime-type to download """ mime = self.retrieve_config('mime', 'audio') mimedict = {"number": mime} # the input that parse_for_download expects return aux.parse_for_download(mimedict)
Check the mime-type to download
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/classes.py#L267-L274
manolomartinez/greg
greg/classes.py
Feed.download_entry
def download_entry(self, entry): """ Find entry link and download entry """ downloadlinks = {} downloaded = False ignoreenclosures = self.retrieve_config('ignoreenclosures', 'no') notype = self.retrieve_config('notype', 'no') if ignoreenclosures == 'no': ...
python
def download_entry(self, entry): """ Find entry link and download entry """ downloadlinks = {} downloaded = False ignoreenclosures = self.retrieve_config('ignoreenclosures', 'no') notype = self.retrieve_config('notype', 'no') if ignoreenclosures == 'no': ...
Find entry link and download entry
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/classes.py#L276-L345
manolomartinez/greg
greg/parser.py
main
def main(): """ Parse the args and call whatever function was selected """ args = parser.parse_args() try: function = args.func except AttributeError: parser.print_usage() parser.exit(1) function(vars(args))
python
def main(): """ Parse the args and call whatever function was selected """ args = parser.parse_args() try: function = args.func except AttributeError: parser.print_usage() parser.exit(1) function(vars(args))
Parse the args and call whatever function was selected
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/parser.py#L128-L138
manolomartinez/greg
greg/commands.py
add
def add(args): """ Add a new feed """ session = c.Session(args) if args["name"] in session.feeds.sections(): sys.exit("You already have a feed with that name.") if args["name"] in ["all", "DEFAULT"]: sys.exit( ("greg uses ""{}"" for a special purpose." "P...
python
def add(args): """ Add a new feed """ session = c.Session(args) if args["name"] in session.feeds.sections(): sys.exit("You already have a feed with that name.") if args["name"] in ["all", "DEFAULT"]: sys.exit( ("greg uses ""{}"" for a special purpose." "P...
Add a new feed
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/commands.py#L35-L52
manolomartinez/greg
greg/commands.py
remove
def remove(args): """ Remove the feed given in <args> """ session = c.Session(args) if not args["name"] in session.feeds: sys.exit("You don't have a feed with that name.") inputtext = ("Are you sure you want to remove the {} " " feed? (y/N) ").format(args["name"]) re...
python
def remove(args): """ Remove the feed given in <args> """ session = c.Session(args) if not args["name"] in session.feeds: sys.exit("You don't have a feed with that name.") inputtext = ("Are you sure you want to remove the {} " " feed? (y/N) ").format(args["name"]) re...
Remove the feed given in <args>
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/commands.py#L98-L117
manolomartinez/greg
greg/commands.py
info
def info(args): """ Provide information of a number of feeds """ session = c.Session(args) if "all" in args["names"]: feeds = session.list_feeds() else: feeds = args["names"] for feed in feeds: aux.pretty_print(session, feed)
python
def info(args): """ Provide information of a number of feeds """ session = c.Session(args) if "all" in args["names"]: feeds = session.list_feeds() else: feeds = args["names"] for feed in feeds: aux.pretty_print(session, feed)
Provide information of a number of feeds
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/commands.py#L120-L130
manolomartinez/greg
greg/commands.py
sync
def sync(args): """ Implement the 'greg sync' command """ import operator session = c.Session(args) if "all" in args["names"]: targetfeeds = session.list_feeds() else: targetfeeds = [] for name in args["names"]: if name not in session.feeds: ...
python
def sync(args): """ Implement the 'greg sync' command """ import operator session = c.Session(args) if "all" in args["names"]: targetfeeds = session.list_feeds() else: targetfeeds = [] for name in args["names"]: if name not in session.feeds: ...
Implement the 'greg sync' command
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/commands.py#L140-L184
manolomartinez/greg
greg/commands.py
check
def check(args): """ Implement the 'greg check' command """ session = c.Session(args) if str(args["url"]) != 'None': url = args["url"] name = "DEFAULT" else: try: url = session.feeds[args["feed"]]["url"] name = args["feed"] except KeyError:...
python
def check(args): """ Implement the 'greg check' command """ session = c.Session(args) if str(args["url"]) != 'None': url = args["url"] name = "DEFAULT" else: try: url = session.feeds[args["feed"]]["url"] name = args["feed"] except KeyError:...
Implement the 'greg check' command
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/commands.py#L187-L217
manolomartinez/greg
greg/commands.py
download
def download(args): """ Implement the 'greg download' command """ session = c.Session(args) issues = aux.parse_for_download(args) if issues == ['']: sys.exit( "You need to give a list of issues, of the form ""a, b-c, d...""") dumpfilename = os.path.join(session.data_dir, ...
python
def download(args): """ Implement the 'greg download' command """ session = c.Session(args) issues = aux.parse_for_download(args) if issues == ['']: sys.exit( "You need to give a list of issues, of the form ""a, b-c, d...""") dumpfilename = os.path.join(session.data_dir, ...
Implement the 'greg download' command
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/commands.py#L220-L247
manolomartinez/greg
greg/aux_functions.py
parse_podcast
def parse_podcast(url): """ Try to parse podcast """ try: podcast = feedparser.parse(url) wentwrong = "urlopen" in str(podcast["bozo_exception"]) except KeyError: wentwrong = False if wentwrong: print("Error: ", url, ": ", str(podcast["bozo_exception"])) retur...
python
def parse_podcast(url): """ Try to parse podcast """ try: podcast = feedparser.parse(url) wentwrong = "urlopen" in str(podcast["bozo_exception"]) except KeyError: wentwrong = False if wentwrong: print("Error: ", url, ": ", str(podcast["bozo_exception"])) retur...
Try to parse podcast
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/aux_functions.py#L93-L104