Python 3 compatibility

This commit is contained in:
Sebastian Huber 2015-11-12 11:15:23 +01:00
parent ab922fec9c
commit 04a52040ae
28 changed files with 284 additions and 283 deletions

View File

@ -155,16 +155,16 @@ def run():
_opts = options.load(args = sys.argv) _opts = options.load(args = sys.argv)
log.notice('RTEMS Source Builder - Check, v%s' % (version.str())) log.notice('RTEMS Source Builder - Check, v%s' % (version.str()))
if host_setup(_opts): if host_setup(_opts):
print 'Environment is ok' print('Environment is ok')
else: else:
print 'Environment is not correctly set up' print('Environment is not correctly set up')
except error.general, gerr: except error.general as gerr:
print gerr print(gerr)
sys.exit(1) sys.exit(1)
except error.internal, ierr: except error.internal as ierr:
print ierr print (ierr)
sys.exit(1) sys.exit(1)
except error.exit, eerr: except error.exit:
pass pass
except KeyboardInterrupt: except KeyboardInterrupt:
log.notice('abort: user terminated') log.notice('abort: user terminated')

View File

@ -48,10 +48,10 @@ try:
import options import options
import path import path
except KeyboardInterrupt: except KeyboardInterrupt:
print 'user terminated' print('user terminated')
sys.exit(1) sys.exit(1)
except: except:
print 'error: unknown application load error' print('error: unknown application load error')
sys.exit(1) sys.exit(1)
def _check_bool(value): def _check_bool(value):
@ -137,14 +137,14 @@ class file(object):
outter level. Nested levels will need to split with futher calls.''' outter level. Nested levels will need to split with futher calls.'''
trace_me = False trace_me = False
if trace_me: if trace_me:
print '------------------------------------------------------' print('------------------------------------------------------')
macros = [] macros = []
nesting = [] nesting = []
has_braces = False has_braces = False
c = 0 c = 0
while c < len(s): while c < len(s):
if trace_me: if trace_me:
print 'ms:', c, '"' + s[c:] + '"', has_braces, len(nesting), nesting print('ms:', c, '"' + s[c:] + '"', has_braces, len(nesting), nesting)
# #
# We need to watch for shell type variables or the form '${var}' because # We need to watch for shell type variables or the form '${var}' because
# they can upset the brace matching. # they can upset the brace matching.
@ -192,9 +192,9 @@ class file(object):
macros.append(s[macro_start:c + 1].strip()) macros.append(s[macro_start:c + 1].strip())
c += 1 c += 1
if trace_me: if trace_me:
print 'ms:', macros print('ms:', macros)
if trace_me: if trace_me:
print '-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=' print('-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=')
return macros return macros
def _shell(self, line): def _shell(self, line):
@ -750,7 +750,7 @@ class file(object):
try: try:
log.trace('config: %s: _open: %s' % (self.init_name, path.host(configname))) log.trace('config: %s: _open: %s' % (self.init_name, path.host(configname)))
config = open(path.host(configname), 'r') config = open(path.host(configname), 'r')
except IOError, err: except IOError as err:
raise error.general('error opening config file: %s' % (path.host(configname))) raise error.general('error opening config file: %s' % (path.host(configname)))
self.configpath += [configname] self.configpath += [configname]
@ -840,13 +840,13 @@ def run():
log.trace('config: count %d' % (len(opts.config_files()))) log.trace('config: count %d' % (len(opts.config_files())))
for config_file in opts.config_files(): for config_file in opts.config_files():
s = file(config_file, opts) s = file(config_file, opts)
print s print(s)
del s del s
except error.general, gerr: except error.general as gerr:
print gerr print(gerr)
sys.exit(1) sys.exit(1)
except error.internal, ierr: except error.internal as ierr:
print ierr print(ierr)
sys.exit(1) sys.exit(1)
except KeyboardInterrupt: except KeyboardInterrupt:
log.notice('abort: user terminated') log.notice('abort: user terminated')

View File

@ -57,9 +57,9 @@ class exit(error):
if __name__ == '__main__': if __name__ == '__main__':
try: try:
raise general('a general error') raise general('a general error')
except general, gerr: except general as gerr:
print 'caught:', gerr print('caught:', gerr)
try: try:
raise internal('an internal error') raise internal('an internal error')
except internal, ierr: except internal as ierr:
print 'caught:', ierr print('caught:', ierr)

View File

@ -127,7 +127,7 @@ class execute(object):
block and return None or False if this thread is to exit and True if this block and return None or False if this thread is to exit and True if this
is a timeout check.""" is a timeout check."""
if trace_threads: if trace_threads:
print 'executte:_writethread: start' print('executte:_writethread: start')
try: try:
while True: while True:
lines = input() lines = input()
@ -142,14 +142,14 @@ class execute(object):
break break
except: except:
if trace_threads: if trace_threads:
print 'executte:_writethread: exception' print('executte:_writethread: exception')
pass pass
try: try:
fh.close() fh.close()
except: except:
pass pass
if trace_threads: if trace_threads:
print 'executte:_writethread: finished' print('executte:_writethread: finished')
def _readthread(exe, fh, out, prefix = ''): def _readthread(exe, fh, out, prefix = ''):
"""Read from a file handle and write to the output handler """Read from a file handle and write to the output handler
@ -167,7 +167,7 @@ class execute(object):
log.flush() log.flush()
if trace_threads: if trace_threads:
print 'executte:_readthread: start' print('executte:_readthread: start')
count = 0 count = 0
line = '' line = ''
try: try:
@ -187,7 +187,7 @@ class execute(object):
except: except:
raise raise
if trace_threads: if trace_threads:
print 'executte:_readthread: exception' print('executte:_readthread: exception')
pass pass
try: try:
fh.close() fh.close()
@ -196,7 +196,7 @@ class execute(object):
if len(line): if len(line):
_output_line(line, exe, prefix, out, 100) _output_line(line, exe, prefix, out, 100)
if trace_threads: if trace_threads:
print 'executte:_readthread: finished' print('executte:_readthread: finished')
def _timerthread(exe, interval, function): def _timerthread(exe, interval, function):
"""Timer thread is used to timeout a process if no output is """Timer thread is used to timeout a process if no output is
@ -345,7 +345,7 @@ class execute(object):
exit_code = self._capture(command, proc, timeout) exit_code = self._capture(command, proc, timeout)
if self.verbose: if self.verbose:
log.output('exit: ' + str(exit_code)) log.output('exit: ' + str(exit_code))
except OSError, ose: except OSError as ose:
exit_code = ose.errno exit_code = ose.errno
if self.verbose: if self.verbose:
log.output('exit: ' + str(ose)) log.output('exit: ' + str(ose))
@ -453,7 +453,7 @@ class execute(object):
self.lock.acquire() self.lock.acquire()
try: try:
if self.proc is not None: if self.proc is not None:
print "sending sig" print("sending sig")
self.proc.send_signal(signal) self.proc.send_signal(signal)
except: except:
raise raise
@ -517,8 +517,8 @@ if __name__ == "__main__":
ec, proc = e.command(commands['pipe'][0], commands['pipe'][1], ec, proc = e.command(commands['pipe'][0], commands['pipe'][1],
capture = False, stdin = subprocess.PIPE) capture = False, stdin = subprocess.PIPE)
if ec == 0: if ec == 0:
print 'piping input into ' + commands['pipe'][0] + ': ' + \ print('piping input into ' + commands['pipe'][0] + ': ' + \
commands['pipe'][2] commands['pipe'][2])
proc.stdin.write(commands['pipe'][2]) proc.stdin.write(commands['pipe'][2])
proc.stdin.close() proc.stdin.close()
e.capture(proc) e.capture(proc)
@ -544,10 +544,10 @@ if __name__ == "__main__":
('date %0 %1', ['-u', '+%d %D %S'])] ('date %0 %1', ['-u', '+%d %D %S'])]
commands['unix']['pipe'] = ('grep', 'hello', 'hello world') commands['unix']['pipe'] = ('grep', 'hello', 'hello world')
print arg_list('cmd a1 a2 "a3 is a string" a4') print(arg_list('cmd a1 a2 "a3 is a string" a4'))
print arg_list('cmd b1 b2 "b3 is a string a4') print(arg_list('cmd b1 b2 "b3 is a string a4'))
print arg_subst(['nothing', 'xx-%0-yyy', '%1', '%2-something'], print(arg_subst(['nothing', 'xx-%0-yyy', '%1', '%2-something'],
['subst0', 'subst1', 'subst2']) ['subst0', 'subst1', 'subst2']))
e = execute(error_prefix = 'ERR: ', verbose = True) e = execute(error_prefix = 'ERR: ', verbose = True)
if sys.platform == "win32": if sys.platform == "win32":

View File

@ -192,10 +192,10 @@ if __name__ == '__main__':
import sys import sys
opts = options.load(sys.argv) opts = options.load(sys.argv)
g = repo('.', opts) g = repo('.', opts)
print g.git_version() print(g.git_version())
print g.valid() print(g.valid())
print g.status() print(g.status())
print g.clean() print(g.clean())
print g.remotes() print(g.remotes())
print g.email() print(g.email())
print g.head() print(g.head())

View File

@ -74,7 +74,7 @@ def _output(text = os.linesep, log = None):
else: else:
lock.acquire() lock.acquire()
for l in text.replace(chr(13), '').splitlines(): for l in text.replace(chr(13), '').splitlines():
print l print(l)
lock.release() lock.release()
def stderr(text = os.linesep, log = None): 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): (default is not None and not default.has_stdout() or stdout_only):
lock.acquire() lock.acquire()
for l in text.replace(chr(13), '').splitlines(): for l in text.replace(chr(13), '').splitlines():
print l print(l)
lock.release() lock.release()
if not stdout_only: if not stdout_only:
_output(text, log) _output(text, log)
@ -127,7 +127,7 @@ class log:
else: else:
try: try:
self.fhs.append(file(s, 'w')) self.fhs.append(file(s, 'w'))
except IOError, ioe: except IOError as ioe:
raise error.general("creating log file '" + s + \ raise error.general("creating log file '" + s + \
"': " + str(ioe)) "': " + str(ioe))
@ -186,41 +186,41 @@ if __name__ == "__main__":
l.output('log: hello world CRLF\r\n') l.output('log: hello world CRLF\r\n')
l.output('log: hello world NONE') l.output('log: hello world NONE')
l.flush() l.flush()
print '=-' * 40 print('=-' * 40)
print 'tail: %d' % (len(l.tail)) print('tail: %d' % (len(l.tail)))
print l print(l)
print '=-' * 40 print('=-' * 40)
for i in range(0, 10): for i in range(0, 10):
l.output('log: hello world 2: %d\n' % (i)) l.output('log: hello world 2: %d\n' % (i))
l.flush() l.flush()
print '=-' * 40 print('=-' * 40)
print 'tail: %d' % (len(l.tail)) print('tail: %d' % (len(l.tail)))
print l print(l)
print '=-' * 40 print('=-' * 40)
for i in [0, 1]: for i in [0, 1]:
quiet = False quiet = False
tracing = 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') trace('trace with quiet and trace off')
notice('notice with quiet and trace off') notice('notice with quiet and trace off')
quiet = True quiet = True
tracing = 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 on and trace off') trace('trace with quiet on and trace off')
notice('notice with quiet on and trace off') notice('notice with quiet on and trace off')
quiet = False quiet = False
tracing = 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 off and trace on') trace('trace with quiet off and trace on')
notice('notice with quiet off and trace on') notice('notice with quiet off and trace on')
quiet = True quiet = True
tracing = 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') trace('trace with quiet on and trace on')
notice('notice with quiet on and trace on') notice('notice with quiet on and trace on')
default = l default = l
print '=-' * 40 print('=-' * 40)
print 'tail: %d' % (len(l.tail)) print('tail: %d' % (len(l.tail)))
print l print(l)
print '=-' * 40 print('=-' * 40)
del l del l

View File

@ -239,7 +239,7 @@ class macros:
trace_me = False trace_me = False
if trace_me: if trace_me:
print '[[[[]]]] parsing macros' print('[[[[]]]] parsing macros')
orig_macros = copy.copy(self.macros) orig_macros = copy.copy(self.macros)
map = 'global' map = 'global'
lc = 0 lc = 0
@ -254,8 +254,8 @@ class macros:
l_remaining = l l_remaining = l
for c in l: for c in l:
if trace_me: if trace_me:
print ']]]]]]]] c:%s(%d) s:%s t:"%s" m:%r M:%s' % \ print(']]]]]]]] c:%s(%d) s:%s t:"%s" m:%r M:%s' % \
(c, ord(c), state, token, macro, map) (c, ord(c), state, token, macro, map))
l_remaining = l_remaining[1:] l_remaining = l_remaining[1:]
if c is '#' and not state.startswith('value'): if c is '#' and not state.startswith('value'):
break break
@ -378,7 +378,7 @@ class macros:
mc.close() mc.close()
self.files += [n] self.files += [n]
return return
except IOError, err: except IOError as err:
pass pass
raise error.general('opening macro file: %s' % \ raise error.general('opening macro file: %s' % \
(path.host(self.expand(name)))) (path.host(self.expand(name))))
@ -490,23 +490,23 @@ class macros:
if __name__ == "__main__": if __name__ == "__main__":
import copy import copy
import sys import sys
print inspect.getfile(macros) print(inspect.getfile(macros))
m = macros(name = 'defaults.mc') m = macros(name = 'defaults.mc')
d = copy.copy(m) d = copy.copy(m)
m['test1'] = 'something' m['test1'] = 'something'
if d.has_key('test1'): if d.has_key('test1'):
print 'error: copy failed.' print('error: copy failed.')
sys.exit(1) sys.exit(1)
m.parse("[test]\n" \ m.parse("[test]\n" \
"test1: none, undefine, ''\n" \ "test1: none, undefine, ''\n" \
"name: none, override, 'pink'\n") "name: none, override, 'pink'\n")
print 'set test:', m.set_read_map('test') print('set test:', m.set_read_map('test'))
if m['name'] != 'pink': if m['name'] != 'pink':
print 'error: override failed. name is %s' % (m['name']) print('error: override failed. name is %s' % (m['name']))
sys.exit(1) sys.exit(1)
if m.has_key('test1'): if m.has_key('test1'):
print 'error: map undefine failed.' print('error: map undefine failed.')
sys.exit(1) sys.exit(1)
print 'unset test:', m.unset_read_map('test') print('unset test:', m.unset_read_map('test'))
print m print(m)
print m.keys() print(m.keys())

View File

@ -75,7 +75,7 @@ class mail:
mrc = open(mailrc, 'r') mrc = open(mailrc, 'r')
lines = mrc.readlines() lines = mrc.readlines()
mrc.close() mrc.close()
except IOError, err: except IOError as err:
raise error.general('error reading: %s' % (mailrc)) raise error.general('error reading: %s' % (mailrc))
for l in lines: for l in lines:
l = _clean(l) l = _clean(l)
@ -104,9 +104,9 @@ class mail:
try: try:
s = smtplib.SMTP(self.smtp_host()) s = smtplib.SMTP(self.smtp_host())
s.sendmail(from_addr, [to_addr], msg) s.sendmail(from_addr, [to_addr], msg)
except smtplib.SMTPException, se: except smtplib.SMTPException as se:
raise error.general('sending mail: %s' % (str(se))) raise error.general('sending mail: %s' % (str(se)))
except socket.error, se: except socket.error as se:
raise error.general('sending mail: %s' % (str(se))) raise error.general('sending mail: %s' % (str(se)))
if __name__ == '__main__': if __name__ == '__main__':
@ -115,6 +115,6 @@ if __name__ == '__main__':
append_options(optargs) append_options(optargs)
opts = options.load(sys.argv, optargs = optargs, defaults = 'defaults.mc') opts = options.load(sys.argv, optargs = optargs, defaults = 'defaults.mc')
m = mail(opts) m = mail(opts)
print 'From: %s' % (m.from_address()) print('From: %s' % (m.from_address()))
print 'SMTP Host: %s' % (m.smtp_host()) print('SMTP Host: %s' % (m.smtp_host()))
m.send(m.from_address(), 'Test mailer.py', 'This is a test') m.send(m.from_address(), 'Test mailer.py', 'This is a test')

View File

@ -273,9 +273,9 @@ class command_line(object):
return indent return indent
def help(self): def help(self):
print '%s: [options] [args]' % (self.command_name) print('%s: [options] [args]' % (self.command_name))
print 'RTEMS Tools Project (c) 2012-2015 Chris Johns' print('RTEMS Tools Project (c) 2012-2015 Chris Johns')
print 'Options and arguments:' print('Options and arguments:')
opts = self.long_opts_help.keys() opts = self.long_opts_help.keys()
if self.optargs: if self.optargs:
opts += self.optargs.keys() opts += self.optargs.keys()
@ -287,7 +287,7 @@ class command_line(object):
h = self.optargs[o] h = self.optargs[o]
else: else:
raise error.general('invalid help data: %s' %(o)) raise error.general('invalid help data: %s' %(o))
print '%-*s : %s' % (indent, o, h) print('%-*s : %s' % (indent, o, h))
raise error.exit() raise error.exit()
def process(self): def process(self):
@ -580,13 +580,13 @@ def run(args):
log.notice(str(opts)) log.notice(str(opts))
log.notice('Defaults:') log.notice('Defaults:')
log.notice(str(opts.defaults)) log.notice(str(opts.defaults))
except error.general, gerr: except error.general as gerr:
print gerr print(gerr)
sys.exit(1) sys.exit(1)
except error.internal, ierr: except error.internal as ierr:
print ierr print(ierr)
sys.exit(1) sys.exit(1)
except error.exit, eerr: except error.exit:
pass pass
except KeyboardInterrupt: except KeyboardInterrupt:
_notice(opts, 'abort: user terminated') _notice(opts, 'abort: user terminated')

View File

@ -122,24 +122,24 @@ def mkdir(path):
if windows: if windows:
try: try:
os.makedirs(host(path)) os.makedirs(host(path))
except IOError, err: except IOError:
raise error.general('cannot make directory: %s' % (path)) raise error.general('cannot make directory: %s' % (path))
except OSError, err: except OSError:
raise error.general('cannot make directory: %s' % (path)) raise error.general('cannot make directory: %s' % (path))
except WindowsError, err: except WindowsError:
raise error.general('cannot make directory: %s' % (path)) raise error.general('cannot make directory: %s' % (path))
else: else:
try: try:
os.makedirs(host(path)) os.makedirs(host(path))
except IOError, err: except IOError:
raise error.general('cannot make directory: %s' % (path)) raise error.general('cannot make directory: %s' % (path))
except OSError, err: except OSError:
raise error.general('cannot make directory: %s' % (path)) raise error.general('cannot make directory: %s' % (path))
def removeall(path): def removeall(path):
def _onerror(function, path, excinfo): def _onerror(function, path, excinfo):
print 'removeall error: (%s) %s' % (excinfo, path) print('removeall error: (%s) %s' % (excinfo, path))
path = host(path) path = host(path)
shutil.rmtree(path, onerror = _onerror) shutil.rmtree(path, onerror = _onerror)
@ -208,13 +208,13 @@ def copy_tree(src, dst):
copy_tree(srcname, dstname) copy_tree(srcname, dstname)
else: else:
shutil.copy2(srcname, dstname) shutil.copy2(srcname, dstname)
except shutil.Error, err: except shutil.Error as err:
raise error.general('copying tree: %s -> %s: %s' % (src, dst, str(err))) raise error.general('copying tree: %s -> %s: %s' % (src, dst, str(err)))
except EnvironmentError, why: except EnvironmentError as why:
raise error.general('copying tree: %s -> %s: %s' % (srcname, dstname, str(why))) raise error.general('copying tree: %s -> %s: %s' % (srcname, dstname, str(why)))
try: try:
shutil.copystat(src, dst) shutil.copystat(src, dst)
except OSError, why: except OSError as why:
ok = False ok = False
if windows: if windows:
if WindowsError is not None and isinstance(why, WindowsError): if WindowsError is not None and isinstance(why, WindowsError):
@ -223,17 +223,17 @@ def copy_tree(src, dst):
raise error.general('copying tree: %s -> %s: %s' % (src, dst, str(why))) raise error.general('copying tree: %s -> %s: %s' % (src, dst, str(why)))
if __name__ == '__main__': if __name__ == '__main__':
print host('/a/b/c/d-e-f') print(host('/a/b/c/d-e-f'))
print host('//a/b//c/d-e-f') print(host('//a/b//c/d-e-f'))
print shell('/w/x/y/z') print(shell('/w/x/y/z'))
print basename('/as/sd/df/fg/me.txt') print(basename('/as/sd/df/fg/me.txt'))
print dirname('/as/sd/df/fg/me.txt') print(dirname('/as/sd/df/fg/me.txt'))
print join('/d', 'g', '/tyty/fgfg') print(join('/d', 'g', '/tyty/fgfg'))
windows = True windows = True
print host('/a/b/c/d-e-f') print(host('/a/b/c/d-e-f'))
print host('//a/b//c/d-e-f') print(host('//a/b//c/d-e-f'))
print shell('/w/x/y/z') print(shell('/w/x/y/z'))
print shell('w:/x/y/z') print(shell('w:/x/y/z'))
print basename('x:/sd/df/fg/me.txt') print(basename('x:/sd/df/fg/me.txt'))
print dirname('x:/sd/df/fg/me.txt') print(dirname('x:/sd/df/fg/me.txt'))
print join('s:/d/', '/g', '/tyty/fgfg') print(join('s:/d/', '/g', '/tyty/fgfg'))

View File

@ -42,7 +42,7 @@ def str():
return '%d.%d.%d'% (major, minor, revision) return '%d.%d.%d'% (major, minor, revision)
if __name__ == '__main__': if __name__ == '__main__':
print 'major = %d' % (major) print('major = %d' % (major))
print 'minor = %d' % (minor) print('minor = %d' % (minor))
print 'revision = %d' % (revision) print('revision = %d' % (revision))
print 'Version: %s' % (str()) print('Version: %s' % (str()))

View File

@ -185,7 +185,7 @@ class file(config.file):
def _realtime_trace(self, text): def _realtime_trace(self, text):
if self.realtime_trace: if self.realtime_trace:
for l in text: for l in text:
print ' '.join(l) print(' '.join(l))
def run(self): def run(self):
self.load(self.name) self.load(self.name)

View File

@ -100,7 +100,7 @@ class tty(console):
def __del__(self): def __del__(self):
super(tty, self).__del__() super(tty, self).__del__()
if self._tracing(): if self._tracing():
print ':: tty close', self.dev print(':: tty close', self.dev)
if fcntl is not None: if fcntl is not None:
fcntl.fcntl(me.tty.fd, fcntl.F_SETFL, fcntl.fcntl(me.tty.fd, fcntl.F_SETFL,
fcntl.fcntl(me.tty.fd, fcntl.F_GETFL) & ~os.O_NONBLOCK) fcntl.fcntl(me.tty.fd, fcntl.F_GETFL) & ~os.O_NONBLOCK)
@ -109,7 +109,7 @@ class tty(console):
def open(self): def open(self):
def _readthread(me, x): def _readthread(me, x):
if self._tracing(): if self._tracing():
print ':: tty runner started', self.dev print(':: tty runner started', self.dev)
if fcntl is not None: if fcntl is not None:
fcntl.fcntl(me.tty.fd, fcntl.F_SETFL, fcntl.fcntl(me.tty.fd, fcntl.F_SETFL,
fcntl.fcntl(me.tty.fd, fcntl.F_GETFL) | os.O_NONBLOCK) fcntl.fcntl(me.tty.fd, fcntl.F_GETFL) | os.O_NONBLOCK)
@ -118,7 +118,7 @@ class tty(console):
time.sleep(0.05) time.sleep(0.05)
try: try:
data = me.tty.fd.read() data = me.tty.fd.read()
except IOError, ioe: except IOError as ioe:
if ioe.errno == errno.EAGAIN: if ioe.errno == errno.EAGAIN:
continue continue
raise raise
@ -133,9 +133,9 @@ class tty(console):
me.output(line) me.output(line)
line = '' line = ''
if self._tracing(): if self._tracing():
print ':: tty runner finished', self.dev print(':: tty runner finished', self.dev)
if self._tracing(): if self._tracing():
print ':: tty open', self.dev print(':: tty open', self.dev)
self.tty = stty.tty(self.dev) self.tty = stty.tty(self.dev)
self.tty.set(self.setup) self.tty.set(self.setup)
self.tty.on() self.tty.on()

View File

@ -76,12 +76,12 @@ class gdb(object):
def _lock(self, msg): def _lock(self, msg):
if self.lock_trace: if self.lock_trace:
print '|[ LOCK:%s ]|' % (msg) print('|[ LOCK:%s ]|' % (msg))
self.lock.acquire() self.lock.acquire()
def _unlock(self, msg): def _unlock(self, msg):
if self.lock_trace: if self.lock_trace:
print '|] UNLOCK:%s [|' % (msg) print('|] UNLOCK:%s [|' % (msg))
self.lock.release() self.lock.release()
def _mi_lock(self): def _mi_lock(self):
@ -92,7 +92,7 @@ class gdb(object):
def _put(self, text): def _put(self, text):
if self.trace: if self.trace:
print ')))', text print(')))', text)
self.commands.put(text) self.commands.put(text)
def _input_commands(self): def _input_commands(self):
@ -100,11 +100,11 @@ class gdb(object):
return False return False
try: try:
if self.trace: if self.trace:
print '... input empty ', self.input.empty() print('... input empty ', self.input.empty())
if self.input.empty(): if self.input.empty():
line = self.commands.get(block = False) line = self.commands.get(block = False)
if self.trace: if self.trace:
print '+++', line print('+++', line)
self.input.put(line) self.input.put(line)
except: except:
pass pass
@ -113,12 +113,12 @@ class gdb(object):
def _reader(self, line): def _reader(self, line):
self._lock('_reader') self._lock('_reader')
if self.trace: if self.trace:
print '<<<', line print('<<<', line)
try: try:
self.lc += 1 self.lc += 1
if line.startswith('(gdb)'): if line.startswith('(gdb)'):
if self.trace: if self.trace:
print '^^^ (gdb)' print('^^^ (gdb)')
if not self._input_commands(): if not self._input_commands():
self.gdb_expect() self.gdb_expect()
self._input_commands() self._input_commands()
@ -138,7 +138,7 @@ class gdb(object):
self._unlock('_open') self._unlock('_open')
line = self.input.get(timeout = 0.5) line = self.input.get(timeout = 0.5)
if self.trace: if self.trace:
print '>>> input: queue=%d' % (self.input.qsize()), line print('>>> input: queue=%d' % (self.input.qsize()), line)
except Queue.Empty: except Queue.Empty:
return True return True
if line is None: if line is None:
@ -146,10 +146,10 @@ class gdb(object):
return line + os.linesep return line + os.linesep
except: except:
if self.trace: if self.trace:
print 'writer exception' print('writer exception')
pass pass
if self.trace: if self.trace:
print 'writer closing' print('writer closing')
return False return False
def _timeout(self): def _timeout(self):
@ -206,7 +206,7 @@ class gdb(object):
self.gdb_console('gdb: %s' % (' '.join(cmds))) self.gdb_console('gdb: %s' % (' '.join(cmds)))
ec, proc = self.process.open(cmds, timeout = (timeout, self._timeout)) ec, proc = self.process.open(cmds, timeout = (timeout, self._timeout))
if self.trace: if self.trace:
print 'gdb done', ec print('gdb done', ec)
if ec > 0: if ec > 0:
raise error.general('gdb exec: %s: %s' % (cmds[0], os.strerror(ec))) raise error.general('gdb exec: %s: %s' % (cmds[0], os.strerror(ec)))
except: except:
@ -219,7 +219,7 @@ class gdb(object):
def gdb_expect(self): def gdb_expect(self):
if self.trace: if self.trace:
print '}}} gdb-expect' print('}}} gdb-expect')
if self.process and not self.running and self.script is not None: if self.process and not self.running and self.script is not None:
if self.script_line == len(self.script): if self.script_line == len(self.script):
self._put(None) self._put(None)
@ -238,12 +238,12 @@ class gdb(object):
self._mi_lock() self._mi_lock()
try: try:
if self.mi_trace: if self.mi_trace:
print 'mi-data:', lines print('mi-data:', lines)
rec = pygdb.mi_parser.process(lines) rec = pygdb.mi_parser.process(lines)
finally: finally:
self._mi_unlock() self._mi_unlock()
if self.mi_trace: if self.mi_trace:
print 'mi-rec:', rec print('mi-rec:', rec)
if rec.record_type == 'result': if rec.record_type == 'result':
if rec.type == 'result': if rec.type == 'result':
if rec.class_ == 'error': if rec.class_ == 'error':
@ -255,12 +255,12 @@ class gdb(object):
elif rec.type == 'exec': elif rec.type == 'exec':
if rec.class_ == 'running': if rec.class_ == 'running':
if self.trace: if self.trace:
print '*** running' print('*** running')
self._put('') self._put('')
self.running = True self.running = True
elif rec.class_ == 'stopped': elif rec.class_ == 'stopped':
if self.trace: if self.trace:
print '*** stopped' print('*** stopped')
self.running = False self.running = False
#self._put('-data-list-register-values') #self._put('-data-list-register-values')
elif rec.type == 'breakpoint': elif rec.type == 'breakpoint':
@ -283,13 +283,13 @@ class gdb(object):
if last_lf >= 0: if last_lf >= 0:
lines = self.output_buffer[:last_lf] lines = self.output_buffer[:last_lf]
if self.trace: if self.trace:
print '/// console output' print('/// console output')
for line in lines.splitlines(): for line in lines.splitlines():
self.output(line) self.output(line)
self.output_buffer = self.output_buffer[last_lf + 1:] self.output_buffer = self.output_buffer[last_lf + 1:]
except: except:
if self.trace: if self.trace:
print '/// console output' print('/// console output')
for line in lines.splitlines(): for line in lines.splitlines():
self.output(line) self.output(line)
@ -297,9 +297,9 @@ if __name__ == "__main__":
stdtty = console.save() stdtty = console.save()
try: try:
def output(text): def output(text):
print ']', text print(']', text)
def gdb_console(text): def gdb_console(text):
print '>', text print('>', text)
script = ['target sim'] script = ['target sim']
if len(sys.argv) > 1: if len(sys.argv) > 1:
executable = sys.argv[1] executable = sys.argv[1]

View File

@ -114,13 +114,13 @@ def run(args):
log.notice(str(_opts)) log.notice(str(_opts))
log.notice('Defaults:') log.notice('Defaults:')
log.notice(str(_opts.defaults)) log.notice(str(_opts.defaults))
except error.general, gerr: except error.general as gerr:
print gerr print(gerr)
sys.exit(1) sys.exit(1)
except error.internal, ierr: except error.internal as ierr:
print ierr print(ierr)
sys.exit(1) sys.exit(1)
except error.exit, eerr: except error.exit:
pass pass
except KeyboardInterrupt: except KeyboardInterrupt:
log.notice('abort: user terminated') log.notice('abort: user terminated')

View File

@ -93,7 +93,7 @@ def __private():
def t_default(self, s): def t_default(self, s):
r'( . | \n )+' r'( . | \n )+'
raise Exception, "Specification error: unmatched input for '%s'" % s raise Exception("Specification error: unmatched input for '%s'" % s)
def __unescape(self, s): def __unescape(self, s):
s = re.sub(r'\\r', r'\r', s) s = re.sub(r'\\r', r'\r', s)
@ -167,8 +167,8 @@ def __private():
def error(self, token, i=0, tokens=None): def error(self, token, i=0, tokens=None):
if i > 2: if i > 2:
print '%s %s %s %s' % (tokens[i-3], tokens[i-2], tokens[i-1], tokens[i]) print('%s %s %s %s' % (tokens[i-3], tokens[i-2], tokens[i-1], tokens[i]))
raise Exception, "Syntax error at or near %d:'%s' token" % (i, token) raise Exception("Syntax error at or near %d:'%s' token" % (i, token))
class GdbMiInterpreter(spark.GenericASTTraversal): class GdbMiInterpreter(spark.GenericASTTraversal):
def __init__(self, ast): def __init__(self, ast):
@ -190,7 +190,7 @@ def __private():
def n_result(self, node): def n_result(self, node):
# result ::= variable = value # result ::= variable = value
node.value = { node[0].value: node[2].value } node.value = { node[0].value: node[2].value }
#print 'result: %s' % node.value #print('result: %s' % node.value)
def n_tuple(self, node): def n_tuple(self, node):
if len(node) == 2: if len(node) == 2:
@ -205,7 +205,7 @@ def __private():
for result in node[2].value: for result in node[2].value:
for n, v in result.items(): for n, v in result.items():
if node.value.has_key(n): if node.value.has_key(n):
#print '**********list conversion: [%s] %s -> %s' % (n, node.value[n], v) #print('**********list conversion: [%s] %s -> %s' % (n, node.value[n], v))
old = node.value[n] old = node.value[n]
if not isinstance(old, list): if not isinstance(old, list):
node.value[n] = [ node.value[n] ] node.value[n] = [ node.value[n] ]
@ -213,8 +213,8 @@ def __private():
else: else:
node.value[n] = v node.value[n] = v
else: else:
raise Exception, 'Invalid tuple' raise Exception('Invalid tuple')
#print 'tuple: %s' % node.value #print('tuple: %s' % node.value)
def n_list(self, node): def n_list(self, node):
if len(node) == 2: if len(node) == 2:
@ -230,7 +230,7 @@ def __private():
#list ::= [ result result_list ] #list ::= [ result result_list ]
#list ::= { value } #list ::= { value }
#list ::= { value value_list } #list ::= { value value_list }
#print 'list %s' % node.value #print('list %s' % node.value)
def n_value_list(self, node): def n_value_list(self, node):
if len(node) == 2: if len(node) == 2:
@ -247,7 +247,7 @@ def __private():
else: else:
# result_list ::= , result result_list # result_list ::= , result result_list
node.value = [ node[1].value ] + node[2].value node.value = [ node[1].value ] + node[2].value
#print 'result_list: %s' % node.value #print('result_list: %s' % node.value)
def n_result_record(self, node): def n_result_record(self, node):
node.value = node[0].value node.value = node[0].value
@ -257,7 +257,7 @@ def __private():
elif len(node) == 2: elif len(node) == 2:
# result_record ::= result_header nl # result_record ::= result_header nl
pass pass
#print 'result_record: %s' % (node.value) #print('result_record: %s' % (node.value))
def n_result_header(self, node): def n_result_header(self, node):
if len(node) == 3: if len(node) == 3:
@ -284,7 +284,7 @@ def __private():
'value': node[1].value, 'value': node[1].value,
'record_type': 'stream' 'record_type': 'stream'
} }
#print 'stream_record: %s' % node.value #print('stream_record: %s' % node.value)
def n_record_list(self, node): def n_record_list(self, node):
if len(node) == 1: if len(node) == 1:
@ -293,10 +293,10 @@ def __private():
elif len(node) == 2: elif len(node) == 2:
# record_list ::= generic_record record_list # record_list ::= generic_record record_list
node.value = [ node[0].value ] + node[1].value node.value = [ node[0].value ] + node[1].value
#print 'record_list: %s' % node.value #print('record_list: %s' % node.value)
#def default(self, node): #def default(self, node):
#print 'default: ' + node.type #print('default: ' + node.type)
class GdbDynamicObject: class GdbDynamicObject:
def __init__(self, dict_): def __init__(self, dict_):
@ -363,7 +363,7 @@ def parse(tokens):
def process(input): def process(input):
tokens = scan(input) tokens = scan(input)
ast = parse(tokens) ast = parse(tokens)
__the_interpreter(ast) __the_interpreter(ast)
return __the_output(ast.value) return __the_output(ast.value)
@ -373,9 +373,9 @@ if __name__ == '__main__':
print print
for token in tokens: for token in tokens:
if token.value: if token.value:
print token.type + ': ' + token.value print(token.type + ': ' + token.value)
else: else:
print token.type print(token.type)
def run_test(test): def run_test(test):
lines = test.splitlines() lines = test.splitlines()
@ -386,7 +386,7 @@ if __name__ == '__main__':
ast = parse(tokens) ast = parse(tokens)
__the_interpreter(ast) __the_interpreter(ast)
output = __the_output(ast.value) output = __the_output(ast.value)
print output print(output)
x = '"No symbol table is loaded. Use the \\"file\\" command."' x = '"No symbol table is loaded. Use the \\"file\\" command."'
m = re.match('\".*?(?<![\\\\])\"', x) m = re.match('\".*?(?<![\\\\])\"', x)

