Initial Configuration Push

This commit is contained in:
CCOSTAN
2016-10-11 16:42:06 +00:00
parent b83eeadfcb
commit 5127bc2109
2145 changed files with 298464 additions and 0 deletions

11
deps/netdisco/discoverables/DLNA.py vendored Normal file
View File

@@ -0,0 +1,11 @@
"""Discover DLNA services."""
from . import SSDPDiscoverable
# pylint: disable=too-few-public-methods
class Discoverable(SSDPDiscoverable):
"""Add support for discovering DLNA services."""
def get_entries(self):
"""Get all the DLNA service uPnP entries."""
return self.find_by_st("urn:schemas-upnp-org:device:MediaServer:1")

133
deps/netdisco/discoverables/__init__.py vendored Normal file
View File

@@ -0,0 +1,133 @@
"""Provides helpful stuff for discoverables."""
# pylint: disable=abstract-method
class BaseDiscoverable(object):
"""Base class for discoverable services or device types."""
def is_discovered(self):
"""Return True if it is discovered."""
return len(self.get_entries()) > 0
def get_info(self):
"""Return a list with the important info for each item.
Uses self.info_from_entry internally.
"""
return [self.info_from_entry(entry) for entry in self.get_entries()]
# pylint: disable=no-self-use
def info_from_entry(self, entry):
"""Return an object with important info from the entry."""
return entry
# pylint: disable=no-self-use
def get_entries(self):
"""Return all the discovered entries."""
raise NotImplementedError()
class SSDPDiscoverable(BaseDiscoverable):
"""uPnP discoverable base class."""
def __init__(self, netdis):
"""Initialize SSDPDiscoverable."""
self.netdis = netdis
def get_info(self):
"""Get most important info, by default the description location."""
return list(set(
self.info_from_entry(entry) for entry in self.get_entries()))
def info_from_entry(self, entry):
"""Get most important info, by default the description location."""
return entry.values['location']
# Helper functions
# pylint: disable=invalid-name
def find_by_st(self, st):
"""Find entries by ST (the device identifier)."""
return self.netdis.ssdp.find_by_st(st)
def find_by_device_description(self, values):
"""Find entries based on values from their description."""
return self.netdis.ssdp.find_by_device_description(values)
class MDNSDiscoverable(BaseDiscoverable):
"""mDNS Discoverable base class."""
def __init__(self, netdis, typ):
"""Initialize MDNSDiscoverable."""
self.netdis = netdis
self.typ = typ
self.services = {}
netdis.mdns.register_service(self)
def reset(self):
"""Reset found services."""
self.services.clear()
def is_discovered(self):
"""Return True if any device has been discovered."""
return len(self.services) > 0
# pylint: disable=unused-argument
def remove_service(self, zconf, typ, name):
"""Callback when a service is removed."""
self.services.pop(name, None)
def add_service(self, zconf, typ, name):
"""Callback when a service is found."""
service = None
tries = 0
while service is None and tries < 3:
service = zconf.get_service_info(typ, name)
tries += 1
if service is not None:
self.services[name] = service
def get_entries(self):
"""Return all found services."""
return self.services.values()
def info_from_entry(self, entry):
"""Return most important info from mDNS entries."""
return (self.ip_from_host(entry.server), entry.port)
def ip_from_host(self, host):
"""Attempt to return the ip address from an mDNS host.
Return host if failed.
"""
ips = self.netdis.mdns.zeroconf.cache.entries_with_name(host.lower())
return repr(ips[0]) if ips else host
class GDMDiscoverable(BaseDiscoverable):
"""GDM discoverable base class."""
def __init__(self, netdis):
"""Initialize GDMDiscoverable."""
self.netdis = netdis
def get_info(self):
"""Get most important info, by default the description location."""
return [self.info_from_entry(entry) for entry in self.get_entries()]
def info_from_entry(self, entry):
"""Get most important info, by default the description location."""
return 'https://%s:%s/' % (entry.values['location'],
entry.values['port'])
def find_by_content_type(self, value):
"""Find entries based on values from their content_type."""
return self.netdis.gdm.find_by_content_type(value)
def find_by_data(self, values):
"""Find entries based on values from any returned field."""
return self.netdis.gdm.find_by_data(values)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,19 @@
"""Discover Belkin Wemo devices."""
from . import SSDPDiscoverable
class Discoverable(SSDPDiscoverable):
"""Add support for discovering Belkin WeMo platform devices."""
def info_from_entry(self, entry):
"""Return most important info from a uPnP entry."""
device = entry.description['device']
return (device['friendlyName'], device['modelName'],
entry.values['location'], device.get('macAddress', ''),
device['serialNumber'])
def get_entries(self):
"""Return all Belkin Wemo entries."""
return self.find_by_device_description(
{'manufacturer': 'Belkin International Inc.'})

22
deps/netdisco/discoverables/directv.py vendored Normal file
View File

