Prep for AAPOR with Confex. General clean up.
This commit is contained in:
@@ -159,7 +159,7 @@ def get_event_presentation_detail(
|
||||
confex_session_id: str,
|
||||
confex_presentation_id: str, # similar to 'Paper/99999'
|
||||
):
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
# if result := authenticate():
|
||||
@@ -167,7 +167,8 @@ def get_event_presentation_detail(
|
||||
# else:
|
||||
# return False
|
||||
|
||||
endpoint = f'/Session/{confex_session_id}/{confex_presentation_id}'
|
||||
# endpoint = f'/Session/{confex_session_id}/{confex_presentation_id}'
|
||||
endpoint = f'/{confex_presentation_id}'
|
||||
uri = api['base_url']+endpoint
|
||||
params = {}
|
||||
|
||||
@@ -200,7 +201,7 @@ def get_event_presentation_detail(
|
||||
|
||||
try_request = False
|
||||
elif resp.status_code == 404:
|
||||
log.info('No results returned (status 404)')
|
||||
log.warning('No results returned (status 404)')
|
||||
try_request = False
|
||||
confex_presentation_detail = None
|
||||
elif resp.status_code == 429:
|
||||
@@ -209,7 +210,7 @@ def get_event_presentation_detail(
|
||||
try_request = True
|
||||
confex_presentation_detail = False
|
||||
else:
|
||||
log.info('Not trying again')
|
||||
log.warning('Not trying again')
|
||||
try_request = False
|
||||
confex_presentation_detail = False
|
||||
|
||||
@@ -290,4 +291,74 @@ def get_event_presenter_detail(
|
||||
# api['app_user_token_datetime'] = None # Resetting this just in case the App and or User token expired.
|
||||
|
||||
return confex_presenter_detail
|
||||
# ### END ### API External Confex Methods ### get_event_presenter_detail() ###
|
||||
# ### END ### API External Confex Methods ### get_event_presenter_detail() ###
|
||||
|
||||
|
||||
|
||||
# ### BEGIN ### API External Confex Methods ### get_event_file_detail() ###
|
||||
# Updated 2023-04-30
|
||||
@logger_reset
|
||||
def get_event_file_detail(
|
||||
confex_file_id: str, # similar to 'FileMap/Paper1928_Presentation2'
|
||||
):
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
# if result := authenticate():
|
||||
# log.debug(result)
|
||||
# else:
|
||||
# return False
|
||||
|
||||
endpoint = f'/{confex_file_id}'
|
||||
uri = api['base_url']+endpoint
|
||||
params = {}
|
||||
|
||||
confex_file_detail = None
|
||||
|
||||
try_request = True
|
||||
max_tries = 5
|
||||
try_count = 0
|
||||
while try_request and try_count <= max_tries:
|
||||
try_count = try_count + 1
|
||||
|
||||
resp = requests.get(url=uri, params=params, headers=api['headers'])
|
||||
|
||||
log.debug(f'Status Code: {resp.status_code}')
|
||||
log.debug(f'Headers: {resp.headers}')
|
||||
# log.debug(f'Encoding: {resp.encoding}')
|
||||
# log.debug('Text:')
|
||||
# log.debug(resp.text)
|
||||
# log.debug(resp.json())
|
||||
|
||||
if resp.status_code == 200:
|
||||
log.info('Status 200')
|
||||
log.debug(resp.json())
|
||||
|
||||
confex_file_detail_raw = resp.json() # .get('data').get('dataList')[0]
|
||||
# log.debug(confex_file_detail_raw)
|
||||
|
||||
confex_file_detail = confex_file_detail_raw
|
||||
log.debug(confex_file_detail)
|
||||
|
||||
try_request = False
|
||||
elif resp.status_code == 404:
|
||||
log.warning('No results returned (status 404)')
|
||||
try_request = False
|
||||
confex_file_detail = None
|
||||
elif resp.status_code == 429:
|
||||
log.warning('Hit rate limit. Sleeping for .1 seconds...')
|
||||
time.sleep(.1)
|
||||
try_request = True
|
||||
confex_file_detail = False
|
||||
else:
|
||||
log.warning('Not trying again')
|
||||
try_request = False
|
||||
confex_file_detail = False
|
||||
|
||||
log.warning('Something may have gone wrong during the request.')
|
||||
|
||||
# log.warning('Something may have gone wrong. Setting the API app_user_token_datetime value to None to re-authenticate with Impexium on the next request.')
|
||||
# api['app_user_token_datetime'] = None # Resetting this just in case the App and or User token expired.
|
||||
|
||||
return confex_file_detail
|
||||
# ### END ### API External Confex Methods ### get_event_file_detail() ###
|
||||
@@ -187,7 +187,7 @@ def get_event_file_rec_list(
|
||||
event_file_rec_li = event_file_rec_li_result
|
||||
else:
|
||||
event_file_rec_li = []
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(event_file_rec_li_result)
|
||||
log.debug(type(event_file_rec_li))
|
||||
log.debug(len(event_file_rec_li))
|
||||
|
||||
@@ -361,7 +361,7 @@ def create_update_event_presentation_obj_v4(
|
||||
fail_any: bool = False, # Fail if any thing goes wrong for sub objects
|
||||
return_outline: bool = False,
|
||||
) -> int|bool:
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
log.info('Checking requirements...')
|
||||
|
||||
@@ -57,7 +57,7 @@ def load_event_session_obj(
|
||||
exclude_unset: bool = True,
|
||||
model_as_dict: bool = False,
|
||||
) -> Event_Session_Base|bool:
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
if event_session_id := redis_lookup_id_random(record_id_random=event_session_id, table_name='event_session'): pass
|
||||
@@ -293,7 +293,7 @@ def load_event_session_obj(
|
||||
log.debug(event_presenter_cat_rec_result.get('event_presenter_names', None))
|
||||
event_session_obj.event_presenter_cat = event_presenter_cat_rec_result.get('event_presenter_names', None)
|
||||
else:
|
||||
log.warning(event_presenter_cat_rec_result)
|
||||
log.info(event_presenter_cat_rec_result)
|
||||
event_session_obj.event_presenter_cat = None
|
||||
|
||||
if inc_event_presenter_list: pass
|
||||
|
||||
Reference in New Issue
Block a user