VirtualBox

Changeset 100845 in vbox for trunk


Ignore:
Timestamp:
Aug 9, 2023 9:00:37 PM (19 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
158746
Message:

ValKit/testdriver/base.py: Use utils.processCheckPidAndName for implementing processCheckPidAndName. That one is clean of pylint warnings.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testdriver/base.py

    r99113 r100845  
    4747import socket
    4848import stat
    49 import subprocess
    5049import sys
    5150import time
     
    281280    Checks if a process PID and NAME matches.
    282281    """
    283     if sys.platform == 'win32':
    284         fRc = winbase.processCheckPidAndName(uPid, sName);
    285     else:
    286         sOs = utils.getHostOs();
    287         if sOs == 'linux':
    288             asPsCmd = ['/bin/ps',     '-p', '%u' % (uPid,), '-o', 'fname='];
    289         elif sOs == 'solaris':
    290             asPsCmd = ['/usr/bin/ps', '-p', '%u' % (uPid,), '-o', 'fname='];
    291         elif sOs == 'darwin':
    292             asPsCmd = ['/bin/ps',     '-p', '%u' % (uPid,), '-o', 'ucomm='];
    293         else:
    294             asPsCmd = None;
    295 
    296         if asPsCmd is not None:
    297             try:
    298                 oPs = subprocess.Popen(asPsCmd, stdout=subprocess.PIPE); # pylint: disable=consider-using-with
    299                 sCurName = oPs.communicate()[0];
    300                 iExitCode = oPs.wait();
    301             except:
    302                 reporter.logXcpt();
    303                 return False;
    304 
    305             # ps fails with non-zero exit code if the pid wasn't found.
    306             if iExitCode != 0:
    307                 return False;
    308             if sCurName is None:
    309                 return False;
    310             sCurName = sCurName.strip();
    311             if sCurName == '':
    312                 return False;
    313 
    314             if os.path.basename(sName) == sName:
    315                 sCurName = os.path.basename(sCurName);
    316             elif os.path.basename(sCurName) == sCurName:
    317                 sName = os.path.basename(sName);
    318 
    319             if sCurName != sName:
    320                 return False;
    321 
    322             fRc = True;
    323     return fRc;
     282    return utils.processCheckPidAndName(uPid, sName);
    324283
    325284def wipeDirectory(sDir):
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