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


Python State.toString方法代码示例

本文整理汇总了Python中uds.core.util.State.State.toString方法的典型用法代码示例。如果您正苦于以下问题:Python State.toString方法的具体用法?Python State.toString怎么用?Python State.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在uds.core.util.State.State的用法示例。


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

示例1: checkOsManagerRelated

# 需要导入模块: from uds.core.util.State import State [as 别名]
# 或者: from uds.core.util.State.State import toString [as 别名]
    def checkOsManagerRelated(self):
        osManager = self.userServiceInstance.osmanager()

        state = State.USABLE

        # and make this usable if os manager says that it is usable, else it pass to configuring state
        # This is an "early check" for os manager, so if we do not have os manager, or os manager
        # already notifies "ready" for this, we
        if osManager is not None and State.isPreparing(self.userService.os_state):
            logger.debug('Has valid osmanager for {}'.format(self.userService.friendly_name))

            stateOs = osManager.checkState(self.userService)
        else:
            stateOs = State.FINISHED

        logger.debug('State {}, StateOS {} for {}'.format(State.toString(state), State.toString(stateOs), self.userService.friendly_name))
        if stateOs == State.RUNNING:
            self.userService.setOsState(State.PREPARING)
        else:
            # If state is finish, we need to notify the userService again that os has finished
            # This will return a new task state, and that one will be the one taken into account
            self.userService.setOsState(State.USABLE)
            rs = self.userServiceInstance.notifyReadyFromOsManager('')
            if rs != State.FINISHED:
                self.checkLater()
                state = self.userService.state  # No not alter current state if after notifying os manager the user service keeps working
            else:
                self.logIp()

        return state
开发者ID:dkmstr,项目名称:openuds,代码行数:32,代码来源:opchecker.py

示例2: __str__

# 需要导入模块: from uds.core.util.State import State [as 别名]
# 或者: from uds.core.util.State.State import toString [as 别名]
 def __str__(self):
     return "User service {0}, cache_level {1}, user {2}, name {3}, state {4}:{5}".format(
         self.id,
         self.cache_level,
         self.user,
         self.friendly_name,
         State.toString(self.state),
         State.toString(self.os_state),
     )
开发者ID:AlexeyBychkov,项目名称:openuds,代码行数:11,代码来源:UserService.py

示例3: moveToLevel

# 需要导入模块: from uds.core.util.State import State [as 别名]
# 或者: from uds.core.util.State.State import toString [as 别名]
    def moveToLevel(self, cache, cacheLevel):
        '''
        Moves a cache element from one level to another
        @return: cache element
        '''
        cache = UserService.objects.get(id=cache.id)
        logger.debug('Moving cache {0} to level {1}'.format(cache, cacheLevel))
        ci = cache.getInstance()
        state = ci.moveToCache(cacheLevel)
        cache.cache_level = cacheLevel
        logger.debug('Service State: {0} {1} {2}'.format(State.toString(state), State.toString(cache.state), State.toString(cache.os_state)))
        if State.isRuning(state) and cache.isUsable():
            cache.setState(State.PREPARING)

        UserServiceOpChecker.makeUnique(cache, ci, state)
开发者ID:joaoguariglia,项目名称:openuds,代码行数:17,代码来源:UserServiceManager.py

示例4: checkAndUpdateState

# 需要导入模块: from uds.core.util.State import State [as 别名]
# 或者: from uds.core.util.State.State import toString [as 别名]
    def checkAndUpdateState(userService, userServiceInstance, state):
        """
        Checks the value returned from invocation to publish or checkPublishingState, updating the servicePoolPub database object
        Return True if it has to continue checking, False if finished
        """
        try:
            # Fills up basic data
            userService.unique_id = userServiceInstance.getUniqueId()  # Updates uniqueId
            userService.friendly_name = userServiceInstance.getName()  # And name, both methods can modify serviceInstance, so we save it later
            userService.save(update_fields=['unique_id', 'friendly_name'])

            updater = {
                State.PREPARING: UpdateFromPreparing,
                State.REMOVING: UpdateFromRemoving,
                State.CANCELING: UpdateFromCanceling
            }.get(userService.state, UpdateFromOther)

            logger.debug('Updating from {} with updater {} and state {}'.format(State.toString(userService.state), updater, state))

            updater(userService, userServiceInstance).run(state)

        except Exception as e:
            logger.exception('Checking service state')
            log.doLog(userService, log.ERROR, 'Exception: {0}'.format(e), log.INTERNAL)
            userService.setState(State.ERROR)
            userService.save(update_fields=['data'])
开发者ID:dkmstr,项目名称:openuds,代码行数:28,代码来源:opchecker.py

示例5: checkAndUpdateState

# 需要导入模块: from uds.core.util.State import State [as 别名]
# 或者: from uds.core.util.State.State import toString [as 别名]
    def checkAndUpdateState(userService, userServiceInstance, state):
        '''
        Checks the value returned from invocation to publish or checkPublishingState, updating the servicePoolPub database object
        Return True if it has to continue checking, False if finished
        '''
        try:
            prevState = userService.state
            userService.unique_id = userServiceInstance.getUniqueId()  # Updates uniqueId
            userService.friendly_name = userServiceInstance.getName()  # And name, both methods can modify serviceInstance, so we save it later
            if State.isFinished(state):
                checkLater = False
                userServiceInstance.finish()
                if State.isPreparing(prevState):
                    if userServiceInstance.service().publicationType is None or userService.publication == userService.deployed_service.activePublication():
                        userService.setState(State.USABLE)
                        # and make this usable if os manager says that it is usable, else it pass to configuring state
                        if userServiceInstance.osmanager() is not None and userService.os_state == State.PREPARING:  # If state is already "Usable", do not recheck it
                            stateOs = userServiceInstance.osmanager().checkState(userService)
                            # If state is finish, we need to notify the userService again that os has finished
                            if State.isFinished(stateOs):
                                state = userServiceInstance.notifyReadyFromOsManager('')
                                userService.updateData(userServiceInstance)
                        else:
                            stateOs = State.FINISHED

                        if State.isRuning(stateOs):
                            userService.setOsState(State.PREPARING)
                        else:
                            userService.setOsState(State.USABLE)
                    else:
                        # We ignore OsManager info and if userService don't belong to "current" publication, mark it as removable
                        userService.setState(State.REMOVABLE)
                elif State.isRemoving(prevState):
                    if userServiceInstance.osmanager() is not None:
                        userServiceInstance.osmanager().release(userService)
                    userService.setState(State.REMOVED)
                else:
                    # Canceled,
                    logger.debug("Canceled us {2}: {0}, {1}".format(prevState, State.toString(state), State.toString(userService)))
                    userService.setState(State.CANCELED)
                    userServiceInstance.osmanager().release(userService)
                userService.updateData(userServiceInstance)
            elif State.isErrored(state):
                checkLater = False
                userService.updateData(userServiceInstance)
                userService.setState(State.ERROR)
            else:
                checkLater = True  # The task is running
                userService.updateData(userServiceInstance)
            userService.save()
            if checkLater:
                UserServiceOpChecker.checkLater(userService, userServiceInstance)
        except Exception as e:
            logger.exception('Checking service state')
            log.doLog(userService, log.ERROR, 'Exception: {0}'.format(e), log.INTERNAL)
            userService.setState(State.ERROR)
            userService.save()
开发者ID:aiminickwong,项目名称:openuds,代码行数:59,代码来源:UserServiceManager.py

示例6: run

# 需要导入模块: from uds.core.util.State import State [as 别名]
# 或者: from uds.core.util.State.State import toString [as 别名]
    def run(self, state):
        executor = {
         State.RUNNING: self.running,
         State.ERROR: self.error,
         State.FINISHED: self.finish
        }.get(state, self.error)

        logger.debug('Running updater with state {} and executor {}'.format(State.toString(state), executor))

        try:
            executor()
        except Exception as e:
            self.setError('Exception: {}'.format(e))
开发者ID:dkmstr,项目名称:openuds,代码行数:15,代码来源:opchecker.py

示例7: setState

# 需要导入模块: from uds.core.util.State import State [as 别名]
# 或者: from uds.core.util.State.State import toString [as 别名]
    def setState(self, state):
        '''
        Updates the state of this object and, optionally, saves it

        Args:
            state: new State to store at record

            save: Defaults to true. If false, record will not be saved to db, just modified

        '''
        logger.debug(' *** Setting state to {} from {} for {}'.format(State.toString(state), State.toString(self.state), self))

        if state != self.state:
            self.state_date = getSqlDatetime()
            self.state = state
开发者ID:joaoguariglia,项目名称:openuds,代码行数:17,代码来源:UserService.py

示例8: remove

# 需要导入模块: from uds.core.util.State import State [as 别名]
# 或者: from uds.core.util.State.State import toString [as 别名]
    def remove(self, uService):
        '''
        Removes a uService element
        @return: the uService removed (marked for removal)
        '''
        with transaction.atomic():
            uService = UserService.objects.select_for_update().get(id=uService.id)
            logger.debug('Removing uService {0}'.format(uService))
            if uService.isUsable() is False and State.isRemovable(uService.state) is False:
                raise OperationException(_('Can\'t remove a non active element'))
            uService.setState(State.REMOVING)
            logger.debug("***** The state now is {}".format(State.toString(uService.state)))
            uService.setInUse(False)  # For accounting, ensure that it is not in use right now
            uService.save()

        ci = uService.getInstance()
        state = ci.destroy()

        UserServiceOpChecker.makeUnique(uService, ci, state)
开发者ID:joaoguariglia,项目名称:openuds,代码行数:21,代码来源:UserServiceManager.py

示例9: running

# 需要导入模块: from uds.core.util.State import State [as 别名]
# 或者: from uds.core.util.State.State import toString [as 别名]
 def running(self):
     self.setError('Unknown running transition from {}'.format(State.toString(self.userService.state)))
开发者ID:dkmstr,项目名称:openuds,代码行数:4,代码来源:opchecker.py

示例10: __str__

# 需要导入模块: from uds.core.util.State import State [as 别名]
# 或者: from uds.core.util.State.State import toString [as 别名]
 def __str__(self):
     return 'Publication {0}, rev {1}, state {2}'.format(self.deployed_service.name, self.revision, State.toString(self.state))
开发者ID:aiminickwong,项目名称:openuds,代码行数:4,代码来源:ServicesPoolPublication.py


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