|
19 | 19 | from optparse import OptionParser |
20 | 20 |
|
21 | 21 | import curses |
22 | | -import threading, Queue |
| 22 | +import threading |
| 23 | +try: |
| 24 | + import Queue |
| 25 | +except ImportError: # py3 |
| 26 | + import queue as Queue |
23 | 27 | import socket |
24 | 28 | import signal |
25 | | -import re, StringIO |
| 29 | +import re |
| 30 | +try: |
| 31 | + import StringIo |
| 32 | +except ImportError: # py3 |
| 33 | + from io import StringIO |
26 | 34 | import logging as LOG |
27 | 35 |
|
28 | 36 | ZK_DEFAULT_PORT = 2181 |
@@ -169,7 +177,7 @@ def __init__(self, win): |
169 | 177 | global mainwin |
170 | 178 | self.maxy, self.maxx = mainwin.getmaxyx() |
171 | 179 | self.resize(self.maxy, self.maxx) |
172 | | - |
| 180 | + |
173 | 181 | def resize(self, maxy, maxx): |
174 | 182 | LOG.debug("resize called y %d x %d" % (maxy, maxx)) |
175 | 183 | self.maxy = maxy |
@@ -241,7 +249,7 @@ def update(self, s): |
241 | 249 | items = [] |
242 | 250 | for l in self.sessions: |
243 | 251 | items.extend(l) |
244 | | - items.sort(lambda x,y: int(y.queued)-int(x.queued)) |
| 252 | + items.sort(key=lambda x: int(x.queued), reverse=True) |
245 | 253 | for i, session in enumerate(items): |
246 | 254 | try: |
247 | 255 | #ugh, need to handle if slow - thread for async resolver? |
@@ -278,7 +286,7 @@ def show_ui(self, stdscr): |
278 | 286 | # start the polling threads |
279 | 287 | pollers = [StatPoller(server) for server in self.servers] |
280 | 288 | for poller in pollers: |
281 | | - poller.setName("PollerThread:" + server) |
| 289 | + poller.setName("PollerThread:" + poller.server) |
282 | 290 | poller.setDaemon(True) |
283 | 291 | poller.start() |
284 | 292 |
|
@@ -355,7 +363,7 @@ def read_zk_config(filename): |
355 | 363 | k,v = tuple(line.replace(' ', '').strip().split('=', 1)) |
356 | 364 | config[k] = v |
357 | 365 | except IOError as e: |
358 | | - print "Unable to open `{0}': I/O error({1}): {2}".format(filename, e.errno, e.strerror) |
| 366 | + print("Unable to open `{0}': I/O error({1}): {2}".format(filename, e.errno, e.strerror)) |
359 | 367 | finally: |
360 | 368 | f.close() |
361 | 369 | return config |
|
0 commit comments