hound fixes, checks for missing files

This commit is contained in:
Ondrej Samohel 2021-08-13 18:18:57 +02:00 committed by Ondřej Samohel
parent b4a3038623
commit b6d8310457
No known key found for this signature in database
GPG key ID: 02376E18990A97C6
2 changed files with 17 additions and 10 deletions

View file

@ -546,7 +546,7 @@ class BootstrapRepos:
# test if zip is ok
zip_file.testzip()
self._progress_callback(100)
def validate_openpype_version(self, path: Path) -> tuple:
"""Validate version directory or zip file.
@ -558,13 +558,13 @@ class BootstrapRepos:
path (Path): Path to OpenPype version to validate.
Returns:
tuple(bool, str): with version validity as first item and string with
reason as second.
tuple(bool, str): with version validity as first item
and string with reason as second.
"""
if not path.exists():
return False, "Path doesn't exist"
if path.is_file():
return self._validate_zip(path)
return self._validate_dir(path)
@ -589,7 +589,10 @@ class BootstrapRepos:
# calculate and compare checksums in the zip file
for file in checksums:
h = hashlib.sha256()
h.update(zip_file.read(file[1]))
try:
h.update(zip_file.read(file[1]))
except FileNotFoundError:
return False, f"Missing file [ {file[1]} ]"
if h.hexdigest() != file[0]:
return False, f"Invalid checksum on {file[1]}"
@ -627,7 +630,11 @@ class BootstrapRepos:
files_in_checksum = set([file[1] for file in checksums])
for file in checksums:
current = sha256sum((path / file[1]).as_posix())
try:
current = sha256sum((path / file[1]).as_posix())
except FileNotFoundError:
return False, f"Missing file [ {file[1]} ]"
if file[0] != current:
return False, f"Invalid checksum on {file[1]}"
diff = files_in_dir.difference(files_in_checksum)

View file

@ -182,7 +182,7 @@ else:
if "--headless" in sys.argv:
os.environ["OPENPYPE_HEADLESS_MODE"] = "1"
import igniter # noqa: E402
import igniter # noqa: E402
from igniter import BootstrapRepos # noqa: E402
from igniter.tools import (
get_openpype_path_from_db,
@ -797,8 +797,7 @@ def boot():
openpype_versions = bootstrap.find_openpype(include_zips=True,
staging=True)
openpype_versions += bootstrap.find_openpype(include_zips=True,
staging=False)
staging=False)
v: OpenPypeVersion
found = [v for v in openpype_versions if str(v) == use_version]
if not found:
@ -814,7 +813,8 @@ def boot():
_print("{}{}".format(
">>> " if result[0] else "!!! ",
bootstrap.validate_openpype_version(
bootstrap.get_version_path_from_list(use_version, openpype_versions)
bootstrap.get_version_path_from_list(
use_version, openpype_versions)
)[1])
)
sys.exit(1)