__version__,
)
from ntclient.argparser import build_subcommands
-from ntclient.utils import CLI_CONFIG, handle_runtime_exception
+from ntclient.utils import CLI_CONFIG
from ntclient.utils.exceptions import SqlException
+from ntclient.utils.sql import handle_runtime_exception
def build_arg_parser() -> argparse.ArgumentParser:
exit_code, *_results = func(_parser)
except SqlException as sql_exception: # pragma: no cover
print("Issue with an sqlite database: " + repr(sql_exception))
- handle_runtime_exception(sql_exception)
+ handle_runtime_exception(args, 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)
- handle_runtime_exception(http_error)
+ handle_runtime_exception(args, http_error)
except URLError as url_error: # pragma: no cover
print("Connection error, check your internet: " + repr(url_error.reason))
- handle_runtime_exception(url_error)
+ handle_runtime_exception(args, 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__)
- handle_runtime_exception(exception)
+ handle_runtime_exception(args, exception)
finally:
if CLI_CONFIG.debug:
exc_time = time.time() - start_time
-Subproject commit 939f55077b97bd1fe1c8e2b897b032dbc1564487
+Subproject commit c5c64d3371a5f1e5c600989e79563c5827486224
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
-Created on Tue Feb 13 09:51:48 2024
+Created on Tue Feb 13 14:28:20 2024
@author: shane
"""
--- /dev/null
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+"""
+Created on Tue Feb 13 14:28:44 2024
+
+@author: shane
+"""
+
+
+def post_bug(bug: tuple) -> None:
+ """Post a bug report to the developer."""
+ print("posting bug report...")
@author: shane
"""
+import os
+import traceback
+
+import ntclient.services.api.funcs
+from ntclient.persistence.sql.nt import sql as sql_nt
+
+
+def insert(args: list, exception: Exception) -> None:
+ """Insert bug report into nt.sqlite3, return True/False."""
+ print("inserting bug reports...", end="")
+ sql_nt(
+ """
+INSERT INTO bug
+ (profile_id, arguments, repr, stack, client_info, app_info, user_details)
+ VALUES
+ (?,?,?,?,?,?,?)
+ """,
+ (
+ 1,
+ " ".join(args),
+ repr(exception),
+ os.linesep.join(traceback.format_tb(exception.__traceback__)),
+ "client_info",
+ "app_info",
+ "user_details",
+ ),
+ )
+
+
+def submit() -> int:
+ """Submit bug reports to developer, return n_submitted."""
+ n_submitted = 0
+ sql_bugs = sql_nt("SELECT * FROM bug WHERE submitted = 0")
+ print(f"submitting {len(sql_bugs)} bug reports...")
+ for bug in sql_bugs:
+ # print(", ".join(str(x) for x in bug))
+ ntclient.services.api.funcs.post_bug(bug)
+ n_submitted += 1
+ # 1 / 0 # force exception
+ # raise Exception("submitting bug reports failed")
+
+ return n_submitted
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
--- /dev/null
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+"""
+Created on Tue Feb 13 14:15:21 2024
+
+@author: shane
+"""
+from ntclient.services.bugs import insert as bug_insert
+from ntclient.utils import CLI_CONFIG
+
+
+def handle_runtime_exception(args: list, exception: Exception) -> None:
+ """
+ Handles exceptions raised during runtime.
+ """
+ print("Exception: %s" % exception)
+ if CLI_CONFIG.debug:
+ bug_insert(args, exception)
+ raise exception