Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

Saturday, June 11, 2011

"setup.py test" throwing "ValueError: Empty module name"

Running 'setup.py test' suddenly started throwing a ValueError:

$ /usr/bin/python ./setup.py test
running test
running egg_info
writing pyVBox.egg-info/PKG-INFO
writing top-level names to pyVBox.egg-info/top_level.txt
writing dependency_links to pyVBox.egg-info/dependency_links.txt
reading manifest file 'pyVBox.egg-info/SOURCES.txt'
writing manifest file 'pyVBox.egg-info/SOURCES.txt'
running build_ext
Traceback (most recent call last):
  File "./setup.py", line 17, in
    url = "http://github.com/von/pyVBox"
...snip...
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/unittest.py", line 576, in loadTestsFromName
    module = __import__('.'.join(parts_copy))
ValueError: Empty module name
Poking around with pdb, it turns out it was because the name argument to loadTestsFromName():

(Pdb) print parts_copy
['test', '', '#VirtualMachineTests']
(Pdb) print name
test..#VirtualMachineTests

Which turns out to be caused by a Emacs autosave file. I had unsaved changes in my Emacs buffer. Once I saved them, the autosave file went away and 'setup.py test' ran fine.

Obviously some deeper problem here with setup.py tripping over these files.

Sunday, May 31, 2009

Booting a VirtualBox VM from removable drive without the GUI

I recently installed VirtualBox on one of my Ubuntu systems. I was intrigued by the VBoxManage command line client and was wondering if it would be possible to boot a VirtualBox VM from a removal drive entirely with a script (i.e. without the GUI).

The answer is yes. You can see the script in my google code repository (Updated to HG path).

In short, you create the VM as usual using the GUI (in theory you should be able to do that from the command line as well, but I need to work out details with the networking). Then remove the harddrive from the VM and copy the .xml and .vdi file to the removable drive. Then go ahead and remove the VM and harddrive from the GUI.

At this point you can boot the VM using something like the following:
$ vbox-add-vm.py -v -H /media/truecrypt1/VM.vdi /media/truecrypt1/VM.xml
The script will automatically register the VM and hard drive, add the hard drive to the VM, boot the VM, wait for it to shut down and then unregister everything.

The only hiccup at this point is if you have the GUI running, it seems to keep the VM open in some way that prevents you from ejecting the device.

Since I finished this script I discovered the VirtualBox SDK with Python bindings. For v2 of the script, then would be a natural thing to leverage.