Hi,
First of all, it would be nice if you tried vboxshell.py first. It's
strongly recommended
to use uniform bindings (vboxapi.py) in all newly developed code.
With it code is pretty simple:
from vboxapi import VirtualBoxManager
mgr = VirtualBoxManager(None, None)
vbox = mgr.vbox
name = "ubu"
mach = vbox.findMachine(name)
session = mgr.mgr.getSessionObject(vbox)
progress = mach.launchVMProcess(session, "gui", "")
progress.waitForCompletion(-1)
Your issue with OS name is a Python bug
(http://bugs.python.org/issue1082), please upgrade Python
to more functional version.
Generally, please make your posting more relevant and compact, last 7
postings you did to vbox-dev
were too much for amount of real issues reported.
Thanks,
Nikolay
On 1/30/11 7:29 PM, Alexey Eromenko wrote:
Hi all !
Today I tried to write small python script to start VirtualBox VMs. It
should work from both Windows and Linux hosts.
Host: Windows Vista 32 + VBox 4.0 + SDK + python 2.5 + pywin32
TRY 1:
I wrote according to VBox SDK docs (2.3.1 Python COM API, v4.0
SDKref.PDF): (plus added few imports)
======================================================
import os,sys
import win32com
vbox = win32com.client.Dispatch("VirtualBox.VirtualBox")
session = win32com.client.Dispatch("VirtualBox.Session")
mach = vbox.findMachine("uuid or name of machine to start")
progress = mach.launchVMProcess(session, "gui", "")
progress.waitForCompletion(-1)
EOF
I get this:
E:\Alex-temp>vbox-devel01.py
Traceback (most recent call last):
File "E:\Alex-temp\vbox-devel01.py", line 16, in<module>
vbox = win32com.client.Dispatch("VirtualBox.VirtualBox")
AttributeError: 'module' object has no attribute 'client'
----
I tried to read source of "vboxshell.py", but it is too hard for me,
and it does not use "VirtualBox.VirtualBox" unlike the SDK example.
I have basic skills in python, but not in VirtualBox-python and not in
COM programming.
Any ideas ?
TRY 2:
This code I copied from "2.3.2 Common Python bindings layer" SDK PDF.
======================================================
# This code assumes vboxapi.py from VirtualBox distribution
# being in PYTHONPATH, or installed system-wide
from vboxapi import VirtualBoxManager
# This code initializes VirtualBox manager with default style
# and parameters
virtualBoxManager = VirtualBoxManager(None, None)
# Alternatively, one can be more verbose, and initialize
# glue with webservice backend, and provide authentication
# information
virtualBoxManager = VirtualBoxManager("WEBSERVICE",
{’url’:’http://myhost.com::18083/’,
’user’:’me’,
’password’:’secret’})
And here is the error:
E:\Alex-temp>vbox-devel02.py
File "E:\Alex-temp\vbox-devel02.py", line 13
SyntaxError: Non-ASCII character '\x92' in file E:\Alex-temp\vbox-devel02.py on
line 13, but no encoding declared; see http://www.python.org/peps/pep-0263.html
for details
I tried to add:
# -*- coding: ascii -*-
..on the first line, but it did not help.
Any ideas ?
TRY 3:
======================================================
vboxshell.py renders text incorrectly on my Windows host.
I did one command: "help", and got:
vbox> help
Help page:
←[94malias←[0m: Control aliases
←[94mattachCtr←[0m: Attach storage controller to the VM: attachCtr win Ctr0
IDE ICH6
←[94mattachHdd←[0m: Attach HDD to the VM: attachHdd win /disk.vdi "IDE
Contr
oller" 0:1
←[94mattachIso←[0m: Attach CD/DVD to the VM: attachIso win /os.iso "IDE
Cont
roller" 0:1
←[94mattachUsb←[0m: Attach USB device to the VM (use listUsb to show
availab
le devices): attachUsb win uuid
←[94mcloseportal←[0m: Close teleportation portal (see openportal,teleport):
closeportal Win
...
vboxshell.py, being a 100K byte code example is too hard to understand.
Why are those extra characters rendered ? Because Windows 'cmd'
console does not support colors ?
======================================================
By and large I would like to see some *working*, yet
easy-to-understand examples.
On the side note: SDKref.pdf references VBox 3.3 once, which should be
changed to v4.0 (in chapter "3.4 VirtualBox events")
_______________________________________________
vbox-dev mailing list
[email protected]
http://vbox.innotek.de/mailman/listinfo/vbox-dev