Showing posts with label software. Show all posts
Showing posts with label software. Show all posts

Tuesday, 7 July 2009

Using the Enumerations provided by VirtualBox's SDK with Python and XPCOM

Because this was surprisingly difficult to find out - thanks to Benjamin who provided the answer :o)

So... the VirtualBox SDK allows you to control VirtualBox programmatically. In particular from a selection of languages using either XPCOM or SOAP. I've been working with Python using the XPCOM method, which looks a bit like this...

vbox = xpcom.components.classes["@virtualbox.org/VirtualBox;1"].createInstance()
session = xpcom.components.classes["@virtualbox.org/Session;1"].createInstance()

default_id = "00000000-0000-0000-0000-000000000000"
mach = vbox.createMachine("my_new_vm_name", "Ubuntu", None, default_id)
vbox.registerMachine(mach)

All good so far... and indeed for quite a long while. Still, this last week Hobnob and I have been pushing the SDK a little bit futher and discovered a need to use some of the built in enumerations. For example, to register a hard disk within VirtualBox using the SDK you'll need the openHardDisk() method provided by the IVirtualBox interface. This takes, as one of it's parameters an enum AccessMode (which does the obvious), the documentation tells you that this is provided in VirtualBox.idl and looks something like this:


Looking good? Well almost. It's just a shame that there's no good examples around to show you how to do this. After some experimentation, Hobnob and I settled for looking up the values and then dropping them into the code I was trying to write:

AccessMode_ReadWrite = 2
hd = vbox.openHardDisk("/vm_disks/mydisk.vdi", AccessMode_ReadWrite, False, "", False, "")

Clearly this is not the way this was meant to be done. So how do you use the built in enums? Answer... like this:

ifaces = xpcom.components.interfaces
hd = vbox.openHardDisk("/vm_disks/mydisk.vdi", ifaces.AccessMode.ReadWrite, False, "", False, "")

Easy when you know how, huh :) So now I can remove these lines from my code:

AccessMode_ReadWrite = 2
HardDiskType_Immutable = 1
HardDiskVariant_Standard = 0

And replace them with:


ifaces.AccessMode.ReadWrite
ifaces.HardDiskType.Immutable
ifaces.HardDiskVariant.Standard

And it turns out I wasn't using HardDiskType_Immutable anymore anyway :) You never know what you'll find with a quick code tidy.

Thursday, 11 June 2009

Smile!

Pidgin says so! I've been looking at this off and on all day and I'm constantly misinterpreting it. It's actually the smilies menu.

Thursday, 4 June 2009

Accessing VirtualBox Shared Folders From Ubuntu Guest

Apologies for the glut of technical posts - normally I drop this kind of thing onto my PhD wiki but it's not available atm :(

So...

1) Setup the shared folder on the host by bringing up the settings dialogue for the appropriate VM within VirtualBox. Click 'Shared Folders' and set up as required with a particular name. Remember the name you've given the folder.

2) Start the VM. Make a new directory in /mnt, this will be the directory to contain your shared folder content. E.g.

mkdir /mnt/docs_host

3) Type the following command into your terminal:

