diff options
| author | CoprDistGit <infra@openeuler.org> | 2023-04-12 03:53:26 +0000 |
|---|---|---|
| committer | CoprDistGit <infra@openeuler.org> | 2023-04-12 03:53:26 +0000 |
| commit | 240d4214b7dc0f9f4c19752514d6636d62d160b3 (patch) | |
| tree | 82e2645228593ec34ae5bc916ecaf759ed4d6cf8 /python-upnpclient.spec | |
| parent | d989e2ed1a9828f9b9d6fcffad22f85ae9764036 (diff) | |
automatic import of python-upnpclientopeneuler20.03
Diffstat (limited to 'python-upnpclient.spec')
| -rw-r--r-- | python-upnpclient.spec | 479 |
1 files changed, 479 insertions, 0 deletions
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 |
