Skip to content

Commit

Permalink
Fixed file not being closed()
Browse files Browse the repository at this point in the history
  • Loading branch information
tadeubas committed Dec 9, 2024
1 parent e031d6d commit 49705bb
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/krux/pages/kapps.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,13 @@ def _parse_all_flash_apps(self):
if file.endswith(MPY_FILE_EXTENSION):

Check warning on line 72 in src/krux/pages/kapps.py

View check run for this annotation

Codecov / codecov/patch

src/krux/pages/kapps.py#L68-L72

Added lines #L68 - L72 were not covered by tests
# Check if signature file exists for the .mpy file
try:
sig_data = open(
flash_path_prefix + file + SIGNATURE_FILE_EXTENSION, "rb"
).read()
sig_data = None
with open(

Check warning on line 76 in src/krux/pages/kapps.py

View check run for this annotation

Codecov / codecov/patch

src/krux/pages/kapps.py#L74-L76

Added lines #L74 - L76 were not covered by tests
flash_path_prefix + file + SIGNATURE_FILE_EXTENSION,
"rb",
buffering=0,
) as sigfile:
sig_data = sigfile.read()
if self._valid_signature(

Check warning on line 82 in src/krux/pages/kapps.py

View check run for this annotation

Codecov / codecov/patch

src/krux/pages/kapps.py#L81-L82

Added lines #L81 - L82 were not covered by tests
sig_data, sha256(flash_path_prefix + file)
):
Expand Down Expand Up @@ -196,9 +200,10 @@ def load_sd_kapp(self): # pylint: disable=R1710
# Check signature of .mpy file in SD
sig_data = None
try:
sig_data = open(
sd_path_prefix + filename + SIGNATURE_FILE_EXTENSION, "rb"
).read()
with open(

Check warning on line 203 in src/krux/pages/kapps.py

View check run for this annotation

Codecov / codecov/patch

src/krux/pages/kapps.py#L201-L203

Added lines #L201 - L203 were not covered by tests
sd_path_prefix + filename + SIGNATURE_FILE_EXTENSION, "rb", buffering=0
) as sigfile:
sig_data = sigfile.read()
except:
self.flash_error(t("Missing signature file"))
return MENU_CONTINUE

Check warning on line 209 in src/krux/pages/kapps.py

View check run for this annotation

Codecov / codecov/patch

src/krux/pages/kapps.py#L206-L209

Added lines #L206 - L209 were not covered by tests
Expand Down Expand Up @@ -242,6 +247,7 @@ def load_sd_kapp(self): # pylint: disable=R1710
with open(

Check warning on line 247 in src/krux/pages/kapps.py

View check run for this annotation

Codecov / codecov/patch

src/krux/pages/kapps.py#L247

Added line #L247 was not covered by tests
flash_path_prefix + filename + SIGNATURE_FILE_EXTENSION,
"wb",
buffering=0,
) as kapp_sig_file:
kapp_sig_file.write(sig_data)

Check warning on line 252 in src/krux/pages/kapps.py

View check run for this annotation

Codecov / codecov/patch

src/krux/pages/kapps.py#L252

Added line #L252 was not covered by tests

Expand Down

0 comments on commit 49705bb

Please sign in to comment.