本文整理汇总了Python中Session.Session.create方法的典型用法代码示例。如果您正苦于以下问题:Python Session.create方法的具体用法?Python Session.create怎么用?Python Session.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Session.Session
的用法示例。
在下文中一共展示了Session.create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: lock
# 需要导入模块: from Session import Session [as 别名]
# 或者: from Session.Session import create [as 别名]
def lock(self, type=Constants.LockType_Shared):
"""Contextmanager yielding a session to a locked machine.
Machine must be registered."""
session = Session.create()
with VirtualBoxException.ExceptionHandler():
self.getIMachine().lockMachine(session.getISession(), type)
try:
session._setMachine(VirtualMachine(session.getIMachine()))
yield session
finally:
session.unlockMachine(wait=True)
示例2: powerOn
# 需要导入模块: from Session import Session [as 别名]
# 或者: from Session.Session import create [as 别名]
def powerOn(self, type="gui", env=""):
"""Spawns a new process that executes a virtual machine.
This is spawning a "remote session" in VirtualBox terms."""
# TODO: Add a wait argument
if not self.isRegistered():
raise VirtualBoxException.VirtualBoxInvalidVMStateException(
"VM is not registered")
with VirtualBoxException.ExceptionHandler():
iMachine = self.getIMachine()
session = Session.create()
iprogress = iMachine.launchVMProcess(session.getISession(),
type, env)
progress = Progress(iprogress)
progress.waitForCompletion()
session.unlockMachine()