From 5be9dea1d539451a406c16782856e4ae08526497 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Fri, 22 Jul 2011 13:45:48 -0400 Subject: [PATCH] docstrings in Tasks command; make !task work with !tasks and !threads; make the afc_statistics task skeleton print kwargs in run() for testing --- irc/commands/tasks.py | 12 ++++++++++-- wiki/tasks/afc_statistics.py | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/irc/commands/tasks.py b/irc/commands/tasks.py index 11e492e..9f33061 100644 --- a/irc/commands/tasks.py +++ b/irc/commands/tasks.py @@ -17,7 +17,7 @@ class Tasks(BaseCommand): return "Manage wiki tasks from IRC, and check on thread status." def check(self, data): - if data.is_command and data.command in ["tasks", "threads", "tasklist"]: + if data.is_command and data.command in ["tasks", "task", "threads", "tasklist"]: return True return False @@ -47,6 +47,9 @@ class Tasks(BaseCommand): self.connection.reply(data, "unknown argument: \x0303{0}\x0301.".format(data.args[0])) def do_list(self): + """With !tasks list (or abbreviation !tasklist), list all running + threads. This includes the main threads, like the irc frontend and the + watcher, and task threads.""" threads = threading.enumerate() normal_threads = [] @@ -72,6 +75,8 @@ class Tasks(BaseCommand): self.connection.reply(self.data, msg) def do_listall(self): + """With !tasks listall or !tasks all, list all loaded tasks, and report + whether they are currently running or idle.""" tasks = task_manager.task_list.keys() threads = threading.enumerate() tasklist = [] @@ -94,6 +99,8 @@ class Tasks(BaseCommand): self.connection.reply(self.data, msg) def do_start(self): + """With !tasks start, start any loaded task by name with or without + kwargs.""" data = self.data try: @@ -116,7 +123,8 @@ class Tasks(BaseCommand): self.connection.reply(data, "task \x0302{0}\x0301 started.".format(task_name)) def get_main_thread_name(self): - """Return the "proper" name of the MainThread; e.g. "irc-frontend" or "irc-watcher".""" + """Return the "proper" name of the MainThread; e.g. "irc-frontend" or + "irc-watcher".""" if "irc_frontend" in config.components: return "irc-frontend" elif "wiki_schedule" in config.components: diff --git a/wiki/tasks/afc_statistics.py b/wiki/tasks/afc_statistics.py index 967c296..830afc0 100644 --- a/wiki/tasks/afc_statistics.py +++ b/wiki/tasks/afc_statistics.py @@ -11,4 +11,4 @@ class Task(BaseTask): pass def run(self, **kwargs): - pass + print kwargs