From 0f951650882220735bfcbc4aba415236122879a9 Mon Sep 17 00:00:00 2001 From: Dmitriy Yefremov Date: Mon, 5 Feb 2018 18:24:49 +0300 Subject: [PATCH] set encoding for ftp, fix file names for bouquets --- app/eparser/enigma/bouquets.py | 4 ++-- app/eparser/enigma/lamedb.py | 4 +++- app/ftp.py | 2 ++ app/picons/picons.py | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/eparser/enigma/bouquets.py b/app/eparser/enigma/bouquets.py index a959cd59..b8a5cc3f 100644 --- a/app/eparser/enigma/bouquets.py +++ b/app/eparser/enigma/bouquets.py @@ -18,7 +18,7 @@ def write_bouquets(path, bouquets): line.append("#NAME {}\n".format(bqs.name)) for bq in bqs.bouquets: - line.append(srv_line.format(bq.name, bq.type)) + line.append(srv_line.format(bq.name.replace(" ", "_"), bq.type)) write_bouquet(path, bq.name, bq.type, bq.services) with open(path + "bouquets.{}".format(bqs.type), "w") as file: @@ -37,7 +37,7 @@ def write_bouquet(path, name, bq_type, channels): else: bouquet.append("#SERVICE {}\n".format(to_bouquet_id(ch))) - with open(path + "userbouquet.{}.{}".format(name, bq_type), "w") as file: + with open(path + "userbouquet.{}.{}".format(name.replace(" ", "_"), bq_type), "w") as file: file.writelines(bouquet) diff --git a/app/eparser/enigma/lamedb.py b/app/eparser/enigma/lamedb.py index 68a9ad7c..2ff88f0c 100644 --- a/app/eparser/enigma/lamedb.py +++ b/app/eparser/enigma/lamedb.py @@ -111,10 +111,12 @@ def parse_services(services, transponders, path): tr_type, sp, tr = str(transponder).partition(" ") tr = tr.split(_SEP) service_type = SERVICE_TYPE.get(data[4], SERVICE_TYPE["-2"]) + # removing all non printable symbols! + srv_name = "".join(c for c in ch[1] if c.isprintable()) channels.append(Service(flags_cas=ch[2], transponder_type=tr_type, coded=coded, - service=ch[1], + service=srv_name, locked=locked, hide=hide, package=package, diff --git a/app/ftp.py b/app/ftp.py index 3412d4a9..7ddb2839 100644 --- a/app/ftp.py +++ b/app/ftp.py @@ -22,6 +22,7 @@ class DownloadDataType(Enum): def download_data(*, properties, download_type=DownloadDataType.ALL, callback=None): with FTP(host=properties["host"]) as ftp: ftp.login(user=properties["user"], passwd=properties["password"]) + ftp.encoding = "utf-8" save_path = properties["data_dir_path"] os.makedirs(os.path.dirname(save_path), exist_ok=True) files = [] @@ -66,6 +67,7 @@ def upload_data(*, properties, download_type=DownloadDataType.ALL, remove_unused with FTP(host=host) as ftp: ftp.login(user=properties["user"], passwd=properties["password"]) + ftp.encoding = "utf-8" if download_type is DownloadDataType.ALL or download_type is DownloadDataType.SATELLITES: ftp.cwd(properties["satellites_xml_path"]) diff --git a/app/picons/picons.py b/app/picons/picons.py index 165a3cd4..cea1a344 100644 --- a/app/picons/picons.py +++ b/app/picons/picons.py @@ -3,7 +3,7 @@ import shutil from collections import namedtuple from html.parser import HTMLParser -from app.commons import log, run_task +from app.commons import log from app.properties import Profile _ENIGMA2_PICON_KEY = "{:X}:{:X}:{:X}0000"