@@ -0,0 +1,22 @@
"""Discover DirecTV Receivers."""
from netdisco.util import urlparse
from . import SSDPDiscoverable
class Discoverable(SSDPDiscoverable):
"""Add support for discovering DirecTV Receivers."""
def info_from_entry(self, entry):
"""Return the most important info from a uPnP entry."""
url = urlparse(entry.values['location'])
device = entry.description['device']
return url.hostname, device['serialNumber']
def get_entries(self):
"""Get all the DirecTV uPnP entries."""
return self.find_by_device_description({
"manufacturer": "DIRECTV",
"deviceType": "urn:schemas-upnp-org:device:MediaServer:1"
})

View File

@@ -0,0 +1,11 @@
"""Discover devices that implement the Google Cast platform."""
from . import MDNSDiscoverable
# pylint: disable=too-few-public-methods
class Discoverable(MDNSDiscoverable):
"""Add support for discovering Google Cast platform devices."""
def __init__(self, nd):
"""Initialize the Cast discovery."""
super(Discoverable, self).__init__(nd, '_googlecast._tcp.local.')

View File

@@ -0,0 +1,20 @@
"""Discover Home Assistant servers."""
from . import MDNSDiscoverable
# pylint: disable=too-few-public-methods
class Discoverable(MDNSDiscoverable):
"""Add support for discovering Home Assistant instances."""
def __init__(self, nd):
super(Discoverable, self).__init__(nd, '_home-assistant._tcp.local.')
def info_from_entry(self, entry):
"""Returns most important info from mDNS entries."""
return (entry.properties.get(b'base_url').decode('utf-8'),
entry.properties.get(b'version').decode('utf-8'),
entry.properties.get(b'requires_api_password'))
def get_info(self):
"""Get details from Home Assistant instances."""
return [self.info_from_entry(entry) for entry in self.get_entries()]

21
deps/netdisco/discoverables/homekit.py vendored Normal file
View File

@@ -0,0 +1,21 @@
"""Discover myStrom devices."""
from . import MDNSDiscoverable
# pylint: disable=too-few-public-methods
class Discoverable(MDNSDiscoverable):
"""Add support for discovering myStrom switches."""
def __init__(self, nd):
super(Discoverable, self).__init__(nd, '_hap._tcp.local.')
def info_from_entry(self, entry):
"""Return the most important info from mDNS entries."""
info = {key.decode('utf-8'): value.decode('utf-8')
for key, value in entry.properties.items()}
info['host'] = 'http://{}'.format(self.ip_from_host(entry.server))
return info
def get_info(self):
"""Get details from myStrom devices."""
return [self.info_from_entry(entry) for entry in self.get_entries()]

20
deps/netdisco/discoverables/kodi.py vendored Normal file
View File

@@ -0,0 +1,20 @@
"""Discover Kodi servers."""
from . import MDNSDiscoverable
# pylint: disable=too-few-public-methods
class Discoverable(MDNSDiscoverable):
"""Add support for discovering Kodi."""
def __init__(self, nd):
"""Initialize the Kodi discovery."""
super(Discoverable, self).__init__(nd, '_http._tcp.local.')
def info_from_entry(self, entry):
"""Return most important info from mDNS entries."""
return (self.ip_from_host(entry.server), entry.port)
def get_info(self):
"""Get all the Kodi details."""
return [self.info_from_entry(entry) for entry in self.get_entries()
if entry.name.startswith('Kodi ')]

View File

@@ -0,0 +1,14 @@
"""Discover Logitech Media Server."""
from . import BaseDiscoverable
class Discoverable(BaseDiscoverable):
"""Add support for discovering Logitech Media Server."""
def __init__(self, netdis):
"""Initialize Logitech Media Server discovery."""
self.netdis = netdis
def get_entries(self):
"""Get all the Logitech Media Server details."""
return [entry['from'] for entry in self.netdis.lms.entries]

20
deps/netdisco/discoverables/mystrom.py vendored Normal file
View File

@@ -0,0 +1,20 @@
"""Discover myStrom devices."""
from . import MDNSDiscoverable
# pylint: disable=too-few-public-methods
class Discoverable(MDNSDiscoverable):
"""Add support for discovering myStrom switches."""
def __init__(self, nd):
super(Discoverable, self).__init__(nd, '_hap._tcp.local.')
def info_from_entry(self, entry):
"""Return the most important info from mDNS entries."""
return (entry.properties.get(b'md').decode('utf-8'),
'http://{}'.format(self.ip_from_host(entry.server)),
entry.properties.get(b'id').decode('utf-8'))
def get_info(self):
"""Get details from myStrom devices."""
return [self.info_from_entry(entry) for entry in self.get_entries()]

View File

@@ -0,0 +1,20 @@
"""Discover Netgear routers."""
from netdisco.util import urlparse
from . import SSDPDiscoverable
class Discoverable(SSDPDiscoverable):
"""Add support for discovering Netgear routers."""
def info_from_entry(self, entry):
"""Return the most important info from a uPnP entry."""
url = urlparse(entry.values['location'])
return (entry.description['device']['modelNumber'], url.hostname)
def get_entries(self):
"""Get all the Netgear uPnP entries."""
return self.find_by_device_description({
"manufacturer": "NETGEAR, Inc.",
"deviceType": "urn:schemas-upnp-org:device:InternetGatewayDevice:1"
})

