import subprocess import configparser class Config(TypedDict): hostname: str user: str password: str def parseConfig() -> Config: cfg_path = os.environ.get("CONFIG", "/etc/ftth-ipe-map/conf.ini") cfg = configparser.ConfigParser() with open(cfg_path, "r") as f: cfg.read_file(f) return { 'hostname':cfg.get("AXIONE_FTP","hostname"), 'user':cfg.get("AXIONE_FTP","user"), 'password':cfg.get("AXIONE_FTP","password"), } def call_lftp(args): return subprocess.run(["lftp", "-u", f"{cfg.user},{cfg.password}", hostname] + args).stdout.decode("utf8") def retrieve_ipe_list(cfg: Config): return call_lftp(["-e", "set ssl:verify-certificate no; find /; bye"]) if __name__ == '__main__': cfg = parseConfig