From 9ffced63659557186ca73939fa7c1bdac2d7a85e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Mon, 10 Sep 2018 10:40:34 +0200 Subject: [PATCH] fixing up things --- server/src/uds/models/Authenticator.py | 4 ++-- server/src/uds/models/ServicesPoolGroup.py | 4 ++-- server/src/uds/models/UserService.py | 7 +++++-- server/src/uds/services/OVirt/OVirtPublication.py | 9 +++------ server/src/uds/services/OpenNebula/LivePublication.py | 9 +++------ server/src/uds/templatetags/uds.py | 5 +++-- server/src/uds/transports/NX/NXTransport.py | 5 ++--- server/src/uds/transports/NX/TSNXTransport.py | 7 +++---- server/src/uds/transports/RDP/TRDPTransport.py | 7 ++----- server/src/uds/transports/X2GO/TX2GOTransport.py | 4 ++-- server/src/uds/web/views/client_download.py | 3 +-- server/src/uds/web/views/service.py | 2 +- 12 files changed, 29 insertions(+), 37 deletions(-) diff --git a/server/src/uds/models/Authenticator.py b/server/src/uds/models/Authenticator.py index 8829fc7f..82f38d68 100644 --- a/server/src/uds/models/Authenticator.py +++ b/server/src/uds/models/Authenticator.py @@ -48,7 +48,7 @@ import logging logger = logging.getLogger(__name__) -__updated__ = '2018-06-27' +__updated__ = '2018-09-07' @python_2_unicode_compatible @@ -194,7 +194,7 @@ class Authenticator(ManagedObjectModel, TaggingMixin): else: auths = Authenticator.objects.all().order_by('priority', 'name') - return [auth for auth in auths if auth.getType().isCustom() is False or tag != 'disabled'] + return [auth for auth in auths if auth.getType() and (auth.getType().isCustom() is False or tag != 'disabled')] @staticmethod def beforeDelete(sender, **kwargs): diff --git a/server/src/uds/models/ServicesPoolGroup.py b/server/src/uds/models/ServicesPoolGroup.py index 1d1abb2b..44d8c134 100644 --- a/server/src/uds/models/ServicesPoolGroup.py +++ b/server/src/uds/models/ServicesPoolGroup.py @@ -44,7 +44,7 @@ from uds.core.ui.images import DEFAULT_THUMB_BASE64 import logging -__updated__ = '2018-09-03' +__updated__ = '2018-09-07' logger = logging.getLogger(__name__) @@ -86,4 +86,4 @@ class ServicesPoolGroup(UUIDModel): @staticmethod def default(): - return ServicesPoolGroup(name=_('General'), comments='Default group', priority=-10000) + return ServicesPoolGroup(name=_('General'), comments='', priority=-10000) diff --git a/server/src/uds/models/UserService.py b/server/src/uds/models/UserService.py index 710b568e..0396c773 100644 --- a/server/src/uds/models/UserService.py +++ b/server/src/uds/models/UserService.py @@ -55,7 +55,7 @@ from uds.models.Util import getSqlDatetime import logging -__updated__ = '2018-06-15' +__updated__ = '2018-09-10' logger = logging.getLogger(__name__) @@ -173,7 +173,10 @@ class UserService(UUIDModel): raise Exception('Class {0} needs deployedType but it is not defined!!!'.format(serviceInstance.__class__.__name__)) us = serviceInstance.deployedType(self.getEnvironment(), service=serviceInstance, publication=publicationInstance, osmanager=osmanagerInstance, dbservice=self) if self.data != '' and self.data is not None: - us.unserialize(self.data) + try: + us.unserialize(self.data) + except Exception: + logger.exception('Error unserializing {}//{} : {}'.format(self.deployed_service.name, self.uuid, self.data)) return us def updateData(self, us): diff --git a/server/src/uds/services/OVirt/OVirtPublication.py b/server/src/uds/services/OVirt/OVirtPublication.py index 3aed257e..a36b2802 100644 --- a/server/src/uds/services/OVirt/OVirtPublication.py +++ b/server/src/uds/services/OVirt/OVirtPublication.py @@ -37,9 +37,7 @@ from uds.core.util.State import State from datetime import datetime import logging - -__updated__ = '2017-03-22' - +__updated__ = '2018-09-10' logger = logging.getLogger(__name__) @@ -71,14 +69,14 @@ class OVirtPublication(Publication): """ returns data from an instance of Sample Publication serialized """ - return '\t'.join(['v1', self._name, self._reason, self._destroyAfter, self._templateId, self._state]) + return b'\t'.join(['v1', self._name, self._reason, self._destroyAfter, self._templateId, self._state]) def unmarshal(self, data): """ deserializes the data and loads it inside instance. """ logger.debug('Data: {0}'.format(data)) - vals = data.split('\t') + vals = data.split(b'\t') if vals[0] == 'v1': self._name, self._reason, self._destroyAfter, self._templateId, self._state = vals[1:] @@ -118,7 +116,6 @@ class OVirtPublication(Publication): self._reason = str(e) return State.ERROR - if self._state == 'removed': self._state = 'error' self._reason = 'Template has been removed!' diff --git a/server/src/uds/services/OpenNebula/LivePublication.py b/server/src/uds/services/OpenNebula/LivePublication.py index 4a52b497..c95b640a 100644 --- a/server/src/uds/services/OpenNebula/LivePublication.py +++ b/server/src/uds/services/OpenNebula/LivePublication.py @@ -39,9 +39,7 @@ import six import logging - -__updated__ = '2017-03-27' - +__updated__ = '2018-09-10' logger = logging.getLogger(__name__) @@ -72,14 +70,14 @@ class LivePublication(Publication): """ returns data from an instance of Sample Publication serialized """ - return '\t'.join(['v1', self._name, self._reason, self._templateId, self._state]) + return b'\t'.join(['v1', self._name, self._reason, self._templateId, self._state]) def unmarshal(self, data): """ deserializes the data and loads it inside instance. """ logger.debug('Data: {0}'.format(data)) - vals = data.split('\t') + vals = data.split(b'\t') if vals[0] == 'v1': self._name, self._reason, self._templateId, self._state = vals[1:] @@ -119,7 +117,6 @@ class LivePublication(Publication): if self._state == 'ok': return State.FINISHED - self._state = 'ok' return State.FINISHED diff --git a/server/src/uds/templatetags/uds.py b/server/src/uds/templatetags/uds.py index deb43fcd..16c513f7 100644 --- a/server/src/uds/templatetags/uds.py +++ b/server/src/uds/templatetags/uds.py @@ -98,7 +98,7 @@ def udsJs(context): 'version_stamp': VERSION_STAMP, 'language': get_language(), 'available_languages': [{'id': k, 'name': gettext(v)} for k, v in settings.LANGUAGES], - 'authenticators': [getAuth(auth) for auth in authenticators], + 'authenticators': [getAuth(auth) for auth in authenticators if auth.getType()], 'bypassPluginDetection': False, 'os': request.os['OS'], 'csrf_field': CSRF_FIELD, @@ -110,7 +110,8 @@ def udsJs(context): 'customAuth': reverse('uds.web.views.customAuth', kwargs={'idAuth': ''}), 'services': reverse('modern.services'), 'enabler': reverse('ClientAccessEnabler', kwargs={ 'idService': 'param1', 'idTransport': 'param2' }), - 'galeryImage': reverse('galleryImage', kwargs={ 'idImage': 'param1' }), + 'galleryImage': reverse('galleryImage', kwargs={ 'idImage': 'param1' }), + 'transportIcon': reverse('uds.web.views.transportIcon', kwargs={'idTrans': 'param1'}) } } diff --git a/server/src/uds/transports/NX/NXTransport.py b/server/src/uds/transports/NX/NXTransport.py index b3a4b0fc..0d64201d 100644 --- a/server/src/uds/transports/NX/NXTransport.py +++ b/server/src/uds/transports/NX/NXTransport.py @@ -27,7 +27,6 @@ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - """ Created on Jul 29, 2011 @@ -125,8 +124,8 @@ class NXTransport(Transport): return str.join('\t', ['v1', gui.boolToStr(self._useEmptyCreds), self._fixedName, self._fixedPassword, self._listenPort, self._connection, self._session, self._cacheDisk, self._cacheMem]) - def unmarshal(self, string): - data = string.split('\t') + def unmarshal(self, val): + data = val.decode('utf8').split('\t') if data[0] == 'v1': self._useEmptyCreds = gui.strToBool(data[1]) self._fixedName, self._fixedPassword, self._listenPort, self._connection, self._session, self._cacheDisk, self._cacheMem = data[2:] diff --git a/server/src/uds/transports/NX/TSNXTransport.py b/server/src/uds/transports/NX/TSNXTransport.py index 5aeeed8e..9ebf69fe 100644 --- a/server/src/uds/transports/NX/TSNXTransport.py +++ b/server/src/uds/transports/NX/TSNXTransport.py @@ -27,7 +27,6 @@ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - """ Created on Jul 29, 2011 @@ -140,8 +139,8 @@ class TSNXTransport(Transport): return str.join('\t', ['v1', gui.boolToStr(self._useEmptyCreds), self._fixedName, self._fixedPassword, self._listenPort, self._connection, self._session, self._cacheDisk, self._cacheMem, self._tunnelServer, self._tunnelCheckServer]) - def unmarshal(self, string): - data = string.split('\t') + def unmarshal(self, val): + data = val.decode('utf8').split('\t') if data[0] == 'v1': self._useEmptyCreds = gui.strToBool(data[1]) self._fixedName, self._fixedPassword, self._listenPort, self._connection, self._session, self._cacheDisk, self._cacheMem, self._tunnelServer, self._tunnelCheckServer = data[2:] @@ -194,7 +193,7 @@ class TSNXTransport(Transport): if self._useEmptyCreds is True: username, password = '', '' - tunpass = ''.join(random.choice(string.letters + string.digits) for _i in range(12)) + tunpass = ''.join(random.choice(string.ascii_letters + string.digits) for _i in range(12)) tunuser = TicketStore.create(tunpass) sshServer = self._tunnelServer diff --git a/server/src/uds/transports/RDP/TRDPTransport.py b/server/src/uds/transports/RDP/TRDPTransport.py index c84bb6b1..55bd7546 100644 --- a/server/src/uds/transports/RDP/TRDPTransport.py +++ b/server/src/uds/transports/RDP/TRDPTransport.py @@ -48,7 +48,7 @@ import logging import random import string -__updated__ = '2018-09-06' +__updated__ = '2018-09-10' logger = logging.getLogger(__name__) @@ -118,7 +118,7 @@ class TRDPTransport(BaseRDPTransport): width, height = self.screenSize.value.split('x') depth = self.colorDepth.value - tunpass = ''.join(random.choice(string.letters + string.digits) for _i in range(12)) + tunpass = ''.join(random.choice(string.ascii_letters + string.digits) for _i in range(12)) tunuser = TicketStore.create(tunpass) sshHost, sshPort = self.tunnelServer.value.split(':') @@ -187,7 +187,6 @@ class TRDPTransport(BaseRDPTransport): if os is None: return super(self.__class__, self).getUDSTransportScript(userService, transport, ip, os, user, password, request) - sp = { 'tunUser': tunuser, 'tunPass': tunpass, @@ -200,6 +199,4 @@ class TRDPTransport(BaseRDPTransport): 'r': r, } - m = tools.DictAsObj(data) - return self.getScript('scripts/{}/tunnel.py', os, sp) diff --git a/server/src/uds/transports/X2GO/TX2GOTransport.py b/server/src/uds/transports/X2GO/TX2GOTransport.py index 48327300..cbbdcbda 100644 --- a/server/src/uds/transports/X2GO/TX2GOTransport.py +++ b/server/src/uds/transports/X2GO/TX2GOTransport.py @@ -45,7 +45,7 @@ import logging import random import string -__updated__ = '2018-03-22' +__updated__ = '2018-09-10' logger = logging.getLogger(__name__) @@ -110,7 +110,7 @@ class TX2GOTransport(BaseX2GOTransport): user=username ) - tunpass = ''.join(random.choice(string.letters + string.digits) for _i in range(12)) + tunpass = ''.join(random.choice(string.ascii_letters + string.digits) for _i in range(12)) tunuser = TicketStore.create(tunpass) sshHost, sshPort = self.tunnelServer.value.split(':') diff --git a/server/src/uds/web/views/client_download.py b/server/src/uds/web/views/client_download.py index 1809cfd0..0394d6c8 100644 --- a/server/src/uds/web/views/client_download.py +++ b/server/src/uds/web/views/client_download.py @@ -45,8 +45,7 @@ import logging logger = logging.getLogger(__name__) -__updated__ = '2016-08-26' - +__updated__ = '2018-09-10' UserPrefsManager.manager().registerPrefs( '_uds', diff --git a/server/src/uds/web/views/service.py b/server/src/uds/web/views/service.py index c17e061d..6beb318e 100644 --- a/server/src/uds/web/views/service.py +++ b/server/src/uds/web/views/service.py @@ -53,7 +53,7 @@ import logging logger = logging.getLogger(__name__) -__updated__ = '2018-08-31' +__updated__ = '2018-09-10' @webLoginRequired(admin=False)