diff --git a/client/src/UDSClient.py b/client/src/UDSClient.py
index a4a1219b5..9ceb52352 100755
--- a/client/src/UDSClient.py
+++ b/client/src/UDSClient.py
@@ -54,6 +54,9 @@ class UDSClient(QtGui.QMainWindow):
ticket = None
scrambler = None
withError = False
+ animTimer = None
+ anim = 0
+ animInverted = False
def __init__(self):
QtGui.QMainWindow.__init__(self)
@@ -73,8 +76,14 @@ class UDSClient(QtGui.QMainWindow):
vpos = (screen.height() - mysize.height() - mysize.height()) / 2
self.move(hpos, vpos)
+ self.animTimer = QtCore.QTimer()
+ QtCore.QObject.connect(self.animTimer, QtCore.SIGNAL('timeout()'), self.updateAnim)
+
self.activateWindow()
+ self.startAnim()
+
+
def closeWindow(self):
self.close()
@@ -90,21 +99,35 @@ class UDSClient(QtGui.QMainWindow):
# return
def showError(self, e):
- self.ui.progressBar.setValue(100)
- self.ui.info.setText('Error')
- QtGui.QMessageBox.critical(self, 'Error', six.text_type(e), QtGui.QMessageBox.Ok)
+ self.stopAnim()
+ self.ui.info.setText('UDS Plugin Error') # In fact, main window is hidden, so this is not visible... :)
+ QtGui.QMessageBox.critical(None, 'UDS Plugin Error', '{}'.format(e), QtGui.QMessageBox.Ok)
self.closeWindow()
self.withError = True
def cancelPushed(self):
self.close()
- def _updateProgressBar(self, increment, maximum=100):
- val = self.ui.progressBar.value()
- val += increment
- if val > maximum:
- val = maximum
- self.ui.progressBar.setValue(val)
+ @QtCore.pyqtSlot()
+ def updateAnim(self):
+ self.anim += 2
+ if self.anim > 99:
+ self.animInverted = not self.animInverted
+ self.ui.progressBar.setInvertedAppearance(self.animInverted)
+ self.anim = 0
+
+ self.ui.progressBar.setValue(self.anim)
+
+ def startAnim(self):
+ self.ui.progressBar.invertedAppearance = False
+ self.anim = 0
+ self.animInverted = False
+ self.ui.progressBar.setInvertedAppearance(self.animInverted)
+ self.animTimer.start(40)
+
+ def stopAnim(self):
+ self.ui.progressBar.invertedAppearance = False
+ self.animTimer.stop()
@QtCore.pyqtSlot()
def getVersion(self):
@@ -114,10 +137,7 @@ class UDSClient(QtGui.QMainWindow):
@QtCore.pyqtSlot(dict)
def version(self, data):
try:
- self.ui.progressBar.setValue(20)
-
self.processError(data)
-
self.ui.info.setText('Processing...')
if data['result']['requiredVersion'] > VERSION:
@@ -128,13 +148,13 @@ class UDSClient(QtGui.QMainWindow):
self.getTransportData()
except RetryException as e:
- self._updateProgressBar(5, 80)
self.ui.info.setText(six.text_type(e))
QtCore.QTimer.singleShot(1000, self.getVersion)
except Exception as e:
self.showError(e)
+
@QtCore.pyqtSlot()
def getTransportData(self):
self.req = RestRequest('/{}/{}'.format(self.ticket, self.scrambler), self, self.transportDataReceived, params={'hostname': tools.getHostName(), 'version': VERSION})
@@ -147,11 +167,10 @@ class UDSClient(QtGui.QMainWindow):
try:
self.processError(data)
- self.ui.progressBar.setValue(80)
-
script = data['result'].decode('base64').decode('bz2')
- self.ui.progressBar.setValue(100)
+ self.stopAnim()
+
if 'darwin' in sys.platform:
self.showMinimized()
@@ -161,7 +180,6 @@ class UDSClient(QtGui.QMainWindow):
six.exec_(script, globals(), {'parent': self})
except RetryException as e:
- self._updateProgressBar(5, 80)
self.ui.info.setText(six.text_type(e) + ', retrying access...')
# Retry operation in ten seconds
QtCore.QTimer.singleShot(10000, self.getTransportData)
@@ -239,6 +257,10 @@ if __name__ == "__main__":
# First parameter must be url
try:
uri = sys.argv[1]
+
+ if uri == '--test':
+ sys.exit(0)
+
logger.debug('URI: {}'.format(uri))
if uri[:6] != 'uds://' and uri[:7] != 'udss://':
raise Exception()
@@ -281,12 +303,3 @@ if __name__ == "__main__":
logger.debug('Exiting')
sys.exit(exitVal)
- # Build base REST
-
- # v = RestRequest('', done)
- # v.get()
-
- # sys.exit(1)
-
- # myapp = UDSConfigDialog(cfg)
- # myapp.show()
diff --git a/client/src/uds/forward.py b/client/src/uds/forward.py
index d01815996..fcf4b17bf 100644
--- a/client/src/uds/forward.py
+++ b/client/src/uds/forward.py
@@ -65,10 +65,11 @@ class Handler(SocketServer.BaseRequestHandler):
except Exception:
pass
- if self.thread.stoppable is True:
+ self.thread.currentConnections -= 1
+
+ if self.thread.stoppable is True and self.thread.currentConnections == 0:
self.thread.stop()
- self.thread.currentConnections -= 1
class ForwardThread(threading.Thread):
status = 0 # Connecting
diff --git a/client/src/uds/tools.py b/client/src/uds/tools.py
index 0276b73bf..a49292e50 100644
--- a/client/src/uds/tools.py
+++ b/client/src/uds/tools.py
@@ -65,7 +65,7 @@ def readTempFile(filename):
filename = os.path.join(tempfile.gettempdir(), filename)
try:
- with open(filename, 'w') as f:
+ with open(filename, 'r') as f:
return f.read()
except Exception:
return None
@@ -129,7 +129,13 @@ def addTaskToWait(taks):
def waitForTasks():
for t in _tasksToWait:
- t.wait()
+ try:
+ if hasattr(t, 'join'):
+ t.join()
+ elif hasattr(t, 'wait'):
+ t.wait()
+ except Exception:
+ pass
def addExecBeforeExit(fnc):
diff --git a/server/src/uds/templates/uds/admin/tmpl/fld/editlist.html b/server/src/uds/templates/uds/admin/tmpl/fld/editlist.html
index 2c2acc511..360ffb38d 100644
--- a/server/src/uds/templates/uds/admin/tmpl/fld/editlist.html
+++ b/server/src/uds/templates/uds/admin/tmpl/fld/editlist.html
@@ -1,7 +1,7 @@
{% extends "uds/admin/tmpl/fld/form-group.html" %}
{% load i18n %}
{% block field %}{% verbatim %}
-
+
{{! We use a Select to get an array of selected values on ".val()" }}