Compare commits

...

1 commit

Author SHA1 Message Date
Félix Baylac-Jacqué
e8dec4a228
wip 2022-04-12 21:36:50 +02:00

View file

@ -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