Skip to content

Instantly share code, notes, and snippets.

@grahamc
Created March 9, 2020 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grahamc/a64bab1c569c9b331e6664c19c8418b0 to your computer and use it in GitHub Desktop.
Save grahamc/a64bab1c569c9b331e6664c19c8418b0 to your computer and use it in GitHub Desktop.
def mark_deploy_complete(self) -> bool:
"""
Starts the target "deploy-complete.target".
+ """
- If the return code is 0: deploy-complete.target is started
- If the return code is 5: deploy-complete.target doesn't exist (success)
- otherwise: don't deploy
+ return self._start_optional_target("deploy-complete")
+
+ def _start_optional_target(self, name: str) -> bool:
+ """
+ Starts a passed target. The passed name will have ".target" appended to it.
+
+ If the return code is 0: {name}.target: true
+ If the return code is 5: {name}.target doesn't exist: true
+ otherwise: false
"""
code: int = self.run_command(
- "systemctl start deploy-complete.target", check=False
+ f"systemctl start {name}.target", check=False
)
if code == 0:
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment