Skip to content

Commit 32fed58

Browse files
python3
1 parent e4a6814 commit 32fed58

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

get_message

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#!/usr/bin/python
22

3+
from __future__ import print_function
34
import hesiod
45
import os
56
import select
67
import socket
78
import sys
9+
import six
810
from optparse import OptionParser
911

1012
MESSAGE_VERS = 'GMS:0'
@@ -25,7 +27,7 @@ def parse(msg):
2527
"""Parse a gms message, returning a version, timestamp, text tuple
2628
if successful, and an Exception otherwise."""
2729
try:
28-
header, text = msg.split('\n', 1)
30+
header, text = six.ensure_str(msg).split('\n', 1)
2931
version, timestamp = header.split(' ', 1)
3032
if version != MESSAGE_VERS:
3133
raise Exception('Incompatible version of GMS [%s] found' % (version,))
@@ -59,7 +61,7 @@ def write_message_times(timestamp):
5961
def fetch_message():
6062
"""Connect to the globalmessage server, and read a message."""
6163
server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
62-
server.sendto('%s 0\n' % (MESSAGE_VERS,), (get_server(), GMS_PORT))
64+
server.sendto(six.ensure_binary('%s 0\n' % (MESSAGE_VERS,)), (get_server(), GMS_PORT))
6365
message = None
6466
readable, _, _ = select.select([server], [], [], MESSAGE_TIMEOUT)
6567
for i in readable:
@@ -100,15 +102,15 @@ def main():
100102
options, args = parser.parse_args(
101103
[old_args.get(x, x) for x in sys.argv[1:]])
102104
if options.zephyr:
103-
print >>sys.stderr, "get_message: The -z/-zephyr option is deprecated."
105+
print("get_message: The -z/-zephyr option is deprecated.", file=sys.stderr)
104106
version, timestamp, content = get_message()
105107
if options.new and has_seen(timestamp):
106108
# This is an already-seen message, and new-only was requested.
107109
sys.exit(0)
108110
if not options.login:
109111
# Update the timestamp so we know this message has been seen
110112
write_message_times(timestamp)
111-
print content
113+
print(content)
112114

113115
if __name__ == "__main__":
114116
main()

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from distutils.core import setup
44

55
setup(name='get_message',
6-
version='10.1.1',
6+
version='10.2',
77
description='Athena utility for getting the global message of the day',
88
author='Alexander Chernyakhovsky',
99
scripts=['get_message']

0 commit comments

Comments
 (0)