mirror of
https://github.com/naruxde/revpicommander.git
synced 2025-11-09 17:08:05 +01:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9202aedf7f | |||
| 8e2b8311ef | |||
| 15058feb7e | |||
| d14b6dccdd | |||
| feb55fe2b5 | |||
| b36e27a7f2 | |||
| 5488e7cc81 | |||
| 8790e508ad | |||
| 7a7741e60b | |||
| 2039f6cfe2 | |||
| 1e8200cc55 | |||
| 98b4879b7f |
1
.idea/revpicommander.iml
generated
1
.idea/revpicommander.iml
generated
@@ -4,6 +4,7 @@
|
|||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||||
|
<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.9 (revpicommander)" jdkType="Python SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
|||||||
@@ -2,12 +2,11 @@ recursive-include data *
|
|||||||
recursive-include src/revpicommander *.py *.qm
|
recursive-include src/revpicommander *.py *.qm
|
||||||
recursive-include ui_dev *
|
recursive-include ui_dev *
|
||||||
include LICENSE.txt
|
include LICENSE.txt
|
||||||
include make_installer_win.bat
|
include make.bat
|
||||||
include Makefile
|
include Makefile
|
||||||
include MANIFEST.in
|
include MANIFEST.in
|
||||||
include README.md
|
include README.md
|
||||||
include requirements.txt
|
include requirements.txt
|
||||||
include setup.iss
|
include setup.iss
|
||||||
include setup.py
|
include setup.py
|
||||||
include stdeb.cfg
|
|
||||||
include translate.pro
|
include translate.pro
|
||||||
|
|||||||
63
Makefile
63
Makefile
@@ -4,9 +4,12 @@ MAKEFLAGS = --no-print-directory --no-builtin-rules
|
|||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
PACKAGE = revpicommander
|
PACKAGE = revpicommander
|
||||||
|
APP_NAME = RevPi\ Commander
|
||||||
|
APP_IDENT = org.revpimodio.revpicommander
|
||||||
|
APPLE_SIG = "Developer ID Application: Sven Sager (U3N5843D9K)"
|
||||||
|
|
||||||
# If virtualenv exists, use it. If not, use PATH to find
|
# If virtualenv exists, use it. If not, use PATH to find, except python3
|
||||||
SYSTEM_PYTHON = $(or $(shell which python3), $(shell which python))
|
SYSTEM_PYTHON = /usr/bin/python3
|
||||||
PYTHON = $(or $(wildcard venv/bin/python), $(SYSTEM_PYTHON))
|
PYTHON = $(or $(wildcard venv/bin/python), $(SYSTEM_PYTHON))
|
||||||
SYSTEM_PYUIC5 = $(shell which pyuic5)
|
SYSTEM_PYUIC5 = $(shell which pyuic5)
|
||||||
PYUIC5 = $(or $(wildcard venv/bin/pyuic5), $(SYSTEM_PYUIC5))
|
PYUIC5 = $(or $(wildcard venv/bin/pyuic5), $(SYSTEM_PYUIC5))
|
||||||
@@ -15,10 +18,22 @@ PYRCC5 = $(or $(wildcard venv/bin/pyrcc5), $(SYSTEM_PYRCC5))
|
|||||||
SYSTEM_PYLUP5 = $(shell which pylupdate5)
|
SYSTEM_PYLUP5 = $(shell which pylupdate5)
|
||||||
PYLUP5 = $(or $(wildcard venv/bin/pylupdate5), $(SYSTEM_PYLUP5))
|
PYLUP5 = $(or $(wildcard venv/bin/pylupdate5), $(SYSTEM_PYLUP5))
|
||||||
|
|
||||||
|
APP_VERSION = $(shell $(PYTHON) src/$(PACKAGE) --version)
|
||||||
|
|
||||||
all: build_ui build_rc build
|
all: build_ui build_rc build
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
|
|
||||||
|
## Environment
|
||||||
|
venv:
|
||||||
|
$(SYSTEM_PYTHON) -m venv venv
|
||||||
|
source venv/bin/activate && \
|
||||||
|
python3 -m pip install --upgrade pip && \
|
||||||
|
python3 -m pip install -r requirements.txt
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
.PHONY: 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 \
|
||||||
@@ -39,16 +54,6 @@ update_translation:
|
|||||||
|
|
||||||
.PHONY: build_ui build_rc update_translation
|
.PHONY: build_ui build_rc update_translation
|
||||||
|
|
||||||
## Environment
|
|
||||||
venv:
|
|
||||||
rm -rf venv
|
|
||||||
$(SYSTEM_PYTHON) -m venv venv
|
|
||||||
|
|
||||||
deps:
|
|
||||||
$(PYTHON) -m pip install --upgrade pip -r requirements.txt
|
|
||||||
|
|
||||||
.PHONY: venv deps
|
|
||||||
|
|
||||||
## Build, install
|
## Build, install
|
||||||
build: build_ui build_rc
|
build: build_ui build_rc
|
||||||
$(PYTHON) -m setup sdist
|
$(PYTHON) -m setup sdist
|
||||||
@@ -60,24 +65,44 @@ install:
|
|||||||
.PHONY: build install
|
.PHONY: build install
|
||||||
|
|
||||||
## PyInstaller
|
## PyInstaller
|
||||||
installer_mac: build
|
installer_mac: build_ui build_rc
|
||||||
$(PYTHON) -m PyInstaller -n "RevPi Commander" \
|
$(PYTHON) -m PyInstaller -n $(APP_NAME) \
|
||||||
--add-data="src/$(PACKAGE)/locale:./revpicommander/locale" \
|
--add-data="src/$(PACKAGE)/locale:./$(PACKAGE)/locale" \
|
||||||
--add-data="data/$(PACKAGE).icns:." \
|
--add-data="data/$(PACKAGE).icns:." \
|
||||||
--icon=data/$(PACKAGE).icns \
|
--icon=data/$(PACKAGE).icns \
|
||||||
--noconfirm \
|
--noconfirm \
|
||||||
--clean \
|
--clean \
|
||||||
--onedir \
|
--onedir \
|
||||||
--windowed \
|
--windowed \
|
||||||
|
--osx-bundle-identifier $APP_IDENT \
|
||||||
|
--codesign-identity $(APPLE_SIG) \
|
||||||
src/$(PACKAGE)/__main__.py
|
src/$(PACKAGE)/__main__.py
|
||||||
|
|
||||||
installer_win: all
|
installer_mac_dmg: installer_mac
|
||||||
make_installer_win.bat
|
mkdir dist/dmg
|
||||||
|
mv dist/$(APP_NAME).app dist/dmg
|
||||||
|
create-dmg \
|
||||||
|
--volname $(APP_NAME) \
|
||||||
|
--background data/dmg_background.png \
|
||||||
|
--window-pos 200 120 \
|
||||||
|
--window-size 480 300 \
|
||||||
|
--icon-size 64 \
|
||||||
|
--icon $(APP_NAME).app 64 64 \
|
||||||
|
--hide-extension $(APP_NAME).app \
|
||||||
|
--app-drop-link 288 64 \
|
||||||
|
--add-file LICENSE.txt LICENSE.txt 192 180 \
|
||||||
|
--codesign $(APPLE_SIG) \
|
||||||
|
--notarize AC_PASSWORD \
|
||||||
|
dist/$(APP_NAME)\ $(APP_VERSION).dmg \
|
||||||
|
dist/dmg
|
||||||
|
|
||||||
.PHONY: installer_mac installer_win
|
.PHONY: installer_mac installer_mac_dmg
|
||||||
|
|
||||||
## Clean
|
## Clean
|
||||||
clean:
|
clean:
|
||||||
rm -rf build dist src/*.egg-info *.spec
|
rm -rf build dist src/*.egg-info *.spec
|
||||||
|
|
||||||
.PHONY: clean
|
clean-all: clean
|
||||||
|
rm -R venv
|
||||||
|
|
||||||
|
.PHONY: clean clean-all
|
||||||
|
|||||||
BIN
data/dmg_background.png
Normal file
BIN
data/dmg_background.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 172 KiB |
@@ -1,3 +1,9 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# Used to call the entry point, if packed with pybuild as application.
|
||||||
|
# PYBUILD_INSTALL_ARGS=--install-lib=/usr/share/revpicommander/ \
|
||||||
|
# --install-scripts=/usr/share/revpicommander/
|
||||||
|
#
|
||||||
|
# In that case the entry point will not find the revpicommander module in
|
||||||
|
# the python lib.
|
||||||
|
|
||||||
exec "/usr/share/revpicommander/revpicommander.py" "$@"
|
exec "/usr/share/revpicommander/revpicommander-gui" "$@"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Name=RevPi PLC Commander
|
Name=RevPi Commander
|
||||||
Comment=Controls the Python PLC program on your Revolution PI
|
Comment=Controls the Python PLC program on your Revolution PI
|
||||||
Comment[de]=Kontrolliert das Python PLC Programm auf dem Revolution PI
|
Comment[de]=Kontrolliert das Python PLC Programm auf dem Revolution PI
|
||||||
Exec=/usr/bin/revpicommander
|
Exec=/usr/bin/revpicommander
|
||||||
@@ -7,4 +7,3 @@ Icon=revpicommander
|
|||||||
Terminal=false
|
Terminal=false
|
||||||
Type=Application
|
Type=Application
|
||||||
Categories=Application;
|
Categories=Application;
|
||||||
#StartupNotify=true
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 5.3 KiB |
39
make.bat
Normal file
39
make.bat
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
@echo off
|
||||||
|
set PACKAGE=revpicommander
|
||||||
|
set APP_NAME=RevPi Commander
|
||||||
|
|
||||||
|
if "%1" == "venv" goto venv
|
||||||
|
if "%1" == "installer" goto installer
|
||||||
|
if "%1" == "clean" goto clean
|
||||||
|
|
||||||
|
echo Make script for "%APP_NAME%" on Windows
|
||||||
|
echo.
|
||||||
|
echo Need action:
|
||||||
|
echo venv Create / update your virtual environment for build process
|
||||||
|
echo installer Build this application with PyInstaller
|
||||||
|
echo clean Clean up your environment after build process
|
||||||
|
goto end
|
||||||
|
|
||||||
|
:venv
|
||||||
|
python -m venv venv
|
||||||
|
venv\\Scripts\\pip.exe install --upgrade -r requirements.txt
|
||||||
|
goto end
|
||||||
|
|
||||||
|
:installer
|
||||||
|
venv\\Scripts\\pyinstaller -n "%APP_NAME%" ^
|
||||||
|
--add-data="src\%PACKAGE%\locale;.\%PACKAGE%\locale" ^
|
||||||
|
--add-data="data\%PACKAGE%.ico;." ^
|
||||||
|
--icon=data\\%PACKAGE%.ico ^
|
||||||
|
--noconfirm ^
|
||||||
|
--clean ^
|
||||||
|
--onedir ^
|
||||||
|
--windowed ^
|
||||||
|
src\\%PACKAGE%\\__main__.py
|
||||||
|
goto end
|
||||||
|
|
||||||
|
:clean
|
||||||
|
rmdir /S /Q build dist
|
||||||
|
rmdir /S /Q src\%PACKAGE%.egg-info
|
||||||
|
del *.spec
|
||||||
|
|
||||||
|
:end
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
@echo off
|
|
||||||
set PACKAGE=revpicommander
|
|
||||||
|
|
||||||
rem python -m venv venv
|
|
||||||
rem venv\\Scripts\\activate.bat
|
|
||||||
rem pip install -r requirements.txt
|
|
||||||
|
|
||||||
pyinstaller -n "RevPi Commander" ^
|
|
||||||
--add-data="src\%PACKAGE%\locale;.\revpicommander\locale" ^
|
|
||||||
--add-data="data\%PACKAGE%.ico;." ^
|
|
||||||
--icon=data\\%PACKAGE%.ico ^
|
|
||||||
--noconfirm ^
|
|
||||||
--clean ^
|
|
||||||
--onedir ^
|
|
||||||
--windowed ^
|
|
||||||
src\\%PACKAGE%\\__main__.py
|
|
||||||
|
|
||||||
rem deactivate
|
|
||||||
@@ -5,3 +5,4 @@ zeroconf>=0.24.4
|
|||||||
setuptools>=65.6.3
|
setuptools>=65.6.3
|
||||||
wheel
|
wheel
|
||||||
paramiko>=2.12.0
|
paramiko>=2.12.0
|
||||||
|
keyring>=23.13.1
|
||||||
3
setup.iss
Executable file → Normal file
3
setup.iss
Executable file → Normal file
@@ -2,12 +2,13 @@
|
|||||||
; 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.10rc1"
|
#define MyAppVersion "0.9.10rc4"
|
||||||
#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"
|
||||||
|
|
||||||
[Setup]
|
[Setup]
|
||||||
|
SignTool=kSign
|
||||||
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
|
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
|
||||||
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
|
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
|
||||||
AppId={{21E8D429-0C18-462F-AFC0-56EA664DE629}
|
AppId={{21E8D429-0C18-462F-AFC0-56EA664DE629}
|
||||||
|
|||||||
15
setup.py
15
setup.py
@@ -6,28 +6,30 @@ __license__ = "GPLv3"
|
|||||||
|
|
||||||
from setuptools import find_namespace_packages, setup
|
from setuptools import find_namespace_packages, setup
|
||||||
|
|
||||||
|
from src.revpicommander import __version__
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="revpicommander",
|
name="revpicommander",
|
||||||
version="0.9.10rc1",
|
version=__version__,
|
||||||
|
|
||||||
packages=find_namespace_packages("src"),
|
packages=find_namespace_packages("src"),
|
||||||
package_dir={'': 'src'},
|
package_dir={'': 'src'},
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
|
|
||||||
install_requires=[
|
install_requires=[
|
||||||
|
"keyring",
|
||||||
"PyQt5",
|
"PyQt5",
|
||||||
"revpimodio2",
|
"revpimodio2",
|
||||||
"zeroconf"
|
"zeroconf"
|
||||||
],
|
],
|
||||||
entry_points={
|
entry_points={
|
||||||
'console_scripts': [
|
|
||||||
'revpicommander = revpicommander.revpicommander:main',
|
|
||||||
],
|
|
||||||
'gui_scripts': [
|
'gui_scripts': [
|
||||||
'RevPiCommander = revpicommander.revpicommander:main',
|
'revpicommander-gui = revpicommander.revpicommander:main',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
platforms=["all"],
|
||||||
|
|
||||||
url="https://revpimodio.org/revpipyplc/",
|
url="https://revpimodio.org/revpipyplc/",
|
||||||
license="GPLv3",
|
license="GPLv3",
|
||||||
author="Sven Sager",
|
author="Sven Sager",
|
||||||
@@ -35,11 +37,12 @@ setup(
|
|||||||
maintainer="Sven Sager",
|
maintainer="Sven Sager",
|
||||||
maintainer_email="akira@revpimodio.org",
|
maintainer_email="akira@revpimodio.org",
|
||||||
description="GUI for Revolution Pi to upload programs and do IO-Checks",
|
description="GUI for Revolution Pi to upload programs and do IO-Checks",
|
||||||
long_description="The RevPiCommander is a GUI tool to manage your revolution Pi over the\n"
|
long_description="The RevPiCommander is a GUI tool to manage your Revolution Pi over the\n"
|
||||||
"network. You can search for RevPis in your network, manage the settings\n"
|
"network. You can search for RevPis in your network, manage the settings\n"
|
||||||
"of RevPiPyLoad and do IO checks on your local machine. Developing your\n"
|
"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"
|
"control program is very easy with the developer, upload and debug it\n"
|
||||||
"over the network.",
|
"over the network.",
|
||||||
|
keywords=["revpi", "revolution pi", "revpimodio", "plc"],
|
||||||
classifiers=[
|
classifiers=[
|
||||||
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
|
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -3,3 +3,4 @@
|
|||||||
__author__ = "Sven Sager"
|
__author__ = "Sven Sager"
|
||||||
__copyright__ = "Copyright (C) 2023 Sven Sager"
|
__copyright__ = "Copyright (C) 2023 Sven Sager"
|
||||||
__license__ = "GPLv3"
|
__license__ = "GPLv3"
|
||||||
|
__version__ = "0.9.10rc4"
|
||||||
|
|||||||
@@ -16,7 +16,15 @@ if __package__ == "":
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import sys
|
import sys
|
||||||
from revpicommander.revpicommander import main
|
|
||||||
|
|
||||||
# Run the main application of this package
|
if len(sys.argv) == 2 and "--version" in sys.argv:
|
||||||
sys.exit(main())
|
# Catch --version, if this is the only argument (sys.argv[0] is always the script name)
|
||||||
|
from revpicommander import __version__
|
||||||
|
print(__version__)
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
else:
|
||||||
|
from revpicommander.revpicommander import main
|
||||||
|
|
||||||
|
# Run the main application of this package
|
||||||
|
sys.exit(main())
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ class AclManager(QtWidgets.QDialog, Ui_diag_aclmanager):
|
|||||||
)
|
)
|
||||||
) == QtWidgets.QMessageBox.Yes
|
) == QtWidgets.QMessageBox.Yes
|
||||||
if ask:
|
if ask:
|
||||||
self.on_btn_add_pressed()
|
self.on_btn_add_clicked()
|
||||||
|
|
||||||
if self.__check_load_error():
|
if self.__check_load_error():
|
||||||
return
|
return
|
||||||
@@ -252,11 +252,11 @@ class AclManager(QtWidgets.QDialog, Ui_diag_aclmanager):
|
|||||||
self.btn_remove.setEnabled(not self.__read_only and selected_rows > 0)
|
self.btn_remove.setEnabled(not self.__read_only and selected_rows > 0)
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def on_btn_edit_pressed(self):
|
def on_btn_edit_clicked(self):
|
||||||
self.__load_selected_entry()
|
self.__load_selected_entry()
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@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)]
|
lst_selected_row_indexes = [mi.row() for mi in self.tb_acls.selectionModel().selectedRows(0)]
|
||||||
if len(lst_selected_row_indexes) == 0:
|
if len(lst_selected_row_indexes) == 0:
|
||||||
return
|
return
|
||||||
@@ -355,7 +355,7 @@ class AclManager(QtWidgets.QDialog, Ui_diag_aclmanager):
|
|||||||
self._check_all_filled()
|
self._check_all_filled()
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def on_btn_add_pressed(self):
|
def on_btn_add_clicked(self):
|
||||||
"""Add a new entry to acl table."""
|
"""Add a new entry to acl table."""
|
||||||
ip_level = "{0}.{1}.{2}.{3},{4}".format(
|
ip_level = "{0}.{1}.{2}.{3},{4}".format(
|
||||||
self.txt_ip_a.text(),
|
self.txt_ip_a.text(),
|
||||||
@@ -366,7 +366,7 @@ class AclManager(QtWidgets.QDialog, Ui_diag_aclmanager):
|
|||||||
)
|
)
|
||||||
if self.__re_ipacl.match(ip_level):
|
if self.__re_ipacl.match(ip_level):
|
||||||
self.__table_add_acl(ip_level)
|
self.__table_add_acl(ip_level)
|
||||||
self.on_btn_clear_pressed()
|
self.on_btn_clear_clicked()
|
||||||
else:
|
else:
|
||||||
QtWidgets.QMessageBox.critical(
|
QtWidgets.QMessageBox.critical(
|
||||||
self, self.tr("Error"), self.tr(
|
self, self.tr("Error"), self.tr(
|
||||||
@@ -376,7 +376,7 @@ class AclManager(QtWidgets.QDialog, Ui_diag_aclmanager):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def on_btn_clear_pressed(self):
|
def on_btn_clear_clicked(self):
|
||||||
"""Clear entry widgets."""
|
"""Clear entry widgets."""
|
||||||
self.txt_ip_a.clear()
|
self.txt_ip_a.clear()
|
||||||
self.txt_ip_b.clear()
|
self.txt_ip_b.clear()
|
||||||
|
|||||||
@@ -5,40 +5,18 @@ __copyright__ = "Copyright (C) 2023 Sven Sager"
|
|||||||
__license__ = "GPLv3"
|
__license__ = "GPLv3"
|
||||||
|
|
||||||
import webbrowser
|
import webbrowser
|
||||||
from os import name as osname
|
|
||||||
from re import compile
|
from re import compile
|
||||||
from sys import platform
|
from sys import platform
|
||||||
|
|
||||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||||
from zeroconf import IPVersion, ServiceBrowser, Zeroconf
|
from zeroconf import IPVersion, ServiceBrowser, Zeroconf
|
||||||
|
|
||||||
|
from . import helper
|
||||||
from . import proginit as pi
|
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
|
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):
|
class AvahiSearchThread(QtCore.QThread):
|
||||||
"""Search thread for Revolution Pi with installed RevPiPyLoad."""
|
"""Search thread for Revolution Pi with installed RevPiPyLoad."""
|
||||||
added = QtCore.pyqtSignal(str, str, int, str, str)
|
added = QtCore.pyqtSignal(str, str, int, str, str)
|
||||||
@@ -49,30 +27,11 @@ class AvahiSearchThread(QtCore.QThread):
|
|||||||
super(AvahiSearchThread, self).__init__(parent)
|
super(AvahiSearchThread, self).__init__(parent)
|
||||||
self._cycle_wait_ms = 1000
|
self._cycle_wait_ms = 1000
|
||||||
|
|
||||||
self.__dict_arp = {}
|
|
||||||
self.re_posix = compile(
|
self.re_posix = compile(
|
||||||
r"(?P<ip>(\d{1,3}\.){3}\d{1,3}).*"
|
r"(?P<ip>(\d{1,3}\.){3}\d{1,3}).*"
|
||||||
r"(?P<mac>([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2})"
|
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:
|
def remove_service(self, zeroconf: Zeroconf, conf_type: str, name: str) -> None:
|
||||||
"""Revolution Pi disappeared."""
|
"""Revolution Pi disappeared."""
|
||||||
pi.logger.debug("AvahiSearchThread.remove_service")
|
pi.logger.debug("AvahiSearchThread.remove_service")
|
||||||
@@ -115,17 +74,20 @@ class AvahiSearch(QtWidgets.QDialog, Ui_diag_search):
|
|||||||
super(AvahiSearch, self).__init__(parent)
|
super(AvahiSearch, self).__init__(parent)
|
||||||
self.setupUi(self)
|
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.clipboard = QtGui.QGuiApplication.clipboard()
|
||||||
self.connect_index = -1
|
self._th_zero_conf = AvahiSearchThread(self)
|
||||||
self.known_hosts = {}
|
|
||||||
self.th_zero_conf = AvahiSearchThread(self)
|
|
||||||
|
|
||||||
self.tb_revpi.setColumnWidth(0, 250)
|
self.tb_revpi.setColumnWidth(0, 250)
|
||||||
self.btn_connect.setEnabled(False)
|
self.btn_connect.setEnabled(False)
|
||||||
self.btn_save.setEnabled(False)
|
self.btn_save.setEnabled(False)
|
||||||
|
|
||||||
self.restoreGeometry(settings.value("avahisearch/geo", b''))
|
self.restoreGeometry(helper.settings.value("avahisearch/geo", b''))
|
||||||
column_sizes = settings.value("avahisearch/column_sizes", [], type=list)
|
column_sizes = helper.settings.value("avahisearch/column_sizes", [], type=list)
|
||||||
if len(column_sizes) == self.tb_revpi.columnCount():
|
if len(column_sizes) == self.tb_revpi.columnCount():
|
||||||
for i in range(self.tb_revpi.columnCount()):
|
for i in range(self.tb_revpi.columnCount()):
|
||||||
self.tb_revpi.setColumnWidth(i, int(column_sizes[i]))
|
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_connect_actions.addAction(self.act_connect_xmlrpc)
|
||||||
|
|
||||||
self.cm_quick_actions = QtWidgets.QMenu(self)
|
self.cm_quick_actions = QtWidgets.QMenu(self)
|
||||||
self.cm_quick_actions.addAction(self.act_open_pictory)
|
self.cm_quick_actions.addAction(self.act_connect)
|
||||||
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_ssh)
|
self.cm_quick_actions.addAction(self.act_connect_ssh)
|
||||||
self.cm_quick_actions.addAction(self.act_connect_xmlrpc)
|
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.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
|
||||||
self.tb_revpi.customContextMenuRequested.connect(self._cm_quick_exec)
|
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)
|
@QtCore.pyqtSlot(QtCore.QPoint)
|
||||||
def _cm_quick_exec(self, position: QtCore.QPoint) -> None:
|
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
|
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()
|
sender = self.sender()
|
||||||
action = self.cm_quick_actions.exec(sender.mapToGlobal(position))
|
self.cm_quick_actions.exec(sender.mapToGlobal(position))
|
||||||
if action:
|
|
||||||
action.trigger()
|
|
||||||
|
|
||||||
def _load_known_hosts(self) -> None:
|
self.act_connect.setVisible(True)
|
||||||
"""Load existing connections to show hostname of existing ip addresses"""
|
self.act_connect_ssh.setVisible(True)
|
||||||
self.known_hosts.clear()
|
self.act_connect_xmlrpc.setVisible(True)
|
||||||
|
|
||||||
for i in range(settings.beginReadArray("connections")):
|
@staticmethod
|
||||||
settings.setArrayIndex(i)
|
def _find_settings(address: str) -> list[RevPiSettings]:
|
||||||
|
"""Find all settings with known avahi_id."""
|
||||||
name = settings.value("name", type=str)
|
return [
|
||||||
folder = settings.value("folder", type=str)
|
revpi_setting
|
||||||
address = settings.value("address", type=str)
|
for revpi_setting in all_revpi_settings()
|
||||||
self.known_hosts[address] = "{0}/{1}".format(folder, name) if folder else name
|
if revpi_setting.address.lower() == address.lower()
|
||||||
|
]
|
||||||
settings.endArray()
|
|
||||||
|
|
||||||
def _restart_search(self) -> None:
|
def _restart_search(self) -> None:
|
||||||
"""Clean up and restart search thread."""
|
"""Clean up and restart search thread."""
|
||||||
while self.tb_revpi.rowCount() > 0:
|
while self.tb_revpi.rowCount() > 0:
|
||||||
|
# Remove each row, a .clean would destroy the columns
|
||||||
self.tb_revpi.removeRow(0)
|
self.tb_revpi.removeRow(0)
|
||||||
self.th_zero_conf.requestInterruption()
|
|
||||||
|
|
||||||
self.th_zero_conf = AvahiSearchThread(self)
|
self._th_zero_conf.requestInterruption()
|
||||||
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 _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 row: Row with connection data
|
||||||
:param ssh_tunnel: Save as SSH tunnel connection
|
:param ssh_tunnel: Save as SSH tunnel connection
|
||||||
:param no_warn: If True, no message boxes will appear
|
:return: RevPi settings with data from avahi search and default values
|
||||||
:return: Array index of connection (found or saved) or -1
|
|
||||||
"""
|
"""
|
||||||
item = self.tb_revpi.item(row, 0)
|
item = self.tb_revpi.item(row, 0)
|
||||||
if not item:
|
if not item:
|
||||||
return -1
|
return None
|
||||||
|
|
||||||
folder_name = self.tr("Auto discovered")
|
settings = RevPiSettings()
|
||||||
selected_name = item.text()
|
settings.folder = self.tr("Auto discovered")
|
||||||
selected_address = item.data(WidgetData.address)
|
settings.name = item.data(WidgetData.host_name)
|
||||||
selected_port = item.data(WidgetData.port)
|
settings.address = item.data(WidgetData.address)
|
||||||
i = 0
|
settings.port = item.data(WidgetData.port)
|
||||||
for i in range(settings.beginReadArray("connections")):
|
settings.ssh_use_tunnel = ssh_tunnel
|
||||||
settings.setArrayIndex(i)
|
|
||||||
|
|
||||||
name = settings.value("name", type=str)
|
return settings
|
||||||
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
|
|
||||||
|
|
||||||
def closeEvent(self, a0: QtGui.QCloseEvent) -> None:
|
def closeEvent(self, a0: QtGui.QCloseEvent) -> None:
|
||||||
settings.setValue("avahisearch/geo", self.saveGeometry())
|
helper.settings.setValue("avahisearch/geo", self.saveGeometry())
|
||||||
settings.setValue("avahisearch/column_sizes", [
|
helper.settings.setValue("avahisearch/column_sizes", [
|
||||||
self.tb_revpi.columnWidth(i)
|
self.tb_revpi.columnWidth(i)
|
||||||
for i in range(self.tb_revpi.columnCount())
|
for i in range(self.tb_revpi.columnCount())
|
||||||
])
|
])
|
||||||
|
|
||||||
def exec(self) -> int:
|
def exec(self) -> int:
|
||||||
self._load_known_hosts()
|
self.connect_settings = None
|
||||||
|
self.just_save = False
|
||||||
self._restart_search()
|
self._restart_search()
|
||||||
rc = super(AvahiSearch, self).exec()
|
rc = super(AvahiSearch, self).exec()
|
||||||
self.th_zero_conf.requestInterruption()
|
self._th_zero_conf.requestInterruption()
|
||||||
return rc
|
return rc
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def on_act_connect_ssh_triggered(self) -> None:
|
def on_act_connect_triggered(self) -> None:
|
||||||
"""Copy ip address of selected item to clipboard."""
|
"""Connect via existing settings or ask for type."""
|
||||||
pi.logger.debug("AvahiSearch.on_act_connect_ssh_triggered")
|
pi.logger.debug("AvahiSearch.on_act_connect_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."""
|
|
||||||
selected_items = self.tb_revpi.selectedItems()
|
selected_items = self.tb_revpi.selectedItems()
|
||||||
if not selected_items:
|
if not selected_items:
|
||||||
return
|
return
|
||||||
item = selected_items[0]
|
item = selected_items[0]
|
||||||
host_name = item.data(WidgetData.host_name)
|
|
||||||
if platform == "win32":
|
revpi_settings = item.data(WidgetData.revpi_settings) # type: RevPiSettings
|
||||||
# Strip hostname on Windows systems, it can not resolve .local addresses
|
if not revpi_settings:
|
||||||
host_name = host_name[:host_name.find(".")]
|
return
|
||||||
self.clipboard.setText(host_name)
|
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()
|
@QtCore.pyqtSlot()
|
||||||
def on_act_copy_ip_triggered(self) -> None:
|
def on_act_copy_ip_triggered(self) -> None:
|
||||||
@@ -321,51 +257,71 @@ class AvahiSearch(QtWidgets.QDialog, Ui_diag_search):
|
|||||||
if not selected_items:
|
if not selected_items:
|
||||||
return
|
return
|
||||||
item = selected_items[0]
|
item = selected_items[0]
|
||||||
if platform == "win32":
|
|
||||||
webbrowser.open("http://{0}/".format(item.data(WidgetData.address)))
|
# Till we could not choose https / http we are using the ip address
|
||||||
else:
|
webbrowser.open("http://{0}/".format(item.data(WidgetData.address)))
|
||||||
webbrowser.open("http://{0}/".format(item.data(WidgetData.host_name)))
|
|
||||||
|
|
||||||
@QtCore.pyqtSlot(str, str, int, str, str)
|
@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."""
|
"""New Revolution Pi found."""
|
||||||
index = -1
|
|
||||||
|
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()):
|
for i in range(self.tb_revpi.rowCount()):
|
||||||
if self.tb_revpi.item(i, 0).data(WidgetData.object_name) == name:
|
item_tb_revpi = self.tb_revpi.item(i, 0)
|
||||||
index = i
|
if item_tb_revpi.data(WidgetData.object_name) == avahi_id:
|
||||||
break
|
# Object already discovered
|
||||||
|
update_tb_revpi_row(i)
|
||||||
|
exists = True
|
||||||
|
|
||||||
if index == -1:
|
if not exists:
|
||||||
# New Row
|
for known_settings in lst_existing or [None]:
|
||||||
item_name = QtWidgets.QTableWidgetItem()
|
item_name = QtWidgets.QTableWidgetItem()
|
||||||
item_ip = QtWidgets.QTableWidgetItem()
|
|
||||||
|
|
||||||
index = self.tb_revpi.rowCount()
|
item_name.setIcon(QtGui.QIcon(":/main/ico/cpu.ico"))
|
||||||
self.tb_revpi.insertRow(index)
|
item_name.setData(WidgetData.object_name, avahi_id)
|
||||||
self.tb_revpi.setItem(index, 0, item_name)
|
item_name.setData(WidgetData.revpi_settings, known_settings)
|
||||||
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)
|
|
||||||
|
|
||||||
host_name = server[:-1]
|
index = self.tb_revpi.rowCount()
|
||||||
item_name.setIcon(QtGui.QIcon(":/main/ico/cpu.ico"))
|
self.tb_revpi.insertRow(index)
|
||||||
if ip in self.known_hosts:
|
self.tb_revpi.setItem(index, 0, item_name)
|
||||||
item_name.setText("{0} ({1})".format(host_name, self.known_hosts[ip]))
|
self.tb_revpi.setItem(index, 1, QtWidgets.QTableWidgetItem())
|
||||||
else:
|
|
||||||
item_name.setText(host_name)
|
update_tb_revpi_row(index)
|
||||||
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)
|
|
||||||
|
|
||||||
@QtCore.pyqtSlot(str, str)
|
@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."""
|
"""Revolution Pi disappeared."""
|
||||||
for i in range(self.tb_revpi.rowCount()):
|
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)
|
self.tb_revpi.removeRow(i)
|
||||||
break
|
break
|
||||||
|
|
||||||
@@ -373,8 +329,17 @@ class AvahiSearch(QtWidgets.QDialog, Ui_diag_search):
|
|||||||
def on_tb_revpi_cellDoubleClicked(self, row: int, column: int) -> None:
|
def on_tb_revpi_cellDoubleClicked(self, row: int, column: int) -> None:
|
||||||
"""Connect to double-clicked Revolution Pi."""
|
"""Connect to double-clicked Revolution Pi."""
|
||||||
pi.logger.debug("AvahiSearch.on_tb_revpi_cellDoubleClicked")
|
pi.logger.debug("AvahiSearch.on_tb_revpi_cellDoubleClicked")
|
||||||
cur = QtGui.QCursor()
|
selected_items = self.tb_revpi.selectedItems()
|
||||||
self._cm_connect_exec(cur.pos())
|
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_actions.exec(cur.pos())
|
||||||
|
|
||||||
@QtCore.pyqtSlot(int, int, int, int)
|
@QtCore.pyqtSlot(int, int, int, int)
|
||||||
def on_tb_revpi_currentCellChanged(self, row: int, column: int, last_row: int, last_column: int) -> None:
|
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:
|
def on_btn_connect_clicked(self) -> None:
|
||||||
"""Connect to selected Revolution Pi."""
|
"""Connect to selected Revolution Pi."""
|
||||||
pi.logger.debug("AvahiSearch.on_btn_connect_clicked")
|
pi.logger.debug("AvahiSearch.on_btn_connect_clicked")
|
||||||
# Open context menu under the button
|
selected_items = self.tb_revpi.selectedItems()
|
||||||
pos = self.btn_connect.pos()
|
if not selected_items:
|
||||||
pos.setY(pos.y() + self.btn_connect.height())
|
return
|
||||||
self._cm_connect_exec(self.mapToGlobal(pos))
|
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()
|
@QtCore.pyqtSlot()
|
||||||
def on_btn_save_clicked(self) -> None:
|
def on_btn_save_clicked(self) -> None:
|
||||||
"""Save selected Revolution Pi."""
|
"""Save selected Revolution Pi."""
|
||||||
pi.logger.debug("AvahiSearch.on_btn_save_clicked")
|
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
|
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()
|
@QtCore.pyqtSlot()
|
||||||
def on_btn_restart_clicked(self) -> None:
|
def on_btn_restart_clicked(self) -> None:
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ class BackgroundWorker(QtCore.QThread):
|
|||||||
steps_done = QtCore.pyqtSignal(int)
|
steps_done = QtCore.pyqtSignal(int)
|
||||||
status_message = QtCore.pyqtSignal(str)
|
status_message = QtCore.pyqtSignal(str)
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None, interruption_text: str = None):
|
||||||
|
self._interruption_text = interruption_text or self.tr("User requested cancellation...")
|
||||||
super(BackgroundWorker, self).__init__(parent)
|
super(BackgroundWorker, self).__init__(parent)
|
||||||
|
|
||||||
def check_cancel(self) -> bool:
|
def check_cancel(self) -> bool:
|
||||||
@@ -28,33 +29,67 @@ class BackgroundWorker(QtCore.QThread):
|
|||||||
:return: True, if interruption was requested
|
:return: True, if interruption was requested
|
||||||
"""
|
"""
|
||||||
if self.isInterruptionRequested():
|
if self.isInterruptionRequested():
|
||||||
self.status_message.emit(self.tr("User requested cancellation..."))
|
self.status_message.emit(self._interruption_text)
|
||||||
self.msleep(750)
|
self.msleep(750)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def exec_dialog(self) -> int:
|
def exec_dialog(self, window_title="", can_cancel=True) -> int:
|
||||||
|
"""
|
||||||
|
Show dialog with progress bar.
|
||||||
|
|
||||||
|
:param window_title: Title of Dialog window
|
||||||
|
:param can_cancel: If False, the cancel button is deactivated
|
||||||
|
:return: Dialog result
|
||||||
|
"""
|
||||||
diag = WorkerDialog(self, self.parent())
|
diag = WorkerDialog(self, self.parent())
|
||||||
|
diag.setWindowTitle(window_title)
|
||||||
|
diag.btn_box.setEnabled(can_cancel)
|
||||||
rc = diag.exec()
|
rc = diag.exec()
|
||||||
diag.deleteLater()
|
diag.deleteLater()
|
||||||
return rc
|
return rc
|
||||||
|
|
||||||
def wait_interruptable(self, seconds=-1) -> None:
|
def wait_interruptable(self, seconds=-1) -> bool:
|
||||||
"""Save function to wait and get the cancel buttons."""
|
"""
|
||||||
|
Save function to wait and get the cancel buttons.
|
||||||
|
|
||||||
|
:param seconds: Wait this amount of seconds
|
||||||
|
:return: True, if interruption was requested
|
||||||
|
"""
|
||||||
counter = seconds * 4
|
counter = seconds * 4
|
||||||
while counter != 0:
|
while counter != 0:
|
||||||
counter -= 1
|
counter -= 1
|
||||||
self.msleep(250)
|
self.msleep(250)
|
||||||
if self._check_cancel():
|
if self.check_cancel():
|
||||||
break
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def run(self) -> None:
|
def run(self) -> None:
|
||||||
"""Worker thread to import pictures from camera."""
|
"""Override this function with your logic."""
|
||||||
log.debug("BackgroundWorker.run")
|
raise NotImplementedError()
|
||||||
self.status_message.emit("Started dummy thread...")
|
|
||||||
self.wait_interruptable(5)
|
|
||||||
self.status_message.emit("Completed dummy thread.")
|
class BackgroundWaiter(BackgroundWorker):
|
||||||
self._save_wait(3)
|
"""Just wait an amount of time and show progress bar."""
|
||||||
|
|
||||||
|
def __init__(self, seconds: int, status_message: str, parent=None, interruption_text: str = None):
|
||||||
|
self._status_message = status_message
|
||||||
|
self._wait_steps = seconds * 4
|
||||||
|
super().__init__(parent, interruption_text)
|
||||||
|
|
||||||
|
def run(self) -> None:
|
||||||
|
log.debug("BackgroundWaiter.run")
|
||||||
|
self.steps_todo.emit(self._wait_steps)
|
||||||
|
self.status_message.emit(self._status_message)
|
||||||
|
counter = 0
|
||||||
|
while counter <= self._wait_steps:
|
||||||
|
counter += 1
|
||||||
|
self.msleep(250)
|
||||||
|
if self.isInterruptionRequested():
|
||||||
|
self.steps_done.emit(self._wait_steps)
|
||||||
|
if self.check_cancel():
|
||||||
|
return
|
||||||
|
self.steps_done.emit(counter)
|
||||||
|
|
||||||
|
|
||||||
class WorkerDialog(QtWidgets.QDialog, Ui_diag_backgroundworker):
|
class WorkerDialog(QtWidgets.QDialog, Ui_diag_backgroundworker):
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ __license__ = "GPLv3"
|
|||||||
import pickle
|
import pickle
|
||||||
from xmlrpc.client import Binary, Fault, MultiCall, MultiCallIterator
|
from xmlrpc.client import Binary, Fault, MultiCall, MultiCallIterator
|
||||||
|
|
||||||
from PyQt5 import QtCore, QtWidgets
|
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||||
|
|
||||||
from .import helper
|
from . import helper
|
||||||
from . import proginit as pi
|
from . import proginit as pi
|
||||||
from .debugios import DebugIos
|
from .debugios import DebugIos
|
||||||
from .ui.debugcontrol_ui import Ui_wid_debugcontrol
|
from .ui.debugcontrol_ui import Ui_wid_debugcontrol
|
||||||
@@ -74,7 +74,17 @@ class DebugControl(QtWidgets.QWidget, Ui_wid_debugcontrol):
|
|||||||
QtWidgets.QSpacerItem(20, 1, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
|
QtWidgets.QSpacerItem(20, 1, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
|
||||||
)
|
)
|
||||||
self.cbx_write.setEnabled(False)
|
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):
|
def __del__(self):
|
||||||
pi.logger.debug("DebugControl.__del__")
|
pi.logger.debug("DebugControl.__del__")
|
||||||
@@ -323,8 +333,6 @@ class DebugControl(QtWidgets.QWidget, Ui_wid_debugcontrol):
|
|||||||
dict_inps[position], dict_outs[position]
|
dict_inps[position], dict_outs[position]
|
||||||
)
|
)
|
||||||
win.device_closed.connect(self.on_device_closed)
|
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
|
self.dict_windows[position] = win
|
||||||
|
|
||||||
btn = QtWidgets.QPushButton(self.gb_devices)
|
btn = QtWidgets.QPushButton(self.gb_devices)
|
||||||
@@ -342,7 +350,7 @@ class DebugControl(QtWidgets.QWidget, Ui_wid_debugcontrol):
|
|||||||
self._work_values(refresh=True)
|
self._work_values(refresh=True)
|
||||||
self._set_gui_control_states()
|
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
|
return True
|
||||||
|
|
||||||
@@ -380,9 +388,9 @@ class DebugControl(QtWidgets.QWidget, Ui_wid_debugcontrol):
|
|||||||
self._work_values(refresh=True)
|
self._work_values(refresh=True)
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def on_btn_write_o_pressed(self):
|
def on_btn_write_o_clicked(self):
|
||||||
"""Write outputs."""
|
"""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):
|
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
|
for win in self.dict_windows.values(): # type: DebugIos
|
||||||
win.reset_label_colors()
|
win.reset_label_colors()
|
||||||
@@ -415,12 +423,12 @@ class DebugControl(QtWidgets.QWidget, Ui_wid_debugcontrol):
|
|||||||
@QtCore.pyqtSlot(bool)
|
@QtCore.pyqtSlot(bool)
|
||||||
def on_cbx_refresh_clicked(self, state: bool):
|
def on_cbx_refresh_clicked(self, state: bool):
|
||||||
"""Save the state on user action."""
|
"""Save the state on user action."""
|
||||||
helper.settings.setValue("auto_refresh", state)
|
helper.settings.setValue("debugcontrol/auto_refresh", state)
|
||||||
|
|
||||||
@QtCore.pyqtSlot(bool)
|
@QtCore.pyqtSlot(bool)
|
||||||
def on_cbx_stay_on_top_clicked(self, state: bool):
|
def on_cbx_stay_on_top_clicked(self, state: bool):
|
||||||
"""Save the state on user action."""
|
"""Save the state on user action."""
|
||||||
helper.settings.setValue("stay_on_top", state)
|
helper.settings.setValue("debugcontrol/stay_on_top", state)
|
||||||
|
|
||||||
@QtCore.pyqtSlot(int)
|
@QtCore.pyqtSlot(int)
|
||||||
def on_cbx_write_stateChanged(self, state: int):
|
def on_cbx_write_stateChanged(self, state: int):
|
||||||
|
|||||||
@@ -18,15 +18,14 @@ class DebugIos(QtWidgets.QMainWindow, Ui_win_debugios):
|
|||||||
|
|
||||||
device_closed = QtCore.pyqtSignal(int)
|
device_closed = QtCore.pyqtSignal(int)
|
||||||
"""This window was closed."""
|
"""This window was closed."""
|
||||||
do_read = QtCore.pyqtSignal()
|
|
||||||
do_write = QtCore.pyqtSignal()
|
|
||||||
search_class = (QtWidgets.QLineEdit, QtWidgets.QDoubleSpinBox, QtWidgets.QCheckBox)
|
search_class = (QtWidgets.QLineEdit, QtWidgets.QDoubleSpinBox, QtWidgets.QCheckBox)
|
||||||
|
|
||||||
def __init__(self, position: int, name: str, inputs: list, outputs: list, parent=None):
|
def __init__(self, position: int, name: str, inputs: list, outputs: list, parent=None):
|
||||||
super(DebugIos, self).__init__(parent)
|
super(DebugIos, self).__init__(parent)
|
||||||
self.setupUi(self)
|
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.setWindowTitle("{0} - {1}".format(position, name))
|
||||||
self.gb_io.setTitle(self.gb_io.title().format(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._create_io(self.outputs, self.saw_out, False)
|
||||||
self.style_sheet = "background-color: red;"
|
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):
|
def __del__(self):
|
||||||
pi.logger.debug("DebugIos.__del__")
|
pi.logger.debug("DebugIos.__del__")
|
||||||
|
|
||||||
def closeEvent(self, a0: QtGui.QCloseEvent):
|
def closeEvent(self, a0: QtGui.QCloseEvent):
|
||||||
pi.logger.debug("DebugIos.closeEvent")
|
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)
|
self.device_closed.emit(self.position)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -12,45 +12,195 @@ from os import environ, remove
|
|||||||
from os.path import exists
|
from os.path import exists
|
||||||
from queue import Queue
|
from queue import Queue
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
|
from uuid import uuid4
|
||||||
from xmlrpc.client import Binary, ServerProxy
|
from xmlrpc.client import Binary, ServerProxy
|
||||||
|
|
||||||
from PyQt5 import QtCore, QtWidgets
|
from PyQt5 import QtCore
|
||||||
from paramiko.ssh_exception import AuthenticationException
|
from paramiko.ssh_exception import AuthenticationException
|
||||||
|
|
||||||
from . import proginit as pi
|
from . import proginit as pi
|
||||||
from .ssh_tunneling.server import SSHLocalTunnel
|
from .ssh_tunneling.server import SSHLocalTunnel
|
||||||
from .sshauth import SSHAuth, SSHAuthType
|
|
||||||
|
settings = QtCore.QSettings("revpimodio.org", "revpicommander")
|
||||||
|
"""Global application settings."""
|
||||||
|
|
||||||
|
homedir = environ.get("HOME", "") or environ.get("APPDATA", "")
|
||||||
|
"""Home dir of user."""
|
||||||
|
|
||||||
|
|
||||||
|
class ConnectionFail(IntEnum):
|
||||||
|
NO_XML_RPC = 1
|
||||||
|
SSH_CONNECT = 2
|
||||||
|
SSH_AUTH = 4
|
||||||
|
|
||||||
|
|
||||||
class WidgetData(IntEnum):
|
class WidgetData(IntEnum):
|
||||||
address = 260
|
address = 260
|
||||||
replace_ios_config = 261
|
|
||||||
acl_level = 262
|
acl_level = 262
|
||||||
has_error = 263
|
has_error = 263
|
||||||
port = 264
|
port = 264
|
||||||
object_name = 265
|
object_name = 265
|
||||||
timeout = 266
|
|
||||||
host_name = 267
|
host_name = 267
|
||||||
last_dir_upload = 301
|
host_name_full = 268
|
||||||
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
|
|
||||||
file_name = 309
|
file_name = 309
|
||||||
watch_files = 310
|
revpi_settings = 320
|
||||||
watch_path = 311
|
|
||||||
debug_geos = 312
|
|
||||||
ssh_use_tunnel = 313
|
class RevPiSettings:
|
||||||
ssh_port = 315
|
|
||||||
ssh_user = 316
|
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):
|
class ConnectionManager(QtCore.QThread):
|
||||||
"""Check connection and status for PLC program on Revolution Pi."""
|
"""Check connection and status for PLC program on Revolution Pi."""
|
||||||
|
|
||||||
|
connect_error = QtCore.pyqtSignal(str, str, ConnectionFail, RevPiSettings)
|
||||||
|
"""Error header, message and reason (ConnectionFail) of a new connection after pyload_connect call."""
|
||||||
connection_established = QtCore.pyqtSignal()
|
connection_established = QtCore.pyqtSignal()
|
||||||
"""New connection established successfully with <class 'ServerProxy'>."""
|
"""New connection established successfully with <class 'ServerProxy'>."""
|
||||||
connection_disconnected = QtCore.pyqtSignal()
|
connection_disconnected = QtCore.pyqtSignal()
|
||||||
@@ -75,29 +225,11 @@ class ConnectionManager(QtCore.QThread):
|
|||||||
self._revpi = None
|
self._revpi = None
|
||||||
self._revpi_output = None
|
self._revpi_output = None
|
||||||
|
|
||||||
self.address = ""
|
self.settings = RevPiSettings()
|
||||||
self.name = ""
|
|
||||||
self.port = 55123
|
|
||||||
|
|
||||||
self.ssh_tunnel_server = None # type: SSHLocalTunnel
|
self.ssh_tunnel_server = None # type: SSHLocalTunnel
|
||||||
self.ssh_use_tunnel = False
|
|
||||||
self.ssh_port = 22
|
|
||||||
self.ssh_user = "pi"
|
|
||||||
self.ssh_pass = ""
|
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)
|
self.pyload_version = (0, 0, 0)
|
||||||
"""Version number of RevPiPyLoad 0.0.0 with <class 'int'> values."""
|
"""Version number of RevPiPyLoad 0.0.0 with <class 'int'> values."""
|
||||||
self.xml_funcs = []
|
self.xml_funcs = []
|
||||||
@@ -178,133 +310,65 @@ class ConnectionManager(QtCore.QThread):
|
|||||||
|
|
||||||
def _clear_settings(self):
|
def _clear_settings(self):
|
||||||
"""Clear connection settings."""
|
"""Clear connection settings."""
|
||||||
self.address = ""
|
self.settings = RevPiSettings()
|
||||||
self.name = ""
|
|
||||||
self.port = 55123
|
|
||||||
|
|
||||||
self.ssh_use_tunnel = False
|
|
||||||
self.ssh_port = 22
|
|
||||||
self.ssh_user = "pi"
|
|
||||||
self.ssh_pass = ""
|
self.ssh_pass = ""
|
||||||
|
|
||||||
self.pyload_version = (0, 0, 0)
|
self.pyload_version = (0, 0, 0)
|
||||||
self.xml_funcs.clear()
|
self.xml_funcs.clear()
|
||||||
self.xml_mode = -1
|
self.xml_mode = -1
|
||||||
|
|
||||||
self.program_last_dir_upload = ""
|
def pyload_connect(self, revpi_settings: RevPiSettings, ssh_pass="") -> bool:
|
||||||
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:
|
|
||||||
"""
|
"""
|
||||||
Create a new connection from settings object.
|
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
|
:param ssh_pass: Use this ssh password, if revpi_settings.ssh_use_tunnel is true
|
||||||
:return: True, if the connection was successfully established
|
:return: True, if the connection was successfully established
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# First disconnect to send signal and clean up values
|
# First disconnect to send signal and clean up values
|
||||||
self.pyload_disconnect()
|
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_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_tunnel_port = 0
|
||||||
ssh_pass = ""
|
|
||||||
|
|
||||||
self.program_last_dir_upload = settings.value("last_dir_upload", ".", str)
|
socket.setdefaulttimeout(revpi_settings.timeout)
|
||||||
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()
|
if revpi_settings.ssh_use_tunnel:
|
||||||
|
ssh_tunnel_server = SSHLocalTunnel(
|
||||||
socket.setdefaulttimeout(2)
|
revpi_settings.port,
|
||||||
|
revpi_settings.address,
|
||||||
if ssh_use_tunnel:
|
revpi_settings.ssh_port
|
||||||
while True:
|
)
|
||||||
diag_ssh_auth = SSHAuth(SSHAuthType.PASS, parent)
|
try:
|
||||||
diag_ssh_auth.username = ssh_user
|
ssh_tunnel_port = ssh_tunnel_server.connect_by_credentials(revpi_settings.ssh_user, ssh_pass)
|
||||||
if not diag_ssh_auth.exec() == QtWidgets.QDialog.Accepted:
|
except AuthenticationException:
|
||||||
self._clear_settings()
|
self.connect_error.emit(
|
||||||
return False
|
self.tr("Error"), self.tr(
|
||||||
|
"The combination of username and password was rejected from the SSH server.\n\n"
|
||||||
ssh_user = diag_ssh_auth.username
|
"Try again."
|
||||||
ssh_pass = diag_ssh_auth.password
|
),
|
||||||
ssh_tunnel_server = SSHLocalTunnel(port, address, ssh_port)
|
ConnectionFail.SSH_AUTH,
|
||||||
try:
|
revpi_settings,
|
||||||
ssh_tunnel_port = ssh_tunnel_server.connect_by_credentials(ssh_user, ssh_pass)
|
)
|
||||||
break
|
return False
|
||||||
except AuthenticationException:
|
except Exception as e:
|
||||||
QtWidgets.QMessageBox.critical(
|
# todo: Check some more kinds of exceptions and nice user info
|
||||||
parent, self.tr("Error"), self.tr(
|
self._clear_settings()
|
||||||
"The combination of username and password was rejected from the SSH server.\n\n"
|
self.connect_error.emit(
|
||||||
"Try again."
|
self.tr("Error"), self.tr(
|
||||||
)
|
"Could not establish a SSH connection to server:\n\n{0}"
|
||||||
)
|
).format(str(e)),
|
||||||
except Exception as e:
|
ConnectionFail.SSH_CONNECT,
|
||||||
# todo: Check some more kinds of exceptions and nice user info
|
revpi_settings,
|
||||||
self._clear_settings()
|
)
|
||||||
QtWidgets.QMessageBox.critical(
|
return False
|
||||||
parent, self.tr("Error"), self.tr(
|
|
||||||
"Could not establish a SSH connection to server:\n\n{0}"
|
|
||||||
).format(str(e))
|
|
||||||
)
|
|
||||||
return False
|
|
||||||
|
|
||||||
sp = ServerProxy("http://127.0.0.1:{0}".format(ssh_tunnel_port))
|
sp = ServerProxy("http://127.0.0.1:{0}".format(ssh_tunnel_port))
|
||||||
|
|
||||||
else:
|
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
|
# Load values and test connection to Revolution Pi
|
||||||
try:
|
try:
|
||||||
@@ -315,39 +379,46 @@ class ConnectionManager(QtCore.QThread):
|
|||||||
pi.logger.exception(e)
|
pi.logger.exception(e)
|
||||||
self.connection_error_observed.emit(str(e))
|
self.connection_error_observed.emit(str(e))
|
||||||
|
|
||||||
if not self.ssh_use_tunnel:
|
if revpi_settings.ssh_use_tunnel:
|
||||||
|
self.connect_error.emit(
|
||||||
|
self.tr("Error"), self.tr(
|
||||||
|
"Can not connect to RevPi XML-RPC Service through SSH tunnel! \n\n"
|
||||||
|
"This could have the following reasons: The XML-RPC service is not "
|
||||||
|
"running / not bind to localhost or the ACL permission is not set for "
|
||||||
|
"127.0.0.1!!!"
|
||||||
|
),
|
||||||
|
ConnectionFail.NO_XML_RPC,
|
||||||
|
revpi_settings,
|
||||||
|
)
|
||||||
|
else:
|
||||||
# todo: Change message, that user can use ssh
|
# todo: Change message, that user can use ssh
|
||||||
QtWidgets.QMessageBox.critical(
|
self.connect_error.emit(
|
||||||
parent, self.tr("Error"), self.tr(
|
self.tr("Error"), self.tr(
|
||||||
"Can not connect to RevPi XML-RPC Service! \n\n"
|
"Can not connect to RevPi XML-RPC Service! \n\n"
|
||||||
"This could have the following reasons: The RevPi is not "
|
"This could have the following reasons: The RevPi is not "
|
||||||
"online, the XML-RPC service is not running / bind to "
|
"online, the XML-RPC service is not running / bind to "
|
||||||
"localhost or the ACL permission is not set for your "
|
"localhost or the ACL permission is not set for your "
|
||||||
"IP!!!\n\nRun 'sudo revpipyload_secure_installation' on "
|
"IP!!!\n\nRun 'sudo revpipyload_secure_installation' on "
|
||||||
"Revolution Pi to setup this function!"
|
"Revolution Pi to setup this function!"
|
||||||
)
|
),
|
||||||
|
ConnectionFail.NO_XML_RPC,
|
||||||
|
revpi_settings,
|
||||||
)
|
)
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.address = address
|
self.settings = revpi_settings
|
||||||
self.name = name
|
|
||||||
self.port = port
|
|
||||||
self.ssh_use_tunnel = ssh_use_tunnel
|
|
||||||
self.ssh_port = ssh_port
|
|
||||||
self.ssh_user = ssh_user
|
|
||||||
self.ssh_pass = ssh_pass
|
self.ssh_pass = ssh_pass
|
||||||
self.pyload_version = pyload_version
|
self.pyload_version = pyload_version
|
||||||
self.xml_funcs = xml_funcs
|
self.xml_funcs = xml_funcs
|
||||||
self.xml_mode = xml_mode
|
self.xml_mode = xml_mode
|
||||||
|
|
||||||
with self._lck_cli:
|
with self._lck_cli:
|
||||||
socket.setdefaulttimeout(timeout)
|
|
||||||
self.ssh_tunnel_server = ssh_tunnel_server
|
self.ssh_tunnel_server = ssh_tunnel_server
|
||||||
self._cli = sp
|
self._cli = sp
|
||||||
self._cli_connect.put_nowait((
|
self._cli_connect.put_nowait((
|
||||||
"127.0.0.1" if ssh_use_tunnel else address,
|
"127.0.0.1" if revpi_settings.ssh_use_tunnel else revpi_settings.address,
|
||||||
ssh_tunnel_port if ssh_use_tunnel else port
|
ssh_tunnel_port if revpi_settings.ssh_use_tunnel else revpi_settings.port
|
||||||
))
|
))
|
||||||
|
|
||||||
self.connection_established.emit()
|
self.connection_established.emit()
|
||||||
@@ -371,9 +442,9 @@ class ConnectionManager(QtCore.QThread):
|
|||||||
|
|
||||||
elif self._cli is not None:
|
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.connection_disconnecting.emit()
|
||||||
self._save_settings()
|
self.settings.save_settings()
|
||||||
|
|
||||||
with self._lck_cli:
|
with self._lck_cli:
|
||||||
if self._ps_started:
|
if self._ps_started:
|
||||||
@@ -475,10 +546,14 @@ class ConnectionManager(QtCore.QThread):
|
|||||||
|
|
||||||
if self.ssh_tunnel_server and not self.ssh_tunnel_server.connected:
|
if self.ssh_tunnel_server and not self.ssh_tunnel_server.connected:
|
||||||
self.ssh_tunnel_server.disconnect()
|
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:
|
try:
|
||||||
ssh_tunnel_port = self.ssh_tunnel_server.connect_by_credentials(
|
ssh_tunnel_port = self.ssh_tunnel_server.connect_by_credentials(
|
||||||
self.ssh_user,
|
self.settings.ssh_user,
|
||||||
self.ssh_pass
|
self.ssh_pass
|
||||||
)
|
)
|
||||||
sp = ServerProxy("http://127.0.0.1:{0}".format(ssh_tunnel_port))
|
sp = ServerProxy("http://127.0.0.1:{0}".format(ssh_tunnel_port))
|
||||||
@@ -563,9 +638,9 @@ class ConnectionManager(QtCore.QThread):
|
|||||||
|
|
||||||
Use connection_recovered signal to figure out new parameters.
|
Use connection_recovered signal to figure out new parameters.
|
||||||
"""
|
"""
|
||||||
if not self.ssh_use_tunnel and self.address and self.port:
|
if not self.settings.ssh_use_tunnel and self.settings.address and self.settings.port:
|
||||||
return ServerProxy("http://{0}:{1}".format(self.address, self.port))
|
return ServerProxy("http://{0}:{1}".format(self.settings.address, self.settings.port))
|
||||||
if self.ssh_use_tunnel and self.ssh_tunnel_server and self.ssh_tunnel_server.connected:
|
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 ServerProxy("http://127.0.0.1:{0}".format(self.ssh_tunnel_server.local_tunnel_port))
|
||||||
|
|
||||||
return None
|
return None
|
||||||
@@ -592,8 +667,32 @@ class ConnectionManager(QtCore.QThread):
|
|||||||
cm = ConnectionManager()
|
cm = ConnectionManager()
|
||||||
"""Clobal connection manager instance."""
|
"""Clobal connection manager instance."""
|
||||||
|
|
||||||
settings = QtCore.QSettings("revpipyplc", "revpipyload")
|
|
||||||
"""Global application settings."""
|
|
||||||
|
|
||||||
homedir = environ.get("HOME", "") or environ.get("APPDATA", "")
|
def all_revpi_settings() -> [RevPiSettings]:
|
||||||
"""Home dir of user."""
|
"""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:
|
||||||
|
pi.logger.warning("Could not import saved connection {0}".format(i))
|
||||||
|
|
||||||
|
|
||||||
|
import_old_settings()
|
||||||
|
|||||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
BIN
src/revpicommander/locale/revpicommander_en.qm
Normal file
BIN
src/revpicommander/locale/revpicommander_en.qm
Normal file
Binary file not shown.
@@ -89,11 +89,12 @@ parser.add_argument(
|
|||||||
"-f", "--logfile", dest="logfile",
|
"-f", "--logfile", dest="logfile",
|
||||||
help="Save log entries to this file"
|
help="Save log entries to this file"
|
||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-v", "--verbose", action="count", dest="verbose", default=0,
|
"-v", "--verbose", action="count", dest="verbose", default=0,
|
||||||
help="Switch on verbose logging"
|
help="Switch on verbose logging"
|
||||||
)
|
)
|
||||||
|
# The __main__ script will process the version number argument
|
||||||
|
parser.add_argument("--version", action="store_true", help="Print version number of program and exit")
|
||||||
pargs = parser.parse_args()
|
pargs = parser.parse_args()
|
||||||
|
|
||||||
# Check important objects and set to default if they do not exists
|
# Check important objects and set to default if they do not exists
|
||||||
|
|||||||
@@ -5,27 +5,48 @@
|
|||||||
__author__ = "Sven Sager"
|
__author__ = "Sven Sager"
|
||||||
__copyright__ = "Copyright (C) 2018 Sven Sager"
|
__copyright__ = "Copyright (C) 2018 Sven Sager"
|
||||||
__license__ = "GPLv3"
|
__license__ = "GPLv3"
|
||||||
__version__ = "0.9.10rc1"
|
|
||||||
|
|
||||||
import webbrowser
|
import webbrowser
|
||||||
from os.path import basename, dirname, join
|
from os.path import dirname, join
|
||||||
|
|
||||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||||
|
|
||||||
|
from revpicommander.backgroundworker import BackgroundWaiter
|
||||||
|
from . import __version__
|
||||||
from . import helper
|
from . import helper
|
||||||
from . import proginit as pi
|
from . import proginit as pi
|
||||||
from . import revpilogfile
|
from . import revpilogfile
|
||||||
from .avahisearch import AvahiSearch
|
from .avahisearch import AvahiSearch
|
||||||
from .debugcontrol import DebugControl
|
from .debugcontrol import DebugControl
|
||||||
|
from .helper import ConnectionFail, RevPiSettings
|
||||||
from .revpifiles import RevPiFiles
|
from .revpifiles import RevPiFiles
|
||||||
from .revpiinfo import RevPiInfo
|
from .revpiinfo import RevPiInfo
|
||||||
from .revpioption import RevPiOption
|
from .revpioption import RevPiOption
|
||||||
from .revpiplclist import RevPiPlcList
|
from .revpiplclist import RevPiPlcList
|
||||||
from .revpiprogram import RevPiProgram
|
from .revpiprogram import RevPiProgram
|
||||||
from .simulator import Simulator
|
from .simulator import Simulator
|
||||||
|
from .sshauth import SSHAuth
|
||||||
from .ui.revpicommander_ui import Ui_win_revpicommander
|
from .ui.revpicommander_ui import Ui_win_revpicommander
|
||||||
|
|
||||||
|
|
||||||
|
class ConnectingPyload(QtCore.QThread):
|
||||||
|
"""
|
||||||
|
Try to establish a connection in background.
|
||||||
|
|
||||||
|
The pyload_connect function will emit signals for error or successful connect. This
|
||||||
|
signals will be used to show error messages and return to this function, if the
|
||||||
|
authentication failed.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, revpi_settings: RevPiSettings, ssh_password="", parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
self._revpi_settings = revpi_settings
|
||||||
|
self._ssh_password = ssh_password
|
||||||
|
|
||||||
|
def run(self) -> None:
|
||||||
|
helper.cm.pyload_connect(self._revpi_settings, self._ssh_password)
|
||||||
|
|
||||||
|
|
||||||
class RevPiCommander(QtWidgets.QMainWindow, Ui_win_revpicommander):
|
class RevPiCommander(QtWidgets.QMainWindow, Ui_win_revpicommander):
|
||||||
"""Main application of RevPiCommander."""
|
"""Main application of RevPiCommander."""
|
||||||
|
|
||||||
@@ -53,22 +74,23 @@ class RevPiCommander(QtWidgets.QMainWindow, Ui_win_revpicommander):
|
|||||||
self.win_files = RevPiFiles(self)
|
self.win_files = RevPiFiles(self)
|
||||||
self.win_log = revpilogfile.RevPiLogfile(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.connect_error.connect(self.on_cm_connect_error)
|
||||||
helper.cm.connection_disconnected.connect(self.on_cm_connection_disconnected)
|
helper.cm.connection_disconnected.connect(self.on_cm_connection_disconnected)
|
||||||
helper.cm.connection_disconnecting.connect(self.on_cm_connection_disconnecting)
|
helper.cm.connection_disconnecting.connect(self.on_cm_connection_disconnecting)
|
||||||
helper.cm.connection_established.connect(self.on_cm_connection_established)
|
helper.cm.connection_established.connect(self.on_cm_connection_established)
|
||||||
helper.cm.connection_error_observed.connect(self.on_cm_connection_error_observed)
|
helper.cm.connection_error_observed.connect(self.on_cm_connection_error_observed)
|
||||||
helper.cm.status_changed.connect(self.on_cm_status_changed)
|
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)
|
self.setWindowFlag(QtCore.Qt.WindowMaximizeButtonHint, False)
|
||||||
|
|
||||||
def closeEvent(self, a0: QtGui.QCloseEvent) -> None:
|
def closeEvent(self, a0: QtGui.QCloseEvent) -> None:
|
||||||
pi.logger.debug("RevPiCommander.closeEvent")
|
pi.logger.debug("RevPiCommander.closeEvent")
|
||||||
helper.cm.pyload_disconnect()
|
helper.cm.pyload_disconnect()
|
||||||
helper.settings.setValue("geo", self.saveGeometry())
|
helper.settings.setValue("revpicommander/geo", self.saveGeometry())
|
||||||
|
|
||||||
def _set_gui_control_states(self):
|
def _set_gui_control_states(self):
|
||||||
"""Setup states of actions and buttons."""
|
"""Setup states of actions and buttons."""
|
||||||
@@ -96,8 +118,20 @@ class RevPiCommander(QtWidgets.QMainWindow, Ui_win_revpicommander):
|
|||||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
# region # REGION: Connection management
|
# region # REGION: Connection management
|
||||||
|
|
||||||
def _pyload_connect(self, settings_index: int) -> None:
|
@QtCore.pyqtSlot(str, str, ConnectionFail, RevPiSettings)
|
||||||
helper.cm.pyload_connect(settings_index, self)
|
def on_cm_connect_error(self, title: str, text: str, fail_code: ConnectionFail, revpi_settings: RevPiSettings):
|
||||||
|
"""
|
||||||
|
Slot to get information of pyload_connect connection errors.
|
||||||
|
|
||||||
|
:param title: Title of error message
|
||||||
|
:param text: Text of error message
|
||||||
|
:param fail_code: Type of error
|
||||||
|
:param revpi_settings: Settings of the revpi with the error
|
||||||
|
"""
|
||||||
|
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):
|
||||||
@@ -148,8 +182,8 @@ class RevPiCommander(QtWidgets.QMainWindow, Ui_win_revpicommander):
|
|||||||
helper.cm.simulating_procimg,
|
helper.cm.simulating_procimg,
|
||||||
))
|
))
|
||||||
else:
|
else:
|
||||||
self.txt_host.setText(helper.cm.name)
|
self.txt_host.setText(helper.cm.settings.name)
|
||||||
self.txt_connection.setText(helper.cm.address)
|
self.txt_connection.setText(helper.cm.settings.address)
|
||||||
self.win_files = RevPiFiles(self)
|
self.win_files = RevPiFiles(self)
|
||||||
|
|
||||||
@QtCore.pyqtSlot(str, str)
|
@QtCore.pyqtSlot(str, str)
|
||||||
@@ -169,33 +203,74 @@ class RevPiCommander(QtWidgets.QMainWindow, Ui_win_revpicommander):
|
|||||||
self.men_connections.clear()
|
self.men_connections.clear()
|
||||||
self.dict_men_connections_subfolder.clear()
|
self.dict_men_connections_subfolder.clear()
|
||||||
|
|
||||||
for i in range(helper.settings.beginReadArray("connections")):
|
for settings in helper.all_revpi_settings(): # type: RevPiSettings
|
||||||
helper.settings.setArrayIndex(i)
|
if settings.folder:
|
||||||
|
if settings.folder not in self.dict_men_connections_subfolder:
|
||||||
if helper.settings.value("folder"):
|
|
||||||
if helper.settings.value("folder") not in self.dict_men_connections_subfolder:
|
|
||||||
men_sub = QtWidgets.QMenu(self.men_connections)
|
men_sub = QtWidgets.QMenu(self.men_connections)
|
||||||
men_sub.setTitle(helper.settings.value("folder"))
|
men_sub.setTitle(settings.folder)
|
||||||
self.dict_men_connections_subfolder[helper.settings.value("folder")] = men_sub
|
self.dict_men_connections_subfolder[settings.folder] = men_sub
|
||||||
self.men_connections.addMenu(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:
|
else:
|
||||||
parent_menu = self.men_connections
|
parent_menu = self.men_connections
|
||||||
|
|
||||||
display_name = helper.settings.value("name")
|
display_name = settings.name
|
||||||
if helper.settings.value("ssh_use_tunnel", False, bool):
|
if settings.ssh_use_tunnel:
|
||||||
display_name += " (SSH)"
|
display_name += " (SSH)"
|
||||||
|
|
||||||
act = QtWidgets.QAction(parent_menu)
|
act = QtWidgets.QAction(parent_menu)
|
||||||
act.setText(display_name)
|
act.setText(display_name)
|
||||||
act.setData(i)
|
act.setData(settings)
|
||||||
act.setToolTip("{0}:{1}".format(
|
act.setToolTip("{0}:{1}".format(settings.address, settings.port))
|
||||||
helper.settings.value("address"),
|
|
||||||
helper.settings.value("port"),
|
|
||||||
))
|
|
||||||
parent_menu.addAction(act)
|
parent_menu.addAction(act)
|
||||||
|
|
||||||
helper.settings.endArray()
|
def _pyload_connect(self, revpi_settings: RevPiSettings, remove_saved_ssh_password=False):
|
||||||
|
"""
|
||||||
|
Try to async establish a connection to Revolution Pi.
|
||||||
|
|
||||||
|
:param revpi_settings: RevPi settings object
|
||||||
|
:param remove_saved_ssh_password: Remove password from keychain
|
||||||
|
"""
|
||||||
|
ssh_password = ""
|
||||||
|
|
||||||
|
diag_connecting = BackgroundWaiter(
|
||||||
|
revpi_settings.timeout,
|
||||||
|
self.tr("Establish a connection to the Revolution Pi..."),
|
||||||
|
self,
|
||||||
|
self.tr("Revolution Pi connected!"),
|
||||||
|
)
|
||||||
|
helper.cm.connection_established.connect(diag_connecting.requestInterruption)
|
||||||
|
|
||||||
|
if revpi_settings.ssh_use_tunnel:
|
||||||
|
diag_ssh_auth = SSHAuth(
|
||||||
|
revpi_settings.ssh_user,
|
||||||
|
"{0}.{1}_{2}".format(
|
||||||
|
helper.settings.applicationName(),
|
||||||
|
helper.settings.organizationName(),
|
||||||
|
revpi_settings.internal_id),
|
||||||
|
self,
|
||||||
|
)
|
||||||
|
|
||||||
|
if remove_saved_ssh_password and revpi_settings.ssh_saved_password:
|
||||||
|
diag_ssh_auth.remove_saved_password()
|
||||||
|
revpi_settings.ssh_saved_password = False
|
||||||
|
|
||||||
|
# Doesn't matter what user selects, we have to save settings to sync keychain and values
|
||||||
|
if diag_ssh_auth.exec() != QtWidgets.QDialog.Accepted:
|
||||||
|
revpi_settings.save_settings()
|
||||||
|
return
|
||||||
|
|
||||||
|
revpi_settings.ssh_saved_password = diag_ssh_auth.in_keyring
|
||||||
|
revpi_settings.ssh_user = diag_ssh_auth.username
|
||||||
|
ssh_password = diag_ssh_auth.password
|
||||||
|
revpi_settings.save_settings()
|
||||||
|
|
||||||
|
# Connect in background and show the connecting dialog to user
|
||||||
|
th_connecting = ConnectingPyload(revpi_settings, ssh_password, self)
|
||||||
|
th_connecting.finished.connect(diag_connecting.requestInterruption)
|
||||||
|
th_connecting.start()
|
||||||
|
|
||||||
|
diag_connecting.exec_dialog(self.tr("Connecting..."), False)
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def on_act_connections_triggered(self):
|
def on_act_connections_triggered(self):
|
||||||
@@ -207,8 +282,11 @@ class RevPiCommander(QtWidgets.QMainWindow, Ui_win_revpicommander):
|
|||||||
def on_act_search_triggered(self):
|
def on_act_search_triggered(self):
|
||||||
"""Search for Revolution Pi with zero conf."""
|
"""Search for Revolution Pi with zero conf."""
|
||||||
if self.diag_search.exec() == QtWidgets.QDialog.Accepted:
|
if self.diag_search.exec() == QtWidgets.QDialog.Accepted:
|
||||||
if self.diag_search.connect_index >= 0:
|
if self.diag_search.connect_settings:
|
||||||
self._pyload_connect(self.diag_search.connect_index)
|
if self.diag_search.just_save:
|
||||||
|
self.diag_connections.exec_with_presets(self.diag_search.connect_settings)
|
||||||
|
else:
|
||||||
|
self._pyload_connect(self.diag_search.connect_settings)
|
||||||
|
|
||||||
self._load_men_connections()
|
self._load_men_connections()
|
||||||
|
|
||||||
@@ -506,4 +584,5 @@ def main() -> int:
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
|||||||
@@ -43,14 +43,13 @@ class UploadFiles(BackgroundWorker):
|
|||||||
progress_counter += 1
|
progress_counter += 1
|
||||||
|
|
||||||
# Remove base dir of file to set relative for PyLoad
|
# 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)
|
self.status_message.emit(send_name)
|
||||||
|
|
||||||
# Check whether this is the auto start program
|
# Check whether this is the auto start program
|
||||||
if send_name == opt_program:
|
if send_name == opt_program:
|
||||||
self.plc_program_included = True
|
self.plc_program_included = True
|
||||||
|
|
||||||
|
|
||||||
# Transfer file
|
# Transfer file
|
||||||
try:
|
try:
|
||||||
with open(file_name, "rb") as fh:
|
with open(file_name, "rb") as fh:
|
||||||
@@ -83,7 +82,7 @@ class RevPiFiles(QtWidgets.QMainWindow, Ui_win_files):
|
|||||||
self.dc_settings = {}
|
self.dc_settings = {}
|
||||||
self.tree_files_counter = 0
|
self.tree_files_counter = 0
|
||||||
self.tree_files_counter_max = 10000
|
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.lbl_path_local.setToolTip(self.lbl_path_local.text())
|
||||||
|
|
||||||
self.btn_all.setEnabled(False)
|
self.btn_all.setEnabled(False)
|
||||||
@@ -91,7 +90,7 @@ class RevPiFiles(QtWidgets.QMainWindow, Ui_win_files):
|
|||||||
self.btn_to_right.setEnabled(False)
|
self.btn_to_right.setEnabled(False)
|
||||||
self.btn_delete_revpi.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)
|
self._load_files_local(True)
|
||||||
if helper.cm.connected:
|
if helper.cm.connected:
|
||||||
self._load_files_revpi(True)
|
self._load_files_revpi(True)
|
||||||
@@ -125,7 +124,7 @@ class RevPiFiles(QtWidgets.QMainWindow, Ui_win_files):
|
|||||||
return
|
return
|
||||||
|
|
||||||
uploader = UploadFiles(self.file_list_local(), self)
|
uploader = UploadFiles(self.file_list_local(), self)
|
||||||
if uploader.exec_dialog() == QtWidgets.QDialog.Rejected:
|
if uploader.exec_dialog(self.tr("File transfer...")) == QtWidgets.QDialog.Rejected:
|
||||||
return
|
return
|
||||||
|
|
||||||
if uploader.ec == 0:
|
if uploader.ec == 0:
|
||||||
@@ -176,7 +175,7 @@ class RevPiFiles(QtWidgets.QMainWindow, Ui_win_files):
|
|||||||
if "plcdownload_file" not in helper.cm.xml_funcs:
|
if "plcdownload_file" not in helper.cm.xml_funcs:
|
||||||
self.btn_to_left.setEnabled(False)
|
self.btn_to_left.setEnabled(False)
|
||||||
self.btn_to_left.setToolTip(self.tr("The RevPiPyLoad version on the Revolution Pi is to old."))
|
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.setEnabled(False)
|
||||||
self.btn_to_left.setToolTip(self.tr("Choose a local directory first."))
|
self.btn_to_left.setToolTip(self.tr("Choose a local directory first."))
|
||||||
else:
|
else:
|
||||||
@@ -208,7 +207,7 @@ class RevPiFiles(QtWidgets.QMainWindow, Ui_win_files):
|
|||||||
elif item.type() == NodeType.FILE:
|
elif item.type() == NodeType.FILE:
|
||||||
item.setSelected(value)
|
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."""
|
"""Manager vor item selection of three views."""
|
||||||
item = tree_view.currentItem()
|
item = tree_view.currentItem()
|
||||||
if item is None:
|
if item is None:
|
||||||
@@ -231,7 +230,7 @@ class RevPiFiles(QtWidgets.QMainWindow, Ui_win_files):
|
|||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def on_tree_files_local_itemSelectionChanged(self):
|
def on_tree_files_local_itemSelectionChanged(self):
|
||||||
self.__item_selection_changed(self.tree_files_local)
|
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()
|
@QtCore.pyqtSlot()
|
||||||
def on_tree_files_revpi_itemSelectionChanged(self):
|
def on_tree_files_revpi_itemSelectionChanged(self):
|
||||||
@@ -288,7 +287,7 @@ class RevPiFiles(QtWidgets.QMainWindow, Ui_win_files):
|
|||||||
else:
|
else:
|
||||||
self.tree_files_local.addTopLevelItem(item)
|
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)
|
self._parent_selection_state(item)
|
||||||
|
|
||||||
def _load_files_local(self, silent=False):
|
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_counter = 0
|
||||||
self.tree_files_local.blockSignals(True)
|
self.tree_files_local.blockSignals(True)
|
||||||
self.tree_files_local.clear()
|
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.sortItems(0, QtCore.Qt.AscendingOrder)
|
||||||
self.tree_files_local.blockSignals(False)
|
self.tree_files_local.blockSignals(False)
|
||||||
|
|
||||||
@@ -435,18 +434,18 @@ class RevPiFiles(QtWidgets.QMainWindow, Ui_win_files):
|
|||||||
# endregion # # # # #
|
# endregion # # # # #
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def on_btn_all_pressed(self):
|
def on_btn_all_clicked(self):
|
||||||
pi.logger.debug("RevPiFiles.on_btn_all_pressed")
|
pi.logger.debug("RevPiFiles.on_btn_all_clicked")
|
||||||
self._do_my_job(True)
|
self._do_my_job(True)
|
||||||
self.file_list_revpi()
|
self.file_list_revpi()
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def on_btn_select_local_pressed(self):
|
def on_btn_select_local_clicked(self):
|
||||||
pi.logger.debug("RevPiFiles.on_btn_select_pressed")
|
pi.logger.debug("RevPiFiles.on_btn_select_clicked")
|
||||||
|
|
||||||
diag_folder = QtWidgets.QFileDialog(
|
diag_folder = QtWidgets.QFileDialog(
|
||||||
self, self.tr("Select folder..."),
|
self, self.tr("Select folder..."),
|
||||||
helper.cm.develop_watch_path,
|
helper.cm.settings.watch_path,
|
||||||
)
|
)
|
||||||
diag_folder.setFileMode(QtWidgets.QFileDialog.DirectoryOnly)
|
diag_folder.setFileMode(QtWidgets.QFileDialog.DirectoryOnly)
|
||||||
if diag_folder.exec() != QtWidgets.QFileDialog.Accepted:
|
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."
|
"Can not access the folder '{0}' to read files."
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
helper.cm.develop_watch_files = []
|
helper.cm.settings.watch_files = []
|
||||||
helper.cm.develop_watch_path = ""
|
helper.cm.settings.watch_path = ""
|
||||||
return
|
return
|
||||||
|
|
||||||
self.lbl_path_local.setText(selected_dir)
|
self.lbl_path_local.setText(selected_dir)
|
||||||
self.lbl_path_local.setToolTip(self.lbl_path_local.text())
|
self.lbl_path_local.setToolTip(self.lbl_path_local.text())
|
||||||
helper.cm.develop_watch_path = selected_dir
|
helper.cm.settings.watch_path = selected_dir
|
||||||
helper.cm.develop_watch_files = []
|
helper.cm.settings.watch_files = []
|
||||||
|
|
||||||
self._load_files_local(False)
|
self._load_files_local(False)
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def on_btn_refresh_local_pressed(self):
|
def on_btn_refresh_local_clicked(self):
|
||||||
pi.logger.debug("RevPiFiles.on_btn_refresh_pressed")
|
pi.logger.debug("RevPiFiles.on_btn_refresh_clicked")
|
||||||
self._load_files_local(False)
|
self._load_files_local(False)
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def on_btn_refresh_revpi_pressed(self):
|
def on_btn_refresh_revpi_clicked(self):
|
||||||
pi.logger.debug("RevPiFiles.on_btn_refresh_revpi_pressed")
|
pi.logger.debug("RevPiFiles.on_btn_refresh_revpi_clicked")
|
||||||
self._load_files_revpi(False)
|
self._load_files_revpi(False)
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def on_btn_to_right_pressed(self):
|
def on_btn_to_right_clicked(self):
|
||||||
"""Upload selected files to revolution pi."""
|
"""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._do_my_job(False)
|
||||||
self._load_files_revpi(True)
|
self._load_files_revpi(True)
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def on_btn_to_left_pressed(self):
|
def on_btn_to_left_clicked(self):
|
||||||
"""Download selected file."""
|
"""Download selected file."""
|
||||||
pi.logger.debug("RevPiFiles.on_btn_to_left_pressed")
|
pi.logger.debug("RevPiFiles.on_btn_to_left_clicked")
|
||||||
|
|
||||||
override = None
|
override = None
|
||||||
for item in self.tree_files_revpi.selectedItems():
|
for item in self.tree_files_revpi.selectedItems():
|
||||||
@@ -511,7 +510,7 @@ class RevPiFiles(QtWidgets.QMainWindow, Ui_win_files):
|
|||||||
).format(file_name)
|
).format(file_name)
|
||||||
)
|
)
|
||||||
else:
|
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):
|
if override is None and os.path.exists(file_name):
|
||||||
rc_diag = QtWidgets.QMessageBox.question(
|
rc_diag = QtWidgets.QMessageBox.question(
|
||||||
self, self.tr("Override files..."), self.tr(
|
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)
|
os.makedirs(os.path.dirname(file_name), exist_ok=True)
|
||||||
file_data = gzip.decompress(rc)
|
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)
|
fh.write(file_data)
|
||||||
|
|
||||||
self._load_files_local()
|
self._load_files_local()
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@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."""
|
"""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 = []
|
lst_delete = []
|
||||||
for item in self.tree_files_revpi.selectedItems():
|
for item in self.tree_files_revpi.selectedItems():
|
||||||
|
|||||||
@@ -166,12 +166,12 @@ class RevPiLogfile(QtWidgets.QMainWindow, Ui_win_revpilogfile):
|
|||||||
self.th_data.resume()
|
self.th_data.resume()
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def on_btn_daemon_pressed(self):
|
def on_btn_daemon_clicked(self):
|
||||||
"""Clear the daemon log view."""
|
"""Clear the daemon log view."""
|
||||||
self.txt_daemon.clear()
|
self.txt_daemon.clear()
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def on_btn_app_pressed(self):
|
def on_btn_app_clicked(self):
|
||||||
"""Clear the app log view."""
|
"""Clear the app log view."""
|
||||||
self.txt_app.clear()
|
self.txt_app.clear()
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,13 @@ __license__ = "GPLv3"
|
|||||||
|
|
||||||
from enum import IntEnum
|
from enum import IntEnum
|
||||||
|
|
||||||
|
import keyring
|
||||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||||
|
from keyring.errors import KeyringError
|
||||||
|
|
||||||
|
from . import helper
|
||||||
from . import proginit as pi
|
from . import proginit as pi
|
||||||
from .helper import WidgetData, settings
|
from .helper import RevPiSettings, WidgetData
|
||||||
from .ui.revpiplclist_ui import Ui_diag_connections
|
from .ui.revpiplclist_ui import Ui_diag_connections
|
||||||
|
|
||||||
|
|
||||||
@@ -24,55 +27,56 @@ class RevPiPlcList(QtWidgets.QDialog, Ui_diag_connections):
|
|||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super(RevPiPlcList, self).__init__(parent)
|
super(RevPiPlcList, self).__init__(parent)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
self.__default_name = self.tr("New connection")
|
|
||||||
self.__default_port = 55123
|
self.__default_port = 55123
|
||||||
|
|
||||||
self.__current_item = QtWidgets.QTreeWidgetItem() # type: QtWidgets.QTreeWidgetItem
|
self.__current_item = QtWidgets.QTreeWidgetItem() # type: QtWidgets.QTreeWidgetItem
|
||||||
self.changes = True
|
self.changes = True
|
||||||
|
self._keyring_cleanup_id_user = []
|
||||||
|
|
||||||
self.tre_connections.setColumnWidth(0, 250)
|
self.tre_connections.setColumnWidth(0, 250)
|
||||||
self.lbl_port.setText(self.lbl_port.text().format(self.__default_port))
|
self.lbl_port.setText(self.lbl_port.text().format(self.__default_port))
|
||||||
self.sbx_port.setValue(self.__default_port)
|
self.sbx_port.setValue(self.__default_port)
|
||||||
|
|
||||||
|
# Dirty workaround to remove default button to prevent action on ENTER key, while user edit texts
|
||||||
|
self.__btn_dummy = QtWidgets.QPushButton(self)
|
||||||
|
self.__btn_dummy.setVisible(False)
|
||||||
|
self.__btn_dummy.setDefault(True)
|
||||||
|
|
||||||
|
def _load_cbb_folder(self):
|
||||||
|
"""Clean up all entries and reload existing ones from treeview."""
|
||||||
|
self.cbb_folder.blockSignals(True)
|
||||||
|
|
||||||
|
self.cbb_folder.clear()
|
||||||
|
self.cbb_folder.addItem("")
|
||||||
|
for i in range(self.tre_connections.topLevelItemCount()):
|
||||||
|
item = self.tre_connections.topLevelItem(i)
|
||||||
|
if item.type() != NodeType.DIR:
|
||||||
|
continue
|
||||||
|
self.cbb_folder.addItem(item.text(0))
|
||||||
|
|
||||||
|
self.cbb_folder.blockSignals(False)
|
||||||
|
|
||||||
def _load_settings(self):
|
def _load_settings(self):
|
||||||
"""Load values to GUI widgets."""
|
"""Load values to GUI widgets."""
|
||||||
pi.logger.debug("RevPiPlcList._load_settings")
|
pi.logger.debug("RevPiPlcList._load_settings")
|
||||||
|
|
||||||
self.tre_connections.clear()
|
self.tre_connections.clear()
|
||||||
self.cbb_folder.clear()
|
|
||||||
self.cbb_folder.addItem("")
|
# Get length of array and close it, the RevPiSettings-class need it
|
||||||
for i in range(settings.beginReadArray("connections")):
|
count_settings = helper.settings.beginReadArray("connections")
|
||||||
settings.setArrayIndex(i)
|
helper.settings.endArray()
|
||||||
|
|
||||||
|
for i in range(count_settings):
|
||||||
|
settings = RevPiSettings(i)
|
||||||
|
|
||||||
con_item = QtWidgets.QTreeWidgetItem(NodeType.CON)
|
con_item = QtWidgets.QTreeWidgetItem(NodeType.CON)
|
||||||
con_item.setIcon(0, QtGui.QIcon(":/main/ico/cpu.ico"))
|
con_item.setIcon(0, QtGui.QIcon(":/main/ico/cpu.ico"))
|
||||||
con_item.setText(0, settings.value("name", "Revolution Pi", str))
|
con_item.setText(0, settings.name)
|
||||||
con_item.setText(1, settings.value("address", "127.0.0.1", str))
|
con_item.setText(1, settings.address)
|
||||||
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.setData(0, WidgetData.ssh_use_tunnel, settings.value("ssh_use_tunnel", False, bool))
|
con_item.setData(0, WidgetData.revpi_settings, settings)
|
||||||
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.last_dir_upload, settings.value("last_dir_upload"))
|
folder = settings.folder
|
||||||
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)
|
|
||||||
if folder:
|
if folder:
|
||||||
sub_folder = self._get_folder_item(folder)
|
sub_folder = self._get_folder_item(folder)
|
||||||
if sub_folder is None:
|
if sub_folder is None:
|
||||||
@@ -80,74 +84,44 @@ class RevPiPlcList(QtWidgets.QDialog, Ui_diag_connections):
|
|||||||
sub_folder.setIcon(0, QtGui.QIcon(":/main/ico/folder.ico"))
|
sub_folder.setIcon(0, QtGui.QIcon(":/main/ico/folder.ico"))
|
||||||
sub_folder.setText(0, folder)
|
sub_folder.setText(0, folder)
|
||||||
self.tre_connections.addTopLevelItem(sub_folder)
|
self.tre_connections.addTopLevelItem(sub_folder)
|
||||||
self.cbb_folder.addItem(folder)
|
|
||||||
|
|
||||||
sub_folder.addChild(con_item)
|
sub_folder.addChild(con_item)
|
||||||
else:
|
else:
|
||||||
self.tre_connections.addTopLevelItem(con_item)
|
self.tre_connections.addTopLevelItem(con_item)
|
||||||
|
|
||||||
settings.endArray()
|
|
||||||
|
|
||||||
self.tre_connections.expandAll()
|
self.tre_connections.expandAll()
|
||||||
self.changes = True
|
self.changes = False
|
||||||
|
|
||||||
if self.tre_connections.topLevelItemCount() == 0:
|
self._edit_state()
|
||||||
self._edit_state()
|
|
||||||
|
|
||||||
def accept(self) -> None:
|
def accept(self) -> None:
|
||||||
pi.logger.debug("RevPiPlcList.accept")
|
pi.logger.debug("RevPiPlcList.accept")
|
||||||
|
|
||||||
def set_settings(node: QtWidgets.QTreeWidgetItem):
|
for internal_id, ssh_user in self._keyring_cleanup_id_user:
|
||||||
parent = node.parent()
|
service_name = "{0}.{1}_{2}".format(
|
||||||
settings.setValue("address", node.text(1))
|
helper.settings.applicationName(),
|
||||||
settings.setValue("folder", parent.text(0) if parent else "")
|
helper.settings.organizationName(),
|
||||||
settings.setValue("name", node.text(0))
|
internal_id
|
||||||
settings.setValue("port", node.data(0, WidgetData.port))
|
)
|
||||||
settings.setValue("timeout", node.data(0, WidgetData.timeout))
|
try:
|
||||||
settings.setValue("ssh_use_tunnel", node.data(0, WidgetData.ssh_use_tunnel))
|
# Remove information from os keyring, which we collected on_btn_delete_clicked
|
||||||
settings.setValue("ssh_port", node.data(0, WidgetData.ssh_port))
|
keyring.delete_password(service_name, ssh_user)
|
||||||
settings.setValue("ssh_user", node.data(0, WidgetData.ssh_user))
|
except KeyringError as e:
|
||||||
|
pi.logger.error(e)
|
||||||
|
|
||||||
if node.data(0, WidgetData.last_dir_upload):
|
helper.settings.remove("connections")
|
||||||
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))
|
|
||||||
|
|
||||||
settings.remove("connections")
|
|
||||||
settings.beginWriteArray("connections")
|
|
||||||
|
|
||||||
counter_index = 0
|
|
||||||
for i in range(self.tre_connections.topLevelItemCount()):
|
for i in range(self.tre_connections.topLevelItemCount()):
|
||||||
root_item = self.tre_connections.topLevelItem(i)
|
root_item = self.tre_connections.topLevelItem(i)
|
||||||
if root_item.type() == NodeType.DIR:
|
if root_item.type() == NodeType.DIR:
|
||||||
for k in range(root_item.childCount()):
|
for k in range(root_item.childCount()):
|
||||||
settings.setArrayIndex(counter_index)
|
revpi_settings = root_item.child(k).data(0, WidgetData.revpi_settings) # type: RevPiSettings
|
||||||
set_settings(root_item.child(k))
|
revpi_settings.folder = root_item.text(0)
|
||||||
counter_index += 1
|
revpi_settings.save_settings()
|
||||||
elif root_item.type() == NodeType.CON:
|
elif root_item.type() == NodeType.CON:
|
||||||
settings.setArrayIndex(counter_index)
|
revpi_settings = root_item.data(0, WidgetData.revpi_settings) # type: RevPiSettings
|
||||||
set_settings(root_item)
|
revpi_settings.folder = ""
|
||||||
counter_index += 1
|
revpi_settings.save_settings()
|
||||||
|
|
||||||
settings.endArray()
|
|
||||||
|
|
||||||
self.changes = False
|
self.changes = False
|
||||||
super(RevPiPlcList, self).accept()
|
super(RevPiPlcList, self).accept()
|
||||||
@@ -170,6 +144,17 @@ class RevPiPlcList(QtWidgets.QDialog, Ui_diag_connections):
|
|||||||
self._load_settings()
|
self._load_settings()
|
||||||
return super(RevPiPlcList, self).exec()
|
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)
|
@QtCore.pyqtSlot(QtWidgets.QAbstractButton)
|
||||||
def on_btn_box_clicked(self, button: QtWidgets.QAbstractButton):
|
def on_btn_box_clicked(self, button: QtWidgets.QAbstractButton):
|
||||||
if self.btn_box.buttonRole(button) == QtWidgets.QDialogButtonBox.DestructiveRole:
|
if self.btn_box.buttonRole(button) == QtWidgets.QDialogButtonBox.DestructiveRole:
|
||||||
@@ -179,6 +164,9 @@ class RevPiPlcList(QtWidgets.QDialog, Ui_diag_connections):
|
|||||||
# region # REGION: Connection management
|
# region # REGION: Connection management
|
||||||
|
|
||||||
def _edit_state(self):
|
def _edit_state(self):
|
||||||
|
"""Set enabled status of all controls, depending on selected item."""
|
||||||
|
pi.logger.debug("RevPiPlcList._edit_state")
|
||||||
|
|
||||||
item = self.tre_connections.currentItem()
|
item = self.tre_connections.currentItem()
|
||||||
if item is None:
|
if item is None:
|
||||||
up_ok = False
|
up_ok = False
|
||||||
@@ -200,12 +188,16 @@ class RevPiPlcList(QtWidgets.QDialog, Ui_diag_connections):
|
|||||||
|
|
||||||
self.btn_up.setEnabled(up_ok)
|
self.btn_up.setEnabled(up_ok)
|
||||||
self.btn_down.setEnabled(down_ok)
|
self.btn_down.setEnabled(down_ok)
|
||||||
self.btn_delete.setEnabled(con_item)
|
self.btn_delete.setEnabled(con_item or dir_item)
|
||||||
self.txt_name.setEnabled(con_item)
|
self.txt_name.setEnabled(con_item)
|
||||||
self.txt_address.setEnabled(con_item)
|
self.txt_address.setEnabled(con_item)
|
||||||
self.sbx_port.setEnabled(con_item)
|
self.sbx_port.setEnabled(con_item)
|
||||||
self.sbx_timeout.setEnabled(con_item)
|
self.sbx_timeout.setEnabled(con_item)
|
||||||
self.cbb_folder.setEnabled(con_item or dir_item)
|
self.cbb_folder.setEnabled(con_item or dir_item)
|
||||||
|
self.cbb_folder.setEditable(dir_item)
|
||||||
|
if self.cbb_folder.isEditable():
|
||||||
|
# Disable auto complete, this would override a new typed name with existing one
|
||||||
|
self.cbb_folder.setCompleter(None)
|
||||||
|
|
||||||
self.cbx_ssh_use_tunnel.setEnabled(con_item)
|
self.cbx_ssh_use_tunnel.setEnabled(con_item)
|
||||||
self.sbx_ssh_port.setEnabled(con_item)
|
self.sbx_ssh_port.setEnabled(con_item)
|
||||||
@@ -238,50 +230,63 @@ class RevPiPlcList(QtWidgets.QDialog, Ui_diag_connections):
|
|||||||
if 0 <= index < self.tre_connections.topLevelItemCount():
|
if 0 <= index < self.tre_connections.topLevelItemCount():
|
||||||
item = self.tre_connections.takeTopLevelItem(index)
|
item = self.tre_connections.takeTopLevelItem(index)
|
||||||
self.tre_connections.insertTopLevelItem(new_index, item)
|
self.tre_connections.insertTopLevelItem(new_index, item)
|
||||||
|
if item.type() == NodeType.DIR:
|
||||||
|
# Expand a moved dir node, it would be collapsed after move
|
||||||
|
self.tre_connections.expandItem(item)
|
||||||
|
|
||||||
self.tre_connections.setCurrentItem(item)
|
self.tre_connections.setCurrentItem(item)
|
||||||
self._edit_state()
|
|
||||||
|
|
||||||
@QtCore.pyqtSlot(QtWidgets.QTreeWidgetItem, QtWidgets.QTreeWidgetItem)
|
@QtCore.pyqtSlot(QtWidgets.QTreeWidgetItem, QtWidgets.QTreeWidgetItem)
|
||||||
def on_tre_connections_currentItemChanged(
|
def on_tre_connections_currentItemChanged(
|
||||||
self, current: QtWidgets.QTreeWidgetItem, previous: QtWidgets.QTreeWidgetItem):
|
self, current: QtWidgets.QTreeWidgetItem, previous: QtWidgets.QTreeWidgetItem):
|
||||||
|
|
||||||
self._edit_state()
|
self._edit_state()
|
||||||
|
self._load_cbb_folder()
|
||||||
|
|
||||||
if current and current.type() == NodeType.CON:
|
if current and current.type() == NodeType.CON:
|
||||||
self.__current_item = current
|
self.__current_item = current
|
||||||
self.txt_name.setText(current.text(0))
|
|
||||||
self.txt_address.setText(current.text(1))
|
settings = current.data(0, WidgetData.revpi_settings) # type: RevPiSettings
|
||||||
self.sbx_port.setValue(current.data(0, WidgetData.port))
|
self.txt_name.setText(settings.name)
|
||||||
self.sbx_timeout.setValue(current.data(0, WidgetData.timeout))
|
self.txt_address.setText(settings.address)
|
||||||
|
self.sbx_port.setValue(settings.port)
|
||||||
|
self.sbx_timeout.setValue(settings.timeout)
|
||||||
if current.parent() is None:
|
if current.parent() is None:
|
||||||
self.cbb_folder.setCurrentIndex(0)
|
self.cbb_folder.setCurrentIndex(0)
|
||||||
else:
|
else:
|
||||||
self.cbb_folder.setCurrentText(current.parent().text(0))
|
self.cbb_folder.setCurrentText(current.parent().text(0))
|
||||||
|
|
||||||
self.cbx_ssh_use_tunnel.setChecked(current.data(0, WidgetData.ssh_use_tunnel))
|
self.cbx_ssh_use_tunnel.setChecked(settings.ssh_use_tunnel)
|
||||||
self.sbx_ssh_port.setValue(current.data(0, WidgetData.ssh_port))
|
self.sbx_ssh_port.setValue(settings.ssh_port)
|
||||||
self.txt_ssh_user.setText(current.data(0, WidgetData.ssh_user))
|
self.txt_ssh_user.setText(settings.ssh_user)
|
||||||
|
|
||||||
elif current and current.type() == NodeType.DIR:
|
elif current and current.type() == NodeType.DIR:
|
||||||
self.__current_item = current
|
self.__current_item = current
|
||||||
self.cbb_folder.setCurrentText(current.text(0))
|
self.cbb_folder.setCurrentText(current.text(0))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.__current_item = QtWidgets.QTreeWidgetItem()
|
self.__current_item = QtWidgets.QTreeWidgetItem()
|
||||||
self.cbb_folder.setCurrentText(current.text(0) if current else "")
|
self.cbb_folder.setCurrentText(current.text(0) if current else "")
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def on_btn_up_pressed(self):
|
def on_btn_up_clicked(self):
|
||||||
self._move_item(-1)
|
self._move_item(-1)
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def on_btn_down_pressed(self):
|
def on_btn_down_clicked(self):
|
||||||
self._move_item(1)
|
self._move_item(1)
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def on_btn_delete_pressed(self):
|
def on_btn_delete_clicked(self):
|
||||||
"""Remove selected entry."""
|
"""Remove selected entry."""
|
||||||
item = self.tre_connections.currentItem()
|
|
||||||
if item and item.type() == NodeType.CON:
|
def remove_item(item: QtWidgets.QTreeWidgetItem):
|
||||||
|
"""Remove CON item and save keyring actions for save action."""
|
||||||
|
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()
|
dir_node = item.parent()
|
||||||
if dir_node:
|
if dir_node:
|
||||||
dir_node.removeChild(item)
|
dir_node.removeChild(item)
|
||||||
@@ -289,130 +294,160 @@ class RevPiPlcList(QtWidgets.QDialog, Ui_diag_connections):
|
|||||||
index = self.tre_connections.indexOfTopLevelItem(item)
|
index = self.tre_connections.indexOfTopLevelItem(item)
|
||||||
self.tre_connections.takeTopLevelItem(index)
|
self.tre_connections.takeTopLevelItem(index)
|
||||||
|
|
||||||
self._edit_state()
|
item_to_remove = self.tre_connections.currentItem()
|
||||||
|
|
||||||
|
if item_to_remove and item_to_remove.type() == NodeType.DIR:
|
||||||
|
if item_to_remove.childCount():
|
||||||
|
rc = QtWidgets.QMessageBox.question(
|
||||||
|
self, self.tr("Question"), self.tr(
|
||||||
|
"If you remote this folder, all containing elements will be removed, too. \n\n"
|
||||||
|
"Do you want to delete folder and all elements?"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
if rc != QtWidgets.QMessageBox.Yes:
|
||||||
|
return
|
||||||
|
|
||||||
|
while item_to_remove.childCount() > 0:
|
||||||
|
remove_item(item_to_remove.child(0))
|
||||||
|
|
||||||
|
item_index = self.tre_connections.indexOfTopLevelItem(item_to_remove)
|
||||||
|
self.tre_connections.takeTopLevelItem(item_index)
|
||||||
|
|
||||||
|
elif item_to_remove and item_to_remove.type() == NodeType.CON:
|
||||||
|
remove_item(item_to_remove)
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def on_btn_add_pressed(self):
|
def on_btn_add_clicked(self, settings_preset: RevPiSettings = None):
|
||||||
"""Create new element."""
|
"""Create new element."""
|
||||||
self.__current_item = QtWidgets.QTreeWidgetItem(NodeType.CON)
|
settings = settings_preset or RevPiSettings()
|
||||||
self.__current_item.setIcon(0, QtGui.QIcon(":/main/ico/cpu.ico"))
|
new_item = QtWidgets.QTreeWidgetItem(NodeType.CON)
|
||||||
self.__current_item.setText(0, self.__default_name)
|
new_item.setIcon(0, QtGui.QIcon(":/main/ico/cpu.ico"))
|
||||||
self.__current_item.setData(0, WidgetData.port, self.__default_port)
|
new_item.setText(0, settings.name)
|
||||||
self.__current_item.setData(0, WidgetData.timeout, 5)
|
new_item.setData(0, WidgetData.revpi_settings, settings)
|
||||||
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")
|
|
||||||
sub_folder = self._get_folder_item(self.cbb_folder.currentText())
|
sub_folder = self._get_folder_item(self.cbb_folder.currentText())
|
||||||
if sub_folder:
|
if sub_folder:
|
||||||
sub_folder.addChild(self.__current_item)
|
sub_folder.addChild(new_item)
|
||||||
else:
|
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.setFocus()
|
||||||
self.txt_name.selectAll()
|
self.txt_name.selectAll()
|
||||||
|
|
||||||
|
@QtCore.pyqtSlot()
|
||||||
|
def on_btn_add_dir_clicked(self):
|
||||||
|
"""Add a new folder."""
|
||||||
|
folder_text = self.tr("New folder")
|
||||||
|
sub_folder = QtWidgets.QTreeWidgetItem(NodeType.DIR)
|
||||||
|
sub_folder.setIcon(0, QtGui.QIcon(":/main/ico/folder.ico"))
|
||||||
|
sub_folder.setText(0, folder_text)
|
||||||
|
|
||||||
|
self.tre_connections.addTopLevelItem(sub_folder)
|
||||||
|
self.tre_connections.setCurrentItem(sub_folder)
|
||||||
|
self.cbb_folder.setFocus()
|
||||||
|
|
||||||
|
self.changes = True
|
||||||
|
|
||||||
@QtCore.pyqtSlot(str)
|
@QtCore.pyqtSlot(str)
|
||||||
def on_txt_name_textEdited(self, text):
|
def on_txt_name_textEdited(self, text):
|
||||||
if self.__current_item.type() != NodeType.CON:
|
if self.__current_item.type() != NodeType.CON:
|
||||||
return
|
return
|
||||||
self.__current_item.setText(0, text)
|
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)
|
@QtCore.pyqtSlot(str)
|
||||||
def on_txt_address_textEdited(self, text):
|
def on_txt_address_textEdited(self, text):
|
||||||
if self.__current_item.type() != NodeType.CON:
|
if self.__current_item.type() != NodeType.CON:
|
||||||
return
|
return
|
||||||
self.__current_item.setText(1, text)
|
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)
|
@QtCore.pyqtSlot(int)
|
||||||
def on_sbx_port_valueChanged(self, value: int):
|
def on_sbx_port_valueChanged(self, value: int):
|
||||||
if self.__current_item.type() != NodeType.CON:
|
if self.__current_item.type() != NodeType.CON:
|
||||||
return
|
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)
|
@QtCore.pyqtSlot(int)
|
||||||
def on_sbx_timeout_valueChanged(self, value: int):
|
def on_sbx_timeout_valueChanged(self, value: int):
|
||||||
if self.__current_item.type() != NodeType.CON:
|
if self.__current_item.type() != NodeType.CON:
|
||||||
return
|
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)
|
@QtCore.pyqtSlot(int)
|
||||||
def on_cbx_ssh_use_tunnel_stateChanged(self, check_state: int):
|
def on_cbx_ssh_use_tunnel_stateChanged(self, check_state: int):
|
||||||
if self.__current_item.type() != NodeType.CON:
|
if self.__current_item.type() != NodeType.CON:
|
||||||
return
|
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)
|
@QtCore.pyqtSlot(int)
|
||||||
def on_sbx_ssh_port_valueChanged(self, value: int):
|
def on_sbx_ssh_port_valueChanged(self, value: int):
|
||||||
if self.__current_item.type() != NodeType.CON:
|
if self.__current_item.type() != NodeType.CON:
|
||||||
return
|
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)
|
@QtCore.pyqtSlot(str)
|
||||||
def on_txt_ssh_user_textEdited(self, text):
|
def on_txt_ssh_user_textEdited(self, text):
|
||||||
if self.__current_item.type() != NodeType.CON:
|
if self.__current_item.type() != NodeType.CON:
|
||||||
return
|
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_currentIndexChanged(self, text: str):
|
||||||
|
pi.logger.debug("RevPiPlcList.on_cbb_folder_currentIndexChanged({0})".format(text))
|
||||||
|
|
||||||
|
if self.__current_item.type() == NodeType.CON:
|
||||||
|
new_dir_node = self._get_folder_item(text)
|
||||||
|
current_dir_node = self.__current_item.parent()
|
||||||
|
if current_dir_node == new_dir_node:
|
||||||
|
# No change required, both nodes are the same
|
||||||
|
return
|
||||||
|
|
||||||
|
change_item = self.__current_item
|
||||||
|
self.tre_connections.blockSignals(True)
|
||||||
|
self.changes = True
|
||||||
|
|
||||||
|
if current_dir_node:
|
||||||
|
# Move an element to other folder or root
|
||||||
|
index = current_dir_node.indexOfChild(change_item)
|
||||||
|
change_item = current_dir_node.takeChild(index)
|
||||||
|
|
||||||
|
else:
|
||||||
|
# Move a root element to a folder
|
||||||
|
index = self.tre_connections.indexOfTopLevelItem(change_item)
|
||||||
|
change_item = self.tre_connections.takeTopLevelItem(index)
|
||||||
|
|
||||||
|
if text == "":
|
||||||
|
self.tre_connections.addTopLevelItem(change_item)
|
||||||
|
|
||||||
|
else:
|
||||||
|
new_dir_node.addChild(change_item)
|
||||||
|
|
||||||
|
self.tre_connections.blockSignals(False)
|
||||||
|
self.tre_connections.setCurrentItem(change_item)
|
||||||
|
|
||||||
@QtCore.pyqtSlot(str)
|
@QtCore.pyqtSlot(str)
|
||||||
def on_cbb_folder_editTextChanged(self, text: str):
|
def on_cbb_folder_editTextChanged(self, text: str):
|
||||||
pi.logger.debug("RevPiPlcList.on_cbb_folder_editTextChanged({0})".format(text))
|
pi.logger.debug("RevPiPlcList.on_cbb_folder_editTextChanged({0})".format(text))
|
||||||
|
|
||||||
if self.__current_item.type() == NodeType.DIR:
|
if self.__current_item.type() == NodeType.DIR and self.__current_item.text(0) != text:
|
||||||
# We just have to rename the dir node
|
# We just have to rename the dir node
|
||||||
self.__current_item.setText(0, text)
|
self.__current_item.setText(0, text)
|
||||||
|
self.changes = True
|
||||||
elif self.__current_item.type() == NodeType.CON:
|
|
||||||
sub_folder = self._get_folder_item(text)
|
|
||||||
dir_node = self.__current_item.parent()
|
|
||||||
if dir_node:
|
|
||||||
if dir_node.text(0) == text:
|
|
||||||
# It is the same folder
|
|
||||||
return
|
|
||||||
|
|
||||||
if text != "" and dir_node.childCount() == 1 and not sub_folder:
|
|
||||||
# The folder hold just one item, so we can rename that
|
|
||||||
for i in range(self.cbb_folder.count()):
|
|
||||||
if self.cbb_folder.itemText(i) == dir_node.text(0):
|
|
||||||
self.cbb_folder.setItemText(i, text)
|
|
||||||
break
|
|
||||||
dir_node.setText(0, text)
|
|
||||||
return
|
|
||||||
|
|
||||||
index = dir_node.indexOfChild(self.__current_item)
|
|
||||||
self.__current_item = dir_node.takeChild(index)
|
|
||||||
|
|
||||||
elif text != "":
|
|
||||||
# Move root to folder
|
|
||||||
index = self.tre_connections.indexOfTopLevelItem(self.__current_item)
|
|
||||||
self.__current_item = self.tre_connections.takeTopLevelItem(index)
|
|
||||||
|
|
||||||
else:
|
|
||||||
# Root stays root
|
|
||||||
return
|
|
||||||
|
|
||||||
if text == "":
|
|
||||||
self.tre_connections.addTopLevelItem(self.__current_item)
|
|
||||||
|
|
||||||
else:
|
|
||||||
if sub_folder is None:
|
|
||||||
sub_folder = QtWidgets.QTreeWidgetItem(NodeType.DIR)
|
|
||||||
sub_folder.setIcon(0, QtGui.QIcon(":/main/ico/folder.ico"))
|
|
||||||
sub_folder.setText(0, text)
|
|
||||||
self.tre_connections.addTopLevelItem(sub_folder)
|
|
||||||
self.cbb_folder.addItem(text)
|
|
||||||
sub_folder.addChild(self.__current_item)
|
|
||||||
|
|
||||||
if dir_node and dir_node.childCount() == 0:
|
|
||||||
# Remove empty folders
|
|
||||||
for i in range(self.cbb_folder.count()):
|
|
||||||
if self.cbb_folder.itemText(i) == dir_node.text(0):
|
|
||||||
self.cbb_folder.removeItem(i)
|
|
||||||
break
|
|
||||||
index = self.tre_connections.indexOfTopLevelItem(dir_node)
|
|
||||||
self.tre_connections.takeTopLevelItem(index)
|
|
||||||
|
|
||||||
self.tre_connections.setCurrentItem(self.__current_item)
|
|
||||||
self.cbb_folder.setFocus()
|
|
||||||
|
|
||||||
# endregion # # # # #
|
# endregion # # # # #
|
||||||
|
|||||||
@@ -58,8 +58,7 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
|
|||||||
|
|
||||||
:return: True, if unsaved changes was found
|
:return: True, if unsaved changes was found
|
||||||
"""
|
"""
|
||||||
return \
|
return self.cbb_plcprogram.currentText() != self.dc.get("plcprogram", "") or \
|
||||||
self.cbb_plcprogram.currentText() != self.dc.get("plcprogram", "") or \
|
|
||||||
self.txt_plcarguments.text() != self.dc.get("plcarguments", "") 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_2.isChecked() != (self.dc.get("pythonversion", 3) == 2) or \
|
||||||
self.rbn_pythonversion_3.isChecked() != (self.dc.get("pythonversion", 3) == 3) 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:
|
elif ec == 0:
|
||||||
helper.cm.program_last_pictory_file = filename
|
helper.cm.settings.last_pictory_file = filename
|
||||||
if ask == QtWidgets.QMessageBox.Yes:
|
if ask == QtWidgets.QMessageBox.Yes:
|
||||||
QtWidgets.QMessageBox.information(
|
QtWidgets.QMessageBox.information(
|
||||||
self, self.tr("Success"), self.tr(
|
self, self.tr("Success"), self.tr(
|
||||||
@@ -319,21 +318,16 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
|
|||||||
self.cbx_pictory.setEnabled(index >= 1)
|
self.cbx_pictory.setEnabled(index >= 1)
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def on_btn_program_download_pressed(self):
|
def on_btn_program_download_clicked(self):
|
||||||
"""Download plc program from Revolution Pi."""
|
"""Download plc program from Revolution Pi."""
|
||||||
if not helper.cm.connected:
|
if not helper.cm.connected:
|
||||||
return
|
return
|
||||||
|
|
||||||
selected_dir = ""
|
|
||||||
|
|
||||||
if self.cbb_format.currentIndex() == 0:
|
if self.cbb_format.currentIndex() == 0:
|
||||||
# Save files as zip archive
|
# Save files as zip archive
|
||||||
diag_save = QtWidgets.QFileDialog(
|
diag_save = QtWidgets.QFileDialog(
|
||||||
self, self.tr("Save ZIP archive..."),
|
self, self.tr("Save ZIP archive..."),
|
||||||
os.path.join(
|
helper.cm.settings.last_zip_file or "{0}.zip".format(helper.cm.settings.name),
|
||||||
helper.cm.program_last_zip_file,
|
|
||||||
"{0}.zip".format(helper.cm.name)
|
|
||||||
),
|
|
||||||
self.tr("ZIP archive (*.zip);;All files (*.*)")
|
self.tr("ZIP archive (*.zip);;All files (*.*)")
|
||||||
)
|
)
|
||||||
diag_save.setAcceptMode(QtWidgets.QFileDialog.AcceptSave)
|
diag_save.setAcceptMode(QtWidgets.QFileDialog.AcceptSave)
|
||||||
@@ -345,16 +339,13 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
|
|||||||
filename = diag_save.selectedFiles()[0]
|
filename = diag_save.selectedFiles()[0]
|
||||||
fh = open(filename, "wb")
|
fh = open(filename, "wb")
|
||||||
|
|
||||||
helper.cm.program_last_zip_file = filename
|
helper.cm.settings.last_zip_file = filename
|
||||||
|
|
||||||
elif self.cbb_format.currentIndex() == 1:
|
elif self.cbb_format.currentIndex() == 1:
|
||||||
# Save files as TarGz archive
|
# Save files as TarGz archive
|
||||||
diag_save = QtWidgets.QFileDialog(
|
diag_save = QtWidgets.QFileDialog(
|
||||||
self, self.tr("Save TGZ archive..."),
|
self, self.tr("Save TGZ archive..."),
|
||||||
os.path.join(
|
helper.cm.settings.last_tar_file or "{0}.tgz".format(helper.cm.settings.name),
|
||||||
helper.cm.program_last_tar_file,
|
|
||||||
"{0}.tgz".format(helper.cm.name)
|
|
||||||
),
|
|
||||||
self.tr("TGZ archive (*.tgz);;All files (*.*)")
|
self.tr("TGZ archive (*.tgz);;All files (*.*)")
|
||||||
)
|
)
|
||||||
diag_save.setAcceptMode(QtWidgets.QFileDialog.AcceptSave)
|
diag_save.setAcceptMode(QtWidgets.QFileDialog.AcceptSave)
|
||||||
@@ -366,7 +357,7 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
|
|||||||
filename = diag_save.selectedFiles()[0]
|
filename = diag_save.selectedFiles()[0]
|
||||||
fh = open(filename, "wb")
|
fh = open(filename, "wb")
|
||||||
|
|
||||||
helper.cm.program_last_tar_file = filename
|
helper.cm.settings.last_tar_file = filename
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Other indexes are not allowed for download
|
# Other indexes are not allowed for download
|
||||||
@@ -405,7 +396,7 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def on_btn_program_upload_pressed(self):
|
def on_btn_program_upload_clicked(self):
|
||||||
"""Upload plc program to Revolution Pi."""
|
"""Upload plc program to Revolution Pi."""
|
||||||
if not helper.cm.connected:
|
if not helper.cm.connected:
|
||||||
return
|
return
|
||||||
@@ -426,7 +417,7 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
|
|||||||
# Upload zip archive content
|
# Upload zip archive content
|
||||||
diag_open = QtWidgets.QFileDialog(
|
diag_open = QtWidgets.QFileDialog(
|
||||||
self, self.tr("Upload content of ZIP archive..."),
|
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 (*.*)")
|
self.tr("ZIP archive (*.zip);;All files (*.*)")
|
||||||
)
|
)
|
||||||
diag_open.setAcceptMode(QtWidgets.QFileDialog.AcceptOpen)
|
diag_open.setAcceptMode(QtWidgets.QFileDialog.AcceptOpen)
|
||||||
@@ -438,7 +429,7 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
|
|||||||
return
|
return
|
||||||
|
|
||||||
filename = diag_open.selectedFiles()[0]
|
filename = diag_open.selectedFiles()[0]
|
||||||
helper.cm.program_last_file_upload = filename
|
helper.cm.settings.last_file_upload = filename
|
||||||
if zipfile.is_zipfile(filename):
|
if zipfile.is_zipfile(filename):
|
||||||
dirtmp = mkdtemp()
|
dirtmp = mkdtemp()
|
||||||
fhz = zipfile.ZipFile(filename)
|
fhz = zipfile.ZipFile(filename)
|
||||||
@@ -460,7 +451,7 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
|
|||||||
# Upload TarGz content
|
# Upload TarGz content
|
||||||
diag_open = QtWidgets.QFileDialog(
|
diag_open = QtWidgets.QFileDialog(
|
||||||
self, self.tr("Upload content of TAR archive..."),
|
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 (*.*)")
|
self.tr("TAR archive (*.tgz);;All files (*.*)")
|
||||||
)
|
)
|
||||||
diag_open.setAcceptMode(QtWidgets.QFileDialog.AcceptOpen)
|
diag_open.setAcceptMode(QtWidgets.QFileDialog.AcceptOpen)
|
||||||
@@ -472,7 +463,7 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
|
|||||||
return
|
return
|
||||||
|
|
||||||
filename = diag_open.selectedFiles()[0]
|
filename = diag_open.selectedFiles()[0]
|
||||||
helper.cm.program_last_file_upload = filename
|
helper.cm.settings.last_file_upload = filename
|
||||||
if tarfile.is_tarfile(filename):
|
if tarfile.is_tarfile(filename):
|
||||||
dirtmp = mkdtemp()
|
dirtmp = mkdtemp()
|
||||||
fht = tarfile.open(filename)
|
fht = tarfile.open(filename)
|
||||||
@@ -598,7 +589,7 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
|
|||||||
# region # REGION: Control files
|
# region # REGION: Control files
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def on_btn_pictory_download_pressed(self):
|
def on_btn_pictory_download_clicked(self):
|
||||||
"""Download piCtory configuration."""
|
"""Download piCtory configuration."""
|
||||||
if not helper.cm.connected:
|
if not helper.cm.connected:
|
||||||
return
|
return
|
||||||
@@ -606,8 +597,8 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
|
|||||||
diag_save = QtWidgets.QFileDialog(
|
diag_save = QtWidgets.QFileDialog(
|
||||||
self, self.tr("Save piCtory file..."),
|
self, self.tr("Save piCtory file..."),
|
||||||
os.path.join(
|
os.path.join(
|
||||||
helper.cm.program_last_dir_pictory,
|
helper.cm.settings.last_dir_pictory,
|
||||||
"{0}.rsc".format(helper.cm.name)
|
"{0}.rsc".format(helper.cm.settings.name)
|
||||||
),
|
),
|
||||||
self.tr("piCtory file (*.rsc);;All files (*.*)")
|
self.tr("piCtory file (*.rsc);;All files (*.*)")
|
||||||
)
|
)
|
||||||
@@ -619,7 +610,7 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
|
|||||||
return
|
return
|
||||||
|
|
||||||
filename = diag_save.selectedFiles()[0]
|
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
|
bin_buffer = helper.cm.call_remote_function("get_pictoryrsc") # type: Binary
|
||||||
if bin_buffer is None:
|
if bin_buffer is None:
|
||||||
QtWidgets.QMessageBox.critical(
|
QtWidgets.QMessageBox.critical(
|
||||||
@@ -639,13 +630,13 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def on_btn_pictory_upload_pressed(self):
|
def on_btn_pictory_upload_clicked(self):
|
||||||
if not helper.cm.connected:
|
if not helper.cm.connected:
|
||||||
return
|
return
|
||||||
|
|
||||||
diag_open = QtWidgets.QFileDialog(
|
diag_open = QtWidgets.QFileDialog(
|
||||||
self, self.tr("Upload piCtory file..."),
|
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 (*.*)")
|
self.tr("piCtory file (*.rsc);;All files (*.*)")
|
||||||
)
|
)
|
||||||
diag_open.setAcceptMode(QtWidgets.QFileDialog.AcceptOpen)
|
diag_open.setAcceptMode(QtWidgets.QFileDialog.AcceptOpen)
|
||||||
@@ -659,7 +650,7 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
|
|||||||
self._upload_pictory(diag_open.selectedFiles()[0])
|
self._upload_pictory(diag_open.selectedFiles()[0])
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def on_btn_procimg_download_pressed(self):
|
def on_btn_procimg_download_clicked(self):
|
||||||
"""Download process image."""
|
"""Download process image."""
|
||||||
if not helper.cm.connected:
|
if not helper.cm.connected:
|
||||||
return
|
return
|
||||||
@@ -668,8 +659,8 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
|
|||||||
self,
|
self,
|
||||||
self.tr("Save piControl file..."),
|
self.tr("Save piControl file..."),
|
||||||
os.path.join(
|
os.path.join(
|
||||||
helper.cm.program_last_dir_picontrol,
|
helper.cm.settings.last_dir_picontrol,
|
||||||
"{0}.img".format(helper.cm.name)
|
"{0}.img".format(helper.cm.settings.name)
|
||||||
),
|
),
|
||||||
self.tr("Process image file (*.img);;All files (*.*)")
|
self.tr("Process image file (*.img);;All files (*.*)")
|
||||||
)
|
)
|
||||||
@@ -681,7 +672,7 @@ class RevPiProgram(QtWidgets.QDialog, Ui_diag_program):
|
|||||||
return
|
return
|
||||||
|
|
||||||
filename = diag_save.selectedFiles()[0]
|
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
|
bin_buffer = helper.cm.call_remote_function("get_procimg") # type: Binary
|
||||||
|
|
||||||
if bin_buffer is None:
|
if bin_buffer is None:
|
||||||
|
|||||||
@@ -4,35 +4,101 @@ __author__ = "Sven Sager"
|
|||||||
__copyright__ = "Copyright (C) 2023 Sven Sager"
|
__copyright__ = "Copyright (C) 2023 Sven Sager"
|
||||||
__license__ = "GPLv3"
|
__license__ = "GPLv3"
|
||||||
|
|
||||||
from enum import Enum
|
from logging import getLogger
|
||||||
|
|
||||||
|
import keyring
|
||||||
from PyQt5 import QtWidgets
|
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):
|
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)
|
super(SSHAuth, self).__init__(parent)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
|
|
||||||
self.wid_password.setVisible(auth_type is SSHAuthType.PASS)
|
self._in_keyring = False
|
||||||
self.wid_keys.setVisible(auth_type is SSHAuthType.KEYS)
|
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
|
@property
|
||||||
def password(self) -> str:
|
def password(self) -> str:
|
||||||
|
"""Get the saved or entered password."""
|
||||||
return self.txt_password.text()
|
return self.txt_password.text()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def username(self) -> str:
|
def username(self) -> str:
|
||||||
|
"""Get the entered username."""
|
||||||
return self.txt_username.text()
|
return self.txt_username.text()
|
||||||
|
|
||||||
@username.setter
|
|
||||||
def username(self, value: str):
|
|
||||||
self.txt_username.setText(value)
|
|
||||||
|
|||||||
@@ -75,6 +75,8 @@ class Ui_diag_search(object):
|
|||||||
self.act_connect_ssh.setObjectName("act_connect_ssh")
|
self.act_connect_ssh.setObjectName("act_connect_ssh")
|
||||||
self.act_connect_xmlrpc = QtWidgets.QAction(diag_search)
|
self.act_connect_xmlrpc = QtWidgets.QAction(diag_search)
|
||||||
self.act_connect_xmlrpc.setObjectName("act_connect_xmlrpc")
|
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.retranslateUi(diag_search)
|
||||||
self.btn_box.rejected.connect(diag_search.reject) # type: ignore
|
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_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.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_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
|
from . import ressources_rc
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets
|
|||||||
class Ui_diag_backgroundworker(object):
|
class Ui_diag_backgroundworker(object):
|
||||||
def setupUi(self, diag_backgroundworker):
|
def setupUi(self, diag_backgroundworker):
|
||||||
diag_backgroundworker.setObjectName("diag_backgroundworker")
|
diag_backgroundworker.setObjectName("diag_backgroundworker")
|
||||||
diag_backgroundworker.resize(418, 97)
|
diag_backgroundworker.resize(424, 104)
|
||||||
diag_backgroundworker.setModal(True)
|
diag_backgroundworker.setModal(True)
|
||||||
self.verticalLayout = QtWidgets.QVBoxLayout(diag_backgroundworker)
|
self.verticalLayout = QtWidgets.QVBoxLayout(diag_backgroundworker)
|
||||||
self.verticalLayout.setObjectName("verticalLayout")
|
self.verticalLayout.setObjectName("verticalLayout")
|
||||||
@@ -37,8 +37,7 @@ class Ui_diag_backgroundworker(object):
|
|||||||
QtCore.QMetaObject.connectSlotsByName(diag_backgroundworker)
|
QtCore.QMetaObject.connectSlotsByName(diag_backgroundworker)
|
||||||
|
|
||||||
def retranslateUi(self, diag_backgroundworker):
|
def retranslateUi(self, diag_backgroundworker):
|
||||||
_translate = QtCore.QCoreApplication.translate
|
pass
|
||||||
diag_backgroundworker.setWindowTitle(_translate("diag_backgroundworker", "File transfer..."))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -36,15 +36,18 @@ class Ui_wid_debugcontrol(object):
|
|||||||
self.verticalLayout = QtWidgets.QVBoxLayout(self.gb_control)
|
self.verticalLayout = QtWidgets.QVBoxLayout(self.gb_control)
|
||||||
self.verticalLayout.setObjectName("verticalLayout")
|
self.verticalLayout.setObjectName("verticalLayout")
|
||||||
self.btn_read_io = QtWidgets.QPushButton(self.gb_control)
|
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.btn_read_io.setObjectName("btn_read_io")
|
||||||
self.verticalLayout.addWidget(self.btn_read_io)
|
self.verticalLayout.addWidget(self.btn_read_io)
|
||||||
self.btn_refresh_io = QtWidgets.QPushButton(self.gb_control)
|
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.btn_refresh_io.setObjectName("btn_refresh_io")
|
||||||
self.verticalLayout.addWidget(self.btn_refresh_io)
|
self.verticalLayout.addWidget(self.btn_refresh_io)
|
||||||
self.btn_write_o = QtWidgets.QPushButton(self.gb_control)
|
self.btn_write_o = QtWidgets.QPushButton(self.gb_control)
|
||||||
self.btn_write_o.setShortcut("F6")
|
|
||||||
self.btn_write_o.setObjectName("btn_write_o")
|
self.btn_write_o.setObjectName("btn_write_o")
|
||||||
self.verticalLayout.addWidget(self.btn_write_o)
|
self.verticalLayout.addWidget(self.btn_write_o)
|
||||||
self.cbx_refresh = QtWidgets.QCheckBox(self.gb_control)
|
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.gb_devices.setTitle(_translate("wid_debugcontrol", "Revolution Pi devices"))
|
||||||
self.cbx_stay_on_top.setText(_translate("wid_debugcontrol", "Open to stay on top"))
|
self.cbx_stay_on_top.setText(_translate("wid_debugcontrol", "Open to stay on top"))
|
||||||
self.gb_control.setTitle(_translate("wid_debugcontrol", "IO Control"))
|
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_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_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.setToolTip(_translate("wid_debugcontrol", "Write locally changed output values to process image (F6)"))
|
||||||
self.btn_write_o.setText(_translate("wid_debugcontrol", "&Write changed outputs"))
|
self.btn_write_o.setText(_translate("wid_debugcontrol", "&Write changed outputs"))
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -67,6 +67,7 @@ class Ui_diag_connections(object):
|
|||||||
self.formLayout_2.setWidget(4, QtWidgets.QFormLayout.LabelRole, self.lbl_folder)
|
self.formLayout_2.setWidget(4, QtWidgets.QFormLayout.LabelRole, self.lbl_folder)
|
||||||
self.cbb_folder = QtWidgets.QComboBox(self.tab_connection)
|
self.cbb_folder = QtWidgets.QComboBox(self.tab_connection)
|
||||||
self.cbb_folder.setEditable(True)
|
self.cbb_folder.setEditable(True)
|
||||||
|
self.cbb_folder.setSizeAdjustPolicy(QtWidgets.QComboBox.AdjustToContents)
|
||||||
self.cbb_folder.setObjectName("cbb_folder")
|
self.cbb_folder.setObjectName("cbb_folder")
|
||||||
self.cbb_folder.addItem("")
|
self.cbb_folder.addItem("")
|
||||||
self.cbb_folder.setItemText(0, "")
|
self.cbb_folder.setItemText(0, "")
|
||||||
@@ -115,39 +116,41 @@ class Ui_diag_connections(object):
|
|||||||
spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
|
spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
|
||||||
self.vl_edit.addItem(spacerItem)
|
self.vl_edit.addItem(spacerItem)
|
||||||
self.btn_up = QtWidgets.QPushButton(diag_connections)
|
self.btn_up = QtWidgets.QPushButton(diag_connections)
|
||||||
self.btn_up.setText("")
|
|
||||||
icon = QtGui.QIcon()
|
icon = QtGui.QIcon()
|
||||||
icon.addPixmap(QtGui.QPixmap(":/action/ico/arrow-up.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
icon.addPixmap(QtGui.QPixmap(":/action/ico/arrow-up.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
self.btn_up.setIcon(icon)
|
self.btn_up.setIcon(icon)
|
||||||
self.btn_up.setObjectName("btn_up")
|
self.btn_up.setObjectName("btn_up")
|
||||||
self.vl_edit.addWidget(self.btn_up)
|
self.vl_edit.addWidget(self.btn_up)
|
||||||
self.btn_down = QtWidgets.QPushButton(diag_connections)
|
self.btn_down = QtWidgets.QPushButton(diag_connections)
|
||||||
self.btn_down.setText("")
|
|
||||||
icon1 = QtGui.QIcon()
|
icon1 = QtGui.QIcon()
|
||||||
icon1.addPixmap(QtGui.QPixmap(":/action/ico/arrow-down.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
icon1.addPixmap(QtGui.QPixmap(":/action/ico/arrow-down.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
self.btn_down.setIcon(icon1)
|
self.btn_down.setIcon(icon1)
|
||||||
self.btn_down.setObjectName("btn_down")
|
self.btn_down.setObjectName("btn_down")
|
||||||
self.vl_edit.addWidget(self.btn_down)
|
self.vl_edit.addWidget(self.btn_down)
|
||||||
self.btn_delete = QtWidgets.QPushButton(diag_connections)
|
self.btn_delete = QtWidgets.QPushButton(diag_connections)
|
||||||
self.btn_delete.setText("")
|
|
||||||
icon2 = QtGui.QIcon()
|
icon2 = QtGui.QIcon()
|
||||||
icon2.addPixmap(QtGui.QPixmap(":/action/ico/edit-delete.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
icon2.addPixmap(QtGui.QPixmap(":/action/ico/edit-delete-6.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
self.btn_delete.setIcon(icon2)
|
self.btn_delete.setIcon(icon2)
|
||||||
self.btn_delete.setObjectName("btn_delete")
|
self.btn_delete.setObjectName("btn_delete")
|
||||||
self.vl_edit.addWidget(self.btn_delete)
|
self.vl_edit.addWidget(self.btn_delete)
|
||||||
self.btn_add = QtWidgets.QPushButton(diag_connections)
|
self.btn_add_dir = QtWidgets.QPushButton(diag_connections)
|
||||||
self.btn_add.setText("")
|
|
||||||
icon3 = QtGui.QIcon()
|
icon3 = QtGui.QIcon()
|
||||||
icon3.addPixmap(QtGui.QPixmap(":/action/ico/edit-add.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
icon3.addPixmap(QtGui.QPixmap(":/action/ico/folder-open.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
self.btn_add.setIcon(icon3)
|
self.btn_add_dir.setIcon(icon3)
|
||||||
|
self.btn_add_dir.setObjectName("btn_add_dir")
|
||||||
|
self.vl_edit.addWidget(self.btn_add_dir)
|
||||||
|
self.btn_add = QtWidgets.QPushButton(diag_connections)
|
||||||
|
icon4 = QtGui.QIcon()
|
||||||
|
icon4.addPixmap(QtGui.QPixmap(":/action/ico/edit-add.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
|
self.btn_add.setIcon(icon4)
|
||||||
self.btn_add.setObjectName("btn_add")
|
self.btn_add.setObjectName("btn_add")
|
||||||
self.vl_edit.addWidget(self.btn_add)
|
self.vl_edit.addWidget(self.btn_add)
|
||||||
self.gridLayout.addLayout(self.vl_edit, 0, 1, 1, 1)
|
self.gridLayout.addLayout(self.vl_edit, 0, 1, 1, 1)
|
||||||
|
|
||||||
self.retranslateUi(diag_connections)
|
self.retranslateUi(diag_connections)
|
||||||
self.tab_properties.setCurrentIndex(0)
|
self.tab_properties.setCurrentIndex(0)
|
||||||
self.btn_box.accepted.connect(diag_connections.accept) # type: ignore
|
|
||||||
self.btn_box.rejected.connect(diag_connections.reject) # type: ignore
|
self.btn_box.rejected.connect(diag_connections.reject) # type: ignore
|
||||||
|
self.btn_box.accepted.connect(diag_connections.accept) # type: ignore
|
||||||
QtCore.QMetaObject.connectSlotsByName(diag_connections)
|
QtCore.QMetaObject.connectSlotsByName(diag_connections)
|
||||||
|
|
||||||
def retranslateUi(self, diag_connections):
|
def retranslateUi(self, diag_connections):
|
||||||
|
|||||||
@@ -15,8 +15,9 @@ class Ui_diag_sshauth(object):
|
|||||||
def setupUi(self, diag_sshauth):
|
def setupUi(self, diag_sshauth):
|
||||||
diag_sshauth.setObjectName("diag_sshauth")
|
diag_sshauth.setObjectName("diag_sshauth")
|
||||||
diag_sshauth.setWindowModality(QtCore.Qt.ApplicationModal)
|
diag_sshauth.setWindowModality(QtCore.Qt.ApplicationModal)
|
||||||
diag_sshauth.resize(275, 170)
|
diag_sshauth.resize(331, 225)
|
||||||
self.verticalLayout = QtWidgets.QVBoxLayout(diag_sshauth)
|
self.verticalLayout = QtWidgets.QVBoxLayout(diag_sshauth)
|
||||||
|
self.verticalLayout.setSizeConstraint(QtWidgets.QLayout.SetFixedSize)
|
||||||
self.verticalLayout.setObjectName("verticalLayout")
|
self.verticalLayout.setObjectName("verticalLayout")
|
||||||
self.wid_password = QtWidgets.QWidget(diag_sshauth)
|
self.wid_password = QtWidgets.QWidget(diag_sshauth)
|
||||||
self.wid_password.setObjectName("wid_password")
|
self.wid_password.setObjectName("wid_password")
|
||||||
@@ -36,18 +37,28 @@ class Ui_diag_sshauth(object):
|
|||||||
self.txt_username.setObjectName("txt_username")
|
self.txt_username.setObjectName("txt_username")
|
||||||
self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.txt_username)
|
self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.txt_username)
|
||||||
self.verticalLayout.addWidget(self.wid_password)
|
self.verticalLayout.addWidget(self.wid_password)
|
||||||
self.wid_keys = QtWidgets.QWidget(diag_sshauth)
|
self.cbx_save_password = QtWidgets.QCheckBox(diag_sshauth)
|
||||||
self.wid_keys.setObjectName("wid_keys")
|
self.cbx_save_password.setObjectName("cbx_save_password")
|
||||||
self.verticalLayout.addWidget(self.wid_keys)
|
self.verticalLayout.addWidget(self.cbx_save_password)
|
||||||
self.buttonBox = QtWidgets.QDialogButtonBox(diag_sshauth)
|
self.btn_box = QtWidgets.QDialogButtonBox(diag_sshauth)
|
||||||
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
|
self.btn_box.setOrientation(QtCore.Qt.Horizontal)
|
||||||
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
|
self.btn_box.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
|
||||||
self.buttonBox.setObjectName("buttonBox")
|
self.btn_box.setObjectName("btn_box")
|
||||||
self.verticalLayout.addWidget(self.buttonBox)
|
self.verticalLayout.addWidget(self.btn_box)
|
||||||
|
self.lbl_info = QtWidgets.QLabel(diag_sshauth)
|
||||||
|
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
|
||||||
|
sizePolicy.setHorizontalStretch(0)
|
||||||
|
sizePolicy.setVerticalStretch(0)
|
||||||
|
sizePolicy.setHeightForWidth(self.lbl_info.sizePolicy().hasHeightForWidth())
|
||||||
|
self.lbl_info.setSizePolicy(sizePolicy)
|
||||||
|
self.lbl_info.setWordWrap(True)
|
||||||
|
self.lbl_info.setObjectName("lbl_info")
|
||||||
|
self.verticalLayout.addWidget(self.lbl_info)
|
||||||
|
self.verticalLayout.setStretch(3, 1)
|
||||||
|
|
||||||
self.retranslateUi(diag_sshauth)
|
self.retranslateUi(diag_sshauth)
|
||||||
self.buttonBox.accepted.connect(diag_sshauth.accept) # type: ignore
|
self.btn_box.accepted.connect(diag_sshauth.accept) # type: ignore
|
||||||
self.buttonBox.rejected.connect(diag_sshauth.reject) # type: ignore
|
self.btn_box.rejected.connect(diag_sshauth.reject) # type: ignore
|
||||||
QtCore.QMetaObject.connectSlotsByName(diag_sshauth)
|
QtCore.QMetaObject.connectSlotsByName(diag_sshauth)
|
||||||
|
|
||||||
def retranslateUi(self, diag_sshauth):
|
def retranslateUi(self, diag_sshauth):
|
||||||
@@ -55,6 +66,9 @@ class Ui_diag_sshauth(object):
|
|||||||
diag_sshauth.setWindowTitle(_translate("diag_sshauth", "SSH authentication"))
|
diag_sshauth.setWindowTitle(_translate("diag_sshauth", "SSH authentication"))
|
||||||
self.lbl_username.setText(_translate("diag_sshauth", "SSH username:"))
|
self.lbl_username.setText(_translate("diag_sshauth", "SSH username:"))
|
||||||
self.lbl_password.setText(_translate("diag_sshauth", "SSH password:"))
|
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"))
|
||||||
|
self.lbl_info.setText(_translate("diag_sshauth", "Note: The default user for SSH is \"pi\" which differs from the web configuration. You can find the password on the sticker on the device."))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -11,6 +11,7 @@ SOURCES = src/revpicommander/aclmanager.py \
|
|||||||
src/revpicommander/revpiplclist.py \
|
src/revpicommander/revpiplclist.py \
|
||||||
src/revpicommander/revpiprogram.py \
|
src/revpicommander/revpiprogram.py \
|
||||||
src/revpicommander/simulator.py \
|
src/revpicommander/simulator.py \
|
||||||
|
src/revpicommander/sshauth.py \
|
||||||
src/revpicommander/revpicommander.py
|
src/revpicommander/revpicommander.py
|
||||||
|
|
||||||
FORMS = ui_dev/aclmanager.ui \
|
FORMS = ui_dev/aclmanager.ui \
|
||||||
|
|||||||
@@ -151,6 +151,14 @@
|
|||||||
<string>You have to configure your Revolution Pi to accept this connections</string>
|
<string>You have to configure your Revolution Pi to accept this connections</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="act_connect">
|
||||||
|
<property name="text">
|
||||||
|
<string>Connect</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Connect to Revoluton Pi</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="ressources.qrc"/>
|
<include location="ressources.qrc"/>
|
||||||
|
|||||||
@@ -6,13 +6,10 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>418</width>
|
<width>424</width>
|
||||||
<height>97</height>
|
<height>104</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
|
||||||
<string>File transfer...</string>
|
|
||||||
</property>
|
|
||||||
<property name="modal">
|
<property name="modal">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
@@ -53,26 +53,42 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="btn_read_io">
|
<widget class="QPushButton" name="btn_read_io">
|
||||||
<property name="toolTip">
|
<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>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Read &all IO values</string>
|
<string>Read &all IO values</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="shortcut">
|
<property name="autoRepeat">
|
||||||
<string notr="true">F4</string>
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="autoRepeatDelay">
|
||||||
|
<number>100</number>
|
||||||
|
</property>
|
||||||
|
<property name="autoRepeatInterval">
|
||||||
|
<number>200</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="btn_refresh_io">
|
<widget class="QPushButton" name="btn_refresh_io">
|
||||||
<property name="toolTip">
|
<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>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Refresh unchanged IOs</string>
|
<string>&Refresh unchanged IOs</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="shortcut">
|
<property name="autoRepeat">
|
||||||
<string notr="true">F5</string>
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="autoRepeatDelay">
|
||||||
|
<number>100</number>
|
||||||
|
</property>
|
||||||
|
<property name="autoRepeatInterval">
|
||||||
|
<number>200</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -84,9 +100,6 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Write changed outputs</string>
|
<string>&Write changed outputs</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="shortcut">
|
|
||||||
<string notr="true">F6</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|||||||
BIN
ui_dev/ico/edit-delete-6.ico
Normal file
BIN
ui_dev/ico/edit-delete-6.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
BIN
ui_dev/ico/process-stop.ico
Executable file → Normal file
BIN
ui_dev/ico/process-stop.ico
Executable file → Normal file
Binary file not shown.
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
@@ -9,6 +9,7 @@
|
|||||||
<file>ico/file-python.ico</file>
|
<file>ico/file-python.ico</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
<qresource prefix="action">
|
<qresource prefix="action">
|
||||||
|
<file>ico/edit-delete-6.ico</file>
|
||||||
<file>ico/applications-utilities.ico</file>
|
<file>ico/applications-utilities.ico</file>
|
||||||
<file>ico/edit-find.ico</file>
|
<file>ico/edit-find.ico</file>
|
||||||
<file>ico/process-stop.ico</file>
|
<file>ico/process-stop.ico</file>
|
||||||
|
|||||||
@@ -108,6 +108,9 @@
|
|||||||
<property name="editable">
|
<property name="editable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizeAdjustPolicy">
|
||||||
|
<enum>QComboBox::AdjustToContents</enum>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
@@ -218,9 +221,6 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="btn_up">
|
<widget class="QPushButton" name="btn_up">
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="ressources.qrc">
|
<iconset resource="ressources.qrc">
|
||||||
<normaloff>:/action/ico/arrow-up.ico</normaloff>:/action/ico/arrow-up.ico</iconset>
|
<normaloff>:/action/ico/arrow-up.ico</normaloff>:/action/ico/arrow-up.ico</iconset>
|
||||||
@@ -229,9 +229,6 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="btn_down">
|
<widget class="QPushButton" name="btn_down">
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="ressources.qrc">
|
<iconset resource="ressources.qrc">
|
||||||
<normaloff>:/action/ico/arrow-down.ico</normaloff>:/action/ico/arrow-down.ico</iconset>
|
<normaloff>:/action/ico/arrow-down.ico</normaloff>:/action/ico/arrow-down.ico</iconset>
|
||||||
@@ -240,20 +237,22 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="btn_delete">
|
<widget class="QPushButton" name="btn_delete">
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="ressources.qrc">
|
<iconset resource="ressources.qrc">
|
||||||
<normaloff>:/action/ico/edit-delete.ico</normaloff>:/action/ico/edit-delete.ico</iconset>
|
<normaloff>:/action/ico/edit-delete-6.ico</normaloff>:/action/ico/edit-delete-6.ico</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_add_dir">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="ressources.qrc">
|
||||||
|
<normaloff>:/action/ico/folder-open.ico</normaloff>:/action/ico/folder-open.ico</iconset>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="btn_add">
|
<widget class="QPushButton" name="btn_add">
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="ressources.qrc">
|
<iconset resource="ressources.qrc">
|
||||||
<normaloff>:/action/ico/edit-add.ico</normaloff>:/action/ico/edit-add.ico</iconset>
|
<normaloff>:/action/ico/edit-add.ico</normaloff>:/action/ico/edit-add.ico</iconset>
|
||||||
@@ -268,22 +267,6 @@
|
|||||||
<include location="ressources.qrc"/>
|
<include location="ressources.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
|
||||||
<sender>btn_box</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>diag_connections</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
<connection>
|
||||||
<sender>btn_box</sender>
|
<sender>btn_box</sender>
|
||||||
<signal>rejected()</signal>
|
<signal>rejected()</signal>
|
||||||
@@ -291,8 +274,8 @@
|
|||||||
<slot>reject()</slot>
|
<slot>reject()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>316</x>
|
<x>322</x>
|
||||||
<y>260</y>
|
<y>564</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>286</x>
|
<x>286</x>
|
||||||
@@ -300,5 +283,21 @@
|
|||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>btn_box</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>diag_connections</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>254</x>
|
||||||
|
<y>564</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
@@ -9,14 +9,17 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>275</width>
|
<width>331</width>
|
||||||
<height>170</height>
|
<height>225</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>SSH authentication</string>
|
<string>SSH authentication</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,1">
|
||||||
|
<property name="sizeConstraint">
|
||||||
|
<enum>QLayout::SetFixedSize</enum>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QWidget" name="wid_password" native="true">
|
<widget class="QWidget" name="wid_password" native="true">
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<layout class="QFormLayout" name="formLayout">
|
||||||
@@ -48,10 +51,17 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<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>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="btn_box">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
@@ -60,12 +70,28 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="lbl_info">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Note: The default user for SSH is "pi" which differs from the web configuration. You can find the password on the sticker on the device.</string>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>btn_box</sender>
|
||||||
<signal>accepted()</signal>
|
<signal>accepted()</signal>
|
||||||
<receiver>diag_sshauth</receiver>
|
<receiver>diag_sshauth</receiver>
|
||||||
<slot>accept()</slot>
|
<slot>accept()</slot>
|
||||||
@@ -81,7 +107,7 @@
|
|||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>btn_box</sender>
|
||||||
<signal>rejected()</signal>
|
<signal>rejected()</signal>
|
||||||
<receiver>diag_sshauth</receiver>
|
<receiver>diag_sshauth</receiver>
|
||||||
<slot>reject()</slot>
|
<slot>reject()</slot>
|
||||||
|
|||||||
Reference in New Issue
Block a user