18 Commits

Author SHA1 Message Date
7c19e0acd1 Update changelog for 0.10.0-3 release 2023-09-18 07:05:43 +02:00
81f5b981a6 packaging: Use patched entry point and link it to /usr/bin
By renaming the entry point, which had the same name as the module,
both can now be installed in the same directory. The entry point can
then be created in /usr/bin as a link with the original name
'revpicommander'.

Signed-off-by: Sven Sager <akira@narux.de>
2023-09-18 07:03:35 +02:00
239273ae16 packaging(patch): Change entry point name in setup.py
Change entry point name to differ from the module name. In the package,
the module and its scripts are installed in the same directory. This is
done via PYBUILD_INSTALL_ARGS and --install-lib, --install-scripts.
Module name and script name must not be the same.
2023-09-18 06:53:37 +02:00
65280435a7 packaging: Remove unused GPL-3+ section from copyright file 2023-09-18 06:33:35 +02:00
b252aec126 Update changelog for 0.10.0-2 release
Signed-off-by: Sven Sager <akira@narux.de>
2023-09-16 17:32:35 +02:00
3d6e9877d7 packaging(deb): Start packaging branch
Signed-off-by: Sven Sager <akira@narux.de>
2023-09-16 17:13:27 +02:00
c10a50fa56 chore: Release 0.10.0
Signed-off-by: Sven Sager <akira@narux.de>
2023-09-16 17:11:11 +02:00
e4d18f7b4a feat: Change entrypoint name
This will update the alternative shell script as well. It will now just
pass the modules directory to python interpreter to execute the __main__
module.

Signed-off-by: Sven Sager <akira@narux.de>
2023-09-16 17:10:59 +02:00
efd27cc96c build: Fix Makefile targets to match GNU coding standards
- Rename target clean-all to distclean
- Add uninstall target
- Install target has to run tests

Signed-off-by: Sven Sager <akira@narux.de>
2023-09-16 10:39:34 +02:00
0494ce53ad fix: Simulator always sets process image to NULL
This fixes the bug that the process image for the simulation is set
to NULL, even though the "Start without changing actual process image"
button is pressed.

Signed-off-by: Sven Sager <akira@narux.de>
2023-09-16 10:39:34 +02:00
c56c33f4e5 feat: Try to start RevPiPyLoad via SSH on the Revolution Pi
If the SSH tunnel is used and RevPiPyLoad is not started on the
Revolution Pi, an attempt is now made to start it.

Signed-off-by: Sven Sager <akira@narux.de>
2023-09-16 10:39:34 +02:00
e95bf70993 build: Use python interpreter and modules for qt commands in Makefile
The Qt5 commands for creating UI, resources and language files have
now been switched from the shell scripts to the direct call of the
Python modules.

Signed-off-by: Sven Sager <akira@narux.de>
2023-09-16 10:39:34 +02:00
6ee53595e2 feat: SSH tunnel server extended to execute commands on remote host.
Signed-off-by: Sven Sager <akira@narux.de>
2023-09-16 10:39:34 +02:00
a0b309ade0 build: Add environment variable to set alternative venv path
Signed-off-by: Sven Sager <akira@narux.de>
2023-09-16 10:39:34 +02:00
be03bbe6f3 fix: PLC monitor crashes when a device has no inputs or outputs
The calculation of the length for a device is now carried out
depending on the list content of the inputs and outputs. A length of
0 is now also possible.

Signed-off-by: Sven Sager <akira@narux.de>
2023-09-16 10:39:34 +02:00
92abe46152 chore: Release 0.10.0rc1
At this point we do not release 0.9.10. We will switch directly to
0.10.x because of all the new things and the matching version number
of revpipyload.

Signed-off-by: Sven Sager <akira@narux.de>
2023-09-16 10:39:33 +02:00
27915e5a58 fix: Show program dialog, even if there are no files on the RevPi 2023-08-22 11:58:13 +02:00
a8e4638ab9 build: Use system python interpreter in make file 2023-08-22 11:34:37 +02:00
26 changed files with 408 additions and 98 deletions

2
.idea/misc.xml generated
View File

@@ -6,7 +6,7 @@
<component name="ProjectPlainTextFileTypeManager"> <component name="ProjectPlainTextFileTypeManager">
<file url="file://$PROJECT_DIR$/src/revpicommander/locale/revpicommander_de.ts" /> <file url="file://$PROJECT_DIR$/src/revpicommander/locale/revpicommander_de.ts" />
</component> </component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (revpicommander)" project-jdk-type="Python SDK" /> <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (revpicommander)" project-jdk-type="Python SDK" />
<component name="PythonCompatibilityInspectionAdvertiser"> <component name="PythonCompatibilityInspectionAdvertiser">
<option name="version" value="3" /> <option name="version" value="3" />
</component> </component>

View File

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

2
.idea/vcs.xml generated
View File

@@ -3,6 +3,8 @@
<component name="CommitMessageInspectionProfile"> <component name="CommitMessageInspectionProfile">
<profile version="1.0"> <profile version="1.0">
<inspection_tool class="BodyLimit" enabled="true" level="WARNING" enabled_by_default="true" /> <inspection_tool class="BodyLimit" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="CommitFormat" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="CommitNamingConvention" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="SubjectBodySeparation" enabled="true" level="WARNING" enabled_by_default="true" /> <inspection_tool class="SubjectBodySeparation" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="SubjectLimit" enabled="true" level="WARNING" enabled_by_default="true" /> <inspection_tool class="SubjectLimit" enabled="true" level="WARNING" enabled_by_default="true" />
</profile> </profile>

View File

