Debugging scripts import hell.
This commit is contained in:
@@ -21,10 +21,10 @@ def set_sqlite_pragma(dbapi_connection, connection_record):
|
||||
if ctx.database_schema == "sqlite":
|
||||
execution_phrase = "PRAGMA foreign_keys=ON"
|
||||
else:
|
||||
print("Nothing to execute, returning")
|
||||
# print("Nothing to execute, returning")
|
||||
cursor.close()
|
||||
return
|
||||
print(f"Executing {execution_phrase} in sql.")
|
||||
print(f"Executing '{execution_phrase}' in sql.")
|
||||
cursor.execute(execution_phrase)
|
||||
cursor.close()
|
||||
|
||||
@@ -34,7 +34,7 @@ from .models import *
|
||||
|
||||
def update_log(mapper, connection, target):
|
||||
state = inspect(target)
|
||||
object_name = state.object.truncated_name()
|
||||
object_name = state.object.truncated_name
|
||||
update = dict(user=getuser(), time=datetime.now(), object=object_name, changes=[])
|
||||
for attr in state.attrs:
|
||||
hist = attr.load_history()
|
||||
|
||||
@@ -24,6 +24,7 @@ logger = logging.getLogger(f"submissions.{__name__}")
|
||||
class LogMixin(Base):
|
||||
__abstract__ = True
|
||||
|
||||
@property
|
||||
def truncated_name(self):
|
||||
name = str(self)
|
||||
if len(name) > 64:
|
||||
|
||||
@@ -368,7 +368,7 @@ class IridaControl(Control):
|
||||
polymorphic_load="inline",
|
||||
inherit_condition=(id == Control.id))
|
||||
|
||||
@validates("sub_type")
|
||||
@validates("subtype")
|
||||
def enforce_subtype_literals(self, key: str, value: str) -> str:
|
||||
"""
|
||||
Validates sub_type field with acceptable values
|
||||
|
||||
@@ -738,7 +738,13 @@ class SubmissionType(BaseClass):
|
||||
return f"<SubmissionType({self.name})>"
|
||||
|
||||
@classmethod
|
||||
def retrieve_template_file(cls):
|
||||
def retrieve_template_file(cls) -> bytes:
|
||||
"""
|
||||
Grabs the default excel template file.
|
||||
|
||||
Returns:
|
||||
bytes: The excel sheet.
|
||||
"""
|
||||
submission_type = cls.query(name="Bacterial Culture")
|
||||
return submission_type.template_file
|
||||
|
||||
|
||||
Reference in New Issue
Block a user