telnet options

This commit is contained in:
Dmitriy Yefremov
2018-01-18 00:57:58 +03:00
parent 240d724b59
commit 24c064b450
4 changed files with 16 additions and 23 deletions

View File

@@ -58,8 +58,8 @@ def upload_data(*, properties, download_type=DownloadDataType.ALL, remove_unused
data_path = properties["data_dir_path"]
host = properties["host"]
# telnet
tn = telnet(host=host, user=None if profile is Profile.ENIGMA_2 else "root", password=None,
timeout=5 if profile is Profile.ENIGMA_2 else 1)
tn = telnet(host=host, user=properties.get("telnet_user", "root"), password=properties.get("telnet_password", ""),
timeout=properties.get("telnet_timeout", 5))
next(tn)
# terminate enigma or enigma
tn.send("init 4")
@@ -119,7 +119,7 @@ def send_file(file_name, path, ftp):
return ftp.storbinary("STOR " + file_name, f)
def telnet(host, port=23, user=None, password=None, timeout=5):
def telnet(host, port=23, user="", password="", timeout=5):
try:
tn = Telnet(host=host, port=port, timeout=timeout)
except socket.timeout:
@@ -127,11 +127,11 @@ def telnet(host, port=23, user=None, password=None, timeout=5):
else:
time.sleep(1)
command = yield
if user is not None:
if user != "":
tn.read_until(b"login: ")
tn.write(user.encode("utf-8") + b"\n")
time.sleep(timeout)
if password is not None:
if password != "":
tn.read_until(b"Password: ")
tn.write(password.encode("utf-8") + b"\n")
time.sleep(timeout)

View File

@@ -223,21 +223,7 @@ dmitry.v.yefremov@gmail.com
</packing>
</child>
<child>
<object class="GtkRadioButton" id="picons_radio_button">
<property name="label" translatable="yes">Picons</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<property name="group">satellites_radio_button</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
<placeholder/>
</child>
</object>
<packing>
@@ -620,9 +606,12 @@ dmitry.v.yefremov@gmail.com
</child>
</object>
<object class="GtkAdjustment" id="telnet_timeout_adjustment">
<property name="upper">100</property>
<property name="lower">1</property>
<property name="upper">11</property>
<property name="value">1</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
<property name="page_size">1</property>
</object>
<object class="GtkDialog" id="settings_dialog">
<property name="can_focus">False</property>
@@ -821,7 +810,6 @@ dmitry.v.yefremov@gmail.com
<child>
<object class="GtkGrid" id="telnet_settings_grid">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="column_spacing">2</property>
<property name="column_homogeneous">True</property>
@@ -907,8 +895,12 @@ dmitry.v.yefremov@gmail.com
<object class="GtkSpinButton" id="telnet_timeout_spin_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">Timeout between commands in seconds</property>
<property name="max_length">2</property>
<property name="primary_icon_name">alarm-symbolic</property>
<property name="input_purpose">number</property>
<property name="adjustment">telnet_timeout_adjustment</property>
<property name="numeric">True</property>
</object>
<packing>
<property name="left_attach">1</property>

View File

@@ -613,6 +613,7 @@ class MainAppWindow:
for v in [view, *args]:
v.get_selection().unselect_all()
@run_idle
def on_preferences(self, item):
response = show_settings_dialog(self.__main_window, self.__options)
if response != Gtk.ResponseType.CANCEL:

View File

@@ -106,7 +106,7 @@ class SettingsDialog:
options["telnet_user"] = self._telnet_login_field.get_text()
options["telnet_password"] = self._telnet_password_field.get_text()
options["telnet_port"] = self._telnet_port_field.get_text()
options["telnet_timeout"] = self._telnet_timeout_spin_button.get_value()
options["telnet_timeout"] = int(self._telnet_timeout_spin_button.get_value())
options["services_path"] = self._services_field.get_text()
options["user_bouquet_path"] = self._user_bouquet_field.get_text()
options["satellites_xml_path"] = self._satellites_xml_field.get_text()