1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-03-30 18:50:20 +03:00

Refactoring

This commit is contained in:
Adolfo Gómez García 2017-03-06 09:30:36 +01:00
commit 8ebc0aeaaf
15 changed files with 27 additions and 28 deletions

View File

@ -237,11 +237,10 @@ class RegexLdap(auths.Authenticator):
l.simple_bind_s(who=username, cred=password)
except ldap.LDAPError as e:
str_ = _('Ldap connection error: ')
if type(e.message) == dict:
str_ += 'info' in e.message and e.message['info'] + ',' or ''
str_ += 'desc' in e.message and e.message['desc'] or ''
if isinstance(e.message, dict):
str_ += ', '.join(e.message.get('info', ''), e.message.get('desc'))
else:
str_ += str(e)
str_ += six.text_type(e)
raise Exception(str_)
if cache is True:
self._connection = l

View File

@ -169,11 +169,10 @@ class SimpleLDAPAuthenticator(Authenticator):
l.simple_bind_s(who=username, cred=password)
except ldap.LDAPError as e:
str_ = _('Ldap connection error: ')
if type(e.message) == dict:
str_ += 'info' in e.message and e.message['info'] + ',' or ''
str_ += 'desc' in e.message and e.message['desc'] or ''
if isinstance(e.message, dict):
str_ += ', '.join(e.message.get('info', ''), e.message.get('desc'))
else:
str_ += str_(e)
str_ += six.text_type(e)
raise Exception(str_)
if cache is True:
self._connection = l

View File

@ -177,7 +177,7 @@ class UserPreference(object):
'''
raise NotImplementedError('Can\'t create an abstract preference!!!')
def guiField(self):
def guiField(self, value):
'''
'''
raise NotImplementedError('Can\'t create an abstract preference!!!')

View File

@ -38,11 +38,11 @@ import pickle
import six
class Attribute(object):
def __init__(self, theType, value=None):
self._type = theType
self._value = None
self.setValue(value)
def getType(self):
@ -76,6 +76,7 @@ class AutoAttributes(Serializable):
ACODEC = 'zip'
def __init__(self, **kwargs):
self._dict = None
self.declare(**kwargs)
def __getattribute__(self, name):

View File

@ -50,6 +50,7 @@ class UniqueMacGenerator(UniqueIDGenerator):
def __toMac(self, seq):
return re.sub(r"(..)", r"\1:", "%0*X" % (12, seq))[:-1]
# noinspection PyMethodOverriding
def get(self, macRange):
firstMac, lastMac = macRange.split('-')
firstMac = self.__toInt(firstMac)

View File

@ -38,6 +38,7 @@ import logging
logger = logging.getLogger(__name__)
# noinspection PyMethodOverriding
class UniqueNameGenerator(UniqueIDGenerator):
def __init__(self, owner):

View File

@ -89,7 +89,6 @@ def make(obj, counterType, **kwargs):
'tickCount': 4,
}
},
'legend': {'hide': True},
'background': {
'chartColor': '#ffeeff',
'baseColor': '#ffffff',

View File

@ -75,8 +75,7 @@ class Cache(models.Model):
v.delete()
def __unicode__(self):
expired = getSqlDatetime() > self.created + timedelta(seconds=self.validity)
if expired:
if getSqlDatetime() > (self.created + timedelta(seconds=self.validity)):
expired = "Expired"
else:
expired = "Active"

View File

@ -130,7 +130,7 @@ class LinuxOsManager(osmanagers.OSManager):
except Exception:
log.doLog(service, log.ERROR, "do not understand {0}".format(data), origin)
def process(self, userService, msg, data, options):
def process(self, userService, msg, data, options=None):
'''
We understand this messages:
* msg = info, data = None. Get information about name of machine (or domain, in derived WinDomainOsManager class), old method

View File

@ -139,7 +139,7 @@ class WindowsOsManager(osmanagers.OSManager):
logger.exception('WindowsOs Manager message log: ')
log.doLog(service, log.ERROR, "do not understand {0}".format(data), origin)
def process(self, userService, msg, data, options):
def process(self, userService, msg, data, options=None):
'''
We understand this messages:
* msg = info, data = None. Get information about name of machine (or domain, in derived WinDomainOsManager class) (old method)

View File

@ -50,6 +50,7 @@ __updated__ = '2015-06-21'
availableReports = []
# noinspection PyTypeChecker
def __init__():
'''
This imports all packages that are descendant of this package, and, after that,

View File

@ -39,7 +39,7 @@ from uds.core.ui import gui
import logging
__updated__ = '2017-02-09'
__updated__ = '2017-03-03'
logger = logging.getLogger(__name__)
@ -51,11 +51,11 @@ class OGService(Service):
# : Name to show the administrator. This string will be translated BEFORE
# : sending it to administration interface, so don't forget to
# : mark it as _ (using ugettext_noop)
typeName = _('OpenGnsys Live Images')
typeName = _('OpenGnsys Machine')
# : Type used internally to identify this provider
typeType = 'openNebulaLiveService'
typeType = 'openGnsysMachine'
# : Description shown at administration interface for this provider
typeDescription = _('OpenGnsys live images based service')
typeDescription = _('OpenGnsys physical machines')
# : Icon file used as icon for this provider. This string will be translated
# : BEFORE sending it to administration interface, so don't forget to
# : mark it as _ (using ugettext_noop)
@ -91,14 +91,14 @@ class OGService(Service):
servicesTypeProvided = (serviceTypes.VDI,)
# Now the form part
datastore = gui.ChoiceField(
label=_("Datastore"),
ou = gui.ChoiceField(
label=_("OU"),
order=100,
tooltip=_('Service clones datastore'),
tooltip=_('Organizational Unit'),
required=True
)
template = gui.ChoiceField(
lab = gui.ChoiceField(
label=_("Base Template"),
order=110,
tooltip=_('Service base template'),

View File

@ -39,7 +39,6 @@ class PhysicalMachinesProvider(services.ServiceProvider):
# No extra data needed
# What services do we offer?
offers = []
typeName = 'Static IP Machines Provider'
typeType = 'PhysicalMachinesServiceProvider'
typeDescription = 'Provides connection to machines by IP'

View File

@ -27,9 +27,6 @@ if not os.path.isfile(remoteViewer):
theFile = '''{m.r.as_file}'''
filename = tools.saveTempFile(theFile)
filename = tools.saveTempFile(theFile)
subprocess.Popen([remoteViewer, filename])

View File

@ -4,13 +4,16 @@ import sys
import os
import errno
import pwd
import six
USER = '__USER__'
KEY = '__KEY__'
def logError(err):
print(err)
def updateAuthorizedKeys(user, pubKey):
# No X2Go server on windows
if 'win' in sys.platform:
@ -49,7 +52,7 @@ def updateAuthorizedKeys(user, pubKey):
if 'UDS@X2GOCLIENT' not in line and len(line.strip()) > 0:
f.write(line)
# Append pubkey
f.write('ssh-rsa {} UDS@X2GOCLIENT\n'.format(pubKey))
f.write(six.binary_type('ssh-rsa {} UDS@X2GOCLIENT\n'.format(pubKey)))
# Ensure access is correct
os.chown(authorizedKeys, uid, -1)