-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
579 additions
and
291 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
release_version = "0.5.0" | ||
release_version = "0.5.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import sys | ||
import traceback | ||
|
||
from pandacommon.pandalogger.LogWrapper import LogWrapper | ||
from pandacommon.pandalogger.PandaLogger import PandaLogger | ||
|
||
|
||
# Base class for DB proxy modules | ||
class BaseModule: | ||
# constructor | ||
def __init__(self, log_stream: PandaLogger): | ||
self._log_stream = log_stream | ||
self.conn = None | ||
self.cur = None | ||
|
||
# abstract method to commit | ||
def _commit(self): | ||
""" | ||
Commit the transaction | ||
""" | ||
raise NotImplementedError("commit is not implemented") | ||
|
||
# abstract method to rollback | ||
def _rollback(self): | ||
""" | ||
Rollback the transaction | ||
""" | ||
raise NotImplementedError("rollback is not implemented") | ||
|
||
# dump error message | ||
def dump_error_message(self, tmp_log: LogWrapper): | ||
""" | ||
Dump error message to the log | ||
:param tmp_log: log wrapper | ||
""" | ||
# error | ||
err_type, err_value = sys.exc_info()[:2] | ||
err_str = f"{err_type.__name__} {err_value}" | ||
err_str.strip() | ||
err_str += " " | ||
err_str += traceback.format_exc() | ||
tmp_log.error(err_str) | ||
|
||
# create method name and logger | ||
def create_method_name_logger(self, comment: str, tag: str = None) -> tuple[str, LogWrapper]: | ||
""" | ||
Create method name and logger from function comment | ||
param comment: comment of the function | ||
param tag: tag to add to the method name | ||
return: (method name, log wrapper) | ||
""" | ||
method_name = comment.split(" ")[-2].split(".")[-1] | ||
if tag is not None: | ||
method_name += f" < {tag} >" | ||
tmp_log = LogWrapper(self._log_stream, method_name) | ||
return method_name, tmp_log |
Oops, something went wrong.