diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2014-03-26 19:21:20 +0000 |
---|---|---|
committer | <> | 2014-05-08 15:03:54 +0000 |
commit | fb123f93f9f5ce42c8e5785d2f8e0edaf951740e (patch) | |
tree | c2103d76aec5f1f10892cd1d3a38e24f665ae5db /src/libs/xpcom18a4/python/vboxxpcom.py | |
parent | 58ed4748338f9466599adfc8a9171280ed99e23f (diff) | |
download | VirtualBox-master.tar.gz |
Imported from /home/lorry/working-area/delta_VirtualBox/VirtualBox-4.3.10.tar.bz2.HEADVirtualBox-4.3.10master
Diffstat (limited to 'src/libs/xpcom18a4/python/vboxxpcom.py')
-rwxr-xr-x | src/libs/xpcom18a4/python/vboxxpcom.py | 61 |
1 files changed, 36 insertions, 25 deletions
diff --git a/src/libs/xpcom18a4/python/vboxxpcom.py b/src/libs/xpcom18a4/python/vboxxpcom.py index 47b11d0f..fa1f597a 100755 --- a/src/libs/xpcom18a4/python/vboxxpcom.py +++ b/src/libs/xpcom18a4/python/vboxxpcom.py @@ -1,5 +1,5 @@ """ -Copyright (C) 2008 Oracle Corporation +Copyright (C) 2008-2012 Oracle Corporation This file is part of VirtualBox Open Source Edition (OSE), as available from http://www.virtualbox.org. This file is free software; @@ -14,38 +14,49 @@ import xpcom import sys import platform -# this code overcomes somewhat unlucky feature of Python, where it searches +# +# This code overcomes somewhat unlucky feature of Python, where it searches # for binaries in the same place as platfom independent modules, while # rest of Python bindings expect _xpcom to be inside xpcom module - -candidates = ['VBoxPython' + str(sys.version_info[0]) + '_' + str(sys.version_info[1]), - 'VBoxPython' + str(sys.version_info[0]), - 'VBoxPython'] +# + +_asVBoxPythons = [ + 'VBoxPython' + str(sys.version_info[0]) + '_' + str(sys.version_info[1]), + 'VBoxPython' + str(sys.version_info[0]), + 'VBoxPython' +]; + +# On platforms where we ship both 32-bit and 64-bit API bindings, we have to +# look for the right set if we're a 32-bit process. +if platform.system() in [ 'SunOS', ] and sys.maxsize <= 2**32: + _asNew = [ sCandidate + '_x86' for sCandidate in _asVBoxPythons ]; + _asNew.extend(_asVBoxPythons); + _asVBoxPythons = _asNew; + del _asNew; + +# On Darwin (aka Mac OS X) we know exactly where things are in a normal +# VirtualBox installation. +## @todo Edit this at build time to the actual VBox location set in the make files. +## @todo We know the location for most hardened builds, not just darwin! if platform.system() == 'Darwin': - # On Darwin (aka Mac OS X) we know exactly where things are in a normal - # VirtualBox installation. Also, there are two versions of python there - # (2.3.x and 2.5.x) depending on whether the os is striped or spotty, so - # we have to choose the right module to load. - # - # XXX: This needs to be adjusted for OSE builds. A more general solution would - # be to to sed the file during install and inject the VBOX_PATH_APP_PRIVATE_ARCH - # and VBOX_PATH_SHARED_LIBS when these are set. sys.path.append('/Applications/VirtualBox.app/Contents/MacOS') -cglue = None -for m in candidates: - try: - cglue = __import__(m) - break - except: - pass +_oVBoxPythonMod = None +for m in _asVBoxPythons: + try: + _oVBoxPythonMod = __import__(m) + break + except Exception, x: + print 'm=%s x=%s' % (m, x); + #except: + # pass if platform.system() == 'Darwin': sys.path.remove('/Applications/VirtualBox.app/Contents/MacOS') -if cglue == None: - raise Exception, "Cannot find VBoxPython module" +if _oVBoxPythonMod == None: + raise Exception('Cannot find VBoxPython module (tried: %s)' % (', '.join(_asVBoxPythons),)); -sys.modules['xpcom._xpcom'] = cglue -xpcom._xpcom = cglue +sys.modules['xpcom._xpcom'] = _oVBoxPythonMod; +xpcom._xpcom = _oVBoxPythonMod; |