Skip to content

Commit

Permalink
small updates to the check script
Browse files Browse the repository at this point in the history
  • Loading branch information
prusnak committed Dec 22, 2023
1 parent ad95404 commit 7f16c7e
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions check.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from PIL import Image

EXTENSIONS_FILE = "extensions.json"
UNPACK_ZIP_CONTENTS = False
CHECK_ZIP_CONTENTS = True
UNPACK_ZIP_CONTENTS = False

MANDATORY_FILES = [
"LICENSE",
Expand All @@ -20,12 +20,14 @@
"manifest.json",
]

# set to True to enable caching of downloaded files, useful for debug
CACHE_DOWNLOADS = False
if CACHE_DOWNLOADS:
try:
# use requests_cache if installed, useful for subsequent runs of check
# so we the files are not downloaded again and again
import requests_cache

requests_cache.install_cache("lnbits-extensions-cache")
requests_cache.install_cache("lnbits-extensions-download-cache")
except ImportError:
pass


def get_remote_file(url):
Expand Down Expand Up @@ -67,7 +69,7 @@ def validate(self) -> (bool, str):
return False, "archive URL does not start with repo URL"
if not self.archive.endswith(f"{self.version}.zip"):
bn = basename(self.archive)
return False, "archive name '{bn}' doesn't end with {self.version}.zip"
return False, f"archive name '{bn}' doesn't end with {self.version}.zip"

# print archive info from json
archive_hash, archive_zip = get_remote_zip(self.archive)
Expand Down Expand Up @@ -96,10 +98,8 @@ def validate(self) -> (bool, str):
"bleskomat",
"deezy",
"discordbot",
"hivemind",
"livestream",
"market",
"nostrnip5",
"paywall",
"smtp",
"streamalerts",
Expand Down Expand Up @@ -141,14 +141,17 @@ def validate(self) -> (bool, str):
min_lnbits_version = config.get("min_lnbits_version")
print(f"- min_lnbits_version : {min_lnbits_version}")
if min_lnbits_version != self.min_lnbits_version:
return False, f"min_lnbits_version mismatch: {min_lnbits_version} != {self.min_lnbits_version}"
return (
False,
f"min_lnbits_version mismatch: {min_lnbits_version} != {self.min_lnbits_version}",
)

# check icon
try:
icon = get_remote_file(self.icon)
img = Image.open(BytesIO(icon))
print(f"- icon : OK {img.size[0]}x{img.size[1]} @ {img.mode} ({self.icon})")
except Exception as ex:
except Exception:
print(f"- icon : broken ({self.icon})")
return False, f"broken icon ({self.icon})"

Expand Down

0 comments on commit 7f16c7e

Please sign in to comment.