import os import ftplib import logging as log import config as cfg def push(path): ftp=ftplib.FTP_TLS() ftp.connect(cfg.ftp["host"],cfg.ftp["port"]) ftp.login(cfg.ftp["user"],cfg.ftp["password"]) filename=os.path.basename(path) log.info("uploading %s",path) with open(path,mode="rb") as f: ftp.storbinary("STOR "+filename,f) ftp.close() if __name__=="__main__": push(os.path.join(cfg.thisDir,"ftp.py"))