diff --git a/openwrt_luci_rpc/__init__.py b/openwrt_luci_rpc/__init__.py index 8d5b4d9..20a60e8 100644 --- a/openwrt_luci_rpc/__init__.py +++ b/openwrt_luci_rpc/__init__.py @@ -3,11 +3,11 @@ """Top-level package for openwrt-luci-rpc.""" __author__ = """Finbarr Brady""" -__email__ = 'fbradyirl@github.io' -__version__ = '1.1.16' +__email__ = "fbradyirl@github.io" +__version__ = "1.1.17" -from .openwrt_luci_rpc import OpenWrtLuciRPC from .constants import Constants +from .openwrt_luci_rpc import OpenWrtLuciRPC class OpenWrtRpc: @@ -15,11 +15,14 @@ class OpenWrtRpc: Class to interact with OpenWrt router running luci-mod-rpc package. """ - def __init__(self, host_url=Constants.DEFAULT_LOCAL_HOST, - username=Constants.DEFAULT_USERNAME, - password=Constants.DEFAULT_PASSWORD, - is_https=Constants.DEFAULT_HTTPS, - verify_https=Constants.DEFAULT_VERIFY_HTTPS): + def __init__( + self, + host_url=Constants.DEFAULT_LOCAL_HOST, + username=Constants.DEFAULT_USERNAME, + password=Constants.DEFAULT_PASSWORD, + is_https=Constants.DEFAULT_HTTPS, + verify_https=Constants.DEFAULT_VERIFY_HTTPS, + ): """ Initiate an instance with a default local ip (192.168.1.1) :param host_url: string - host url. Defaults to 192.168.1.1 @@ -28,16 +31,20 @@ def __init__(self, host_url=Constants.DEFAULT_LOCAL_HOST, :param is_https: boolean - use https? Default is false :param verify_https: boolean - verify https? Default is true """ - self.router = OpenWrtLuciRPC(host_url, username, password, - is_https, verify_https) + self.router = OpenWrtLuciRPC( + host_url, username, password, is_https, verify_https + ) def is_logged_in(self): """Returns true if a token has been aquired""" return self.router.token is not None - def get_all_connected_devices(self, - only_reachable=Constants.DEFAULT_ONLY_REACH, - wlan_interfaces=Constants.DEFAULT_WLAN_IF): + def get_all_connected_devices( + self, + only_reachable=Constants.DEFAULT_ONLY_REACH, + wlan_interfaces=Constants.DEFAULT_WLAN_IF, + ): """Get details of all devices""" return self.router.get_all_connected_devices( - only_reachable=only_reachable, wlan_interfaces=wlan_interfaces) + only_reachable=only_reachable, wlan_interfaces=wlan_interfaces + ) diff --git a/setup.cfg b/setup.cfg index 7b34c3a..517ac1d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.1.16 +current_version = 1.1.17 commit = True tag = True diff --git a/setup.py b/setup.py index de0b18a..953c8fe 100644 --- a/setup.py +++ b/setup.py @@ -3,42 +3,42 @@ """The setup script.""" -from setuptools import setup, find_packages +from setuptools import find_packages, setup -with open('README.rst') as readme_file: +with open("README.rst") as readme_file: readme = readme_file.read() -with open('HISTORY.rst') as history_file: +with open("HISTORY.rst") as history_file: history = history_file.read() -requirements = ['Click>=6.0', 'requests>=2.21.0', 'packaging>=19.1'] +requirements = ["Click>=6.0", "requests>=2.21.0", "packaging>=19.1"] -setup_requirements = [ ] +setup_requirements = [] -test_requirements = [ ] +test_requirements = [] setup( author="Finbarr Brady", - author_email='fbradyirl@github.io', + author_email="fbradyirl@github.io", classifiers=[ - 'Development Status :: 2 - Pre-Alpha', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: Apache Software License', - 'Natural Language :: English', - 'Programming Language :: Python :: 3.7', + "Development Status :: 2 - Pre-Alpha", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Natural Language :: English", + "Programming Language :: Python :: 3.7", ], description="Module for interacting with OpenWrt Luci RPC interface", install_requires=requirements, license="Apache Software License 2.0", - long_description=readme + '\n\n' + history, + long_description=readme + "\n\n" + history, include_package_data=True, - keywords='openwrt-luci-rpc', - name='openwrt-luci-rpc', - packages=find_packages(include=['openwrt_luci_rpc']), + keywords="openwrt-luci-rpc", + name="openwrt-luci-rpc", + packages=find_packages(include=["openwrt_luci_rpc"]), setup_requires=setup_requirements, - test_suite='tests', + test_suite="tests", tests_require=test_requirements, - url='https://github.com/fbradyirl/openwrt-luci-rpc', - version='1.1.16', + url="https://github.com/fbradyirl/openwrt-luci-rpc", + version="1.1.17", zip_safe=False, ) diff --git a/tests/test_openwrt_60.py b/tests/test_openwrt_60.py index 3650eab..ea327ab 100644 --- a/tests/test_openwrt_60.py +++ b/tests/test_openwrt_60.py @@ -21,16 +21,18 @@ def tearDown(self): def test_get_hostname_from_dhcp_mac_list_formating(self): """Test if lower case list of MAC match with Upper case.""" - data = [{ - ".name": "cfg07ee1", - ".type": "host", - "name": "imac-ethernet", - ".index": 4, - "mac": ["c8:2a:10:4a:10:dd"], - "dns": "1", - ".anonymous": True, - "ip": "192.168.1.124" - }] + data = [ + { + ".name": "cfg07ee1", + ".type": "host", + "name": "imac-ethernet", + ".index": 4, + "mac": ["c8:2a:10:4a:10:dd"], + "dns": "1", + ".anonymous": True, + "ip": "192.168.1.124", + } + ] data = utilities.get_hostname_from_dhcp(data, "C8:2A:10:4A:10:DD") assert data is None @@ -38,33 +40,37 @@ def test_get_hostname_from_dhcp_mac_list_formating(self): def test_get_hostname_from_dhcp_mac_string_formating(self): """Test if lower case string of MAC match with Upper case.""" - data = [{ - ".name": "cfg07ee1", - ".type": "host", - "name": "imac-ethernet", - ".index": 4, - "mac": "c8:2a:10:4a:10:dd", - "dns": "1", - ".anonymous": True, - "ip": "192.168.1.124" - }] + data = [ + { + ".name": "cfg07ee1", + ".type": "host", + "name": "imac-ethernet", + ".index": 4, + "mac": "c8:2a:10:4a:10:dd", + "dns": "1", + ".anonymous": True, + "ip": "192.168.1.124", + } + ] data = utilities.get_hostname_from_dhcp(data, "C8:2A:10:4A:10:DD") assert data is None def test_get_hostname_from_dhcp_multiple_mac_string_formating(self): - """Test if lower case string of MAC match with Upper case of multi mac list.""" - - data = [{ - ".name": "cfg07ee1", - ".type": "host", - "name": "imac-ethernet", - ".index": 4, - "mac": {"c8:2a:10:4a:10:d9","c8:2a:10:4a:10:dd"}, - "dns": "1", - ".anonymous": True, - "ip": "192.168.1.124" - }] + """Test if lower case string of MAC match with Upper case of multi mac list.""" # noqa: E501python setup.py test + + data = [ + { + ".name": "cfg07ee1", + ".type": "host", + "name": "imac-ethernet", + ".index": 4, + "mac": {"c8:2a:10:4a:10:d9", "c8:2a:10:4a:10:dd"}, + "dns": "1", + ".anonymous": True, + "ip": "192.168.1.124", + } + ] data = utilities.get_hostname_from_dhcp(data, "C8:2A:10:4A:10:DD") assert data is None