tinytoolslib 0.3.4__tar.gz → 0.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tinytoolslib-0.3.4 → tinytoolslib-0.4.1}/PKG-INFO +3 -3
- {tinytoolslib-0.3.4 → tinytoolslib-0.4.1}/pyproject.toml +2 -2
- tinytoolslib-0.4.1/tinytoolslib/__version__.py +1 -0
- {tinytoolslib-0.3.4 → tinytoolslib-0.4.1}/tinytoolslib/flash.py +23 -18
- {tinytoolslib-0.3.4 → tinytoolslib-0.4.1}/tinytoolslib/models.py +13 -8
- {tinytoolslib-0.3.4 → tinytoolslib-0.4.1}/tinytoolslib.egg-info/PKG-INFO +3 -3
- {tinytoolslib-0.3.4 → tinytoolslib-0.4.1}/tinytoolslib.egg-info/top_level.txt +1 -0
- tinytoolslib-0.3.4/tinytoolslib/__version__.py +0 -1
- {tinytoolslib-0.3.4 → tinytoolslib-0.4.1}/README.md +0 -0
- {tinytoolslib-0.3.4 → tinytoolslib-0.4.1}/setup.cfg +0 -0
- {tinytoolslib-0.3.4 → tinytoolslib-0.4.1}/tinytoolslib/__init__.py +0 -0
- {tinytoolslib-0.3.4 → tinytoolslib-0.4.1}/tinytoolslib/constants.py +0 -0
- {tinytoolslib-0.3.4 → tinytoolslib-0.4.1}/tinytoolslib/discovery.py +0 -0
- {tinytoolslib-0.3.4 → tinytoolslib-0.4.1}/tinytoolslib/exceptions.py +0 -0
- {tinytoolslib-0.3.4 → tinytoolslib-0.4.1}/tinytoolslib/parsers.py +0 -0
- {tinytoolslib-0.3.4 → tinytoolslib-0.4.1}/tinytoolslib/requests.py +0 -0
- {tinytoolslib-0.3.4 → tinytoolslib-0.4.1}/tinytoolslib.egg-info/SOURCES.txt +0 -0
- {tinytoolslib-0.3.4 → tinytoolslib-0.4.1}/tinytoolslib.egg-info/dependency_links.txt +0 -0
- {tinytoolslib-0.3.4 → tinytoolslib-0.4.1}/tinytoolslib.egg-info/requires.txt +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: tinytoolslib
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.1
|
|
4
4
|
Summary: Set of tools for use with Tinycontrol devices like LK2.X, LK3.X, LK4.X or tcPDU.
|
|
5
5
|
Author-email: Bartek Barszczewski <tinycontrol.software@gmail.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
6
7
|
Keywords: tinycontrol,lk,tcpdu
|
|
7
8
|
Classifier: Programming Language :: Python :: 3
|
|
8
9
|
Classifier: Operating System :: OS Independent
|
|
9
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
10
|
Requires-Python: >=3.7
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
12
|
Requires-Dist: aiohttp<4,>=3.9.3
|
|
@@ -4,16 +4,16 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "tinytoolslib"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.4.1"
|
|
8
8
|
authors = [
|
|
9
9
|
{ name="Bartek Barszczewski", email="tinycontrol.software@gmail.com" },
|
|
10
10
|
]
|
|
11
|
+
license = "Apache-2.0"
|
|
11
12
|
description = "Set of tools for use with Tinycontrol devices like LK2.X, LK3.X, LK4.X or tcPDU."
|
|
12
13
|
requires-python = ">=3.7"
|
|
13
14
|
classifiers = [
|
|
14
15
|
"Programming Language :: Python :: 3",
|
|
15
16
|
"Operating System :: OS Independent",
|
|
16
|
-
"License :: OSI Approved :: Apache Software License",
|
|
17
17
|
]
|
|
18
18
|
dependencies = [
|
|
19
19
|
"aiohttp >= 3.9.3, < 4",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '0.4.1'
|
|
@@ -276,9 +276,10 @@ class Flasher:
|
|
|
276
276
|
self,
|
|
277
277
|
firmware_path: str,
|
|
278
278
|
host: str,
|
|
279
|
-
username: str,
|
|
280
|
-
password: str,
|
|
281
279
|
port: int = 80,
|
|
280
|
+
schema: str = "http",
|
|
281
|
+
username: str = "",
|
|
282
|
+
password: str = "",
|
|
282
283
|
callback_progress: Union[Callable[[int, int, float, str], None], None] = None,
|
|
283
284
|
callback_cancel: Union[Callable[[], bool], None] = None,
|
|
284
285
|
) -> bool:
|
|
@@ -295,17 +296,14 @@ class Flasher:
|
|
|
295
296
|
and os.path.isfile(firmware_path)
|
|
296
297
|
):
|
|
297
298
|
with self._session:
|
|
298
|
-
# Try to
|
|
299
|
-
#
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
port = 443
|
|
307
|
-
else:
|
|
308
|
-
schema = "http"
|
|
299
|
+
# Try to get device version. Note that get_version may return
|
|
300
|
+
# different port and schema than given ones, eg. for http:80,
|
|
301
|
+
# may return http:80 or https:443.
|
|
302
|
+
# It also assumes that lk4/tcpdu always respond via HTTP.
|
|
303
|
+
version_info = get_version(host, port, schema, username, password)
|
|
304
|
+
if version_info and "network_info" in version_info:
|
|
305
|
+
schema = version_info["network_info"]["schema"]
|
|
306
|
+
port = version_info["network_info"]["port"]
|
|
309
307
|
if (
|
|
310
308
|
version_info
|
|
311
309
|
and version_info.get("fw_update_method") == FWUpdateMethod.HTTP
|
|
@@ -347,7 +345,12 @@ def check_for_latest_firmware(fw_url: str) -> Tuple[bool, Union[Dict[str, Any],
|
|
|
347
345
|
|
|
348
346
|
|
|
349
347
|
def get_latest_firmware(
|
|
350
|
-
host: str,
|
|
348
|
+
host: str,
|
|
349
|
+
port: int,
|
|
350
|
+
schema: str,
|
|
351
|
+
username: str,
|
|
352
|
+
password: str,
|
|
353
|
+
firmware_directory: str,
|
|
351
354
|
) -> Tuple[bool, Union[Dict[str, Any], str]]:
|
|
352
355
|
"""Get latest firmware for device.
|
|
353
356
|
|
|
@@ -355,7 +358,7 @@ def get_latest_firmware(
|
|
|
355
358
|
(True, {**get_version(), path: str, new_sw: str})
|
|
356
359
|
(False, str) - str is an error message
|
|
357
360
|
"""
|
|
358
|
-
version_info = get_version(host, username=username, password=password)
|
|
361
|
+
version_info = get_version(host, port, schema, username=username, password=password)
|
|
359
362
|
if version_info:
|
|
360
363
|
latest_version = check_for_latest_firmware(version_info.get("fw_url"))
|
|
361
364
|
if latest_version[0]:
|
|
@@ -398,9 +401,10 @@ def download_firmware(download_url: str, save_location: str) -> bool:
|
|
|
398
401
|
def run_flash(
|
|
399
402
|
firmware_path: str,
|
|
400
403
|
host: str,
|
|
401
|
-
username: str,
|
|
402
|
-
password: str,
|
|
403
404
|
port: int = 80,
|
|
405
|
+
schema: str = "http",
|
|
406
|
+
username: str = "",
|
|
407
|
+
password: str = "",
|
|
404
408
|
callback_progress: Union[Callable[[int, int, float, str], None], None] = None,
|
|
405
409
|
callback_cancel: Union[Callable[[], bool], None] = None,
|
|
406
410
|
) -> bool:
|
|
@@ -409,9 +413,10 @@ def run_flash(
|
|
|
409
413
|
return flasher.run(
|
|
410
414
|
firmware_path,
|
|
411
415
|
host,
|
|
416
|
+
port,
|
|
417
|
+
schema,
|
|
412
418
|
username,
|
|
413
419
|
password,
|
|
414
|
-
port,
|
|
415
420
|
callback_progress,
|
|
416
421
|
callback_cancel,
|
|
417
422
|
)
|
|
@@ -1242,6 +1242,10 @@ class LK_HW_40(DeviceModel):
|
|
|
1242
1242
|
"netMac": {"name": "mac", "format": str},
|
|
1243
1243
|
"softwareVersion": {"name": "software_version", "format": str},
|
|
1244
1244
|
"hardwareVersion": {"name": "hardware_version", "format": str},
|
|
1245
|
+
"pm1": {"name": "pm1.0", "format": float},
|
|
1246
|
+
"pm2": {"name": "pm2.5", "format": float},
|
|
1247
|
+
"pm4": {"name": "pm4.0", "format": float},
|
|
1248
|
+
"pm10": {"name": "pm10.0", "format": float},
|
|
1245
1249
|
}
|
|
1246
1250
|
parsers: ClassVar[List[str]] = ["_parse_outs"]
|
|
1247
1251
|
|
|
@@ -1630,7 +1634,7 @@ def _get_version_initial(
|
|
|
1630
1634
|
exc: Exception, schema: str, port: int, silent: bool
|
|
1631
1635
|
) -> Tuple[str, str, int]:
|
|
1632
1636
|
"""Handle first response in get_version - prepare data for second request."""
|
|
1633
|
-
|
|
1637
|
+
path = ""
|
|
1634
1638
|
try:
|
|
1635
1639
|
raise exc
|
|
1636
1640
|
except TinyToolsRequestNotFound:
|
|
@@ -1658,6 +1662,7 @@ def _get_version_initial(
|
|
|
1658
1662
|
def get_version(
|
|
1659
1663
|
host: str,
|
|
1660
1664
|
port: int = 80,
|
|
1665
|
+
schema: str = "http",
|
|
1661
1666
|
username: str = "",
|
|
1662
1667
|
password: str = "",
|
|
1663
1668
|
with_info: bool = True,
|
|
@@ -1666,15 +1671,14 @@ def get_version(
|
|
|
1666
1671
|
) -> Union[Dict[str, Any], None]:
|
|
1667
1672
|
"""Query device for version and optionally device model.
|
|
1668
1673
|
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
TODO: Might add schema parameter so it would work to handle proxy.
|
|
1674
|
+
To work with https on port different than 443, schema has to be set to https.
|
|
1675
|
+
Normally LK always uses port 443 for https.
|
|
1672
1676
|
"""
|
|
1673
1677
|
response = None
|
|
1674
1678
|
try:
|
|
1675
|
-
response = get(host, "/st2.xml",
|
|
1679
|
+
response = get(host, "/st2.xml", schema, port, username, password)
|
|
1676
1680
|
except TinyToolsRequestError as exc:
|
|
1677
|
-
path, schema, port = _get_version_initial(exc,
|
|
1681
|
+
path, schema, port = _get_version_initial(exc, schema, port, silent)
|
|
1678
1682
|
if path:
|
|
1679
1683
|
response = get(host, path, schema, port, username, password, silent=silent)
|
|
1680
1684
|
return _get_version(
|
|
@@ -1685,6 +1689,7 @@ def get_version(
|
|
|
1685
1689
|
async def async_get_version(
|
|
1686
1690
|
host: str,
|
|
1687
1691
|
port: int = 80,
|
|
1692
|
+
schema: str = "http",
|
|
1688
1693
|
username: str = "",
|
|
1689
1694
|
password: str = "",
|
|
1690
1695
|
with_info: bool = True,
|
|
@@ -1695,10 +1700,10 @@ async def async_get_version(
|
|
|
1695
1700
|
response = None
|
|
1696
1701
|
try:
|
|
1697
1702
|
response = await async_get(
|
|
1698
|
-
host, "/st2.xml",
|
|
1703
|
+
host, "/st2.xml", schema, port, username, password, session=session
|
|
1699
1704
|
)
|
|
1700
1705
|
except TinyToolsRequestError as exc:
|
|
1701
|
-
path, schema, port = _get_version_initial(exc,
|
|
1706
|
+
path, schema, port = _get_version_initial(exc, schema, port, silent)
|
|
1702
1707
|
if path:
|
|
1703
1708
|
response = await async_get(
|
|
1704
1709
|
host,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: tinytoolslib
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.1
|
|
4
4
|
Summary: Set of tools for use with Tinycontrol devices like LK2.X, LK3.X, LK4.X or tcPDU.
|
|
5
5
|
Author-email: Bartek Barszczewski <tinycontrol.software@gmail.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
6
7
|
Keywords: tinycontrol,lk,tcpdu
|
|
7
8
|
Classifier: Programming Language :: Python :: 3
|
|
8
9
|
Classifier: Operating System :: OS Independent
|
|
9
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
10
|
Requires-Python: >=3.7
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
12
|
Requires-Dist: aiohttp<4,>=3.9.3
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '0.3.4'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|