本文整理匯總了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()