本文整理汇总了Python中uds.core.util.State.State.isRuning方法的典型用法代码示例。如果您正苦于以下问题:Python State.isRuning方法的具体用法?Python State.isRuning怎么用?Python State.isRuning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类uds.core.util.State.State
的用法示例。
在下文中一共展示了State.isRuning方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: checkAndUpdateState
# 需要导入模块: from uds.core.util.State import State [as 别名]
# 或者: from uds.core.util.State.State import isRuning [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()
示例2: moveToLevel
# 需要导入模块: from uds.core.util.State import State [as 别名]
# 或者: from uds.core.util.State.State import isRuning [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)