]> Nutra Git (v2) - nutratech/cli.git/commitdiff
wip bug report
authorShane Jaroch <chown_tee@proton.me>
Tue, 13 Feb 2024 14:56:16 +0000 (09:56 -0500)
committerShane Jaroch <chown_tee@proton.me>
Tue, 13 Feb 2024 15:00:05 +0000 (10:00 -0500)
.editorconfig
ntclient/__main__.py
ntclient/argparser/__init__.py
ntclient/argparser/funcs.py
ntclient/ntsqlite
ntclient/services/bugs.py [new file with mode: 0644]
ntclient/utils/__init__.py

index 11b1d231fa1772b59c27f31ecefd782dd6179b95..3d74d05ae03277cc200e9923d403c97fc82adf0d 100644 (file)
@@ -34,5 +34,5 @@ indent_size = 2
 max_line_length = 79
 
 
-[{COMMIT_EDITMSG,MERGE_MSG,SQUASH_MSG,git-rebase-todo}]
+[{COMMIT_EDITMSG,MERGE_MSG,SQUASH_MSG,TAG_EDITMSG,git-rebase-todo}]
 max_line_length = 72
index 99964c2e37c46c848f82d7dd3003e137cd5da6cc..6de1e07e6d2c6ed2b70777da2c208c6ddd17d2de 100644 (file)
@@ -23,7 +23,7 @@ from ntclient import (
     __version__,
 )
 from ntclient.argparser import build_subcommands
-from ntclient.utils import CLI_CONFIG
+from ntclient.utils import CLI_CONFIG, handle_runtime_exception
 from ntclient.utils.exceptions import SqlException
 
 
@@ -101,23 +101,19 @@ def main(args: list = None) -> int:  # type: ignore
         exit_code, *_results = func(_parser)
     except SqlException as sql_exception:  # pragma: no cover
         print("Issue with an sqlite database: " + repr(sql_exception))
-        if CLI_CONFIG.debug:
-            raise
+        handle_runtime_exception(sql_exception)
     except HTTPError as http_error:  # pragma: no cover
         err_msg = "{0}: {1}".format(http_error.code, repr(http_error))
         print("Server response error, try again: " + err_msg)
-        if CLI_CONFIG.debug:
-            raise
+        handle_runtime_exception(http_error)
     except URLError as url_error:  # pragma: no cover
         print("Connection error, check your internet: " + repr(url_error.reason))
-        if CLI_CONFIG.debug:
-            raise
+        handle_runtime_exception(url_error)
     except Exception as exception:  # pylint: disable=broad-except  # pragma: no cover
         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__)
-        if CLI_CONFIG.debug:
-            raise
+        handle_runtime_exception(exception)
     finally:
         if CLI_CONFIG.debug:
             exc_time = time.time() - start_time
index d3a255b87af016576b84680713c8ec7f6e6179a7..b7299c087f5a138b3847c4cedf717da1f0bc6ad6 100644 (file)
@@ -23,6 +23,7 @@ def build_subcommands(subparsers: argparse._SubParsersAction) -> None:
     build_day_subcommand(subparsers)
     build_recipe_subcommand(subparsers)
     build_calc_subcommand(subparsers)
+    build_subcommand_bug(subparsers)
 
 
 ################################################################################
@@ -319,3 +320,10 @@ def build_calc_subcommand(subparsers: argparse._SubParsersAction) -> None:
         "ankle", type=float, nargs="?", help="ankle (cm) [casey_butt]"
     )
     calc_lbl_parser.set_defaults(func=parser_funcs.calc_lbm_limits)
+
+
+def build_subcommand_bug(subparsers: argparse._SubParsersAction) -> None:
+    """Report bugs"""
+
+    bug_parser = subparsers.add_parser("bug", help="report bugs")
+    bug_parser.set_defaults(func=parser_funcs.bugs_report)
index fb4e753917aaaca19ebdb6795c5899435f2051cd..fbeb8e76c3e2dddc601ff790692bd582bb3d5a3a 100644 (file)
@@ -335,3 +335,9 @@ def calc_lbm_limits(args: argparse.Namespace) -> tuple:
     print(_table)
 
     return 0, result
+
+
+def bugs_report() -> tuple:
+    """Report a bug"""
+    n_submissions = ntclient.services.bugs.submit()
+    return 0, n_submissions
index e69368ff9a64db7134a212686c08922c6537bcee..939f55077b97bd1fe1c8e2b897b032dbc1564487 160000 (submodule)
@@ -1 +1 @@
-Subproject commit e69368ff9a64db7134a212686c08922c6537bcee
+Subproject commit 939f55077b97bd1fe1c8e2b897b032dbc1564487
diff --git a/ntclient/services/bugs.py b/ntclient/services/bugs.py
new file mode 100644 (file)
index 0000000..b29e6c1
--- /dev/null
@@ -0,0 +1,7 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+"""
+Created on Tue Feb 13 09:51:48 2024
+
+@author: shane
+"""
index 042f66f2ebe8a772d00c34b14f36fc957f8c460b..f5fc7b0c89f12289d4da9c5b5335af2efb14a9c7 100644 (file)
@@ -150,3 +150,12 @@ def activity_factor_from_index(activity_factor: int) -> float:
     raise ValueError(  # pragma: no cover
         "No such ActivityFactor for value: %s" % activity_factor
     )
+
+
+def handle_runtime_exception(exception: Exception) -> None:
+    """
+    Handles exceptions raised during runtime.
+    """
+    print("Exception: %s" % exception)
+    if CLI_CONFIG.debug:
+        raise exception