Clean up and debugging.

This commit is contained in:
Scott Idem
2023-01-30 17:29:01 -05:00
parent bbf23e9f0b
commit b510a44adf
3 changed files with 11 additions and 9 deletions

View File

@@ -26,7 +26,6 @@ def get_token_header(x_token: str = Header(...)):
# ### END ### API Lib General ### async get_token_header() ###
# ### BEGIN ### API Lib General ### class Common_Route_Params ###
# Updated 2023-01-30
class Common_Route_Params_No_Account_ID:
@@ -93,7 +92,6 @@ def common_route_params_no_account_id(
# ### END ### API Lib General ### async common_route_params() ###
# ### BEGIN ### API Lib General ### class Common_Route_Params ###
# Updated 2022-01-05
class Common_Route_Params:
@@ -161,6 +159,7 @@ def common_route_params(
# ### BEGIN ### API Lib General ### class Common_Route_Params_Min ###
# Updated 2022-01-05
# NOTE: Is this essentially the same as Common_Route_Params_No_Account_ID above?
class Common_Route_Params_Min:
def __init__(
self,
@@ -187,6 +186,7 @@ class Common_Route_Params_Min:
# ### BEGIN ### API Lib General ### common_route_params_min() ###
# Updated 2022-02-15
# NOTE: Is this essentially the same as common_route_params_no_account_id above?
@logger_reset # This breaks things for some reason when the function is async. Do not use async def common_route_params()!
def common_route_params_min(
x_account_id: str = Header(None, min_length=11, max_length=22),
@@ -373,7 +373,7 @@ def return_full_tmp_path(
subdir_path: str = None,
filename: str = None,
) -> bool|str:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
hosted_tmp_path = settings.FILES_PATH['hosted_tmp_root']
@@ -469,15 +469,15 @@ def send_email(
log.info('Creating SMTP SSL connection...')
context = ssl.create_default_context()
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.info('SMTP configuration, connect, and send')
try:
with smtplib.SMTP_SSL(settings.SMTP['server'], settings.SMTP['port'], context=context) as server:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug('SMTP log in...')
server.login(settings.SMTP['username'], settings.SMTP['password'])
log.debug('SMTP send message...')
server.send_message(message)
log.info('Email sent')
log.info('Email sent!')
return True
except:
#except SMTPException:

View File

@@ -29,7 +29,7 @@ logging.config.dictConfig({
'formatter': 'long',
'filename': settings.LOG_PATH['app'],
'maxBytes': 5242880, # 524,2880 = 5 MB
'backupCount': 10
'backupCount': 9
},
# 'log_file_warning': {
# 'level': 'WARNING',
@@ -37,7 +37,7 @@ logging.config.dictConfig({
# 'formatter': 'long',
# 'filename': settings.LOG_PATH['app_warning'],
# 'maxBytes': 512000, # 524,288 = 512KB
# 'backupCount': 5
# 'backupCount': 9
# },
# 'test_handler': {
# 'class': 'logging.StreamHandler',

View File

@@ -21,12 +21,13 @@ def load_account_cfg_obj(
inc_fundraising_cfg: bool = False,
inc_membership_cfg: bool = False,
) -> Account_Cfg_Base|dict|bool:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
if account_id := redis_lookup_id_random(record_id_random=account_id, table_name='account'): pass
else: return False
log.info('Getting Account CFG ID: ${account_id}')
if account_cfg_rec := sql_select(
table_name = 'v_account_cfg', # This view should probably be cleaned up
field_name = 'account_id',
@@ -34,11 +35,12 @@ def load_account_cfg_obj(
): pass
else: return False
log.debug(account_cfg_rec)
try:
account_cfg_obj = Account_Cfg_Base(**account_cfg_rec)
log.debug(account_cfg_obj)
except ValidationError as e:
log.error(e.json())
log.debug(account_cfg_obj)
if inc_fundraising_cfg:
if fundraising_cfg_dict := load_fundraising_cfg_obj_old(