1 import os
2 import imp
3 import traceback
4
5 __all__ = ['loadExtensions','windows','i386','darwin','amd64','gdbstub','arm','android']
6
7 '''
8 A package to contain all the extended functionality for platform specific
9 commands and modules.
10 '''
11
13 '''
14 Actually load all known extensions here.
15 '''
16 plat = trace.getMeta('Platform').lower()
17 arch = trace.getMeta('Architecture').lower()
18
19 if plat in __all__:
20 mod = __import__('vdb.extensions.%s' % plat, 0, 0, 1)
21 mod.vdbExtension(vdb, trace)
22
23 if arch in __all__:
24 mod = __import__('vdb.extensions.%s' % arch, 0, 0, 1)
25 mod.vdbExtension(vdb, trace)
26
27 extdir = os.getenv('VDB_EXT_PATH')
28
29 if extdir != None:
30
31 for dirname in extdir.split(';'):
32
33 if not os.path.isdir(dirname):
34 vdb.vprint('Invalid VDB_EXT_PATH dir: %s' % dirname)
35 continue
36
37 for fname in os.listdir(dirname):
38 if not fname.endswith('.py'):
39 continue
40
41
42 mod = imp.new_module('vdb_ext')
43 filepath = os.path.join(dirname, fname)
44 filebytes = file( filepath, 'r' ).read()
45 mod.__file__ = filepath
46 try:
47 exec filebytes in mod.__dict__
48 mod.vdbExtension(vdb, trace)
49 except Exception, e:
50 vdb.vprint( traceback.format_exc() )
51 vdb.vprint('Extension Error: %s' % filepath)
52