Changeset 71157 in vbox for trunk/src/VBox/ValidationKit/common
- Timestamp:
- Feb 28, 2018 3:38:15 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 121053
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/common/utils.py
r70710 r71157 6 6 Common Utility Functions. 7 7 """ 8 9 from __future__ import print_function; 8 10 9 11 __copyright__ = \ … … 61 63 xrange = range; # pylint: disable=redefined-builtin,invalid-name 62 64 long = int; # pylint: disable=redefined-builtin,invalid-name 65 66 67 # 68 # Output. 69 # 70 71 def printOut(sString): 72 """ 73 Outputs a string to standard output, dealing with python 2.x encoding stupidity. 74 """ 75 sStreamEncoding = sys.stdout.encoding; 76 if sStreamEncoding == 'UTF-8' or not isinstance(sString, unicode): 77 print(sString); 78 else: 79 print(sString.encode(sStreamEncoding, 'backslashreplace').decode(sStreamEncoding)); 80 81 def printErr(sString): 82 """ 83 Outputs a string to standard error, dealing with python 2.x encoding stupidity. 84 """ 85 sStreamEncoding = sys.stderr.encoding; 86 if sStreamEncoding == 'UTF-8' or not isinstance(sString, unicode): 87 print(sString, file = sys.stderr); 88 else: 89 print(sString.encode(sStreamEncoding, 'backslashreplace').decode(sStreamEncoding), file = sys.stderr); 63 90 64 91
Note:
See TracChangeset
for help on using the changeset viewer.