1
0
mirror of https://github.com/dkmstr/openuds.git synced 2024-12-22 13:34:04 +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,7 +31,7 @@
@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

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

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

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):
'''