From 2b3c357657b7c3f0ccf22ba27d5bdb5e93878327 Mon Sep 17 00:00:00 2001 From: DYefremov Date: Sun, 4 Nov 2018 00:33:50 +0300 Subject: [PATCH] new download dialog --- app/{ftp.py => connections.py} | 14 ++ app/ui/download_dialog.py | 2 +- app/ui/new_download_dialog.glade | 297 +++++++++++++++---------------- app/ui/new_download_dialog.py | 12 +- app/ui/picons_downloader.py | 2 +- 5 files changed, 170 insertions(+), 157 deletions(-) rename app/{ftp.py => connections.py} (94%) diff --git a/app/ftp.py b/app/connections.py similarity index 94% rename from app/ftp.py rename to app/connections.py index 68c257cc..8c3cdba0 100644 --- a/app/ftp.py +++ b/app/connections.py @@ -193,5 +193,19 @@ def telnet(host, port=23, user="", password="", timeout=5): yield +def test_telnet(host, port, user, password, timeout): + tn = Telnet(host=host, port=port, timeout=timeout) + time.sleep(1) + tn.read_until(b"login: ", timeout=2) + tn.write(user.encode("utf-8") + b"\n") + time.sleep(timeout) + tn.read_until(b"Password: ", timeout=2) + tn.write(password.encode("utf-8") + b"\n") + time.sleep(timeout) + yield tn.read_very_eager() + tn.close() + yield "Done" + + if __name__ == "__main__": pass diff --git a/app/ui/download_dialog.py b/app/ui/download_dialog.py index 20229032..a27f3238 100644 --- a/app/ui/download_dialog.py +++ b/app/ui/download_dialog.py @@ -1,7 +1,7 @@ from gi.repository import GLib from app.commons import run_idle, run_task -from app.ftp import download_data, DownloadType, upload_data +from app.connections import download_data, DownloadType, upload_data from app.properties import Profile from .uicommons import Gtk, UI_RESOURCES_PATH, TEXT_DOMAIN from .dialogs import show_dialog, DialogType, get_message diff --git a/app/ui/new_download_dialog.glade b/app/ui/new_download_dialog.glade index 2a3df17a..35d0a3ad 100644 --- a/app/ui/new_download_dialog.glade +++ b/app/ui/new_download_dialog.glade @@ -33,13 +33,8 @@ Author: Dmitriy Yefremov - - True - False - gtk-connect - - 560 + 500 False False True @@ -55,33 +50,13 @@ Author: Dmitriy Yefremov 5 True - + True False 2 - - - True - True - True - Cancel - - - True - False - gtk-cancel - - - - - False - True - 0 - - - 75 + 48 True True True @@ -95,6 +70,28 @@ Author: Dmitriy Yefremov + + False + True + 0 + + + + + 48 + True + True + True + Send + + + + True + False + gtk-goto-top + + + False True @@ -110,7 +107,7 @@ Author: Dmitriy Yefremov 5 2 vertical - 2 + 5 True @@ -210,18 +207,18 @@ Author: Dmitriy Yefremov - - 75 + + 48 True True True - Send - + Options + - + True False - gtk-goto-top + gtk-properties @@ -264,6 +261,7 @@ Author: Dmitriy Yefremov False 2 2 + True True @@ -388,7 +386,7 @@ Author: Dmitriy Yefremov False True - 1 + 2 @@ -404,7 +402,7 @@ Author: Dmitriy Yefremov - + True False 5 @@ -414,132 +412,125 @@ Author: Dmitriy Yefremov 0.019999999552965164 in - + True False - vertical + + + 5 + 5 + 5 + 2 + 2 - + True False - - - 5 - 5 - 5 - 2 - 2 - - - True - False - Login: - 0.10000000149011612 - - - 0 - 0 - - - - - True - True - 15 - root - False - avatar-default-symbolic - - - 0 - 1 - - - - - True - False - Port: - 0.10000000149011612 - - - 2 - 0 - - - - - True - True - False - 8 - 21 - False - network-workgroup-symbolic - - - 2 - 1 - - - - - True - False - Password: - 0.10000000149011612 - - - 1 - 0 - - - - - True - True - False - - 15 - root - emblem-readonly - password - - - 1 - 1 - - - - - Test - True - True - True - Test connection - True - connection_image - True - - - 3 - 1 - - - - - + Login: + 0.10000000149011612 - False - True - 0 + 0 + 0 + + + + + True + True + root + False + avatar-default-symbolic + + + 0 + 1 + + + + + True + False + Password: + 0.10000000149011612 + + + 1 + 0 + + + + + True + True + False + + root + emblem-readonly + password + + + 1 + 1 + + + + + True + False + Port: + 0.10000000149011612 + + + 2 + 0 + + + + + True + True + False + 8 + 21 + False + network-workgroup-symbolic + + + 2 + 1 + + + + + True + True + False + 8 + False + alarm-symbolic + digits + + + 3 + 1 + + + + + True + False + Timeout: + + + 3 + 0 - + True False @@ -566,7 +557,7 @@ Author: Dmitriy Yefremov True False False - ftp_radio_button + telnet_radio_button @@ -582,7 +573,7 @@ Author: Dmitriy Yefremov True False False - http_radio_button + ftp_radio_button diff --git a/app/ui/new_download_dialog.py b/app/ui/new_download_dialog.py index abc52856..27e58e77 100644 --- a/app/ui/new_download_dialog.py +++ b/app/ui/new_download_dialog.py @@ -1,8 +1,9 @@ from gi.repository import GLib from app.commons import run_idle, run_task -from app.ftp import download_data, DownloadType, upload_data -from app.properties import Profile +from app.connections import download_data, DownloadType, upload_data +from app.properties import Profile, get_config +from app.ui.settings_dialog import show_settings_dialog from .uicommons import Gtk, UI_RESOURCES_PATH, TEXT_DOMAIN from .dialogs import show_dialog, DialogType, get_message @@ -16,6 +17,7 @@ class DownloadDialog: handlers = {"on_receive": self.on_receive, "on_send": self.on_send, "on_settings_button": self.on_settings_button, + "on_preferences": self.on_preferences, "on_info_bar_close": self.on_info_bar_close} builder = Gtk.Builder() @@ -23,6 +25,7 @@ class DownloadDialog: builder.add_from_file(UI_RESOURCES_PATH + "new_download_dialog.glade") builder.connect_signals(handlers) + self._current_property = "FTP" self._dialog_window = builder.get_object("download_dialog_window") self._dialog_window.set_transient_for(transient) self._info_bar = builder.get_object("info_bar") @@ -36,6 +39,7 @@ class DownloadDialog: self._webtv_radio_button = builder.get_object("webtv_radio_button") self._login_entry = builder.get_object("login_entry") self._password_entry = builder.get_object("password_entry") + self._host_entry = builder.get_object("host_entry") self._port_entry = builder.get_object("port_entry") if profile is Profile.NEUTRINO_MP: @@ -83,6 +87,10 @@ class DownloadDialog: self._login_entry.set_text(self._properties.get("user", "root")) self._password_entry.set_text(self._properties.get("password", "root")) self._port_entry.set_text(self._properties.get("port", "21")) + self._current_property = label + + def on_preferences(self, item): + show_settings_dialog(self._dialog_window, get_config()) def on_info_bar_close(self, bar=None, resp=None): self._info_bar.set_visible(False) diff --git a/app/ui/picons_downloader.py b/app/ui/picons_downloader.py index 17993f3b..6c14b5ea 100644 --- a/app/ui/picons_downloader.py +++ b/app/ui/picons_downloader.py @@ -8,7 +8,7 @@ import time from gi.repository import GLib, GdkPixbuf from app.commons import run_idle, run_task -from app.ftp import upload_data, DownloadType +from app.connections import upload_data, DownloadType from app.tools.picons import PiconsParser, parse_providers, Provider, convert_to from app.properties import Profile from app.tools.satellites import SatellitesParser, SatelliteSource