本文整理汇总了Python中uds.core.util.State.State.isRemovable方法的典型用法代码示例。如果您正苦于以下问题:Python State.isRemovable方法的具体用法?Python State.isRemovable怎么用?Python State.isRemovable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类uds.core.util.State.State
的用法示例。
在下文中一共展示了State.isRemovable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: removeOrCancel
# 需要导入模块: from uds.core.util.State import State [as 别名]
# 或者: from uds.core.util.State.State import isRemovable [as 别名]
def removeOrCancel(self, uService):
if uService.isUsable() or State.isRemovable(uService.state):
return self.remove(uService)
elif uService.isPreparing():
return self.cancel(uService)
else:
raise OperationException(_('Can\'t remove nor cancel {0} cause its states don\'t allow it'))
示例2: remove
# 需要导入模块: from uds.core.util.State import State [as 别名]
# 或者: from uds.core.util.State.State import isRemovable [as 别名]
def remove(self, uService):
'''
Removes a uService element
@return: the uService removed (marked for removal)
'''
uService = UserService.objects.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'))
ci = uService.getInstance()
state = ci.destroy()
uService.setState(State.REMOVING)
UserServiceOpChecker.makeUnique(uService, ci, state)
示例3: unpublish
# 需要导入模块: from uds.core.util.State import State [as 别名]
# 或者: from uds.core.util.State.State import isRemovable [as 别名]
def unpublish(self, servicePoolPub): # pylint: disable=no-self-use
'''
Unpublishes an active (usable) or removable publication
:param servicePoolPub: Publication to unpublish
'''
if State.isUsable(servicePoolPub.state) is False and State.isRemovable(servicePoolPub.state) is False:
raise PublishException(_('Can\'t unpublish non usable publication')
)
if servicePoolPub.userServices.exclude(state__in=State.INFO_STATES).count() > 0:
raise PublishException(_('Can\'t unpublish publications with services in process'))
try:
pubInstance = servicePoolPub.getInstance()
state = pubInstance.destroy()
servicePoolPub.setState(State.REMOVING)
PublicationFinishChecker.checkAndUpdateState(servicePoolPub, pubInstance, state)
except Exception, e:
raise PublishException(str(e))
示例4: remove
# 需要导入模块: from uds.core.util.State import State [as 别名]
# 或者: from uds.core.util.State.State import isRemovable [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)