mirror of
https://github.com/dkmstr/openuds.git
synced 2024-12-22 13:34:04 +03:00
*Merged fixes for UDS Client
This commit is contained in:
commit
2021fd69ec
@ -157,8 +157,12 @@ class UDSClient(QtGui.QMainWindow):
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def getTransportData(self):
|
||||
self.req = RestRequest('/{}/{}'.format(self.ticket, self.scrambler), self, self.transportDataReceived, params={'hostname': tools.getHostName(), 'version': VERSION})
|
||||
self.req.get()
|
||||
try:
|
||||
self.req = RestRequest('/{}/{}'.format(self.ticket, self.scrambler), self, self.transportDataReceived, params={'hostname': tools.getHostName(), 'version': VERSION})
|
||||
self.req.get()
|
||||
except Exception as e:
|
||||
logger.exception('Got exception: {}'.format(e))
|
||||
raise e
|
||||
|
||||
|
||||
@QtCore.pyqtSlot(dict)
|
||||
@ -271,7 +275,7 @@ if __name__ == "__main__":
|
||||
|
||||
except Exception:
|
||||
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)
|
||||
|
||||
# Setup REST api endpoint
|
||||
|
@ -56,7 +56,7 @@ class RestRequest(QObject):
|
||||
# private
|
||||
self._manager = QNetworkAccessManager()
|
||||
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)
|
||||
|
||||
|
@ -42,21 +42,30 @@ import six
|
||||
import sys
|
||||
import time
|
||||
|
||||
from log import logger
|
||||
|
||||
_unlinkFiles = []
|
||||
_tasksToWait = []
|
||||
_execBeforeExit = []
|
||||
|
||||
|
||||
sys_fs_enc = sys.getfilesystemencoding() or 'mbcs'
|
||||
|
||||
def saveTempFile(content, filename=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'
|
||||
|
||||
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)
|
||||
|
||||
with open(filename, 'w') as f:
|
||||
f.write(content)
|
||||
|
||||
logger.info('Returning filename')
|
||||
return filename
|
||||
|
||||
def readTempFile(filename):
|
||||
@ -81,7 +90,7 @@ def testServer(host, port, timeOut=4):
|
||||
|
||||
def findApp(appName, extraPath=None):
|
||||
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)
|
||||
if extraPath is not None:
|
||||
searchPath += list(extraPath)
|
||||
@ -98,7 +107,13 @@ def getHostName():
|
||||
Returns current host name
|
||||
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)
|
||||
|
||||
|
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">
|
||||
<p></p>
|
||||
</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>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block jsnc %}
|
||||
@ -56,9 +71,12 @@ var groups = {
|
||||
|
||||
function showSelectedTabItems() {
|
||||
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(){
|
||||
itemsTemplate = Handlebars.compile($("#tmpl_items").html());
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% load i18n html5 static %}
|
||||
{% preferences_allowed as show_prefs %}
|
||||
{% root_id as rootid %}
|
||||
<div class="ui menu">
|
||||
<div class="ui inverted menu doubling grid">
|
||||
<a class="header item" href="/">
|
||||
<img class="ui mini spaced image" src="{% get_static_prefix %}img/udsicon.png">Universal Desktop Services
|
||||
</a>
|
||||
|
@ -74,6 +74,7 @@
|
||||
})
|
||||
</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 %}
|
||||
|
||||
|
||||
|
@ -1,28 +1,32 @@
|
||||
{% load i18n %}
|
||||
{% verbatim %}
|
||||
<div class="ui five link cards">
|
||||
{{#each this}}
|
||||
<div class="card">
|
||||
<div class="ui fluid image centered">
|
||||
<img src="{{ image }}">
|
||||
</div>
|
||||
<div class="content">
|
||||
<a class="header">{{ name }}</a>
|
||||
<div class="meta">
|
||||
<span>{{#if in_use }}{% endverbatim %}{% trans 'Session in use' %}{% verbatim %}{{/if}}</span>
|
||||
<span>{{#if maintenance }}{% endverbatim %}{% trans 'Maintenance' %}{% verbatim %}{{/if}}</span>
|
||||
<div class="ui five doubling link cards">
|
||||
{{#each data}}
|
||||
<div class="card">
|
||||
<div class="content">
|
||||
<div class="right floated mini ui image">
|
||||
<img src="{{ image }}">
|
||||
</div>
|
||||
<a class="header">{{ name }}</a>
|
||||
<div class="meta">
|
||||
<span>{{#if in_use }}{% endverbatim %}{% trans 'Session in use' %}{% verbatim %}{{/if}}</span>
|
||||
<span>{{#if maintenance }}{% endverbatim %}{% trans 'Maintenance' %}{% verbatim %}{{/if}}</span>
|
||||
</div>
|
||||
<div class="description">
|
||||
{{ description }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="description">
|
||||
{{ description }}
|
||||
{{# if show_transports }}
|
||||
{{# compare transports.length 1 operator=">" }}
|
||||
<div class="extra content">
|
||||
<a>
|
||||
<i class="open folder icon"></i>
|
||||
{% endverbatim %}{% trans 'Transports' %}{% verbatim %}{{ transports.length }}
|
||||
</a>
|
||||
</div>
|
||||
{{/ compare }}
|
||||
{{/ if }}
|
||||
</div>
|
||||
<div class="extra content">
|
||||
<a>
|
||||
<i class="user icon"></i>
|
||||
22 Friends
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{{/each }}
|
||||
{{/each }}
|
||||
</div>
|
||||
{% endverbatim %}
|
||||
|
Loading…
Reference in New Issue
Block a user