@@ -8,61 +8,69 @@ APP_NAME = RevPi\ Commander
APP_IDENT = org.revpimodio.revpicommander APP_IDENT = org.revpimodio.revpicommander
APPLE_SIG = "Developer ID Application: Sven Sager (U3N5843D9K)" APPLE_SIG = "Developer ID Application: Sven Sager (U3N5843D9K)"
# If virtualenv exists, use it. If not, use PATH to find, except python3 # Set path to create the virtual environment with package name
SYSTEM_PYTHON = /usr/bin/python3 ifdef PYTHON3_VENV
PYTHON = $(or $(wildcard venv/bin/python), $(SYSTEM_PYTHON)) VENV_PATH = $(PYTHON3_VENV)/$(PACKAGE)
SYSTEM_PYUIC5 = $(shell which pyuic5) else
PYUIC5 = $(or $(wildcard venv/bin/pyuic5), $(SYSTEM_PYUIC5)) VENV_PATH = venv
SYSTEM_PYRCC5 = $(shell which pyrcc5) endif
PYRCC5 = $(or $(wildcard venv/bin/pyrcc5), $(SYSTEM_PYRCC5))
SYSTEM_PYLUP5 = $(shell which pylupdate5) # If virtualenv exists, use it. If not, use PATH to find commands
PYLUP5 = $(or $(wildcard venv/bin/pylupdate5), $(SYSTEM_PYLUP5)) SYSTEM_PYTHON = python3
PYTHON = $(or $(wildcard $(VENV_PATH)/bin/python), $(SYSTEM_PYTHON))
APP_VERSION = $(shell $(PYTHON) src/$(PACKAGE) --version) APP_VERSION = $(shell $(PYTHON) src/$(PACKAGE) --version)
all: build_ui build_rc build all: build_ui build_rc test build
.PHONY: all .PHONY: all
## Environment ## Environment
venv-info:
echo Using path: "$(VENV_PATH)"
exit 0
venv: venv:
$(SYSTEM_PYTHON) -m venv venv $(SYSTEM_PYTHON) -m venv --system-site-packages "$(VENV_PATH)"
source venv/bin/activate && \ source $(VENV_PATH)/bin/activate && \
python3 -m pip install --upgrade pip && \ python3 -m pip install --upgrade pip && \
python3 -m pip install -r requirements.txt python3 -m pip install -r requirements.txt
exit 0 exit 0
.PHONY: venv .PHONY: venv-info venv
## Compile Qt UI files to python code ## Compile Qt UI files to python code
build_ui: build_ui:
cd ui_dev && for ui_file in *.ui; do \ cd ui_dev && for ui_file in *.ui; do \
file_name=$${ui_file%.ui}; \ file_name=$${ui_file%.ui}; \
$(PYUIC5) $${ui_file} -o ../src/$(PACKAGE)/ui/$${file_name}_ui.py -x --from-imports; \ $(PYTHON) -m PyQt5.uic.pyuic $${ui_file} -o ../src/$(PACKAGE)/ui/$${file_name}_ui.py -x --from-imports; \
echo $${file_name}; \ echo $${file_name}; \
done done
build_rc: build_rc:
cd ui_dev && for rc_file in *.qrc; do \ cd ui_dev && for rc_file in *.qrc; do \
file_name=$${rc_file%.qrc}; \ file_name=$${rc_file%.qrc}; \
$(PYRCC5) $${rc_file} -o ../src/$(PACKAGE)/ui/$${file_name}_rc.py; \ $(PYTHON) -m PyQt5.pyrcc_main $${rc_file} -o ../src/$(PACKAGE)/ui/$${file_name}_rc.py; \
echo $${file_name}; \ echo $${file_name}; \
done done
update_translation: update_translation:
$(PYLUP5) translate.pro $(PYTHON) -m PyQt5.pylupdate_main translate.pro
.PHONY: build_ui build_rc update_translation .PHONY: build_ui build_rc update_translation
## Build, install ## Build steps
build: build_ui build_rc build: build_ui build_rc
$(PYTHON) -m setup sdist $(PYTHON) -m setup sdist
$(PYTHON) -m setup bdist_wheel $(PYTHON) -m setup bdist_wheel
install: build install: test build
$(PYTHON) -m pip install dist/$(PACKAGE)-*.whl $(PYTHON) -m pip install dist/$(PACKAGE)-*.whl
.PHONY: build install uninstall:
$(PYTHON) -m pip uninstall --yes $(PACKAGE)
.PHONY: test build install uninstall
## PyInstaller ## PyInstaller
installer_mac: build_ui build_rc installer_mac: build_ui build_rc
@@ -114,7 +122,7 @@ installer_linux: build_ui build_rc
clean: clean:
rm -rf build dist src/*.egg-info *.spec rm -rf build dist src/*.egg-info *.spec
clean-all: clean distclean: clean
rm -R venv rm -rf $(VENV_PATH)
.PHONY: clean clean-all .PHONY: clean distclean

View File

@@ -1,9 +1,7 @@
#!/bin/sh #!/bin/sh
# Used to call the entry point, if packed with pybuild as application. # This script will create the entry point 'revpicommander', which is defined
# PYBUILD_INSTALL_ARGS=--install-lib=/usr/share/revpicommander/ \ # in the setup.py script. If you want to install this python module as an
# --install-scripts=/usr/share/revpicommander/ # application and not in the python standard library directory, you will need
# # to use this script for /usr/bin.
# In that case the entry point will not find the revpicommander module in
# the python lib.
exec "/usr/share/revpicommander/revpicommander-gui" "$@" exec python3 /usr/share/revpicommander/revpicommander "$@"

106
debian/changelog vendored Normal file
View File

@@ -0,0 +1,106 @@
revpicommander (0.10.0-3) stable; urgency=medium
* packaging: Remove unused GPL-3+ section from copyright file
* packaging(patch): Change entry point name in setup.py
* packaging: Use patched entry point and link it to /usr/bin
-- Sven Sager <akira@narux.de> Mon, 18 Sep 2023 07:05:35 +0200
revpicommander (0.10.0-2) stable; urgency=medium
[ Sven Sager ]
* Renamed version of revpipycontrol written with Qt framework
* Replace widget search to widget directory (performance)
* Replace widget search to widget dict (performance)
* WIP: GUI and base function from revpidevelop
* Bugfix: PyInstaller script
* Save IP address, not hostname of avahisearch.py found RevPi
(Windows will not resolve)
* WIP: revpifiles.py has all functions for PyLoad 0.9.2
* revpifiles.py is ready with PyLoad 0.9.3 functions
* files.ui Design change, cleanup
* String fields (> 4 Bytes) can be switched to numbers
* Load and display logfiles block by block
* Add option for software watchdog and driver reset action
* Destroy changed IOs after piCtory changes
* UI Text check and translation-de
* Bugfixes - IP regex, Queue handling, file upload
* UI Text check and translation-de
* Bugfix: Load locales file
* Remove included revpimodio2 static link and add it as requires
* New release
* Get AVAHI IPv4 addresses with service_info
* Bugfix for translations strings and format function
* Add parameter to change connection timeout (default was and
is 5 seconds)
* Add a simulator dialog to manage simulator settings
* Bugfix for simulator to prevent GUI crash after first use
* Modified translations
* New release
* Add upload progress display in developer, bugfix on file download in
developer
* Fix error on decoding broken log files
* Fix crash during add new connection
* Reduce max block to load for log files on slow networks
* Improved RevPi search window
* New release
* Fix error in debugios.py with long byte values
* Bugfix: RevPi simulator could not be startet without existing
proc.img file
* Design things: enable HighDpi, dependency versions, icon text
* Add Windows files for pyinstaller and setup generation
* Fix qt parents of menu entries in connections
* Improved shortcuts to meet the needs of different operating systems
* Implement update function of ZeroConf ServiceListener
* Redesign main window with text boxes to copy host name or ip
* Add translation of status codes
* Bugfix: could not open debugcontrol, because of new layout names
* Add context menu with copy and piCtory actions to revpi search dialog
* Switch project so src layout
* Switch to setuptools for setup.py
* Add icons to commander main window for start, stop and so on
* Update Makefile and requirements.txt for build and clean ui files
* Add PyInstaller script for Windows
* QTranslator uses ui_languages to find translation
* Use cm.call_remote_function to fetch log files via XML-RPC
* Prepare SSH tunnel server and password GUI
* Configure and start ssh tunneled connections
* Choose connection type (ssh or xml-rpc) in avahisearch dialog
* Update Makefile rules
* Update translation file
* Update Windows setup script to match pyinstaller output
* Manage revolution pi saved settings in an own class
* Change most button pressed event to clicked and add global shortcuts
* Set the use of ssh tunnel to default value for new settings
* Save SSH credentials with keyring module
* Show just the hostname without .local in avahisearch.py list
* Bugfix for new settings management
* Clean up keyring when a connection is deleted
* Move version number from revpicommander.py to __init__.py
* New async connection management with user feedback
* Connection list with add folder button and removed naming bug
* Move version number from __init__.py to __main__.py
* Adjustments for creating installations on various operating systems
* Bugfix: Add missing packages to install_requires
* Add option to switch word order on debugios
* Add pyinstaller option for linux platform
* Bugfix type hinting, PyLoad version handling, piCtory browser
* Update translation and messages
* Change license from GPLv3 to GPLv2 after approval of all contributors
* Replaces Master-Slave with Client-Server
* Bugfix in super call of backgroundworker.py
* Ignore ssh known_hosts from home directory, use own
* build: Use system python interpreter in make file
* fix: Show program dialog, even if there are no files on the RevPi
* chore: Release 0.10.0rc1
* fix: PLC monitor crashes when a device has no inputs or outputs
* build: Add environment variable to set alternative venv path
* feat: SSH tunnel server extended to execute commands on remote host.
* build: Use python interpreter and modules for qt commands in Makefile
* feat: Try to start RevPiPyLoad via SSH on the Revolution Pi
* fix: Simulator always sets process image to NULL
* build: Fix Makefile targets to match GNU coding standards
* chore: Release 0.10.0
* packaging(deb): Start packaging branch
-- Sven Sager <s.sager@kunbus.com> Sat, 16 Sep 2023 14:10:12 +0200

32
debian/control vendored Normal file
View File

@@ -0,0 +1,32 @@
Source: revpicommander
Section: x11
Priority: optional
Maintainer: Sven Sager <akira@narux.de>
Rules-Requires-Root: no
Homepage: https://revpimodio.org/revpipyplc/
Vcs-Browser: https://github.com/narux/revpicommander
Vcs-Git: https://github.com/narux/revpicommander.git
Build-Depends:
debhelper-compat (= 12),
dh-python,
python3-all,
python3-keyring (>= 17.1.1),
python3-pyqt5,
python3-paramiko (>= 2.4.2),
python3-revpimodio2 (>= 2.5.6),
python3-zeroconf (>= 0.24.4),
python3-setuptools,
python3-wheel
Standards-Version: 4.3.0
Package: revpicommander
Architecture: all
Depends:
${python3:Depends},
${misc:Depends}
Description: GUI for Revolution Pi to upload programs and do IO-Checks
The RevPiCommander is a GUI tool to manage your revolution Pi over the
network. You can search for RevPis in your network, manage the settings
of RevPiPyLoad and do IO checks on your local machine. Developing your
control program is very easy with the developer, upload and debug it
over the network.

29
debian/copyright vendored Normal file
View File

@@ -0,0 +1,29 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Source: https://github.com/naruxde/revpicommander
Upstream-Name: revpicommander
Upstream-Contact: Sven Sager <akira@narux.de>
Files: *
Copyright: 2017-2023 Sven Sager
License: GPL-2+
Files: debian/*
Copyright: 2021-2023 KUNBUS GmbH
License: GPL-2+
License: GPL-2+
This package is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>
.
On Debian systems, the complete text of the GNU General
Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".

4
debian/gbp.conf vendored Normal file
View File

@@ -0,0 +1,4 @@
[DEFAULT]
upstream-branch = main
upstream-tag = %(version)s
debian-branch=pkg/debian

2
debian/install vendored Normal file
View File

@@ -0,0 +1,2 @@
data/revpicommander.desktop /usr/share/applications
data/revpicommander.png /usr/share/icons/hicolor/128x128/apps

1
debian/links vendored Normal file
View File

@@ -0,0 +1 @@
/usr/share/revpicommander/revpicommander_entry_point /usr/bin/revpicommander

View File

@@ -0,0 +1,24 @@
From: Sven Sager <akira@narux.de>
Date: Mon, 18 Sep 2023 06:49:44 +0200
Subject: Change entry point name to differ from the module name
In the package, the module and its scripts are installed in the same
directory. This is done via PYBUILD_INSTALL_ARGS and --install-lib,
--install-scripts. Module name and script name must not be the same.
---
setup.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/setup.py b/setup.py
index 227874b..8b2acab 100644
--- a/setup.py
+++ b/setup.py
@@ -25,7 +25,7 @@ setup(
],
entry_points={
'gui_scripts': [
- 'revpicommander = revpicommander.revpicommander:main',
+ 'revpicommander_entry_point = revpicommander.revpicommander:main',
],
},

1
debian/patches/series vendored Normal file
View File

@@ -0,0 +1 @@
0001-Change-entry-point-name-to-differ-from-the-module-na.patch

1
debian/py3dist-overrides vendored Normal file
View File

@@ -0,0 +1 @@
pyqt5 python3-pyqt5

9
debian/rules vendored Executable file
View File

@@ -0,0 +1,9 @@
#!/usr/bin/make -f
export PYBUILD_NAME=revpicommander
# Install this module as an application an not into the python standard library path
export PYBUILD_INSTALL_ARGS=--install-lib=/usr/share/revpicommander/ --install-scripts=/usr/share/revpicommander/
%:
dh $@ --with python3 --buildsystem=pybuild

1
debian/source/format vendored Normal file
View File

@@ -0,0 +1 @@
3.0 (quilt)

View File

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

View File

@@ -25,7 +25,7 @@ setup(
], ],
entry_points={ entry_points={
'gui_scripts': [ 'gui_scripts': [
'revpicommander-gui = revpicommander.revpicommander:main', 'revpicommander = revpicommander.revpicommander:main',
], ],
}, },

View File

@@ -4,4 +4,4 @@ __author__ = "Sven Sager"
__copyright__ = "Copyright (C) 2023 Sven Sager" __copyright__ = "Copyright (C) 2023 Sven Sager"
__license__ = "GPLv2" __license__ = "GPLv2"
__package__ = "revpicommander" __package__ = "revpicommander"
__version__ = "0.9.10rc7" __version__ = "0.10.0"

View File

@@ -38,9 +38,7 @@ class DebugIos(QtWidgets.QMainWindow, Ui_win_debugios):
self.outputs = outputs.copy() self.outputs = outputs.copy()
self.write_values = False self.write_values = False
min_input = min(inputs, key=lambda k: k[2]) self.length = self._calc_device_length(self.inputs, self.outputs)
max_output = max(outputs, key=lambda k: k[2])
self.length = max_output[2] + max_output[1] - min_input[2]
self.style_sheet = "" self.style_sheet = ""
self._create_io(self.inputs, self.saw_inp, True) self._create_io(self.inputs, self.saw_inp, True)
@@ -62,6 +60,23 @@ class DebugIos(QtWidgets.QMainWindow, Ui_win_debugios):
return max_int_value / 2 * -1 if signed else 0.0, \ return max_int_value / 2 * -1 if signed else 0.0, \
max_int_value / 2 - 1 if signed else max_int_value - 1 max_int_value / 2 - 1 if signed else max_int_value - 1
@staticmethod
def _calc_device_length(inputs: list, outputs: list) -> int:
"""Calculate the device length with IO data."""
if inputs and outputs:
min_input = min(inputs, key=lambda k: k[2])
max_output = max(outputs, key=lambda k: k[2])
elif inputs:
min_input = min(inputs, key=lambda k: k[2])
max_output = max(inputs, key=lambda k: k[2])
elif outputs:
min_input = min(outputs, key=lambda k: k[2])
max_output = max(outputs, key=lambda k: k[2])
else:
return 0
return max_output[2] + max_output[1] - min_input[2]
def _create_io(self, lst_ios: list, container: QtWidgets.QWidget, read_only: bool): def _create_io(self, lst_ios: list, container: QtWidgets.QWidget, read_only: bool):
lst_names = list(lst[0] for lst in lst_ios) lst_names = list(lst[0] for lst in lst_ios)
layout = container.layout() # type: QtWidgets.QFormLayout layout = container.layout() # type: QtWidgets.QFormLayout
@@ -293,10 +308,7 @@ class DebugIos(QtWidgets.QMainWindow, Ui_win_debugios):
"""Update IOs after driver reset of piCtory.""" """Update IOs after driver reset of piCtory."""
# Check device length, this has to match to reuse this device # Check device length, this has to match to reuse this device
min_input = min(inputs, key=lambda k: k[2]) if self.length != self._calc_device_length(inputs, outputs):
max_output = max(outputs, key=lambda k: k[2])
new_length = max_output[2] + max_output[1] - min_input[2]
if self.length != new_length:
return False return False
# Remove IOs, which was remove or renamed # Remove IOs, which was remove or renamed

View File

@@ -33,6 +33,7 @@ class ConnectionFail(IntEnum):
NO_XML_RPC = 1 NO_XML_RPC = 1
SSH_CONNECT = 2 SSH_CONNECT = 2
SSH_AUTH = 4 SSH_AUTH = 4
NO_XML_RPC_VIA_TUNNEL = 9 # Includes NO_XML_RPC Bit
class WidgetData(IntEnum): class WidgetData(IntEnum):
@@ -347,6 +348,10 @@ class ConnectionManager(QtCore.QThread):
) )
try: try:
ssh_tunnel_port = ssh_tunnel_server.connect_by_credentials(revpi_settings.ssh_user, ssh_pass) ssh_tunnel_port = ssh_tunnel_server.connect_by_credentials(revpi_settings.ssh_user, ssh_pass)
if getattr(revpi_settings, "ssh_enable_revpipyload", False):
ssh_tunnel_server.send_cmd("sudo systemctl enable --now revpipyload")
except AuthenticationException: except AuthenticationException:
self.connect_error.emit( self.connect_error.emit(
self.tr("Error"), self.tr( self.tr("Error"), self.tr(
@@ -394,7 +399,7 @@ class ConnectionManager(QtCore.QThread):
"- The RevPiPyLoad XML-RPC service is NOT bind to localhost\n" "- The RevPiPyLoad XML-RPC service is NOT bind to localhost\n"
"- The ACL permission is not set for 127.0.0.1!!!" "- The ACL permission is not set for 127.0.0.1!!!"
), ),
ConnectionFail.NO_XML_RPC, ConnectionFail.NO_XML_RPC_VIA_TUNNEL,
revpi_settings, revpi_settings,
) )
else: else:
@@ -471,7 +476,13 @@ class ConnectionManager(QtCore.QThread):
self.connection_disconnected.emit() self.connection_disconnected.emit()
def pyload_simulate(self, configrsc: str, procimg: str, clean_existing: bool): def pyload_simulate(self, configrsc: str, procimg: str, clean_existing: bool):
"""Start the simulator for piControl on local computer.""" """
Start the simulator for piControl on local computer.
:param configrsc: piCtory configuration
:param procimg: Process image, which is a 4 kByte file for simulation
:param clean_existing: Reset the file to ZERO \x00 bytes
"""
pi.logger.debug("ConnectionManager.start_simulate") pi.logger.debug("ConnectionManager.start_simulate")
if not exists(procimg) or clean_existing: if not exists(procimg) or clean_existing:

View File

@@ -229,62 +229,62 @@ Wurde eine Hardwarekonfiguration in piCtory erzeugt?</translation>
<context> <context>
<name>ConnectionManager</name> <name>ConnectionManager</name>
<message> <message>
<location filename="../helper.py" line="533"/> <location filename="../helper.py" line="538"/>
<source>SIMULATING</source> <source>SIMULATING</source>
<translation>SIMULATION</translation> <translation>SIMULATION</translation>
</message> </message>
<message> <message>
<location filename="../helper.py" line="536"/> <location filename="../helper.py" line="541"/>
<source>NOT CONNECTED</source> <source>NOT CONNECTED</source>
<translation>NICHT VERBUNDEN</translation> <translation>NICHT VERBUNDEN</translation>
</message> </message>
<message> <message>
<location filename="../helper.py" line="553"/> <location filename="../helper.py" line="558"/>
<source>SERVER ERROR</source> <source>SERVER ERROR</source>
<translation>SERVER FEHLER</translation> <translation>SERVER FEHLER</translation>
</message> </message>
<message> <message>
<location filename="../helper.py" line="578"/> <location filename="../helper.py" line="583"/>
<source>RUNNING</source> <source>RUNNING</source>
<translation>LÄUFT</translation> <translation>LÄUFT</translation>
</message> </message>
<message> <message>
<location filename="../helper.py" line="580"/> <location filename="../helper.py" line="585"/>
<source>PLC FILE NOT FOUND</source> <source>PLC FILE NOT FOUND</source>
<translation>SPS PROGRAMM NICHT GEFUNDEN</translation> <translation>SPS PROGRAMM NICHT GEFUNDEN</translation>
</message> </message>
<message> <message>
<location filename="../helper.py" line="582"/> <location filename="../helper.py" line="587"/>
<source>NOT RUNNING (NO STATUS)</source> <source>NOT RUNNING (NO STATUS)</source>
<translation>LÄUFT NICHT (KEIN STATUS)</translation> <translation>LÄUFT NICHT (KEIN STATUS)</translation>
</message> </message>
<message> <message>
<location filename="../helper.py" line="584"/> <location filename="../helper.py" line="589"/>
<source>PROGRAM KILLED</source> <source>PROGRAM KILLED</source>
<translation>PROGRAMM GETÖTET</translation> <translation>PROGRAMM GETÖTET</translation>
</message> </message>
<message> <message>
<location filename="../helper.py" line="586"/> <location filename="../helper.py" line="591"/>
<source>PROGRAM TERMED</source> <source>PROGRAM TERMED</source>
<translation>PROGRAMM BEENDET</translation> <translation>PROGRAMM BEENDET</translation>
</message> </message>
<message> <message>
<location filename="../helper.py" line="588"/> <location filename="../helper.py" line="593"/>
<source>NOT RUNNING</source> <source>NOT RUNNING</source>
<translation>LÄUFT NICHT</translation> <translation>LÄUFT NICHT</translation>
</message> </message>
<message> <message>
<location filename="../helper.py" line="590"/> <location filename="../helper.py" line="595"/>
<source>FINISHED WITH CODE {0}</source> <source>FINISHED WITH CODE {0}</source>
<translation>BEENDET MIT CODE {0}</translation> <translation>BEENDET MIT CODE {0}</translation>
</message> </message>
<message> <message>
<location filename="../helper.py" line="401"/> <location filename="../helper.py" line="406"/>
<source>Error</source> <source>Error</source>
<translation>Fehler</translation> <translation>Fehler</translation>
</message> </message>
<message> <message>
<location filename="../helper.py" line="351"/> <location filename="../helper.py" line="356"/>
<source>The combination of username and password was rejected from the SSH server. <source>The combination of username and password was rejected from the SSH server.
Try again.</source> Try again.</source>
@@ -293,7 +293,7 @@ Try again.</source>
Bitte erneut versuchen.</translation> Bitte erneut versuchen.</translation>
</message> </message>
<message> <message>
<location filename="../helper.py" line="363"/> <location filename="../helper.py" line="368"/>
<source>Could not establish a SSH connection to server: <source>Could not establish a SSH connection to server:
{0}</source> {0}</source>
@@ -352,7 +352,7 @@ Das kann eine der folgenden Ursachen haben:
Benutze &quot;Über SSH verbinden&quot; um eine verschlüsselte Verbindung aufzubauen oder führe &apos;sudo revpipyload_secure_installation&apos; auf dem Revolution Pi aus, um eine direkte Verbindung zu konfigurieren!</translation> Benutze &quot;Über SSH verbinden&quot; um eine verschlüsselte Verbindung aufzubauen oder führe &apos;sudo revpipyload_secure_installation&apos; auf dem Revolution Pi aus, um eine direkte Verbindung zu konfigurieren!</translation>
</message> </message>
<message> <message>
<location filename="../helper.py" line="401"/> <location filename="../helper.py" line="406"/>
<source>Can not connect to RevPiPyLoad XML-RPC service! <source>Can not connect to RevPiPyLoad XML-RPC service!
This could have the following reasons: This could have the following reasons:
@@ -373,7 +373,7 @@ Das kann eine der folgenden Ursachen haben:
Benutze &quot;Über SSH verbinden&quot; um eine verschlüsselte Verbindung aufzubauen oder führe &apos;sudo revpipyload_secure_installation&apos; auf dem Revolution Pi aus, um eine direkte Verbindung zu konfigurieren!</translation> Benutze &quot;Über SSH verbinden&quot; um eine verschlüsselte Verbindung aufzubauen oder führe &apos;sudo revpipyload_secure_installation&apos; auf dem Revolution Pi aus, um eine direkte Verbindung zu konfigurieren!</translation>
</message> </message>
<message> <message>
<location filename="../helper.py" line="389"/> <location filename="../helper.py" line="394"/>
<source>Can not connect to RevPiPyLoad service through SSH tunnel! <source>Can not connect to RevPiPyLoad service through SSH tunnel!
This could have the following reasons: This could have the following reasons:
@@ -426,37 +426,37 @@ Das kann eine der folgenden Ursachen haben:
<context> <context>
<name>DebugIos</name> <name>DebugIos</name>
<message> <message>
<location filename="../debugios.py" line="213"/> <location filename="../debugios.py" line="228"/>
<source>signed</source> <source>signed</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../debugios.py" line="218"/> <location filename="../debugios.py" line="233"/>
<source>big_endian</source> <source>big_endian</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../debugios.py" line="204"/> <location filename="../debugios.py" line="219"/>
<source>as text</source> <source>as text</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../debugios.py" line="206"/> <location filename="../debugios.py" line="221"/>
<source>as number</source> <source>as number</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../debugios.py" line="365"/> <location filename="../debugios.py" line="377"/>
<source>Can not use format text</source> <source>Can not use format text</source>
<translation>Formatierung nicht möglich</translation> <translation>Formatierung nicht möglich</translation>
</message> </message>
<message> <message>
<location filename="../debugios.py" line="365"/> <location filename="../debugios.py" line="377"/>
<source>Can not convert bytes {0} to a text for IO &apos;{1}&apos;. Switch to number format instead!</source> <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> <translation>Kann bytes {0} für &apos;{1}&apos; nicht in Text konvertieren. Wechseln Sie auf Nummernformat!</translation>
</message> </message>
<message> <message>
<location filename="../debugios.py" line="224"/> <location filename="../debugios.py" line="239"/>
<source>switch wordorder</source> <source>switch wordorder</source>
<translation>Wordorder tauschen</translation> <translation>Wordorder tauschen</translation>
</message> </message>
@@ -489,86 +489,86 @@ Ungesicherte Änderungen gehen verloren.</translation>
<context> <context>
<name>RevPiCommander</name> <name>RevPiCommander</name>
<message> <message>
<location filename="../revpicommander.py" line="308"/> <location filename="../revpicommander.py" line="320"/>
<source>Simulator started...</source> <source>Simulator started...</source>
<translation>Simulator gestartet...</translation> <translation>Simulator gestartet...</translation>
</message> </message>
<message> <message>
<location filename="../revpicommander.py" line="317"/> <location filename="../revpicommander.py" line="329"/>
<source>Can not start...</source> <source>Can not start...</source>
<translation>Kann nicht gestartet werden...</translation> <translation>Kann nicht gestartet werden...</translation>
</message> </message>
<message> <message>
<location filename="../revpicommander.py" line="510"/> <location filename="../revpicommander.py" line="522"/>
<source>Warning</source> <source>Warning</source>
<translation>Warnung</translation> <translation>Warnung</translation>
</message> </message>
<message> <message>
<location filename="../revpicommander.py" line="333"/> <location filename="../revpicommander.py" line="345"/>
<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> <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> <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>
<message> <message>
<location filename="../revpicommander.py" line="383"/> <location filename="../revpicommander.py" line="395"/>
<source>XML-RPC access mode in the RevPiPyLoad configuration is too small to access this dialog!</source> <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> <translation>XML-RPC Zugriffsberechtigung in der RevPiPyLoad Konfiguraiton ist zu klein für diese Einstellungen!</translation>
</message> </message>
<message> <message>
<location filename="../revpicommander.py" line="537"/> <location filename="../revpicommander.py" line="549"/>
<source>Error</source> <source>Error</source>
<translation>Fehler</translation> <translation>Fehler</translation>
</message> </message>
<message> <message>
<location filename="../revpicommander.py" line="363"/> <location filename="../revpicommander.py" line="375"/>
<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> <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> <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>
<message> <message>
<location filename="../revpicommander.py" line="416"/> <location filename="../revpicommander.py" line="428"/>
<source>Question</source> <source>Question</source>
<translation>Frage</translation> <translation>Frage</translation>
</message> </message>
<message> <message>
<location filename="../revpicommander.py" line="416"/> <location filename="../revpicommander.py" line="428"/>
<source>Are you sure to reset piControl? <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> 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? <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> 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>
<message> <message>
<location filename="../revpicommander.py" line="429"/> <location filename="../revpicommander.py" line="441"/>
<source>Success</source> <source>Success</source>
<translation>Erfolgreich</translation> <translation>Erfolgreich</translation>
</message> </message>
<message> <message>
<location filename="../revpicommander.py" line="429"/> <location filename="../revpicommander.py" line="441"/>
<source>piControl reset executed successfully</source> <source>piControl reset executed successfully</source>
<translation>piControl wurde erfolgreich zurückgesetzt</translation> <translation>piControl wurde erfolgreich zurückgesetzt</translation>
</message> </message>
<message> <message>
<location filename="../revpicommander.py" line="436"/> <location filename="../revpicommander.py" line="448"/>
<source>piControl reset could not be executed successfully</source> <source>piControl reset could not be executed successfully</source>
<translation>piControl konnte nicht zurückgesetzt werden</translation> <translation>piControl konnte nicht zurückgesetzt werden</translation>
</message> </message>
<message> <message>
<location filename="../revpicommander.py" line="484"/> <location filename="../revpicommander.py" line="496"/>
<source>Reset to piCtory defaults...</source> <source>Reset to piCtory defaults...</source>
<translation>Standardwerte von piCtory laden...</translation> <translation>Standardwerte von piCtory laden...</translation>
</message> </message>
<message> <message>
<location filename="../revpicommander.py" line="510"/> <location filename="../revpicommander.py" line="522"/>
<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> <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> <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>
<message> <message>
<location filename="../revpicommander.py" line="522"/> <location filename="../revpicommander.py" line="534"/>
<source>Can not load this function, because your ACL level is to low! <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> You need at least level 1 to read or level 3 to write.</source>
<translation>Für diese Funktion ist das Berechtigungslevel zu gering! <translation>Für diese Funktion ist das Berechtigungslevel zu gering!
Es muss mindestens Level 1 zum Lesen oder Level 3 zu Schreiben sein.</translation> Es muss mindestens Level 1 zum Lesen oder Level 3 zu Schreiben sein.</translation>
</message> </message>
<message> <message>
<location filename="../revpicommander.py" line="537"/> <location filename="../revpicommander.py" line="549"/>
<source>Can not load piCtory configuration. <source>Can not load piCtory configuration.
Did you create a hardware configuration? Please check this in piCtory!</source> Did you create a hardware configuration? Please check this in piCtory!</source>
<translation>Kann piCtory Konfiguration nicht laden. <translation>Kann piCtory Konfiguration nicht laden.
@@ -588,7 +588,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> Führe &apos;sudo revpipyload_secure_installation&apos; auf dem Revolution Pi aus um diese Funktion zu konfigurieren!</translation>
</message> </message>
<message> <message>
<location filename="../revpicommander.py" line="308"/> <location filename="../revpicommander.py" line="320"/>
<source>The simulator is running! <source>The simulator is running!
You can work with this simulator if your call RevPiModIO with this additional parameters: You can work with this simulator if your call RevPiModIO with this additional parameters:
@@ -605,42 +605,65 @@ configrsc={1}
Dies kann aus der Textbox oben kopiert werden.</translation> Dies kann aus der Textbox oben kopiert werden.</translation>
</message> </message>
<message> <message>
<location filename="../revpicommander.py" line="317"/> <location filename="../revpicommander.py" line="329"/>
<source>Can not start the simulator! Maybe the piCtory file is corrupt or you have no write permissions for &apos;{0}&apos;.</source> <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}&apos;.</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>
<message> <message>
<location filename="../revpicommander.py" line="484"/> <location filename="../revpicommander.py" line="496"/>
<source>Do you want to reset your process image to {0} values? <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> 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? <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> Es sollten alle RevPiModIO Programme vorher beendet werden, da diese ihre IO Werte sofort wieder schreiben würden.</translation>
</message> </message>
<message> <message>
<location filename="../revpicommander.py" line="484"/> <location filename="../revpicommander.py" line="496"/>
<source>zero</source> <source>zero</source>
<translation>null</translation> <translation>null</translation>
</message> </message>
<message> <message>
<location filename="../revpicommander.py" line="484"/> <location filename="../revpicommander.py" line="496"/>
<source>piCtory default</source> <source>piCtory default</source>
<translation>piCtory Standardwerte</translation> <translation>piCtory Standardwerte</translation>
</message> </message>
<message> <message>
<location filename="../revpicommander.py" line="238"/> <location filename="../revpicommander.py" line="250"/>
<source>Revolution Pi connected!</source> <source>Revolution Pi connected!</source>
<translation>Revolution Pi verbunden!</translation> <translation>Revolution Pi verbunden!</translation>
</message> </message>
<message> <message>
<location filename="../revpicommander.py" line="275"/> <location filename="../revpicommander.py" line="287"/>
<source>Connecting...</source> <source>Connecting...</source>
<translation>Verbinde...</translation> <translation>Verbinde...</translation>
</message> </message>
<message> <message>
<location filename="../revpicommander.py" line="238"/> <location filename="../revpicommander.py" line="250"/>
<source>Establish a connection to the Revolution Pi...</source> <source>Establish a connection to the Revolution Pi...</source>
<translation>Baue eine Verbindung zum Revolution Pi auf...</translation> <translation>Baue eine Verbindung zum Revolution Pi auf...</translation>
</message> </message>
<message>
<location filename="../revpicommander.py" line="133"/>
<source>Can not connect to RevPiPyLoad service through SSH tunnel!
We are trying to activate this service now and reconnect. The settings can be changed at any time via web status.</source>
<translation type="obsolete">Über den SSH Tunnel kann keine Verbindung zu RevPiPyLoad hergestellt werden!
Wir werden versuchen den Dienst zu starten und eine neue Verbindung herzustellen. Diese Einstellung kann im Webstatus geändert werden.</translation>
</message>
<message>
<location filename="../revpicommander.py" line="133"/>
<source>Information</source>
<translation>Information</translation>
</message>
<message>
<location filename="../revpicommander.py" line="133"/>
<source>Can not connect to RevPiPyLoad service through SSH tunnel!
We are trying to activate this service now and reconnect. The settings can be changed at any time via &apos;webstatus&apos;.</source>
<translation>Vielleicht läuft der RevPiPyLoad Dienst nicht.
Wir versuchen diesen Dienst jetzt zu aktivieren und verbinden uns neu. Die Einstellungen können über &apos;Webstatus&apos; jederzeit geändert werden.</translation>
</message>
</context> </context>
<context> <context>
<name>RevPiFiles</name> <name>RevPiFiles</name>
@@ -1216,12 +1239,12 @@ Dies ist kein Fehler von RevPi Commander.</translation>
<context> <context>
<name>Simulator</name> <name>Simulator</name>
<message> <message>
<location filename="../simulator.py" line="79"/> <location filename="../simulator.py" line="80"/>
<source>Select downloaded piCtory file...</source> <source>Select downloaded piCtory file...</source>
<translation>Heruntergeladene piCtory Datei auswählen...</translation> <translation>Heruntergeladene piCtory Datei auswählen...</translation>
</message> </message>
<message> <message>
<location filename="../simulator.py" line="79"/> <location filename="../simulator.py" line="80"/>
<source>piCtory file (*.rsc);;All files (*.*)</source> <source>piCtory file (*.rsc);;All files (*.*)</source>
<translation>piCtory Datei (*.rsc);;Alle Dateien (*.*)</translation> <translation>piCtory Datei (*.rsc);;Alle Dateien (*.*)</translation>
</message> </message>

View File

@@ -128,10 +128,22 @@ class RevPiCommander(QtWidgets.QMainWindow, Ui_win_revpicommander):
:param fail_code: Type of error :param fail_code: Type of error
:param revpi_settings: Settings of the revpi with the error :param revpi_settings: Settings of the revpi with the error
""" """
QtWidgets.QMessageBox.critical(self, title, text) if fail_code is ConnectionFail.NO_XML_RPC_VIA_TUNNEL:
if fail_code is ConnectionFail.SSH_AUTH: # If RevPiPyLoad is not running, we can try to activate it via ssh
# On failed credentials, we try to connect again and remove password form keychain, if exists QtWidgets.QMessageBox.information(
self._pyload_connect(revpi_settings, True) self, self.tr("Information"), self.tr(
"Can not connect to RevPiPyLoad service through SSH tunnel!\n\n"
"We are trying to activate this service now and reconnect. The settings can be "
"changed at any time via 'webstatus'."
),
)
revpi_settings.ssh_enable_revpipyload = True
self._pyload_connect(revpi_settings, False)
else:
QtWidgets.QMessageBox.critical(self, title, text)
if fail_code is ConnectionFail.SSH_AUTH:
# On failed credentials, we try to connect again and remove password form keychain, if exists
self._pyload_connect(revpi_settings, True)
@QtCore.pyqtSlot(str) @QtCore.pyqtSlot(str)
def on_cm_connection_error_observed(self, message: str): def on_cm_connection_error_observed(self, message: str):
@@ -304,7 +316,7 @@ class RevPiCommander(QtWidgets.QMainWindow, Ui_win_revpicommander):
configrsc_file = helper.settings.value("simulator/configrsc", "", str) configrsc_file = helper.settings.value("simulator/configrsc", "", str)
procimg_file = helper.settings.value("simulator/procimg", "", str) procimg_file = helper.settings.value("simulator/procimg", "", str)
if helper.cm.pyload_simulate(configrsc_file, procimg_file, diag.cbx_stop_remove.isChecked()): if helper.cm.pyload_simulate(configrsc_file, procimg_file, diag.clean_procimg):
QtWidgets.QMessageBox.information( QtWidgets.QMessageBox.information(
self, self.tr("Simulator started..."), self.tr( self, self.tr("Simulator started..."), self.tr(
"The simulator is running!\n\nYou can work with this simulator if your call " "The simulator is running!\n\nYou can work with this simulator if your call "

View File

@@ -167,8 +167,8 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
return QtWidgets.QDialog.Rejected return QtWidgets.QDialog.Rejected
self.dc = helper.cm.call_remote_function("get_config", default_value={}) self.dc = helper.cm.call_remote_function("get_config", default_value={})
self.lst_files = helper.cm.call_remote_function("get_filelist", default_value=[]) self.lst_files = helper.cm.call_remote_function("get_filelist", default_value=None)
if len(self.dc) == 0 or len(self.lst_files) == 0: if len(self.dc) == 0 or self.lst_files is None:
return QtWidgets.QDialog.Rejected return QtWidgets.QDialog.Rejected
self._load_settings() self._load_settings()

View File

@@ -10,14 +10,18 @@ __copyright__ = "Copyright (C) 2023 Sven Sager"
__license__ = "GPLv2" __license__ = "GPLv2"
import select import select
from logging import getLogger
from socketserver import BaseRequestHandler, ThreadingTCPServer from socketserver import BaseRequestHandler, ThreadingTCPServer
from threading import Thread from threading import Thread
from typing import Tuple, Union
from paramiko.client import MissingHostKeyPolicy, SSHClient from paramiko.client import MissingHostKeyPolicy, SSHClient
from paramiko.rsakey import RSAKey from paramiko.rsakey import RSAKey
from paramiko.ssh_exception import PasswordRequiredException from paramiko.ssh_exception import PasswordRequiredException
from paramiko.transport import Transport from paramiko.transport import Transport
log = getLogger("ssh_tunneling")
class ForwardServer(ThreadingTCPServer): class ForwardServer(ThreadingTCPServer):
daemon_threads = True daemon_threads = True
@@ -33,10 +37,14 @@ class Handler(BaseRequestHandler):
self.request.getpeername(), self.request.getpeername(),
) )
except Exception as e: except Exception as e:
log.error(e)
return return
if chan is None: if chan is None:
log.error("Could not create a ssh channel")
return return
log.info("Starting tunnel exchange loop")
while True: while True:
r, w, x = select.select([self.request, chan], [], [], 5.0) r, w, x = select.select([self.request, chan], [], [], 5.0)
if self.request in r: if self.request in r:
@@ -50,6 +58,8 @@ class Handler(BaseRequestHandler):
break break
self.request.send(data) self.request.send(data)
log.info("Stopped tunnel exchange loop")
chan.close() chan.close()
self.request.close() self.request.close()
@@ -162,6 +172,30 @@ class SSHLocalTunnel:
return True return True
return False return False
def send_cmd(self, cmd: str, timeout: float = None) -> Union[Tuple[str, str], Tuple[None, None]]:
"""
Send simple command to ssh host.
The output of stdout and stderr is returned as a tuple of two elements.
This elements could be None, in case of an internal error.
:param cmd: Shell command to execute on remote host
:param timeout: Timeout for execution
:return: Tuple with stdout and stderr
"""
if not self._th_server.is_alive():
raise RuntimeError("Not connected")
try:
_, stdout, stderr = self._ssh_client.exec_command(cmd, 1024, timeout)
buffer_out = stdout.read()
buffer_err = stderr.read()
return buffer_out.decode(), buffer_err.decode()
except Exception as e:
log.error(e)
return None, None
@property @property
def connected(self): def connected(self):
"""Check connection state of ssh tunnel.""" """Check connection state of ssh tunnel."""