Skip to content

Commit

Permalink
adding test to Escribir_Datos_Osiris(), adding env variable to Docker…
Browse files Browse the repository at this point in the history
…file and changing time for datetime
  • Loading branch information
natilou committed Apr 11, 2023
1 parent bb1c244 commit 719e18d
Show file tree
Hide file tree
Showing 6 changed files with 227 additions and 111 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ COPY Pipfile Pipfile.lock ./

RUN pipenv install --system --deploy --ignore-pipfile

ENV file_directory="Subida Osiris"

COPY . .

CMD ["python3", "src/subida.py"]
5 changes: 3 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ verify_ssl = true
name = "pypi"

[packages]
pytest = "7.2.2"
pandas = "2.0.0"
numpy = "1.24.2"
ipdb = "0.13.13"

[dev-packages]
pytest = "7.2.2"
ipdb = "0.13.13"
freezegun = "1.2.2"

[requires]
python_version = "3.10"
213 changes: 115 additions & 98 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions src/subida.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import shutil
import pandas as pd
import numpy as np
import datetime
import time
from datetime import datetime
import traceback

from driver_email import enviar_mail_con_adjuntos
Expand Down Expand Up @@ -113,14 +112,14 @@ def Preparacion_Cuentas():
df_sub = df_sub.drop('riesgo', inplace=False, axis=1)
try:
df_sub.to_csv(
f'Subida Osiris/{time.strftime("(%H.%M hs) -")} subida_cartera_{name}.csv',
f'Subida Osiris/{datetime.now().strftime("(%H.%M hs) -")} subida_cartera_{name}.csv',
sep=';',
encoding='latin_1',
index=False
)
except Exception:
df_sub.to_csv(
f'Subida Osiris/{time.strftime("(%H.%M hs) -")} subida_cartera_{name}.csv',
f'Subida Osiris/{datetime.now().strftime("(%H.%M hs) -")} subida_cartera_{name}.csv',
sep=';',
encoding='ANSI',
index=False
Expand Down Expand Up @@ -185,7 +184,7 @@ def Preparacion_Cuentas_Comafi():
df_os['IDSucursal(17)'] = '1'
df_os['subcliente'] = df['subcliente']

name_folder = f'Subida Osiris/{time.strftime("(%H.%M hs) -")} {nombre_cartera}'
name_folder = f'Subida Osiris/{datetime.now().strftime("(%H.%M hs) -")} {nombre_cartera}'
if os.path.isdir(name_folder):
shutil.rmtree(name_folder)
os.mkdir(name_folder)
Expand Down Expand Up @@ -332,14 +331,14 @@ def Preparacion_Datos_Comafi():
print('Guardando planilla subida...')
try:
df_subida.to_csv(
f'Subida Osiris/{time.strftime("(%H.%M hs) -")}DATOS_EMERIX_subida_telefono.csv',
f'Subida Osiris/{datetime.now().strftime("(%H.%M hs) -")}DATOS_EMERIX_subida_telefono.csv',
sep=';',
index=False,
encoding='ANSI'
)
except Exception:
df_subida.to_csv(
f'Subida Osiris/{time.strftime("(%H.%M hs) -")}DATOS_EMERIX_subida_telefono.csv',
f'Subida Osiris/{datetime.now().strftime("(%H.%M hs) -")}DATOS_EMERIX_subida_telefono.csv',
sep=';',
index=False,
encoding='ANSI'
Expand Down
10 changes: 6 additions & 4 deletions src/write_data_osiris.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@

from datetime import datetime
import os
import pandas as pd
import time
from constants.constants import DATA_UPLOADER_HEADER


def Escribir_Datos_Osiris(df, filename, cols_df, cols_osiris):
def Escribir_Datos_Osiris(df: pd.DataFrame, filename: str, cols_df: list[str], cols_osiris: list[str]):

Control_Carpeta_Subida()

df_subida = pd.DataFrame(columns=DATA_UPLOADER_HEADER)
df_subida[cols_osiris] = df[cols_df]
try:
df_subida.to_csv(
f'Subida Osiris/{time.strftime("(%H.%M hs) -")} {filename}',
f'{os.getenv("file_directory", "Subida Osiris")}/{datetime.now().strftime("(%H.%M hs) -")} {filename}',
sep=';',
index=False,
encoding='latin_1'
)

except Exception:
df_subida.to_csv(
f'Subida Osiris/{time.strftime("(%H.%M hs) -")} {filename}',
f'{os.getenv("file_directory", "Subida Osiris")}/{datetime.now().strftime("(%H.%M hs) -")} {filename}',
sep=';',
index=False,
encoding='ANSI'
Expand Down
Loading

0 comments on commit 719e18d

Please sign in to comment.