summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--python-upnpclient.spec479
-rw-r--r--sources1
3 files changed, 481 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..92d3cf9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/upnpclient-1.0.3.tar.gz
diff --git a/python-upnpclient.spec b/python-upnpclient.spec
new file mode 100644
index 0000000..2f6868a
--- /dev/null
+++ b/python-upnpclient.spec
@@ -0,0 +1,479 @@
+%global _empty_manifest_terminate_build 0
+Name: python-upnpclient
+Version: 1.0.3
+Release: 1
+Summary: Python 3 library for accessing uPnP devices.
+License: MIT
+URL: https://github.com/flyte/upnpclient
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/dd/69/4d38d9fa757c328df93e7037eb8c1da8ca48e62828c23ba3c421e9335e30/upnpclient-1.0.3.tar.gz
+BuildArch: noarch
+
+Requires: python3-requests
+Requires: python3-six
+Requires: python3-dateutil
+Requires: python3-lxml
+Requires: python3-ifaddr
+
+%description
+_uPnP client library for Python 3._
+This library can be used to discover and consume uPnP devices and their services.
+It's originally based on [Ferry Boender's work](https://github.com/fboender/pyupnpclient) and his blog post entitled [Exploring UPnP with Python](https://www.electricmonk.nl/log/2016/07/05/exploring-upnp-with-python/).
+### Installation
+```bash
+pip install upnpclient
+```
+### Usage
+Typical usage:
+```python
+In [1]: import upnpclient
+In [2]: devices = upnpclient.discover()
+In [3]: devices
+Out[3]:
+[<Device 'OpenWRT router'>,
+ <Device 'Harmony Hub'>,
+ <Device 'walternate: root'>]
+In [4]: d = devices[0]
+In [5]: d.WANIPConn1.GetStatusInfo()
+Out[5]:
+{'NewConnectionStatus': 'Connected',
+ 'NewLastConnectionError': 'ERROR_NONE',
+ 'NewUptime': 14851479}
+In [6]: d.WANIPConn1.GetNATRSIPStatus()
+Out[6]: {'NewNATEnabled': True, 'NewRSIPAvailable': False}
+In [7]: d.WANIPConn1.GetExternalIPAddress()
+Out[7]: {'NewExternalIPAddress': '123.123.123.123'}
+```
+If you know the URL for the device description XML, you can access it directly.
+```python
+In [1]: import upnpclient
+In [2]: d = upnpclient.Device("http://192.168.1.1:5000/rootDesc.xml")
+In [3]: d.services
+Out[3]:
+[<Service service_id='urn:upnp-org:serviceId:Layer3Forwarding1'>,
+ <Service service_id='urn:upnp-org:serviceId:WANCommonIFC1'>,
+ <Service service_id='urn:upnp-org:serviceId:WANIPConn1'>]
+In [4]: d.Layer3Forwarding1.actions
+Out[4]:
+[<Action 'SetDefaultConnectionService'>,
+ <Action 'GetDefaultConnectionService'>]
+In [5]: d.Layer3Forwarding1.GetDefaultConnectionService()
+Out[5]: {'NewDefaultConnectionService': 'uuid:46cb370a-d7f2-490f-ac01-fb0db6c8b22b:WANConnectionDevice:1,urn:upnp-org:serviceId:WANIPConn1'}
+```
+Sometimes the service or action name isn't a valid property name. In which case, service and actions can be accessed other ways:
+```python
+In [1]: d["Layer3Forwarding1"]["GetDefaultConnectionService"]()
+Out[1]: {'NewDefaultConnectionService': 'uuid:46cb370a-d7f2-490f-ac01-fb0db6c8b22b:WANConnectionDevice:1,urn:upnp-org:serviceId:WANIPConn1'}
+```
+To view the arguments required to call a given action:
+```python
+In [1]: d.WANIPConn1.AddPortMapping.argsdef_in
+Out[1]:
+[('NewRemoteHost',
+ {'allowed_values': set(), 'datatype': 'string', 'name': 'RemoteHost'}),
+ ('NewExternalPort',
+ {'allowed_values': set(), 'datatype': 'ui2', 'name': 'ExternalPort'}),
+ ('NewProtocol',
+ {'allowed_values': {'TCP', 'UDP'},
+ 'datatype': 'string',
+ 'name': 'PortMappingProtocol'}),
+ ('NewInternalPort',
+ {'allowed_values': set(), 'datatype': 'ui2', 'name': 'InternalPort'}),
+ ('NewInternalClient',
+ {'allowed_values': set(), 'datatype': 'string', 'name': 'InternalClient'}),
+ ('NewEnabled',
+ {'allowed_values': set(),
+ 'datatype': 'boolean',
+ 'name': 'PortMappingEnabled'}),
+ ('NewPortMappingDescription',
+ {'allowed_values': set(),
+ 'datatype': 'string',
+ 'name': 'PortMappingDescription'}),
+ ('NewLeaseDuration',
+ {'allowed_values': set(),
+ 'datatype': 'ui4',
+ 'name': 'PortMappingLeaseDuration'})]
+```
+and then to call the action using those arguments:
+```python
+In [1]: d.WANIPConn1.AddPortMapping(
+Out[1]: {}
+```
+Similarly, the arguments you can expect to receive in response are listed:
+```python
+In [1]: d.WANIPConn1.GetGenericPortMappingEntry.argsdef_out
+Out[1]:
+[('NewRemoteHost',
+ {'allowed_values': set(), 'datatype': 'string', 'name': 'RemoteHost'}),
+ ('NewExternalPort',
+ {'allowed_values': set(), 'datatype': 'ui2', 'name': 'ExternalPort'}),
+ ('NewProtocol',
+ {'allowed_values': {'TCP', 'UDP'},
+ 'datatype': 'string',
+ 'name': 'PortMappingProtocol'}),
+ ('NewInternalPort',
+ {'allowed_values': set(), 'datatype': 'ui2', 'name': 'InternalPort'}),
+ ('NewInternalClient',
+ {'allowed_values': set(), 'datatype': 'string', 'name': 'InternalClient'}),
+ ('NewEnabled',
+ {'allowed_values': set(),
+ 'datatype': 'boolean',
+ 'name': 'PortMappingEnabled'}),
+ ('NewPortMappingDescription',
+ {'allowed_values': set(),
+ 'datatype': 'string',
+ 'name': 'PortMappingDescription'}),
+ ('NewLeaseDuration',
+ {'allowed_values': set(),
+ 'datatype': 'ui4',
+ 'name': 'PortMappingLeaseDuration'})]
+```
+#### HTTP Auth/Headers
+You may pass a
+[requests compatible](http://docs.python-requests.org/en/master/user/authentication/)
+authentication object and/or a dictionary containing headers to use on the HTTP
+calls to your uPnP device.
+These may be set on the `Device` itself on creation for use with every HTTP
+call:
+```python
+device = upnpclient.Device(
+ "http://192.168.1.1:5000/rootDesc.xml"
+ http_auth=('myusername', 'mypassword'),
+ http_headers={'Some-Required-Header': 'somevalue'}
+)
+```
+Or on a per-call basis:
+```python
+device.Layer3Forwarding1.GetDefaultConnectionService(
+ http_auth=('myusername', 'mypassword'),
+ http_headers={'Some-Required-Header': 'somevalue'}
+)
+```
+If you've set either at `Device` level, they can be overridden per-call by
+setting them to `None`.
+
+%package -n python3-upnpclient
+Summary: Python 3 library for accessing uPnP devices.
+Provides: python-upnpclient
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-upnpclient
+_uPnP client library for Python 3._
+This library can be used to discover and consume uPnP devices and their services.
+It's originally based on [Ferry Boender's work](https://github.com/fboender/pyupnpclient) and his blog post entitled [Exploring UPnP with Python](https://www.electricmonk.nl/log/2016/07/05/exploring-upnp-with-python/).
+### Installation
+```bash
+pip install upnpclient
+```
+### Usage
+Typical usage:
+```python
+In [1]: import upnpclient
+In [2]: devices = upnpclient.discover()
+In [3]: devices
+Out[3]:
+[<Device 'OpenWRT router'>,
+ <Device 'Harmony Hub'>,
+ <Device 'walternate: root'>]
+In [4]: d = devices[0]
+In [5]: d.WANIPConn1.GetStatusInfo()
+Out[5]:
+{'NewConnectionStatus': 'Connected',
+ 'NewLastConnectionError': 'ERROR_NONE',
+ 'NewUptime': 14851479}
+In [6]: d.WANIPConn1.GetNATRSIPStatus()
+Out[6]: {'NewNATEnabled': True, 'NewRSIPAvailable': False}
+In [7]: d.WANIPConn1.GetExternalIPAddress()
+Out[7]: {'NewExternalIPAddress': '123.123.123.123'}
+```
+If you know the URL for the device description XML, you can access it directly.
+```python
+In [1]: import upnpclient
+In [2]: d = upnpclient.Device("http://192.168.1.1:5000/rootDesc.xml")
+In [3]: d.services
+Out[3]:
+[<Service service_id='urn:upnp-org:serviceId:Layer3Forwarding1'>,
+ <Service service_id='urn:upnp-org:serviceId:WANCommonIFC1'>,
+ <Service service_id='urn:upnp-org:serviceId:WANIPConn1'>]
+In [4]: d.Layer3Forwarding1.actions
+Out[4]:
+[<Action 'SetDefaultConnectionService'>,
+ <Action 'GetDefaultConnectionService'>]
+In [5]: d.Layer3Forwarding1.GetDefaultConnectionService()
+Out[5]: {'NewDefaultConnectionService': 'uuid:46cb370a-d7f2-490f-ac01-fb0db6c8b22b:WANConnectionDevice:1,urn:upnp-org:serviceId:WANIPConn1'}
+```
+Sometimes the service or action name isn't a valid property name. In which case, service and actions can be accessed other ways:
+```python
+In [1]: d["Layer3Forwarding1"]["GetDefaultConnectionService"]()
+Out[1]: {'NewDefaultConnectionService': 'uuid:46cb370a-d7f2-490f-ac01-fb0db6c8b22b:WANConnectionDevice:1,urn:upnp-org:serviceId:WANIPConn1'}
+```
+To view the arguments required to call a given action:
+```python
+In [1]: d.WANIPConn1.AddPortMapping.argsdef_in
+Out[1]:
+[('NewRemoteHost',
+ {'allowed_values': set(), 'datatype': 'string', 'name': 'RemoteHost'}),
+ ('NewExternalPort',
+ {'allowed_values': set(), 'datatype': 'ui2', 'name': 'ExternalPort'}),
+ ('NewProtocol',
+ {'allowed_values': {'TCP', 'UDP'},
+ 'datatype': 'string',
+ 'name': 'PortMappingProtocol'}),
+ ('NewInternalPort',
+ {'allowed_values': set(), 'datatype': 'ui2', 'name': 'InternalPort'}),
+ ('NewInternalClient',
+ {'allowed_values': set(), 'datatype': 'string', 'name': 'InternalClient'}),
+ ('NewEnabled',
+ {'allowed_values': set(),
+ 'datatype': 'boolean',
+ 'name': 'PortMappingEnabled'}),
+ ('NewPortMappingDescription',
+ {'allowed_values': set(),
+ 'datatype': 'string',
+ 'name': 'PortMappingDescription'}),
+ ('NewLeaseDuration',
+ {'allowed_values': set(),
+ 'datatype': 'ui4',
+ 'name': 'PortMappingLeaseDuration'})]
+```
+and then to call the action using those arguments:
+```python
+In [1]: d.WANIPConn1.AddPortMapping(
+Out[1]: {}
+```
+Similarly, the arguments you can expect to receive in response are listed:
+```python
+In [1]: d.WANIPConn1.GetGenericPortMappingEntry.argsdef_out
+Out[1]:
+[('NewRemoteHost',
+ {'allowed_values': set(), 'datatype': 'string', 'name': 'RemoteHost'}),
+ ('NewExternalPort',
+ {'allowed_values': set(), 'datatype': 'ui2', 'name': 'ExternalPort'}),
+ ('NewProtocol',
+ {'allowed_values': {'TCP', 'UDP'},
+ 'datatype': 'string',
+ 'name': 'PortMappingProtocol'}),
+ ('NewInternalPort',
+ {'allowed_values': set(), 'datatype': 'ui2', 'name': 'InternalPort'}),
+ ('NewInternalClient',
+ {'allowed_values': set(), 'datatype': 'string', 'name': 'InternalClient'}),
+ ('NewEnabled',
+ {'allowed_values': set(),
+ 'datatype': 'boolean',
+ 'name': 'PortMappingEnabled'}),
+ ('NewPortMappingDescription',
+ {'allowed_values': set(),
+ 'datatype': 'string',
+ 'name': 'PortMappingDescription'}),
+ ('NewLeaseDuration',
+ {'allowed_values': set(),
+ 'datatype': 'ui4',
+ 'name': 'PortMappingLeaseDuration'})]
+```
+#### HTTP Auth/Headers
+You may pass a
+[requests compatible](http://docs.python-requests.org/en/master/user/authentication/)
+authentication object and/or a dictionary containing headers to use on the HTTP
+calls to your uPnP device.
+These may be set on the `Device` itself on creation for use with every HTTP
+call:
+```python
+device = upnpclient.Device(
+ "http://192.168.1.1:5000/rootDesc.xml"
+ http_auth=('myusername', 'mypassword'),
+ http_headers={'Some-Required-Header': 'somevalue'}
+)
+```
+Or on a per-call basis:
+```python
+device.Layer3Forwarding1.GetDefaultConnectionService(
+ http_auth=('myusername', 'mypassword'),
+ http_headers={'Some-Required-Header': 'somevalue'}
+)
+```
+If you've set either at `Device` level, they can be overridden per-call by
+setting them to `None`.
+
+%package help
+Summary: Development documents and examples for upnpclient
+Provides: python3-upnpclient-doc
+%description help
+_uPnP client library for Python 3._
+This library can be used to discover and consume uPnP devices and their services.
+It's originally based on [Ferry Boender's work](https://github.com/fboender/pyupnpclient) and his blog post entitled [Exploring UPnP with Python](https://www.electricmonk.nl/log/2016/07/05/exploring-upnp-with-python/).
+### Installation
+```bash
+pip install upnpclient
+```
+### Usage
+Typical usage:
+```python
+In [1]: import upnpclient
+In [2]: devices = upnpclient.discover()
+In [3]: devices
+Out[3]:
+[<Device 'OpenWRT router'>,
+ <Device 'Harmony Hub'>,
+ <Device 'walternate: root'>]
+In [4]: d = devices[0]
+In [5]: d.WANIPConn1.GetStatusInfo()
+Out[5]:
+{'NewConnectionStatus': 'Connected',
+ 'NewLastConnectionError': 'ERROR_NONE',
+ 'NewUptime': 14851479}
+In [6]: d.WANIPConn1.GetNATRSIPStatus()
+Out[6]: {'NewNATEnabled': True, 'NewRSIPAvailable': False}
+In [7]: d.WANIPConn1.GetExternalIPAddress()
+Out[7]: {'NewExternalIPAddress': '123.123.123.123'}
+```
+If you know the URL for the device description XML, you can access it directly.
+```python
+In [1]: import upnpclient
+In [2]: d = upnpclient.Device("http://192.168.1.1:5000/rootDesc.xml")
+In [3]: d.services
+Out[3]:
+[<Service service_id='urn:upnp-org:serviceId:Layer3Forwarding1'>,
+ <Service service_id='urn:upnp-org:serviceId:WANCommonIFC1'>,
+ <Service service_id='urn:upnp-org:serviceId:WANIPConn1'>]
+In [4]: d.Layer3Forwarding1.actions
+Out[4]:
+[<Action 'SetDefaultConnectionService'>,
+ <Action 'GetDefaultConnectionService'>]
+In [5]: d.Layer3Forwarding1.GetDefaultConnectionService()
+Out[5]: {'NewDefaultConnectionService': 'uuid:46cb370a-d7f2-490f-ac01-fb0db6c8b22b:WANConnectionDevice:1,urn:upnp-org:serviceId:WANIPConn1'}
+```
+Sometimes the service or action name isn't a valid property name. In which case, service and actions can be accessed other ways:
+```python
+In [1]: d["Layer3Forwarding1"]["GetDefaultConnectionService"]()
+Out[1]: {'NewDefaultConnectionService': 'uuid:46cb370a-d7f2-490f-ac01-fb0db6c8b22b:WANConnectionDevice:1,urn:upnp-org:serviceId:WANIPConn1'}
+```
+To view the arguments required to call a given action:
+```python
+In [1]: d.WANIPConn1.AddPortMapping.argsdef_in
+Out[1]:
+[('NewRemoteHost',
+ {'allowed_values': set(), 'datatype': 'string', 'name': 'RemoteHost'}),
+ ('NewExternalPort',
+ {'allowed_values': set(), 'datatype': 'ui2', 'name': 'ExternalPort'}),
+ ('NewProtocol',
+ {'allowed_values': {'TCP', 'UDP'},
+ 'datatype': 'string',
+ 'name': 'PortMappingProtocol'}),
+ ('NewInternalPort',
+ {'allowed_values': set(), 'datatype': 'ui2', 'name': 'InternalPort'}),
+ ('NewInternalClient',
+ {'allowed_values': set(), 'datatype': 'string', 'name': 'InternalClient'}),
+ ('NewEnabled',
+ {'allowed_values': set(),
+ 'datatype': 'boolean',
+ 'name': 'PortMappingEnabled'}),
+ ('NewPortMappingDescription',
+ {'allowed_values': set(),
+ 'datatype': 'string',
+ 'name': 'PortMappingDescription'}),
+ ('NewLeaseDuration',
+ {'allowed_values': set(),
+ 'datatype': 'ui4',
+ 'name': 'PortMappingLeaseDuration'})]
+```
+and then to call the action using those arguments:
+```python
+In [1]: d.WANIPConn1.AddPortMapping(
+Out[1]: {}
+```
+Similarly, the arguments you can expect to receive in response are listed:
+```python
+In [1]: d.WANIPConn1.GetGenericPortMappingEntry.argsdef_out
+Out[1]:
+[('NewRemoteHost',
+ {'allowed_values': set(), 'datatype': 'string', 'name': 'RemoteHost'}),
+ ('NewExternalPort',
+ {'allowed_values': set(), 'datatype': 'ui2', 'name': 'ExternalPort'}),
+ ('NewProtocol',
+ {'allowed_values': {'TCP', 'UDP'},
+ 'datatype': 'string',
+ 'name': 'PortMappingProtocol'}),
+ ('NewInternalPort',
+ {'allowed_values': set(), 'datatype': 'ui2', 'name': 'InternalPort'}),
+ ('NewInternalClient',
+ {'allowed_values': set(), 'datatype': 'string', 'name': 'InternalClient'}),
+ ('NewEnabled',
+ {'allowed_values': set(),
+ 'datatype': 'boolean',
+ 'name': 'PortMappingEnabled'}),
+ ('NewPortMappingDescription',
+ {'allowed_values': set(),
+ 'datatype': 'string',
+ 'name': 'PortMappingDescription'}),
+ ('NewLeaseDuration',
+ {'allowed_values': set(),
+ 'datatype': 'ui4',
+ 'name': 'PortMappingLeaseDuration'})]
+```
+#### HTTP Auth/Headers
+You may pass a
+[requests compatible](http://docs.python-requests.org/en/master/user/authentication/)
+authentication object and/or a dictionary containing headers to use on the HTTP
+calls to your uPnP device.
+These may be set on the `Device` itself on creation for use with every HTTP
+call:
+```python
+device = upnpclient.Device(
+ "http://192.168.1.1:5000/rootDesc.xml"
+ http_auth=('myusername', 'mypassword'),
+ http_headers={'Some-Required-Header': 'somevalue'}
+)
+```
+Or on a per-call basis:
+```python
+device.Layer3Forwarding1.GetDefaultConnectionService(
+ http_auth=('myusername', 'mypassword'),
+ http_headers={'Some-Required-Header': 'somevalue'}
+)
+```
+If you've set either at `Device` level, they can be overridden per-call by
+setting them to `None`.
+
+%prep
+%autosetup -n upnpclient-1.0.3
+
+%build
+%py3_build
+
+%install
+%py3_install
+install -d -m755 %{buildroot}/%{_pkgdocdir}
+if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
+if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
+if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
+if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
+pushd %{buildroot}
+if [ -d usr/lib ]; then
+ find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/lib64 ]; then
+ find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/bin ]; then
+ find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/sbin ]; then
+ find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+touch doclist.lst
+if [ -d usr/share/man ]; then
+ find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
+fi
+popd
+mv %{buildroot}/filelist.lst .
+mv %{buildroot}/doclist.lst .
+
+%files -n python3-upnpclient -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Wed Apr 12 2023 Python_Bot <Python_Bot@openeuler.org> - 1.0.3-1
+- Package Spec generated
diff --git a/sources b/sources
new file mode 100644
index 0000000..1113011
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+f936c8de89705555f6bd736a66d3af5d upnpclient-1.0.3.tar.gz