7 Commits

Author SHA1 Message Date
b36e27a7f2 Clean up keyring when a connection is deleted 2023-01-10 23:23:55 +01:00
5488e7cc81 Bugfix for new settings management
Do not create new internal_id, if the setting already have one.
Do not create new entries, if the setting is the last one in the array.
2023-01-10 15:17:29 +01:00
8790e508ad Show just the hostname without .local in avahisearch.py list 2023-01-10 15:06:46 +01:00
7a7741e60b Save SSH credentials with keyring module
The keyring module will save the username and password of the SSH
connection to the operating system password storage.
2023-01-10 09:08:33 +01:00
2039f6cfe2 Set the use of ssh tunnel to default value for new settings 2023-01-09 20:47:35 +01:00
1e8200cc55 Change most button pressed event to clicked and add global shortcuts
Most events of the buttons was on pressed, which should not be used. Now
the debugcontrol buttons has a repeating pressed event, if you hold the
button, it will read the IOs every 200 ms. The shortcuts F4, F5, F6 to
read/write IOs are now application wide.
2023-01-09 19:40:00 +01:00
98b4879b7f Manage revolution pi saved settings in an own class
Start a complete new setting file with right naming. Import all old
saved connections from old settings file. Revolution Pi saved settings
are now in an own class with all properties and default values. All
modules are using this new setting class, which support the save
function.
2023-01-09 17:22:47 +01:00
28 changed files with 987 additions and 768 deletions

View File

@@ -4,6 +4,7 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/venv" />
<excludeFolder url="file://$MODULE_DIR$/build" />
</content>
<orderEntry type="jdk" jdkName="Python 3.9 (revpicommander)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />

View File

@@ -9,5 +9,4 @@ include README.md
include requirements.txt
include setup.iss
include setup.py
include stdeb.cfg
include translate.pro

View File

@@ -5,3 +5,4 @@ zeroconf>=0.24.4
setuptools>=65.6.3
wheel
paramiko>=2.12.0
keyring>=23.13.1

View File

@@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "RevPi Commander"
#define MyAppVersion "0.9.10rc1"
#define MyAppVersion "0.9.10rc2"
#define MyAppPublisher "Sven Sager"
#define MyAppURL "https://revpimodio.org/"
#define MyAppICO "data\revpicommander.ico"

View File

