Skip to content

Commit

Permalink
Implement persistent build tracking for more intuitive behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
rmartin16 committed Jun 8, 2024
1 parent eeca223 commit 2007db3
Show file tree
Hide file tree
Showing 35 changed files with 1,293 additions and 564 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ dependencies = [
"rich >= 12.6, < 14.0",
"tomli >= 2.0, < 3.0; python_version <= '3.10'",
"tomli_w >= 1.0, < 2.0",
"watchdog >= 3.0.0, < 5.0",
]

[project.optional-dependencies]
Expand Down
77 changes: 39 additions & 38 deletions src/briefcase/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,48 +15,49 @@
def main():
result = 0
command = None

printer = Printer()
console = Console(printer=printer)
logger = Log(printer=printer)
try:
Command, extra_cmdline = parse_cmdline(sys.argv[1:], console=console)
command = Command(logger=logger, console=console)
options, overrides = command.parse_options(extra=extra_cmdline)
command.parse_config(
Path.cwd() / "pyproject.toml",
overrides=overrides,
)
command(**options)
except HelpText as e:
logger.info()
logger.info(str(e))
result = e.error_code
except BriefcaseWarning as w:
# The case of something that hasn't gone right, but in an
# acceptable way.
logger.warning(str(w))
result = w.error_code
except BriefcaseTestSuiteFailure as e:
# Test suite status is logged when the test is executed.
# Set the return code, but don't log anything else.
result = e.error_code
except BriefcaseError as e:
logger.error()
logger.error(str(e))
result = e.error_code
logger.capture_stacktrace()
except Exception:
logger.capture_stacktrace()
raise
except KeyboardInterrupt:
logger.warning()
logger.warning("Aborted by user.")
logger.warning()
result = -42
if logger.save_log:

with suppress(KeyboardInterrupt):
try:
Command, extra_cmdline = parse_cmdline(sys.argv[1:], console=console)
command = Command(logger=logger, console=console)
options, overrides = command.parse_options(extra=extra_cmdline)
command.parse_config(Path.cwd() / "pyproject.toml", overrides=overrides)
command(**options)
except HelpText as e:
logger.info()
logger.info(str(e))
result = e.error_code
except BriefcaseWarning as w:
# The case of something that hasn't gone right, but in an
# acceptable way.
logger.warning(str(w))
result = w.error_code
except BriefcaseTestSuiteFailure as e:
# Test suite status is logged when the test is executed.
# Set the return code, but don't log anything else.
result = e.error_code
except BriefcaseError as e:
logger.error()
logger.error(str(e))
result = e.error_code
logger.capture_stacktrace()
except Exception:
logger.capture_stacktrace()
finally:
with suppress(KeyboardInterrupt):
raise
except KeyboardInterrupt:
logger.warning()
logger.warning("Aborted by user.")
logger.warning()
result = -42
if logger.save_log:
logger.capture_stacktrace()
finally:
if command is not None:
command.tracking_save()
logger.save_log_to_file(command)

return result
Expand Down
Loading

0 comments on commit 2007db3

Please sign in to comment.