Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.cache
.idea
*.egg-info/
*.pyc
.cache
dist/
4 changes: 0 additions & 4 deletions bin/udapy.bat

This file was deleted.

8 changes: 4 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ classifiers =
packages = find:
python_requires = >=3.9
include_package_data = True
scripts =
bin/udapy
install_requires =
colorama
termcolor

[options.entry_points]
console_scripts =
udapy = udapi:cli.main

[options.extras_require]
test =
pytest


48 changes: 26 additions & 22 deletions bin/udapy → udapi/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,35 +58,34 @@
argparser.add_argument(
'scenario', nargs=argparse.REMAINDER, help="A sequence of blocks and their parameters.")

args = argparser.parse_args()

# Set the level of logs according to parameters.
if args.verbose:
level = logging.DEBUG
elif args.quiet:
level = logging.CRITICAL
else:
level = logging.INFO

logging.basicConfig(format='%(asctime)-15s [%(levelname)7s] %(funcName)s - %(message)s',
level=level)
# Process and provide the scenario.
def main(argv=None):
args = argparser.parse_args(argv)

# Global flag to track if an unhandled exception occurred
_unhandled_exception_occurred = False
# Set the level of logs according to parameters.
if args.verbose:
level = logging.DEBUG
elif args.quiet:
level = logging.CRITICAL
else:
level = logging.INFO

def _custom_excepthook(exc_type, exc_value, traceback):
global _unhandled_exception_occurred
_unhandled_exception_occurred = True
logging.basicConfig(format='%(asctime)-15s [%(levelname)7s] %(funcName)s - %(message)s',
level=level)

# Call the default excepthook to allow normal error reporting
sys.__excepthook__(exc_type, exc_value, traceback)
# Global flag to track if an unhandled exception occurred
_unhandled_exception_occurred = False

# Override the default excepthook
sys.excepthook = _custom_excepthook
def _custom_excepthook(exc_type, exc_value, traceback):
global _unhandled_exception_occurred
_unhandled_exception_occurred = True

# Call the default excepthook to allow normal error reporting
sys.__excepthook__(exc_type, exc_value, traceback)

# Process and provide the scenario.
if __name__ == "__main__":
# Override the default excepthook
sys.excepthook = _custom_excepthook

# Disabling garbage collections makes the whole processing much faster.
# Similarly, we can save several seconds by partially disabling the at-exit Python cleanup
Expand Down Expand Up @@ -134,3 +133,8 @@ def _custom_excepthook(exc_type, exc_value, traceback):
runner.execute()
except BrokenPipeError:
pass
return 0


if __name__ == "__main__":
sys.exit(main())