当前位置: 首页>>代码示例>>Python>>正文


Python model.processUuid函数代码示例

本文整理汇总了Python中uds.core.util.model.processUuid函数的典型用法代码示例。如果您正苦于以下问题:Python processUuid函数的具体用法?Python processUuid怎么用?Python processUuid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了processUuid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: beforeSave

    def beforeSave(self, fields):
        # logger.debug(self._params)
        try:
            # **** IMAGE ***
            imgId = fields['image_id']
            fields['image_id'] = None
            logger.debug('Image id: {}'.format(imgId))
            try:
                if imgId != '-1':
                    image = Image.objects.get(uuid=processUuid(imgId))
                    fields['image_id'] = image.id
            except Exception:
                logger.exception('At image recovering')

            # Servicepool Group
            spgrpId = fields['servicesPoolGroup_id']
            fields['servicesPoolGroup_id'] = None
            logger.debug('servicesPoolGroup_id: {}'.format(spgrpId))
            try:
                if spgrpId != '-1':
                    spgrp = ServicesPoolGroup.objects.get(uuid=processUuid(spgrpId))
                    fields['servicesPoolGroup_id'] = spgrp.id
            except Exception:
                logger.exception('At service pool group recovering')

        except (RequestError, ResponseError):
            raise
        except Exception as e:
            raise RequestError(str(e))

        logger.debug('Fields: {}'.format(fields))
开发者ID:dkmstr,项目名称:openuds,代码行数:31,代码来源:meta_pools.py

示例2: saveItem

    def saveItem(self, parent, item):
        # If already exists
        uuid = processUuid(item) if item is not None else None

        calendar = Calendar.objects.get(uuid=processUuid(self._params['calendarId']))
        action = self._params['action'].upper()
        eventsOffset = int(self._params['eventsOffset'])
        atStart = self._params['atStart'] not in ('false', False, '0', 0)
        params = json.dumps(self._params['params'])

        logger.debug('Got parameters: {} {} {} {} ----> {}'.format(calendar, action, eventsOffset, atStart, params))

        if uuid is not None:
            calAction = CalendarAction.objects.get(uuid=uuid)
            calAction.calendar = calendar
            calAction.service_pool = parent
            calAction.action = action
            calAction.at_start = atStart
            calAction.events_offset = eventsOffset
            calAction.params = params
            calAction.save()
        else:
            CalendarAction.objects.create(calendar=calendar, service_pool=parent, action=action, at_start=atStart, events_offset=eventsOffset, params=params)

        return self.success()
开发者ID:joaoguariglia,项目名称:openuds,代码行数:25,代码来源:services_pool_calendars.py

示例3: saveItem

    def saveItem(self, parent, item):
        # If already exists
        uuid = processUuid(item) if item is not None else None

        try:
            calendar = Calendar.objects.get(uuid=processUuid(self._params['calendarId']))
            access = self._params['access'].upper()
            if access not in ('ALLOW', 'DENY'):
                raise Exception()
        except Exception:
            self.invalidRequestException(_('Invalid parameters on request'))
        priority = int(self._params['priority'])

        if uuid is not None:
            calAccess = parent.calendarAccess.get(uuid=uuid)
            calAccess.calendar = calendar
            calAccess.service_pool = parent
            calAccess.access = access
            calAccess.priority = priority
            calAccess.save()
        else:
            parent.calendarAccess.create(calendar=calendar, access=access, priority=priority)

        log.doLog(parent, log.INFO, "Added access calendar {}/{} by {}".format(calendar.name, access, self._user.pretty_name), log.ADMIN)

        return self.success()
开发者ID:dkmstr,项目名称:openuds,代码行数:26,代码来源:op_calendars.py

示例4: getItems

 def getItems(self, parent, item):
     # Extract provider
     try:
         if item is None:
             return [AssignedService.itemToDict(k) for k in parent.assignedUserServices().all()
                     .prefetch_related('properties').prefetch_related('deployed_service').prefetch_related('publication')]
         else:
             return parent.assignedUserServices().get(processUuid(uuid=processUuid(item)))
     except Exception:
         logger.exception('getItems')
         self.invalidItemException()
开发者ID:joaoguariglia,项目名称:openuds,代码行数:11,代码来源:user_services.py

示例5: userServices

    def userServices(self, parent, item):
        uuid = processUuid(item)
        user = parent.users.get(uuid=processUuid(uuid))
        res = []
        for i in user.userServices.all():
            if i.state == State.USABLE:
                v = AssignedService.itemToDict(i)
                v['pool'] = i.deployed_service.name
                v['pool_id'] = i.deployed_service.uuid
                res.append(v)

        return res
开发者ID:glyptodon,项目名称:openuds,代码行数:12,代码来源:users_groups.py

示例6: serviceImage

def serviceImage(request, idImage):
    try:
        icon = Image.objects.get(uuid=processUuid(idImage))
        return icon.imageResponse()
    except Image.DoesNotExist:
        pass  # Tries to get image from transport

    try:
        icon = Transport.objects.get(uuid=processUuid(idImage)).getInstance().icon(False)
        return HttpResponse(icon, content_type='image/png')
    except Exception:
        return HttpResponse(DEFAULT_IMAGE, content_type='image/png')
开发者ID:joaoguariglia,项目名称:openuds,代码行数:12,代码来源:service.py

示例7: servicesPools

    def servicesPools(self, parent, item):
        uuid = processUuid(item)
        group = parent.groups.get(uuid=processUuid(uuid))
        res = []
        for i in getPoolsForGroups((group,)):
            res.append({
                'id': i.uuid,
                'name': i.name,
                'thumb': i.image.thumb64 if i.image is not None else DEFAULT_THUMB_BASE64,
                'user_services_count': i.userServices.exclude(state__in=(State.REMOVED, State.ERROR)).count(),
                'state': _('With errors') if i.isRestrained() else _('Ok'),
            })

        return res
开发者ID:glyptodon,项目名称:openuds,代码行数:14,代码来源:users_groups.py

示例8: getLogs

    def getLogs(self, parent, item):
        try:
            user = parent.users.get(uuid=processUuid(item))
        except Exception:
            self.invalidItemException()

        return log.getLogs(user)
开发者ID:joaoguariglia,项目名称:openuds,代码行数:7,代码来源:users_groups.py

示例9: getLogs

 def getLogs(self, parent, item):
     try:
         item = parent.cachedUserServices().get(uuid=processUuid(item))
         logger.debug('Getting logs for {0}'.format(item))
         return log.getLogs(item)
     except Exception:
         self.invalidItemException()
开发者ID:dkmstr,项目名称:openuds,代码行数:7,代码来源:user_services.py

示例10: saveItem

    def saveItem(self, parent, item):
        # Extract item db fields
        # We need this fields for all
        logger.debug("Saving service {0} / {1}".format(parent, item))
        fields = self.readFieldsFromParams(["name", "comments", "data_type"])
        service = None
        try:
            if item is None:  # Create new
                service = parent.services.create(**fields)
            else:
                service = parent.services.get(uuid=processUuid(item))
                service.__dict__.update(fields)

            service.data = service.getInstance(self._params).serialize()
            service.save()
        except Service.DoesNotExist:
            self.invalidItemException()
        except IntegrityError:  # Duplicate key probably
            raise RequestError(_("Element already exists (duplicate key error)"))
        except coreService.ValidationException as e:
            self._deleteIncompleteService(service)
            raise RequestError(_("Input error: {0}".format(unicode(e))))
        except Exception as e:
            self._deleteIncompleteService(service)
            logger.exception("Saving Service")
            raise RequestError("incorrect invocation to PUT: {0}".format(e))

        return self.getItems(parent, service.uuid)
开发者ID:AlexeyBychkov,项目名称:openuds,代码行数:28,代码来源:services.py

示例11: saveItem

    def saveItem(self, parent, item):
        # Extract item db fields
        # We need this fields for all
        logger.debug('Saving rule {0} / {1}'.format(parent, item))
        fields = self.readFieldsFromParams(['name', 'comments', 'frequency', 'start', 'end', 'interval', 'duration', 'duration_unit'])
        # Convert timestamps to datetimes
        fields['start'] = datetime.datetime.fromtimestamp(fields['start'])
        if fields['end'] != None:
            fields['end'] = datetime.datetime.fromtimestamp(fields['end'])

        calRule = None
        try:
            if item is None:  # Create new
                calRule = parent.rules.create(**fields)
            else:
                calRule = parent.rules.get(uuid=processUuid(item))
                calRule.__dict__.update(fields)
                calRule.save()
        except CalendarRule.DoesNotExist:
            self.invalidItemException()
        except IntegrityError:  # Duplicate key probably
            raise RequestError(_('Element already exists (duplicate key error)'))
        except Exception as e:
            logger.exception('Saving calendar')
            raise RequestError('incorrect invocation to PUT: {0}'.format(e))

        return self.getItems(parent, calRule.uuid)
开发者ID:AlexeyBychkov,项目名称:openuds,代码行数:27,代码来源:calendarrules.py

