try{300,301,400}: fix
This commit is contained in:
@@ -539,11 +539,11 @@ def main() -> None:
|
||||
|
||||
try:
|
||||
args.func(args)
|
||||
except ClanError as e:
|
||||
except ClanError:
|
||||
if debug:
|
||||
log.exception("Exited with error")
|
||||
else:
|
||||
log.error("%s", e)
|
||||
log.exception("Exited with error")
|
||||
sys.exit(1)
|
||||
except KeyboardInterrupt as ex:
|
||||
log.warning("Interrupted by user", exc_info=ex)
|
||||
|
||||
@@ -71,7 +71,7 @@ def create_clan(opts: CreateOptions) -> None:
|
||||
try:
|
||||
nix_metadata(str(opts.src_flake))
|
||||
except ClanError:
|
||||
log.error(
|
||||
log.exception(
|
||||
f"Found a repository, but it is not a valid flake: {opts.src_flake}",
|
||||
)
|
||||
log.warning("Setting src_flake to None")
|
||||
|
||||
@@ -45,7 +45,6 @@ def check_machine_ssh_login(
|
||||
["true"],
|
||||
RunOpts(timeout=opts.timeout, needs_user_terminal=True),
|
||||
)
|
||||
return
|
||||
except ClanCmdTimeoutError as e:
|
||||
msg = f"SSH login timeout after {opts.timeout}s"
|
||||
raise ClanError(msg) from e
|
||||
@@ -54,6 +53,8 @@ def check_machine_ssh_login(
|
||||
raise ClanError(e.cmd.stderr.strip()) from e
|
||||
msg = f"SSH login failed: {e}"
|
||||
raise ClanError(msg) from e
|
||||
else:
|
||||
return
|
||||
|
||||
|
||||
@API.register
|
||||
|
||||
@@ -158,15 +158,15 @@ def read_qr_image(image_path: Path) -> dict[str, Any]:
|
||||
try:
|
||||
res = run(cmd)
|
||||
data = res.stdout.strip()
|
||||
|
||||
if not data:
|
||||
msg = f"No QR code found in image: {image_path}"
|
||||
raise ClanError(msg)
|
||||
|
||||
return json.loads(data)
|
||||
except json.JSONDecodeError as e:
|
||||
msg = f"Invalid JSON in QR code: {e}"
|
||||
raise ClanError(msg) from e
|
||||
except Exception as e:
|
||||
except OSError as e:
|
||||
msg = f"Failed to read QR code from {image_path}: {e}"
|
||||
raise ClanError(msg) from e
|
||||
|
||||
if not data:
|
||||
msg = f"No QR code found in image: {image_path}"
|
||||
raise ClanError(msg)
|
||||
|
||||
return json.loads(data)
|
||||
|
||||
@@ -82,14 +82,14 @@ class SudoAskpassProxy:
|
||||
prompt = stripped_line[len("PASSWORD_REQUESTED:") :].strip()
|
||||
password = self.handle_password_request(prompt)
|
||||
if ssh_process.stdin is None:
|
||||
msg = "SSH process stdin is None"
|
||||
raise ClanError(msg)
|
||||
logger.error("SSH process stdin is None")
|
||||
return
|
||||
print(password, file=ssh_process.stdin)
|
||||
ssh_process.stdin.flush()
|
||||
else:
|
||||
print(stripped_line)
|
||||
except (OSError, ClanError) as e:
|
||||
logger.error(f"Error processing passwords requests output: {e}")
|
||||
except (OSError, ClanError):
|
||||
logger.exception("Error processing passwords requests output")
|
||||
|
||||
def run(self) -> str:
|
||||
"""Run the SSH command with password proxying. Returns the askpass script path."""
|
||||
|
||||
@@ -89,8 +89,8 @@ def machine_template(
|
||||
|
||||
try:
|
||||
yield dst_machine_dir
|
||||
except Exception as e:
|
||||
log.error(f"An error occurred inside the 'machine_template' context: {e}")
|
||||
except Exception:
|
||||
log.exception("An error occurred inside the 'machine_template' context")
|
||||
|
||||
# Ensure that the directory is removed to avoid half-created machines
|
||||
# Everything in the with block is considered part of the context
|
||||
@@ -182,7 +182,7 @@ def clan_template(
|
||||
try:
|
||||
post_process(dst_dir)
|
||||
except Exception as e:
|
||||
log.error(f"Error during post-processing of clan template: {e}")
|
||||
log.exception("Error during post-processing of clan template")
|
||||
log.info(f"Removing left-over directory: {dst_dir}")
|
||||
shutil.rmtree(dst_dir, ignore_errors=True)
|
||||
msg = (
|
||||
@@ -191,8 +191,8 @@ def clan_template(
|
||||
raise ClanError(msg) from e
|
||||
try:
|
||||
yield dst_dir
|
||||
except Exception as e:
|
||||
log.error(f"An error occurred inside the 'clan_template' context: {e}")
|
||||
except Exception:
|
||||
log.exception("An error occurred inside the 'clan_template' context")
|
||||
log.info(f"Removing left-over directory: {dst_dir}")
|
||||
shutil.rmtree(dst_dir, ignore_errors=True)
|
||||
raise
|
||||
|
||||
Reference in New Issue
Block a user