1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-01-08 21:18:00 +03:00

Fixing up several minor lang issues

This commit is contained in:
Adolfo Gómez García 2015-09-07 21:40:12 +02:00
parent c6683db6e6
commit e0843179cd
21 changed files with 239 additions and 239 deletions

View File

@ -9,6 +9,6 @@ ovirt-engine-sdk-python
pycurl
pyOpenSSL
python-ldap
six
MySQL-python
reportlab
bitarray

View File

@ -37,7 +37,7 @@ from uds.models import User, Service, UserService, DeployedService, getSqlDateti
from uds.core.util.stats import counters
from uds.core.util.Cache import Cache
from uds.REST import Handler, RequestError, ResponseError
import cPickle
import pickle
from datetime import timedelta
import logging
@ -70,11 +70,11 @@ def getServicesPoolsCounters(servicePool, counter_type):
for x in counters.getCounters(us, counter_type, since=since, to=to, limit=POINTS, use_max=USE_MAX, all=complete):
val.append({'stamp': x[0], 'value': int(x[1])})
if len(val) > 2:
cache.put(cacheKey, cPickle.dumps(val).encode('zip'), 600)
cache.put(cacheKey, pickle.dumps(val).encode('zip'), 600)
else:
val = [{'stamp': since, 'value': 0}, {'stamp': to, 'value': 0}]
else:
val = cPickle.loads(val.decode('zip'))
val = pickle.loads(val.decode('zip'))
return val
except:

View File

@ -141,7 +141,7 @@ class gui(object):
'''
if isinstance(str_, bool):
return str_
if unicode(str_).lower() == gui.TRUE:
if six.text_type(str_).lower() == gui.TRUE:
return True
return False
@ -219,7 +219,7 @@ class gui(object):
'length': options.get('length', gui.InputField.DEFAULT_LENTGH),
'required': options.get('required', False),
'label': options.get('label', ''),
'defvalue': unicode(options.get('defvalue', '')),
'defvalue': six.text_type(options.get('defvalue', '')),
'rdonly': options.get('rdonly', False), # This property only affects in "modify" operations
'order': options.get('order', 0),
'tooltip': options.get('tooltip', ''),

View File

@ -32,7 +32,7 @@
'''
from uds.core.Serializable import Serializable
import cPickle
import pickle
import timeit
@ -93,7 +93,7 @@ class AutoAttributes(Serializable):
self.dict = d
def marshal(self):
return '\2'.join(['%s\1%s' % (k, cPickle.dumps(v)) for k, v in self.dict.iteritems()]).encode(AutoAttributes.ACODEC)
return '\2'.join(['%s\1%s' % (k, pickle.dumps(v)) for k, v in self.dict.iteritems()]).encode(AutoAttributes.ACODEC)
def unmarshal(self, data):
if data == '': # Can be empty
@ -101,7 +101,7 @@ class AutoAttributes(Serializable):
# We keep original data (maybe incomplete)
for pair in data.decode(AutoAttributes.ACODEC).split('\2'):
k, v = pair.split('\1')
self.dict[k] = cPickle.loads(str(v))
self.dict[k] = pickle.loads(str(v))
def __str__(self):
str_ = '<AutoAttribute '

View File

@ -36,7 +36,7 @@ from uds.models import Cache as dbCache, getSqlDatetime
from datetime import datetime, timedelta
import hashlib
import logging
import cPickle
import pickle
logger = logging.getLogger(__name__)
@ -62,7 +62,7 @@ class Cache(object):
expired = now > c.created + timedelta(seconds=c.validity)
if expired:
return defValue
val = cPickle.loads(c.value.decode(Cache.CODEC))
val = pickle.loads(c.value.decode(Cache.CODEC))
return val
except dbCache.DoesNotExist: # @UndefinedVariable
logger.debug('key not found: {}'.format(skey))
@ -90,7 +90,7 @@ class Cache(object):
if validity is None:
validity = Cache.DEFAULT_VALIDITY
key = self.__getKey(skey)
value = cPickle.dumps(value).encode(Cache.CODEC)
value = pickle.dumps(value).encode(Cache.CODEC)
now = getSqlDatetime()
try:
dbCache.objects.create(owner=self._owner, key=key, value=value, created=now, validity=validity) # @UndefinedVariable

View File

