1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-01-08 21:18:00 +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:35:56 +02:00
parent e6b707868f
commit 5770d94c33
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23

View File

@ -51,7 +51,6 @@ from uds import tools
from uds import VERSION from uds import VERSION
class UDSClient(QtWidgets.QMainWindow): # type: ignore class UDSClient(QtWidgets.QMainWindow): # type: ignore
ticket: str = '' ticket: str = ''
scrambler: str = '' scrambler: str = ''
@ -66,7 +65,7 @@ class UDSClient(QtWidgets.QMainWindow): # type: ignore
self.api = api self.api = api
self.ticket = ticket self.ticket = ticket
self.scrambler = scrambler self.scrambler = scrambler
self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint) # type: ignore self.setWindowFlags(QtCore.Qt.WindowType.FramelessWindowHint | QtCore.Qt.WindowType.WindowStaysOnTopHint)
self.ui = Ui_MainWindow() self.ui = Ui_MainWindow()
self.ui.setupUi(self) self.ui.setupUi(self)
@ -83,7 +82,7 @@ class UDSClient(QtWidgets.QMainWindow): # type: ignore
self.move(hpos, vpos) self.move(hpos, vpos)
self.animTimer = QtCore.QTimer() self.animTimer = QtCore.QTimer()
self.animTimer.timeout.connect(self.updateAnim) # type: ignore self.animTimer.timeout.connect(self.updateAnim)
# QtCore.QObject.connect(self.animTimer, QtCore.SIGNAL('timeout()'), self.updateAnim) # QtCore.QObject.connect(self.animTimer, QtCore.SIGNAL('timeout()'), self.updateAnim)
self.activateWindow() self.activateWindow()
@ -121,7 +120,7 @@ class UDSClient(QtWidgets.QMainWindow): # type: ignore
self.ui.progressBar.setValue(self.anim) self.ui.progressBar.setValue(self.anim)
def startAnim(self): def startAnim(self):
self.ui.progressBar.invertedAppearance = False # type: ignore self.ui.progressBar.setInvertedAppearance(False)
self.anim = 0 self.anim = 0
self.animInverted = False self.animInverted = False
self.ui.progressBar.setInvertedAppearance(self.animInverted) self.ui.progressBar.setInvertedAppearance(self.animInverted)
@ -129,7 +128,7 @@ class UDSClient(QtWidgets.QMainWindow): # type: ignore
self.animTimer.start(40) self.animTimer.start(40)
def stopAnim(self): def stopAnim(self):
self.ui.progressBar.invertedAppearance = False # type: ignore self.ui.progressBar.setInvertedAppearance(False)
if self.animTimer: if self.animTimer:
self.animTimer.stop() self.animTimer.stop()
@ -239,7 +238,7 @@ def approveHost(hostName: str):
None, # type: ignore None, # type: ignore
'ACCESS Warning', 'ACCESS Warning',
errorString, errorString,
QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No, # type: ignore QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No,
) )
== QtWidgets.QMessageBox.StandardButton.Yes == QtWidgets.QMessageBox.StandardButton.Yes
): ):
@ -262,7 +261,7 @@ def sslError(hostname: str, serial):
None, # type: ignore None, # type: ignore
'SSL Warning', 'SSL Warning',
f'Could not check SSL certificate for {hostname}.\nDo you trust this host?', f'Could not check SSL certificate for {hostname}.\nDo you trust this host?',
QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No, # type: ignore QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No,
) )
== QtWidgets.QMessageBox.StandardButton.Yes == QtWidgets.QMessageBox.StandardButton.Yes
): ):
@ -285,7 +284,7 @@ def minimal(api: RestApi, ticket: str, scrambler: str):
None, # type: ignore None, # type: ignore
'Upgrade required', 'Upgrade required',
'A newer connector version is required.\nA browser will be opened to download it.', 'A newer connector version is required.\nA browser will be opened to download it.',
QtWidgets.QMessageBox.StandardButton.Ok, # type: ignore QtWidgets.QMessageBox.StandardButton.Ok,
) )
webbrowser.open(e.downloadUrl) webbrowser.open(e.downloadUrl)
return 0 return 0
@ -303,7 +302,7 @@ def minimal(api: RestApi, ticket: str, scrambler: str):
'Service not ready', 'Service not ready',
'{}'.format('.\n'.join(str(e).split('.'))) '{}'.format('.\n'.join(str(e).split('.')))
+ '\n\nPlease, retry again in a while.', + '\n\nPlease, retry again in a while.',
QtWidgets.QMessageBox.StandardButton.Ok, # type: ignore QtWidgets.QMessageBox.StandardButton.Ok,
) )
except Exception as e: # pylint: disable=broad-exception-caught except Exception as e: # pylint: disable=broad-exception-caught
# logger.exception('Got exception on getTransportData') # logger.exception('Got exception on getTransportData')
@ -311,7 +310,7 @@ def minimal(api: RestApi, ticket: str, scrambler: str):
None, # type: ignore None, # type: ignore
'Error', 'Error',
'{}'.format(str(e)) + '\n\nPlease, retry again in a while.', '{}'.format(str(e)) + '\n\nPlease, retry again in a while.',
QtWidgets.QMessageBox.StandardButton.Ok, # type: ignore QtWidgets.QMessageBox.StandardButton.Ok,
) )
return 0 return 0
@ -327,7 +326,7 @@ def main(args: typing.List[str]):
if 'darwin' not in sys.platform: if 'darwin' not in sys.platform:
logger.debug('Mac OS *NOT* Detected') logger.debug('Mac OS *NOT* Detected')
app.setStyle('plastique') # type: ignore app.setStyle('plastique')
else: else:
logger.debug('Platform is Mac OS, adding homebrew possible paths') logger.debug('Platform is Mac OS, adding homebrew possible paths')
os.environ['PATH'] += ''.join( os.environ['PATH'] += ''.join(
@ -358,7 +357,7 @@ def main(args: typing.List[str]):
None, # type: ignore None, # type: ignore
'Notice', 'Notice',
f'UDS Client Version {VERSION} does not support HTTP protocol Anymore.', f'UDS Client Version {VERSION} does not support HTTP protocol Anymore.',
QtWidgets.QMessageBox.StandardButton.Ok, # type: ignore QtWidgets.QMessageBox.StandardButton.Ok,
) )
sys.exit(1) sys.exit(1)
if uri[:7] != 'udss://': if uri[:7] != 'udss://':
@ -377,7 +376,7 @@ def main(args: typing.List[str]):
None, # type: ignore None, # type: ignore
'Notice', 'Notice',
f'UDS Client Version {VERSION}', f'UDS Client Version {VERSION}',
QtWidgets.QMessageBox.StandardButton.Ok, # type: ignore QtWidgets.QMessageBox.StandardButton.Ok,
) )
sys.exit(1) sys.exit(1)
@ -405,7 +404,10 @@ def main(args: typing.List[str]):
logger.exception('Got an exception executing client:') logger.exception('Got an exception executing client:')
exitVal = 128 exitVal = 128
QtWidgets.QMessageBox.critical( QtWidgets.QMessageBox.critical(
None, 'Error', str(e), QtWidgets.QMessageBox.Ok # type: ignore None, # type: ignore
'Error',
f'Fatal error: {e}',
QtWidgets.QMessageBox.StandardButton.Ok
) )
logger.debug('Exiting') logger.debug('Exiting')