base: First pass at making nag-once working with python3

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
This commit is contained in:
Pierre-Yves Chibon 2019-11-19 22:19:24 +01:00
parent 705bccaa3b
commit 5a25802f9a

View file

@ -7,6 +7,7 @@
# copyright (c) 2011 Red Hat, inc
# gpl v2 blah blah
# skvidal - skvidal@fedoraproject.org
from __future__ import print_function
import tempfile
import sys
@ -86,23 +87,23 @@ def main():
if theinput != old_output or (tti and now - old_date > tti):
if theinput.strip(): # if there is nothing here, don't output and don't drop a \n on the end of it
print theinput,
print(theinput,)
fo = open(mydir + '/output', 'w')
fo.write(theinput)
fo.flush()
fo.close()
except Exception, e:
print >> sys.stderr, e
print >> sys.stderr, theinput
except Exception as e:
print(e, file=sys.stderr)
print(theinput, file=sys.stderr)
if __name__ == '__main__':
try:
main()
except Exception, e:
print >> sys.stderr, e
except Exception as e:
print(e, file=sys.stderr)
if not sys.stdin.isatty():
print >> sys.stderr, sys.stdin.read()
print(sys.stdin.read(), file=sys.stderr)