forked from shaba/openuds
Upgrading client for MAC multi open compatibility
This commit is contained in:
parent
1417a66b21
commit
6af0617c2a
@ -44,10 +44,10 @@ from PyQt5.QtCore import QSettings
|
||||
from uds.rest import RestApi, RetryException, InvalidVersion, UDSException
|
||||
|
||||
# Just to ensure there are available on runtime
|
||||
from uds.forward import forward # type: ignore
|
||||
from uds.tunnel import forward as f2 # type: ignore
|
||||
from uds.forward import forward as ssh_forward # type: ignore
|
||||
from uds.tunnel import forward as tunnel_forwards # type: ignore
|
||||
|
||||
from uds.log import logger, DEBUG
|
||||
from uds.log import logger
|
||||
from uds import tools
|
||||
from uds import VERSION
|
||||
|
||||
@ -176,8 +176,6 @@ class UDSClient(QtWidgets.QMainWindow):
|
||||
# Retry operation in ten seconds
|
||||
QtCore.QTimer.singleShot(10000, self.getTransportData)
|
||||
except Exception as e:
|
||||
if DEBUG:
|
||||
logger.exception('Got exception on getTransportData')
|
||||
self.showError(e)
|
||||
|
||||
def start(self):
|
||||
@ -316,12 +314,11 @@ def minimal(api: RestApi, ticket: str, scrambler: str):
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def main(args: typing.List[str]):
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
logger.debug('Initializing connector for %s(%s)', sys.platform, platform.machine())
|
||||
|
||||
# Initialize app
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
|
||||
logger.debug('Arguments: %s', args)
|
||||
# Set several info for settings
|
||||
QtCore.QCoreApplication.setOrganizationName('Virtual Cable S.L.U.')
|
||||
QtCore.QCoreApplication.setApplicationName('UDS Connector')
|
||||
@ -343,11 +340,11 @@ if __name__ == "__main__":
|
||||
# First parameter must be url
|
||||
useMinimal = False
|
||||
try:
|
||||
uri = sys.argv[1]
|
||||
uri = args[1]
|
||||
|
||||
if uri == '--minimal':
|
||||
useMinimal = True
|
||||
uri = sys.argv[2] # And get URI
|
||||
uri = args[2] # And get URI
|
||||
|
||||
if uri == '--test':
|
||||
sys.exit(0)
|
||||
@ -362,8 +359,8 @@ if __name__ == "__main__":
|
||||
'ssl:%s, host:%s, ticket:%s, scrambler:%s',
|
||||
ssl,
|
||||
host,
|
||||
UDSClient.ticket,
|
||||
UDSClient.scrambler,
|
||||
ticket,
|
||||
scrambler,
|
||||
)
|
||||
except Exception:
|
||||
logger.debug('Detected execution without valid URI, exiting')
|
||||
@ -404,3 +401,6 @@ if __name__ == "__main__":
|
||||
|
||||
logger.debug('Exiting')
|
||||
sys.exit(exitVal)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv)
|
||||
|
47
client-py3/full/src/UDSClientLauncher.py
Normal file
47
client-py3/full/src/UDSClientLauncher.py
Normal file
@ -0,0 +1,47 @@
|
||||
import sys
|
||||
import os.path
|
||||
import subprocess
|
||||
import typing
|
||||
|
||||
from uds.log import logger
|
||||
import UDSClient
|
||||
from UDSLauncherMac import Ui_MacLauncher
|
||||
|
||||
from PyQt5 import QtCore, QtWidgets, QtGui
|
||||
|
||||
SCRIPT_NAME = 'UDSClientLauncher'
|
||||
|
||||
class UdsApplication(QtWidgets.QApplication):
|
||||
path: str
|
||||
def __init__(self, argv: typing.List[str]) -> None:
|
||||
super().__init__(argv)
|
||||
self.path = os.path.join(os.path.dirname(sys.argv[0]).replace('Resources', 'MacOS'), SCRIPT_NAME)
|
||||
|
||||
def event(self, evnt: QtCore.QEvent) -> bool:
|
||||
logger.debug('Got event %s -> %s', evnt, evnt.type())
|
||||
|
||||
if evnt.type() == QtCore.QEvent.FileOpen:
|
||||
fe = typing.cast(QtGui.QFileOpenEvent, evnt)
|
||||
logger.debug('Got url: %s', fe.url().url())
|
||||
fe.accept()
|
||||
logger.debug('Spawning %s', self.path)
|
||||
subprocess.Popen([self.path, fe.url().url()])
|
||||
|
||||
return super().event(evnt)
|
||||
|
||||
|
||||
def main(args: typing.List[str]):
|
||||
if len(args) > 1:
|
||||
UDSClient.main(args)
|
||||
else:
|
||||
app = UdsApplication(sys.argv)
|
||||
window = QtWidgets.QMainWindow()
|
||||
Ui_MacLauncher().setupUi(window)
|
||||
|
||||
window.showMinimized()
|
||||
|
||||
sys.exit(app.exec_())
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(args=sys.argv)
|
||||
|
78
client-py3/full/src/UDSLauncherMac.py
Normal file
78
client-py3/full/src/UDSLauncherMac.py
Normal file
@ -0,0 +1,78 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Form implementation generated from reading ui file 'UDSLauncherMac.ui'
|
||||
#
|
||||
# Created by: PyQt5 UI code generator 5.15.2
|
||||
#
|
||||
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
|
||||
# run again. Do not edit this file unless you know what you are doing.
|
||||
|
||||
|
||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||
|
||||
|
||||
class Ui_MacLauncher(object):
|
||||
def setupUi(self, MacLauncher):
|
||||
MacLauncher.setObjectName("MacLauncher")
|
||||
MacLauncher.setWindowModality(QtCore.Qt.NonModal)
|
||||
MacLauncher.resize(256, 150)
|
||||
MacLauncher.setCursor(QtGui.QCursor(QtCore.Qt.BusyCursor))
|
||||
icon = QtGui.QIcon()
|
||||
icon.addPixmap(QtGui.QPixmap(":/images/logo-uds-small"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
MacLauncher.setWindowIcon(icon)
|
||||
MacLauncher.setWindowOpacity(1.0)
|
||||
self.centralwidget = QtWidgets.QWidget(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(self.centralwidget)
|
||||
self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
|
||||
self.frame.setFrameShadow(QtWidgets.QFrame.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(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.AlignCenter)
|
||||
self.image.setObjectName("image")
|
||||
self.verticalLayout.addWidget(self.image)
|
||||
self.info = QtWidgets.QLabel(self.frame)
|
||||
self.info.setMaximumSize(QtCore.QSize(16777215, 16))
|
||||
self.info.setAlignment(QtCore.Qt.AlignCenter)
|
||||
self.info.setObjectName("info")
|
||||
self.verticalLayout.addWidget(self.info)
|
||||
spacerItem = QtWidgets.QSpacerItem(20, 30, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
|
||||
self.verticalLayout.addItem(spacerItem)
|
||||
self.verticalLayout_3.addLayout(self.verticalLayout)
|
||||
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.info.setText(_translate("MacLauncher", "UDS Launcher"))
|
||||
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_())
|
144
client-py3/full/src/UDSLauncherMac.ui
Normal file
144
client-py3/full/src/UDSLauncherMac.ui
Normal file
@ -0,0 +1,144 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MacLauncher</class>
|
||||
<widget class="QMainWindow" name="MacLauncher">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::NonModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>256</width>
|
||||
<height>150</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>BusyCursor</cursorShape>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>UDS Launcher</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="UDSResources.qrc">
|
||||
<normaloff>:/images/logo-uds-small</normaloff>:/images/logo-uds-small</iconset>
|
||||
</property>
|
||||
<property name="windowOpacity">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="image">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="UDSResources.qrc">:/images/logo-uds-small</pixmap>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="info">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>UDS Launcher</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="UDSResources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
@ -2,7 +2,7 @@
|
||||
|
||||
# Resource object code
|
||||
#
|
||||
# Created by: The Resource Compiler for PyQt5 (Qt v5.13.2)
|
||||
# Created by: The Resource Compiler for PyQt5 (Qt v5.15.2)
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
|
@ -2,9 +2,10 @@
|
||||
|
||||
# Form implementation generated from reading ui file 'UDSWindow.ui'
|
||||
#
|
||||
# Created by: PyQt5 UI code generator 5.13.2
|
||||
# Created by: PyQt5 UI code generator 5.15.2
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
|
||||
# run again. Do not edit this file unless you know what you are doing.
|
||||
|
||||
|
||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||
|
Loading…
Reference in New Issue
Block a user