Skip to content

Instantly share code, notes, and snippets.

@grahamc
Created March 9, 2020 20:10
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/4d0411a63006b72340e621d02dd2f952 to your computer and use it in GitHub Desktop.
Save grahamc/4d0411a63006b72340e621d02dd2f952 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
"""
- code: int = self.run_command(
- "systemctl start deploy-complete.target", check=False
- )
- if code == 0:
- return True
- elif code == 5:
- return True
- else:
- return False
+ 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(
+ f"systemctl start {name}.target", check=False
+ )
+ if code == 0:
+ return True
+ elif code == 5:
+ return True
+ else:
+ return False
+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment