1
0
mirror of https://github.com/dkmstr/openuds.git synced 2024-12-22 13:34:04 +03:00

updating client to use PyQt6 first, and if not found, use pyqt5

This commit is contained in:
Adolfo Gómez García 2023-05-24 02:23:12 +02:00
commit e6b707868f
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23
18 changed files with 5224 additions and 48 deletions

View File

@ -7,7 +7,7 @@ update-desktop-database
echo "Installation process done."
echo "Remember that the following packages must be installed on system:"
echo "* Python3 paramiko"
echo "* Python3 PySide6 or PyQt5"
echo "* Python3 PyQt6 or PyQt5"
echo "* Python3 six"
echo "* Python3 requests"
echo "* Python3 cryptography"

View File

@ -35,7 +35,7 @@ AppDir:
include:
- python3
- python3-pkg-resources
# In future, will be replaced with pyside6 (when available as debian package)
# In future, will be replaced with PyQt6 (when available as debian package)
- python3-pyqt5
- python3-paramiko
- python3-cryptography

View File

@ -38,14 +38,8 @@ import webbrowser
import threading
import typing
# First, try to use PySide6, available on arm64, x86_64, i386, ...
try:
from PySide6 import QtCore, QtWidgets, QtGui
from PySide6.QtCore import QSettings
except ImportError: # If not found, try to use PyQt5 (not available on arm64)
from PyQt5 import QtCore, QtWidgets, QtGui # type: ignore
from PyQt5.QtCore import QSettings # type: ignore
# First, try to use PyQt6, available on arm64, x86_64, i386, ...
from uds.ui import QtCore, QtWidgets, QtGui, QSettings, Ui_MainWindow
from uds.rest import RestApi, RetryException, InvalidVersion
# Just to ensure there are available on runtime
@ -56,7 +50,6 @@ from uds.log import logger
from uds import tools
from uds import VERSION
from UDSWindow import Ui_MainWindow
class UDSClient(QtWidgets.QMainWindow): # type: ignore

View File

@ -5,13 +5,8 @@ import typing
from uds.log import logger
import UDSClient
from UDSLauncherMac import Ui_MacLauncher
# First, try to use PySide6 (has arm64, x86_64 support)
try:
from PySide6 import QtCore, QtWidgets, QtGui
except ImportError: # If not found, try to use PyQt5 (only x86_64)
from PyQt5 import QtCore, QtWidgets, QtGui # type: ignore
from uds.ui import QtCore, QtWidgets, QtGui, Ui_MacLauncher
SCRIPT_NAME = 'UDSClientLauncher'

View File

@ -2467,9 +2467,9 @@ qt_resource_struct_v2 = b"\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x02\
\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x12\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
\x00\x00\x01\x87\x81\xc5\x85\xf0\
\x00\x00\x01\x81\xce\x8a\xaf\xd2\
\x00\x00\x00\x34\x00\x00\x00\x00\x00\x01\x00\x00\x08\xf1\
\x00\x00\x01\x87\x81\xc5\x85\xf0\
\x00\x00\x01\x81\xce\x8a\xaf\xd2\
"
qt_version = [int(v) for v in QtCore.qVersion().split('.')]

View File

@ -3,7 +3,7 @@
# Created by: The Resource Compiler for Qt version 6.3.1
# WARNING! All changes made in this file will be lost!
from PySide6 import QtCore
from PyQt6 import QtCore
qt_resource_data = b"\
\x00\x00\x08\xed\

View File

@ -36,10 +36,10 @@ import platform
import sys
import tempfile
# First, try to use PySide6, available on arm64, x86_64, i386, ...
# First, try to use PyQt6, available on arm64, x86_64, i386, ...
try:
from PySide6 import QtCore # Just to test if it's available
QT='PySide6'
from PyQt6 import QtCore # Just to test if it's available
QT='PyQt6'
except ImportError: # If not found, it is using PyQt5
QT='PyQt5'

View File

@ -27,7 +27,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
'''
@author: Adolfo Gómez, dkmaster at dkmon dot com
Author: Adolfo Gómez, dkmaster at dkmon dot com
'''
import json
import bz2

View File

@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2023 Virtual Cable S.L.U.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
'''
Author: Adolfo Gómez, dkmaster at dkmon dot com
'''
# First, try to use PyQt6, available on arm64, x86_64, i386, ...
try:
from PyQt6 import QtCore, QtWidgets, QtGui
from PyQt6.QtCore import QSettings
from .qt6.UDSLauncherMac import Ui_MacLauncher
from .qt6.UDSWindow import Ui_MainWindow
from .qt6 import UDSResources_rc
except ImportError: # If not found, try to use PyQt5 (not available on arm64)
from PyQt5 import QtCore, QtWidgets, QtGui # type: ignore
from PyQt5.QtCore import QSettings # type: ignore
from .qt5.UDSLauncherMac import Ui_MacLauncher # type: ignore
from .qt5.UDSWindow import Ui_MainWindow # type: ignore
from .qt5 import UDSResources_rc # type: ignore

View File

@ -62,14 +62,4 @@ class Ui_MacLauncher(object):
MacLauncher.setWindowTitle(_translate("MacLauncher", "UDS Launcher"))
self.topLabel.setText(_translate("MacLauncher", "<html><head/><body><p align=\"center\"><span style=\" font-size:12pt; font-weight:600;\">UDS Launcher</span></p></body></html>"))
self.label_2.setText(_translate("MacLauncher", "<html><head/><body><p align=\"center\"><span style=\" font-size:6pt;\">Closing this window will end all UDS tunnels</span></p></body></html>"))
import UDSResources_rc
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MacLauncher = QtWidgets.QMainWindow()
ui = Ui_MacLauncher()
ui.setupUi(MacLauncher)
MacLauncher.show()
sys.exit(app.exec_())
from uds.ui.qt5 import UDSResources_rc

File diff suppressed because it is too large Load Diff

View File

@ -80,14 +80,4 @@ class Ui_MainWindow(object):
MainWindow.setWindowTitle(_translate("MainWindow", "UDS Connection"))
self.info.setText(_translate("MainWindow", "TextLabel"))
self.cancelButton.setText(_translate("MainWindow", "Cancel"))
import UDSResources_rc
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
from uds.ui.qt5 import UDSResources_rc

View File

