How can I control the events that take place inside my python script?

0

I have three files:

  • login.txt contains: the data to make an FTP connection.
  • DatosMail.txt contains: origin, destination, smtp, passwd.
  • FTP test contains Ftp connection, mail, log.

I need to check that these two files exist (login.txt, DatosMail) and add the response to my log.

I put the lines of code that I need control.

  • I need to check that login.txt exists.

    with open("login.txt") as fichero:
        dirServer = fichero.readline().split(":")[1].strip()
        usuario = fichero.readline().split(":")[1].strip()
        passwd = fichero.readline().split(":")[1].strip()
    
  • I need to control whether or not you connect to Server.

    ftp.login(user=usuario, passwd=passwd)
    
  • I need to check that the download has been made or not.

    ftp.retrbinary('RETR prueba.txt', open('PruebaFtp.txt', 'wb').write)
    
  • I need to control if DataMail.txt exists or not

  • I need to control if the email has been sent

    smtp = SMTP(smtp)
    smtp.login(from_address, passwd)
    smtp.sendmail(from_address, to_address, mime_message.as_string())'
    

I do not know where to take it since I've been using Python for a week and I've come this far. All contributions are welcome, thank you very much

    
asked by antoniop 06.11.2018 в 13:21
source

0 answers