Beispiel #1
0
    def test_AmountOfHostsConnected(self):
        data = """<?xml version="10"?>
<root
  xmlns="urn:schemas-upnp-org:device-1-0"
  xmlns:ms="urn:microsoft-com:wmc-1-0"
  xmlns:pnpx="http://schemasmicrosoftcom/windows/pnpx/2005/11"
  xmlns:df="http://schemasmicrosoftcom/windows/2008/09/devicefoundation"
  xmlns:yamaha="urn:schemas-yamaha-com:device-1-0">
    <yamaha:X_device><yamaha:X_URLBase>http://REDACTED:80/</yamaha:X_URLBase><yamaha:X_serviceList><yamaha:X_service><yamaha:X_specType>urn:schemas-yamaha-com:service:X_YamahaRemoteControl:1</yamaha:X_specType><yamaha:X_controlURL>/YamahaRemoteControl/ctrl</yamaha:X_controlURL><yamaha:X_unitDescURL>/YamahaRemoteControl/descxml</yamaha:X_unitDescURL></yamaha:X_service></yamaha:X_serviceList></yamaha:X_device>
    <specVersion>
        <major>1</major>
        <minor>0</minor>
    </specVersion>
    <device
      ms:X_MS_SupportsWMDRM="true">
        <dlna:X_DLNADOC xmlns:dlna="urn:schemas-dlna-org:device-1-0">DMR-150</dlna:X_DLNADOC>
        <pnpx:X_compatibleId>MS_DigitalMediaDeviceClass_DMR_V001
                </pnpx:X_compatibleId>
        <pnpx:X_deviceCategory>MediaDevices MultimediaDMR MediaDeviceDMC
                </pnpx:X_deviceCategory>
        <pnpx:X_hardwareId>VEN_0033&amp;DEV_0006&amp;REV_01
                </pnpx:X_hardwareId>
        <df:X_deviceCategory>MultimediaDMR
                </df:X_deviceCategory>
        <deviceType>urn:schemas-upnp-org:device:MediaRenderer:1</deviceType>
        <friendlyName>Pascal</friendlyName>
        <manufacturer>Yamaha Corporation</manufacturer>
        <manufacturerURL>http://wwwyamahacom/</manufacturerURL>
        <modelDescription>AV Receiver</modelDescription>
        <modelName>RX-V475</modelName>
        <modelNumber>V475</modelNumber>
        <modelURL>http://wwwyamahacom/</modelURL>
        <serialNumber>REDACTED</serialNumber>
        <UDN>REDACTED</UDN>
        <UPC>REDACTED</UPC>
        <iconList>
            <icon>
                <mimetype>image/jpeg</mimetype>
                <width>48</width>
                <height>48</height>
                <depth>24</depth>
                <url>/BCO_device_sm_iconjpg</url>
            </icon>
            <icon>
                <mimetype>image/jpeg</mimetype>
                <width>120</width>
                <height>120</height>
                <depth>24</depth>
                <url>/BCO_device_lrg_iconjpg</url>
            </icon>
            <icon>
                <mimetype>image/png</mimetype>
                <width>48</width>
                <height>48</height>
                <depth>24</depth>
                <url>/BCO_device_sm_iconpng</url>
            </icon>
            <icon>
                <mimetype>image/png</mimetype>
                <width>120</width>
                <height>120</height>
                <depth>24</depth>
                <url>/BCO_device_lrg_iconpng</url>
            </icon>
        </iconList>
        <serviceList>
            <service>
                <serviceType>urn:schemas-upnp-org:service:RenderingControl:1</serviceType>
                <serviceId>urn:upnp-org:serviceId:RenderingControl</serviceId>
                <SCPDURL>/RenderingControl/descxml</SCPDURL>
                <controlURL>/RenderingControl/ctrl</controlURL>
                <eventSubURL>/RenderingControl/evt</eventSubURL>
            </service>
            <service>
                <serviceType>urn:schemas-upnp-org:service:ConnectionManager:1</serviceType>
                <serviceId>urn:upnp-org:serviceId:ConnectionManager</serviceId>
                <SCPDURL>/ConnectionManager/descxml</SCPDURL>
                <controlURL>/ConnectionManager/ctrl</controlURL>
                <eventSubURL>/ConnectionManager/evt</eventSubURL>
            </service>
            <service>
                <serviceType>urn:schemas-upnp-org:service:AVTransport:1</serviceType>
                <serviceId>urn:upnp-org:serviceId:AVTransport</serviceId>
                <SCPDURL>/AVTransport/descxml</SCPDURL>
                <controlURL>/AVTransport/ctrl</controlURL>
                <eventSubURL>/AVTransport/evt</eventSubURL>
            </service>
        </serviceList>
        <presentationURL>http://REDACTED/</presentationURL>
    </device>
</root>"""

        url = "http://pascalfritzbox:8080/MediaRenderer/desc.xml"
        box = DeviceTR64.createFromURL(url)

        box._loadDeviceDefinitions(url, data)

        self.assertTrue(len(box.deviceServiceDefinitions.keys()) > 0)
Beispiel #2
0
    def test_AmountOfHostsConnected(self):
        data = """<?xml version="10"?>
<root
  xmlns="urn:schemas-upnp-org:device-1-0"
  xmlns:ms="urn:microsoft-com:wmc-1-0"
  xmlns:pnpx="http://schemasmicrosoftcom/windows/pnpx/2005/11"
  xmlns:df="http://schemasmicrosoftcom/windows/2008/09/devicefoundation"
  xmlns:yamaha="urn:schemas-yamaha-com:device-1-0">
    <yamaha:X_device><yamaha:X_URLBase>http://REDACTED:80/</yamaha:X_URLBase><yamaha:X_serviceList><yamaha:X_service><yamaha:X_specType>urn:schemas-yamaha-com:service:X_YamahaRemoteControl:1</yamaha:X_specType><yamaha:X_controlURL>/YamahaRemoteControl/ctrl</yamaha:X_controlURL><yamaha:X_unitDescURL>/YamahaRemoteControl/descxml</yamaha:X_unitDescURL></yamaha:X_service></yamaha:X_serviceList></yamaha:X_device>
    <specVersion>
        <major>1</major>
        <minor>0</minor>
    </specVersion>
    <device
      ms:X_MS_SupportsWMDRM="true">
        <dlna:X_DLNADOC xmlns:dlna="urn:schemas-dlna-org:device-1-0">DMR-150</dlna:X_DLNADOC>
        <pnpx:X_compatibleId>MS_DigitalMediaDeviceClass_DMR_V001
                </pnpx:X_compatibleId>
        <pnpx:X_deviceCategory>MediaDevices MultimediaDMR MediaDeviceDMC
                </pnpx:X_deviceCategory>
        <pnpx:X_hardwareId>VEN_0033&amp;DEV_0006&amp;REV_01
                </pnpx:X_hardwareId>
        <df:X_deviceCategory>MultimediaDMR
                </df:X_deviceCategory>
        <deviceType>urn:schemas-upnp-org:device:MediaRenderer:1</deviceType>
        <friendlyName>Pascal</friendlyName>
        <manufacturer>Yamaha Corporation</manufacturer>
        <manufacturerURL>http://wwwyamahacom/</manufacturerURL>
        <modelDescription>AV Receiver</modelDescription>
        <modelName>RX-V475</modelName>
        <modelNumber>V475</modelNumber>
        <modelURL>http://wwwyamahacom/</modelURL>
        <serialNumber>REDACTED</serialNumber>
        <UDN>REDACTED</UDN>
        <UPC>REDACTED</UPC>
        <iconList>
            <icon>
                <mimetype>image/jpeg</mimetype>
                <width>48</width>
                <height>48</height>
                <depth>24</depth>
                <url>/BCO_device_sm_iconjpg</url>
            </icon>
            <icon>
                <mimetype>image/jpeg</mimetype>
                <width>120</width>
                <height>120</height>
                <depth>24</depth>
                <url>/BCO_device_lrg_iconjpg</url>
            </icon>
            <icon>
                <mimetype>image/png</mimetype>
                <width>48</width>
                <height>48</height>
                <depth>24</depth>
                <url>/BCO_device_sm_iconpng</url>
            </icon>
            <icon>
                <mimetype>image/png</mimetype>
                <width>120</width>
                <height>120</height>
                <depth>24</depth>
                <url>/BCO_device_lrg_iconpng</url>
            </icon>
        </iconList>
        <serviceList>
            <service>
                <serviceType>urn:schemas-upnp-org:service:RenderingControl:1</serviceType>
                <serviceId>urn:upnp-org:serviceId:RenderingControl</serviceId>
                <SCPDURL>/RenderingControl/descxml</SCPDURL>
                <controlURL>/RenderingControl/ctrl</controlURL>
                <eventSubURL>/RenderingControl/evt</eventSubURL>
            </service>
            <service>
                <serviceType>urn:schemas-upnp-org:service:ConnectionManager:1</serviceType>
                <serviceId>urn:upnp-org:serviceId:ConnectionManager</serviceId>
                <SCPDURL>/ConnectionManager/descxml</SCPDURL>
                <controlURL>/ConnectionManager/ctrl</controlURL>
                <eventSubURL>/ConnectionManager/evt</eventSubURL>
            </service>
            <service>
                <serviceType>urn:schemas-upnp-org:service:AVTransport:1</serviceType>
                <serviceId>urn:upnp-org:serviceId:AVTransport</serviceId>
                <SCPDURL>/AVTransport/descxml</SCPDURL>
                <controlURL>/AVTransport/ctrl</controlURL>
                <eventSubURL>/AVTransport/evt</eventSubURL>
            </service>
        </serviceList>
        <presentationURL>http://REDACTED/</presentationURL>
    </device>
</root>"""

        url = "http://pascalfritzbox:8080/MediaRenderer/desc.xml"
        box = DeviceTR64.createFromURL(url)

        box._loadDeviceDefinitions(url, data)

        self.assertTrue(len(box.deviceServiceDefinitions.keys()) > 0)