@ -36,7 +36,7 @@ from django.db import transaction
from uds.models import Storage as dbStorage
import hashlib
import logging
import cPickle
import pickle
logger = logging.getLogger(__name__)
@ -69,7 +69,7 @@ class Storage(object):
return self.saveData(skey, data)
def putPickle(self, skey, data, attr1=None):
return self.saveData(skey, cPickle.dumps(data), attr1)
return self.saveData(skey, pickle.dumps(data), attr1)
def updateData(self, skey, data, attr1=None):
self.saveData(skey, data, attr1)
@ -98,12 +98,12 @@ class Storage(object):
def getPickle(self, skey):
v = self.readData(skey, True)
if v is not None:
v = cPickle.loads(v)
v = pickle.loads(v)
return v
def getPickleByAttr1(self, attr1):
try:
return cPickle.loads(dbStorage.objects.get(owner=self._owner, attr1=attr1).data.decode(Storage.CODEC)) # @UndefinedVariable
return pickle.loads(dbStorage.objects.get(owner=self._owner, attr1=attr1).data.decode(Storage.CODEC)) # @UndefinedVariable
except Exception:
return None
@ -144,7 +144,7 @@ class Storage(object):
query = dbStorage.objects.filter(owner=self._owner, attr1=attr1) # @UndefinedVariable
for v in query: # @UndefinedVariable
yield (v.key, cPickle.loads(v.data.decode(Storage.CODEC)), v.attr1)
yield (v.key, pickle.loads(v.data.decode(Storage.CODEC)), v.attr1)
@staticmethod
def delete(owner=None):

View File

@ -32,7 +32,7 @@
'''
from __future__ import unicode_literals
from UniqueIDGenerator import UniqueIDGenerator
from .UniqueIDGenerator import UniqueIDGenerator
import logging
logger = logging.getLogger(__name__)

View File

@ -32,7 +32,7 @@
'''
from __future__ import unicode_literals
from UniqueIDGenerator import UniqueIDGenerator
from .UniqueIDGenerator import UniqueIDGenerator
import logging
import re

View File

