Sync branch magefile with main #104308

Merged
Sybren A. Stüvel merged 85 commits from abelli/flamenco:magefile into magefile 2024-05-13 16:26:32 +02:00
3 changed files with 43 additions and 46 deletions
Showing only changes of commit 68ac3c03e3 - Show all commits

View File

@ -286,12 +286,12 @@ class Transferrer(submodules.transfer.FileTransferer): # type: ignore
return None
self.log.debug(" %s: %s", file_spec.status, file_spec.path)
match file_spec.status.value:
case "unknown":
status = file_spec.status.value
if status == "unknown":
to_upload.appendleft(file_spec)
case "uploading":
elif status == "uploading":
to_upload.append(file_spec)
case _:
else:
msg = "Unknown status in response from Shaman: %r" % file_spec
self.log.error(msg)
self.error_set(msg)
@ -375,21 +375,22 @@ class Transferrer(submodules.transfer.FileTransferer): # type: ignore
x_shaman_original_filename=file_spec.path,
)
except ApiException as ex:
match ex.status:
case 425: # Too Early, i.e. defer uploading this file.
if ex.status == 425:
# Too Early, i.e. defer uploading this file.
self.log.info(
" %s: someone else is uploading this file, deferring",
file_spec.path,
)
defer(file_spec)
continue
case 417: # Expectation Failed; mismatch of checksum or file size.
elif ex.status == 417:
# Expectation Failed; mismatch of checksum or file size.
msg = "Error from Shaman uploading %s, code %d: %s" % (
file_spec.path,
ex.status,
ex.body,
)
case _: # Unknown error
else: # Unknown error
msg = "API exception\nHeaders: %s\nBody: %s\n" % (
ex.headers,
ex.body,
@ -453,15 +454,11 @@ class Transferrer(submodules.transfer.FileTransferer): # type: ignore
checkoutRequest
)
except ApiException as ex:
match ex.status:
case 424: # Files were missing
if ex.status == 424: # Files were missing
msg = "We did not upload some files, checkout aborted"
case 409: # Checkout already exists
msg = (
"There is already an existing checkout at %s"
% self.checkout_path
)
case _: # Unknown error
elif ex.status == 409: # Checkout already exists
msg = "There is already an existing checkout at %s" % self.checkout_path
else: # Unknown error
msg = "API exception\nHeaders: %s\nBody: %s\n" % (
ex.headers,
ex.body,

View File

@ -5,7 +5,7 @@ import dataclasses
import json
import platform
from pathlib import Path
from typing import TYPE_CHECKING, Optional
from typing import TYPE_CHECKING, Optional, Union
from urllib3.exceptions import HTTPError, MaxRetryError
@ -133,7 +133,7 @@ def _to_json(info: ManagerInfo) -> str:
return json.dumps(info, indent=" ", cls=Encoder)
def _from_json(contents: str | bytes) -> ManagerInfo:
def _from_json(contents: Union[str, bytes]) -> ManagerInfo:
# Do a late import, so that the API is only imported when actually used.
from flamenco.manager.configuration import Configuration
from flamenco.manager.model_utils import validate_and_convert_types

View File

@ -2,7 +2,7 @@
# <pep8 compliant>
from pathlib import Path
from typing import Callable, TypeAlias
from typing import Callable
import dataclasses
from .bat.submodules import bpathlib
@ -64,7 +64,7 @@ def _search_path_marker(blendfile: Path, marker_path: str) -> Path:
return blendfile_dir
Finder: TypeAlias = Callable[[Path], Path]
Finder = Callable[[Path], Path]
@dataclasses.dataclass