@@ -8,26 +8,26 @@ from setuptools import find_namespace_packages, setup
setup(
name="revpicommander",
version="0.9.10rc1",
version="0.9.10rc2",
packages=find_namespace_packages("src"),
package_dir={'': 'src'},
include_package_data=True,
install_requires=[
"keyring",
"PyQt5",
"revpimodio2",
"zeroconf"
],
entry_points={
'console_scripts': [
'revpicommander = revpicommander.revpicommander:main',
],
'gui_scripts': [
'RevPiCommander = revpicommander.revpicommander:main',
'revpicommander-gui = revpicommander.revpicommander:main',
],
},
platforms=["all"],
url="https://revpimodio.org/revpipyplc/",
license="GPLv3",
author="Sven Sager",
@@ -40,6 +40,7 @@ setup(
"of RevPiPyLoad and do IO checks on your local machine. Developing your\n"
"control program is very easy with the developer, upload and debug it\n"
"over the network.",
keywords=["revpi", "revolution pi", "revpimodio", "plc"],
classifiers=[
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
],

View File

@@ -85,7 +85,7 @@ class AclManager(QtWidgets.QDialog, Ui_diag_aclmanager):
)
) == QtWidgets.QMessageBox.Yes
if ask:
self.on_btn_add_pressed()
self.on_btn_add_clicked()
if self.__check_load_error():
return
@@ -252,11 +252,11 @@ class AclManager(QtWidgets.QDialog, Ui_diag_aclmanager):
self.btn_remove.setEnabled(not self.__read_only and selected_rows > 0)
@QtCore.pyqtSlot()
def on_btn_edit_pressed(self):
def on_btn_edit_clicked(self):
self.__load_selected_entry()
@QtCore.pyqtSlot()
def on_btn_remove_pressed(self):
def on_btn_remove_clicked(self):
lst_selected_row_indexes = [mi.row() for mi in self.tb_acls.selectionModel().selectedRows(0)]
if len(lst_selected_row_indexes) == 0:
return
@@ -355,7 +355,7 @@ class AclManager(QtWidgets.QDialog, Ui_diag_aclmanager):
self._check_all_filled()
@QtCore.pyqtSlot()
def on_btn_add_pressed(self):
def on_btn_add_clicked(self):
"""Add a new entry to acl table."""
ip_level = "{0}.{1}.{2}.{3},{4}".format(
self.txt_ip_a.text(),
@@ -366,7 +366,7 @@ class AclManager(QtWidgets.QDialog, Ui_diag_aclmanager):
)
if self.__re_ipacl.match(ip_level):
self.__table_add_acl(ip_level)
self.on_btn_clear_pressed()
self.on_btn_clear_clicked()
else:
QtWidgets.QMessageBox.critical(
self, self.tr("Error"), self.tr(
@@ -376,7 +376,7 @@ class AclManager(QtWidgets.QDialog, Ui_diag_aclmanager):
)
@QtCore.pyqtSlot()
def on_btn_clear_pressed(self):
def on_btn_clear_clicked(self):
"""Clear entry widgets."""
self.txt_ip_a.clear()
self.txt_ip_b.clear()

View File

@@ -5,40 +5,18 @@ __copyright__ = "Copyright (C) 2023 Sven Sager"
__license__ = "GPLv3"
import webbrowser
from os import name as osname
from re import compile
from sys import platform
from PyQt5 import QtCore, QtGui, QtWidgets
from zeroconf import IPVersion, ServiceBrowser, Zeroconf
from . import helper
from . import proginit as pi
from .helper import WidgetData, settings
from .helper import RevPiSettings, WidgetData, all_revpi_settings
from .ui.avahisearch_ui import Ui_diag_search
def find_settings_index(address: str, port: int) -> int:
"""
Search index of saved settings.
:param address: Host or IP address of Revolution Pi
:param port: Port to connect
:return: Index of settings array or -1, if not found
"""
settings_index = -1
for i in range(settings.beginReadArray("connections")):
settings.setArrayIndex(i)
_address = settings.value("address", type=str)
_port = settings.value("port", type=int)
if address.lower() == _address.lower() and port == _port:
settings_index = i
break
settings.endArray()
return settings_index
class AvahiSearchThread(QtCore.QThread):
"""Search thread for Revolution Pi with installed RevPiPyLoad."""
added = QtCore.pyqtSignal(str, str, int, str, str)
@@ -49,30 +27,11 @@ class AvahiSearchThread(QtCore.QThread):
super(AvahiSearchThread, self).__init__(parent)
self._cycle_wait_ms = 1000
self.__dict_arp = {}
self.re_posix = compile(
r"(?P<ip>(\d{1,3}\.){3}\d{1,3}).*"
r"(?P<mac>([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2})"
)
def _update_arp(self) -> None:
"""Find mac address in arp table."""
if osname == "posix":
with open("/proc/net/arp") as fh:
for line in fh.readlines():
ip_mac = self.re_posix.search(line)
if ip_mac:
self.__dict_arp[ip_mac.group("ip")] = ip_mac.group("mac")
def get_mac(self, ip: str) -> dict:
"""
Get mac address of ip, if known.
:param ip: IP address to find mac address
:return: MAC address as string or empty string, if unknown
"""
return self.__dict_arp.get(ip, "")
def remove_service(self, zeroconf: Zeroconf, conf_type: str, name: str) -> None:
"""Revolution Pi disappeared."""
pi.logger.debug("AvahiSearchThread.remove_service")
@@ -115,17 +74,20 @@ class AvahiSearch(QtWidgets.QDialog, Ui_diag_search):
super(AvahiSearch, self).__init__(parent)
self.setupUi(self)
# Global variables to let parent decide other actions
self.connect_settings = None
self.just_save = False
# Local variables
self.clipboard = QtGui.QGuiApplication.clipboard()
self.connect_index = -1
self.known_hosts = {}
self.th_zero_conf = AvahiSearchThread(self)
self._th_zero_conf = AvahiSearchThread(self)
self.tb_revpi.setColumnWidth(0, 250)
self.btn_connect.setEnabled(False)
self.btn_save.setEnabled(False)
self.restoreGeometry(settings.value("avahisearch/geo", b''))
column_sizes = settings.value("avahisearch/column_sizes", [], type=list)
self.restoreGeometry(helper.settings.value("avahisearch/geo", b''))
column_sizes = helper.settings.value("avahisearch/column_sizes", [], type=list)
if len(column_sizes) == self.tb_revpi.columnCount():
for i in range(self.tb_revpi.columnCount()):
self.tb_revpi.setColumnWidth(i, int(column_sizes[i]))
@@ -136,174 +98,148 @@ class AvahiSearch(QtWidgets.QDialog, Ui_diag_search):
self.cm_connect_actions.addAction(self.act_connect_xmlrpc)
self.cm_quick_actions = QtWidgets.QMenu(self)
self.cm_quick_actions.addAction(self.act_open_pictory)
self.cm_quick_actions.addSeparator()
self.cm_quick_actions.addAction(self.act_copy_ip)
self.cm_quick_actions.addAction(self.act_copy_host)
self.cm_quick_actions.addSeparator()
self.cm_quick_actions.addAction(self.act_connect)
self.cm_quick_actions.addAction(self.act_connect_ssh)
self.cm_quick_actions.addAction(self.act_connect_xmlrpc)
self.cm_quick_actions.addSeparator()
self.cm_quick_actions.addAction(self.act_open_pictory)
self.cm_quick_actions.addSeparator()
self.cm_quick_actions.addAction(self.act_copy_host)
self.cm_quick_actions.addAction(self.act_copy_ip)
self.tb_revpi.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.tb_revpi.customContextMenuRequested.connect(self._cm_quick_exec)
@QtCore.pyqtSlot(QtCore.QPoint)
def _cm_connect_exec(self, position: QtCore.QPoint) -> None:
row = self.tb_revpi.currentRow()
if row == -1:
return
item = self.tb_revpi.item(row, 0)
settings_index = find_settings_index(item.data(WidgetData.address), item.data(WidgetData.port))
if settings_index >= 0:
self.connect_index = settings_index
self.accept()
return
action = self.cm_connect_actions.exec(position)
if action:
action.trigger()
@QtCore.pyqtSlot(QtCore.QPoint)
def _cm_quick_exec(self, position: QtCore.QPoint) -> None:
if self.tb_revpi.currentItem() is None:
selected_items = self.tb_revpi.selectedItems()
if not selected_items:
return
item = selected_items[0]
revpi_settings = bool(item.data(WidgetData.revpi_settings))
self.act_connect.setVisible(revpi_settings)
self.act_connect_ssh.setVisible(not revpi_settings)
self.act_connect_xmlrpc.setVisible(not revpi_settings)
sender = self.sender()
action = self.cm_quick_actions.exec(sender.mapToGlobal(position))
if action:
action.trigger()
self.cm_quick_actions.exec(sender.mapToGlobal(position))
def _load_known_hosts(self) -> None:
"""Load existing connections to show hostname of existing ip addresses"""
self.known_hosts.clear()
self.act_connect.setVisible(True)
self.act_connect_ssh.setVisible(True)
self.act_connect_xmlrpc.setVisible(True)
for i in range(settings.beginReadArray("connections")):
settings.setArrayIndex(i)
name = settings.value("name", type=str)
folder = settings.value("folder", type=str)
address = settings.value("address", type=str)
self.known_hosts[address] = "{0}/{1}".format(folder, name) if folder else name
settings.endArray()
@staticmethod
def _find_settings(address: str) -> list[RevPiSettings]:
"""Find all settings with known avahi_id."""
return [
revpi_setting
for revpi_setting in all_revpi_settings()
if revpi_setting.address.lower() == address.lower()
]
def _restart_search(self) -> None:
"""Clean up and restart search thread."""
while self.tb_revpi.rowCount() > 0:
# Remove each row, a .clean would destroy the columns
self.tb_revpi.removeRow(0)
self.th_zero_conf.requestInterruption()
self.th_zero_conf = AvahiSearchThread(self)
self.th_zero_conf.added.connect(self.on_avahi_added)
self.th_zero_conf.updated.connect(self.on_avahi_added)
self.th_zero_conf.removed.connect(self.on_avahi_removed)
self.th_zero_conf.start()
self._th_zero_conf.requestInterruption()
def _save_connection(self, row: int, ssh_tunnel: bool, no_warn=False) -> int:
self._th_zero_conf = AvahiSearchThread(self)
self._th_zero_conf.added.connect(self.on_avahi_added)
self._th_zero_conf.updated.connect(self.on_avahi_added)
self._th_zero_conf.removed.connect(self.on_avahi_removed)
self._th_zero_conf.start()
def _create_settings_object(self, row: int, ssh_tunnel: bool) -> RevPiSettings or None:
"""
Save the connection from given row to settings.
Create settings object from given row to settings.
:param row: Row with connection data
:param ssh_tunnel: Save as SSH tunnel connection
:param no_warn: If True, no message boxes will appear
:return: Array index of connection (found or saved) or -1
:return: RevPi settings with data from avahi search and default values
"""
item = self.tb_revpi.item(row, 0)
if not item:
return -1
return None
folder_name = self.tr("Auto discovered")
selected_name = item.text()
selected_address = item.data(WidgetData.address)
selected_port = item.data(WidgetData.port)
i = 0
for i in range(settings.beginReadArray("connections")):
settings.setArrayIndex(i)
settings = RevPiSettings()
settings.folder = self.tr("Auto discovered")
settings.name = item.data(WidgetData.host_name)
settings.address = item.data(WidgetData.address)
settings.port = item.data(WidgetData.port)
settings.ssh_use_tunnel = ssh_tunnel
name = settings.value("name", type=str)
address = settings.value("address", type=str)
port = settings.value("port", type=int)
if address.lower() == selected_address.lower() and port == selected_port:
if not no_warn:
QtWidgets.QMessageBox.information(
self, self.tr("Already in list..."), self.tr(
"The selected Revolution Pi is already saved in your "
"connection list as '{0}'."
).format(name)
)
settings.endArray()
return i
settings.endArray()
settings.beginWriteArray("connections")
settings.setArrayIndex(i + 1)
settings.setValue("address", selected_address)
settings.setValue("folder", folder_name)
settings.setValue("name", selected_name)
settings.setValue("port", selected_port)
settings.setValue("ssh_use_tunnel", ssh_tunnel)
settings.setValue("ssh_port", 22)
settings.setValue("ssh_user", "pi")
settings.endArray()
if not no_warn:
QtWidgets.QMessageBox.information(
self, self.tr("Success"), self.tr(
"The connection with the name '{0}' was successfully saved "
"to folder '{1}' in your connections."
).format(selected_name, folder_name)
)
return i + 1
return settings
def closeEvent(self, a0: QtGui.QCloseEvent) -> None:
settings.setValue("avahisearch/geo", self.saveGeometry())
settings.setValue("avahisearch/column_sizes", [
helper.settings.setValue("avahisearch/geo", self.saveGeometry())
helper.settings.setValue("avahisearch/column_sizes", [
self.tb_revpi.columnWidth(i)
for i in range(self.tb_revpi.columnCount())
])
def exec(self) -> int:
self._load_known_hosts()
self.connect_settings = None
self.just_save = False
self._restart_search()
rc = super(AvahiSearch, self).exec()
self.th_zero_conf.requestInterruption()
self._th_zero_conf.requestInterruption()
return rc
@QtCore.pyqtSlot()
def on_act_connect_ssh_triggered(self) -> None:
"""Copy ip address of selected item to clipboard."""
pi.logger.debug("AvahiSearch.on_act_connect_ssh_triggered")
if self.tb_revpi.currentRow() == -1:
return
self.connect_index = self._save_connection(self.tb_revpi.currentRow(), True, no_warn=True)
self.accept()
@QtCore.pyqtSlot()
def on_act_connect_xmlrpc_triggered(self) -> None:
"""Copy ip address of selected item to clipboard."""
pi.logger.debug("AvahiSearch.on_act_connect_xmlrpc_triggered")
if self.tb_revpi.currentRow() == -1:
return
self.connect_index = self._save_connection(self.tb_revpi.currentRow(), False, no_warn=True)
self.accept()
@QtCore.pyqtSlot()
def on_act_copy_host_triggered(self) -> None:
"""Copy ip address of selected item to clipboard."""
def on_act_connect_triggered(self) -> None:
"""Connect via existing settings or ask for type."""
pi.logger.debug("AvahiSearch.on_act_connect_triggered")
selected_items = self.tb_revpi.selectedItems()
if not selected_items:
return
item = selected_items[0]
host_name = item.data(WidgetData.host_name)
if platform == "win32":
# Strip hostname on Windows systems, it can not resolve .local addresses
host_name = host_name[:host_name.find(".")]
self.clipboard.setText(host_name)
revpi_settings = item.data(WidgetData.revpi_settings) # type: RevPiSettings
if not revpi_settings:
return
self.connect_settings = revpi_settings
self.accept()
@QtCore.pyqtSlot()
def on_act_connect_ssh_triggered(self) -> None:
"""Create new revpi settings with ssh, save and connect."""
pi.logger.debug("AvahiSearch.on_act_connect_ssh_triggered")
if self.tb_revpi.currentRow() == -1:
return
revpi_settings = self._create_settings_object(self.tb_revpi.currentRow(), True)
revpi_settings.save_settings()
self.connect_settings = revpi_settings
self.accept()
@QtCore.pyqtSlot()
def on_act_connect_xmlrpc_triggered(self) -> None:
"""Create new revpi settings with XML-RPC, save and connect."""
pi.logger.debug("AvahiSearch.on_act_connect_xmlrpc_triggered")
if self.tb_revpi.currentRow() == -1:
return
revpi_settings = self._create_settings_object(self.tb_revpi.currentRow(), False)
revpi_settings.save_settings()
self.connect_settings = revpi_settings
self.accept()
@QtCore.pyqtSlot()
def on_act_copy_host_triggered(self) -> None:
"""Copy hostname of selected item to clipboard."""
selected_items = self.tb_revpi.selectedItems()
if not selected_items:
return
item = selected_items[0]
# Use just the hostname on Windows systems, it can not resolve .local addresses
self.clipboard.setText(
item.data(WidgetData.host_name) if platform == "win32"
else item.data(WidgetData.host_name_full)
)
@QtCore.pyqtSlot()
def on_act_copy_ip_triggered(self) -> None:
@@ -321,51 +257,71 @@ class AvahiSearch(QtWidgets.QDialog, Ui_diag_search):
if not selected_items:
return
item = selected_items[0]
if platform == "win32":
# Till we could not choose https / http we are using the ip address
webbrowser.open("http://{0}/".format(item.data(WidgetData.address)))
else:
webbrowser.open("http://{0}/".format(item.data(WidgetData.host_name)))
@QtCore.pyqtSlot(str, str, int, str, str)
def on_avahi_added(self, name: str, server: str, port: int, conf_type: str, ip: str) -> None:
def on_avahi_added(self, avahi_id: str, server: str, port: int, conf_type: str, ip: str) -> None:
"""New Revolution Pi found."""
index = -1
for i in range(self.tb_revpi.rowCount()):
if self.tb_revpi.item(i, 0).data(WidgetData.object_name) == name:
index = i
break
if index == -1:
# New Row
def update_tb_revpi_row(row_index: int):
host_name_full = server[:-1]
host_name = host_name_full[:host_name_full.find(".")]
item_name = self.tb_revpi.item(row_index, 0)
item_name.setData(WidgetData.address, ip)
item_name.setData(WidgetData.port, port)
item_name.setData(WidgetData.host_name_full, host_name_full)
item_name.setData(WidgetData.host_name, host_name)
revpi_settings = item_name.data(WidgetData.revpi_settings) # type: RevPiSettings
if revpi_settings:
# Generate the name of saved revpi and show the avahi-name in brackets
settings_text = "{0}/{1}".format(revpi_settings.folder, revpi_settings.name) \
if revpi_settings.folder \
else revpi_settings.name
if revpi_settings.ssh_use_tunnel:
settings_text += self.tr(" over SSH")
item_name.setText("{0} ({1})".format(settings_text, host_name))
else:
item_name.setText(host_name)
item_name.setToolTip(item_name.text())
item_ip = self.tb_revpi.item(row_index, 1)
item_ip.setText(ip)
item_ip.setToolTip(item_name.text())
lst_existing = self._find_settings(ip)
exists = False
for i in range(self.tb_revpi.rowCount()):
item_tb_revpi = self.tb_revpi.item(i, 0)
if item_tb_revpi.data(WidgetData.object_name) == avahi_id:
# Object already discovered
update_tb_revpi_row(i)
exists = True
if not exists:
for known_settings in lst_existing or [None]:
item_name = QtWidgets.QTableWidgetItem()
item_ip = QtWidgets.QTableWidgetItem()
item_name.setIcon(QtGui.QIcon(":/main/ico/cpu.ico"))
item_name.setData(WidgetData.object_name, avahi_id)
item_name.setData(WidgetData.revpi_settings, known_settings)
index = self.tb_revpi.rowCount()
self.tb_revpi.insertRow(index)
self.tb_revpi.setItem(index, 0, item_name)
self.tb_revpi.setItem(index, 1, item_ip)
else:
# Update row
item_name = self.tb_revpi.item(index, 0)
item_ip = self.tb_revpi.item(index, 1)
self.tb_revpi.setItem(index, 1, QtWidgets.QTableWidgetItem())
host_name = server[:-1]
item_name.setIcon(QtGui.QIcon(":/main/ico/cpu.ico"))
if ip in self.known_hosts:
item_name.setText("{0} ({1})".format(host_name, self.known_hosts[ip]))
else:
item_name.setText(host_name)
item_name.setData(WidgetData.object_name, name)
item_name.setData(WidgetData.address, ip)
item_name.setData(WidgetData.port, port)
item_name.setData(WidgetData.host_name, host_name)
item_ip.setText(ip)
update_tb_revpi_row(index)
@QtCore.pyqtSlot(str, str)
def on_avahi_removed(self, name: str, conf_type: str) -> None:
def on_avahi_removed(self, avahi_id: str, conf_type: str) -> None:
"""Revolution Pi disappeared."""
for i in range(self.tb_revpi.rowCount()):
if self.tb_revpi.item(i, 0).data(WidgetData.object_name) == name:
if self.tb_revpi.item(i, 0).data(WidgetData.object_name) == avahi_id:
self.tb_revpi.removeRow(i)
break
@@ -373,8 +329,17 @@ class AvahiSearch(QtWidgets.QDialog, Ui_diag_search):
def on_tb_revpi_cellDoubleClicked(self, row: int, column: int) -> None:
"""Connect to double-clicked Revolution Pi."""
pi.logger.debug("AvahiSearch.on_tb_revpi_cellDoubleClicked")
selected_items = self.tb_revpi.selectedItems()
if not selected_items:
return
item = selected_items[0]
revpi_settings = bool(item.data(WidgetData.revpi_settings))
if revpi_settings:
self.act_connect.trigger()
else:
cur = QtGui.QCursor()
self._cm_connect_exec(cur.pos())
self.cm_connect_actions.exec(cur.pos())
@QtCore.pyqtSlot(int, int, int, int)
def on_tb_revpi_currentCellChanged(self, row: int, column: int, last_row: int, last_column: int) -> None:
@@ -386,18 +351,29 @@ class AvahiSearch(QtWidgets.QDialog, Ui_diag_search):
def on_btn_connect_clicked(self) -> None:
"""Connect to selected Revolution Pi."""
pi.logger.debug("AvahiSearch.on_btn_connect_clicked")
# Open context menu under the button
pos = self.btn_connect.pos()
pos.setY(pos.y() + self.btn_connect.height())
self._cm_connect_exec(self.mapToGlobal(pos))
selected_items = self.tb_revpi.selectedItems()
if not selected_items:
return
item = selected_items[0]
revpi_settings = bool(item.data(WidgetData.revpi_settings))
if revpi_settings:
self.act_connect.trigger()
else:
pos_context_menu = self.btn_connect.pos()
pos_context_menu.setY(pos_context_menu.y() + self.btn_connect.height())
self.cm_connect_actions.exec(self.mapToGlobal(pos_context_menu))
@QtCore.pyqtSlot()
def on_btn_save_clicked(self) -> None:
"""Save selected Revolution Pi."""
pi.logger.debug("AvahiSearch.on_btn_save_clicked")
if self.tb_revpi.currentRow() == -1:
row_index = self.tb_revpi.currentRow()
if row_index == -1:
return
self.connect_index = self._save_connection(self.tb_revpi.currentRow(), ssh_tunnel=True)
self.connect_settings = self._create_settings_object(row_index, True)
self.just_save = True
self.accept()
@QtCore.pyqtSlot()
def on_btn_restart_clicked(self) -> None:

View File

@@ -45,7 +45,7 @@ class BackgroundWorker(QtCore.QThread):
while counter != 0:
counter -= 1
self.msleep(250)
if self._check_cancel():
if self.check_cancel():
break
def run(self) -> None:
@@ -54,7 +54,7 @@ class BackgroundWorker(QtCore.QThread):
self.status_message.emit("Started dummy thread...")
self.wait_interruptable(5)
self.status_message.emit("Completed dummy thread.")
self._save_wait(3)
self.wait_interruptable(2)
class WorkerDialog(QtWidgets.QDialog, Ui_diag_backgroundworker):

View File

@@ -7,7 +7,7 @@ __license__ = "GPLv3"
import pickle
from xmlrpc.client import Binary, Fault, MultiCall, MultiCallIterator
from PyQt5 import QtCore, QtWidgets
from PyQt5 import QtCore, QtGui, QtWidgets
from . import helper
from . import proginit as pi
@@ -74,7 +74,17 @@ class DebugControl(QtWidgets.QWidget, Ui_wid_debugcontrol):
QtWidgets.QSpacerItem(20, 1, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
)
self.cbx_write.setEnabled(False)
self.cbx_stay_on_top.setChecked(helper.settings.value("stay_on_top", False, bool))
self.cbx_stay_on_top.setChecked(helper.settings.value("debugcontrol/stay_on_top", False, bool))
self.shc_read_io = QtWidgets.QShortcut(QtGui.QKeySequence("F4"), self)
self.shc_read_io.setContext(QtCore.Qt.ApplicationShortcut)
self.shc_read_io.activated.connect(self.on_btn_read_io_pressed)
self.shc_refresh_io = QtWidgets.QShortcut(QtGui.QKeySequence("F5"), self)
self.shc_refresh_io.setContext(QtCore.Qt.ApplicationShortcut)
self.shc_refresh_io.activated.connect(self.on_btn_refresh_io_pressed)
self.shc_write_o = QtWidgets.QShortcut(QtGui.QKeySequence("F6"), self)
self.shc_write_o.setContext(QtCore.Qt.ApplicationShortcut)
self.shc_write_o.activated.connect(self.on_btn_write_o_clicked)
def __del__(self):
pi.logger.debug("DebugControl.__del__")
@@ -323,8 +333,6 @@ class DebugControl(QtWidgets.QWidget, Ui_wid_debugcontrol):
dict_inps[position], dict_outs[position]
)
win.device_closed.connect(self.on_device_closed)
win.do_read.connect(self.btn_refresh_io.pressed)
win.do_write.connect(self.btn_write_o.pressed)
self.dict_windows[position] = win
btn = QtWidgets.QPushButton(self.gb_devices)
@@ -342,7 +350,7 @@ class DebugControl(QtWidgets.QWidget, Ui_wid_debugcontrol):
self._work_values(refresh=True)
self._set_gui_control_states()
self.cbx_refresh.setChecked(helper.settings.value("auto_refresh", False, bool))
self.cbx_refresh.setChecked(helper.settings.value("debugcontrol/auto_refresh", False, bool))
return True
@@ -380,9 +388,9 @@ class DebugControl(QtWidgets.QWidget, Ui_wid_debugcontrol):
self._work_values(refresh=True)
@QtCore.pyqtSlot()
def on_btn_write_o_pressed(self):
def on_btn_write_o_clicked(self):
"""Write outputs."""
pi.logger.debug("DebugControl.on_btn_write_o_pressed")
pi.logger.debug("DebugControl.on_btn_write_o_clicked")
if not self.cbx_write.isChecked() and (helper.cm.xml_mode >= 3 or helper.cm.simulating):
for win in self.dict_windows.values(): # type: DebugIos
win.reset_label_colors()
@@ -415,12 +423,12 @@ class DebugControl(QtWidgets.QWidget, Ui_wid_debugcontrol):
@QtCore.pyqtSlot(bool)
def on_cbx_refresh_clicked(self, state: bool):
"""Save the state on user action."""
helper.settings.setValue("auto_refresh", state)
helper.settings.setValue("debugcontrol/auto_refresh", state)
@QtCore.pyqtSlot(bool)
def on_cbx_stay_on_top_clicked(self, state: bool):
"""Save the state on user action."""
helper.settings.setValue("stay_on_top", state)
helper.settings.setValue("debugcontrol/stay_on_top", state)
@QtCore.pyqtSlot(int)
def on_cbx_write_stateChanged(self, state: int):

View File

@@ -18,15 +18,14 @@ class DebugIos(QtWidgets.QMainWindow, Ui_win_debugios):
device_closed = QtCore.pyqtSignal(int)
"""This window was closed."""
do_read = QtCore.pyqtSignal()
do_write = QtCore.pyqtSignal()
search_class = (QtWidgets.QLineEdit, QtWidgets.QDoubleSpinBox, QtWidgets.QCheckBox)
def __init__(self, position: int, name: str, inputs: list, outputs: list, parent=None):
super(DebugIos, self).__init__(parent)
self.setupUi(self)
self.restoreGeometry(helper.cm.debug_geos.get(position, b''))
self.restoreGeometry(helper.cm.settings.debug_geos.get(position, b''))
self.setWindowTitle("{0} - {1}".format(position, name))
self.gb_io.setTitle(self.gb_io.title().format(name))
@@ -48,17 +47,12 @@ class DebugIos(QtWidgets.QMainWindow, Ui_win_debugios):
self._create_io(self.outputs, self.saw_out, False)
self.style_sheet = "background-color: red;"
shc_read = QtWidgets.QShortcut(QtGui.QKeySequence("F5"), self)
shc_read.activated.connect(self.do_read)
shc_write = QtWidgets.QShortcut(QtGui.QKeySequence("F6"), self)
shc_write.activated.connect(self.do_write)
def __del__(self):
pi.logger.debug("DebugIos.__del__")
def closeEvent(self, a0: QtGui.QCloseEvent):
pi.logger.debug("DebugIos.closeEvent")
helper.cm.debug_geos[self.position] = self.saveGeometry()
helper.cm.settings.debug_geos[self.position] = self.saveGeometry()
self.device_closed.emit(self.position)
@staticmethod

View File

@@ -12,6 +12,7 @@ from os import environ, remove
from os.path import exists
from queue import Queue
from threading import Lock
from uuid import uuid4
from xmlrpc.client import Binary, ServerProxy
from PyQt5 import QtCore, QtWidgets
@@ -19,33 +20,175 @@ from paramiko.ssh_exception import AuthenticationException
from . import proginit as pi
from .ssh_tunneling.server import SSHLocalTunnel
from .sshauth import SSHAuth, SSHAuthType
from .sshauth import SSHAuth
settings = QtCore.QSettings("revpimodio.org", "RevPiCommander")
"""Global application settings."""
homedir = environ.get("HOME", "") or environ.get("APPDATA", "")
"""Home dir of user."""
class WidgetData(IntEnum):
address = 260
replace_ios_config = 261
acl_level = 262
has_error = 263
port = 264
object_name = 265
timeout = 266
host_name = 267
last_dir_upload = 301
last_file_upload = 302
last_dir_pictory = 303
last_dir_picontrol = 304
last_dir_selected = 305
last_pictory_file = 306
last_tar_file = 307
last_zip_file = 308
host_name_full = 268
file_name = 309
watch_files = 310
watch_path = 311
debug_geos = 312
ssh_use_tunnel = 313
ssh_port = 315
ssh_user = 316
revpi_settings = 320
class RevPiSettings:
def __init__(self, load_index: int = None, settings_storage: QtCore.QSettings = None):
"""
Revolution Pi saved settings.
:param load_index: Load settings from index, same as .load_from_index
:param settings_storage: Change QSettings object to work on from default to this one
"""
self._settings = settings_storage or settings
self.internal_id = ""
self.name = "New connection"
self.folder = ""
self.address = "127.0.0.1"
self.port = 55123
self.timeout = 5
self.ssh_use_tunnel = True
self.ssh_port = 22
self.ssh_user = "pi"
self.ssh_saved_password = False
self.last_dir_upload = "."
self.last_file_upload = "."
self.last_dir_pictory = "."
self.last_dir_picontrol = "."
self.last_dir_selected = "."
self.last_pictory_file = ""
self.last_tar_file = ""
self.last_zip_file = ""
self.watch_files = []
self.watch_path = ""
self.debug_geos = {}
if load_index is not None:
self.load_from_index(load_index)
def load_from_index(self, settings_index: int) -> None:
"""Load settings from 'connections' index."""
self._settings.beginReadArray("connections")
self._settings.setArrayIndex(settings_index)
# Flag as "legacy" connection to generate missing internal_id on save_settings()
self.internal_id = self._settings.value("internal_id", "legacy", type=str)
self.name = self._settings.value("name", type=str)
self.folder = self._settings.value("folder", "", type=str)
self.address = self._settings.value("address", type=str)
self.port = self._settings.value("port", 55123, type=int)
self.timeout = self._settings.value("timeout", 5, type=int)
self.ssh_use_tunnel = self._settings.value("ssh_use_tunnel", True, type=bool)
self.ssh_port = self._settings.value("ssh_port", 22, type=int)
self.ssh_user = self._settings.value("ssh_user", "pi", type=str)
self.ssh_saved_password = self._settings.value("ssh_saved_password", False, type=bool)
self.last_dir_upload = self._settings.value("last_dir_upload", ".", type=str)
self.last_file_upload = self._settings.value("last_file_upload", ".", type=str)
self.last_dir_pictory = self._settings.value("last_dir_pictory", ".", type=str)
self.last_dir_picontrol = self._settings.value("last_dir_picontrol", ".", type=str)
self.last_dir_selected = self._settings.value("last_dir_selected", ".", type=str)
self.last_pictory_file = self._settings.value("last_pictory_file", "", type=str)
self.last_tar_file = self._settings.value("last_tar_file", "", type=str)
self.last_zip_file = self._settings.value("last_zip_file", "", type=str)
self.watch_files = self._settings.value("watch_files", [], type=list)
self.watch_path = self._settings.value("watch_path", "", type=str)
try:
# Bytes with QSettings are a little difficult sometimes
self.debug_geos = self._settings.value("debug_geos", {}, type=dict)
except Exception:
# Just drop the geos of IO windows
pass
# These values must exists
if not (self.name and self.address and self.port):
raise ValueError("Could not geht all required values from saved settings")
self._settings.endArray()
def save_settings(self):
"""Save all settings."""
count_settings = self._settings.beginReadArray("connections")
def create_new_array_member():
"""Insert a new setting at the end of the array."""
# Close the active array action to reopen a write action to expand the array
self._settings.endArray()
self._settings.beginWriteArray("connections")
self._settings.setArrayIndex(count_settings)
if not self.internal_id:
self.internal_id = uuid4().hex
if not self.internal_id:
create_new_array_member()
else:
# Always search setting in array, because connection manager could reorganize array indexes
new_setting = True
for index in range(count_settings):
self._settings.setArrayIndex(index)
if self.internal_id == "legacy":
# Legacy connection without internal_id
if self._settings.value("address") == self.address:
# Set missing internal_id
self.internal_id = uuid4().hex
new_setting = False
break
else:
if self._settings.value("internal_id") == self.internal_id:
new_setting = False
break
if new_setting:
# On this point, we iterate all settings and found none, so create new one
create_new_array_member()
self._settings.setValue("internal_id", self.internal_id)
self._settings.setValue("name", self.name)
self._settings.setValue("folder", self.folder)
self._settings.setValue("address", self.address)
self._settings.setValue("port", self.port)
self._settings.setValue("timeout", self.timeout)
self._settings.setValue("ssh_use_tunnel", self.ssh_use_tunnel)
self._settings.setValue("ssh_port", self.ssh_port)
self._settings.setValue("ssh_user", self.ssh_user)
self._settings.setValue("ssh_saved_password", self.ssh_saved_password)
self._settings.setValue("last_dir_upload", self.last_dir_upload)
self._settings.setValue("last_file_upload", self.last_file_upload)
self._settings.setValue("last_dir_pictory", self.last_dir_pictory)
self._settings.setValue("last_dir_picontrol", self.last_dir_picontrol)
self._settings.setValue("last_dir_selected", self.last_dir_selected)
self._settings.setValue("last_pictory_file", self.last_pictory_file)
self._settings.setValue("last_tar_file", self.last_tar_file)
self._settings.setValue("last_zip_file", self.last_zip_file)
self._settings.setValue("watch_files", self.watch_files)
self._settings.setValue("watch_path", self.watch_path)
self._settings.setValue("debug_geos", self.debug_geos)
self._settings.endArray()
class ConnectionManager(QtCore.QThread):
@@ -75,29 +218,11 @@ class ConnectionManager(QtCore.QThread):
self._revpi = None
self._revpi_output = None
self.address = ""
self.name = ""
self.port = 55123
self.settings = RevPiSettings()
self.ssh_tunnel_server = None # type: SSHLocalTunnel
self.ssh_use_tunnel = False
self.ssh_port = 22
self.ssh_user = "pi"
self.ssh_pass = ""
# Sync this with revpiplclist to preserve settings
self.program_last_dir_upload = ""
self.program_last_file_upload = ""
self.program_last_dir_pictory = ""
self.program_last_dir_picontrol = ""
self.program_last_dir_selected = ""
self.program_last_pictory_file = ""
self.program_last_tar_file = ""
self.program_last_zip_file = ""
self.develop_watch_files = []
self.develop_watch_path = ""
self.debug_geos = {}
self.pyload_version = (0, 0, 0)
"""Version number of RevPiPyLoad 0.0.0 with <class 'int'> values."""
self.xml_funcs = []
@@ -178,60 +303,19 @@ class ConnectionManager(QtCore.QThread):
def _clear_settings(self):
"""Clear connection settings."""
self.address = ""
self.name = ""
self.port = 55123
self.settings = RevPiSettings()
self.ssh_use_tunnel = False
self.ssh_port = 22
self.ssh_user = "pi"
self.ssh_pass = ""
self.pyload_version = (0, 0, 0)
self.xml_funcs.clear()
self.xml_mode = -1
self.program_last_dir_upload = ""
self.program_last_file_upload = ""
self.program_last_dir_pictory = ""
self.program_last_dir_picontrol = ""
self.program_last_dir_selected = ""
self.program_last_pictory_file = ""
self.program_last_tar_file = ""
self.program_last_zip_file = ""
self.develop_watch_files = []
self.develop_watch_path = ""
self.debug_geos = {}
def _save_settings(self):
"""Save settings to named Revolution Pi."""
for i in range(settings.beginReadArray("connections")):
settings.setArrayIndex(i)
if settings.value("address") != self.address:
# Search used connection, because connection manager could reorganize array
continue
settings.setValue("last_dir_upload", self.program_last_dir_upload)
settings.setValue("last_file_upload", self.program_last_file_upload)
settings.setValue("last_dir_pictory", self.program_last_dir_pictory)
settings.setValue("last_dir_picontrol", self.program_last_dir_picontrol)
settings.setValue("last_dir_selected", self.program_last_dir_selected)
settings.setValue("last_pictory_file", self.program_last_pictory_file)
settings.setValue("last_tar_file", self.program_last_tar_file)
settings.setValue("last_zip_file", self.program_last_zip_file)
settings.setValue("watch_files", self.develop_watch_files)
settings.setValue("watch_path", self.develop_watch_path)
settings.setValue("debug_geos", self.debug_geos)
break
settings.endArray()
def pyload_connect(self, settings_index: int, parent=None) -> bool:
def pyload_connect(self, revpi_settings: RevPiSettings, parent=None) -> bool:
"""
Create a new connection from settings object.
:param settings_index: Index of settings array 'connections'
:param revpi_settings: Revolution Pi saved connection settings
:param parent: Qt parent window for dialog positioning
:return: True, if the connection was successfully established
"""
@@ -239,52 +323,39 @@ class ConnectionManager(QtCore.QThread):
# First disconnect to send signal and clean up values
self.pyload_disconnect()
settings.beginReadArray("connections")
settings.setArrayIndex(settings_index)
address = settings.value("address", str)
name = settings.value("name", str)
port = settings.value("port", 55123, int)
timeout = settings.value("timeout", 5, int)
ssh_tunnel_server = None
ssh_use_tunnel = settings.value("ssh_use_tunnel", False, bool)
ssh_port = settings.value("ssh_port", 22, int)
ssh_user = settings.value("ssh_user", "pi", str)
ssh_tunnel_port = 0
ssh_pass = ""
self.program_last_dir_upload = settings.value("last_dir_upload", ".", str)
self.program_last_file_upload = settings.value("last_file_upload", ".", str)
self.program_last_dir_pictory = settings.value("last_dir_pictory", ".", str)
self.program_last_dir_picontrol = settings.value("last_dir_picontrol", ".", str)
self.program_last_dir_selected = settings.value("last_dir_selected", ".", str)
self.program_last_pictory_file = settings.value("last_pictory_file", "{0}.rsc".format(name), str)
self.program_last_tar_file = settings.value("last_tar_file", "{0}.tgz".format(name), str)
self.program_last_zip_file = settings.value("last_zip_file", "{0}.zip".format(name), str)
self.develop_watch_files = settings.value("watch_files", [], list)
self.develop_watch_path = settings.value("watch_path", "", str)
self.debug_geos = settings.value("debug_geos", {}, dict)
settings.endArray()
socket.setdefaulttimeout(2)
if ssh_use_tunnel:
if revpi_settings.ssh_use_tunnel:
while True:
diag_ssh_auth = SSHAuth(SSHAuthType.PASS, parent)
diag_ssh_auth.username = ssh_user
diag_ssh_auth = SSHAuth(
revpi_settings.ssh_user,
"{0}.{1}_{2}".format(
settings.applicationName(),
settings.organizationName(),
revpi_settings.internal_id),
parent,
)
if not diag_ssh_auth.exec() == QtWidgets.QDialog.Accepted:
self._clear_settings()
return False
ssh_user = diag_ssh_auth.username
ssh_pass = diag_ssh_auth.password
ssh_tunnel_server = SSHLocalTunnel(port, address, ssh_port)
ssh_tunnel_server = SSHLocalTunnel(
revpi_settings.port,
revpi_settings.address,
revpi_settings.ssh_port
)
revpi_settings.ssh_saved_password = diag_ssh_auth.in_keyring
try:
ssh_tunnel_port = ssh_tunnel_server.connect_by_credentials(ssh_user, ssh_pass)
break
except AuthenticationException:
diag_ssh_auth.remove_saved_password()
QtWidgets.QMessageBox.critical(
parent, self.tr("Error"), self.tr(
"The combination of username and password was rejected from the SSH server.\n\n"
@@ -304,7 +375,7 @@ class ConnectionManager(QtCore.QThread):
sp = ServerProxy("http://127.0.0.1:{0}".format(ssh_tunnel_port))
else:
sp = ServerProxy("http://{0}:{1}".format(address, port))
sp = ServerProxy("http://{0}:{1}".format(revpi_settings.address, revpi_settings.port))
# Load values and test connection to Revolution Pi
try:
@@ -315,7 +386,7 @@ class ConnectionManager(QtCore.QThread):
pi.logger.exception(e)
self.connection_error_observed.emit(str(e))
if not self.ssh_use_tunnel:
if not revpi_settings.ssh_use_tunnel:
# todo: Change message, that user can use ssh
QtWidgets.QMessageBox.critical(
parent, self.tr("Error"), self.tr(
@@ -330,24 +401,19 @@ class ConnectionManager(QtCore.QThread):
return False
self.address = address
self.name = name
self.port = port
self.ssh_use_tunnel = ssh_use_tunnel
self.ssh_port = ssh_port
self.ssh_user = ssh_user
self.settings = revpi_settings
self.ssh_pass = ssh_pass
self.pyload_version = pyload_version
self.xml_funcs = xml_funcs
self.xml_mode = xml_mode
with self._lck_cli:
socket.setdefaulttimeout(timeout)
socket.setdefaulttimeout(revpi_settings.timeout)
self.ssh_tunnel_server = ssh_tunnel_server
self._cli = sp
self._cli_connect.put_nowait((
"127.0.0.1" if ssh_use_tunnel else address,
ssh_tunnel_port if ssh_use_tunnel else port
"127.0.0.1" if revpi_settings.ssh_use_tunnel else revpi_settings.address,
ssh_tunnel_port if revpi_settings.ssh_use_tunnel else revpi_settings.port
))
self.connection_established.emit()
@@ -371,9 +437,9 @@ class ConnectionManager(QtCore.QThread):
elif self._cli is not None:
# Tell all widget, that we want to disconnect, to save the settings
# Tell all widget, that we want to disconnect
self.connection_disconnecting.emit()
self._save_settings()
self.settings.save_settings()
with self._lck_cli:
if self._ps_started:
@@ -475,10 +541,14 @@ class ConnectionManager(QtCore.QThread):
if self.ssh_tunnel_server and not self.ssh_tunnel_server.connected:
self.ssh_tunnel_server.disconnect()
ssh_tunnel_server = SSHLocalTunnel(self.port, self.address, self.ssh_port)
ssh_tunnel_server = SSHLocalTunnel(
self.settings.port,
self.settings.address,
self.settings.ssh_port
)
try:
ssh_tunnel_port = self.ssh_tunnel_server.connect_by_credentials(
self.ssh_user,
self.settings.ssh_user,
self.ssh_pass
)
sp = ServerProxy("http://127.0.0.1:{0}".format(ssh_tunnel_port))
@@ -563,9 +633,9 @@ class ConnectionManager(QtCore.QThread):
Use connection_recovered signal to figure out new parameters.
"""
if not self.ssh_use_tunnel and self.address and self.port:
return ServerProxy("http://{0}:{1}".format(self.address, self.port))
if self.ssh_use_tunnel and self.ssh_tunnel_server and self.ssh_tunnel_server.connected:
if not self.settings.ssh_use_tunnel and self.settings.address and self.settings.port:
return ServerProxy("http://{0}:{1}".format(self.settings.address, self.settings.port))
if self.settings.ssh_use_tunnel and self.ssh_tunnel_server and self.ssh_tunnel_server.connected:
return ServerProxy("http://127.0.0.1:{0}".format(self.ssh_tunnel_server.local_tunnel_port))
return None
@@ -592,8 +662,31 @@ class ConnectionManager(QtCore.QThread):
cm = ConnectionManager()
"""Clobal connection manager instance."""
settings = QtCore.QSettings("revpipyplc", "revpipyload")
"""Global application settings."""
homedir = environ.get("HOME", "") or environ.get("APPDATA", "")
"""Home dir of user."""
def all_revpi_settings() -> [RevPiSettings]:
"""Get all revpi settings objects."""
# Get length of array and close it, the RevPiSettings-class need it
count_settings = settings.beginReadArray("connections")
settings.endArray()
return [RevPiSettings(i) for i in range(count_settings)]
def import_old_settings():
"""Try to import saved connections from old storage to new setting object."""
if settings.value("revpicommander/imported_settings", False, type=bool):
return
settings.setValue("revpicommander/imported_settings", True)
old_settings = QtCore.QSettings("revpipyplc", "revpipyload")
count_settings = old_settings.beginReadArray("connections")
old_settings.endArray()
for i in range(count_settings):
try:
revpi_setting = RevPiSettings(i, settings_storage=old_settings)
revpi_setting._settings = settings
revpi_setting.save_settings()
except Exception as e:
pi.logger.warning("Could not import saved connection {0}".format(i))
import_old_settings()

View File

@@ -68,90 +68,95 @@ Nicht gespeicherte Änderunen gehen verloren</translation>
<context>
<name>AvahiSearch</name>
<message>
<location filename="../avahisearch.py" line="216"/>
<location filename="../avahisearch.py" line="168"/>
<source>Auto discovered</source>
<translation>Automatisch erkannt</translation>
</message>
<message>
<location filename="../avahisearch.py" line="229"/>
<location filename="../avahisearch.py" line="191"/>
<source>Already in list...</source>
<translation>Bereits in Liste...</translation>
<translation type="obsolete">Bereits in Liste...</translation>
</message>
<message>
<location filename="../avahisearch.py" line="254"/>
<location filename="../avahisearch.py" line="201"/>
<source>Success</source>
<translation>Erfolgreich</translation>
<translation type="obsolete">Erfolgreich</translation>
</message>
<message>
<location filename="../avahisearch.py" line="254"/>
<location filename="../avahisearch.py" line="201"/>
<source>The connection with the name &apos;{0}&apos; was successfully saved to folder &apos;{1}&apos; in your connections.</source>
<translation>Die Verbindung mit dem Namen &apos;{0}&apos; wurde erfolgreich im Ordner &apos;{1}&apos; gespeichert.</translation>
<translation type="obsolete">Die Verbindung mit dem Namen &apos;{0}&apos; wurde erfolgreich im Ordner &apos;{1}&apos; gespeichert.</translation>
</message>
<message>
<location filename="../avahisearch.py" line="229"/>
<location filename="../avahisearch.py" line="191"/>
<source>The selected Revolution Pi is already saved in your connection list as &apos;{0}&apos;.</source>
<translation>Der ausgewählte RevPi ist schon in der Verbindungsliste als &apos;{0}&apos;.</translation>
<translation type="obsolete">Der ausgewählte RevPi ist schon in der Verbindungsliste als &apos;{0}&apos;.</translation>
</message>
<message>
<location filename="../avahisearch.py" line="283"/>
<source> over SSH</source>
<translation> über SSH</translation>
</message>
</context>
<context>
<name>ConnectionManager</name>
<message>
<location filename="../helper.py" line="454"/>
<location filename="../helper.py" line="512"/>
<source>SIMULATING</source>
<translation>SIMULATION</translation>
</message>
<message>
<location filename="../helper.py" line="457"/>
<location filename="../helper.py" line="515"/>
<source>NOT CONNECTED</source>
<translation>NICHT VERBUNDEN</translation>
</message>
<message>
<location filename="../helper.py" line="474"/>
<location filename="../helper.py" line="532"/>
<source>SERVER ERROR</source>
<translation>SERVER FEHLER</translation>
</message>
<message>
<location filename="../helper.py" line="495"/>
<location filename="../helper.py" line="557"/>
<source>RUNNING</source>
<translation>LÄUFT</translation>
</message>
<message>
<location filename="../helper.py" line="497"/>
<location filename="../helper.py" line="559"/>
<source>PLC FILE NOT FOUND</source>
<translation>SPS PROGRAMM NICHT GEFUNDEN</translation>
</message>
<message>
<location filename="../helper.py" line="499"/>
<location filename="../helper.py" line="561"/>
<source>NOT RUNNING (NO STATUS)</source>
<translation>LÄUFT NICHT (KEIN STATUS)</translation>
</message>
<message>
<location filename="../helper.py" line="501"/>
<location filename="../helper.py" line="563"/>
<source>PROGRAM KILLED</source>
<translation>PROGRAMM GETÖTET</translation>
</message>
<message>
<location filename="../helper.py" line="503"/>
<location filename="../helper.py" line="565"/>
<source>PROGRAM TERMED</source>
<translation>PROGRAMM BEENDET</translation>
</message>
<message>
<location filename="../helper.py" line="505"/>
<location filename="../helper.py" line="567"/>
<source>NOT RUNNING</source>
<translation>LÄUFT NICHT</translation>
</message>
<message>
<location filename="../helper.py" line="507"/>
<location filename="../helper.py" line="569"/>
<source>FINISHED WITH CODE {0}</source>
<translation>BEENDET MIT CODE {0}</translation>
</message>
<message>
<location filename="../helper.py" line="321"/>
<location filename="../helper.py" line="384"/>
<source>Error</source>
<translation>Fehler</translation>
</message>
<message>
<location filename="../helper.py" line="289"/>
<location filename="../helper.py" line="352"/>
<source>The combination of username and password was rejected from the SSH server.
Try again.</source>
@@ -160,7 +165,7 @@ Try again.</source>
Bitte erneut versuchen.</translation>
</message>
<message>
<location filename="../helper.py" line="298"/>
<location filename="../helper.py" line="361"/>
<source>Could not establish a SSH connection to server:
{0}</source>
@@ -169,7 +174,7 @@ Bitte erneut versuchen.</translation>
{0}</translation>
</message>
<message>
<location filename="../helper.py" line="321"/>
<location filename="../helper.py" line="384"/>
<source>Can not connect to RevPi XML-RPC Service!
This could have the following reasons: The RevPi is not online, the XML-RPC service is not running / bind to localhost or the ACL permission is not set for your IP!!!
@@ -185,34 +190,34 @@ Führe &apos;sudo revpipyload_secure_installation&apos; auf dem Revolution Pi au
<context>
<name>DebugControl</name>
<message>
<location filename="../debugcontrol.py" line="124"/>
<location filename="../debugcontrol.py" line="134"/>
<source>Driver reset for piControl detected.</source>
<translation>Treiberneustart in piCtory erkannt.</translation>
</message>
<message>
<location filename="../debugcontrol.py" line="164"/>
<location filename="../debugcontrol.py" line="174"/>
<source>Error while getting values from Revolution Pi.</source>
<translation>Fehler bei Werteempfang von RevPi.</translation>
</message>
<message>
<location filename="../debugcontrol.py" line="218"/>
<location filename="../debugcontrol.py" line="228"/>
<source>Auto update values...</source>
<translation>Werte automatisch aktualisiert...</translation>
</message>
<message>
<location filename="../debugcontrol.py" line="220"/>
<location filename="../debugcontrol.py" line="230"/>
<source>Values updated...</source>
<translation>Werte aktualisiert...</translation>
</message>
<message>
<location filename="../debugcontrol.py" line="257"/>
<location filename="../debugcontrol.py" line="267"/>
<source>Error set value of device &apos;{0}&apos; Output &apos;{1}&apos;: {2}
</source>
<translation>Fehler beim Setzen des Ausgangs &apos;{1}&apos; auf Modul &apos;{0}&apos;: {2}
</translation>
</message>
<message>
<location filename="../debugcontrol.py" line="266"/>
<location filename="../debugcontrol.py" line="276"/>
<source>Error</source>
<translation>Fehler</translation>
</message>
@@ -220,32 +225,32 @@ Führe &apos;sudo revpipyload_secure_installation&apos; auf dem Revolution Pi au
<context>
<name>DebugIos</name>
<message>
<location filename="../debugios.py" line="213"/>
<location filename="../debugios.py" line="207"/>
<source>signed</source>
<translation></translation>
</message>
<message>
<location filename="../debugios.py" line="218"/>
<location filename="../debugios.py" line="212"/>
<source>big_endian</source>
<translation></translation>
</message>
<message>
<location filename="../debugios.py" line="207"/>
<location filename="../debugios.py" line="201"/>
<source>as text</source>
<translation></translation>
</message>
<message>
<location filename="../debugios.py" line="209"/>
<location filename="../debugios.py" line="203"/>
<source>as number</source>
<translation></translation>
</message>
<message>
<location filename="../debugios.py" line="352"/>
<location filename="../debugios.py" line="346"/>
<source>Can not use format text</source>
<translation>Formatierung nicht möglich</translation>
</message>
<message>
<location filename="../debugios.py" line="352"/>
<location filename="../debugios.py" line="346"/>
<source>Can not convert bytes {0} to a text for IO &apos;{1}&apos;. Switch to number format instead!</source>
<translation>Kann bytes {0} für &apos;{1}&apos; nicht in Text konvertieren. Wechseln Sie auf Nummernformat!</translation>
</message>
@@ -278,86 +283,86 @@ Ungesicherte Änderungen gehen verloren.</translation>
<context>
<name>RevPiCommander</name>
<message>
<location filename="../revpicommander.py" line="228"/>
<location filename="../revpicommander.py" line="222"/>
<source>Simulator started...</source>
<translation>Simulator gestartet...</translation>
</message>
<message>
<location filename="../revpicommander.py" line="237"/>
<location filename="../revpicommander.py" line="231"/>
<source>Can not start...</source>
<translation>Kann nicht gestartet werden...</translation>
</message>
<message>
<location filename="../revpicommander.py" line="430"/>
<location filename="../revpicommander.py" line="424"/>
<source>Warning</source>
<translation>Warnung</translation>
</message>
<message>
<location filename="../revpicommander.py" line="253"/>
<location filename="../revpicommander.py" line="247"/>
<source>This version of Logviewer ist not supported in version {0} of RevPiPyLoad on your RevPi! You need at least version 0.4.1.</source>
<translation>Diese Version vom Logbetrachter wird in RevPiPyLoad Version {0} nicht unterstützt! Es wird mindestens Version 0.4.1 benötigt.</translation>
</message>
<message>
<location filename="../revpicommander.py" line="303"/>
<location filename="../revpicommander.py" line="297"/>
<source>XML-RPC access mode in the RevPiPyLoad configuration is too small to access this dialog!</source>
<translation>XML-RPC Zugriffsberechtigung in der RevPiPyLoad Konfiguraiton ist zu klein für diese Einstellungen!</translation>
</message>
<message>
<location filename="../revpicommander.py" line="457"/>
<location filename="../revpicommander.py" line="451"/>
<source>Error</source>
<translation>Fehler</translation>
</message>
<message>
<location filename="../revpicommander.py" line="283"/>
<location filename="../revpicommander.py" line="277"/>
<source>The Version of RevPiPyLoad on your Revolution Pi ({0}) is to old. This Version of RevPiCommander require at least version 0.6.0 of RevPiPyLoad. Please update your Revolution Pi!</source>
<translation>Die Version von RevPiPyLoad ({0}) auf dem Revolution Pi ist zu alt. Diese Version vom RevPiCommander braucht mindestens Version 0.6.0. Bitte aktualisiere deinen Revolution Pi!</translation>
</message>
<message>
<location filename="../revpicommander.py" line="336"/>
<location filename="../revpicommander.py" line="330"/>
<source>Question</source>
<translation>Frage</translation>
</message>
<message>
<location filename="../revpicommander.py" line="336"/>
<location filename="../revpicommander.py" line="330"/>
<source>Are you sure to reset piControl?
The pictory configuration will be reloaded. During that time the process image will be interrupted and could rise errors on running control programs!</source>
<translation>Soll piControl wirklich zurückgesetzt werden?
Die piCtory Konfiguration wird neu geladen. Das Prozessabbild wird in dieser Zeit nicht verfügbar sein und es könnten Fehler in Steuerungsprogrammen ausgelöst werden!</translation>
</message>
<message>
<location filename="../revpicommander.py" line="349"/>
<location filename="../revpicommander.py" line="343"/>
<source>Success</source>
<translation>Erfolgreich</translation>
</message>
<message>
<location filename="../revpicommander.py" line="349"/>
<location filename="../revpicommander.py" line="343"/>
<source>piControl reset executed successfully</source>
<translation>piControl wurde erfolgreich zurückgesetzt</translation>
</message>
<message>
<location filename="../revpicommander.py" line="356"/>
<location filename="../revpicommander.py" line="350"/>
<source>piControl reset could not be executed successfully</source>
<translation>piControl konnte nicht zurückgesetzt werden</translation>
</message>
<message>
<location filename="../revpicommander.py" line="404"/>
<location filename="../revpicommander.py" line="398"/>
<source>Reset to piCtory defaults...</source>
<translation>Standardwerte von piCtory laden...</translation>
</message>
<message>
<location filename="../revpicommander.py" line="430"/>
<location filename="../revpicommander.py" line="424"/>
<source>The watch mode ist not supported in version {0} of RevPiPyLoad on your RevPi! You need at least version 0.5.3! Maybe the python3-revpimodio2 module is not installed on your RevPi at least version 2.0.0.</source>
<translation>Der SPS Betrachter ist in Version {0} von RevPiPyLoad auf dem Rev Pi nicht unterstützt! Es muss mindestens Version 0.5.3 installiert sein! Vielleicht fehlt auch das python3-revpimodio2 Modul, welches mindestens Version 2.0.0 haben muss.</translation>
</message>
<message>
<location filename="../revpicommander.py" line="442"/>
<location filename="../revpicommander.py" line="436"/>
<source>Can not load this function, because your ACL level is to low!
You need at least level 1 to read or level 3 to write.</source>
<translation>Für diese Funktion ist das Berechtigungslevel zu gering!
Es muss mindestens Level 1 zum Lesen oder Level 3 zu Schreiben sein.</translation>
</message>
<message>
<location filename="../revpicommander.py" line="457"/>
<location filename="../revpicommander.py" line="451"/>
<source>Can not load piCtory configuration.
Did you create a hardware configuration? Please check this in piCtory!</source>
<translation>Kann piCtory Konfiguration nicht laden.
@@ -377,7 +382,7 @@ Das kann eine der folgenden Ursachen haben: Der Rev Pi ist nicht online, der XML
Führe &apos;sudo revpipyload_secure_installation&apos; auf dem Revolution Pi aus um diese Funktion zu konfigurieren!</translation>
</message>
<message>
<location filename="../revpicommander.py" line="228"/>
<location filename="../revpicommander.py" line="222"/>
<source>The simulator is running!
You can work with this simulator if your call RevPiModIO with this additional parameters:
@@ -394,24 +399,24 @@ configrsc={1}
Dies kann aus der Textbox oben kopiert werden.</translation>
</message>
<message>
<location filename="../revpicommander.py" line="237"/>
<location filename="../revpicommander.py" line="231"/>
<source>Can not start the simulator! Maybe the piCtory file is corrupt or you have no write permissions for &apos;{0}&apos;.</source>
<translation>Kann Simulator nicht starten! Vielleicht ist die piCtory Datei defekt oder es gibt keine Schreibberechtigung für &apos;{0}`.</translation>
<translation>Kann Simulator nicht starten! Vielleicht ist die piCtory Datei defekt oder es gibt keine Schreibberechtigung für &apos;{0}&apos;.</translation>
</message>
<message>
<location filename="../revpicommander.py" line="404"/>
<location filename="../revpicommander.py" line="398"/>
<source>Do you want to reset your process image to {0} values?
You have to stop other RevPiModIO programs before doing that, because they could reset the outputs.</source>
<translation>Soll das virtuelle Prozessabbild auf {0} zurückgesetzt werden?
Es sollten alle RevPiModIO Programme vorher beendet werden, da diese ihre IO Werte sofort wieder schreiben würden.</translation>
</message>
<message>
<location filename="../revpicommander.py" line="404"/>
<location filename="../revpicommander.py" line="398"/>
<source>zero</source>
<translation>null</translation>
</message>
<message>
<location filename="../revpicommander.py" line="404"/>
<location filename="../revpicommander.py" line="398"/>
<source>piCtory default</source>
<translation>piCtory Standardwerte</translation>
</message>
@@ -419,92 +424,92 @@ Es sollten alle RevPiModIO Programme vorher beendet werden, da diese ihre IO Wer
<context>
<name>RevPiFiles</name>
<message>
<location filename="../revpifiles.py" line="86"/>
<location filename="../revpifiles.py" line="85"/>
<source>Please select...</source>
<translation>Bitte auswählen...</translation>
</message>
<message>
<location filename="../revpifiles.py" line="458"/>
<location filename="../revpifiles.py" line="457"/>
<source>Error</source>
<translation>Fehler</translation>
</message>
<message>
<location filename="../revpifiles.py" line="120"/>
<location filename="../revpifiles.py" line="119"/>
<source>Can not stop plc program on Revolution Pi.</source>
<translation>Kann SPS Programm auf Rev Pi nicht stoppen.</translation>
</message>
<message>
<location filename="../revpifiles.py" line="143"/>
<location filename="../revpifiles.py" line="142"/>
<source>The Revolution Pi could not process some parts of the transmission.</source>
<translation>Der Revolution Pi hat Teile der Übertragung nicht durchgeführt.</translation>
</message>
<message>
<location filename="../revpifiles.py" line="151"/>
<location filename="../revpifiles.py" line="150"/>
<source>Errors occurred during transmission</source>
<translation>Fehler bei Übertragung aufgetreten</translation>
</message>
<message>
<location filename="../revpifiles.py" line="157"/>
<location filename="../revpifiles.py" line="156"/>
<source>Warning</source>
<translation>Warnung</translation>
</message>
<message>
<location filename="../revpifiles.py" line="157"/>
<location filename="../revpifiles.py" line="156"/>
<source>Could not start the plc program on Revolution Pi.</source>
<translation>Kann das SPS Programm auf dem Revolution Pi nicht starten.</translation>
</message>
<message>
<location filename="../revpifiles.py" line="178"/>
<location filename="../revpifiles.py" line="177"/>
<source>The RevPiPyLoad version on the Revolution Pi is to old.</source>
<translation>Die RevPiPyLoad Version auf dem Revolution Pi ist zu alt.</translation>
</message>
<message>
<location filename="../revpifiles.py" line="253"/>
<location filename="../revpifiles.py" line="252"/>
<source>Can not open last directory &apos;{0}&apos;.</source>
<translation>Kann letztes Verzeichnis &apos;{0}&apos; nicht öffnen.</translation>
</message>
<message>
<location filename="../revpifiles.py" line="310"/>
<location filename="../revpifiles.py" line="309"/>
<source>Stop scanning for files, because we found more than {0} files.</source>
<translation>Dateisuche wurde angehalten, da mehr als {0} Dateien gefunden wurden.</translation>
</message>
<message>
<location filename="../revpifiles.py" line="354"/>
<location filename="../revpifiles.py" line="353"/>
<source>Could not load path of working dir</source>
<translation>Kann Arbeitsverzeichnis nicht laden</translation>
</message>
<message>
<location filename="../revpifiles.py" line="415"/>
<location filename="../revpifiles.py" line="414"/>
<source>Can not load file list from Revolution Pi.</source>
<translation>Kann Dateiliste vom Revolution Pi nicht laden.</translation>
</message>
<message>
<location filename="../revpifiles.py" line="447"/>
<location filename="../revpifiles.py" line="446"/>
<source>Select folder...</source>
<translation>Ordner auswählen...</translation>
</message>
<message>
<location filename="../revpifiles.py" line="458"/>
<location filename="../revpifiles.py" line="457"/>
<source>Can not access the folder &apos;{0}&apos; to read files.</source>
<translation>Keine Berechtigung für Zugriff auf Ordner &apos;{0}&apos;.</translation>
</message>
<message>
<location filename="../revpifiles.py" line="559"/>
<location filename="../revpifiles.py" line="558"/>
<source>Error...</source>
<translation>Fehler...</translation>
</message>
<message>
<location filename="../revpifiles.py" line="508"/>
<location filename="../revpifiles.py" line="507"/>
<source>Error while download file &apos;{0}&apos;.</source>
<translation>Fehler beim Herunterladen der Datei &apos;{0}&apos;.</translation>
</message>
<message>
<location filename="../revpifiles.py" line="516"/>
<location filename="../revpifiles.py" line="515"/>
<source>Override files...</source>
<translation>Dateien überschreiben...</translation>
</message>
<message>
<location filename="../revpifiles.py" line="516"/>
<location filename="../revpifiles.py" line="515"/>
<source>One or more files does exist on your computer! Do you want to override the existingfiles?
Select &apos;Yes&apos; to override, &apos;No&apos; to download only missing files.</source>
@@ -513,32 +518,32 @@ Select &apos;Yes&apos; to override, &apos;No&apos; to download only missing file
Wählen Sie &apos;Ja&apos; zum Überschreiben, &apos;Nein&apos; um nur fehlende Dateien zu laden.</translation>
</message>
<message>
<location filename="../revpifiles.py" line="548"/>
<location filename="../revpifiles.py" line="547"/>
<source>Delete files from Revolution Pi...</source>
<translation>Dateien auf Rev Pi löschen...</translation>
</message>
<message>
<location filename="../revpifiles.py" line="548"/>
<location filename="../revpifiles.py" line="547"/>
<source>Do you want to delete {0} files from revolution pi?</source>
<translation>Sollen {0} Dateien vom Revolution Pi gelöscht werden?</translation>
</message>
<message>
<location filename="../revpifiles.py" line="559"/>
<location filename="../revpifiles.py" line="558"/>
<source>Error while delete file &apos;{0}&apos;.</source>
<translation>Fehler beim Löschen der Datei &apos;{0}&apos;.</translation>
</message>
<message>
<location filename="../revpifiles.py" line="134"/>
<location filename="../revpifiles.py" line="133"/>
<source>Information</source>
<translation>Information</translation>
</message>
<message>
<location filename="../revpifiles.py" line="134"/>
<location filename="../revpifiles.py" line="133"/>
<source>A PLC program has been uploaded. Please check the PLC program settings to see if the correct program is specified as the start program.</source>
<translation>Ein SPS Programm wurde hochgeladen. Bitte prüfe die SPS Programmeinstellungen ob das richtige Startprogramm gewählt ist.</translation>
</message>
<message>
<location filename="../revpifiles.py" line="181"/>
<location filename="../revpifiles.py" line="180"/>
<source>Choose a local directory first.</source>
<translation>Lokales Verzeichnis wählen.</translation>
</message>
@@ -658,17 +663,17 @@ Ungesicherte Änderungen gehen verloren.</translation>
<context>
<name>RevPiPlcList</name>
<message>
<location filename="../revpiplclist.py" line="27"/>
<location filename="../revpiplclist.py" line="28"/>
<source>New connection</source>
<translation>Neue Verbindung</translation>
<translation type="obsolete">Neue Verbindung</translation>
</message>
<message>
<location filename="../revpiplclist.py" line="158"/>
<location filename="../revpiplclist.py" line="102"/>
<source>Question</source>
<translation>Frage</translation>
</message>
<message>
<location filename="../revpiplclist.py" line="158"/>
<location filename="../revpiplclist.py" line="102"/>
<source>Do you really want to quit?
Unsaved changes will be lost.</source>
<translation>Soll das Fenster wirklich geschlossen werden?
@@ -678,22 +683,22 @@ Ungesicherte Änderungen gehen verloren.</translation>
<context>
<name>RevPiProgram</name>
<message>
<location filename="../revpiprogram.py" line="688"/>
<location filename="../revpiprogram.py" line="679"/>
<source>Error</source>
<translation>Fehler</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="111"/>
<location filename="../revpiprogram.py" line="110"/>
<source>You have to select a start program, before uploading the settings.</source>
<translation>Es muss erst ein Startprogramm gewählt werden.</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="154"/>
<location filename="../revpiprogram.py" line="153"/>
<source>Question</source>
<translation>Frage</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="119"/>
<location filename="../revpiprogram.py" line="118"/>
<source>The settings will be set on the Revolution Pi now.
If you made changes on the &apos;PCL Program&apos; section, your plc program will restart now!</source>
@@ -702,251 +707,272 @@ If you made changes on the &apos;PCL Program&apos; section, your plc program wil
Sollte es Änderungen in dem SPS Programmabschnitt geben, wird das SPS Programm neu gestartet!</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="144"/>
<location filename="../revpiprogram.py" line="143"/>
<source>The settings could not be saved on the Revolution Pi!
Try to save the values one mor time and check the log files of RevPiPyLoad if the error rises again.</source>
<translation>Die Einstellungen konnten nicht auf dem Revolution Pi gespeichert werden!
Versuche es erneut und prüfe die Logdateien von RevPiPyLoad, wenn der Fehler erneut auftritt.</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="154"/>
<location filename="../revpiprogram.py" line="153"/>
<source>Do you really want to quit?
Unsaved changes will be lost.</source>
<translation>Soll das Fenster wirklich geschlossen werden?
Ungesicherte Änderungen gehen verloren.</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="194"/>
<location filename="../revpiprogram.py" line="193"/>
<source>Reset driver...</source>
<translation>Treiber zurücksetzen...</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="194"/>
<location filename="../revpiprogram.py" line="193"/>
<source>Reset piControl driver after successful uploading new piCtory configuration?
The process image will be interrupted for a short time!</source>
<translation>Soll piControl nach dem erfolgreichen Hochladen der neuen piCtory Konfiguration zurückgesetzt werden?
Das Prozessabbild wird kurzzeitig nicht verfügbar sein!</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="209"/>
<location filename="../revpiprogram.py" line="208"/>
<source>Got an network error while send data to Revolution Pi.
Please try again.</source>
<translation>Beim Senden der Daten an den Revolution Pi trat ein Netzwerkfehler auf.
Versuche es erneut.</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="698"/>
<location filename="../revpiprogram.py" line="689"/>
<source>Success</source>
<translation>Erfolgreich</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="218"/>
<location filename="../revpiprogram.py" line="217"/>
<source>The transfer of the piCtory configuration and the reset of piControl have been successfully executed.</source>
<translation>Die piCtory Übertragung und der Reset von piControl wurden erfolgreich durchgeführt.</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="226"/>
<location filename="../revpiprogram.py" line="225"/>
<source>The piCtory configuration was successfully transferred.</source>
<translation>Die piCtory Konfiguration wurde erfolgreich übertragen.</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="233"/>
<location filename="../revpiprogram.py" line="232"/>
<source>Can not process the transferred file.</source>
<translation>Kann die Übertragene Datei nicht verarbeiten.</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="239"/>
<location filename="../revpiprogram.py" line="238"/>
<source>Can not find main elements in piCtory file.</source>
<translation>Konnte piCtory Struktur nicht erkennen.</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="245"/>
<location filename="../revpiprogram.py" line="244"/>
<source>Contained devices could not be found on Revolution Pi. The configuration may be from a newer piCtory version!</source>
<translation>Enthaltene Module können auf dem Revolution Pi nicht gefunden werden. Die Konfiguraiton könnte von einer neueren piCtory Version stammen!</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="252"/>
<location filename="../revpiprogram.py" line="251"/>
<source>Could not load RAP catalog on Revolution Pi.</source>
<translation>Kann RAP Katalog auf dem Revolution Pi nicht laden.</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="258"/>
<location filename="../revpiprogram.py" line="257"/>
<source>The piCtory configuration could not be written on the Revolution Pi.</source>
<translation>Die piCtory Konfiguration konnte nicht auf dem Revolution Pi geschrieben werden.</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="265"/>
<location filename="../revpiprogram.py" line="264"/>
<source>Warning</source>
<translation>Warnung</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="265"/>
<location filename="../revpiprogram.py" line="264"/>
<source>The piCtroy configuration has been saved successfully.
An error occurred on piControl reset!</source>
<translation>Die piCtory Konfiguration wurde erfolgreich hochgeladen.
Es trat jedoch ein Fehler beim Zurücksetzen von piControl auf!</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="331"/>
<location filename="../revpiprogram.py" line="328"/>
<source>Save ZIP archive...</source>
<translation>ZIP Archiv speichern...</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="427"/>
<location filename="../revpiprogram.py" line="418"/>
<source>ZIP archive (*.zip);;All files (*.*)</source>
<translation>ZIP Archive (*.tgz);;Alle Dateien (*.*)</translation>
<translation>ZIP Archive (*.zip);;Alle Dateien (*.*)</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="352"/>
<location filename="../revpiprogram.py" line="346"/>
<source>Save TGZ archive...</source>
<translation>TGZ Archiv speichern...</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="352"/>
<location filename="../revpiprogram.py" line="346"/>
<source>TGZ archive (*.tgz);;All files (*.*)</source>
<translation>TAR Archive (*.tgz);;Alle Dateien (*.*)</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="382"/>
<location filename="../revpiprogram.py" line="373"/>
<source>Could not load PLC program from Revolution Pi.</source>
<translation>Kann SPS Programm nicht vom Revolution Pi laden.</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="395"/>
<location filename="../revpiprogram.py" line="386"/>
<source>Coud not save the archive or extract the files!
Please retry.</source>
<translation>Konnte das Archiv nicht speichern oder extrahieren!
Versuche es erneut.</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="401"/>
<location filename="../revpiprogram.py" line="392"/>
<source>Transfer successfully completed.</source>
<translation>Übertragung erfolgreich abgeschlossen.</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="427"/>
<location filename="../revpiprogram.py" line="418"/>
<source>Upload content of ZIP archive...</source>
<translation>ZIP Archiv hochladen...</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="452"/>
<location filename="../revpiprogram.py" line="443"/>
<source>The selected file ist not a ZIP archive.</source>
<translation>Die ausgewählte Datei ist kein ZIP Archiv.</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="461"/>
<location filename="../revpiprogram.py" line="452"/>
<source>Upload content of TAR archive...</source>
<translation>TAR Archiv hochladen...</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="461"/>
<location filename="../revpiprogram.py" line="452"/>
<source>TAR archive (*.tgz);;All files (*.*)</source>
<translation>TAR Archive (*.tgz);;Alle Dateien (*.*)</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="486"/>
<location filename="../revpiprogram.py" line="477"/>
<source>The selected file ist not a TAR archive.</source>
<translation>Die ausgewählte Datei ist kein TAR Archiv.</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="495"/>
<location filename="../revpiprogram.py" line="486"/>
<source>No files to upload...</source>
<translation>Keine Dateien zum Hochladen...</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="495"/>
<location filename="../revpiprogram.py" line="486"/>
<source>Found no files to upload in given location or archive.</source>
<translation>Konnte keine Dateien in der Quelle zum Hochladen finden.</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="506"/>
<location filename="../revpiprogram.py" line="497"/>
<source>There was an error deleting the files on the Revolution Pi.
Upload aborted! Please try again.</source>
<translation>Beim Löschen der Dateien auf dem Revolution Pi ist ein Fehler aufgetreten.
Hochladen abgebrochen! Versuche es erneut.</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="552"/>
<location filename="../revpiprogram.py" line="543"/>
<source>The PLC program was transferred successfully.</source>
<translation>Das SPS Programm wurde erfolgreich übertragen.</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="560"/>
<location filename="../revpiprogram.py" line="551"/>
<source>Information</source>
<translation>Information</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="560"/>
<location filename="../revpiprogram.py" line="551"/>
<source>Could not find the selected PLC start program in uploaded files.
This is not an error, if the file was already on the Revolution Pi. Check PLC start program field</source>
<translation>Konnte eingestelltes SPS Starprogramm in hochgeladenen Dateien nicht finden.
Dies ist kein Fehler, wenn das SPS Startprogramm bereits auf dem Rev Pi ist. Prüfe SPS Programm Einstellungen</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="573"/>
<location filename="../revpiprogram.py" line="564"/>
<source>There is no piCtory configuration in this archive.</source>
<translation>Kann keine piCtory Konfiguration im Archiv finden.</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="580"/>
<location filename="../revpiprogram.py" line="571"/>
<source>The Revolution Pi could not process some parts of the transmission.</source>
<translation>Der Revolution Pi konnte Teile der Übertragung nicht verarbeiten.</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="587"/>
<location filename="../revpiprogram.py" line="578"/>
<source>Errors occurred during transmission.</source>
<translation>Fehler bei Übertragung aufgetreten.</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="606"/>
<location filename="../revpiprogram.py" line="597"/>
<source>Save piCtory file...</source>
<translation>piCtory Datei speichern...</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="646"/>
<location filename="../revpiprogram.py" line="637"/>
<source>piCtory file (*.rsc);;All files (*.*)</source>
<translation>piCtory Datei (*.rsc);;Alle Dateien (*.*)</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="625"/>
<location filename="../revpiprogram.py" line="616"/>
<source>Could not load piCtory file from Revolution Pi.</source>
<translation>Kann piCtory Konfiguration nicht vom Revolution Pi laden.</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="635"/>
<location filename="../revpiprogram.py" line="626"/>
<source>piCtory configuration successfully loaded and saved to:
{0}.</source>
<translation>piCtory Konfiguration erfolgreich geladen und gespeichert als:
{0}.</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="646"/>
<location filename="../revpiprogram.py" line="637"/>
<source>Upload piCtory file...</source>
<translation>piCtory datei hochladen...</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="667"/>
<location filename="../revpiprogram.py" line="658"/>
<source>Save piControl file...</source>
<translation>piCtory Datei speichern...</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="667"/>
<location filename="../revpiprogram.py" line="658"/>
<source>Process image file (*.img);;All files (*.*)</source>
<translation>Processabbild (*.img);;Alle Dateien (*.*)</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="688"/>
<location filename="../revpiprogram.py" line="679"/>
<source>Could not load process image from Revolution Pi.</source>
<translation>Kann Prozessabbild von Revolution Pi nicht laden.</translation>
</message>
<message>
<location filename="../revpiprogram.py" line="698"/>
<location filename="../revpiprogram.py" line="689"/>
<source>Process image successfully loaded and saved to:
{0}.</source>
<translation>Prozessabbild erfolgreich geladen und gespeichert als:
{0}.</translation>
</message>
</context>
<context>
<name>SSHAuth</name>
<message>
<location filename="../sshauth.py" line="49"/>
<source>Could not save password</source>
<translation>Konnte Kennwort nicht speichern</translation>
</message>
<message>
<location filename="../sshauth.py" line="49"/>
<source>Could not save password to operating systems password save.
Maybe your operating system does not support saving passwords. This could be due to missing libraries or programs.
This is not an error of RevPi Commander.</source>
<translation>Konnte das Kennwort nicht im Kennwortspeicher des Betriebssystems speichern.
Vielleicht untersützt das Betriebssystem keine Kennwortspeicherung. Dies könnte an fehlenden Bibliotheken oder Programmen liegen.
Dies ist kein Fehler von RevPi Commander.</translation>
</message>
</context>
<context>
<name>Simulator</name>
<message>
@@ -1556,6 +1582,16 @@ applicable law.
<source>You have to configure your Revolution Pi to accept this connections</source>
<translation>Sie müssen den Revolution Pi für diese Art der Verbindung konfigurieren</translation>
</message>
<message>
<location filename="../../../ui_dev/avahisearch.ui" line="156"/>
<source>Connect</source>
<translation>Verbinden</translation>
</message>
<message>
<location filename="../../../ui_dev/avahisearch.ui" line="159"/>
<source>Connect to Revoluton Pi</source>
<translation>Mit Revolution Pi verbinden</translation>
</message>
</context>
<context>
<name>diag_simulator</name>
@@ -1657,6 +1693,16 @@ applicable law.
<source>SSH password:</source>
<translation>SSH Passwort:</translation>
</message>
<message>
<location filename="../../../ui_dev/sshauth.ui" line="53"/>
<source>Username and password will be saved in secured operating systems&apos;s password storage.</source>
<translation>Benutzername und Kennwort werden im Passwortspeicher vom Betriebssystem gesichert.</translation>
</message>
<message>
<location filename="../../../ui_dev/sshauth.ui" line="56"/>
<source>Save username and password</source>
<translation>Benutzername und Kennwort merken</translation>
</message>
</context>
<context>
<name>wid_debugcontrol</name>
@@ -1678,43 +1724,61 @@ applicable law.
<message>
<location filename="../../../ui_dev/debugcontrol.ui" line="56"/>
<source>Read all IO values and discard local changes (F4)</source>
<translation>Alle EA Werte lesen und lokale Änderungen überschreiben (F4)</translation>
<translation type="obsolete">Alle EA Werte lesen und lokale Änderungen überschreiben (F4)</translation>
</message>
<message>
<location filename="../../../ui_dev/debugcontrol.ui" line="59"/>
<location filename="../../../ui_dev/debugcontrol.ui" line="61"/>
<source>Read &amp;all IO values</source>
<translation>&amp;Alle EA Werte lesen</translation>
</message>
<message>
<location filename="../../../ui_dev/debugcontrol.ui" line="69"/>
<source>Refresh all IO values which are locally not changed (F5)</source>
<translation>Alle EA Werte aktualisieren, die lokal nicht geändert sind (F5)</translation>
<translation type="obsolete">Alle EA Werte aktualisieren, die lokal nicht geändert sind (F5)</translation>
</message>
<message>
<location filename="../../../ui_dev/debugcontrol.ui" line="72"/>
<location filename="../../../ui_dev/debugcontrol.ui" line="82"/>
<source>&amp;Refresh unchanged IOs</source>
<translation>Unve&amp;ränderte EAs lesen</translation>
</message>
<message>
<location filename="../../../ui_dev/debugcontrol.ui" line="82"/>
<location filename="../../../ui_dev/debugcontrol.ui" line="98"/>
<source>Write locally changed output values to process image (F6)</source>
<translation>Schreibe lokal veränderte Ausgangswerte in das Prozessabbild (F6)</translation>
</message>
<message>
<location filename="../../../ui_dev/debugcontrol.ui" line="85"/>
<location filename="../../../ui_dev/debugcontrol.ui" line="101"/>
<source>&amp;Write changed outputs</source>
<translation>Ausgänge &amp;schreiben</translation>
</message>
<message>
<location filename="../../../ui_dev/debugcontrol.ui" line="95"/>
<location filename="../../../ui_dev/debugcontrol.ui" line="108"/>
<source>&amp;Auto refresh values</source>
<translation>&amp;Automatisch aktualisieren</translation>
</message>
<message>
<location filename="../../../ui_dev/debugcontrol.ui" line="102"/>
<location filename="../../../ui_dev/debugcontrol.ui" line="115"/>
<source>and write outputs</source>
<translation>und Ausgänge schreiben</translation>
</message>
<message>
<location filename="../../../ui_dev/debugcontrol.ui" line="56"/>
<source>Read all IO values and discard local changes (F4)
Hold this button pressed and it will refresh the IOs every 200 ms.</source>
<translation>Alle EA Werte lesen und lokale Änderungen überschreiben (F4)
Wird der Button gehalten, aktualisieren sich die EAs alle 200 ms.</translation>
</message>
<message>
<location filename="../../../ui_dev/debugcontrol.ui" line="77"/>
<source>Refresh all IO values which are locally not changed (F5)
Hold this button pressed and it will refresh the IOs every 200 ms.</source>
<translation>Alle EA Werte aktualisieren, die lokal nicht geändert sind (F5)
Wird der Button gehalten, aktualisieren sich die EAs alle 200 ms.</translation>
</message>
</context>
<context>
<name>win_debugios</name>

Binary file not shown.

View File

@@ -5,10 +5,10 @@
__author__ = "Sven Sager"
__copyright__ = "Copyright (C) 2018 Sven Sager"
__license__ = "GPLv3"
__version__ = "0.9.10rc1"
__version__ = "0.9.10rc2"
import webbrowser
from os.path import basename, dirname, join
from os.path import dirname, join
from PyQt5 import QtCore, QtGui, QtWidgets
@@ -17,6 +17,7 @@ from . import proginit as pi
from . import revpilogfile
from .avahisearch import AvahiSearch
from .debugcontrol import DebugControl
from .helper import RevPiSettings
from .revpifiles import RevPiFiles
from .revpiinfo import RevPiInfo
from .revpioption import RevPiOption
@@ -53,7 +54,7 @@ class RevPiCommander(QtWidgets.QMainWindow, Ui_win_revpicommander):
self.win_files = RevPiFiles(self)
self.win_log = revpilogfile.RevPiLogfile(self)
self.btn_plc_logs.pressed.connect(self.on_act_logs_triggered)
self.btn_plc_logs.clicked.connect(self.on_act_logs_triggered)
helper.cm.connection_disconnected.connect(self.on_cm_connection_disconnected)
helper.cm.connection_disconnecting.connect(self.on_cm_connection_disconnecting)
@@ -61,14 +62,14 @@ class RevPiCommander(QtWidgets.QMainWindow, Ui_win_revpicommander):
helper.cm.connection_error_observed.connect(self.on_cm_connection_error_observed)
helper.cm.status_changed.connect(self.on_cm_status_changed)
self.restoreGeometry(helper.settings.value("geo", b''))
self.restoreGeometry(helper.settings.value("revpicommander/geo", b''))
self.setWindowFlag(QtCore.Qt.WindowMaximizeButtonHint, False)
def closeEvent(self, a0: QtGui.QCloseEvent) -> None:
pi.logger.debug("RevPiCommander.closeEvent")
helper.cm.pyload_disconnect()
helper.settings.setValue("geo", self.saveGeometry())
helper.settings.setValue("revpicommander/geo", self.saveGeometry())
def _set_gui_control_states(self):
"""Setup states of actions and buttons."""
@@ -96,9 +97,6 @@ class RevPiCommander(QtWidgets.QMainWindow, Ui_win_revpicommander):
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# region # REGION: Connection management
def _pyload_connect(self, settings_index: int) -> None:
helper.cm.pyload_connect(settings_index, self)
@QtCore.pyqtSlot(str)
def on_cm_connection_error_observed(self, message: str):
"""
@@ -148,8 +146,8 @@ class RevPiCommander(QtWidgets.QMainWindow, Ui_win_revpicommander):
helper.cm.simulating_procimg,
))
else:
self.txt_host.setText(helper.cm.name)
self.txt_connection.setText(helper.cm.address)
self.txt_host.setText(helper.cm.settings.name)
self.txt_connection.setText(helper.cm.settings.address)
self.win_files = RevPiFiles(self)
@QtCore.pyqtSlot(str, str)
@@ -169,34 +167,27 @@ class RevPiCommander(QtWidgets.QMainWindow, Ui_win_revpicommander):
self.men_connections.clear()
self.dict_men_connections_subfolder.clear()
for i in range(helper.settings.beginReadArray("connections")):
helper.settings.setArrayIndex(i)
if helper.settings.value("folder"):
if helper.settings.value("folder") not in self.dict_men_connections_subfolder:
for settings in helper.all_revpi_settings(): # type: RevPiSettings
if settings.folder:
if settings.folder not in self.dict_men_connections_subfolder:
men_sub = QtWidgets.QMenu(self.men_connections)
men_sub.setTitle(helper.settings.value("folder"))
self.dict_men_connections_subfolder[helper.settings.value("folder")] = men_sub
men_sub.setTitle(settings.folder)
self.dict_men_connections_subfolder[settings.folder] = men_sub
self.men_connections.addMenu(men_sub)
parent_menu = self.dict_men_connections_subfolder[helper.settings.value("folder")]
parent_menu = self.dict_men_connections_subfolder[settings.folder]
else:
parent_menu = self.men_connections
display_name = helper.settings.value("name")
if helper.settings.value("ssh_use_tunnel", False, bool):
display_name = settings.name
if settings.ssh_use_tunnel:
display_name += " (SSH)"
act = QtWidgets.QAction(parent_menu)
act.setText(display_name)
act.setData(i)
act.setToolTip("{0}:{1}".format(
helper.settings.value("address"),
helper.settings.value("port"),
))
act.setData(settings)
act.setToolTip("{0}:{1}".format(settings.address, settings.port))
parent_menu.addAction(act)
helper.settings.endArray()
@QtCore.pyqtSlot()
def on_act_connections_triggered(self):
"""Edit saved connections to Revolution Pi devices."""
@@ -207,8 +198,11 @@ class RevPiCommander(QtWidgets.QMainWindow, Ui_win_revpicommander):
def on_act_search_triggered(self):
"""Search for Revolution Pi with zero conf."""
if self.diag_search.exec() == QtWidgets.QDialog.Accepted:
if self.diag_search.connect_index >= 0:
self._pyload_connect(self.diag_search.connect_index)
if self.diag_search.connect_settings:
if self.diag_search.just_save:
self.diag_connections.exec_with_presets(self.diag_search.connect_settings)
else:
helper.cm.pyload_connect(self.diag_search.connect_settings, self)
self._load_men_connections()
@@ -367,7 +361,7 @@ class RevPiCommander(QtWidgets.QMainWindow, Ui_win_revpicommander):
@QtCore.pyqtSlot(QtWidgets.QAction)
def on_men_connections_triggered(self, action: QtWidgets.QAction):
"""A connection is selected in the men_connections menu."""
self._pyload_connect(action.data())
helper.cm.pyload_connect(action.data(), self)
@QtCore.pyqtSlot()
def on_act_webpage_triggered(self):
@@ -506,4 +500,5 @@ def main() -> int:
if __name__ == "__main__":
import sys
sys.exit(main())

View File

@@ -43,14 +43,13 @@ class UploadFiles(BackgroundWorker):
progress_counter += 1
# Remove base dir of file to set relative for PyLoad
send_name = file_name.replace(helper.cm.develop_watch_path, "")[1:]
send_name = file_name.replace(helper.cm.settings.watch_path, "")[1:]
self.status_message.emit(send_name)
# Check whether this is the auto start program
if send_name == opt_program:
self.plc_program_included = True
# Transfer file
try:
with open(file_name, "rb") as fh:
@@ -83,7 +82,7 @@ class RevPiFiles(QtWidgets.QMainWindow, Ui_win_files):
self.dc_settings = {}
self.tree_files_counter = 0
self.tree_files_counter_max = 10000
self.lbl_path_local.setText(helper.cm.develop_watch_path or self.tr("Please select..."))
self.lbl_path_local.setText(helper.cm.settings.watch_path or self.tr("Please select..."))
self.lbl_path_local.setToolTip(self.lbl_path_local.text())
self.btn_all.setEnabled(False)
@@ -91,7 +90,7 @@ class RevPiFiles(QtWidgets.QMainWindow, Ui_win_files):
self.btn_to_right.setEnabled(False)
self.btn_delete_revpi.setEnabled(False)
if helper.cm.develop_watch_path:
if helper.cm.settings.watch_path:
self._load_files_local(True)
if helper.cm.connected:
self._load_files_revpi(True)
@@ -176,7 +175,7 @@ class RevPiFiles(QtWidgets.QMainWindow, Ui_win_files):
if "plcdownload_file" not in helper.cm.xml_funcs:
self.btn_to_left.setEnabled(False)
self.btn_to_left.setToolTip(self.tr("The RevPiPyLoad version on the Revolution Pi is to old."))
elif not helper.cm.develop_watch_path:
elif not helper.cm.settings.watch_path:
self.btn_to_left.setEnabled(False)
self.btn_to_left.setToolTip(self.tr("Choose a local directory first."))
else:
@@ -208,7 +207,7 @@ class RevPiFiles(QtWidgets.QMainWindow, Ui_win_files):
elif item.type() == NodeType.FILE:
item.setSelected(value)
def __item_selection_changed(self, tree_view: QtWidgets.QTreeView):
def __item_selection_changed(self, tree_view: QtWidgets.QTreeWidget):
"""Manager vor item selection of three views."""
item = tree_view.currentItem()
if item is None:
@@ -231,7 +230,7 @@ class RevPiFiles(QtWidgets.QMainWindow, Ui_win_files):
@QtCore.pyqtSlot()
def on_tree_files_local_itemSelectionChanged(self):
self.__item_selection_changed(self.tree_files_local)
helper.cm.develop_watch_files = self.file_list_local()
helper.cm.settings.watch_files = self.file_list_local()
@QtCore.pyqtSlot()
def on_tree_files_revpi_itemSelectionChanged(self):
@@ -288,7 +287,7 @@ class RevPiFiles(QtWidgets.QMainWindow, Ui_win_files):
else:
self.tree_files_local.addTopLevelItem(item)
item.setSelected(de.path in helper.cm.develop_watch_files)
item.setSelected(de.path in helper.cm.settings.watch_files)
self._parent_selection_state(item)
def _load_files_local(self, silent=False):
@@ -302,7 +301,7 @@ class RevPiFiles(QtWidgets.QMainWindow, Ui_win_files):
self.tree_files_counter = 0
self.tree_files_local.blockSignals(True)
self.tree_files_local.clear()
self.__insert_files_local(helper.cm.develop_watch_path)
self.__insert_files_local(helper.cm.settings.watch_path)
self.tree_files_local.sortItems(0, QtCore.Qt.AscendingOrder)
self.tree_files_local.blockSignals(False)
@@ -435,18 +434,18 @@ class RevPiFiles(QtWidgets.QMainWindow, Ui_win_files):
# endregion # # # # #
@QtCore.pyqtSlot()
def on_btn_all_pressed(self):
pi.logger.debug("RevPiFiles.on_btn_all_pressed")
def on_btn_all_clicked(self):
pi.logger.debug("RevPiFiles.on_btn_all_clicked")
self._do_my_job(True)
self.file_list_revpi()
@QtCore.pyqtSlot()
def on_btn_select_local_pressed(self):
pi.logger.debug("RevPiFiles.on_btn_select_pressed")
def on_btn_select_local_clicked(self):
pi.logger.debug("RevPiFiles.on_btn_select_clicked")
diag_folder = QtWidgets.QFileDialog(
self, self.tr("Select folder..."),
helper.cm.develop_watch_path,
helper.cm.settings.watch_path,
)
diag_folder.setFileMode(QtWidgets.QFileDialog.DirectoryOnly)
if diag_folder.exec() != QtWidgets.QFileDialog.Accepted:
@@ -460,38 +459,38 @@ class RevPiFiles(QtWidgets.QMainWindow, Ui_win_files):
"Can not access the folder '{0}' to read files."
)
)
helper.cm.develop_watch_files = []
helper.cm.develop_watch_path = ""
helper.cm.settings.watch_files = []
helper.cm.settings.watch_path = ""
return
self.lbl_path_local.setText(selected_dir)
self.lbl_path_local.setToolTip(self.lbl_path_local.text())
helper.cm.develop_watch_path = selected_dir
helper.cm.develop_watch_files = []
helper.cm.settings.watch_path = selected_dir
helper.cm.settings.watch_files = []
self._load_files_local(False)
@QtCore.pyqtSlot()
def on_btn_refresh_local_pressed(self):
pi.logger.debug("RevPiFiles.on_btn_refresh_pressed")
def on_btn_refresh_local_clicked(self):
pi.logger.debug("RevPiFiles.on_btn_refresh_clicked")
self._load_files_local(False)
@QtCore.pyqtSlot()
def on_btn_refresh_revpi_pressed(self):
pi.logger.debug("RevPiFiles.on_btn_refresh_revpi_pressed")
def on_btn_refresh_revpi_clicked(self):
pi.logger.debug("RevPiFiles.on_btn_refresh_revpi_clicked")
self._load_files_revpi(False)
@QtCore.pyqtSlot()
def on_btn_to_right_pressed(self):
def on_btn_to_right_clicked(self):
"""Upload selected files to revolution pi."""
pi.logger.debug("RevPiFiles.on_btn_to_right_pressed")
pi.logger.debug("RevPiFiles.on_btn_to_right_clicked")
self._do_my_job(False)
self._load_files_revpi(True)
@QtCore.pyqtSlot()
def on_btn_to_left_pressed(self):
def on_btn_to_left_clicked(self):
"""Download selected file."""
pi.logger.debug("RevPiFiles.on_btn_to_left_pressed")
pi.logger.debug("RevPiFiles.on_btn_to_left_clicked")
override = None
for item in self.tree_files_revpi.selectedItems():
@@ -511,7 +510,7 @@ class RevPiFiles(QtWidgets.QMainWindow, Ui_win_files):
).format(file_name)
)
else:
file_name = os.path.join(helper.cm.develop_watch_path, file_name)
file_name = os.path.join(helper.cm.settings.watch_path, file_name)
if override is None and os.path.exists(file_name):
rc_diag = QtWidgets.QMessageBox.question(
self, self.tr("Override files..."), self.tr(
@@ -530,15 +529,15 @@ class RevPiFiles(QtWidgets.QMainWindow, Ui_win_files):
os.makedirs(os.path.dirname(file_name), exist_ok=True)
file_data = gzip.decompress(rc)
with open(os.path.join(helper.cm.develop_watch_path, file_name), "wb") as fh:
with open(os.path.join(helper.cm.settings.watch_path, file_name), "wb") as fh:
fh.write(file_data)
self._load_files_local()
@QtCore.pyqtSlot()
def on_btn_delete_revpi_pressed(self):
def on_btn_delete_revpi_clicked(self):
"""Remove selected files from working directory on revolution pi."""
pi.logger.debug("RevPiFiles.btn_delete_revpi_pressed")
pi.logger.debug("RevPiFiles.btn_delete_revpi_clicked")
lst_delete = []
for item in self.tree_files_revpi.selectedItems():

View File

@@ -166,12 +166,12 @@ class RevPiLogfile(QtWidgets.QMainWindow, Ui_win_revpilogfile):
self.th_data.resume()
@QtCore.pyqtSlot()
def on_btn_daemon_pressed(self):
def on_btn_daemon_clicked(self):
"""Clear the daemon log view."""
self.txt_daemon.clear()
@QtCore.pyqtSlot()
def on_btn_app_pressed(self):
def on_btn_app_clicked(self):
"""Clear the app log view."""
self.txt_app.clear()

View File

@@ -6,10 +6,13 @@ __license__ = "GPLv3"
from enum import IntEnum
import keyring
from PyQt5 import QtCore, QtGui, QtWidgets
from keyring.errors import KeyringError
from . import helper
from . import proginit as pi
from .helper import WidgetData, settings
from .helper import RevPiSettings, WidgetData
from .ui.revpiplclist_ui import Ui_diag_connections
@@ -24,11 +27,11 @@ class RevPiPlcList(QtWidgets.QDialog, Ui_diag_connections):
def __init__(self, parent=None):
super(RevPiPlcList, self).__init__(parent)
self.setupUi(self)
self.__default_name = self.tr("New connection")
self.__default_port = 55123
self.__current_item = QtWidgets.QTreeWidgetItem() # type: QtWidgets.QTreeWidgetItem
self.changes = True
self._keyring_cleanup_id_user = []
self.tre_connections.setColumnWidth(0, 250)
self.lbl_port.setText(self.lbl_port.text().format(self.__default_port))
@@ -41,38 +44,22 @@ class RevPiPlcList(QtWidgets.QDialog, Ui_diag_connections):
self.tre_connections.clear()
self.cbb_folder.clear()
self.cbb_folder.addItem("")
for i in range(settings.beginReadArray("connections")):
settings.setArrayIndex(i)
# Get length of array and close it, the RevPiSettings-class need it
count_settings = helper.settings.beginReadArray("connections")
helper.settings.endArray()
for i in range(count_settings):
settings = RevPiSettings(i)
con_item = QtWidgets.QTreeWidgetItem(NodeType.CON)
con_item.setIcon(0, QtGui.QIcon(":/main/ico/cpu.ico"))
con_item.setText(0, settings.value("name", "Revolution Pi", str))
con_item.setText(1, settings.value("address", "127.0.0.1", str))
con_item.setData(0, WidgetData.port, settings.value("port", self.__default_port, int))
con_item.setData(0, WidgetData.timeout, settings.value("timeout", 5, int))
con_item.setText(0, settings.name)
con_item.setText(1, settings.address)
con_item.setData(0, WidgetData.ssh_use_tunnel, settings.value("ssh_use_tunnel", False, bool))
con_item.setData(0, WidgetData.ssh_port, settings.value("ssh_port", 22, int))
con_item.setData(0, WidgetData.ssh_user, settings.value("ssh_user", "pi", str))
con_item.setData(0, WidgetData.revpi_settings, settings)
con_item.setData(0, WidgetData.last_dir_upload, settings.value("last_dir_upload"))
con_item.setData(0, WidgetData.last_file_upload, settings.value("last_file_upload"))
con_item.setData(0, WidgetData.last_dir_pictory, settings.value("last_dir_pictory"))
con_item.setData(0, WidgetData.last_dir_picontrol, settings.value("last_dir_picontrol"))
con_item.setData(0, WidgetData.last_dir_selected, settings.value("last_dir_selected"))
con_item.setData(0, WidgetData.last_pictory_file, settings.value("last_pictory_file"))
con_item.setData(0, WidgetData.last_tar_file, settings.value("last_tar_file"))
con_item.setData(0, WidgetData.last_zip_file, settings.value("last_zip_file"))
con_item.setData(0, WidgetData.watch_files, settings.value("watch_files"))
con_item.setData(0, WidgetData.watch_path, settings.value("watch_path"))
try:
# Bytes with QSettings are a little difficult sometimes
con_item.setData(0, WidgetData.debug_geos, settings.value("debug_geos"))
except Exception:
# Just drop the geos of IO windows
pass
folder = settings.value("folder", "", str)
folder = settings.folder
if folder:
sub_folder = self._get_folder_item(folder)
if sub_folder is None:
@@ -86,10 +73,8 @@ class RevPiPlcList(QtWidgets.QDialog, Ui_diag_connections):
else:
self.tre_connections.addTopLevelItem(con_item)
settings.endArray()
self.tre_connections.expandAll()
self.changes = True
self.changes = False
if self.tre_connections.topLevelItemCount() == 0:
self._edit_state()
@@ -97,57 +82,31 @@ class RevPiPlcList(QtWidgets.QDialog, Ui_diag_connections):
def accept(self) -> None:
pi.logger.debug("RevPiPlcList.accept")
def set_settings(node: QtWidgets.QTreeWidgetItem):
parent = node.parent()
settings.setValue("address", node.text(1))
settings.setValue("folder", parent.text(0) if parent else "")
settings.setValue("name", node.text(0))
settings.setValue("port", node.data(0, WidgetData.port))
settings.setValue("timeout", node.data(0, WidgetData.timeout))
settings.setValue("ssh_use_tunnel", node.data(0, WidgetData.ssh_use_tunnel))
settings.setValue("ssh_port", node.data(0, WidgetData.ssh_port))
settings.setValue("ssh_user", node.data(0, WidgetData.ssh_user))
for internal_id, ssh_user in self._keyring_cleanup_id_user:
service_name = "{0}.{1}_{2}".format(
helper.settings.applicationName(),
helper.settings.organizationName(),
internal_id
)
try:
# Remove information from os keyring, which we collected on_btn_delete_clicked
keyring.delete_password(service_name, ssh_user)
except KeyringError as e:
pi.logger.error(e)
if node.data(0, WidgetData.last_dir_upload):
settings.setValue("last_dir_upload", node.data(0, WidgetData.last_dir_upload))
if node.data(0, WidgetData.last_file_upload):
settings.setValue("last_file_upload", node.data(0, WidgetData.last_file_upload))
if node.data(0, WidgetData.last_dir_pictory):
settings.setValue("last_dir_pictory", node.data(0, WidgetData.last_dir_pictory))
if node.data(0, WidgetData.last_dir_picontrol):
settings.setValue("last_dir_picontrol", node.data(0, WidgetData.last_dir_picontrol))
if node.data(0, WidgetData.last_dir_selected):
settings.setValue("last_dir_selected", node.data(0, WidgetData.last_dir_selected))
if node.data(0, WidgetData.last_pictory_file):
settings.setValue("last_pictory_file", node.data(0, WidgetData.last_pictory_file))
if node.data(0, WidgetData.last_tar_file):
settings.setValue("last_tar_file", node.data(0, WidgetData.last_tar_file))
if node.data(0, WidgetData.last_zip_file):
settings.setValue("last_zip_file", node.data(0, WidgetData.last_zip_file))
if node.data(0, WidgetData.watch_files):
settings.setValue("watch_files", node.data(0, WidgetData.watch_files))
if node.data(0, WidgetData.watch_path):
settings.setValue("watch_path", node.data(0, WidgetData.watch_path))
if node.data(0, WidgetData.debug_geos):
settings.setValue("debug_geos", node.data(0, WidgetData.debug_geos))
helper.settings.remove("connections")
settings.remove("connections")
settings.beginWriteArray("connections")
counter_index = 0
for i in range(self.tre_connections.topLevelItemCount()):
root_item = self.tre_connections.topLevelItem(i)
if root_item.type() == NodeType.DIR:
for k in range(root_item.childCount()):
settings.setArrayIndex(counter_index)
set_settings(root_item.child(k))
counter_index += 1
revpi_settings = root_item.child(k).data(0, WidgetData.revpi_settings) # type: RevPiSettings
revpi_settings.folder = root_item.text(0)
revpi_settings.save_settings()
elif root_item.type() == NodeType.CON:
settings.setArrayIndex(counter_index)
set_settings(root_item)
counter_index += 1
settings.endArray()
revpi_settings = root_item.data(0, WidgetData.revpi_settings) # type: RevPiSettings
revpi_settings.folder = ""
revpi_settings.save_settings()
self.changes = False
super(RevPiPlcList, self).accept()
@@ -170,6 +129,17 @@ class RevPiPlcList(QtWidgets.QDialog, Ui_diag_connections):
self._load_settings()
return super(RevPiPlcList, self).exec()
def exec_with_presets(self, presets: RevPiSettings) -> int:
"""
Start dialog with new created settings object and presets.
:param presets: Use these settings as preset
:return: Dialog status
"""
self._load_settings()
self.on_btn_add_clicked(presets)
return super(RevPiPlcList, self).exec()
@QtCore.pyqtSlot(QtWidgets.QAbstractButton)
def on_btn_box_clicked(self, button: QtWidgets.QAbstractButton):
if self.btn_box.buttonRole(button) == QtWidgets.QDialogButtonBox.DestructiveRole:
@@ -179,6 +149,7 @@ class RevPiPlcList(QtWidgets.QDialog, Ui_diag_connections):
# region # REGION: Connection management
def _edit_state(self):
"""Set enabled status of all controls, depending on selected item."""
item = self.tre_connections.currentItem()
if item is None:
up_ok = False
@@ -232,6 +203,7 @@ class RevPiPlcList(QtWidgets.QDialog, Ui_diag_connections):
if 0 <= new_index < dir_item.childCount():
item = dir_item.takeChild(index)
dir_item.insertChild(new_index, item)
self.tre_connections.expandItem(dir_item)
else:
index = self.tre_connections.indexOfTopLevelItem(item)
new_index = index + count
@@ -249,39 +221,48 @@ class RevPiPlcList(QtWidgets.QDialog, Ui_diag_connections):
self._edit_state()
if current and current.type() == NodeType.CON:
self.__current_item = current
self.txt_name.setText(current.text(0))
self.txt_address.setText(current.text(1))
self.sbx_port.setValue(current.data(0, WidgetData.port))
self.sbx_timeout.setValue(current.data(0, WidgetData.timeout))
settings = current.data(0, WidgetData.revpi_settings) # type: RevPiSettings
self.txt_name.setText(settings.name)
self.txt_address.setText(settings.address)
self.sbx_port.setValue(settings.port)
self.sbx_timeout.setValue(settings.timeout)
if current.parent() is None:
self.cbb_folder.setCurrentIndex(0)
else:
self.cbb_folder.setCurrentText(current.parent().text(0))
self.cbx_ssh_use_tunnel.setChecked(current.data(0, WidgetData.ssh_use_tunnel))
self.sbx_ssh_port.setValue(current.data(0, WidgetData.ssh_port))
self.txt_ssh_user.setText(current.data(0, WidgetData.ssh_user))
self.cbx_ssh_use_tunnel.setChecked(settings.ssh_use_tunnel)
self.sbx_ssh_port.setValue(settings.ssh_port)
self.txt_ssh_user.setText(settings.ssh_user)
elif current and current.type() == NodeType.DIR:
self.__current_item = current
self.cbb_folder.setCurrentText(current.text(0))
else:
self.__current_item = QtWidgets.QTreeWidgetItem()
self.cbb_folder.setCurrentText(current.text(0) if current else "")
@QtCore.pyqtSlot()
def on_btn_up_pressed(self):
def on_btn_up_clicked(self):
self._move_item(-1)
@QtCore.pyqtSlot()
def on_btn_down_pressed(self):
def on_btn_down_clicked(self):
self._move_item(1)
@QtCore.pyqtSlot()
def on_btn_delete_pressed(self):
def on_btn_delete_clicked(self):
"""Remove selected entry."""
item = self.tre_connections.currentItem()
if item and item.type() == NodeType.CON:
revpi_settings = item.data(0, WidgetData.revpi_settings) # type: RevPiSettings
if revpi_settings.ssh_saved_password:
# Cleans up keyring in save function
self._keyring_cleanup_id_user.append((revpi_settings.internal_id, revpi_settings.ssh_user))
dir_node = item.parent()
if dir_node:
dir_node.removeChild(item)
@@ -292,23 +273,21 @@ class RevPiPlcList(QtWidgets.QDialog, Ui_diag_connections):
self._edit_state()
@QtCore.pyqtSlot()
def on_btn_add_pressed(self):
def on_btn_add_clicked(self, settings_preset: RevPiSettings = None):
"""Create new element."""
self.__current_item = QtWidgets.QTreeWidgetItem(NodeType.CON)
self.__current_item.setIcon(0, QtGui.QIcon(":/main/ico/cpu.ico"))
self.__current_item.setText(0, self.__default_name)
self.__current_item.setData(0, WidgetData.port, self.__default_port)
self.__current_item.setData(0, WidgetData.timeout, 5)
self.__current_item.setData(0, WidgetData.ssh_use_tunnel, False)
self.__current_item.setData(0, WidgetData.ssh_port, 22)
self.__current_item.setData(0, WidgetData.ssh_user, "pi")
settings = settings_preset or RevPiSettings()
new_item = QtWidgets.QTreeWidgetItem(NodeType.CON)
new_item.setIcon(0, QtGui.QIcon(":/main/ico/cpu.ico"))
new_item.setText(0, settings.name)
new_item.setData(0, WidgetData.revpi_settings, settings)
sub_folder = self._get_folder_item(self.cbb_folder.currentText())
if sub_folder:
sub_folder.addChild(self.__current_item)
sub_folder.addChild(new_item)
else:
self.tre_connections.addTopLevelItem(self.__current_item)
self.tre_connections.addTopLevelItem(new_item)
self.tre_connections.setCurrentItem(self.__current_item)
# This will load all settings and prepare widgets
self.tre_connections.setCurrentItem(new_item)
self.txt_name.setFocus()
self.txt_name.selectAll()
@@ -317,42 +296,58 @@ class RevPiPlcList(QtWidgets.QDialog, Ui_diag_connections):
if self.__current_item.type() != NodeType.CON:
return
self.__current_item.setText(0, text)
settings = self.__current_item.data(0, WidgetData.revpi_settings) # type: RevPiSettings
settings.name = text
self.changes = True
@QtCore.pyqtSlot(str)
def on_txt_address_textEdited(self, text):
if self.__current_item.type() != NodeType.CON:
return
self.__current_item.setText(1, text)
settings = self.__current_item.data(0, WidgetData.revpi_settings) # type: RevPiSettings
settings.address = text
self.changes = True
@QtCore.pyqtSlot(int)
def on_sbx_port_valueChanged(self, value: int):
if self.__current_item.type() != NodeType.CON:
return
self.__current_item.setData(0, WidgetData.port, value)
settings = self.__current_item.data(0, WidgetData.revpi_settings) # type: RevPiSettings
settings.port = value
self.changes = True
@QtCore.pyqtSlot(int)
def on_sbx_timeout_valueChanged(self, value: int):
if self.__current_item.type() != NodeType.CON:
return
self.__current_item.setData(0, WidgetData.timeout, value)
settings = self.__current_item.data(0, WidgetData.revpi_settings) # type: RevPiSettings
settings.timeout = value
self.changes = True
@QtCore.pyqtSlot(int)
def on_cbx_ssh_use_tunnel_stateChanged(self, check_state: int):
if self.__current_item.type() != NodeType.CON:
return
self.__current_item.setData(0, WidgetData.ssh_use_tunnel, check_state == QtCore.Qt.CheckState.Checked)
settings = self.__current_item.data(0, WidgetData.revpi_settings) # type: RevPiSettings
settings.ssh_use_tunnel = check_state == QtCore.Qt.CheckState.Checked
self.changes = True
@QtCore.pyqtSlot(int)
def on_sbx_ssh_port_valueChanged(self, value: int):
if self.__current_item.type() != NodeType.CON:
return
self.__current_item.setData(0, WidgetData.ssh_port, value)
settings = self.__current_item.data(0, WidgetData.revpi_settings) # type: RevPiSettings
settings.ssh_port = value
self.changes = True
@QtCore.pyqtSlot(str)
def on_txt_ssh_user_textEdited(self, text):
if self.__current_item.type() != NodeType.CON:
return
self.__current_item.setData(0, WidgetData.ssh_user, text)
settings = self.__current_item.data(0, WidgetData.revpi_settings) # type: RevPiSettings
settings.ssh_user = text
self.changes = True
@QtCore.pyqtSlot(str)
def on_cbb_folder_editTextChanged(self, text: str):

View File

@@ -58,8 +58,7 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
:return: True, if unsaved changes was found
"""
return \
self.cbb_plcprogram.currentText() != self.dc.get("plcprogram", "") or \
return self.cbb_plcprogram.currentText() != self.dc.get("plcprogram", "") or \
self.txt_plcarguments.text() != self.dc.get("plcarguments", "") or \
self.rbn_pythonversion_2.isChecked() != (self.dc.get("pythonversion", 3) == 2) or \
self.rbn_pythonversion_3.isChecked() != (self.dc.get("pythonversion", 3) == 3) or \
@@ -213,7 +212,7 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
)
)
elif ec == 0:
helper.cm.program_last_pictory_file = filename
helper.cm.settings.last_pictory_file = filename
if ask == QtWidgets.QMessageBox.Yes:
QtWidgets.QMessageBox.information(
self, self.tr("Success"), self.tr(
@@ -319,21 +318,16 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
self.cbx_pictory.setEnabled(index >= 1)
@QtCore.pyqtSlot()
def on_btn_program_download_pressed(self):
def on_btn_program_download_clicked(self):
"""Download plc program from Revolution Pi."""
if not helper.cm.connected:
return
selected_dir = ""
if self.cbb_format.currentIndex() == 0:
# Save files as zip archive
diag_save = QtWidgets.QFileDialog(
self, self.tr("Save ZIP archive..."),
os.path.join(
helper.cm.program_last_zip_file,
"{0}.zip".format(helper.cm.name)
),
helper.cm.settings.last_zip_file or "{0}.zip".format(helper.cm.settings.name),
self.tr("ZIP archive (*.zip);;All files (*.*)")
)
diag_save.setAcceptMode(QtWidgets.QFileDialog.AcceptSave)
@@ -345,16 +339,13 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
filename = diag_save.selectedFiles()[0]
fh = open(filename, "wb")
helper.cm.program_last_zip_file = filename
helper.cm.settings.last_zip_file = filename
elif self.cbb_format.currentIndex() == 1:
# Save files as TarGz archive
diag_save = QtWidgets.QFileDialog(
self, self.tr("Save TGZ archive..."),
os.path.join(
helper.cm.program_last_tar_file,
"{0}.tgz".format(helper.cm.name)
),
helper.cm.settings.last_tar_file or "{0}.tgz".format(helper.cm.settings.name),
self.tr("TGZ archive (*.tgz);;All files (*.*)")
)
diag_save.setAcceptMode(QtWidgets.QFileDialog.AcceptSave)
@@ -366,7 +357,7 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
filename = diag_save.selectedFiles()[0]
fh = open(filename, "wb")
helper.cm.program_last_tar_file = filename
helper.cm.settings.last_tar_file = filename
else:
# Other indexes are not allowed for download
@@ -405,7 +396,7 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
)
@QtCore.pyqtSlot()
def on_btn_program_upload_pressed(self):
def on_btn_program_upload_clicked(self):
"""Upload plc program to Revolution Pi."""
if not helper.cm.connected:
return
@@ -426,7 +417,7 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
# Upload zip archive content
diag_open = QtWidgets.QFileDialog(
self, self.tr("Upload content of ZIP archive..."),
helper.cm.program_last_file_upload,
helper.cm.settings.last_file_upload,
self.tr("ZIP archive (*.zip);;All files (*.*)")
)
diag_open.setAcceptMode(QtWidgets.QFileDialog.AcceptOpen)
@@ -438,7 +429,7 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
return
filename = diag_open.selectedFiles()[0]
helper.cm.program_last_file_upload = filename
helper.cm.settings.last_file_upload = filename
if zipfile.is_zipfile(filename):
dirtmp = mkdtemp()
fhz = zipfile.ZipFile(filename)
@@ -460,7 +451,7 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
# Upload TarGz content
diag_open = QtWidgets.QFileDialog(
self, self.tr("Upload content of TAR archive..."),
helper.cm.program_last_file_upload,
helper.cm.settings.last_file_upload,
self.tr("TAR archive (*.tgz);;All files (*.*)")
)
diag_open.setAcceptMode(QtWidgets.QFileDialog.AcceptOpen)
@@ -472,7 +463,7 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
return
filename = diag_open.selectedFiles()[0]
helper.cm.program_last_file_upload = filename
helper.cm.settings.last_file_upload = filename
if tarfile.is_tarfile(filename):
dirtmp = mkdtemp()
fht = tarfile.open(filename)
@@ -598,7 +589,7 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
# region # REGION: Control files
@QtCore.pyqtSlot()
def on_btn_pictory_download_pressed(self):
def on_btn_pictory_download_clicked(self):
"""Download piCtory configuration."""
if not helper.cm.connected:
return
@@ -606,8 +597,8 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
diag_save = QtWidgets.QFileDialog(
self, self.tr("Save piCtory file..."),
os.path.join(
helper.cm.program_last_dir_pictory,
"{0}.rsc".format(helper.cm.name)
helper.cm.settings.last_dir_pictory,
"{0}.rsc".format(helper.cm.settings.name)
),
self.tr("piCtory file (*.rsc);;All files (*.*)")
)
@@ -619,7 +610,7 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
return
filename = diag_save.selectedFiles()[0]
helper.cm.program_last_dir_pictory = os.path.dirname(filename)
helper.cm.settings.last_dir_pictory = os.path.dirname(filename)
bin_buffer = helper.cm.call_remote_function("get_pictoryrsc") # type: Binary
if bin_buffer is None:
QtWidgets.QMessageBox.critical(
@@ -639,13 +630,13 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
)
@QtCore.pyqtSlot()
def on_btn_pictory_upload_pressed(self):
def on_btn_pictory_upload_clicked(self):
if not helper.cm.connected:
return
diag_open = QtWidgets.QFileDialog(
self, self.tr("Upload piCtory file..."),
helper.cm.program_last_pictory_file,
helper.cm.settings.last_pictory_file or "{0}.rsc".format(helper.cm.settings.name),
self.tr("piCtory file (*.rsc);;All files (*.*)")
)
diag_open.setAcceptMode(QtWidgets.QFileDialog.AcceptOpen)
@@ -659,7 +650,7 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
self._upload_pictory(diag_open.selectedFiles()[0])
@QtCore.pyqtSlot()
def on_btn_procimg_download_pressed(self):
def on_btn_procimg_download_clicked(self):
"""Download process image."""
if not helper.cm.connected:
return
@@ -668,8 +659,8 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
self,
self.tr("Save piControl file..."),
os.path.join(
helper.cm.program_last_dir_picontrol,
"{0}.img".format(helper.cm.name)
helper.cm.settings.last_dir_picontrol,
"{0}.img".format(helper.cm.settings.name)
),
self.tr("Process image file (*.img);;All files (*.*)")
)
@@ -681,7 +672,7 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
return
filename = diag_save.selectedFiles()[0]
helper.cm.program_last_dir_picontrol = os.path.dirname(filename)
helper.cm.settings.last_dir_picontrol = os.path.dirname(filename)
bin_buffer = helper.cm.call_remote_function("get_procimg") # type: Binary
if bin_buffer is None:

View File

@@ -4,35 +4,101 @@ __author__ = "Sven Sager"
__copyright__ = "Copyright (C) 2023 Sven Sager"
__license__ = "GPLv3"
from enum import Enum
from logging import getLogger
import keyring
from PyQt5 import QtWidgets
from keyring.errors import KeyringError
from revpicommander.ui.sshauth_ui import Ui_diag_sshauth
from .ui.sshauth_ui import Ui_diag_sshauth
log = getLogger()
class SSHAuthType(Enum):
PASS = "pass"
KEYS = "keys"
class SSHAuth(QtWidgets.QDialog, Ui_diag_sshauth):
"""Version information window."""
def __init__(self, auth_type: SSHAuthType, parent=None):
def __init__(self, user_name="", service_name: str = None, parent=None):
"""
Ask the user for username and password or use saved entries.
If you want to use the operating system's password storage, you have
to set a 'service_name'. The value must be unique for your application
or for each user, if the username is the same.
:param user_name: Preset username, also used to check password save
:param service_name: Identity to save passwords in os's password save
:param parent: Qt parent for this dialog
"""
log.debug("SSHAuth.__init__")
super(SSHAuth, self).__init__(parent)
self.setupUi(self)
self.wid_password.setVisible(auth_type is SSHAuthType.PASS)
self.wid_keys.setVisible(auth_type is SSHAuthType.KEYS)
self._in_keyring = False
self._service_name = service_name
self.cbx_save_password.setVisible(bool(service_name))
self.txt_username.setText(user_name)
def accept(self) -> None:
log.debug("SSHAuth.accept")
if self._service_name and self.cbx_save_password.isChecked():
try:
keyring.set_password(self._service_name, self.username, self.password)
except KeyringError as e:
log.error(e)
self._in_keyring = False
QtWidgets.QMessageBox.warning(
self, self.tr("Could not save password"), self.tr(
"Could not save password to operating systems password save.\n\n"
"Maybe your operating system does not support saving passwords. "
"This could be due to missing libraries or programs.\n\n"
"This is not an error of RevPi Commander."
)
)
else:
self._in_keyring = True
super().accept()
def exec(self) -> int:
log.debug("SSHAuth.exec")
if self._service_name:
try:
saved_password = keyring.get_password(self._service_name, self.username)
except KeyringError as e:
log.error(e)
self._in_keyring = False
else:
if saved_password:
self._in_keyring = True
self.txt_password.setText(saved_password)
return QtWidgets.QDialog.Accepted
return super().exec()
def remove_saved_password(self) -> None:
"""Remove saved password."""
log.debug("SSHAuth.remove_saved_password")
if self._service_name:
try:
keyring.delete_password(self._service_name, self.username)
except KeyringError as e:
log.error(e)
@property
def in_keyring(self) -> bool:
"""True, if password is in keyring."""
return self._in_keyring
@property
def password(self) -> str:
"""Get the saved or entered password."""
return self.txt_password.text()
@property
def username(self) -> str:
"""Get the entered username."""
return self.txt_username.text()
@username.setter
def username(self, value: str):
self.txt_username.setText(value)

View File

@@ -75,6 +75,8 @@ class Ui_diag_search(object):
self.act_connect_ssh.setObjectName("act_connect_ssh")
self.act_connect_xmlrpc = QtWidgets.QAction(diag_search)
self.act_connect_xmlrpc.setObjectName("act_connect_xmlrpc")
self.act_connect = QtWidgets.QAction(diag_search)
self.act_connect.setObjectName("act_connect")
self.retranslateUi(diag_search)
self.btn_box.rejected.connect(diag_search.reject) # type: ignore
@@ -99,6 +101,8 @@ class Ui_diag_search(object):
self.act_connect_ssh.setToolTip(_translate("diag_search", "Establish a connection via encrypted SSH tunnel"))
self.act_connect_xmlrpc.setText(_translate("diag_search", "Connect via XML-RPC"))
self.act_connect_xmlrpc.setToolTip(_translate("diag_search", "You have to configure your Revolution Pi to accept this connections"))
self.act_connect.setText(_translate("diag_search", "Connect"))
self.act_connect.setToolTip(_translate("diag_search", "Connect to Revoluton Pi"))
from . import ressources_rc

View File

@@ -36,15 +36,18 @@ class Ui_wid_debugcontrol(object):
self.verticalLayout = QtWidgets.QVBoxLayout(self.gb_control)
self.verticalLayout.setObjectName("verticalLayout")
self.btn_read_io = QtWidgets.QPushButton(self.gb_control)
self.btn_read_io.setShortcut("F4")
self.btn_read_io.setAutoRepeat(True)
self.btn_read_io.setAutoRepeatDelay(100)
self.btn_read_io.setAutoRepeatInterval(200)
self.btn_read_io.setObjectName("btn_read_io")
self.verticalLayout.addWidget(self.btn_read_io)
self.btn_refresh_io = QtWidgets.QPushButton(self.gb_control)
self.btn_refresh_io.setShortcut("F5")
self.btn_refresh_io.setAutoRepeat(True)
self.btn_refresh_io.setAutoRepeatDelay(100)
self.btn_refresh_io.setAutoRepeatInterval(200)
self.btn_refresh_io.setObjectName("btn_refresh_io")
self.verticalLayout.addWidget(self.btn_refresh_io)
self.btn_write_o = QtWidgets.QPushButton(self.gb_control)
self.btn_write_o.setShortcut("F6")
self.btn_write_o.setObjectName("btn_write_o")
self.verticalLayout.addWidget(self.btn_write_o)
self.cbx_refresh = QtWidgets.QCheckBox(self.gb_control)
@@ -65,9 +68,13 @@ class Ui_wid_debugcontrol(object):
self.gb_devices.setTitle(_translate("wid_debugcontrol", "Revolution Pi devices"))
self.cbx_stay_on_top.setText(_translate("wid_debugcontrol", "Open to stay on top"))
self.gb_control.setTitle(_translate("wid_debugcontrol", "IO Control"))
self.btn_read_io.setToolTip(_translate("wid_debugcontrol", "Read all IO values and discard local changes (F4)"))
self.btn_read_io.setToolTip(_translate("wid_debugcontrol", "Read all IO values and discard local changes (F4)\n"
"\n"
"Hold this button pressed and it will refresh the IOs every 200 ms."))
self.btn_read_io.setText(_translate("wid_debugcontrol", "Read &all IO values"))
self.btn_refresh_io.setToolTip(_translate("wid_debugcontrol", "Refresh all IO values which are locally not changed (F5)"))
self.btn_refresh_io.setToolTip(_translate("wid_debugcontrol", "Refresh all IO values which are locally not changed (F5)\n"
"\n"
"Hold this button pressed and it will refresh the IOs every 200 ms."))
self.btn_refresh_io.setText(_translate("wid_debugcontrol", "&Refresh unchanged IOs"))
self.btn_write_o.setToolTip(_translate("wid_debugcontrol", "Write locally changed output values to process image (F6)"))
self.btn_write_o.setText(_translate("wid_debugcontrol", "&Write changed outputs"))

View File

@@ -15,7 +15,7 @@ class Ui_diag_sshauth(object):
def setupUi(self, diag_sshauth):
diag_sshauth.setObjectName("diag_sshauth")
diag_sshauth.setWindowModality(QtCore.Qt.ApplicationModal)
diag_sshauth.resize(275, 170)
diag_sshauth.resize(363, 163)
self.verticalLayout = QtWidgets.QVBoxLayout(diag_sshauth)
self.verticalLayout.setObjectName("verticalLayout")
self.wid_password = QtWidgets.QWidget(diag_sshauth)
@@ -36,18 +36,18 @@ class Ui_diag_sshauth(object):
self.txt_username.setObjectName("txt_username")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.txt_username)
self.verticalLayout.addWidget(self.wid_password)
self.wid_keys = QtWidgets.QWidget(diag_sshauth)
self.wid_keys.setObjectName("wid_keys")
self.verticalLayout.addWidget(self.wid_keys)
self.buttonBox = QtWidgets.QDialogButtonBox(diag_sshauth)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
self.verticalLayout.addWidget(self.buttonBox)
self.cbx_save_password = QtWidgets.QCheckBox(diag_sshauth)
self.cbx_save_password.setObjectName("cbx_save_password")
self.verticalLayout.addWidget(self.cbx_save_password)
self.btn_box = QtWidgets.QDialogButtonBox(diag_sshauth)
self.btn_box.setOrientation(QtCore.Qt.Horizontal)
self.btn_box.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.btn_box.setObjectName("btn_box")
self.verticalLayout.addWidget(self.btn_box)
self.retranslateUi(diag_sshauth)
self.buttonBox.accepted.connect(diag_sshauth.accept) # type: ignore
self.buttonBox.rejected.connect(diag_sshauth.reject) # type: ignore
self.btn_box.accepted.connect(diag_sshauth.accept) # type: ignore
self.btn_box.rejected.connect(diag_sshauth.reject) # type: ignore
QtCore.QMetaObject.connectSlotsByName(diag_sshauth)
def retranslateUi(self, diag_sshauth):
@@ -55,6 +55,8 @@ class Ui_diag_sshauth(object):
diag_sshauth.setWindowTitle(_translate("diag_sshauth", "SSH authentication"))
self.lbl_username.setText(_translate("diag_sshauth", "SSH username:"))
self.lbl_password.setText(_translate("diag_sshauth", "SSH password:"))
self.cbx_save_password.setToolTip(_translate("diag_sshauth", "Username and password will be saved in secured operating systems\'s password storage."))
self.cbx_save_password.setText(_translate("diag_sshauth", "Save username and password"))
if __name__ == "__main__":

View File

@@ -1,6 +0,0 @@
[DEFAULT]
Debian-Version=1
Depends3=python3-pyqt5, python3-revpimodio2 (>= 2.5.0), python3-zeroconf (>= 0.24.4)
Section=universe/x11
Suite=stable
X-Python3-Version: >=3.4

View File

@@ -11,6 +11,7 @@ SOURCES = src/revpicommander/aclmanager.py \
src/revpicommander/revpiplclist.py \
src/revpicommander/revpiprogram.py \
src/revpicommander/simulator.py \
src/revpicommander/sshauth.py \
src/revpicommander/revpicommander.py
FORMS = ui_dev/aclmanager.ui \

View File

@@ -151,6 +151,14 @@
<string>You have to configure your Revolution Pi to accept this connections</string>
</property>
</action>
<action name="act_connect">
<property name="text">
<string>Connect</string>
</property>
<property name="toolTip">
<string>Connect to Revoluton Pi</string>
</property>
</action>
</widget>
<resources>
<include location="ressources.qrc"/>

View File

@@ -53,26 +53,42 @@
<item>
<widget class="QPushButton" name="btn_read_io">
<property name="toolTip">
<string>Read all IO values and discard local changes (F4)</string>
<string>Read all IO values and discard local changes (F4)
Hold this button pressed and it will refresh the IOs every 200 ms.</string>
</property>
<property name="text">
<string>Read &amp;all IO values</string>
</property>
<property name="shortcut">
<string notr="true">F4</string>
<property name="autoRepeat">
<bool>true</bool>
</property>
<property name="autoRepeatDelay">
<number>100</number>
</property>
<property name="autoRepeatInterval">
<number>200</number>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_refresh_io">
<property name="toolTip">
<string>Refresh all IO values which are locally not changed (F5)</string>
<string>Refresh all IO values which are locally not changed (F5)
Hold this button pressed and it will refresh the IOs every 200 ms.</string>
</property>
<property name="text">
<string>&amp;Refresh unchanged IOs</string>
</property>
<property name="shortcut">
<string notr="true">F5</string>
<property name="autoRepeat">
<bool>true</bool>
</property>
<property name="autoRepeatDelay">
<number>100</number>
</property>
<property name="autoRepeatInterval">
<number>200</number>
</property>
</widget>
</item>
@@ -84,9 +100,6 @@
<property name="text">
<string>&amp;Write changed outputs</string>
</property>
<property name="shortcut">
<string notr="true">F6</string>
</property>
</widget>
</item>
<item>

View File

@@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>275</width>
<height>170</height>
<width>363</width>
<height>163</height>
</rect>
</property>
<property name="windowTitle">
@@ -48,10 +48,17 @@
</widget>
</item>
<item>
<widget class="QWidget" name="wid_keys" native="true"/>
<widget class="QCheckBox" name="cbx_save_password">
<property name="toolTip">
<string>Username and password will be saved in secured operating systems's password storage.</string>
</property>
<property name="text">
<string>Save username and password</string>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<widget class="QDialogButtonBox" name="btn_box">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@@ -65,7 +72,7 @@
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<sender>btn_box</sender>
<signal>accepted()</signal>
<receiver>diag_sshauth</receiver>
<slot>accept()</slot>
@@ -81,7 +88,7 @@
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<sender>btn_box</sender>
<signal>rejected()</signal>
<receiver>diag_sshauth</receiver>
<slot>reject()</slot>