mirror of
https://github.com/dkmstr/openuds.git
synced 2024-12-22 13:34:04 +03:00
Merge branch 'master' of github.com:dkmstr/openuds
This commit is contained in:
commit
caae694628
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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):
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% extends "uds/admin/tmpl/fld/form-group.html" %}
|
||||
{% load i18n %}
|
||||
{% block field %}{% verbatim %}
|
||||
<input name="{{ name }}_nonused1" type="text" id="{{ name }}_field_txt" class="form-control cursor-pointer" value="{{ truncatechars 64 value }}" readonly tabindex="{{ index }}">
|
||||
<input name="{{ name }}_nonused1" type="text" id="{{ name }}_field_txt" class="form-control cursor-pointer" value="{{ truncatechars 64 value }}" readonly>
|
||||
{{! We use a Select to get an array of selected values on ".val()" }}
|
||||
<select id="{{ name }}_field_hdn" class="{{ css }} hidden" name="{{ name }}" multiple>
|
||||
{{# each value }}
|
||||
@ -14,8 +14,8 @@
|
||||
(function(){
|
||||
"use strict";
|
||||
var id = '{{ name }}_field_';
|
||||
var idTxt = 'input#' + id + 'txt';
|
||||
var idHidden = 'input#' + id + 'hdn';
|
||||
var idTxt = '#' + id + 'txt';
|
||||
var idHidden = '#' + id + 'hdn';
|
||||
$(idTxt).tooltip({
|
||||
placement: 'bottom',
|
||||
title: "{% endverbatim %}{% trans 'Click to edit list' %}{% verbatim %}",
|
||||
|
@ -19,6 +19,8 @@ forwardThread, port = forward('{m.tunHost}', '{m.tunPort}', '{m.tunUser}', '{m.t
|
||||
if forwardThread.status == 2:
|
||||
raise Exception('Unable to open tunnel')
|
||||
|
||||
tools.addTaskToWait(forwardThread)
|
||||
|
||||
# The password must be encoded, to be included in a .rdp file, as 'UTF-16LE' before protecting (CtrpyProtectData) it in order to work with mstsc
|
||||
theFile = '''{m.r.as_file}'''.format(
|
||||
password=win32crypt.CryptProtectData(six.binary_type('{m.password}'.encode('UTF-16LE')), None, None, None, None, 0x01).encode('hex'),
|
||||
|
Loading…
Reference in New Issue
Block a user