From e8dec4a2283f7ce0a1687ae3964d821a8f31185e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Baylac-Jacqu=C3=A9?= Date: Tue, 12 Apr 2022 21:36:50 +0200 Subject: [PATCH] wip --- data-ingest/fetch-axione-data.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 data-ingest/fetch-axione-data.py diff --git a/data-ingest/fetch-axione-data.py b/data-ingest/fetch-axione-data.py new file mode 100644 index 0000000..0aed348 --- /dev/null +++ b/data-ingest/fetch-axione-data.py @@ -0,0 +1,28 @@ +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