VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/python/vboxxpcom.py@ 63450

Last change on this file since 63450 was 60492, checked in by vboxsync, 9 years ago

xpcom/python/vboxxpcom.py: added CDDL header

  • Property svn:eol-style set to native
File size: 2.5 KB
Line 
1"""
2Copyright (C) 2008-2016 Oracle Corporation
3
4This file is part of VirtualBox Open Source Edition (OSE), as
5available from http://www.virtualbox.org. This file is free software;
6you can redistribute it and/or modify it under the terms of the GNU
7General Public License (GPL) as published by the Free Software
8Foundation, in version 2 as it comes in the "COPYING" file of the
9VirtualBox OSE distribution. VirtualBox OSE is distributed in the
10hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
11
12The contents of this file may alternatively be used under the terms
13of the Common Development and Distribution License Version 1.0
14(CDDL) only, as it comes in the "COPYING.CDDL" file of the
15VirtualBox OSE distribution, in which case the provisions of the
16CDDL are applicable instead of those of the GPL.
17
18You may elect to license modified versions of this file under the
19terms and conditions of either the GPL or the CDDL or both.
20"""
21
22import xpcom
23import sys
24import platform
25
26#
27# This code overcomes somewhat unlucky feature of Python, where it searches
28# for binaries in the same place as platfom independent modules, while
29# rest of Python bindings expect _xpcom to be inside xpcom module
30#
31
32_asVBoxPythons = [
33 'VBoxPython' + str(sys.version_info[0]) + '_' + str(sys.version_info[1]),
34 'VBoxPython' + str(sys.version_info[0]),
35 'VBoxPython'
36];
37
38# On platforms where we ship both 32-bit and 64-bit API bindings, we have to
39# look for the right set if we're a 32-bit process.
40if platform.system() in [ 'SunOS', ] and sys.maxsize <= 2**32:
41 _asNew = [ sCandidate + '_x86' for sCandidate in _asVBoxPythons ];
42 _asNew.extend(_asVBoxPythons);
43 _asVBoxPythons = _asNew;
44 del _asNew;
45
46# On Darwin (aka Mac OS X) we know exactly where things are in a normal
47# VirtualBox installation.
48## @todo Edit this at build time to the actual VBox location set in the make files.
49## @todo We know the location for most hardened builds, not just darwin!
50if platform.system() == 'Darwin':
51 sys.path.append('/Applications/VirtualBox.app/Contents/MacOS')
52
53_oVBoxPythonMod = None
54for m in _asVBoxPythons:
55 try:
56 _oVBoxPythonMod = __import__(m)
57 break
58 except Exception as x:
59 print('m=%s x=%s' % (m, x))
60 #except:
61 # pass
62
63if platform.system() == 'Darwin':
64 sys.path.remove('/Applications/VirtualBox.app/Contents/MacOS')
65
66if _oVBoxPythonMod == None:
67 raise Exception('Cannot find VBoxPython module (tried: %s)' % (', '.join(_asVBoxPythons),));
68
69sys.modules['xpcom._xpcom'] = _oVBoxPythonMod;
70xpcom._xpcom = _oVBoxPythonMod;
71
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette