Changeset 70568 in vbox
- Timestamp:
- Jan 12, 2018 9:44:37 PM (7 years ago)
- File:
-
- 1 edited
-
trunk/src/VBox/ValidationKit/common/utils.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/common/utils.py
r70567 r70568 381 381 except: 382 382 return sXcptRet; 383 return sRet.decode(sEncoding, 'ignore'); 383 if hasattr(sRet, 'decode'): 384 sRet = sRet.decode(sEncoding, 'ignore'); 385 return sRet; 384 386 385 387 def readFile(sFile, sMode = 'rb'): … … 400 402 except: 401 403 sRet = sXcptRet; 402 if sEncoding is not None :404 if sEncoding is not None and hasattr(sRet, 'decode'): 403 405 sRet = sRet.decode(sEncoding, 'ignore'); 404 406 return sRet; … … 588 590 Wrapper around subprocess.check_output to deal with its absense in older 589 591 python versions. 590 Extra keyword: sEncoding='utf-8; for specifying now output is to be decoded. 592 593 Extra keywords for specifying now output is to be decoded: 594 sEncoding='utf-8 595 fIgnoreEncoding=True/False 591 596 """ 592 597 sEncoding = dKeywordArgs.get('sEncoding'); 593 598 if sEncoding is not None: del dKeywordArgs['sEncoding']; 594 599 else: sEncoding = 'utf-8'; 600 601 fIgnoreEncoding = dKeywordArgs.get('fIgnoreEncoding'); 602 if sEncoding is not None: del dKeywordArgs['fIgnoreEncoding']; 603 else: fIgnoreEncoding = True; 595 604 596 605 _processFixPythonInterpreter(aPositionalArgs, dKeywordArgs); … … 607 616 raise subprocess.CalledProcessError(iExitCode, asArgs); 608 617 609 return sOutput.decode(sEncoding); 618 if hasattr(sOutput, 'decode'): 619 sOutput = sOutput.decode(sEncoding, 'ignore' if fIgnoreEncoding else 'strict'); 620 return sOutput; 610 621 611 622 g_fOldSudo = None;
Note:
See TracChangeset
for help on using the changeset viewer.

