Commit 28e288bd authored by madhuri.penikalapati's avatar madhuri.penikalapati

changes

parent 7d969fac
......@@ -11,13 +11,11 @@ passwords.txt
#Ignoring all the markdown and class files
*.md
**/*.class
.env
__pycache__
*.pyc
*.pyo
*.pyd
.Python
env
pip-log.txt
pip-delete-this-directory.txt
.tox
......
......@@ -26,6 +26,6 @@ INTERVAL=60
EMAIL_SERVICE_PROXY=https://cloud.ilens.io/sms-util
MQTT_URL=192.168.0.220
MQTT_PORT=1883
FILES_MAPPING='{"file_name":"Quality Report_AC2O.xlsx","sheet_name":"Pure Tank","fill_range":"A4:E7","column_based": true}'
FILES_MAPPING=[{"file_name":"Quality Report_AC2O.xlsx","sheet_name":"Pure Tank","fill_range":"A4:E7","column_based": true}]
TEMPLATE_PATH=data/templates
DATA_PATH=C:/Users/harshavardhan.c/Downloads
\ No newline at end of file
DATA_PATH=data
\ No newline at end of file
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.8-slim
COPY . /app
RUN pip install -r requirements.txt
CMD [ "python3", "_execute_xlsx.py"]
\ No newline at end of file
import json
import os
import sys
if __name__ == '__main__':
from dotenv import load_dotenv
load_dotenv()
from scripts.core.handlers import ExcelUploadHandler
def main():
s = ExcelUploadHandler()
files_mapping = os.environ.get("FILES_MAPPING", default="")
if not files_mapping:
print("Files Mapping Found empty, existing!!")
sys.exit(0)
files_list = json.loads(files_mapping)
template_path = os.environ.get("TEMPLATE_PATH", default="")
data_path = os.environ.get("DATA_PATH", default="")
for each_file in files_list:
_file = each_file.get("file_name")
sheet_name = each_file.get("sheet_name")
fill_range = each_file.get("fill_range")
column_enabled = each_file.get("column_based")
response = s.parse_excel_data(template_file_path=os.path.join(template_path, _file),
data_file_path=os.path.join(data_path, _file),column_enabled=column_enabled,
template_fill_range=fill_range, sheet_name=sheet_name, file_name=_file)
a = True
while a:
main()
\ No newline at end of file
......@@ -40,22 +40,6 @@ class Service:
HOST = config.get("SERVICE", "host")
PORT = config.getint("SERVICE", "port")
class DBConf:
MONGO_URI = config.get('MONGO_DB', 'uri')
if not MONGO_URI:
print("Error, environment variable MONGO_URI not set")
sys.exit(1)
MAINTENANCE_DB_URI = config.get('POSTGRES', "maintenance")
if not MAINTENANCE_DB_URI:
print("MAINTENANCE_DB_URI env variables missing")
sys.exit(1)
ASSISTANT_DB_URI = config.get('POSTGRES', "assistant")
if not ASSISTANT_DB_URI:
print("ASSISTANT_DB_URI env variables missing")
sys.exit(1)
class KafkaConf:
host = config.get('KAFKA', 'host')
port = config.get('KAFKA', 'port')
......@@ -75,34 +59,6 @@ class StoragePaths:
base_path = os.path.join("data", module_name)
class DatabaseConstants:
metadata_db = config.get("DATABASES", "metadata_db")
if not bool(metadata_db):
metadata_db = "ilens_configuration"
ilens_assistant_db = config.get("DATABASES", "ilens_assistant")
if not bool(ilens_assistant_db):
ilens_assistant_db = "ilens_assistant"
ilens_asset_model_db = config.get("DATABASES", "ilens_asset_model")
if not bool(ilens_asset_model_db):
ilens_asset_model_db = "ilens_asset_model"
class PathToServices:
DATA_ENGINE = config.get("PATH_TO_SERVICES", "data_engine")
if not bool(DATA_ENGINE):
print("FORM_DE not set, proceeding without data engine support")
METADATA_SERVICES = config.get("PATH_TO_SERVICES", "metadata_services")
if not bool(METADATA_SERVICES):
print("METADATA_SERVICES not set, proceeding without metadata_services support")
AUDIT_PROXY = config.get("PATH_TO_SERVICES", "audit_proxy")
if not bool(AUDIT_PROXY):
print("AUDIT_PROXY not set, proceeding without audit_proxy support")
FORM_MT = config.get("PATH_TO_SERVICES", "form_mt")
if not bool(FORM_MT):
print("Error, environment variable FORM_MT not set")
sys.exit(1)
class PathToStorage:
BASE_PATH = config.get("DIRECTORY", "base_path")
if not BASE_PATH:
......@@ -118,41 +74,9 @@ class PathToStorage:
LOGS_MODULE_PATH = f"{BASE_PATH}/logs{MOUNT_DIR}/"
class KeyPath:
keys_path = config['DIRECTORY']['keys_path']
if not os.path.isfile(os.path.join(keys_path, "public")) or not os.path.isfile(
os.path.join(keys_path, "private")):
if not os.path.exists(keys_path):
os.makedirs(keys_path)
shutil.copy(os.path.join("assets", "keys", "public"), os.path.join(keys_path, "public"))
shutil.copy(os.path.join("assets", "keys", "private"), os.path.join(keys_path, "private"))
public = os.path.join(keys_path, "public")
private = os.path.join(keys_path, "private")
class RedisConfig:
host = config["REDIS"]["host"]
port = int(config["REDIS"]["port"])
login_db = config["REDIS"]["login_db"]
project_tags_db = config.getint("REDIS", "project_tags_db")
class BackFill:
interval_in_mins = config.get("BACKFILL", "interval", fallback=60)
class EnableAuditing:
periodic_entry_auditing = config.getboolean("AUDITING", "periodic_entry_auditing", fallback=False)
form_non_periodic_auditing = config.getboolean("AUDITING", "form_non_periodic_auditing", fallback=False)
form_periodic_auditing = config.getboolean("AUDITING", "form_periodic_auditing", fallback=False)
class OtherService:
EMAIL_URL = config["PATH_TO_OTHER_SERVICES"]["email_service"]
class MQTTConf:
uri = config["MQTT"]["uri"]
host = config["MQTT"]["host"]
port = int(config["MQTT"]["port"])
publish_base_topic = config["MQTT"]["publish_base_topic"]
......@@ -129,7 +129,7 @@ class ExcelUploadHandler:
date_key = date_key[0] if date_key else ""
timestamp_value = self.convert_date_string_to_timestamp(input_data=input_json[date_key]) if date_key else ''
if not timestamp_value and date_keys:
timestamp_value = data_parameters[key_mapping_json[data_parameters[0]]]
timestamp_value = key_mapping_json[date_keys[0]]
timestamp_value = self.convert_date_string_to_timestamp(input_data=timestamp_value)
if not timestamp_value and self.enable_current_timestamp:
timestamp_value = int(datetime.now().replace(hour=0, minute=0, second=0, microsecond=0).astimezone(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment