mirror of
https://github.com/dkmstr/openuds.git
synced 2025-08-25 13:49:59 +03:00
Fix for show errors
This commit is contained in:
@ -53,7 +53,6 @@ from uds import VERSION
|
|||||||
from UDSWindow import Ui_MainWindow
|
from UDSWindow import Ui_MainWindow
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class UDSClient(QtWidgets.QMainWindow):
|
class UDSClient(QtWidgets.QMainWindow):
|
||||||
|
|
||||||
ticket: str = ''
|
ticket: str = ''
|
||||||
@ -107,7 +106,7 @@ class UDSClient(QtWidgets.QMainWindow):
|
|||||||
None, # type: ignore
|
None, # type: ignore
|
||||||
'UDS Plugin Error',
|
'UDS Plugin Error',
|
||||||
'{}'.format(error),
|
'{}'.format(error),
|
||||||
QtWidgets.QMessageBox.Ok
|
QtWidgets.QMessageBox.Ok,
|
||||||
)
|
)
|
||||||
self.withError = True
|
self.withError = True
|
||||||
|
|
||||||
@ -142,7 +141,7 @@ class UDSClient(QtWidgets.QMainWindow):
|
|||||||
self,
|
self,
|
||||||
'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.Ok
|
QtWidgets.QMessageBox.Ok,
|
||||||
)
|
)
|
||||||
webbrowser.open(e.downloadUrl)
|
webbrowser.open(e.downloadUrl)
|
||||||
self.closeWindow()
|
self.closeWindow()
|
||||||
@ -174,8 +173,8 @@ class UDSClient(QtWidgets.QMainWindow):
|
|||||||
# Retry operation in ten seconds
|
# Retry operation in ten seconds
|
||||||
QtCore.QTimer.singleShot(10000, self.getTransportData)
|
QtCore.QTimer.singleShot(10000, self.getTransportData)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception('Got exception on getTransportData')
|
# logger.exception('Got exception on getTransportData')
|
||||||
raise e
|
self.showError(e)
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
"""
|
"""
|
||||||
@ -184,6 +183,7 @@ class UDSClient(QtWidgets.QMainWindow):
|
|||||||
self.ui.info.setText('Initializing...')
|
self.ui.info.setText('Initializing...')
|
||||||
QtCore.QTimer.singleShot(100, self.getVersion)
|
QtCore.QTimer.singleShot(100, self.getVersion)
|
||||||
|
|
||||||
|
|
||||||
def endScript():
|
def endScript():
|
||||||
# Wait a bit before start processing ending sequence
|
# Wait a bit before start processing ending sequence
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
@ -200,7 +200,7 @@ def endScript():
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Removing
|
# Removing
|
||||||
try:
|
try:
|
||||||
logger.debug('Executing threads before exit')
|
logger.debug('Executing threads before exit')
|
||||||
tools.execBeforeExit()
|
tools.execBeforeExit()
|
||||||
@ -224,18 +224,22 @@ def approveHost(hostName: str):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if not approved:
|
if not approved:
|
||||||
if QtWidgets.QMessageBox.warning(
|
if (
|
||||||
None, # type: ignore
|
QtWidgets.QMessageBox.warning(
|
||||||
'ACCESS Warning',
|
None, # type: ignore
|
||||||
errorString,
|
'ACCESS Warning',
|
||||||
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No # type: ignore
|
errorString,
|
||||||
) == QtWidgets.QMessageBox.Yes:
|
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, # type: ignore
|
||||||
|
)
|
||||||
|
== QtWidgets.QMessageBox.Yes
|
||||||
|
):
|
||||||
settings.setValue(hostName, True)
|
settings.setValue(hostName, True)
|
||||||
approved = True
|
approved = True
|
||||||
|
|
||||||
settings.endGroup()
|
settings.endGroup()
|
||||||
return approved
|
return approved
|
||||||
|
|
||||||
|
|
||||||
def sslError(hostname: str, serial):
|
def sslError(hostname: str, serial):
|
||||||
settings = QSettings()
|
settings = QSettings()
|
||||||
settings.beginGroup('ssl')
|
settings.beginGroup('ssl')
|
||||||
@ -245,7 +249,7 @@ def sslError(hostname: str, serial):
|
|||||||
if (
|
if (
|
||||||
approved
|
approved
|
||||||
or QtWidgets.QMessageBox.warning(
|
or QtWidgets.QMessageBox.warning(
|
||||||
None, # type: ignore
|
None, # type: ignore
|
||||||
'SSL Warning',
|
'SSL Warning',
|
||||||
f'Could not check sll certificate for {hostname}',
|
f'Could not check sll certificate for {hostname}',
|
||||||
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, # type: ignore
|
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, # type: ignore
|
||||||
@ -258,6 +262,7 @@ def sslError(hostname: str, serial):
|
|||||||
settings.endGroup()
|
settings.endGroup()
|
||||||
return approved
|
return approved
|
||||||
|
|
||||||
|
|
||||||
def minimal(api: RestApi, ticket: str, scrambler: str):
|
def minimal(api: RestApi, ticket: str, scrambler: str):
|
||||||
try:
|
try:
|
||||||
logger.info('M1 Execution')
|
logger.info('M1 Execution')
|
||||||
@ -269,7 +274,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.Ok
|
QtWidgets.QMessageBox.Ok,
|
||||||
)
|
)
|
||||||
webbrowser.open(e.downloadUrl)
|
webbrowser.open(e.downloadUrl)
|
||||||
return 0
|
return 0
|
||||||
@ -283,17 +288,22 @@ def minimal(api: RestApi, ticket: str, scrambler: str):
|
|||||||
|
|
||||||
except RetryException as e:
|
except RetryException as e:
|
||||||
QtWidgets.QMessageBox.warning(
|
QtWidgets.QMessageBox.warning(
|
||||||
None, # type: ignore
|
None, # type: ignore
|
||||||
'Service not ready',
|
'Service not ready',
|
||||||
'{}'.format('.\n'.join(str(e).split('.'))) + '\n\nPlease, retry again in a while.' ,
|
'{}'.format('.\n'.join(str(e).split('.')))
|
||||||
QtWidgets.QMessageBox.Ok
|
+ '\n\nPlease, retry again in a while.',
|
||||||
)
|
QtWidgets.QMessageBox.Ok,
|
||||||
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception('Got exception on getTransportData')
|
# logger.exception('Got exception on getTransportData')
|
||||||
raise e
|
QtWidgets.QMessageBox.critical(
|
||||||
|
None, # type: ignore
|
||||||
|
'Error',
|
||||||
|
'{}'.format(str(e))
|
||||||
|
+ '\n\nPlease, retry again in a while.',
|
||||||
|
QtWidgets.QMessageBox.Ok,
|
||||||
|
)
|
||||||
|
|
||||||
except Exception:
|
|
||||||
logger.exception('Uncaught exception')
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
logger.debug('Initializing connector')
|
logger.debug('Initializing connector')
|
||||||
@ -340,9 +350,9 @@ if __name__ == "__main__":
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Setup REST api endpoint
|
# Setup REST api endpoint
|
||||||
api = RestApi('{}://{}/uds/rest/client'.format(
|
api = RestApi(
|
||||||
['http', 'https'][ssl], host
|
'{}://{}/uds/rest/client'.format(['http', 'https'][ssl], host), sslError
|
||||||
), sslError)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if platform.mac_ver()[2] == 'arm64':
|
if platform.mac_ver()[2] == 'arm64':
|
||||||
|
Reference in New Issue
Block a user