Controlling VirtualBox via COM from Python? -


I'm trying to control the latest Sun Virtualbox through Python's Com Interface. But unfortunately, the following code does not work:

  Import win32com.client VBOX_GUID = "{B1A7A4F2-47B9-4A1E-82B2-07CCD5323C3F}" Try: oVbox = win32com.client.Dispatch ( VOX_GUID) ox except for oVbox.FindMachine ("kubuntu") Exception: print str (ox)  

error is normal "(-2147467262, 'no such interface is supported', none, None) "It seems that the wrong part is being handed over to my com Python, can anyone leave a look and say something clearer, that I am doing wrong?

The problem is that the object given by FindMachine ("kbuntu") IDispatch interface does not support, and win32com does not support it.

You have your Comtypes package for this, but you have to patched the version in the repository to work with it's Virtualbox type libraries.

Here is a demo session:

  Python 2.5.4 (r254: 67916, 23 December 2008, 15:10:54) [MSc v.1310 32 bit ( Intel)) Win32 Type "Help", "Copyright", "Credit" or "License" for more information. & Gt; & Gt; & Gt; CreateObject from Comtypes.client Import & gt; & Gt; & Gt; Box = Create Object ("VirtualBox.VirtualBox") & gt; & Gt; & Gt; M = box.findmarket ("fedora") & gt; & Gt; & Gt; Print m State 4 & gt; & Gt; & Gt; Print m.ccccount 1 & gt; & Gt; & Gt; Print m.Name Fedora & gt; & Gt; & Gt;  

And here's the patch you should:

  Index: automation.py =============== = ================================================== = --- automation.py (Revision 507) +++ Automation (@ working copy) @@-753,6 +753,8 @@ c_float: VT_R4, c_double: VT_R8, + c_ulonglong: VT_I8, + VARIANT_BOOL: VT_BOOL, BSTR: VT_BSTR,  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -