download/upload data skeleton

This commit is contained in:
Dmitriy Yefremov
2017-10-09 14:27:15 +03:00
parent c15ff64def
commit ef0d89a40e
4 changed files with 36 additions and 2382 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -532,6 +532,7 @@
</child>
<child>
<object class="GtkTreeViewColumn" id="service_type_column">
<property name="resizable">True</property>
<property name="title" translatable="yes">Type</property>
<child>
<object class="GtkCellRendererText" id="type_cellrenderertex"/>

View File

@@ -9,7 +9,7 @@ from enum import Enum
Channel = namedtuple("Channel", ["service", "package", "service_type", "ssid", "freq", "rate", "pol", "fec", "system"])
_HEADER = "eDVB services /4/"
_FILE_PATH = "../data/lamedb_example"
_FILE_PATH = "../data/lamedb"
_SEP = ":" # separator
@@ -36,7 +36,7 @@ FEC = {0: "None", 1: "Auto", 2: "1/2",
SYSTEM = {0: "DVB-S", 1: "DVB_S2"}
SERVICE_TYPE = {-2: "Unknown", 1: "TV", 2: "Radio", 3: "Data",
10: "Radio", 12: "Data", 22: "TV", 25: "HD TV",
10: "Radio", 12: "Data", 22: "TV", 25: "TV",
136: "Data", 139: "Data"}
@@ -77,7 +77,7 @@ def get_channels(*args):
transponder = transponders.get(str(data[1] + _SEP + data[2] + _SEP + data[3]), None)
if transponder is not None:
tr = str(transponder)[2:].split(_SEP) # Removing type of DVB transponders (s , t, c) and split
pack = pack[2:pack.find(",")]
pack = pack[2:] if pack.find(",") < 0 else pack[2:pack.find(",")]
channels.append(Channel(ch[1], pack, SERVICE_TYPE.get(int(data[4]), SERVICE_TYPE[-2]), data[0], tr[0],
tr[1], Polarization(int(tr[2])).name,
FEC[int(tr[3])], SYSTEM[int(tr[6])]))

View File

@@ -1,4 +1,5 @@
import gi
import os
from ftplib import FTP
from main.properties import get_config, write_config
@@ -10,6 +11,7 @@ from gi.repository import Gtk, Gdk
__status_bar = None
__options = get_config()
__services_model = None
__DATA_FILES_LIST = ("tv", "radio", "lamedb")
def on_about_app(item):
@@ -35,10 +37,9 @@ def get_handlers():
def on_data_open(item):
if isinstance(item, Gtk.ListStore):
channels = parse(get_config()["data_dir_path"] + "lamedb_example")
channels = parse(get_config()["data_dir_path"] + "lamedb")
for ch in channels:
item.append(ch)
# item.append()
def on_path_open(*args):
@@ -113,12 +114,38 @@ def connect(properties, download=True):
try:
with FTP(properties["host"]) as ftp:
ftp.login(user=properties["user"], passwd=properties["password"])
save_path = properties["data_dir_path"]
if download:
__status_bar.push(1, ftp.voidcmd("NOOP"))
# bouquets section
ftp.cwd(properties["services_path"])
ftp.retrlines("LIST")
files = []
ftp.dir(files.append)
for file in files:
name = str(file).strip()
if name.endswith(__DATA_FILES_LIST):
name = name.split()[-1]
with open(save_path + name, 'wb') as f:
ftp.retrbinary('RETR ' + name, f.write)
# satellites.xml section
ftp.cwd(properties["satellites_xml_path"])
files.clear()
ftp.dir(files.append)
for file in files:
name = str(file).strip()
xml_file = "satellites.xml"
if name.endswith(xml_file):
with open(save_path + xml_file, 'wb') as f:
ftp.retrbinary('RETR ' + xml_file, f.write)
__status_bar.push(1, ftp.voidcmd("NOOP"))
for name in os.listdir(save_path):
print(name)
else:
pass
for file_name in os.listdir(save_path):
print(file_name)
# Open the file for transfer in binary mode
# f = open(file_name, "rb")
# transfer the file into receiver
# send = ftp.storbinary("STOR " + file_name, f)
except Exception as e:
__status_bar.remove_all(1)
__status_bar.push(1, getattr(e, "message", repr(e))) # Or maybe so: getattr(e, 'message', str(e))