View File

@ -60,7 +60,7 @@ class GenericScanner:
return string.join(rv, '|') return string.join(rv, '|')
def error(self, s, pos): def error(self, s, pos):
print "Lexical error at position %s" % pos print("Lexical error at position %s" % pos)
raise SystemExit raise SystemExit
def position(self, newpos=None): def position(self, newpos=None):
@ -86,7 +86,7 @@ class GenericScanner:
def t_default(self, s): def t_default(self, s):
r'( . | \n )+' r'( . | \n )+'
print "Specification error: unmatched input" print("Specification error: unmatched input")
raise SystemExit raise SystemExit
# #
@ -303,7 +303,7 @@ class GenericParser:
return None return None
def error(self, token): def error(self, token):
print "Syntax error at or near `%s' token" % token print("Syntax error at or near `%s' token" % token)
raise SystemExit raise SystemExit
def parse(self, tokens): def parse(self, tokens):
@ -349,7 +349,8 @@ class GenericParser:
# #
return self._NULLABLE == sym[0:len(self._NULLABLE)] return self._NULLABLE == sym[0:len(self._NULLABLE)]
def skip(self, (lhs, rhs), pos=0): def skip(self, lhs_rhs, pos=0):
lhs, rhs = lhs_rhs
n = len(rhs) n = len(rhs)
while pos < n: while pos < n:
if not self.isnullable(rhs[pos]): if not self.isnullable(rhs[pos]):
@ -612,7 +613,7 @@ class GenericParser:
rule = self.ambiguity(self.newrules[nt]) rule = self.ambiguity(self.newrules[nt])
else: else:
rule = self.newrules[nt][0] rule = self.newrules[nt][0]
#print rule #print(rule)
rhs = rule[1] rhs = rule[1]
attr = [None] * len(rhs) attr = [None] * len(rhs)
@ -631,7 +632,7 @@ class GenericParser:
rule = choices[0] rule = choices[0]
if len(choices) > 1: if len(choices) > 1:
rule = self.ambiguity(choices) rule = self.ambiguity(choices)
#print rule #print(rule)
rhs = rule[1] rhs = rule[1]
attr = [None] * len(rhs) attr = [None] * len(rhs)
@ -668,7 +669,7 @@ class GenericParser:
sortlist.append((len(rhs), name)) sortlist.append((len(rhs), name))
name2index[name] = i name2index[name] = i
sortlist.sort() sortlist.sort()
list = map(lambda (a,b): b, sortlist) list = list(map(lambda a,b: b, sortlist))
return rules[name2index[self.resolve(list)]] return rules[name2index[self.resolve(list)]]
def resolve(self, list): def resolve(self, list):
@ -833,15 +834,15 @@ class GenericASTMatcher(GenericParser):
def _dump(tokens, sets, states): def _dump(tokens, sets, states):
for i in range(len(sets)): for i in range(len(sets)):
print 'set', i print('set', i)
for item in sets[i]: for item in sets[i]:
print '\t', item print('\t', item)
for (lhs, rhs), pos in states[item[0]].items: for (lhs, rhs), pos in states[item[0]].items:
print '\t\t', lhs, '::=', print('\t\t', lhs, '::=',)
print string.join(rhs[:pos]), print(string.join(rhs[:pos]),)
print '.', print('.',)
print string.join(rhs[pos:]) print(string.join(rhs[pos:]))
if i < len(tokens): if i < len(tokens):
print print
print 'token', str(tokens[i]) print('token', str(tokens[i]))
print print

View File

@ -72,7 +72,7 @@ class tty:
raise error.general('dev not found: %s' % (dev)) raise error.general('dev not found: %s' % (dev))
try: try:
self.fd = open(dev, 'rw') self.fd = open(dev, 'rw')
except IOError, ioe: except IOError as ioe:
raise error.general('opening tty dev: %s: %s' % (dev, ioe)) raise error.general('opening tty dev: %s: %s' % (dev, ioe))
except: except:
raise error.general('opening tty dev: %s: unknown' % (dev)) raise error.general('opening tty dev: %s: unknown' % (dev))
@ -558,9 +558,9 @@ if __name__ == "__main__":
t.control('CRTSCTS', False) t.control('CRTSCTS', False)
t.vmin(1) t.vmin(1)
t.vtime(2) t.vtime(2)
print t print(t)
t.set('B115200,~BRKINT,IGNBRK,IGNCR,~ICANON,~ISIG,~IEXTEN,~ECHO,CLOCAL,~CRTSCTS') t.set('B115200,~BRKINT,IGNBRK,IGNCR,~ICANON,~ISIG,~IEXTEN,~ECHO,CLOCAL,~CRTSCTS')
print t print(t)
t.on() t.on()
while True: while True:
c = t.fd.read(1) c = t.fd.read(1)

View File

@ -118,7 +118,7 @@ class test_run(object):
def reraise(self): def reraise(self):
if self.result is not None: if self.result is not None:
raise self.result[0], self.result[1], self.result[2] raise (self.result[0], self.result[1], self.result[2])
def kill(self): def kill(self):
if self.test: if self.test:
@ -157,9 +157,9 @@ def report_finished(reports, report_mode, reporting, finished, job_trace):
if len(reported): if len(reported):
del reported[:] del reported[:]
if job_trace: if job_trace:
print '}} threading:', threading.active_count() print('}} threading:', threading.active_count())
for t in threading.enumerate(): for t in threading.enumerate():
print '}} ', t.name print('}} ', t.name)
return reporting return reporting
def _job_trace(tst, msg, total, exe, active, reporting): def _job_trace(tst, msg, total, exe, active, reporting):
@ -302,20 +302,20 @@ def run(command_path = None):
end_time = datetime.datetime.now() end_time = datetime.datetime.now()
log.notice('Average test time: %s' % (str((end_time - start_time) / total))) log.notice('Average test time: %s' % (str((end_time - start_time) / total)))
log.notice('Testing time : %s' % (str(end_time - start_time))) log.notice('Testing time : %s' % (str(end_time - start_time)))
except error.general, gerr: except error.general as gerr:
print gerr print(gerr)
sys.exit(1) sys.exit(1)
except error.internal, ierr: except error.internal as ierr:
print ierr print(ierr)
sys.exit(1) sys.exit(1)
except error.exit, eerr: except error.exit:
sys.exit(2) sys.exit(2)
except KeyboardInterrupt: except KeyboardInterrupt:
if opts is not None and opts.find_arg('--stacktrace'): if opts is not None and opts.find_arg('--stacktrace'):
print '}} dumping:', threading.active_count() print('}} dumping:', threading.active_count())
for t in threading.enumerate(): for t in threading.enumerate():
print '}} ', t.name print('}} ', t.name)
print stacktraces.trace() print(stacktraces.trace())
log.notice('abort: user terminated') log.notice('abort: user terminated')
killall(tests) killall(tests)
sys.exit(1) sys.exit(1)