View File

@@ -0,0 +1,17 @@
"""Discover Panasonic Viera TV devices."""
from netdisco.util import urlparse
from . import SSDPDiscoverable
# pylint: disable=too-few-public-methods
class Discoverable(SSDPDiscoverable):
"""Add support for discovering Viera TV devices."""
def info_from_entry(self, entry):
"""Return the most important info from a uPnP entry."""
parsed = urlparse(entry.values['location'])
return '{}:{}'.format(parsed.hostname, parsed.port)
def get_entries(self):
"""Get all the Viera TV device uPnP entries."""
return self.find_by_st("urn:panasonic-com:service:p00NetworkControl:1")

View File

@@ -0,0 +1,20 @@
"""Discover Philips Hue bridges."""
from . import SSDPDiscoverable
class Discoverable(SSDPDiscoverable):
"""Add support for discovering Philips Hue bridges."""
def info_from_entry(self, entry):
"""Return the most important info from a uPnP entry."""
desc = entry.description
return desc['device']['friendlyName'], desc['URLBase']
def get_entries(self):
"""Get all the Hue bridge uPnP entries."""
# Hub models for year 2012 and 2015
return self.find_by_device_description({
"manufacturer": "Royal Philips Electronics",
"modelNumber": ["929000226503", "BSB002"]
})

View File

@@ -0,0 +1,15 @@
"""Discover PlexMediaServer."""
from . import GDMDiscoverable
class Discoverable(GDMDiscoverable):
"""Add support for discovering Plex Media Server."""
def info_from_entry(self, entry):
"""Return most important info from a GDM entry."""
return (entry['data']['Name'],
'https://%s:%s' % (entry['from'][0], entry['data']['Port']))
def get_entries(self):
"""Return all PMS entries."""
return self.find_by_data({'Content-Type': 'plex/media-server'})

16
deps/netdisco/discoverables/roku.py vendored Normal file
View File

@@ -0,0 +1,16 @@
"""Discover Roku players."""
from netdisco.util import urlparse
from . import SSDPDiscoverable
class Discoverable(SSDPDiscoverable):
"""Add support for discovering Roku media players."""
def info_from_entry(self, entry):
"""Return the most important info from a uPnP entry."""
info = urlparse(entry.location)
return info.hostname, info.port
def get_entries(self):
"""Get all the Roku entries."""
return self.find_by_st("roku:ecp")

21
deps/netdisco/discoverables/sabnzbd.py vendored Normal file
View File

@@ -0,0 +1,21 @@
"""Discover SABnzbd servers."""
from . import MDNSDiscoverable
# pylint: disable=too-few-public-methods
class Discoverable(MDNSDiscoverable):
"""Add support for discovering SABnzbd."""
def __init__(self, nd):
"""Initialize the SABnzbd discovery."""
super(Discoverable, self).__init__(nd, '_http._tcp.local.')
def info_from_entry(self, entry):
"""Return most important info from mDNS entries."""
return (self.ip_from_host(entry.server), entry.port,
entry.properties.get('path', '/sabnzbd/'))
def get_info(self):
"""Get details of SABnzbd."""
return [self.info_from_entry(entry) for entry in self.get_entries()
if entry.name.startswith('SABnzbd on')]

16
deps/netdisco/discoverables/sonos.py vendored Normal file
View File

@@ -0,0 +1,16 @@
"""Discover Sonos devices."""
from netdisco.util import urlparse
from . import SSDPDiscoverable
# pylint: disable=too-few-public-methods
class Discoverable(SSDPDiscoverable):
"""Add support for discovering Sonos devices."""
def info_from_entry(self, entry):
"""Return the most important info from a uPnP entry."""
return urlparse(entry.values['location']).hostname
def get_entries(self):
"""Get all the Sonos device uPnP entries."""
return self.find_by_st("urn:schemas-upnp-org:device:ZonePlayer:1")

View File

@@ -0,0 +1,14 @@
"""Discover Tellstick devices."""
from . import BaseDiscoverable
class Discoverable(BaseDiscoverable):
"""Add support for discovering a Tellstick device."""
def __init__(self, netdis):
"""Initialize the Tellstick discovery."""
self._netdis = netdis
def get_entries(self):
"""Get all the Tellstick details."""
return self._netdis.tellstick.entries

19
deps/netdisco/discoverables/webos_tv.py vendored Normal file
View File

@@ -0,0 +1,19 @@
"""Discover LG WebOS TV devices."""
from netdisco.util import urlparse
from . import SSDPDiscoverable
# pylint: disable=too-few-public-methods
class Discoverable(SSDPDiscoverable):
"""Add support for discovering LG WebOS TV devices."""
def info_from_entry(self, entry):
"""Return the most important info from a uPnP entry."""
return urlparse(entry.values['location']).hostname
def get_entries(self):
"""Get all the LG WebOS TV device uPnP entries."""
return self.find_by_device_description({
"deviceType": "urn:dial-multiscreen-org:device:dial:1",
"friendlyName": "[LG] webOS TV"
})