sudo mount.vboxsf *name_created_in_1* /mnt/*folder_created_in_2 *

E.g.

sudo mount.vboxsf my_docs /mnt/docs_host/

All done! You should now be able to do an ls on the directory you created in 2) and see the content you linked to in 1).

Tuesday, 2 June 2009

Apache VCL

I'm currently attempting to install Apache VCL on my local machine. I've no idea how this will work, if it will work, and have an overall suspicion that for our purposes, it will not. However...

Things to note so far:
* The installation instructions actually seem pretty thorough.
* Got stuck with a redirect problem but it turned out to be this - set the cookie domain to "" and the problem goes away.

Monday, 1 June 2009

VRDP/RDesktop-cli

Using VirtualBox v2.2.2, I've got a VM with a plain boring Ubuntu install. Standard setup with no extra magic except that I've turned on VRDP (Settings->Remote Display->Enable VRDP Server. So that's the server side.

On the client side I'm using a Nokia N810 device, rdesktop-cli v1.6.0 and (attempting to use) PyRDesktop 1.5.

Firstly PyRDesktop is slow to start. That aside, I enter the IP of my host, and hit 'connect' - it does. Seemingly satisfied I close the window. Coming back to it a while later to see how *well* it works I start to notice a significant problem - my touch screen interactions seem to be totally mismatched with the resulting output. Imagine a display that just really wasn't calibrated right: I touch the screen in the top left and drag down - a selection starts to be made in the centre of the screen, I touch in the centre and I can just see my selection falling off the bottom right corner... not so useful.

Curious.

So, I figure I'll leave PyRDesktop out of the equation for a moment at try RDesktop without the 'pretty' (it isn't) Python GUI. Starting out with the reasonably simple "rdp myip" (having aliased the rather stupidly named rdesktop-cli to rdp - surely it should either be rdesktop or rdesktop-client not some weird middle ground?) I find the same problem occurs. Fine, so what's next? Try forcing the thing to use RDP 4 "rdp -4 myip" but that just doesn't work at all, I can't connect that way. Try a bit of a fiddle with compression and caching, neither of which alter anything (did I expect them to?) and then reread the usage information.

Usage: rdp [options] server[:port]
-g: desktop geometry (WxH)

Ah-ha. That looks kind of useful. Try it first with some arbitrary values:

Nokia-N810-43-7:~# rdp -g 480x220 169.254.10.32
Autoselected keyboard map en-gb
WARNING: Remote desktop changed from 480x220 to 800x600.

This doesn't 'fix' the problem, but it does seem vastly improved. Quickly look up the resolution for the N810 on the magic Internets and try again:

Nokia-N810-43-7:~# rdp -g 800x480 169.254.10.32
Autoselected keyboard map en-gb
WARNING: Remote desktop changed from 800x480 to 800x600.

Much better. Curious about the warning though - if it hasn't actually used the resolution I've told it to then 1) why not? 2) why has this helped?

Tuesday, 2 September 2008

Fixing Errors When Using BibOrder

I'm having a quick play with BibOrder for Office 2007 to see if it'll do what I want. Problems overcome so far...

********* Error #1 *********

C:\Documents and Settings\Saffy\Desktop>BibOrder.exe /d:test.docx

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
File name: 'WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
at BibWord.BibOrder.TransformDocument(String docx, String styledir, String stylesheet)
at BibWord.BibOrder.Main(String[] args)

Solution: Install Microsoft .NET Framework 3.0 Redistributable Package

********* Error #2 *********
C:\Documents and Settings\Saffy\Desktop>BibOrder.exe /d:"test.docx"

Unhandled Exception: System.IO.IOException: The process cannot access the file 'C:\Documents and Settings\Saffy\Desktop\test.docx' because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync)
at MS.Internal.IO.Zip.ZipArchive.OpenOnFile(String path, FileMode mode, FileAccess access, FileShare share, Boolean streaming)
at System.IO.Packaging.ZipPackage..ctor(String path, FileMode mode, FileAccess access, FileShare share, Boolean streaming)
at System.IO.Packaging.Package.Open(String path, FileMode packageMode, FileAccess packageAccess, FileShare packageShare, Boolean streaming)
at System.IO.Packaging.Package.Open(String path, FileMode packageMode, FileAccess packageAccess)
at BibWord.BibOrder.TransformDocument(String docx, String styledir, String stylesheet)
at BibWord.BibOrder.Main(String[] args)

Solution: Close the file in Office before you try running BibOrder on it.

***

And those not overcome :(

C:\Documents and Settings\Saffy\Desktop>BibOrder.exe /d:"test.docx"

Unhandled Exception: System.Xml.XmlException: Root element is missing.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.ThrowWithoutLineInfo(String res)
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at System.Xml.XmlDocument.LoadXml(String xml)
at BibWord.BibOrder.TransformDocument(String docx, String styledir, String stylesheet)
at BibWord.BibOrder.Main(String[] args)

*sigh* - nothing obvious so far :(

Referencing With Word 2007

Referencing with Word 2007 is one of those things I'll never quite understand. Word (and possibly just Office in general) 2007 is, by far, the best office software I've ever used and is, quite probably, the most pleasing Microsoft sotware ever. However, the whole referencing feels like something that they designed well and then just never bothered finishing. It goes so far... and then stops.

Why do they have a neat, extensible, configurable underlying system that can't be played with from the UI?

Sadly, none of the in built referencing styles suit the documents I want to write. Fortunately it's all done based on xsl files. Unfortunately, there's no interface to customise/create them.

Last time I had this problem it was early days and noone had done much to create other styles. More recently this is almost still the case except, it seems, for some (now much loved) bloke on Code Plex.

I've started out by downloading his IEEE style to have a play with which is good but isn't quite what I want. There seems to be quite a bit there for supporting DIY though which could be rather useful.

Wednesday, 12 September 2007

iTunes fun resolved!

I found my problem in the end. I downloaded and installed 1.4.1 and nothing changed. Then I noticed I'd got a version of iTunes in 'Applications' as well as one I knew to be in a 'Media' folder in 'Applications'. Turned out that I had installed a new version (presumably when I had the software agreement pop up at me) but it had gone into the default location of 'Applications' rather than replacing the existing item. After that first time I guess it always opened the old version which didn't like the new library. Some shuffling things round fixed my problem.

I'm slightly confused as to how I opened the new version at all. It's fairly likely I successfully installed iTunes 1.4.1 ages ago but have always run the older version. The older version would have detected the need for an update but once downloaded, Software Update would have found 1.4.1 installed already and so not bothered with it. The 1.3 version was the one in the dock so I guess I must have looked for it in Spotlight sometime this (yesterday) afternoon and so opened 1.4.1 instead.

Hmmm... confusion and unconfusion.

---

I'm about to save this but I'm stopped by the sudden appearance of exciting rain! If it weren't 3am I'd think about going to run around outside.

iTunes

iTunes has got itself into a terrible muddle. It's been trying to update to a newer version (7.4.1 I assume) for ages now. Software update would pop up and say it had an update, would go away and download it and would then, once the download was completed, seemed to take another look and say that it didn't want to install anything after all. This has been occurring for over a month now I think.

This afternoon, when I opened iTunes it seemed to think it was running a new version and showed me the software agreement. I assumed that it had caught up with itself and didn't bother to think any more about it.

Now, when I open iTunes (I know I said I was going to bed, but I remembered a quick piece of code I could write) it says:

The file "iTunes Library" cannot be read because it was created by a newer version of iTunes.

So it seems that whatever it installed has gone away again. I had a look at version.plist and that says it's currently version 1.3.1 that's installed. As I now can't use iTunes at all I've decided to download a copy of 7.4.1 from the Apple site and hope it'll be all happy again...

On the plus side, my code change was a five minute job so I have achieved something by delaying my sleep some more.

Tuesday, 4 September 2007

Zealous

A good Scrabble word if ever there were one. I played against myself today (awww...) but I got to put down Zealous and Pious and some other good words I have already forgotten.

Also, we discovered my computer doesn't work. Tomorrow I shall order a new one.

Oooh, and we made iChat work!

That's it.

LinkWithin

Related Posts Plugin for WordPress, Blogger...