From 05816ee95d4268512b3b531a69b7ce4af1d61883 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 20 Aug 2025 21:55:59 +0200 Subject: [PATCH] add doc in load ftp user --- src/load_ftp_users.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/load_ftp_users.py b/src/load_ftp_users.py index b64638b..bacd2d1 100644 --- a/src/load_ftp_users.py +++ b/src/load_ftp_users.py @@ -27,7 +27,11 @@ FTP_CONFIG = { } def connect_ftp() -> FTP: - """Connessione al server FTP""" + """ + Establishes a connection to the FTP server using the predefined configuration. + Returns: + FTP: An active FTP connection object. + """ try: ftp = FTP() ftp.connect(FTP_CONFIG['host'], FTP_CONFIG['port']) @@ -39,7 +43,14 @@ def connect_ftp() -> FTP: sys.exit(1) def fetch_data_from_db(connection: mysql.connector.MySQLConnection) -> List[Tuple]: - """Preleva i dati dal database""" + """ + Fetches username and password data from the 'ftp_accounts' table in the database. + + Args: + connection (mysql.connector.MySQLConnection): The database connection object. + Returns: + List[Tuple]: A list of tuples, where each tuple contains (username, password). + """ try: cursor = connection.cursor() @@ -62,6 +73,15 @@ def fetch_data_from_db(connection: mysql.connector.MySQLConnection) -> List[Tupl cursor.close() def send_site_command(ftp: FTP, command: str) -> bool: + """ + Sends a SITE command to the FTP server. + + Args: + ftp (FTP): The FTP connection object. + command (str): The SITE command string to send (e.g., "ADDU username password"). + Returns: + bool: True if the command was sent successfully, False otherwise. + """ """Invia un comando SITE al server FTP""" try: # Il comando SITE viene inviato usando sendcmd @@ -73,7 +93,9 @@ def send_site_command(ftp: FTP, command: str) -> bool: return False def main(): - """Funzione principale""" + """ + Main function to connect to the database, fetch FTP user data, and send SITE ADDU commands to the FTP server. + """ logger.info("Avvio script caricamento utenti FTP") cfg = setting.Config()