diff --git a/server/src/uds/core/workers/AssignedAndUnused.py b/server/src/uds/core/workers/AssignedAndUnused.py index 9fa8a7452..afb715192 100644 --- a/server/src/uds/core/workers/AssignedAndUnused.py +++ b/server/src/uds/core/workers/AssignedAndUnused.py @@ -30,6 +30,7 @@ ''' @author: Adolfo Gómez, dkmaster at dkmon dot com ''' +from __future__ import unicode_literals from uds.core.util.Config import GlobalConfig from uds.models import DeployedService, getSqlDatetime diff --git a/server/src/uds/core/workers/CacheCleaner.py b/server/src/uds/core/workers/CacheCleaner.py index ad351b639..0182c6c23 100644 --- a/server/src/uds/core/workers/CacheCleaner.py +++ b/server/src/uds/core/workers/CacheCleaner.py @@ -30,6 +30,7 @@ ''' @author: Adolfo Gómez, dkmaster at dkmon dot com ''' +from __future__ import unicode_literals from uds.core.util.Cache import Cache from uds.core.jobs.Job import Job diff --git a/server/src/uds/core/workers/DeployedServiceCleaner.py b/server/src/uds/core/workers/DeployedServiceCleaner.py index ea171d2a3..e4d0525f4 100644 --- a/server/src/uds/core/workers/DeployedServiceCleaner.py +++ b/server/src/uds/core/workers/DeployedServiceCleaner.py @@ -30,6 +30,7 @@ ''' @author: Adolfo Gómez, dkmaster at dkmon dot com ''' +from __future__ import unicode_literals from django.db import transaction from uds.core.util.Config import GlobalConfig diff --git a/server/src/uds/core/workers/HangedCleaner.py b/server/src/uds/core/workers/HangedCleaner.py index e8a9dbdf6..c9b763526 100644 --- a/server/src/uds/core/workers/HangedCleaner.py +++ b/server/src/uds/core/workers/HangedCleaner.py @@ -30,6 +30,8 @@ ''' @author: Adolfo Gómez, dkmaster at dkmon dot com ''' +from __future__ import unicode_literals + from django.db.models import Q from uds.core.util.Config import GlobalConfig from uds.models import DeployedService, getSqlDatetime diff --git a/server/src/uds/core/workers/PublicationCleaner.py b/server/src/uds/core/workers/PublicationCleaner.py index 3644ed90e..c68fe13b9 100644 --- a/server/src/uds/core/workers/PublicationCleaner.py +++ b/server/src/uds/core/workers/PublicationCleaner.py @@ -30,6 +30,7 @@ ''' @author: Adolfo Gómez, dkmaster at dkmon dot com ''' +from __future__ import unicode_literals from uds.core.managers.PublicationManager import PublicationManager from uds.core.util.Config import GlobalConfig diff --git a/server/src/uds/core/workers/ServiceCacheUpdater.py b/server/src/uds/core/workers/ServiceCacheUpdater.py index 2fc48ef0a..34b2cda0a 100644 --- a/server/src/uds/core/workers/ServiceCacheUpdater.py +++ b/server/src/uds/core/workers/ServiceCacheUpdater.py @@ -30,6 +30,7 @@ ''' @author: Adolfo Gómez, dkmaster at dkmon dot com ''' +from __future__ import unicode_literals from django.db import transaction from django.db.models import Q diff --git a/server/src/uds/core/workers/StatsCollector.py b/server/src/uds/core/workers/StatsCollector.py index 77603a154..45b7d5c45 100644 --- a/server/src/uds/core/workers/StatsCollector.py +++ b/server/src/uds/core/workers/StatsCollector.py @@ -29,6 +29,7 @@ ''' @author: Adolfo Gómez, dkmaster at dkmon dot com ''' +from __future__ import unicode_literals from uds.models import DeployedService from uds.core.util.State import State diff --git a/server/src/uds/core/workers/UserServiceCleaner.py b/server/src/uds/core/workers/UserServiceCleaner.py index 3157b4c84..66227f5e0 100644 --- a/server/src/uds/core/workers/UserServiceCleaner.py +++ b/server/src/uds/core/workers/UserServiceCleaner.py @@ -30,6 +30,7 @@ ''' @author: Adolfo Gómez, dkmaster at dkmon dot com ''' +from __future__ import unicode_literals from django.db import transaction from uds.core.managers.UserServiceManager import UserServiceManager diff --git a/server/src/uds/osmanagers/WindowsOsManager/WinDomainOsManager.py b/server/src/uds/osmanagers/WindowsOsManager/WinDomainOsManager.py index c3cf17cd9..4aacb0d92 100644 --- a/server/src/uds/osmanagers/WindowsOsManager/WinDomainOsManager.py +++ b/server/src/uds/osmanagers/WindowsOsManager/WinDomainOsManager.py @@ -13,7 +13,7 @@ from django.utils.translation import ugettext_noop as _ from uds.core.ui.UserInterface import gui from uds.core.managers.CryptoManager import CryptoManager from uds.core import osmanagers -from WindowsOsManager import WindowsOsManager, scrambleMsg +from WindowsOsManager import WindowsOsManager from uds.core.util import log import dns.resolver import ldap @@ -124,7 +124,7 @@ class WinDomainOsManager(WindowsOsManager): except dns.resolver.NXDOMAIN: # No domain found, log it and pass logger.warn('Could not find _ldap._tcp.'+self._domain) log.doLog(service, log.WARN, "Could not remove machine from domain (_ldap._tcp.{0} not found)".format(self._domain), log.OSMANAGER); - except ldap.LDAPError as e: + except ldap.LDAPError: logger.exception('Ldap Exception caught') log.doLog(service, log.WARN, "Could not remove machine from domain (invalid credentials for {0})".format(self._account), log.OSMANAGER); @@ -149,7 +149,7 @@ class WinDomainOsManager(WindowsOsManager): logger.exception('Exception ') return [False, str(e)] try: - r = l.search_st(self._ou, ldap.SCOPE_BASE) + l.search_st(self._ou, ldap.SCOPE_BASE) except ldap.LDAPError as e: return _('Check error: {0}').format(self.__getLdapError(e)) @@ -213,10 +213,10 @@ class WinDomainOsManager(WindowsOsManager): super(WinDomainOsManager, self).unmarshal(data[5].decode('hex')) def valuesDict(self): - dict = super(WinDomainOsManager,self).valuesDict() - dict['domain'] = self._domain - dict['ou'] = self._ou - dict['account'] = self._account - dict['password'] = self._password - return dict + dct = super(WinDomainOsManager,self).valuesDict() + dct['domain'] = self._domain + dct['ou'] = self._ou + dct['account'] = self._account + dct['password'] = self._password + return dct diff --git a/server/src/uds/services/OVirt/Helpers.py b/server/src/uds/services/OVirt/Helpers.py index 2613501bc..11ad817de 100644 --- a/server/src/uds/services/OVirt/Helpers.py +++ b/server/src/uds/services/OVirt/Helpers.py @@ -4,7 +4,8 @@ Created on Nov 15, 2012 @author: dkmaster ''' -from django.utils.translation import ugettext as _ +from __future__ import unicode_literals + import logging logger = logging.getLogger(__name__) diff --git a/server/src/uds/services/PhysicalMachines/ServiceProvider.py b/server/src/uds/services/PhysicalMachines/ServiceProvider.py index 59f6506df..508cc03d8 100644 --- a/server/src/uds/services/PhysicalMachines/ServiceProvider.py +++ b/server/src/uds/services/PhysicalMachines/ServiceProvider.py @@ -30,9 +30,8 @@ ''' @author: Adolfo Gómez, dkmaster at dkmon dot com ''' +from __future__ import unicode_literals -from django.utils.translation import ugettext as _ -from uds.core.ui.UserInterface import gui from uds.core import services diff --git a/server/src/uds/services/Sample/SampleService.py b/server/src/uds/services/Sample/SampleService.py index e38c96f6d..ca83d369a 100644 --- a/server/src/uds/services/Sample/SampleService.py +++ b/server/src/uds/services/Sample/SampleService.py @@ -31,7 +31,7 @@ .. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com ''' -from django.utils.translation import ugettext_noop as translatable, ugettext as _ +from django.utils.translation import ugettext_noop as translatable from uds.core.services import Service from SamplePublication import SamplePublication from SampleUserDeploymentOne import SampleUserDeploymentOne diff --git a/server/src/uds/web/transformers.py b/server/src/uds/web/transformers.py index 5315ebbc5..0aebabde7 100644 --- a/server/src/uds/web/transformers.py +++ b/server/src/uds/web/transformers.py @@ -56,11 +56,11 @@ def transformId(view_func): return _wrapped_view -def scrambleId(request, id): +def scrambleId(request, id_): if request.session.get(SCRAMBLE_SES) == None: - request.session[SCRAMBLE_SES] = ''.join(random.choice(string.letters) for i in xrange(SCRAMBLE_LEN)) - return base64.b64encode(str(id) + request.session.get(SCRAMBLE_SES)).encode('hex') + request.session[SCRAMBLE_SES] = ''.join(random.choice(string.letters) for _ in xrange(SCRAMBLE_LEN)) + return base64.b64encode(str(id_) + request.session.get(SCRAMBLE_SES)).encode('hex') -def unscrambleId(request, id): - idd = base64.b64decode(id.decode('hex')) +def unscrambleId(request, id_): + idd = base64.b64decode(id_.decode('hex')) return idd[:-SCRAMBLE_LEN] diff --git a/server/src/uds/xmlrpc/osmanagers/OSManagers.py b/server/src/uds/xmlrpc/osmanagers/OSManagers.py index 672955826..23c1fc0c9 100644 --- a/server/src/uds/xmlrpc/osmanagers/OSManagers.py +++ b/server/src/uds/xmlrpc/osmanagers/OSManagers.py @@ -30,6 +30,7 @@ ''' @author: Adolfo Gómez, dkmaster at dkmon dot com ''' +from __future__ import unicode_literals from django.utils.translation import ugettext as _ from django.db import IntegrityError @@ -51,8 +52,8 @@ def getOSManagersTypes(credentials): Returns the types of services providers registered in system ''' res = [] - for type in OSManagersFactory.factory().providers().values(): - val = { 'name' : type.name(), 'type' : type.type(), 'description' : type.description(), 'icon' : type.icon() } + for type_ in OSManagersFactory.factory().providers().values(): + val = { 'name' : type_.name(), 'type' : type_.type(), 'description' : type_.description(), 'icon' : type_.icon() } res.append(val) return res @@ -71,19 +72,19 @@ def getOSManagers(credentials): return res @needs_credentials -def getOSManagerGui(credentials, type): +def getOSManagerGui(credentials, type_): ''' Returns the description of an gui for the specified service provider ''' - spType = OSManagersFactory.factory().lookup(type) + spType = OSManagersFactory.factory().lookup(type_) return spType.guiDescription() @needs_credentials -def getOSManager(credentials, id): +def getOSManager(credentials, id_): ''' Returns the specified service provider (at database) ''' - data = OSManager.objects.get(pk=id) + data = OSManager.objects.get(pk=id_) res = [ { 'name' : 'name', 'value' : data.name }, { 'name' : 'comments', 'value' : data.comments }, @@ -97,52 +98,52 @@ def getOSManager(credentials, id): return res @needs_credentials -def createOSManager(credentials, type, data): +def createOSManager(credentials, type_, data): ''' - Creates a new service provider with specified type and data + Creates a new service provider with specified type_ and data It's mandatory that data contains at least 'name' and 'comments'. The expected structure is the same that provided at getServiceProvider ''' - dict = dictFromData(data) + dct = dictFromData(data) try: # First create data without serialization, then serialies data with correct environment - sp = OSManager.objects.create(name = dict['name'], comments = dict['comments'], data_type = type) - sp.data = sp.getInstance(dict).serialize() + sp = OSManager.objects.create(name = dct['name'], comments = dct['comments'], data_type = type_) + sp.data = sp.getInstance(dct).serialize() sp.save() except osmanagers.OSManager.ValidationException, e: sp.delete() raise ValidationException(str(e)) except IntegrityError: # Must be exception at creation - raise InsertException(_('Name %s already exists') % (dict['name'])) + raise InsertException(_('Name %s already exists') % (dct['name'])) return True @needs_credentials -def modifyOSManager(credentials, id, data): +def modifyOSManager(credentials, id_, data): ''' - Modifies an existing service provider with specified id and data + Modifies an existing service provider with specified id_ and data It's mandatory that data contains at least 'name' and 'comments'. The expected structure is the same that provided at getServiceProvider ''' - osm = OSManager.objects.get(pk=id) + osm = OSManager.objects.get(pk=id_) dps = osm.deployedServices.all().count() if dps > 0: errorDps = ','.join([ o.name for o in osm.deployedServices.all()]) raise ModifyException(_('This os mnager is being used by deployed services') + ' ' + errorDps) - dict = dictFromData(data) - sp = osm.getInstance(dict) + dct = dictFromData(data) + sp = osm.getInstance(dct) osm.data = sp.serialize() - osm.name = dict['name'] - osm.comments = dict['comments'] + osm.name = dct['name'] + osm.comments = dct['comments'] osm.save() return True @needs_credentials -def removeOSManager(credentials, id): +def removeOSManager(credentials, id_): ''' - Removes from os manager with specified id + Removes from os manager with specified id_ ''' try: - if OSManager.objects.get(pk=id).remove() == False: + if OSManager.objects.get(pk=id_).remove() == False: raise DeleteException(_('There is deployed services using this os manager')) except OSManager.DoesNotExist: raise FindException(_('Can\'t find os manager')) @@ -150,23 +151,23 @@ def removeOSManager(credentials, id): return True @needs_credentials -def testOsManager(credentials, type, data): +def testOsManager(credentials, type_, data): ''' - invokes the test function of the specified service provider type, with the suplied data + invokes the test function of the specified service provider type_, with the suplied data ''' - logger.debug("Testing service provider, type: {0}, data:{1}".format(type, data)) - spType = OSManagersFactory.factory().lookup(type) + logger.debug("Testing service provider, type_: {0}, data:{1}".format(type_, data)) + spType = OSManagersFactory.factory().lookup(type_) # We need an "temporary" environment to test this service - dict = dictFromData(data) - res = spType.test(Environment.getTempEnv(), dict) + dct = dictFromData(data) + res = spType.test(Environment.getTempEnv(), dct) return {'ok' : res[0], 'message' : res[1]} @needs_credentials -def checkOSManager(credentials, id): +def checkOSManager(credentials, id_): ''' Invokes the check function of the specified service provider ''' - prov = OSManager.objects.get(id=id) + prov = OSManager.objects.get(pk=id_) sp = prov.getInstance() return sp.check()