Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Commit

Permalink
Add the command output as return value
Browse files Browse the repository at this point in the history
  • Loading branch information
niklas-heer committed Dec 15, 2017
1 parent 6604498 commit 0ed9a63
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions paci/helpers/cli_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,15 @@ def run_cmd(msg, cmd, ok_msg="", err_msg="", exit_msg="", exit_all=False, cwd=No
Returns
-------
True if the command was successful else it returns False.
If there is an output and it was successful it returns the output of the command.
"""
spinner = Halo(text=msg, spinner='dots', color='blue')
spinner.start()
time.sleep(DELAY) # If this is cut out some IO operations will fail if !(@(cmd) &>/dev/null):
if sh(cmd if type(cmd) is str else " ".join(cmd), cwd=cwd):
time.sleep(DELAY) # If this is cut out some IO operations will fail
stdout = sh(cmd if type(cmd) is str else " ".join(cmd), cwd=cwd)
if stdout:
spinner.succeed(colored(ok_msg if ok_msg else msg, 'green'))
return True
return stdout
else:
spinner.fail(colored(err_msg if err_msg else msg + " Failed!", 'red'))
if exit_all:
Expand Down

0 comments on commit 0ed9a63

Please sign in to comment.