VirtualBox

Changeset 103326 in vbox


Ignore:
Timestamp:
Feb 13, 2024 12:53:57 AM (10 months ago)
Author:
vboxsync
Message:

Installer/vboxapisetup.py: Use os.path.exist() rather than searching the listdir() output when searching for a module. listdir may barf on 2.6 if applied to .zip files (not that it is necessarily relevant). bugref:10579

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Installer/common/vboxapisetup.py

    r103325 r103326  
    151151    return True
    152152
     153## @todo r=bird: This is supposed to be publicly visible?
    153154def findModulePathHelper(sModule = 'vboxapi', asDirs = None):
    154155    """
     
    161162    for sPath in asDirs:
    162163        if g_fVerbose:
    163             print('Searching for "%s" in path "%s" ...' % (sModule, sPath))
    164         ## @todo r=bird: WOW. We read the directory and then look for a filename in the returned list?!? Case sensitively.
    165         ##  What about:
    166         ## if g_fVerbose: # drop this
    167         ##     print(os.listdir(sPath));
    168         ## sCandiate = os.path.join(sPath, sModule);
    169         ## if os.path.exists(sCandiate):
    170         ##     return sCandiate;
    171         if os.path.isdir(sPath):
    172             asDirEntries = os.listdir(sPath)
    173             if g_fVerbose:
    174                 print(asDirEntries)
    175             if sModule in asDirEntries:
    176                 return os.path.join(sPath, sModule)
     164            print('Searching for "%s" in "%s" ...' % (sModule, sPath))
     165            try: print(os.listdir(sPath));
     166            except: pass;
     167        sCandiate = os.path.join(sPath, sModule);
     168        if os.path.exists(sCandiate):
     169             return sCandiate;
    177170    return None
    178171
     172## @todo r=bird: This is supposed to be publicly visible?
    179173def findModulePath(sModule = 'vboxapi'):
    180174    """
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