Module: deluge
Branch: master
Commit: 40a572298770c8d62d1fe20791988de4949e2464

Author: Nick Lanham <[email protected]>
Date:   Tue Feb 22 16:57:56 2011 +0100

support -s STATE in info

---

 deluge/ui/console/commands/info.py |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/deluge/ui/console/commands/info.py 
b/deluge/ui/console/commands/info.py
index cf5ae48..7e6ed99 100644
--- a/deluge/ui/console/commands/info.py
+++ b/deluge/ui/console/commands/info.py
@@ -70,6 +70,8 @@ status_keys = ["state",
         "is_finished"
         ]
 
+states = ["Active", "Downloading", "Seeding", "Paused", "Checking", "Error", 
"Queued"]
+
 
 def format_progressbar(progress, width):
     """
@@ -98,11 +100,17 @@ class Command(BaseCommand):
                         help='shows more information per torrent'),
             make_option('-i', '--id', action='store_true', default=False, 
dest='tid',
                         help='use internal id instead of torrent name'),
+            make_option('-s', '--state', action='store', dest='state',
+                        help="Only retrieve torrents in state STATE. "
+                        "Allowable values are: %s "%(", ".join(states))),
     )
 
-    usage =  "Usage: info [<torrent-id> [<torrent-id> ...]]\n"\
+    usage =  "Usage: info [-v | -i | -s <state>] [<torrent-id> [<torrent-id> 
...]]\n"\
+             "       info -s <state> will show only torrents in state 
<state>\n"\
              "       You can give the first few characters of a torrent-id to 
identify the torrent."
 
+
+
     def handle(self, *args, **options):
         self.console = component.get("ConsoleUI")
         # Compile a list of torrent_ids to request the status of
@@ -121,7 +129,17 @@ class Command(BaseCommand):
         def on_torrents_status_fail(reason):
             self.console.write("{!error!}Error getting torrent info: %s" % 
reason)
 
-        d = client.core.get_torrents_status({"id": torrent_ids}, status_keys)
+        status_dict = {"id": torrent_ids}
+
+        if options["state"]:
+            if options["state"] not in states:
+                self.console.write("Invalid state: %s"%options["state"])
+                self.console.write("Allowble values are: %s."%(", 
".join(states)))
+                return
+            else:
+                status_dict["state"] = options["state"]
+
+        d = client.core.get_torrents_status(status_dict, status_keys)
         d.addCallback(on_torrents_status)
         d.addErrback(on_torrents_status_fail)
         return d

-- 
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en.

Reply via email to