from tabulate import tabulate
import ntclient.services.analyze
+import ntclient.services.bugs
import ntclient.services.recipe.utils
import ntclient.services.usda
from ntclient.services import calculate as calc
@author: shane
"""
import os
+import sqlite3
import traceback
import ntclient.services.api.funcs
def insert(args: list, exception: Exception) -> None:
"""Insert bug report into nt.sqlite3, return True/False."""
- print("inserting bug reports...", end="")
- sql_nt(
- """
+ print("INFO: inserting bug report...")
+ try:
+ 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",
- ),
- )
+ VALUES
+ (?,?,?,?,?,?,?)
+ """,
+ (
+ 1,
+ " ".join(args),
+ repr(exception),
+ os.linesep.join(traceback.format_tb(exception.__traceback__)),
+ "client_info",
+ "app_info",
+ "user_details",
+ ),
+ )
+ except sqlite3.IntegrityError as exc:
+ print(f"WARN: {repr(exc)}")
+ if repr(exc) == (
+ "IntegrityError('UNIQUE constraint failed: " "bug.arguments, bug.stack')"
+ ):
+ print("INFO: bug report already exists")
+ else:
+ raise
def submit() -> int:
"""
Handles exceptions raised during runtime.
"""
- print("Exception: %s" % exception)
+ print("ERROR: Exception: %s" % exception)
+ bug_insert(args, exception)
if CLI_CONFIG.debug:
- bug_insert(args, exception)
raise exception