VirtualBox

Changeset 35929 in vbox


Ignore:
Timestamp:
Feb 10, 2011 2:22:54 PM (14 years ago)
Author:
vboxsync
Message:

SDK docs: working sample for Python glue layer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/manual/en_US/SDKRef.xml

    r35296 r35929  
    14381438        following code will a start virtual machine by name or ID:</para>
    14391439
    1440         <screen>vbox = virtualBoxManager.vbox
    1441 mgr = virtualBoxManager.mgr
    1442 print "Version is",vbox.version
    1443 
    1444 def machById(id):
    1445     mach = None
    1446     for m in virtualBoxManager.getArray(vbox, 'machines'):
    1447         if m.name == id or mach.id == id:
    1448             mach = m
    1449             break
    1450     return mach
    1451 
     1440        <screen>from vboxapi import VirtualBoxManager
     1441mgr = VirtualBoxManager(None, None)
     1442vbox = mgr.vbox
    14521443name = "Linux"
    1453 mach = machById(name)
    1454 if mach is None:
    1455     print "cannot find machine",name
    1456 else:
    1457     session = mgr.getSessionObject(vbox)
    1458     # one can also start headless session with "headless" instead of "gui"
    1459     progress = vb.openRemoteSession(session, mach.id, "gui", "")
    1460     progress.waitForCompletion(-1)
    1461     session.close()
     1444mach = vbox.findMachine(name)
     1445session = mgr.mgr.getSessionObject(vbox)
     1446progress = mach.launchVMProcess(session, "gui", "")
     1447progress.waitForCompletion(-1)
     1448mgr.closeMachineSession(session)
    14621449        </screen>
    14631450
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette