Work on temporary hosted files

This commit is contained in:
Scott Idem
2021-11-23 17:17:40 -05:00
parent 24c7411109
commit 523a7378c6
3 changed files with 13 additions and 9 deletions

View File

@@ -28,6 +28,9 @@ class Settings(BaseSettings):
HTTP_STATUS_LI[503] = { 'name': 'Service Unavailable', 'message': 'The server is currently unable to handle the request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay. If known, the length of the delay MAY be indicated in a Retry-After header. If no Retry-After is given, the client SHOULD handle the response as it would for a 500 response.' } HTTP_STATUS_LI[503] = { 'name': 'Service Unavailable', 'message': 'The server is currently unable to handle the request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay. If known, the length of the delay MAY be indicated in a Retry-After header. If no Retry-After is given, the client SHOULD handle the response as it would for a 500 response.' }
HTTP_STATUS_LI[504] = { 'name': 'Gateway Timeout', 'message': 'The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server specified by the URI (e.g. HTTP, FTP, LDAP) or some other auxiliary server (e.g. DNS) it needed to access in attempting to complete the request.' } HTTP_STATUS_LI[504] = { 'name': 'Gateway Timeout', 'message': 'The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server specified by the URI (e.g. HTTP, FTP, LDAP) or some other auxiliary server (e.g. DNS) it needed to access in attempting to complete the request.' }
PATH_HOSTED_FILES_ROOT = '/mnt/data_drive/srv/data/osit_app/hosted_hashed_dev' # Will contain only hashed files
PATH_HOSTED_TMP_ROOT = '/mnt/data_drive/srv/data/osit_app/hosted_tmp_dev' # Will contain only temporary files
DB_CFG_FASTAPI_ID = 0 DB_CFG_FASTAPI_ID = 0
settings = Settings() settings = Settings()

View File

@@ -7,6 +7,7 @@ from pydantic import BaseModel, EmailStr, Field
from typing import Dict, List, Optional, Set, Union from typing import Dict, List, Optional, Set, Union
from app.log import log, logging, logger_reset from app.log import log, logging, logger_reset
from app.config import settings
from app.db_sql import redis_lookup_id_random, sql_select from app.db_sql import redis_lookup_id_random, sql_select
@@ -114,7 +115,7 @@ def decode_jwt(
# ### BEGIN ### API Lib General ### create_export() ### # ### BEGIN ### API Lib General ### create_export() ###
# Updated 2021-07-14 # Updated 2021-11-23
@logger_reset @logger_reset
def create_export_file( def create_export_file(
data_dict_list: list, data_dict_list: list,
@@ -125,10 +126,11 @@ def create_export_file(
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals()) log.debug(locals())
hosted_temp_path = 'admin/temp' hosted_tmp_path = settings.PATH_HOSTED_TMP_ROOT
log.info(f'Hosted Temp Path: {hosted_temp_path}') # hosted_tmp_path = 'admin/temp'
log.info(f'Hosted Temp Path: {hosted_tmp_path}')
subdirectory_dest = os.path.join(hosted_temp_path, subdir_path) subdirectory_dest = os.path.join(hosted_tmp_path, subdir_path)
log.debug(subdirectory_dest) log.debug(subdirectory_dest)
pathlib.Path(subdirectory_dest).mkdir(parents=True, exist_ok=True) pathlib.Path(subdirectory_dest).mkdir(parents=True, exist_ok=True)
file_dest_w_subdir = os.path.join(subdirectory_dest, filename) file_dest_w_subdir = os.path.join(subdirectory_dest, filename)
@@ -154,5 +156,4 @@ def create_export_file(
return False return False
return True return True
# ### END ### API Lib General ### create_export() ### # ### END ### API Lib General ### create_export() ###

View File

@@ -95,10 +95,10 @@ async def get_obj_id_order_line_list(
if create_export: if create_export:
datetime_format='%Y-%m-%d_%H%M' datetime_format='%Y-%m-%d_%H%M'
current_datetime = datetime.datetime.now() # current_datetime = datetime.datetime.now() # Servers timezone (Eastern)
# current_datetime_string = current_datetime.isoformat() current_datetime_utc = datetime.datetime.utcnow()
current_datetime_string = current_datetime.strftime(datetime_format) current_datetime_utc = current_datetime_utc.strftime(datetime_format)
filename = f'order_line_list_{current_datetime_string}' filename = f'order_line_list_{current_datetime_utc}'
create_export_file(data_dict_list=data_dict_list_for_export, subdir_path='order_line', filename=filename, export_type='Excel') create_export_file(data_dict_list=data_dict_list_for_export, subdir_path='order_line', filename=filename, export_type='Excel')
# print(response_data) # print(response_data)