Changeset 19783 in vbox
- Timestamp:
- May 18, 2009 12:03:26 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxShell/mscom/vboxshell.py
r19239 r19783 28 28 class LocalManager: 29 29 def getSessionObject(self, vb): 30 30 return win32com.client.Dispatch("{3C02F46D-C9D2-4f11-A384-53F0CF917214}") 31 31 32 32 vbox = None 33 33 mgr = LocalManager() 34 34 try: 35 vbox = win32com.client.Dispatch("{B1A7A4F2-47B9-4A1E-82B2-07CCD5323C3F}") 35 vbox = win32com.client.Dispatch("{B1A7A4F2-47B9-4A1E-82B2-07CCD5323C3F}") 36 win32com.client.gencache.EnsureDispatch('VirtualBox.Session') 36 37 except Exception,e: 37 38 print "COM exception: ",e … … 39 40 sys.exit(1) 40 41 41 # fake constants, while get resolved constants issues for real 42 # win32com.client.constants doesn't work for some reasons 43 class DummyInterfaces: pass 44 class SessionState:pass 42 class ConstantFake: 43 def __init__(self, parent, name): 44 self.__dict__['_parent'] = parent 45 self.__dict__['_name'] = name 46 try: 47 self.__dict__['_depth']=parent.__dict__['_depth']+1 48 except: 49 self.__dict__['_depth']=0 50 self.__dict__['_klazz'] = self.__class__ 51 if self.__dict__['_depth'] > 4: 52 raise AttributeError 45 53 46 DummyInterfaces.SessionState=SessionState() 47 DummyInterfaces.SessionState.Open = 2 54 def __getattr__(self, attr): 55 if attr.startswith("__"): 56 raise AttributeError 57 58 try: 59 n = makeFullName(self) + "_" + attr 60 v = win32com.client.constants.__getattr__(n) 61 return v 62 except AttributeError,e: 63 return ConstantFake(self, attr) 48 64 49 ctx = {'mgr':mgr, 'vb':vbox, 'ifaces':DummyInterfaces(), 50 #'ifaces':win32com.client.constants, 65 def makeFullName(fake): 66 name = fake._name 67 parent = fake._parent 68 while parent != None: 69 name = parent._name+'_'+name 70 parent = parent._parent 71 return name 72 73 74 class InterfacesWrapper: 75 """COM constants name translator 76 """ 77 def __init__(self): 78 pass 79 80 def __getattr__(self, a): 81 try: 82 return win32com.client.constants.__getattr__(a) 83 except AttributeError,e: 84 if a.startswith("__"): 85 raise e 86 return ConstantFake(None, a) 87 88 ctx = {'mgr':mgr, 'vb':vbox, 'ifaces':InterfacesWrapper(), 51 89 'remote':False, 'type':'mscom' } 52 90
Note:
See TracChangeset
for help on using the changeset viewer.