Beispiel #3
0
use_arguments = {}

for argument in args.arguments:
    args = argument.split("::")

    if len(args) != 2:
        raise ValueError("Argument needs to be in the format of ArgumentName::Value, found: " + argument)

    use_arguments[args[0]] = args[1]

#######################################################################################################################

urlParts = urlparse(use_controlURL)
uri = urlParts.path

device = DeviceTR64.createFromURL(use_controlURL)

device.username = use_user
device.password = use_pw
device.httpProxy = use_httpProxy
device.httpsProxy = use_httpsProxy

try:
    # where the "magic" happens
    results = device.execute(uri, use_namespace, use_action, timeout=use_timeout, **use_arguments)
except (requests.exceptions.ConnectTimeout, requests.exceptions.ConnectionError) as e:
    print("Failed: " + str(e))
    results = {}

if len(results.keys()):
    print("Results:")
Beispiel #4
0
if use_httpsProxy:
    proxies = {"https": use_httpsProxy}

if use_httpProxy:
    proxies = {"http": use_httpProxy}

# get TR64 multicast result for the given host to get XML definition url
result = Discover.discoverParticularHost(use_host,
                                         proxies=proxies,
                                         timeout=use_timeout)

if not result:
    raise ValueError("Could not discover given host: " + use_host)

# get instance of device
box = DeviceTR64.createFromURL(result.location)
box.username = use_user
box.password = use_pw
box.httpProxy = use_httpProxy
box.httpsProxy = use_httpsProxy

# the discovery result contains the right URL to initialize device definitions
box.loadDeviceDefinitions(result.location, timeout=use_timeout)
# load the actions
box.loadSCPD(timeout=use_timeout, ignoreFailures=True)

device = {"informations": box.deviceInformations, "services": {}}

if len(box.deviceInformationUnknownKeys.keys()):
    device["unknownKeys"] = box.deviceInformationUnknownKeys
# setup proxies for discovery call
proxies = {}
if use_httpsProxy:
    proxies = {"https": use_httpsProxy}

if use_httpProxy:
    proxies = {"http": use_httpProxy}

# get TR64 multicast result for the given host to get XML definition url
result = Discover.discoverParticularHost(use_host, proxies=proxies, timeout=use_timeout)

if not result:
    raise ValueError("Could not discover given host: " + use_host)

# get instance of device
box = DeviceTR64.createFromURL(result.location)
box.username = use_user
box.password = use_pw
box.httpProxy = use_httpProxy
box.httpsProxy = use_httpsProxy

# the discovery result contains the right URL to initialize device definitions
box.loadDeviceDefinitions(result.location, timeout=use_timeout)
# load the actions
box.loadSCPD(timeout=use_timeout, ignoreFailures=True)

device = {"informations": box.deviceInformations, "services": {}}

if len(box.deviceInformationUnknownKeys.keys()):
    device["unknownKeys"] = box.deviceInformationUnknownKeys
Beispiel #6
0
for argument in args.arguments:
    args = argument.split("::")

    if len(args) != 2:
        raise ValueError(
            "Argument needs to be in the format of ArgumentName::Value, found: "
            + argument)

    use_arguments[args[0]] = args[1]

#######################################################################################################################

urlParts = urlparse(use_controlURL)
uri = urlParts.path

device = DeviceTR64.createFromURL(use_controlURL)

device.username = use_user
device.password = use_pw
device.httpProxy = use_httpProxy
device.httpsProxy = use_httpsProxy

try:
    # where the "magic" happens
    results = device.execute(uri,
                             use_namespace,
                             use_action,
                             timeout=use_timeout,
                             **use_arguments)
except (requests.exceptions.ConnectTimeout,
        requests.exceptions.ConnectionError) as e: