VirtualBox

Changeset 103325 in vbox for trunk/src/VBox/Installer/common


Ignore:
Timestamp:
Feb 13, 2024 12:40:49 AM (11 months ago)
Author:
vboxsync
Message:

Installer/vboxapisetup*.py: Some pylint nits. Removed some unnecessary newline escaping and such. bugref:10579

Location:
trunk/src/VBox/Installer/common
Files:
2 edited

Legend:

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

    r103028 r103325  
    3737    import sys
    3838    try:
    39         sys.path.append("vboxapi")
     39        sys.path.append("vboxapi") # ASSUMES that the CWD is the same as the script directory. This has always been the case.
    4040        import setup
    4141        sys.exit(setup.main())
    42     except ImportError as exc:
    43         print("VBox Python API binding sources not found: %s" % (exc))
     42    except ImportError as oXcpt:
     43        print("VBox Python API binding sources not found: %s" % (oXcpt,))
    4444    sys.exit(1)
  • trunk/src/VBox/Installer/common/vboxapisetup.py

    r103073 r103325  
    136136        oVBox    = oVBoxMgr.getVirtualBox()
    137137        oHost    = oVBox.host
    138         if oHost.architecture not in (oVBoxMgr.constants.PlatformArchitecture_x86, \
     138        if oHost.architecture not in (oVBoxMgr.constants.PlatformArchitecture_x86,
    139139                                      oVBoxMgr.constants.PlatformArchitecture_ARM):
    140140            raise Exception('Host platform invalid!')
     
    144144        del oVBoxMgr
    145145    except ImportError as exc:
    146         print("ERROR: Testing VirtualBox Python bindings failed: %s" % (exc))
     146        print("ERROR: Testing VirtualBox Python bindings failed: %s" % (exc,))
    147147        return False
    148148
    149     print("Installation of VirtualBox Python bindings for Python %d.%d successful." \
     149    print("Installation of VirtualBox Python bindings for Python %d.%d successful."
    150150          % (sys.version_info.major, sys.version_info.minor))
    151151    return True
    152152
    153 def findModulePathHelper(sModule = 'vboxapi', aDir = sys.path):
     153def findModulePathHelper(sModule = 'vboxapi', asDirs = None):
    154154    """
    155155    Helper function for findModulePath.
     
    157157    Returns the path found, or None if not found.
    158158    """
    159     for sPath in aDir:
     159    if asDirs is None:
     160        asDirs = sys.path;
     161    for sPath in asDirs:
    160162        if g_fVerbose:
    161163            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;
    162171        if os.path.isdir(sPath):
    163             aDirEntries = os.listdir(sPath)
     172            asDirEntries = os.listdir(sPath)
    164173            if g_fVerbose:
    165                 print(aDirEntries)
    166             if sModule in aDirEntries:
     174                print(asDirEntries)
     175            if sModule in asDirEntries:
    167176                return os.path.join(sPath, sModule)
    168177    return None
     
    188197    pass
    189198
    190 class setupInstallClass(install):
     199class VBoxSetupInstallClass(install):
    191200    """
    192201    Class which overrides the "install" command of the setup so that we can
     
    210219    # Deprecation warning for older Python stuff (< Python 3.x).
    211220    if sys.version_info.major < 3:
    212         print("\nWarning: Running VirtualBox with Python %d.%d is marked as being deprecated.\n" \
    213               "Please upgrade your Python installation to avoid breakage.\n" \
    214               % (sys.version_info.major, sys.version_info.minor))
     221        print("\nWarning: Running VirtualBox with Python %d.%d is marked as being deprecated.\n"
     222              "Please upgrade your Python installation to avoid breakage.\n"
     223              % (sys.version_info.major, sys.version_info.minor,))
    215224
    216225    sVBoxInstallPath = os.environ.get("VBOX_MSI_INSTALL_PATH", None)
     
    247256        #              Better would be patching the *installed* module instead of the original module.
    248257        sVBoxSdkPath = os.path.join(sVBoxInstallPath, "sdk")
    249         fRc = patchWith(os.path.join(sCurDir, 'src', 'vboxapi', '__init__.py'), \
    250                         sVBoxInstallPath, sVBoxSdkPath)
     258        fRc = patchWith(os.path.join(sCurDir, 'src', 'vboxapi', '__init__.py'), sVBoxInstallPath, sVBoxSdkPath)
    251259        if not fRc:
    252260            return 1
     
    266274                print("ERROR: setuptools package not installed, can't continue. Exiting.")
    267275                return 1
    268             setup(cmdclass={"install": setupInstallClass})
     276            setup(cmdclass = { "install": VBoxSetupInstallClass, })
    269277        else:
    270278            try:
     
    279287                    print("Invoking setuptools directly ...")
    280288                setupTool = setup(name='vboxapi',
    281                             version=sVBoxVersion,
    282                             description='Python interface to VirtualBox',
    283                             author='Oracle Corp.',
    284                             author_email='[email protected]',
    285                             url='https://www.virtualbox.org',
    286                             package_dir={'': 'src'},
    287                             packages=['vboxapi'])
     289                                  version=sVBoxVersion,
     290                                  description='Python interface to VirtualBox',
     291                                  author='Oracle Corp.',
     292                                  author_email='[email protected]',
     293                                  url='https://www.virtualbox.org',
     294                                  package_dir={'': 'src'},
     295                                  packages=['vboxapi'])
    288296                if setupTool:
    289297                    sPathInstalled = setupTool.command_obj['install'].install_lib
    290298                    if sPathInstalled not in sys.path:
    291                         print("\nWARNING: Installation path is not in current module search path!")
    292                         print("         This might happen on OSes / distributions which only maintain packages by")
    293                         print("         a vendor-specific method.")
     299                        print("");
     300                        print("WARNING: Installation path is not in current module search path!")
     301                        print("         This might happen on OSes / distributions which only maintain ")
     302                        print("         packages by a vendor-specific method.")
    294303                        print("Hints:")
    295304                        print("- Check how the distribution handles user-installable Python packages.")
     
    304313
    305314    except RuntimeError as exc:
    306         print("ERROR: Installation of VirtualBox Python bindings failed: %s" % (exc))
     315        print("ERROR: Installation of VirtualBox Python bindings failed: %s" % (exc,))
    307316        return 1
    308317
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