se agrega archivos para la instalación en Docker
This commit is contained in:
1 parent
533105e7c3
commit
cf2c1ee147
28 files changed
+1430
-501
No files matched your search
+12
-8
@@ -8,7 +8,10 @@ from config_loader import CONFIG
|
||||
|
||||
warnings.filterwarnings("ignore")
|
||||
|
||||
########################################################
|
||||
# Diferencia horaria respecto a UTC (Perú: UTC-5)
|
||||
UTC_OFFSET_HOURS = -5
|
||||
|
||||
# ========================================================================
|
||||
def get_access_token():
|
||||
"""
|
||||
Obtiene un token de acceso de Microsoft Graph usando las credenciales
|
||||
@@ -37,7 +40,7 @@ def get_access_token():
|
||||
correlation_id = result.get("correlation_id")
|
||||
raise Exception(f"Error al obtener token: {error} - {error_description} (ID: {correlation_id})")
|
||||
|
||||
########################################################
|
||||
# ========================================================================
|
||||
def get_emails(user_email, token, fecha_inicio, fecha_fin):
|
||||
"""
|
||||
Obtiene los correos de una cuenta específica en un rango de fechas.
|
||||
@@ -48,8 +51,8 @@ def get_emails(user_email, token, fecha_inicio, fecha_fin):
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
|
||||
dt_inicio_utc = datetime.strptime(fecha_inicio, "%Y-%m-%d") + timedelta(hours=5)
|
||||
dt_fin_utc = datetime.strptime(fecha_fin, "%Y-%m-%d") + timedelta(days=1, hours=5)
|
||||
dt_inicio_utc = datetime.strptime(fecha_inicio, "%Y-%m-%d") + timedelta(hours=-UTC_OFFSET_HOURS)
|
||||
dt_fin_utc = datetime.strptime(fecha_fin, "%Y-%m-%d") + timedelta(days=1, hours=-UTC_OFFSET_HOURS)
|
||||
|
||||
filter_query = (
|
||||
f"receivedDateTime ge {dt_inicio_utc.strftime('%Y-%m-%dT%H:%M:%SZ')} and "
|
||||
@@ -82,7 +85,7 @@ def get_emails(user_email, token, fecha_inicio, fecha_fin):
|
||||
for msg in messages:
|
||||
utc_str = msg.get("receivedDateTime")
|
||||
dt_utc = datetime.fromisoformat(utc_str.replace("Z", "+00:00"))
|
||||
dt_local = dt_utc - timedelta(hours=5)
|
||||
dt_local = dt_utc + timedelta(hours=UTC_OFFSET_HOURS)
|
||||
|
||||
from_obj = msg.get("from", {})
|
||||
sender = from_obj.get("emailAddress", {}).get("address", "Desconocido")
|
||||
@@ -100,7 +103,7 @@ def get_emails(user_email, token, fecha_inicio, fecha_fin):
|
||||
|
||||
return all_mails
|
||||
|
||||
########################################################
|
||||
# ========================================================================
|
||||
def download_attachments(user_email, message_id, token, download_path):
|
||||
"""
|
||||
Descarga los adjuntos de un mensaje específico y los guarda en la ruta indicada.
|
||||
@@ -137,7 +140,7 @@ def download_attachments(user_email, message_id, token, download_path):
|
||||
|
||||
return downloaded_files
|
||||
|
||||
########################################################
|
||||
# ========================================================================
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
print("Intentando obtener token de acceso...")
|
||||
@@ -162,4 +165,5 @@ if __name__ == "__main__":
|
||||
print(f"Descargados: {archivos}")
|
||||
break
|
||||
except Exception as e:
|
||||
print(f"❌ Error: {e}")
|
||||
print(f"❌ Error: {e}")
|
||||
# ========================================================================
|
||||
Reference in new issue
Block a user