print("Unforeseen error, run with --debug for more info: " + repr(exception))
print("You can open an issue here: %s" % __url__)
print("Or send me an email with the debug output: %s" % __email__)
+ print("Or, run the bug report command.")
+ print()
handle_runtime_exception(args, exception)
finally:
if CLI_CONFIG.debug:
def build_subcommand_bug(subparsers: argparse._SubParsersAction) -> None:
- """Report bugs"""
+ """List and report bugs"""
bug_parser = subparsers.add_parser("bug", help="report bugs")
- bug_parser.set_defaults(func=parser_funcs.bugs_report)
+ bug_subparser = bug_parser.add_subparsers(title="bug subcommands")
+ bug_parser.add_argument(
+ "--all", action="store_true", help="include already submitted bugs, too"
+ )
+ bug_parser.set_defaults(func=parser_funcs.bugs_list)
+
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ # Report (bug)
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ bug_report_parser = bug_subparser.add_parser(
+ "report", help="submit/report all bugs"
+ )
+ bug_report_parser.set_defaults(func=parser_funcs.bugs_report)
return 0, result
-def bugs_report() -> tuple:
- """Report a bug"""
- n_submissions = ntclient.services.bugs.submit()
+def bugs_list(args: argparse.Namespace) -> tuple:
+ """List bug reports that have een saved"""
+ _bugs_list = ntclient.services.bugs.list_bugs()
+
+ print(f"You have {len(_bugs_list)} unique bugs to report/submit! Good job.")
+ print()
+
+ for bug in _bugs_list:
+ # Skip submitted bugs by default
+ if bug[-1] != 0 and not args.all:
+ continue
+ # Print all (except noisy stacktrace)
+ print(", ".join(str(x) for x in bug if "\n" not in str(x)))
+
+ return 0, _bugs_list
+
+
+# pylint: disable=unused-argument
+def bugs_report(args: argparse.Namespace) -> tuple:
+ """Report bugs"""
+ n_submissions = ntclient.services.bugs.submit_bugs()
return 0, n_submissions
# TODO: move this outside class; support with host iteration helper method
def post_bug(self, bug: tuple) -> None:
"""Post a bug report to the developer."""
- print("posting bug report...")
self.post("bug", dict(bug))
raise
-def submit() -> int:
+def list_bugs() -> list:
+ """List all bugs."""
+ sql_bugs = sql_nt("SELECT * FROM bug WHERE submitted = 0")
+ return sql_bugs
+
+
+def submit_bugs() -> int:
"""Submit bug reports to developer, return n_submitted."""
sql_bugs = sql_nt("SELECT * FROM bug WHERE submitted = 0")
api_client = ntclient.services.api.ApiClient()
n_submitted = 0
print(f"submitting {len(sql_bugs)} bug reports...")
+ print("_" * len(sql_bugs))
for bug in sql_bugs:
- # print(", ".join(str(x) for x in bug))
+ print(".", end="", flush=True)
api_client.post_bug(bug)
n_submitted += 1
+ print()
# 1 / 0 # force exception
# raise Exception("submitting bug reports failed")