import os import json import ftplib import logging as log thisDir=os.path.dirname(__file__) with open(os.path.join(thisDir,"ftp.json")) as f: cfg=json.load(f) def push(path): ftp=ftplib.FTP() ftp.connect(cfg["host"],cfg["port"]) ftp.login(cfg["user"],cfg["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()