forked from shaba/openuds
*Merged fixes for UDS Client
This commit is contained in:
commit
2021fd69ec
@ -157,8 +157,12 @@ class UDSClient(QtGui.QMainWindow):
|
|||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def getTransportData(self):
|
def getTransportData(self):
|
||||||
|
try:
|
||||||
self.req = RestRequest('/{}/{}'.format(self.ticket, self.scrambler), self, self.transportDataReceived, params={'hostname': tools.getHostName(), 'version': VERSION})
|
self.req = RestRequest('/{}/{}'.format(self.ticket, self.scrambler), self, self.transportDataReceived, params={'hostname': tools.getHostName(), 'version': VERSION})
|
||||||
self.req.get()
|
self.req.get()
|
||||||
|
except Exception as e:
|
||||||
|
logger.exception('Got exception: {}'.format(e))
|
||||||
|
raise e
|
||||||
|
|
||||||
|
|
||||||
@QtCore.pyqtSlot(dict)
|
@QtCore.pyqtSlot(dict)
|
||||||
@ -271,7 +275,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.debug('Detected execution without valid URI, exiting')
|
logger.debug('Detected execution without valid URI, exiting')
|
||||||
QtGui.QMessageBox.critical(None, 'Notice', 'This program is designed to be used by UDS', QtGui.QMessageBox.Ok)
|
QtGui.QMessageBox.critical(None, 'Notice', 'UDS Client Version {}'.format(VERSION), QtGui.QMessageBox.Ok)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Setup REST api endpoint
|
# Setup REST api endpoint
|
||||||
|
@ -56,7 +56,7 @@ class RestRequest(QObject):
|
|||||||
# private
|
# private
|
||||||
self._manager = QNetworkAccessManager()
|
self._manager = QNetworkAccessManager()
|
||||||
if params is not None:
|
if params is not None:
|
||||||
url += '?' + '&'.join('{}={}'.format(k, urllib.quote(six.text_type(v))) for k, v in params.iteritems())
|
url += '?' + '&'.join('{}={}'.format(k, urllib.quote(six.text_type(v).encode('utf8'))) for k, v in params.iteritems())
|
||||||
|
|
||||||
self.url = QUrl(RestRequest.restApiUrl + url)
|
self.url = QUrl(RestRequest.restApiUrl + url)
|
||||||
|
|
||||||
|
@ -42,21 +42,30 @@ import six
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from log import logger
|
||||||
|
|
||||||
_unlinkFiles = []
|
_unlinkFiles = []
|
||||||
_tasksToWait = []
|
_tasksToWait = []
|
||||||
_execBeforeExit = []
|
_execBeforeExit = []
|
||||||
|
|
||||||
|
|
||||||
|
sys_fs_enc = sys.getfilesystemencoding() or 'mbcs'
|
||||||
|
|
||||||
def saveTempFile(content, filename=None):
|
def saveTempFile(content, filename=None):
|
||||||
if filename is None:
|
if filename is None:
|
||||||
filename = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(16))
|
filename = b''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(16))
|
||||||
filename = filename + '.uds'
|
filename = filename + '.uds'
|
||||||
|
|
||||||
if 'win32' in sys.platform:
|
if 'win32' in sys.platform:
|
||||||
filename = filename.encode('utf-8')
|
logger.info('Fixing for win32')
|
||||||
|
filename = filename.encode(sys_fs_enc)
|
||||||
|
|
||||||
filename = os.path.join(tempfile.gettempdir(), filename)
|
filename = os.path.join(tempfile.gettempdir(), filename)
|
||||||
|
|
||||||
with open(filename, 'w') as f:
|
with open(filename, 'w') as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
|
|
||||||
|
logger.info('Returning filename')
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
def readTempFile(filename):
|
def readTempFile(filename):
|
||||||
@ -81,7 +90,7 @@ def testServer(host, port, timeOut=4):
|
|||||||
|
|
||||||
def findApp(appName, extraPath=None):
|
def findApp(appName, extraPath=None):
|
||||||
if 'win32' in sys.platform and isinstance(appName, six.text_type):
|
if 'win32' in sys.platform and isinstance(appName, six.text_type):
|
||||||
appName = six.binary_type(appName)
|
appName = appName.encode(sys_fs_enc)
|
||||||
searchPath = os.environ['PATH'].split(os.pathsep)
|
searchPath = os.environ['PATH'].split(os.pathsep)
|
||||||
if extraPath is not None:
|
if extraPath is not None:
|
||||||
searchPath += list(extraPath)
|
searchPath += list(extraPath)
|
||||||
@ -98,7 +107,13 @@ def getHostName():
|
|||||||
Returns current host name
|
Returns current host name
|
||||||
In fact, it's a wrapper for socket.gethostname()
|
In fact, it's a wrapper for socket.gethostname()
|
||||||
'''
|
'''
|
||||||
return six.text_type(socket.gethostname())
|
hostname = socket.gethostname()
|
||||||
|
if 'win32' in sys.platform:
|
||||||
|
hostname = hostname.decode(sys_fs_enc)
|
||||||
|
|
||||||
|
hostname = six.text_type(hostname)
|
||||||
|
logger.info('Hostname: {}'.format(hostname))
|
||||||
|
return hostname
|
||||||
|
|
||||||
# Queing operations (to be executed before exit)
|
# Queing operations (to be executed before exit)
|
||||||
|
|
||||||
|
32
server/src/uds/static/semantic/js/uds.js
Normal file
32
server/src/uds/static/semantic/js/uds.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
// Comparison block from doginthehat.com.au/2012/02/comparison-block-helper-for-handlebars-templates/
|
||||||
|
Handlebars.registerHelper('compare', function(lvalue, rvalue, options) {
|
||||||
|
|
||||||
|
if (arguments.length < 3)
|
||||||
|
throw new Error("Handlerbars Helper 'compare' needs 2 parameters");
|
||||||
|
|
||||||
|
var operator = options.hash.operator || "==";
|
||||||
|
|
||||||
|
var operators = {
|
||||||
|
'==': function(l,r) { return l == r; },
|
||||||
|
'===': function(l,r) { return l === r; },
|
||||||
|
'!=': function(l,r) { return l != r; },
|
||||||
|
'<': function(l,r) { return l < r; },
|
||||||
|
'>': function(l,r) { return l > r; },
|
||||||
|
'<=': function(l,r) { return l <= r; },
|
||||||
|
'>=': function(l,r) { return l >= r; },
|
||||||
|
'typeof': function(l,r) { return typeof l == r; }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!operators[operator])
|
||||||
|
throw new Error("Handlerbars Helper 'compare' doesn't know the operator "+operator);
|
||||||
|
|
||||||
|
var result = operators[operator](lvalue,rvalue);
|
||||||
|
|
||||||
|
if( result ) {
|
||||||
|
return options.fn(this);
|
||||||
|
} else {
|
||||||
|
return options.inverse(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
@ -15,7 +15,22 @@
|
|||||||
<div class="ui bottom attached segment">
|
<div class="ui bottom attached segment">
|
||||||
<p></p>
|
<p></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if user.isStaff %}
|
||||||
|
<h4 class="ui horizontal divider header">
|
||||||
|
<i class="tag icon"></i> {% trans "Administrator info" %}
|
||||||
|
</h4>
|
||||||
|
<div class="ui segment">
|
||||||
|
<p>{% trans "Ip" %}: {{ ip }}</p>
|
||||||
|
<p>{% trans "Networks" %}: {{ nets }}</p>
|
||||||
|
<p>{% trans "Transports" %}: {{ transports }}</p>
|
||||||
|
<p>{% trans "User Agent" %}: {{ request.META.HTTP_USER_AGENT }}</p>
|
||||||
|
<p>{% trans "OS" %}: {{ request.session.OS.OS }}</p>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block jsnc %}
|
{% block jsnc %}
|
||||||
@ -56,9 +71,12 @@ var groups = {
|
|||||||
|
|
||||||
function showSelectedTabItems() {
|
function showSelectedTabItems() {
|
||||||
var gName = $(".tab.active").attr('data-group');
|
var gName = $(".tab.active").attr('data-group');
|
||||||
$('.attached.segment').html(itemsTemplate(groups[gName].items));
|
$('.attached.segment').html(itemsTemplate({
|
||||||
|
'data': groups[gName].items
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ready function
|
||||||
$(function(){
|
$(function(){
|
||||||
itemsTemplate = Handlebars.compile($("#tmpl_items").html());
|
itemsTemplate = Handlebars.compile($("#tmpl_items").html());
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{% load i18n html5 static %}
|
{% load i18n html5 static %}
|
||||||
{% preferences_allowed as show_prefs %}
|
{% preferences_allowed as show_prefs %}
|
||||||
{% root_id as rootid %}
|
{% root_id as rootid %}
|
||||||
<div class="ui menu">
|
<div class="ui inverted menu doubling grid">
|
||||||
<a class="header item" href="/">
|
<a class="header item" href="/">
|
||||||
<img class="ui mini spaced image" src="{% get_static_prefix %}img/udsicon.png">Universal Desktop Services
|
<img class="ui mini spaced image" src="{% get_static_prefix %}img/udsicon.png">Universal Desktop Services
|
||||||
</a>
|
</a>
|
||||||
|
@ -74,6 +74,7 @@
|
|||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
<script type="text/coffeescript" charset="utf-8" src="{% get_static_prefix %}js/uds-client.coffee"></script>
|
<script type="text/coffeescript" charset="utf-8" src="{% get_static_prefix %}js/uds-client.coffee"></script>
|
||||||
|
<script src="{% get_static_prefix %}semantic/js/uds.js"></script>
|
||||||
{% endcompress %}
|
{% endcompress %}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% verbatim %}
|
{% verbatim %}
|
||||||
<div class="ui five link cards">
|
<div class="ui five doubling link cards">
|
||||||
{{#each this}}
|
{{#each data}}
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="ui fluid image centered">
|
<div class="content">
|
||||||
|
<div class="right floated mini ui image">
|
||||||
<img src="{{ image }}">
|
<img src="{{ image }}">
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
|
||||||
<a class="header">{{ name }}</a>
|
<a class="header">{{ name }}</a>
|
||||||
<div class="meta">
|
<div class="meta">
|
||||||
<span>{{#if in_use }}{% endverbatim %}{% trans 'Session in use' %}{% verbatim %}{{/if}}</span>
|
<span>{{#if in_use }}{% endverbatim %}{% trans 'Session in use' %}{% verbatim %}{{/if}}</span>
|
||||||
@ -16,13 +16,17 @@
|
|||||||
{{ description }}
|
{{ description }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{{# if show_transports }}
|
||||||
|
{{# compare transports.length 1 operator=">" }}
|
||||||
<div class="extra content">
|
<div class="extra content">
|
||||||
<a>
|
<a>
|
||||||
<i class="user icon"></i>
|
<i class="open folder icon"></i>
|
||||||
22 Friends
|
{% endverbatim %}{% trans 'Transports' %}{% verbatim %}{{ transports.length }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{{/ compare }}
|
||||||
{{/each }}
|
{{/ if }}
|
||||||
|
</div>
|
||||||
|
{{/each }}
|
||||||
</div>
|
</div>
|
||||||
{% endverbatim %}
|
{% endverbatim %}
|
||||||
|
Loading…
Reference in New Issue
Block a user