@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2023 Virtual Cable S.L.U.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -0,0 +1,62 @@
# Form implementation generated from reading ui file 'UDSLauncherMac.ui'
#
# Created by: PyQt6 UI code generator 6.5.0
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt6 import QtCore, QtGui, QtWidgets
class Ui_MacLauncher(object):
def setupUi(self, MacLauncher):
MacLauncher.setObjectName("MacLauncher")
MacLauncher.setWindowModality(QtCore.Qt.WindowModality.NonModal)
MacLauncher.resize(235, 120)
MacLauncher.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.ArrowCursor))
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/images/logo-uds-small"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
MacLauncher.setWindowIcon(icon)
MacLauncher.setWindowOpacity(1.0)
self.centralwidget = QtWidgets.QWidget(parent=MacLauncher)
self.centralwidget.setAutoFillBackground(True)
self.centralwidget.setObjectName("centralwidget")
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.centralwidget)
self.verticalLayout_2.setContentsMargins(4, 4, 4, 4)
self.verticalLayout_2.setSpacing(4)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.frame = QtWidgets.QFrame(parent=self.centralwidget)
self.frame.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
self.frame.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
self.frame.setObjectName("frame")
self.verticalLayout = QtWidgets.QVBoxLayout(self.frame)
self.verticalLayout.setObjectName("verticalLayout")
self.topLabel = QtWidgets.QLabel(parent=self.frame)
self.topLabel.setTextFormat(QtCore.Qt.TextFormat.RichText)
self.topLabel.setObjectName("topLabel")
self.verticalLayout.addWidget(self.topLabel)
self.image = QtWidgets.QLabel(parent=self.frame)
self.image.setMinimumSize(QtCore.QSize(0, 32))
self.image.setAutoFillBackground(True)
self.image.setText("")
self.image.setPixmap(QtGui.QPixmap(":/images/logo-uds-small"))
self.image.setScaledContents(False)
self.image.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
self.image.setObjectName("image")
self.verticalLayout.addWidget(self.image)
self.label_2 = QtWidgets.QLabel(parent=self.frame)
self.label_2.setTextFormat(QtCore.Qt.TextFormat.RichText)
self.label_2.setObjectName("label_2")
self.verticalLayout.addWidget(self.label_2)
self.verticalLayout_2.addWidget(self.frame)
MacLauncher.setCentralWidget(self.centralwidget)
self.retranslateUi(MacLauncher)
QtCore.QMetaObject.connectSlotsByName(MacLauncher)
def retranslateUi(self, MacLauncher):
_translate = QtCore.QCoreApplication.translate
MacLauncher.setWindowTitle(_translate("MacLauncher", "UDS Launcher"))
self.topLabel.setText(_translate("MacLauncher", "<html><head/><body><p align=\"center\"><span style=\" font-size:12pt; font-weight:600;\">UDS Launcher</span></p></body></html>"))
self.label_2.setText(_translate("MacLauncher", "<html><head/><body><p align=\"center\"><span style=\" font-size:6pt;\">Closing this window will end all UDS tunnels</span></p></body></html>"))

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,80 @@
# Form implementation generated from reading ui file 'UDSWindow.ui'
#
# Created by: PyQt6 UI code generator 6.5.0
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt6 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.setWindowModality(QtCore.Qt.WindowModality.NonModal)
MainWindow.resize(259, 185)
MainWindow.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.BusyCursor))
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/images/logo-uds-small"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
MainWindow.setWindowIcon(icon)
MainWindow.setWindowOpacity(1.0)
self.centralwidget = QtWidgets.QWidget(parent=MainWindow)
self.centralwidget.setAutoFillBackground(True)
self.centralwidget.setObjectName("centralwidget")
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.centralwidget)
self.verticalLayout_2.setContentsMargins(4, 4, 4, 4)
self.verticalLayout_2.setSpacing(4)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.frame = QtWidgets.QFrame(parent=self.centralwidget)
self.frame.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
self.frame.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
self.frame.setObjectName("frame")
self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.frame)
self.verticalLayout_3.setContentsMargins(4, 4, 4, 4)
self.verticalLayout_3.setSpacing(4)
self.verticalLayout_3.setObjectName("verticalLayout_3")
self.verticalLayout = QtWidgets.QVBoxLayout()
self.verticalLayout.setObjectName("verticalLayout")
self.image = QtWidgets.QLabel(parent=self.frame)
self.image.setMinimumSize(QtCore.QSize(0, 24))
self.image.setAutoFillBackground(True)
self.image.setText("")
self.image.setPixmap(QtGui.QPixmap(":/images/logo-uds-small"))
self.image.setScaledContents(False)
self.image.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
self.image.setObjectName("image")
self.verticalLayout.addWidget(self.image)
self.info = QtWidgets.QLabel(parent=self.frame)
self.info.setMaximumSize(QtCore.QSize(16777215, 16))
self.info.setObjectName("info")
self.verticalLayout.addWidget(self.info)
self.progressBar = QtWidgets.QProgressBar(parent=self.frame)
self.progressBar.setProperty("value", 24)
self.progressBar.setTextVisible(False)
self.progressBar.setObjectName("progressBar")
self.verticalLayout.addWidget(self.progressBar)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
self.horizontalLayout.addItem(spacerItem)
self.cancelButton = QtWidgets.QPushButton(parent=self.frame)
self.cancelButton.setDefault(True)
self.cancelButton.setFlat(False)
self.cancelButton.setObjectName("cancelButton")
self.horizontalLayout.addWidget(self.cancelButton)
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
self.horizontalLayout.addItem(spacerItem1)
self.verticalLayout.addLayout(self.horizontalLayout)
self.verticalLayout_3.addLayout(self.verticalLayout)
self.verticalLayout_2.addWidget(self.frame)
MainWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "UDS Connection"))
self.info.setText(_translate("MainWindow", "TextLabel"))
self.cancelButton.setText(_translate("MainWindow", "Cancel"))

View File

@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2023 Virtual Cable S.L.U.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -3,12 +3,16 @@
function process {
for a in *.ui; do
pyuic5 $a -o `basename $a .ui`.py -x
pyuic5 $a -o uds/ui/qt5/`basename $a .ui`.py --import-from=uds.ui.qt5
pyuic6 $a -o uds/ui/qt6/`basename $a .ui`.py
done
}
pyrcc5 UDSResources.qrc -o UDSResources_rc.py
pyrcc5 UDSResources.qrc -o uds/ui/qt5/UDSResources_rc.py
pyside6-rcc UDSResources.qrc -o uds/ui/qt6/UDSResources_rc.py
echo "Note: Qt6 does not include pyrcc6, so pyside6-rcc is used instead"
echo "Must modify uds/ui/qt6/UDSResources_rc.py to use PyQT6 instead of PySide6, and ensure it is loaded
# process current directory ui's
process