This commit is contained in:
Félix Baylac-Jacqué 2022-04-12 21:36:50 +02:00
parent 5f5c08798a
commit e8dec4a228
No known key found for this signature in database
GPG Key ID: EFD315F31848DBA4
1 changed files with 28 additions and 0 deletions

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