VirtualBox

Changeset 48321 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Sep 5, 2013 5:35:55 PM (11 years ago)
Author:
vboxsync
Message:

vboxapi.py: Ensure that the dynamic python code for the VBox type library is up to date since we're not quite following the COM guidelines.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/glue/vboxapi.py

    r48282 r48321  
    484484        ## @todo
    485485
    486 
    487         win32com.client.gencache.EnsureDispatch('VirtualBox.Session')
    488         win32com.client.gencache.EnsureDispatch('VirtualBox.VirtualBox')
     486        #
     487        # Make sure the gencache is correct (we don't quite follow the COM
     488        # versioning rules).
     489        #
     490        self.flushGenPyCache(win32com.client.gencache);
     491        win32com.client.gencache.EnsureDispatch('VirtualBox.Session');
     492        win32com.client.gencache.EnsureDispatch('VirtualBox.VirtualBox');
    489493
    490494        self.oIntCv = threading.Condition()
     
    492496
    493497        _ = dParams;
     498
     499    def flushGenPyCache(self, oGenCache):
     500        """
     501        Flushes VBox related files in the win32com gen_py cache.
     502
     503        This is necessary since we don't follow the typelib versioning rules
     504        that everyeone else seems to subscribe to.
     505        """
     506        #
     507        # The EnsureModule method have broken validation code, it doesn't take
     508        # typelib module directories into account.  So we brute force them here.
     509        # (It's possible the directory approach is from some older pywin
     510        # version or the result of runnig makepy or gencache manually, but we
     511        # need to cover it as well.)
     512        #
     513        sName    = oGenCache.GetGeneratedFileName(self.VBOX_TLB_GUID, self.VBOX_TLB_LCID,
     514                                                  self.VBOX_TLB_MAJOR, self.VBOX_TLB_MINOR);
     515        sGenPath = oGenCache.GetGeneratePath();
     516        if len(sName) > 36 and len(sGenPath) > 5:
     517            sTypelibPath = os.path.join(sGenPath, sName);
     518            if os.path.isdir(sTypelibPath):
     519                import shutil;
     520                shutil.rmtree(sTypelibPath, ignore_errors = True);
     521
     522        #
     523        # Ensure that our typelib is valid.
     524        #
     525        return oGenCache.EnsureModule(self.VBOX_TLB_GUID, self.VBOX_TLB_LCID, self.VBOX_TLB_MAJOR, self.VBOX_TLB_MINOR);
    494526
    495527    def getSessionObject(self, oIVBox):
Note: See TracChangeset for help on using the changeset viewer.

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