View File

@ -42,7 +42,7 @@ def str():
return '%d.%d.%d'% (major, minor, revision) return '%d.%d.%d'% (major, minor, revision)
if __name__ == '__main__': if __name__ == '__main__':
print 'major = %d' % (major) print('major = %d' % (major))
print 'minor = %d' % (minor) print('minor = %d' % (minor))
print 'revision = %d' % (revision) print('revision = %d' % (revision))
print 'Version: %s' % (str()) print('Version: %s' % (str()))

View File

@ -37,4 +37,4 @@ def get_architure():
_cmds = rtems.create() _cmds = rtems.create()
print 'RTEMS GDB Support' print('RTEMS GDB Support')

View File

@ -147,29 +147,29 @@ class semaphore:
def show(self, from_tty): def show(self, from_tty):
if self.object_control.id() != 0: if self.object_control.id() != 0:
print ' Name:', self.object_control.name() print(' Name:', self.object_control.name())
print ' Id: 0x%08x (@ 0x%08x)' % (self.object_control.id(), print(' Id: 0x%08x (@ 0x%08x)' % (self.object_control.id(),
self.reference) self.reference))
print ' Attr:', self.attr.to_string() print(' Attr:', self.attr.to_string())
if self.attr.test('semaphore-type', 'bin-sema') or \ if self.attr.test('semaphore-type', 'bin-sema') or \
self.attr.test('semaphore-type', 'simple-bin-sema'): self.attr.test('semaphore-type', 'simple-bin-sema'):
core_mutex = mutex.control(self.object['Core_control']['mutex']) core_mutex = mutex.control(self.object['Core_control']['mutex'])
print ' Nesting:', core_mutex.nest_count() print(' Nesting:', core_mutex.nest_count())
print ' Holder:', print(' Holder:',)
holder = core_mutex.holder() holder = core_mutex.holder()
if holder: if holder:
print '%s (id 0x%08x)' % (holder.brief(), holder.id()) print('%s (id 0x%08x)' % (holder.brief(), holder.id()))
else: else:
print 'no holder (unlocked)' print('no holder (unlocked)')
wait_queue = core_mutex.wait_queue() wait_queue = core_mutex.wait_queue()
tasks = wait_queue.tasks() tasks = wait_queue.tasks()
print ' Queue: len = %d, state = %s' % (len(tasks), print(' Queue: len = %d, state = %s' % (len(tasks),
wait_queue.state()) wait_queue.state()))
if len(tasks) > 0: if len(tasks) > 0:
print ' Tasks:' print(' Tasks:')
print ' Name (c:current, r:real), (id)' print(' Name (c:current, r:real), (id)')
for t in range(0, len(tasks)): for t in range(0, len(tasks)):
print ' ', tasks[t].brief(), ' (%08x)' % (tasks[t].id()) print(' ', tasks[t].brief(), ' (%08x)' % (tasks[t].id()))
return True return True
return False return False
@ -189,21 +189,21 @@ class task:
cpu = self.task.executing() cpu = self.task.executing()
if cpu == -1: if cpu == -1:
cpu = 'not executing' cpu = 'not executing'
print ' Id:', '0x%08x (@ 0x%08x)' % (self.task.id(), print(' Id:', '0x%08x (@ 0x%08x)' % (self.task.id(),
self.task.reference) self.task.reference))
print ' Name:', self.task.name() print(' Name:', self.task.name())
print ' Active CPU:', cpu print(' Active CPU:', cpu)
print ' State:', self.task.current_state() print(' State:', self.task.current_state())
print ' Current:', self.task.current_priority() print(' Current:', self.task.current_priority())
print ' Real:', self.task.real_priority() print(' Real:', self.task.real_priority())
print ' Preempt:', self.task.preemptible() print(' Preempt:', self.task.preemptible())
print ' T Budget:', self.task.cpu_time_budget() print(' T Budget:', self.task.cpu_time_budget())
print ' Time:', self.task.cpu_time_used() print(' Time:', self.task.cpu_time_used())
print ' Resources:', self.task.resource_count() print(' Resources:', self.task.resource_count())
print ' Regsters:' print(' Regsters:')
for name in self.regs.names(): for name in self.regs.names():
val = self.regs.get(name) val = self.regs.get(name)
print ' %20s: %08x (%d)' % (name, val, val) print(' %20s: %08x (%d)' % (name, val, val))
return True return True
return False return False
@ -222,8 +222,8 @@ class message_queue:
self.core_control = supercore.message_queue(self.object['message_queue']) self.core_control = supercore.message_queue(self.object['message_queue'])
def show(self, from_tty): def show(self, from_tty):
print ' Name:', self.object_control.name() print(' Name:', self.object_control.name())
print ' Attr:', self.attr.to_string() print(' Attr:', self.attr.to_string())
self.core_control.show() self.core_control.show()
@ -237,7 +237,7 @@ class timer:
self.watchdog = watchdog.control(self.object['Ticker']) self.watchdog = watchdog.control(self.object['Ticker'])
def show(self, from_tty): def show(self, from_tty):
print ' Name:', self.object_control.name() print(' Name:', self.object_control.name())
self.watchdog.show() self.watchdog.show()
class partition: class partition:
@ -255,11 +255,11 @@ class partition:
def show(self, from_tty): def show(self, from_tty):
# ToDo: the printing still somewhat crude. # ToDo: the printing still somewhat crude.
print ' Name:', self.object_control.name() print(' Name:', self.object_control.name())
print ' Attr:', self.attr.to_string() print(' Attr:', self.attr.to_string())
print ' Length:', self.length print(' Length:', self.length)
print ' B Size:', self.buffer_size print(' B Size:', self.buffer_size)
print ' U Blocks:', self.used_blocks print(' U Blocks:', self.used_blocks)
class region: class region:
"prints a classic region" "prints a classic region"
@ -273,10 +273,10 @@ class region:
self.heap = heaps.control(self.object['Memory']) self.heap = heaps.control(self.object['Memory'])
def show(self, from_tty): def show(self, from_tty):
print ' Name:', self.object_control.name() print(' Name:', self.object_control.name())
print ' Attr:', self.attr.to_string() print(' Attr:', self.attr.to_string())
helper.tasks_printer_routine(self.wait_queue) helper.tasks_printer_routine(self.wait_queue)
print ' Memory:' print(' Memory:')
self.heap.show() self.heap.show()
class barrier: class barrier:
@ -290,12 +290,12 @@ class barrier:
self.core_b_control = supercore.barrier_control(self.object['Barrier']) self.core_b_control = supercore.barrier_control(self.object['Barrier'])
def show(self,from_tty): def show(self,from_tty):
print ' Name:',self.object_control.name() print(' Name:',self.object_control.name())
print ' Attr:',self.attr.to_string() print(' Attr:',self.attr.to_string())
if self.attr.test('barrier','barrier-auto-release'): if self.attr.test('barrier','barrier-auto-release'):
max_count = self.core_b_control.max_count() max_count = self.core_b_control.max_count()
print 'Aut Count:', max_count print('Aut Count:', max_count)
print ' Waiting:',self.core_b_control.waiting_threads() print(' Waiting:',self.core_b_control.waiting_threads())
helper.tasks_printer_routine(self.core_b_control.tasks()) helper.tasks_printer_routine(self.core_b_control.tasks())

