[28884] in Source-Commits
athinfo commit: Convert to python3
daemon@ATHENA.MIT.EDU (Benjamin Kaduk)
Sat Aug 22 22:28:22 2020
Date: Sat, 22 Aug 2020 22:28:07 -0400
From: Benjamin Kaduk <kaduk@mit.edu>
Message-ID: <202008230228.07N2S7C6017006@drugstore.mit.edu>
To: <source-commits@mit.edu>
MIME-Version: 1.0
Content-Type: text/plain
https://github.com/mit-athena/athinfo/commit/4d2b8cc11b20ec446f7333f6633572b76582cd7e
commit 4d2b8cc11b20ec446f7333f6633572b76582cd7e
Author: Miriam Rittenberg <mrittenb@mit.edu>
Date: Wed Aug 12 10:15:38 2020 -0400
Convert to python3
athinfo | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/athinfo b/athinfo
index 68117e7..728b4bd 100755
--- a/athinfo
+++ b/athinfo
@@ -1,5 +1,6 @@
#!/usr/bin/python
+from __future__ import print_function
import optparse
import os
import signal
@@ -9,7 +10,7 @@ import sys
ATHINFO_FALLBACK_PORT = 49155
def alarm(signum, frame):
- print >>sys.stderr, 'athinfo: timed out'
+ print('athinfo: timed out', file=sys.stderr)
sys.exit(1)
def main():
@@ -39,7 +40,7 @@ def main():
try:
host_addr = socket.gethostbyname(host)
except socket.error:
- print >>sys.stderr, 'athinfo: host %s not found' % host
+ print('athinfo: host %s not found' % host, file=sys.stderr)
return 1
try:
@@ -50,13 +51,13 @@ def main():
signal.alarm(options.timeout)
s.connect((host_addr, port))
- s.sendall('%s\n' % query)
+ s.sendall(('%s\n' % query).encode())
sys.stdout.writelines(s.makefile())
- except socket.error, e:
- print >>sys.stderr, 'athinfo: %s' % e.args[-1]
+ except socket.error as e:
+ print('athinfo: %s' % e.args[-1], file=sys.stderr)
return 1
- except IOError, e:
- print >>sys.stderr, 'athinfo: %s' % e.args[-1]
+ except IOError as e:
+ print('athinfo: %s' % e.args[-1], file=sys.stderr)
return 1
except KeyboardInterrupt:
return 1