VirtualBox

Ignore:
Timestamp:
Mar 25, 2020 4:29:07 PM (5 years ago)
Author:
vboxsync
Message:

common/utils.py: Added processOutputUnchecked.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/common/utils.py

    r83357 r83416  
    717717    return sOutput;
    718718
     719def processOutputUnchecked(*aPositionalArgs, **dKeywordArgs):
     720    """
     721    Similar to processOutputChecked, but returns status code and both stdout
     722    and stderr results.
     723
     724    Extra keywords for specifying now output is to be decoded:
     725        sEncoding='utf-8
     726        fIgnoreEncoding=True/False
     727    """
     728    sEncoding = dKeywordArgs.get('sEncoding');
     729    if sEncoding is not None:   del dKeywordArgs['sEncoding'];
     730    else:                       sEncoding = 'utf-8';
     731
     732    fIgnoreEncoding = dKeywordArgs.get('fIgnoreEncoding');
     733    if fIgnoreEncoding is not None:   del dKeywordArgs['fIgnoreEncoding'];
     734    else:                             fIgnoreEncoding = True;
     735
     736    _processFixPythonInterpreter(aPositionalArgs, dKeywordArgs);
     737    oProcess = processPopenSafe(stdout = subprocess.PIPE, stderr = subprocess.PIPE, *aPositionalArgs, **dKeywordArgs);
     738
     739    sOutput, sError = oProcess.communicate();
     740    iExitCode       = oProcess.poll();
     741
     742    if hasattr(sOutput, 'decode'):
     743        sOutput = sOutput.decode(sEncoding, 'ignore' if fIgnoreEncoding else 'strict');
     744    if hasattr(sError, 'decode'):
     745        sError = sError.decode(sEncoding, 'ignore' if fIgnoreEncoding else 'strict');
     746    return (iExitCode, sOutput, sError);
     747
    719748g_fOldSudo = None;
    720749def _sudoFixArguments(aPositionalArgs, dKeywordArgs, fInitialEnv = True):
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