Skip to content

Commit

Permalink
adding fallback method to other update cli
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Feb 5, 2025
1 parent 0d81f16 commit 33c2f17
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions pioreactor/cli/pios.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,20 @@ def _thread_function(unit: str) -> tuple[bool, dict]:
r.raise_for_status()
return True, r.json()
except HTTPException as e:
logger.error(f"Unable to update app on {unit} due to server error: {e}.")
logger.error(f"Unable to update on {unit} due to server error: {e}. Attempting SSH method...")
try:
args: str
if source is not None:
args = f"--source {source}"
elif branch is not None:
args = f"--branch {branch}"
elif version is not None:
args = f"--version {version}"

ssh(resolve_to_address(unit), f"pio update app {args}")
return True, {"unit": unit}
except SSHError as e:
logger.error(f"Unable to update on {unit} due to SSH error: {e}.")
return False, {"unit": unit}

with ThreadPoolExecutor(max_workers=len(units)) as executor:
Expand Down Expand Up @@ -450,7 +463,20 @@ def _thread_function(unit: str) -> tuple[bool, dict]:
r.raise_for_status()
return True, r.json()
except HTTPException as e:
logger.error(f"Unable to update ui on {unit} due to server error: {e}.")
logger.error(f"Unable to update on {unit} due to server error: {e}. Attempting SSH method...")
try:
args: str
if source is not None:
args = f"--source {source}"
elif branch is not None:
args = f"--branch {branch}"
elif version is not None:
args = f"--version {version}"

ssh(resolve_to_address(unit), f"pio update ui {args}")
return True, {"unit": unit}
except SSHError as e:
logger.error(f"Unable to update on {unit} due to SSH error: {e}.")
return False, {"unit": unit}

with ThreadPoolExecutor(max_workers=len(units)) as executor:
Expand Down

0 comments on commit 33c2f17

Please sign in to comment.