aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2016-07-03 12:58:50 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2016-07-03 12:58:50 -0400
commit4b7c318aad84b5274f11e7f82da84241314baed3 (patch)
treea3f3e5704d13e28b640649f960db1efaf7e09bd5
parent5651d5c9725fd2ef2f292a9500c177318cbf20ca (diff)
downloadsteuermann-4b7c318aad84b5274f11e7f82da84241314baed3.tar.gz
Python 3k compat
-rw-r--r--steuermann/dot.py2
-rw-r--r--steuermann/nodes.py16
-rw-r--r--steuermann/report.py2
-rw-r--r--steuermann/rexec.py18
-rw-r--r--steuermann/rexecd.py20
-rw-r--r--steuermann/run.py48
-rw-r--r--steuermann/run_all.py102
-rw-r--r--steuermann/run_cron.py4
-rw-r--r--steuermann/specfile.py22
9 files changed, 117 insertions, 117 deletions
diff --git a/steuermann/dot.py b/steuermann/dot.py
index e4d7a1f..eb9f3b4 100644
--- a/steuermann/dot.py
+++ b/steuermann/dot.py
@@ -11,7 +11,7 @@ Requires graphviz and pygraphviz
if len(sys.argv) < 2:
- print 'ERROR - missing argument(s)'
+ print('ERROR - missing argument(s)')
sys.exit(1)
sm_files = sys.argv[1:]
diff --git a/steuermann/nodes.py b/steuermann/nodes.py
index d02cbf6..2d93a72 100644
--- a/steuermann/nodes.py
+++ b/steuermann/nodes.py
@@ -64,11 +64,11 @@ class command_tree(object):
if not before in self.node_index :
if required :
- print "error: %s happens after non-existant %s - line %s"%(after,before,line)
+ print("error: %s happens after non-existant %s - line %s"%(after,before,line))
return
if not after in self.node_index :
- print "error: after node %s does not exist %s"%(after,line)
+ print("error: after node %s does not exist %s"%(after,line))
return
# tell the after node that the other one comes first
@@ -95,7 +95,7 @@ class command_tree(object):
if command in self.node_index :
# bug: should be error
- print "# warning: %s already used on line %s"%(command,self.node_index[command].input_line)
+ print("# warning: %s already used on line %s"%(command,self.node_index[command].input_line))
# create the node
self.node_index[command]=node(command, script, script_type, nice_pos( current_file_name, pos), resources )
@@ -270,7 +270,7 @@ def nice_pos( filename, yapps_pos ) :
def c_d_fn(x,depth) :
if x.in_recursion :
- print "error: loop detected at",x.name
+ print("error: loop detected at",x.name)
return
# print '>'," "*depth, depth, x.name
@@ -282,7 +282,7 @@ def c_d_fn(x,depth) :
if depth > 100 :
# bug: proxy for somebody wrote a loop
- print "error: depth > 100, node = ",x.name
+ print("error: depth > 100, node = ",x.name)
return
x.in_recursion = 1
@@ -350,7 +350,7 @@ def read_file_list( file_list ) :
continue
imported[current_file_name] = 1
- print "READING ",current_file_name
+ print("READING ",current_file_name)
# read/parse
sc = specfile.specfileScanner( open(current_file_name,'r').read() )
p = specfile.specfile( scanner=sc, data=di )
@@ -397,7 +397,7 @@ def declare_conditions( text, filename ) :
for ln in text.split('\n'):
ln = ln.strip()
cond = saved_conditions.copy()
- exec ln in cond
+ exec(ln, cond)
for k, v in cond.items():
if k not in saved_conditions:
saved_conditions[k] = v
@@ -440,5 +440,5 @@ def get_hostgroup( name ) :
if __name__=='__main__':
import sys
n = read_file_list( sys.argv[1:] )
- print show_nodes(n.node_index)
+ print(show_nodes(n.node_index))
diff --git a/steuermann/report.py b/steuermann/report.py
index e68f634..ab4796b 100644
--- a/steuermann/report.py
+++ b/steuermann/report.py
@@ -219,7 +219,7 @@ def report_html( db, run_name, info_callback = info_callback_status, hlevel=1 )
def main() :
import steuermann.config
db = steuermann.config.open_db()
- print report_html( db, 'arf2011-08-30 16:52:23.928381' )
+ print(report_html( db, 'arf2011-08-30 16:52:23.928381' ))
if __name__ == '__main__' :
main()
diff --git a/steuermann/rexec.py b/steuermann/rexec.py
index 013dc94..81c55af 100644
--- a/steuermann/rexec.py
+++ b/steuermann/rexec.py
@@ -39,9 +39,9 @@ def run( host, cmd, password, directory ):
req = urllib2.Request(url, data)
try :
f = urllib2.urlopen(req)
- except urllib2.HTTPError, e:
- print "HTTP ERROR",e.code
- print e.read()
+ except urllib2.HTTPError as e:
+ print("HTTP ERROR",e.code)
+ print(e.read())
return 1
while 1 :
s = f.read(2048)
@@ -64,11 +64,11 @@ def upload( host, filename, password, directory) :
req = urllib2.Request(url, data)
try :
f = urllib2.urlopen(req)
- except urllib2.HTTPError, e:
- print "HTTP ERROR",e.code
- print e.read()
+ except urllib2.HTTPError as e:
+ print("HTTP ERROR",e.code)
+ print(e.read())
return 1
- print f.read()
+ print(f.read())
f.close()
return 0
@@ -86,7 +86,7 @@ if __name__ == '__main__' :
password = open(opt['-f'],'r').readline().strip()
if not ( '-h' in opt ) :
- print "must give host name with -h"
+ print("must give host name with -h")
sys.exit(2)
host = opt['-h']
if '-d' in opt :
@@ -97,7 +97,7 @@ if __name__ == '__main__' :
if opt['-u'] :
ex = 0
for x in args :
- print "UPLOAD", x
+ print("UPLOAD", x)
ex |= upload(host = host , filename=x, directory=directory, password=password)
sys.exit(ex)
else :
diff --git a/steuermann/rexecd.py b/steuermann/rexecd.py
index 712d48f..30e0b90 100644
--- a/steuermann/rexecd.py
+++ b/steuermann/rexecd.py
@@ -17,7 +17,7 @@ import urllib
import urlparse
os.chdir('/')
-print os.getcwd()
+print(os.getcwd())
#####
#
@@ -44,7 +44,7 @@ class my_handler( CGIHTTPServer.CGIHTTPRequestHandler ) :
CGIHTTPServer.CGIHTTPRequestHandler.__init__(self, request, client_address, server)
def reject_client(self) :
- print self.client_address
+ print(self.client_address)
if not ( self.client_address[0] in valid_client_ip ) :
self.bad_client('a')
return 1
@@ -66,7 +66,7 @@ class my_handler( CGIHTTPServer.CGIHTTPRequestHandler ) :
path = self.path
- print "GET",path
+ print("GET",path)
self.send_response(200)
self.send_header('Content-type', 'text/plain')
self.end_headers()
@@ -96,7 +96,7 @@ class my_handler( CGIHTTPServer.CGIHTTPRequestHandler ) :
if self.reject_client() :
return
- print self.path
+ print(self.path)
length = int(self.headers['Content-Length'])
@@ -104,14 +104,14 @@ class my_handler( CGIHTTPServer.CGIHTTPRequestHandler ) :
d = urlparse.parse_qs(data)
for x in sorted([ x for x in d]) :
- print x,d[x]
+ print(x,d[x])
if d['password'][0] != password :
self.bad_client('p')
return
dirname = d['dirname'][0]
- print "CD",dirname
+ print("CD",dirname)
os.chdir(dirname)
if self.path == 'upload' :
@@ -165,7 +165,7 @@ windows = platform.system() == 'Windows'
def run_child(path, wfile) :
env = os.environ
cmd = urllib.unquote_plus(path)
- print "COMMAND",cmd
+ print("COMMAND",cmd)
# bug: implement timeouts
if windows :
@@ -184,7 +184,7 @@ def run_child(path, wfile) :
# subprocess does not tell you if there was a core
# dump, but there is nothing we can do about it.
- print "COMMAND EXIT:",status,t_status
+ print("COMMAND EXIT:",status,t_status)
def subprocess_windows(cmd, wfile, env ) :
@@ -222,12 +222,12 @@ def run( args = [ ] ) :
port = 7070
- print "http://%s:%s/"%(str(ip),str(port))
+ print("http://%s:%s/"%(str(ip),str(port)))
httpd = MultiThreadedHTTPServer( (ip, port) , my_handler)
sa = httpd.socket.getsockname()
- print "Serving HTTP on", sa[0], "port", sa[1], "..."
+ print("Serving HTTP on", sa[0], "port", sa[1], "...")
while 1 :
httpd.handle_request()
diff --git a/steuermann/run.py b/steuermann/run.py
index 4846350..adbc40d 100644
--- a/steuermann/run.py
+++ b/steuermann/run.py
@@ -95,10 +95,10 @@ class runner(object):
try :
args = self.get_host_info(node.host)
- except Exception, e :
+ except Exception as e :
log_traceback()
- print "ERROR: do not know how to run on %s"%node.host
- print e
+ print("ERROR: do not know how to run on %s"%node.host)
+ print(e)
raise
if ( config_yes_no(args,'disable') ) :
@@ -134,9 +134,9 @@ class runner(object):
if debug :
- print "run",node.name
+ print("run",node.name)
if debug :
- print "....%s:%s/%s\n"%(node.host, node.table, node.cmd)
+ print("....%s:%s/%s\n"%(node.host, node.table, node.cmd))
node.running = 1
@@ -168,9 +168,9 @@ class runner(object):
args[k] = v
if debug :
- print "ARGS"
+ print("ARGS")
for x in sorted([x for x in args]) :
- print '%s=%s'%(x,args[x])
+ print('%s=%s'%(x,args[x]))
args['script'] = args['script'] % args
@@ -189,11 +189,11 @@ class runner(object):
run = t
if debug :
- print "RUN",run
+ print("RUN",run)
try :
os.makedirs( os.path.dirname(logfile_name) )
- except OSError, e :
+ except OSError as e :
if e.errno == errno.EEXIST :
pass
else :
@@ -211,7 +211,7 @@ class runner(object):
# start running the process
if debug :
- print "RUN",run
+ print("RUN",run)
p = subprocess.Popen(
args=run,
stdout=logfile,
@@ -230,7 +230,7 @@ class runner(object):
return 'R'
- except Exception, e :
+ except Exception as e :
log_traceback()
txt= "ERROR RUNNING %s"%node.name
raise run_exception(txt)
@@ -252,7 +252,7 @@ class runner(object):
if debug :
hostname = args['hostname']
- print "finish %s %s %d"%(hostname,node_name,n)
+ print("finish %s %s %d"%(hostname,node_name,n))
# note the termination of the process at the end of the log file
logfile = self.all_procs[node_name].logfile
@@ -262,7 +262,7 @@ class runner(object):
# note the completion of the command
if debug :
- print "finish",node.name
+ print("finish",node.name)
node.running = 0
node.finished = 1
node.exit_status = status
@@ -302,10 +302,10 @@ class runner(object):
def display_procs( self ) :
# display currently active child processes
- print "procs:"
+ print("procs:")
for x in sorted(self.all_procs) :
- print " ",x
- print ""
+ print(" ",x)
+ print("")
#####
@@ -328,7 +328,7 @@ class runner(object):
d[name] = value
return d
except ConfigParser.NoSectionError :
- print "No config section in hosts.ini: %s"%section
+ print("No config section in hosts.ini: %s"%section)
return { }
@@ -338,7 +338,7 @@ class runner(object):
pass
# print 'READING HOST INFO FROM %s' %filename
else:
- print 'ERROR - %s does not exist' %filename
+ print('ERROR - %s does not exist' %filename)
sys.exit(1)
# read the config file
@@ -376,20 +376,20 @@ def log_traceback() :
# strings. I want each line of output logged separately so the log
# file remains easy to process, so I reverse engineered this out of
# the logging module.
- print "LOG TRACEBACK:"
+ print("LOG TRACEBACK:")
try:
etype, value, tb = sys.exc_info()
tbex = traceback.extract_tb( tb )
- print tbex
+ print(tbex)
for filename, lineno, name, line in tbex :
- print '%s:%d, in %s'%(filename,lineno,name)
+ print('%s:%d, in %s'%(filename,lineno,name))
if line:
- print ' %s'%line.strip()
+ print(' %s'%line.strip())
for x in traceback.format_exception_only( etype, value ) :
- print ": %s",x
+ print(": %s",x)
- print "---"
+ print("---")
finally:
# If you don't clear these guys, you can make loops that
diff --git a/steuermann/run_all.py b/steuermann/run_all.py
index 20623d9..6ef8b82 100644
--- a/steuermann/run_all.py
+++ b/steuermann/run_all.py
@@ -120,7 +120,7 @@ def main() :
def get_common_resources(hosts_ini):
if not os.path.exists(hosts_ini):
- print 'ERROR - %s does not exist'
+ print('ERROR - %s does not exist')
sys.exit(1)
file = open(hosts_ini)
@@ -150,11 +150,11 @@ def get_common_resources(hosts_ini):
#
def find_wild_names( xnodes, name ) :
- print "find_wild",name
+ print("find_wild",name)
l = [ ]
for x in xnodes :
if nodes.wildcard_name( name, x ) :
- print "...",x
+ print("...",x)
l.append(x)
return l
#
@@ -168,22 +168,22 @@ def do_flag( xnodes, name, recursive, fn, verbose ) :
name = '*:' + name
if ( '*' in name ) or ( '?' in name ) or ( '[' in name ) :
if verbose :
- print ' '*verbose, "wild",name
+ print(' '*verbose, "wild",name)
for x in xnodes :
if nodes.wildcard_name( name, x ) :
if verbose :
- print ' '*verbose, "match",x
+ print(' '*verbose, "match",x)
do_flag( xnodes, x, recursive, fn, verbose )
elif name in xnodes :
if verbose :
- print ' '*verbose, "found",name
+ print(' '*verbose, "found",name)
fn(xnodes[name])
if recursive :
for y in xnodes[name].predecessors :
do_flag( xnodes, y.name, recursive, fn, verbose )
else :
if verbose :
- print ' '*verbose, "not in list", name
+ print(' '*verbose, "not in list", name)
def set_want( node ) :
# if we said we want it, mark it as wanted and don't skip
@@ -215,13 +215,13 @@ def cmd_flagging( l, xnodes, func ) :
#
def print_node(xnodes, x, print_recursive, print_all, indent=0, print_cmd=1):
- print ' '*indent, xnodes[x].wanted, xnodes[x].finished, xnodes[x].skip, xnodes[x].depth, x
+ print(' '*indent, xnodes[x].wanted, xnodes[x].finished, xnodes[x].skip, xnodes[x].depth, x)
if print_cmd :
- print ' '*indent, " CMD", xnodes[x].script_type, xnodes[x].script
+ print(' '*indent, " CMD", xnodes[x].script_type, xnodes[x].script)
if print_all :
l = [ a.name for a in xnodes[x].predecessors ]
- print ' '*indent, " AFTER", ' '.join(l)
- print ' '*indent, " RESOURCES", ' '.join([ "%s=%s"%(aa, xnodes[x].resources[aa]) for aa in sorted(xnodes[x].resources) ])
+ print(' '*indent, " AFTER", ' '.join(l))
+ print(' '*indent, " RESOURCES", ' '.join([ "%s=%s"%(aa, xnodes[x].resources[aa]) for aa in sorted(xnodes[x].resources) ]))
if print_recursive :
for x in l :
print_node( xnodes, x, print_recursive, print_all, indent=indent+8)
@@ -265,7 +265,7 @@ def run_interactive( xnodes, run_name, hosts_ini, db) :
xnodes[x].wanted = 0
xnodes[x].skip = 1
- print "Defaulting all to SKIP"
+ print("Defaulting all to SKIP")
keep_running = 0
@@ -283,26 +283,26 @@ def run_interactive( xnodes, run_name, hosts_ini, db) :
n = ''
if n == '?' :
- print helpstr
+ print(helpstr)
elif n == 'd' :
run.debug=0
if len(l) > 1 :
for x in l[1:] :
- print "XXXXXXXXXX"
- print "SECTION",x
- print runner.get_host_info(x)
- print ""
+ print("XXXXXXXXXX")
+ print("SECTION",x)
+ print(runner.get_host_info(x))
+ print("")
else :
for x in runner.cfg.sections() :
- print "XXXXXXXXXX"
- print "SECTION",x
- print runner.get_host_info(x)
- print ""
+ print("XXXXXXXXXX")
+ print("SECTION",x)
+ print(runner.get_host_info(x))
+ print("")
run.debug=0
elif n == 'report' :
- print report.report_text( db, run_name )
+ print(report.report_text( db, run_name ))
elif n == 'hostgroups' or n == 'hostgroup' or n == 'hg' :
print_hostgroups()
@@ -311,10 +311,10 @@ def run_interactive( xnodes, run_name, hosts_ini, db) :
print_conditions()
elif n == 'wr' :
- print report.report_text( db, run_name, info_callback_want )
+ print(report.report_text( db, run_name, info_callback_want ))
elif n == 'dr' :
- print report.report_text( db, run_name, info_callback_depth )
+ print(report.report_text( db, run_name, info_callback_depth ))
elif n == 'pre' :
pre_cmd( l[1:], xnodes )
@@ -326,13 +326,13 @@ def run_interactive( xnodes, run_name, hosts_ini, db) :
cmd_flagging( l, xnodes, set_skip )
elif n == 'reset' :
- print "marking all as not finished"
+ print("marking all as not finished")
for x in xnodes :
xnodes[x].finished = 0
run_name = org_run_name + '.%d'%run_count
run_count = run_count + 1
- print "new run name",run_name
+ print("new run name",run_name)
register_database(db, run_name, xnodes)
elif n == 'list' :
@@ -356,14 +356,14 @@ def run_interactive( xnodes, run_name, hosts_ini, db) :
if not no_sleep :
time.sleep(1)
if keypress() :
- print "wait interrupted (processes continue)"
+ print("wait interrupted (processes continue)")
break
else :
- print "unrecognized"
+ print("unrecognized")
if keep_running :
- print "run step"
+ print("run step")
( runner, keep_running, no_sleep ) = run_step( runner, xnodes, run_name, db )
if len(runner.all_procs) == 0 :
@@ -371,11 +371,11 @@ def run_interactive( xnodes, run_name, hosts_ini, db) :
( runner, keep_running, no_sleep ) = run_step( runner, xnodes, run_name, db )
if not keep_running :
- print 'all done'
+ print('all done')
else :
if len(runner.all_procs) == 0 :
- print "no processes running - some prereq not satisfiable"
+ print("no processes running - some prereq not satisfiable")
#
@@ -403,8 +403,8 @@ def match_all_nodes( l, xnodes ) :
def pre_cmd( l, xnodes ) :
for x in match_all_nodes( l, xnodes ) :
- print "-----"
- print x
+ print("-----")
+ print(x)
print_pre(x, xnodes, 1)
@@ -412,7 +412,7 @@ def print_pre(who, xnodes, depth) :
pre = xnodes[who].predecessors
for x in pre :
x = x.name
- print ' '*depth+ x
+ print(' '*depth+ x)
print_pre( x, xnodes, depth+1)
#
@@ -458,7 +458,7 @@ def run_all(xnodes, run_name, hosts_ini, db) :
if len(runner.all_procs) == 0 :
none_running += 1
if none_running > 5 :
- print "No processes running - some prereq missing"
+ print("No processes running - some prereq missing")
break
else :
none_running = 0
@@ -552,7 +552,7 @@ def run_step( runner, xnodes, run_name, db ) :
tmp = runner.run(x, run_name, no_run=no_run, logfile_name = make_log_file_name(run_name, host, table, cmd) )
# print "STARTED",x_name
- except run.run_exception, e :
+ except run.run_exception as e :
now = str(datetime.datetime.now())
db.execute("UPDATE sm_status SET start_time=?, end_time=?, status='E', notes=? WHERE ( run=? AND host=? AND tablename=? AND cmd=? )",
( now, now, repr(e), run_name, host, table, cmd ) )
@@ -574,7 +574,7 @@ def run_step( runner, xnodes, run_name, db ) :
# hit resource cap - not run, but try again later
pass
else :
- print "WARNING: runner.run() returned unknown code %s"%str(tmp)
+ print("WARNING: runner.run() returned unknown code %s"%str(tmp))
db.commit()
@@ -587,7 +587,7 @@ def run_step( runner, xnodes, run_name, db ) :
break
# something exited; no sleep, keep running
- print "SOMETHING EXITED", who_exited
+ print("SOMETHING EXITED", who_exited)
no_sleep = 1
keep_running = 1
@@ -618,19 +618,19 @@ def run_step( runner, xnodes, run_name, db ) :
try:
os.system('mkdir -p %s' %os.path.dirname(dst))
except:
- print 'mkdir -p %s failed' %os.path.dirname(dst)
+ print('mkdir -p %s failed' %os.path.dirname(dst))
try:
os.system('scp -r %s:%s %s 2> /dev/null' %(hostname, src, dst))
except:
- print 'scp failed'
+ print('scp failed')
logs_exist = 0
if not os.path.exists(dst):
- print 'WARNING - %s does not exist' %dst
+ print('WARNING - %s does not exist' %dst)
else:
if len(os.listdir(dst)) > 0:
logs_exist = 1
- print 'FOUND SOME LOGS'
+ print('FOUND SOME LOGS')
# update node record in database
@@ -682,19 +682,19 @@ if __name__ == '__main__' :
#####
def print_hostgroups() :
- print ""
+ print("")
l = sorted( [ x for x in nodes.hostgroups ] )
for x in l :
- print "%s:"%x
+ print("%s:"%x)
l1 = sorted( [ y for y in nodes.hostgroups[x] ] )
for y in l1 :
- print " %s"%y
- print ""
+ print(" %s"%y)
+ print("")
#####
def print_conditions() :
boring = { }
- exec 'pass' in boring
+ exec('pass', boring)
l = sorted( [ x for x in nodes.saved_conditions ] )
row = 0
@@ -711,7 +711,7 @@ def print_conditions() :
tt.set_value(row,1,str(v))
row = row + 1
- print tt.get_rst()
+ print(tt.get_rst())
#####
def list_cmd(l) :
@@ -724,7 +724,7 @@ def list_cmd(l) :
if len(l) > 0 and l[0] == '-c' :
l = l[1:]
print_cmd = 1
- print "YOW"
+ print("YOW")
else :
print_cmd = 0
@@ -742,8 +742,8 @@ def list_cmd(l) :
all = all + find_wild_names( xnodes, x )
all = sorted(all)
- print "recursive",print_recursive
- print "w f s name"
+ print("recursive",print_recursive)
+ print("w f s name")
for x in all :
print_node(xnodes, x, print_recursive, all, print_cmd=print_cmd)
diff --git a/steuermann/run_cron.py b/steuermann/run_cron.py
index edb0451..0b137a8 100644
--- a/steuermann/run_cron.py
+++ b/steuermann/run_cron.py
@@ -16,8 +16,8 @@ class fakenode(object):
def main() :
if len(sys.argv) < 4 :
- print "smcron host name command"
- print "(from ",sys.argv,")"
+ print("smcron host name command")
+ print("(from ",sys.argv,")")
sys.exit(1)
host = sys.argv[1]
diff --git a/steuermann/specfile.py b/steuermann/specfile.py
index 6cda1c0..dcd8305 100644
--- a/steuermann/specfile.py
+++ b/steuermann/specfile.py
@@ -195,7 +195,7 @@ class Scanner(object):
file,line,p = pos
if file != self.filename:
if self.stack: return self.stack.print_line_with_pointer(pos,length=length,out=out)
- print >>out, "(%s: not in input buffer)" % file
+ print("(%s: not in input buffer)" % file, file=out)
return
text = self.input
@@ -218,7 +218,7 @@ class Scanner(object):
break
spos = cr+1
else:
- print >>out, "(%s:%d not in input buffer)" % (file,origline)
+ print("(%s:%d not in input buffer)" % (file,origline), file=out)
return
# Now try printing part of the line
@@ -247,8 +247,8 @@ class Scanner(object):
p = p - 7
# Now print the string, along with an indicator
- print >>out, '> ',text
- print >>out, '> ',' '*p + '^'
+ print('> ',text, file=out)
+ print('> ',' '*p + '^', file=out)
def grab_input(self):
"""Get more input if possible."""
@@ -436,14 +436,14 @@ def print_error(err, scanner, max_ctx=None):
pos = scanner.get_pos()
file_name, line_number, column_number = pos
- print >>sys.stderr, '%s:%d:%d: %s' % (file_name, line_number, column_number, err.msg)
+ print('%s:%d:%d: %s' % (file_name, line_number, column_number, err.msg), file=sys.stderr)
scanner.print_line_with_pointer(pos)
context = err.context
token = None
while context:
- print >>sys.stderr, 'while parsing %s%s:' % (context.rule, tuple(context.args))
+ print('while parsing %s%s:' % (context.rule, tuple(context.args)), file=sys.stderr)
if context.token:
token = context.token
if token:
@@ -457,11 +457,11 @@ def print_error(err, scanner, max_ctx=None):
def wrap_error_reporter(parser, rule, *args,**kw):
try:
return getattr(parser, rule)(*args,**kw)
- except SyntaxError, e:
+ except SyntaxError as e:
print_error(e, parser._scanner)
except NoMoreTokens:
- print >>sys.stderr, 'Could not complete parsing; stopped around here:'
- print >>sys.stderr, parser._scanner
+ print('Could not complete parsing; stopped around here:', file=sys.stderr)
+ print(parser._scanner, file=sys.stderr)
###### end of runtime.py
class specfileScanner(Scanner):
@@ -521,7 +521,7 @@ class specfile(Parser):
if _token == 'DEBUG':
DEBUG = self._scan('DEBUG', context=_context)
string = self._scan('string', context=_context)
- print "-->debug: %s"%string
+ print("-->debug: %s"%string)
elif _token == 'HOSTGROUP':
hostgroup_def = self.hostgroup_def(_context)
elif _token == 'CONDITIONS':
@@ -652,7 +652,7 @@ class specfile(Parser):
RES_AVAILABLE = self._scan('RES_AVAILABLE', context=_context)
ans = 'available'
rl[name] = ans
- print rl ; return rl
+ print(rl) ; return rl
def optword(self, _parent=None):
_context = self.Context(_parent, self._scanner, 'optword', [])