Skip to content

Commit

Permalink
Rename get_info() to firmware_info()
Browse files Browse the repository at this point in the history
  • Loading branch information
AT0myks committed Dec 21, 2023
1 parent 5508bdc commit 18b7c69
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,11 @@ You should not use it to repack a custom firmware.

```py
import asyncio
from reolinkfw import ReolinkFirmware, get_info
from reolinkfw import ReolinkFirmware, firmware_info

async def main():
url = "https://reolink-storage.s3.amazonaws.com/website/firmware/20200523firmware/RLC-410-5MP_20_20052300.zip"
print(await get_info(url))
print(await firmware_info(url))
pak = "/home/ben/RLC-410-5MP_20_20052300.pak"
with ReolinkFirmware.from_file(pak) as fw:
print(await fw.get_info())
Expand Down Expand Up @@ -210,7 +210,7 @@ There are 3 types of file systems used for Reolink firmwares:
- [squashfs](https://www.kernel.org/doc/html/latest/filesystems/squashfs.html) (handled by [PySquashfsImage](https://github.com/matteomattei/PySquashfsImage))
- [UBIFS](https://www.kernel.org/doc/html/latest/filesystems/ubifs.html) (handled by [ubi_reader](https://github.com/jrspruitt/ubi_reader))

Some ZIP files provided by Reolink contain multiple PAKs. This is why `get_info`
Some ZIP files provided by Reolink contain multiple PAKs. This is why `firmware_info`
always returns a list.

Here's a map of vendors to hardware versions:
Expand Down
2 changes: 1 addition & 1 deletion reolinkfw/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ async def firmwares_from_file(file_or_url: StrPathURL, use_cache: bool = True) -
raise Exception("Not a URL or file")


async def get_info(file_or_url: StrPathURL, use_cache: bool = True) -> list[dict[str, Any]]:
async def firmware_info(file_or_url: StrPathURL, use_cache: bool = True) -> list[dict[str, Any]]:
"""Retrieve firmware info from an on-disk file or a URL.
The file or resource may be a ZIP or a PAK.
Expand Down
10 changes: 5 additions & 5 deletions reolinkfw/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
from datetime import datetime
from pathlib import Path, PurePath

from reolinkfw import __version__, firmwares_from_file, get_info
from reolinkfw import __version__, firmware_info, firmwares_from_file

HW_FIELDS = ("board_type", "detail_machine_type", "board_name")


async def info(args: Namespace) -> None:
pak_infos = await get_info(args.file_or_url, not args.no_cache)
pak_infos = await firmware_info(args.file_or_url, not args.no_cache)
if args.json is None:
width = 21
for idx, info in enumerate(pak_infos):
Expand Down Expand Up @@ -55,9 +55,9 @@ async def extract(args: Namespace) -> None:
raise Exception("No PAKs found in ZIP file")
dest = Path.cwd() if args.dest is None else args.dest
for pakname, fw in fws:
name = fw.sha256() if pakname is None else PurePath(pakname).stem
await asyncio.to_thread(fw.extract, dest / name, args.force)
fw.close()
with fw:
name = fw.sha256() if pakname is None else PurePath(pakname).stem
await asyncio.to_thread(fw.extract, dest / name, args.force)


def main() -> None:
Expand Down

0 comments on commit 18b7c69

Please sign in to comment.