@ -32,7 +32,7 @@
'''
from __future__ import unicode_literals
from UniqueIDGenerator import UniqueIDGenerator
from .UniqueIDGenerator import UniqueIDGenerator
import logging
logger = logging.getLogger(__name__)

View File

@ -40,17 +40,17 @@ from django.utils.encoding import python_2_unicode_compatible
from uds.core.util.State import State
from uds.core.util import log
from uds.models.UUIDModel import UUIDModel
from .UUIDModel import UUIDModel
from uds.models.Authenticator import Authenticator
from uds.models.User import User
from uds.models.Util import UnsavedForeignKey, getSqlDatetime
from .Authenticator import Authenticator
from .User import User
from .Util import UnsavedForeignKey, getSqlDatetime
import logging
logger = logging.getLogger(__name__)
__updated__ = '2015-04-30'
__updated__ = '2015-09-07'
@python_2_unicode_compatible

View File

@ -34,10 +34,10 @@ from uds.core.services import UserDeployment
from uds.core.util.State import State
from uds.core.util import log
import cPickle
import pickle
import logging
__updated__ = '2015-06-09'
__updated__ = '2015-09-07'
logger = logging.getLogger(__name__)
@ -75,7 +75,7 @@ class OVirtLinkedDeployment(UserDeployment):
'''
Does nothing right here, we will use envoronment storage in this sample
'''
return '\1'.join(['v1', self._name, self._ip, self._mac, self._vmid, self._reason, cPickle.dumps(self._queue)])
return '\1'.join(['v1', self._name, self._ip, self._mac, self._vmid, self._reason, pickle.dumps(self._queue)])
def unmarshal(self, str_):
'''
@ -84,7 +84,7 @@ class OVirtLinkedDeployment(UserDeployment):
vals = str_.split('\1')
if vals[0] == 'v1':
self._name, self._ip, self._mac, self._vmid, self._reason, queue = vals[1:]
self._queue = cPickle.loads(queue)
self._queue = pickle.loads(queue)
def getName(self):
'''

View File

@ -37,15 +37,16 @@ from __future__ import unicode_literals
from django.utils.translation import ugettext_noop as _
from uds.core.util.State import State
from uds.core.services import ServiceProvider
from OVirtLinkedService import OVirtLinkedService
from uds.core.ui import gui
from uds.core.util import validators
from client import oVirtClient
from .OVirtLinkedService import OVirtLinkedService
from .client import oVirtClient
import logging
__updated__ = '2015-07-24'
__updated__ = '2015-09-07'
logger = logging.getLogger(__name__)

View File

@ -28,5 +28,5 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from OVirtProvider import Provider
from .OVirtProvider import Provider

View File

@ -10,7 +10,7 @@ from ovirtsdk.api import API
import threading
import logging
__updated__ = '2015-06-12'
__updated__ = '2015-09-07'
logger = logging.getLogger(__name__)
@ -373,7 +373,7 @@ class Client(object):
if vm.get_status().get_state() != 'down':
raise Exception('Machine must be in down state to publish it')
print vm.disks.list()
print(vm.disks.list())
# Create disks description to be created in specified storage domain, one for each disk
sd = params.StorageDomains(storage_domain=[params.StorageDomain(id=storageId)])

View File

@ -34,11 +34,10 @@
from django.utils.translation import ugettext_lazy as _
from uds.core import services
from uds.core.services import types as serviceTypes
from uds.core.util.AutoAttributes import AutoAttributes
from uds.core.ui.UserInterface import gui
from IPMachineDeployed import IPMachineDeployed
from .IPMachineDeployed import IPMachineDeployed
import logging
import cPickle
import pickle
logger = logging.getLogger(__name__)
@ -79,12 +78,12 @@ class IPMachinesService(services.Service):
return {'ipList': gui.convertToList(ips)}
def marshal(self):
self.storage().saveData('ips', cPickle.dumps(self._ips))
self.storage().saveData('ips', pickle.dumps(self._ips))
return 'v1'
def unmarshal(self, vals):
if vals == 'v1':
self._ips = cPickle.loads(str(self.storage().readData('ips')))
self._ips = pickle.loads(str(self.storage().readData('ips')))
def getUnassignedMachine(self):
# Search first unassigned machine

View File

@ -45,7 +45,7 @@ class PhysicalMachinesProvider(services.ServiceProvider):
typeDescription = 'Provides connection to Virtual Center Services'
iconFile = 'provider.png'
from IPMachinesService import IPMachinesService
from .IPMachinesService import IPMachinesService
offers = [IPMachinesService]
def __unicode__(self):

View File

@ -31,8 +31,8 @@
@author: Adolfo Gómez, dkmaster at dkmon dot com
'''
from ServiceProvider import PhysicalMachinesProvider
from .ServiceProvider import PhysicalMachinesProvider
# Now we use __subclasses__ method to locate Service Providers
# and register them inside factory
#ServiceProviderFactory.factory().insert(PhysicalMachinesProvider)
# ServiceProviderFactory.factory().insert(PhysicalMachinesProvider)

View File

@ -35,7 +35,7 @@ Created on Jun 22, 2012
from django.utils.translation import ugettext_noop as _
from uds.core.services import ServiceProvider
from SampleService import ServiceOne, ServiceTwo
from .SampleService import ServiceOne, ServiceTwo
from uds.core.ui import gui
import logging
@ -60,19 +60,19 @@ class Provider(ServiceProvider):
we MUST register it at package __init__.
'''
#: What kind of services we offer, this are classes inherited from Service
# : What kind of services we offer, this are classes inherited from Service
offers = [ServiceOne, ServiceTwo]
#: 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)
# : 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 = _('Sample Provider')
#: Type used internally to identify this provider
# : Type used internally to identify this provider
typeType = 'SampleProvider'
#: Description shown at administration interface for this provider
# : Description shown at administration interface for this provider
typeDescription = _('Sample (and dummy) service provider')
#: 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)
# : 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)
iconFile = 'provider.png'
# now comes the form fields
@ -85,39 +85,39 @@ class Provider(ServiceProvider):
# If we don't indicate an order, the output order of fields will be
# "random"
#: Remote host. Here core will translate label and tooltip, remember to
#: mark them as _ using ugettext_noop.
# : Remote host. Here core will translate label and tooltip, remember to
# : mark them as _ using ugettext_noop.
remoteHost = gui.TextField(oder=1,
length=64,
label=_('Remote host'),
tooltip=_('This fields contains a remote host'),
required=True,
)
#: Name of your pet (sample, not really needed :-) )
# : Name of your pet (sample, not really needed :-) )
petName = gui.TextField(order=2,
length=32,
label=_('Your pet\'s name'),
tooltip=_('If you like, write the name of your pet'),
requred=False,
defvalue='Tux' #: This will not get translated
defvalue='Tux' # : This will not get translated
)
#: Age of Methuselah (matusalén in spanish)
#: in Spain there is a well-known to say that something is very old,
#: "Tiene mas años que matusalén"(is older than Methuselah)
# : Age of Methuselah (matusalén in spanish)
# : in Spain there is a well-known to say that something is very old,
# : "Tiene mas años que matusalén"(is older than Methuselah)
methAge = gui.NumericField(order=3,
length=4, # That is, max allowed value is 9999
label=_('Age of Methuselah'),
tooltip=_('If you know it, please, tell me!!!'),
required=True, #: Numeric fields have always a value, so this not really needed
required=True, # : Numeric fields have always a value, so this not really needed
defvalue='4500'
)
#: Is Methuselah istill alive?
# : Is Methuselah istill alive?
methAlive = gui.CheckBoxField(order=4,
label=_('Is Methuselah still alive?'),
tooltip=_('If you fail, this will not get saved :-)'),
required=True, #: Also means nothing. Check boxes has always a value
defvalue=gui.TRUE #: By default, at new item, check this
required=True, # : Also means nothing. Check boxes has always a value
defvalue=gui.TRUE # : By default, at new item, check this
)
# There is more fields type, but not here the best place to cover it

View File

@ -33,9 +33,9 @@
from django.utils.translation import ugettext_noop as _
from uds.core.services import Service
from SamplePublication import SamplePublication
from SampleUserDeploymentOne import SampleUserDeploymentOne
from SampleUserDeploymentTwo import SampleUserDeploymentTwo
from .SamplePublication import SamplePublication
from .SampleUserDeploymentOne import SampleUserDeploymentOne
from .SampleUserDeploymentTwo import SampleUserDeploymentTwo
from uds.core.ui import gui
@ -65,81 +65,81 @@ class ServiceOne(Service):
information.
'''
#: 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)
# : 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 = _('Sample Service One')
#: Type used internally to identify this provider
# : Type used internally to identify this provider
typeType = 'SampleService1'
#: Description shown at administration interface for this provider
# : Description shown at administration interface for this provider
typeDescription = _('Sample (and dummy) service ONE')
#: 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)
# : 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)
iconFile = 'service.png'
# Functional related data
#: If the service provides more than 1 "deployed user" (-1 = no limit,
#: 0 = ???? (do not use it!!!), N = max number to deploy
# : If the service provides more than 1 "deployed user" (-1 = no limit,
# : 0 = ???? (do not use it!!!), N = max number to deploy
maxDeployed = -1
#: If we need to generate "cache" for this service, so users can access the
#: provided services faster. Is usesCache is True, you will need also
#: set publicationType, do take care about that!
# : If we need to generate "cache" for this service, so users can access the
# : provided services faster. Is usesCache is True, you will need also
# : set publicationType, do take care about that!
usesCache = False
#: Tooltip shown to user when this item is pointed at admin interface, none
#: because we don't use it
# : Tooltip shown to user when this item is pointed at admin interface, none
# : because we don't use it
cacheTooltip = _('None')
#: If we need to generate a "Level 2" cache for this service (i.e., L1
#: could be running machines and L2 suspended machines)
# : If we need to generate a "Level 2" cache for this service (i.e., L1
# : could be running machines and L2 suspended machines)
usesCache_L2 = False
#: Tooltip shown to user when this item is pointed at admin interface, None
#: also because we don't use it
# : Tooltip shown to user when this item is pointed at admin interface, None
# : also because we don't use it
cacheTooltip_L2 = _('None')
#: If the service needs a s.o. manager (managers are related to agents
#: provided by services itselfs, i.e. virtual machines with actors)
# : If the service needs a s.o. manager (managers are related to agents
# : provided by services itselfs, i.e. virtual machines with actors)
needsManager = False
#: If true, the system can't do an automatic assignation of a deployed user
#: service from this service
# : If true, the system can't do an automatic assignation of a deployed user
# : service from this service
mustAssignManually = False
#: Types of publications (preparated data for deploys)
#: In our case, we do no need a publication, so this is None
# : Types of publications (preparated data for deploys)
# : In our case, we do no need a publication, so this is None
publicationType = None
#: Types of deploys (services in cache and/or assigned to users)
# : Types of deploys (services in cache and/or assigned to users)
deployedType = SampleUserDeploymentOne
# Now the form part, this service will have only two "dummy" fields
# If we don't indicate an order, the output order of fields will be
# "random"
colour = gui.ChoiceField(order = 1,
label = _('Colour'),
tooltip = _('Colour of the field'),
colour = gui.ChoiceField(order=1,
label=_('Colour'),
tooltip=_('Colour of the field'),
# In this case, the choice can have none value selected by default
required = True,
values = [ gui.choiceItem('red', 'Red'),
required=True,
values=[ gui.choiceItem('red', 'Red'),
gui.choiceItem('green', 'Green'),
gui.choiceItem('blue', 'Blue'),
gui.choiceItem('nonsense', 'Blagenta')
],
defvalue = '1' # Default value is the ID of the choicefield
defvalue='1' # Default value is the ID of the choicefield
)
passw = gui.PasswordField(order = 2,
label = _('Password'),
tooltip = _('Password for testing purposes'),
required = True,
defvalue = '1234' #: Default password are nonsense?? :-)
passw = gui.PasswordField(order=2,
label=_('Password'),
tooltip=_('Password for testing purposes'),
required=True,
defvalue='1234' # : Default password are nonsense?? :-)
)
baseName = gui.TextField(order = 3,
label = _('Services names'),
tooltip = _('Base name for this user services'),
baseName = gui.TextField(order=3,
label=_('Services names'),
tooltip=_('Base name for this user services'),
# In this case, the choice can have none value selected by default
required = True,
defvalue = '' # Default value is the ID of the choicefield
required=True,
defvalue='' # Default value is the ID of the choicefield
)
def initialize(self, values):
@ -196,7 +196,7 @@ class ServiceTwo(Service):
typeName = _('Sample Service Two')
typeType = 'SampleService2'
typeDescription = _('Sample (and dummy) service ONE+ONE')
iconFile = 'provider.png' #: We reuse provider icon here :-)
iconFile = 'provider.png' # : We reuse provider icon here :-)
# Functional related data
maxDeployed = 5
@ -208,18 +208,18 @@ class ServiceTwo(Service):
needsManager = False
mustAssignManually = False
#: Types of publications. In this case, we will include a publication
#: type for this one
#: Note that this is a MUST if you indicate that needPublication
# : Types of publications. In this case, we will include a publication
# : type for this one
# : Note that this is a MUST if you indicate that needPublication
publicationType = SamplePublication
#: Types of deploys (services in cache and/or assigned to users)
# : Types of deploys (services in cache and/or assigned to users)
deployedType = SampleUserDeploymentTwo
# Gui, we will use here the EditableList field
names = gui.EditableList(label=_('List of names'))
def __init__(self, environment, parent, values = None):
def __init__(self, environment, parent, values=None):
'''
We here can get a HUGE list from client.
Right now, this is treated same as other fields, in a near

View File

@ -40,5 +40,5 @@ For this, we must simply import the class at __init__, UDS will take care
of the rest
'''
from SampleProvider import Provider
from .SampleProvider import Provider

View File

@ -37,7 +37,7 @@ from uds.core.util import log
from uds.services.Xen.xen_client import XenPowerState
import cPickle
import pickle
import logging
logger = logging.getLogger(__name__)
@ -76,7 +76,7 @@ class XenLinkedDeployment(UserDeployment):
'''
Does nothing right here, we will use envoronment storage in this sample
'''
return '\1'.join(['v1', self._name, self._ip, self._mac, self._vmid, self._reason, cPickle.dumps(self._queue), self._task])
return '\1'.join(['v1', self._name, self._ip, self._mac, self._vmid, self._reason, pickle.dumps(self._queue), self._task])
def unmarshal(self, str_):
'''
@ -85,7 +85,7 @@ class XenLinkedDeployment(UserDeployment):
vals = str_.split('\1')
if vals[0] == 'v1':
self._name, self._ip, self._mac, self._vmid, self._reason, queue, self._task = vals[1:]
self._queue = cPickle.loads(queue)
self._queue = pickle.loads(queue)
def getName(self):
'''