diff --git a/helpers/generate.py b/helpers/generate.py index 815f47b..07d97c5 100755 --- a/helpers/generate.py +++ b/helpers/generate.py @@ -156,10 +156,16 @@ def conf2top(top): print("Warning: Error opening", top["file"], file=sys.stderr) if "command" in top: - body = subprocess.run(top["command"], shell=True, text=True, capture_output=True, check=args.allowfailcommand).stdout + try: + body = subprocess.run(top["command"], shell=True, text=True, capture_output=True, check=True).stdout + except subprocess.CalledProcessError as e: + print(f"Warning: Command for '{top['title']}' returned non-zero exit code, output not used") if "proto_command" in top: - protostub = subprocess.run(top["proto_command"], shell=True, text=True, capture_output=True, check=args.allowfailcommand).stdout + try: + protostub = subprocess.run(top["proto_command"], shell=True, text=True, capture_output=True, check=True).stdout + except subprocess.CalledProcessError as e: + print(f"Warning: Protocommand for '{top['title']}' returned non-zero exit code, output not used") return Top(top["title"], sender, body, protostub) @@ -180,6 +186,8 @@ def do_imports(entry): result[key] = do_imports(value) except KeyError: pass + except OSError as e: + print(f"Warning: reading {key} yielded error {e}") return result if isinstance(entry, list): @@ -223,7 +231,6 @@ if __name__ == "__main__": parser.add_argument("--send-mm", action="store_true") parser.add_argument("--send-mail", action="store_true") parser.add_argument("--save", action="store_true") - parser.add_argument("--allowfailcommand", action="store_false") parser.add_argument("--time") parser.add_argument("--date") args = parser.parse_args()