View File

@ -73,9 +73,9 @@ class stats:
return self.stat['free_size'] return self.stat['free_size']
def show(self): def show(self):
print ' Instance:',self.inst() print(' Instance:',self.inst())
print ' Avail:',self.avail() print(' Avail:',self.avail())
print ' Free:',self.free() print(' Free:',self.free())
# ToDo : incorporate others # ToDo : incorporate others
@ -105,9 +105,9 @@ class control:
fi = self.first() fi = self.first()
la = self.last() la = self.last()
print ' First:', fi.val() print(' First:', fi.val())
print ' Last:', la.val() print(' Last:', la.val())
stats = self.stat() stats = self.stat()
print ' stats:' print(' stats:')
stats.show() stats.show()

View File

@ -34,9 +34,9 @@ import gdb
def tasks_printer_routine(wait_queue): def tasks_printer_routine(wait_queue):
tasks = wait_queue.tasks() tasks = wait_queue.tasks()
print ' Queue: len = %d, state = %s' % (len(tasks),wait_queue.state()) print(' Queue: len = %d, state = %s' % (len(tasks),wait_queue.state()))
for t in range(0, len(tasks)): for t in range(0, len(tasks)):
print ' ', tasks[t].brief(), ' (%08x)' % (tasks[t].id()) print(' ', tasks[t].brief(), ' (%08x)' % (tasks[t].id()))
def type_from_value(val): def type_from_value(val):
type = val.type; type = val.type;

View File

@ -78,15 +78,15 @@ class rtems_object(gdb.Command):
val = gdb.parse_and_eval(num) val = gdb.parse_and_eval(num)
num = int(val) num = int(val)
except: except:
print 'error: "%s" is not a number' % (num) print('error: "%s" is not a number' % (num))
return True return True
id = objects.ident(num) id = objects.ident(num)
if not id.valid(): if not id.valid():
print 'Invalid object id' print('Invalid object id')
return True return True
print 'API:%s Class:%s Node:%d Index:%d Id:%08X' % \ print('API:%s Class:%s Node:%d Index:%d Id:%08X' % \
(id.api(), id._class(), id.node(), id.index(), id.value()) (id.api(), id._class(), id.node(), id.index(), id.value()))
objectname = id.api() + '/' + id._class() objectname = id.api() + '/' + id._class()
obj = objects.information.object(id).dereference() obj = objects.information.object(id).dereference()
@ -124,32 +124,32 @@ class rtems_index(gdb.Command):
index = int(val, base = 0) index = int(val, base = 0)
if index < maximum: if index < maximum:
if index < minimum_id.index(): if index < minimum_id.index():
print "error: %s is not an index (min is %d)" % (val, print("error: %s is not an index (min is %d)" % (val,
minimum_id.index()) minimum_id.index()))
return return
else: else:
index = objects.ident(index).index() index = objects.ident(index).index()
except ValueError: except ValueError:
print "error: %s is not an index" % (val) print("error: %s is not an index" % (val))
return return
try: try:
obj = objects.information.object_return(self.api, obj = objects.information.object_return(self.api,
self._class, self._class,
index) index)
except IndexError: except IndexError:
print "error: index %s is invalid" % (index) print("error: index %s is invalid" % (index))
return return
instance = self.instance(obj) instance = self.instance(obj)
valid = instance.show(from_tty) valid = instance.show(from_tty)
objects.information.invalidate() objects.information.invalidate()
else: else:
print '-' * 70 print('-' * 70)
print ' %s: %d [%08x -> %08x]' % (objects.information.name(self.api, self._class), print(' %s: %d [%08x -> %08x]' % (objects.information.name(self.api, self._class),
maximum, minimum_id.value(), maximum_id.value()) maximum, minimum_id.value(), maximum_id.value()))
valid = True valid = True
for index in range(minimum_id.index(), minimum_id.index() + maximum): for index in range(minimum_id.index(), minimum_id.index() + maximum):
if valid: if valid:
print '-' * 70 print('-' * 70)
valid = self.invoke(str(index), from_tty) valid = self.invoke(str(index), from_tty)
return valid return valid
@ -249,7 +249,7 @@ class rtems_tod(gdb.Command):
def invoke(self, arg, from_tty): def invoke(self, arg, from_tty):
if arg: if arg:
print "warning: commad takes no arguments!" print("warning: commad takes no arguments!")
obj = objects.information.object_return(self.api, self._class) obj = objects.information.object_return(self.api, self._class)
instance = supercore.time_of_day(obj) instance = supercore.time_of_day(obj)
instance.show() instance.show()
@ -271,15 +271,15 @@ class rtems_watchdog_chain(gdb.Command):
inst = chains.control(obj) inst = chains.control(obj)
if inst.empty(): if inst.empty():
print ' error: empty chain' print(' error: empty chain')
return return
nd = inst.first() nd = inst.first()
i = 0 i = 0
while not nd.null(): while not nd.null():
wd = watchdog.control(nd.cast('Watchdog_Control')) wd = watchdog.control(nd.cast('Watchdog_Control'))
print ' #'+str(i) print(' #'+str(i))
print wd.to_string() print(wd.to_string())
nd.next() nd.next()
i += 1 i += 1

View File

@ -114,29 +114,29 @@ class register:
return self.psr(self.reg['psr']) return self.psr(self.reg['psr'])
def show(self): def show(self):
print ' Global Regs:', print(' Global Regs:',)
print ' [', print(' [',)
for i in self.global_regs(): for i in self.global_regs():
print str(i)+',', print(str(i)+',',)
print '\b\b ]' print('\b\b ]')
print ' Local Regs:', print(' Local Regs:',)
print ' [', print(' [',)
for i in self.local_regs(): for i in self.local_regs():
print str(i)+',', print(str(i)+',',)
print '\b\b ]' print('\b\b ]')
print ' In Regs:', print(' In Regs:',)
print ' [', print(' [',)
for i in self.in_regs(): for i in self.in_regs():
print str(i)+',', print(str(i)+',',)
print '\b\b ]' print('\b\b ]')
print ' Out Regs:', print(' Out Regs:',)
print ' [', print(' [',)
for i in self.out_regs(): for i in self.out_regs():
print str(i)+',', print(str(i)+',',)
print '\b\b ]' print('\b\b ]')
sr = self.status() sr = self.status()
print sr.to_string() print(sr.to_string())

View File

@ -50,13 +50,13 @@ class time_of_day:
return bool(self.tod['is_set']) return bool(self.tod['is_set'])
def show(self): def show(self):
print ' Time Of Day' print(' Time Of Day')
if not self.is_set(): if not self.is_set():
print ' Application has not set a TOD' print(' Application has not set a TOD')
print ' Now:', self.now() print(' Now:', self.now())
print ' Uptime:', self.timer() print(' Uptime:', self.timer())
class message_queue: class message_queue:

View File

@ -89,4 +89,4 @@ class control:
return val return val
def show(self): def show(self):
print self.to_string() print(self.to_string())