mirror of
https://git.rtems.org/rtems-tools/
synced 2025-10-19 18:00:25 +08:00
Python 3 compatibility
This commit is contained in:
@@ -74,7 +74,7 @@ def _output(text = os.linesep, log = None):
|
||||
else:
|
||||
lock.acquire()
|
||||
for l in text.replace(chr(13), '').splitlines():
|
||||
print l
|
||||
print(l)
|
||||
lock.release()
|
||||
|
||||
def stderr(text = os.linesep, log = None):
|
||||
@@ -92,7 +92,7 @@ def notice(text = os.linesep, log = None, stdout_only = False):
|
||||
(default is not None and not default.has_stdout() or stdout_only):
|
||||
lock.acquire()
|
||||
for l in text.replace(chr(13), '').splitlines():
|
||||
print l
|
||||
print(l)
|
||||
lock.release()
|
||||
if not stdout_only:
|
||||
_output(text, log)
|
||||
@@ -127,7 +127,7 @@ class log:
|
||||
else:
|
||||
try:
|
||||
self.fhs.append(file(s, 'w'))
|
||||
except IOError, ioe:
|
||||
except IOError as ioe:
|
||||
raise error.general("creating log file '" + s + \
|
||||
"': " + str(ioe))
|
||||
|
||||
@@ -186,41 +186,41 @@ if __name__ == "__main__":
|
||||
l.output('log: hello world CRLF\r\n')
|
||||
l.output('log: hello world NONE')
|
||||
l.flush()
|
||||
print '=-' * 40
|
||||
print 'tail: %d' % (len(l.tail))
|
||||
print l
|
||||
print '=-' * 40
|
||||
print('=-' * 40)
|
||||
print('tail: %d' % (len(l.tail)))
|
||||
print(l)
|
||||
print('=-' * 40)
|
||||
for i in range(0, 10):
|
||||
l.output('log: hello world 2: %d\n' % (i))
|
||||
l.flush()
|
||||
print '=-' * 40
|
||||
print 'tail: %d' % (len(l.tail))
|
||||
print l
|
||||
print '=-' * 40
|
||||
print('=-' * 40)
|
||||
print('tail: %d' % (len(l.tail)))
|
||||
print(l)
|
||||
print('=-' * 40)
|
||||
for i in [0, 1]:
|
||||
quiet = False
|
||||
tracing = False
|
||||
print '- quiet:%s - trace:%s %s' % (str(quiet), str(tracing), '-' * 30)
|
||||
print('- quiet:%s - trace:%s %s' % (str(quiet), str(tracing), '-' * 30))
|
||||
trace('trace with quiet and trace off')
|
||||
notice('notice with quiet and trace off')
|
||||
quiet = True
|
||||
tracing = False
|
||||
print '- quiet:%s - trace:%s %s' % (str(quiet), str(tracing), '-' * 30)
|
||||
print('- quiet:%s - trace:%s %s' % (str(quiet), str(tracing), '-' * 30))
|
||||
trace('trace with quiet on and trace off')
|
||||
notice('notice with quiet on and trace off')
|
||||
quiet = False
|
||||
tracing = True
|
||||
print '- quiet:%s - trace:%s %s' % (str(quiet), str(tracing), '-' * 30)
|
||||
print('- quiet:%s - trace:%s %s' % (str(quiet), str(tracing), '-' * 30))
|
||||
trace('trace with quiet off and trace on')
|
||||
notice('notice with quiet off and trace on')
|
||||
quiet = True
|
||||
tracing = True
|
||||
print '- quiet:%s - trace:%s %s' % (str(quiet), str(tracing), '-' * 30)
|
||||
print('- quiet:%s - trace:%s %s' % (str(quiet), str(tracing), '-' * 30))
|
||||
trace('trace with quiet on and trace on')
|
||||
notice('notice with quiet on and trace on')
|
||||
default = l
|
||||
print '=-' * 40
|
||||
print 'tail: %d' % (len(l.tail))
|
||||
print l
|
||||
print '=-' * 40
|
||||
print('=-' * 40)
|
||||
print('tail: %d' % (len(l.tail)))
|
||||
print(l)
|
||||
print('=-' * 40)
|
||||
del l
|
||||
|
Reference in New Issue
Block a user