Skip to content

Commit

Permalink
version 0.5.3
Browse files Browse the repository at this point in the history
- return last non-zero returncode or 0
  • Loading branch information
elesiuta committed Jan 22, 2021
1 parent 0b0e4eb commit fbe9aaf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions baka.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ def main() -> int:
# execute commands
command_output = []
error_message = ""
return_code = 0
try:
for cmd in cmds:
if args.dry_run:
Expand Down Expand Up @@ -293,6 +294,8 @@ def main() -> int:
if verbosity in ["debug", "info", "error"]:
proc_err = sys.stderr
proc = subprocess.run(cmd, stdout=proc_out, stderr=proc_err)
if proc.returncode != 0:
return_code = proc.returncode
if capture_output:
if verbosity in ["debug", "info"]:
sys.stdout.buffer.write(proc.stdout)
Expand All @@ -313,7 +316,9 @@ def main() -> int:
print(line)
else:
# run command normally
subprocess.run(cmd)
proc = subprocess.run(cmd)
if proc.returncode != 0:
return_code = proc.returncode
except Exception as e:
error_message = "Error baka line: %s For: %s %s %s" % (sys.exc_info()[2].tb_lineno, shlex.join(cmd), type(e).__name__, e.args)
command_output.append(error_message)
Expand All @@ -338,7 +343,7 @@ def main() -> int:
os.makedirs(os.path.dirname(file_path), exist_ok=True)
with open(file_path, "w", encoding="utf-8", errors="backslashreplace") as f:
f.write(command_output)
return 0
return return_code


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="bakabakabaka",
version="0.5.2",
version="0.5.3",
description="Baka Admin's Kludge Assistant",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit fbe9aaf

Please sign in to comment.