Changeset 67049 in vbox for trunk/src/VBox
- Timestamp:
- May 23, 2017 5:48:32 PM (8 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxShell/vboxshell.py
r63231 r67049 267 267 vbox = ctx['vb'] 268 268 perf = ctx['perf'] 269 session = ctx['global'].getSessionObject( vbox)269 session = ctx['global'].getSessionObject() 270 270 progress = mach.launchVMProcess(session, vmtype, "") 271 271 if progressBar(ctx, progress, 100) and int(progress.resultCode) == 0: … … 700 700 try: 701 701 vbox = ctx['vb'] 702 session = ctx['global'].getSessionObject(vbox) 703 mach.lockMachine(session, ctx['global'].constants.LockType_Shared) 702 session = ctx['global'].openMachineSession(mach, fPermitSharing=True) 704 703 except Exception as e: 705 704 printErr(ctx, "Session to '%s' not open: %s" % (mach.name, str(e))) … … 747 746 748 747 def cmdClosedVm(ctx, mach, cmd, args=[], save=True): 749 session = ctx['global'].openMachineSession(mach, True)748 session = ctx['global'].openMachineSession(mach, fPermitSharing=True) 750 749 mach = session.machine 751 750 try: … … 767 766 768 767 def cmdAnyVm(ctx, mach, cmd, args=[], save=False): 769 session = ctx['global'].openMachineSession(mach )768 session = ctx['global'].openMachineSession(mach, fPermitSharing=True) 770 769 mach = session.machine 771 770 try: … … 1670 1669 guestPort = int(args[4]) 1671 1670 proto = "TCP" 1672 session = ctx['global'].openMachineSession(mach )1671 session = ctx['global'].openMachineSession(mach, fPermitSharing=True) 1673 1672 mach = session.machine 1674 1673 … … 1879 1878 1880 1879 ctx['wsinfo'] = [url, user, passwd] 1881 vbox = ctx['global'].platform.connect(url, user, passwd) 1882 ctx['vb'] = vbox 1880 ctx['vb'] = ctx['global'].platform.connect(url, user, passwd) 1883 1881 try: 1884 print("Running VirtualBox version %s" % ( vbox.version))1882 print("Running VirtualBox version %s" % (ctx['vb'].version)) 1885 1883 except Exception as e: 1886 1884 printErr(ctx, e) … … 1926 1924 if g_fVerbose: 1927 1925 traceback.print_exc() 1926 ctx['perf'] = ctx['global'].getPerfCollector(ctx['vb']) 1928 1927 return 0 1929 1928 … … 2906 2905 if len(cmdargs) > 1: 2907 2906 rosession = 0 2908 session = ctx['global'].openMachineSession(mach, False)2907 session = ctx['global'].openMachineSession(mach, fPermitSharing=False) 2909 2908 mach = session.machine 2910 2909 … … 3084 3083 func = args[3] 3085 3084 session = None 3086 session = ctx['global'].openMachineSession(vm )3085 session = ctx['global'].openMachineSession(vm, fPermitSharing=True) 3087 3086 vm = session.machine 3088 3087 adapter = vm.getNetworkAdapter(nicnum) … … 3540 3539 asLocations = [ os.getcwd(), ] 3541 3540 try: sScriptDir = os.path.dirname(os.path.abspath(__file__)) 3542 except: pass ;# In case __file__ isn't there.3541 except: pass # In case __file__ isn't there. 3543 3542 else: 3544 3543 if platform.system() in [ 'SunOS', ]: … … 3584 3583 ctx = { 3585 3584 'global': oVBoxMgr, 3586 'vb': oVBoxMgr. vbox,3585 'vb': oVBoxMgr.getVirtualBox(), 3587 3586 'const': oVBoxMgr.constants, 3588 3587 'remote': oVBoxMgr.remote, … … 3605 3604 # 3606 3605 for sKey in list(ctx.keys()): 3607 del ctx[sKey] ;3608 ctx = None ;3609 gc.collect() ;3606 del ctx[sKey] 3607 ctx = None 3608 gc.collect() 3610 3609 3611 3610 oVBoxMgr.deinit() -
trunk/src/VBox/Main/glue/vboxapi.py
r66630 r67049 45 45 # Globals, environment and sys.path changes. 46 46 # 47 import platform ;47 import platform 48 48 VBoxBinDir = os.environ.get("VBOX_PROGRAM_PATH", None) 49 49 VBoxSdkDir = os.environ.get("VBOX_SDK_PATH", None) … … 210 210 return None 211 211 212 def getSessionObject(self , oIVBox):212 def getSessionObject(self): 213 213 """ 214 214 Get a session object that can be used for opening machine sessions. … … 219 219 See also openMachineSession. 220 220 """ 221 _ = oIVBox222 221 return None 223 222 … … 514 513 return oGenCache.EnsureModule(self.VBOX_TLB_GUID, self.VBOX_TLB_LCID, self.VBOX_TLB_MAJOR, self.VBOX_TLB_MINOR) 515 514 516 def getSessionObject(self, oIVBox): 517 _ = oIVBox 515 def getSessionObject(self): 518 516 import win32com 519 517 from win32com.client import Dispatch … … 545 543 # the missing type information from the getter. 546 544 # 547 oOleObj = getattr(oInterface, '_oleobj_') ;548 aPropMapGet = getattr(oInterface, '_prop_map_get_') ;549 aPropMapPut = getattr(oInterface, '_prop_map_put_') ;550 sComAttrib = sAttrib if sAttrib in aPropMapGet else ComifyName(sAttrib) ;545 oOleObj = getattr(oInterface, '_oleobj_') 546 aPropMapGet = getattr(oInterface, '_prop_map_get_') 547 aPropMapPut = getattr(oInterface, '_prop_map_put_') 548 sComAttrib = sAttrib if sAttrib in aPropMapGet else ComifyName(sAttrib) 551 549 try: 552 aArgs, aDefaultArgs = aPropMapPut[sComAttrib] ;553 aGetArgs = aPropMapGet[sComAttrib] ;550 aArgs, aDefaultArgs = aPropMapPut[sComAttrib] 551 aGetArgs = aPropMapGet[sComAttrib] 554 552 except KeyError: # fallback. 555 return oInterface.__setattr__(sAttrib, aoArray) ;556 557 import pythoncom ;553 return oInterface.__setattr__(sAttrib, aoArray) 554 555 import pythoncom 558 556 oOleObj.InvokeTypes(aArgs[0], # dispid 559 557 aArgs[1], # LCID … … 561 559 (pythoncom.VT_HRESULT, 0), # retType - or void? 562 560 (aGetArgs[2],), # argTypes - trick: we get the type from the getter. 563 aoArray,) ;# The array561 aoArray,) # The array 564 562 565 563 def initPerThread(self): … … 753 751 _ = dParams 754 752 755 def getSessionObject(self, oIVBox): 756 _ = oIVBox 753 def getSessionObject(self): 757 754 import xpcom.components 758 755 return xpcom.components.classes["@virtualbox.org/Session;1"].createInstance() … … 881 878 # 882 879 883 def getSessionObject(self , oIVBox):884 return self.wsmgr.getSessionObject( oIVBox)880 def getSessionObject(self): 881 return self.wsmgr.getSessionObject(self.vbox) 885 882 886 883 def getVirtualBox(self): … … 1014 1011 # Get the virtualbox singleton. 1015 1012 try: 1016 self.vbox = self.platform.getVirtualBox()1013 vbox = self.platform.getVirtualBox() 1017 1014 except NameError: 1018 1015 print("Installation problem: check that appropriate libs in place") … … 1023 1020 print("init exception: ", e) 1024 1021 traceback.print_exc() 1025 if self.remote:1026 self.vbox = None1027 else:1028 raise e1029 1022 1030 1023 def __del__(self): … … 1044 1037 only one method called getSessionObject. It moved into this class. 1045 1038 """ 1046 return self ;1039 return self 1047 1040 1048 1041 # … … 1053 1046 return self.platform.getVirtualBox() 1054 1047 1055 def getSessionObject(self, oIVBox ):1048 def getSessionObject(self, oIVBox = None): 1056 1049 """ See PlatformBase::getSessionObject(). """ 1057 return self.platform.getSessionObject(oIVBox) 1050 # ignore parameter which was never needed 1051 _ = oIVBox 1052 return self.platform.getSessionObject() 1058 1053 1059 1054 def getArray(self, oInterface, sAttrib): … … 1097 1092 Do not access it after calling this method. 1098 1093 """ 1099 if hasattr(self, "vbox") and self.vbox is not None:1100 del self.vbox1101 self.vbox = None1102 1094 if hasattr(self, "platform") and self.platform is not None: 1103 1095 self.platform.deinit() … … 1114 1106 Raises exception on failure. 1115 1107 """ 1116 oSession = self.getSessionObject( self.vbox);1108 oSession = self.getSessionObject() 1117 1109 if fPermitSharing: 1118 1110 eType = self.constants.LockType_Shared -
trunk/src/VBox/Main/webservice/samples/python/clienttest.py
r62485 r67049 39 39 from vboxapi import VirtualBoxManager 40 40 # This is a VirtualBox COM/XPCOM API client, no data needed. 41 wrapper = VirtualBoxManager(None, None)41 mgr = VirtualBoxManager(None, None) 42 42 43 # Get the VirtualBox manager44 mgr = wrapper.mgr45 43 # Get the global VirtualBox object 46 vbox = wrapper.vbox44 vbox = mgr.getVirtualBox() 47 45 48 46 print "Running VirtualBox version %s" %(vbox.version) 49 47 50 # Get all constants through the Python wrapper code51 vboxConstants = wrapper.constants48 # Get all constants through the Python manager code 49 vboxConstants = mgr.constants 52 50 53 51 # Enumerate all defined machines 54 for mach in wrapper.getArray(vbox, 'machines'):52 for mach in mgr.getArray(vbox, 'machines'): 55 53 56 54 try: … … 80 78 81 79 # Get the session object 82 session = mgr.getSessionObject( vbox)80 session = mgr.getSessionObject() 83 81 84 82 # Lock the current machine (shared mode, since we won't modify the machine) … … 111 109 traceback.print_exc() 112 110 113 # Call destructor and delete wrapper114 del wrapper111 # Call destructor and delete manager 112 del mgr 115 113 116 114 if __name__ == '__main__': -
trunk/src/VBox/ValidationKit/testdriver/vbox.py
r67048 r67049 2510 2510 or (self.fpApiVer == 4.3 and not hasattr(self.oVBoxMgr, 'getSessionObject')): 2511 2511 oSession = self.oVBoxMgr.mgr.getSessionObject(self.oVBox); # pylint: disable=E1101 2512 elif self.fpApiVer < 5.2 \ 2513 or (self.fpApiVer == 5.2 and hasattr(self.oVBoxMgr, 'vbox')): 2514 oSession = self.oVBoxMgr.getSessionObject(self.oVBox); # pylint: disable=E1101 2512 2515 else: 2513 oSession = self.oVBoxMgr.getSessionObject( self.oVBox);# pylint: disable=E11012516 oSession = self.oVBoxMgr.getSessionObject(); # pylint: disable=E1101 2514 2517 if self.fpApiVer < 3.3: 2515 2518 oProgress = self.oVBox.openRemoteSession(oSession, sUuid, sType, sEnv);
Note:
See TracChangeset
for help on using the changeset viewer.