示例12: getItems

 def getItems(self, parent, item):
     try:
         multi = False
         if item is None:
             multi = True
             q = parent.groups.all().order_by('name')
         else:
             q = parent.groups.filter(uuid=processUuid(item))
         res = []
         for i in q:
             val = {
                 'id': i.uuid,
                 'name': i.name,
                 'comments': i.comments,
                 'state': i.state,
                 'type': i.is_meta and 'meta' or 'group',
                 'meta_if_any': i.meta_if_any
             }
             if i.is_meta:
                 val['groups'] = list(x.uuid for x in i.groups.all())
             res.append(val)
         if multi:
             return res
         return res[0]
     except:
         logger.exception('REST groups')
         self.invalidItemException()
开发者ID:glyptodon,项目名称:openuds,代码行数:27,代码来源:users_groups.py

示例13: deleteItem

    def deleteItem(self, parent, item):  # This is also used by CachedService, so we use "userServices" directly and is valid for both
        service = None
        try:
            service = parent.userServices.get(uuid=processUuid(item))
        except Exception:
            logger.exception('deleteItem')
            self.invalidItemException()

        if service.user:
            logStr = 'Deleted assigned service {} to user {} by {}'.format(service.friendly_name, service.user.pretty_name, self._user.pretty_name)
        else:
            logStr = 'Deleted cached service {} by {}'.format(service.friendly_name, self._user.pretty_name)

        if service.state in (State.USABLE, State.REMOVING):
            service.remove()
        elif service.state == State.PREPARING:
            service.cancel()
        elif service.state == State.REMOVABLE:
            self.invalidItemException(_('Item already being removed'))
        else:
            self.invalidItemException(_('Item is not removable'))

        log.doLog(parent, log.INFO, logStr, log.ADMIN)

        return self.success()
开发者ID:dkmstr,项目名称:openuds,代码行数:25,代码来源:user_services.py

示例14: getItems

 def getItems(self, parent, item):
     try:
         multi = False
         if item is None:
             multi = True
             q = parent.groups.all().order_by('name')
         else:
             q = parent.groups.filter(uuid=processUuid(item))
         res = []
         for i in q:
             val = {
                 'id': i.uuid,
                 'name': i.name,
                 'comments': i.comments,
                 'state': i.state,
                 'type': i.is_meta and 'meta' or 'group',
                 'meta_if_any': i.meta_if_any
             }
             if i.is_meta:
                 val['groups'] = list(x.uuid for x in i.groups.all().order_by('name'))
             res.append(val)
         if multi:
             return res
         # Add pools field if 1 item only
         res = res[0]
         if i.is_meta:
             res['pools'] = []  # Meta groups do not have "assigned "pools, they get it from groups interaction
         else:
             res['pools'] = [v.uuid for v in  i.deployedServices.all()]
         return res
     except:
         logger.exception('REST groups')
         self.invalidItemException()
开发者ID:dkmstr,项目名称:openuds,代码行数:33,代码来源:users_groups.py

示例15: saveItem

    def saveItem(self, parent, item):
        # Extract item db fields
        # We need this fields for all
        logger.debug('Saving service for {0} / {1}'.format(parent, item))
        fields = self.readFieldsFromParams(['name', 'comments', 'data_type', 'tags', 'proxy_id'])
        tags = fields['tags']
        del fields['tags']
        service = None

        proxyId = fields['proxy_id']
        fields['proxy_id'] = None
        logger.debug('Proxy id: {}'.format(proxyId))

        proxy = None
        if proxyId != '-1':
            try:
                proxy = Proxy.objects.get(uuid=processUuid(proxyId))
            except Exception:
                logger.exception('Getting proxy ID')

        try:
            if item is None:  # Create new
                service = parent.services.create(**fields)
            else:
                service = parent.services.get(uuid=processUuid(item))
                service.__dict__.update(fields)

            service.tags.set([Tag.objects.get_or_create(tag=val)[0] for val in tags])
            service.proxy = proxy

            service.data = service.getInstance(self._params).serialize()  # This may launch an validation exception (the getInstance(...) part)
            service.save()
        except Service.DoesNotExist:
            self.invalidItemException()
        except IntegrityError:  # Duplicate key probably
            raise RequestError(_('Element already exists (duplicate key error)'))
        except coreService.ValidationException as e:
            if item is None:  # Only remove partially saved element if creating new (if editing, ignore this)
                self._deleteIncompleteService(service)
            raise RequestError(_('Input error: {0}'.format(six.text_type(e))))
        except Exception as e:
            if item is None:
                self._deleteIncompleteService(service)
            logger.exception('Saving Service')
            raise RequestError('incorrect invocation to PUT: {0}'.format(e))

        return self.getItems(parent, service.uuid)
开发者ID:dkmstr,项目名称:openuds,代码行数:47,代码来源:services.py


注:本文中的uds.core.util.model.processUuid函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。