Browse Source

Improve !threads command output.

tags/v0.2
Ben Kurtovic 9 years ago
parent
commit
6a90efc812
1 changed files with 14 additions and 6 deletions
  1. +14
    -6
      earwigbot/commands/threads.py

+ 14
- 6
earwigbot/commands/threads.py View File

@@ -69,20 +69,28 @@ class Threads(Command):

for thread in threads:
tname = thread.name
ident = thread.ident % 10000
if tname == "MainThread":
t = "\x0302MainThread\x0F (id {0})"
normal_threads.append(t.format(thread.ident % 10000))
normal_threads.append(t.format(ident))
elif tname in self.config.components:
t = "\x0302{0}\x0F (id {1})"
normal_threads.append(t.format(tname, thread.ident % 10000))
normal_threads.append(t.format(tname, ident))
elif tname.startswith("remind-"):
t = "\x0302reminder\x0F (id {0})"
daemon_threads.append(t.format(tname[len("remind-"):]))
elif tname.startswith("cvworker-"):
t = "\x0302copyvio worker\x0F (site {0})"
daemon_threads.append(t.format(tname[len("cvworker-"):]))
else:
tname, start_time = re.findall("^(.*?) \((.*?)\)$", tname)[0]
t = "\x0302{0}\x0F (id {1}, since {2})"
daemon_threads.append(t.format(tname, thread.ident % 10000,
start_time))
match = re.findall("^(.*?) \((.*?)\)$", tname)
if match:
t = "\x0302{0}\x0F (id {1}, since {2})"
thread_info = t.format(match[0][0], ident, match[0][1])
daemon_threads.append(thread_info)
else:
t = "\x0302{0}\x0F (id {1})"
daemon_threads.append(t.format(tname, ident))

if daemon_threads:
if len(daemon_threads) > 1:


Loading…
Cancel
Save