diff --git a/deluge/ui/console/commands/info.py b/deluge/ui/console/commands/info.py
index 8a7f6daf0bde8cc91e59f91d07fdd1901de733c6..ae3b39fe8859596b143620da63bb3d359acf30b7 100644
|
a
|
b
|
class Command(BaseCommand):
|
| 97 | 97 | |
| 98 | 98 | option_list = BaseCommand.option_list + ( |
| 99 | 99 | make_option('-v', '--verbose', action='store_true', default=False, dest='verbose', |
| 100 | | help='shows more information per torrent'), |
| | 100 | help='Shows more information per torrent'), |
| | 101 | make_option('-I', '--intense-match', action='store_true', default=False, dest='intense_match', |
| | 102 | help='Consider torrents which have the pattern anywhere in the name a match(slower)'), |
| 101 | 103 | make_option('-i', '--id', action='store_true', default=False, dest='tid', |
| 102 | | help='use internal id instead of torrent name'), |
| | 104 | help='Use internal id instead of torrent name'), |
| 103 | 105 | make_option('-s', '--state', action='store', dest='state', |
| 104 | 106 | help="Only retrieve torrents in state STATE. " |
| 105 | 107 | "Allowable values are: %s "%(", ".join(states))), |
| 106 | 108 | ) |
| 107 | 109 | |
| 108 | | usage = "Usage: info [-v | -i | -s <state>] [<torrent-id> [<torrent-id> ...]]\n"\ |
| | 110 | usage = "Usage: info [-v | -i | -I | -s <state>] [<torrent-id> [<torrent-id> ...]]\n"\ |
| 109 | 111 | " info -s <state> will show only torrents in state <state>\n"\ |
| 110 | 112 | " You can give the first few characters of a torrent-id to identify the torrent." |
| 111 | 113 | |
| … |
… |
def handle(self, *args, **options):
|
| 116 | 118 | # Compile a list of torrent_ids to request the status of |
| 117 | 119 | torrent_ids = [] |
| 118 | 120 | for arg in args: |
| 119 | | torrent_ids.extend(self.console.match_torrent(arg)) |
| | 121 | torrent_ids.extend(self.console.match_torrent(arg, options['intense_match'])) |
| 120 | 122 | |
| 121 | 123 | if not args: |
| 122 | | torrent_ids.extend(self.console.match_torrent("")) |
| | 124 | torrent_ids.extend(self.console.match_torrent("", options['intense_match'])) |
| 123 | 125 | |
| 124 | 126 | def on_torrents_status(status): |
| 125 | 127 | # Print out the information for each torrent |
| … |
… |
def on_torrents_status_fail(reason):
|
| 134 | 136 | if options["state"]: |
| 135 | 137 | if options["state"] not in states: |
| 136 | 138 | self.console.write("Invalid state: %s"%options["state"]) |
| 137 | | self.console.write("Allowble values are: %s."%(", ".join(states))) |
| | 139 | self.console.write("Allowable values are: %s."%(", ".join(states))) |
| 138 | 140 | return |
| 139 | 141 | else: |
| 140 | 142 | status_dict["state"] = options["state"] |
diff --git a/deluge/ui/console/commands/move.py b/deluge/ui/console/commands/move.py
index 011031417ef5c25c71643656201e1cd20e20f726..36fb488a6ab7ddc4a7c8a434f33536b9653a26da 100644
|
a
|
b
|
|
| 33 | 33 | # |
| 34 | 34 | # |
| 35 | 35 | |
| | 36 | import os.path |
| | 37 | from optparse import make_option |
| | 38 | |
| 36 | 39 | from deluge.ui.console.main import BaseCommand |
| 37 | 40 | from deluge.ui.client import client |
| 38 | 41 | import deluge.component as component |
| 39 | 42 | |
| 40 | | import os.path |
| 41 | | |
| 42 | | |
| 43 | 43 | class Command(BaseCommand): |
| 44 | 44 | """Move torrents' storage location""" |
| 45 | | usage = "Usage: move <torrent-id> [<torrent-id> ...] <path>" |
| | 45 | option_list = BaseCommand.option_list + ( |
| | 46 | make_option('-I', '--intense-match', action='store_true', default=False, dest='intense_match', |
| | 47 | help='Consider torrents which have the pattern anywhere in the name a match(slower)'), |
| | 48 | ) |
| | 49 | usage = "Usage: move [ -I ] <torrent-id> [<torrent-id> ...] <path>" |
| 46 | 50 | |
| 47 | 51 | def handle(self, *args, **options): |
| 48 | 52 | self.console = component.get("ConsoleUI") |
| … |
… |
def handle(self, *args, **options):
|
| 59 | 63 | |
| 60 | 64 | ids = [] |
| 61 | 65 | for i in args[:-1]: |
| 62 | | ids.extend(self.console.match_torrent(i)) |
| | 66 | ids.extend(self.console.match_torrent(i, options['intense_match'])) |
| 63 | 67 | |
| 64 | 68 | names = [] |
| 65 | 69 | for i in ids: |
diff --git a/deluge/ui/console/commands/pause.py b/deluge/ui/console/commands/pause.py
index 351027897caad95c1e2baff6fc1434cf0cda986d..d6ce844e9f416405e6bfd097bfd81644cf9adce5 100644
|
a
|
b
|
|
| 33 | 33 | # statement from all source files in the program, then also delete it here. |
| 34 | 34 | # |
| 35 | 35 | # |
| | 36 | from optparse import make_option |
| | 37 | |
| 36 | 38 | from deluge.ui.console.main import BaseCommand |
| 37 | 39 | from deluge.ui.client import client |
| 38 | 40 | import deluge.ui.console.colors as colors |
| … |
… |
|
| 40 | 42 | |
| 41 | 43 | class Command(BaseCommand): |
| 42 | 44 | """Pause a torrent""" |
| 43 | | usage = "Usage: pause [ * | <torrent-id> [<torrent-id> ...] ]" |
| | 45 | option_list = BaseCommand.option_list + ( |
| | 46 | make_option('-I', '--intense-match', action='store_true', default=False, dest='intense_match', |
| | 47 | help='Consider torrents which have the pattern anywhere in the name a match(slower)'), |
| | 48 | ) |
| | 49 | usage = "Usage: pause [ -I ] [ * | <torrent-id> [<torrent-id> ...] ]" |
| 44 | 50 | def handle(self, *args, **options): |
| 45 | 51 | self.console = component.get("ConsoleUI") |
| 46 | 52 | |
| … |
… |
def handle(self, *args, **options):
|
| 53 | 59 | |
| 54 | 60 | torrent_ids = [] |
| 55 | 61 | for arg in args: |
| 56 | | torrent_ids.extend(self.console.match_torrent(arg)) |
| | 62 | torrent_ids.extend(self.console.match_torrent(arg, options['intense_match'])) |
| 57 | 63 | |
| 58 | 64 | if torrent_ids: |
| 59 | 65 | return client.core.pause_torrent(torrent_ids) |
diff --git a/deluge/ui/console/commands/recheck.py b/deluge/ui/console/commands/recheck.py
index 2e9cc75f1cef576ab8339812035c3b8d4de43b73..72a6981873310e9a61827934ad1559422e83197f 100644
|
a
|
b
|
|
| 32 | 32 | # statement from all source files in the program, then also delete it here. |
| 33 | 33 | # |
| 34 | 34 | # |
| | 35 | from optparse import make_option |
| | 36 | |
| 35 | 37 | from deluge.ui.console.main import BaseCommand |
| 36 | 38 | from deluge.ui.client import client |
| 37 | 39 | import deluge.ui.console.colors as colors |
| … |
… |
|
| 39 | 41 | |
| 40 | 42 | class Command(BaseCommand): |
| 41 | 43 | """Forces a recheck of the torrent data""" |
| 42 | | usage = "Usage: recheck [ * | <torrent-id> [<torrent-id> ...] ]" |
| | 44 | option_list = BaseCommand.option_list + ( |
| | 45 | make_option('-I', '--intense-match', action='store_true', default=False, dest='intense_match', |
| | 46 | help='Consider torrents which have the pattern anywhere in the name a match(slower)'), |
| | 47 | ) |
| | 48 | usage = "Usage: recheck [ -I ] [ * | <torrent-id> [<torrent-id> ...] ]" |
| 43 | 49 | def handle(self, *args, **options): |
| 44 | 50 | self.console = component.get("ConsoleUI") |
| 45 | 51 | |
| … |
… |
def handle(self, *args, **options):
|
| 47 | 53 | self.console.write(self.usage) |
| 48 | 54 | return |
| 49 | 55 | if len(args) > 0 and args[0].lower() == '*': |
| 50 | | client.core.force_recheck(self.console.match_torrent("")) |
| | 56 | client.core.force_recheck(self.console.match_torrent("", options['intense_match'])) |
| 51 | 57 | return |
| 52 | 58 | |
| 53 | 59 | torrent_ids = [] |
| 54 | 60 | for arg in args: |
| 55 | | torrent_ids.extend(self.console.match_torrent(arg)) |
| | 61 | torrent_ids.extend(self.console.match_torrent(arg, options['intense_match'])) |
| 56 | 62 | |
| 57 | 63 | if torrent_ids: |
| 58 | 64 | return client.core.force_recheck(torrent_ids) |
diff --git a/deluge/ui/console/commands/resume.py b/deluge/ui/console/commands/resume.py
index 70cd6cbe87b49d4f5cebf4092afa878163bd6c1a..09a00000a376907241ca12dd719bb13cf57716d8 100644
|
a
|
b
|
|
| 33 | 33 | # statement from all source files in the program, then also delete it here. |
| 34 | 34 | # |
| 35 | 35 | # |
| | 36 | from optparse import make_option |
| 36 | 37 | |
| 37 | 38 | from deluge.ui.console.main import BaseCommand |
| 38 | 39 | from deluge.ui.client import client |
| … |
… |
|
| 41 | 42 | |
| 42 | 43 | class Command(BaseCommand): |
| 43 | 44 | """Resume a torrent""" |
| 44 | | usage = "Usage: resume [ * | <torrent-id> [<torrent-id> ...] ]" |
| | 45 | option_list = BaseCommand.option_list + ( |
| | 46 | make_option('-I', '--intense-match', action='store_true', default=False, dest='intense_match', |
| | 47 | help='Consider torrents which have the pattern anywhere in the name a match(slower)'), |
| | 48 | ) |
| | 49 | usage = "Usage: resume [ -I ] [ * | <torrent-id> [<torrent-id> ...] ]" |
| 45 | 50 | def handle(self, *args, **options): |
| 46 | 51 | self.console = component.get("ConsoleUI") |
| 47 | 52 | |
| … |
… |
def handle(self, *args, **options):
|
| 54 | 59 | |
| 55 | 60 | torrent_ids = [] |
| 56 | 61 | for arg in args: |
| 57 | | torrent_ids.extend(self.console.match_torrent(arg)) |
| | 62 | torrent_ids.extend(self.console.match_torrent(arg, options['intense_match'])) |
| 58 | 63 | |
| 59 | 64 | if torrent_ids: |
| 60 | 65 | return client.core.resume_torrent(torrent_ids) |
diff --git a/deluge/ui/console/commands/rm.py b/deluge/ui/console/commands/rm.py
index 378a78d5c29bf44fc80ddab8a4e4af36b4ac5f10..a5c8e730936a318f7f748e74dca86b606d24e09d 100644
|
a
|
b
|
|
| 33 | 33 | # statement from all source files in the program, then also delete it here. |
| 34 | 34 | # |
| 35 | 35 | # |
| | 36 | from optparse import make_option |
| | 37 | |
| 36 | 38 | from deluge.ui.console.main import BaseCommand |
| 37 | 39 | import deluge.ui.console.colors as colors |
| 38 | 40 | from deluge.ui.client import client |
| 39 | 41 | import deluge.component as component |
| 40 | 42 | |
| 41 | | from optparse import make_option |
| 42 | | |
| 43 | | |
| 44 | 43 | class Command(BaseCommand): |
| 45 | 44 | """Remove a torrent""" |
| 46 | | usage = "Usage: rm <torrent-id>" |
| 47 | | aliases = ['del'] |
| 48 | | |
| 49 | 45 | option_list = BaseCommand.option_list + ( |
| | 46 | make_option('-I', '--intense-match', action='store_true', default=False, dest='intense_match', |
| | 47 | help='Consider torrents which have the pattern anywhere in the name a match(slower)'), |
| 50 | 48 | make_option('--remove_data', action='store_true', default=False, |
| 51 | 49 | help="remove the torrent's data"), |
| 52 | 50 | ) |
| | 51 | usage = "Usage: rm [ -I ] <torrent-id>" |
| | 52 | aliases = ['del'] |
| 53 | 53 | |
| 54 | 54 | def handle(self, *args, **options): |
| 55 | 55 | self.console = component.get("ConsoleUI") |
| … |
… |
def handle(self, *args, **options):
|
| 58 | 58 | |
| 59 | 59 | torrent_ids = [] |
| 60 | 60 | for arg in args: |
| 61 | | torrent_ids.extend(self.console.match_torrent(arg)) |
| | 61 | torrent_ids.extend(self.console.match_torrent(arg, options['intense_match'])) |
| 62 | 62 | |
| 63 | 63 | for torrent_id in torrent_ids: |
| 64 | 64 | client.core.remove_torrent(torrent_id, options['remove_data']) |
diff --git a/deluge/ui/console/commands/update-tracker.py b/deluge/ui/console/commands/update-tracker.py
index a4aa880e122294a38c67285a9325325c352b4e22..bd6792c235fd818ab73ac83d70688bf12c0ff866 100644
|
a
|
b
|
|
| 33 | 33 | # statement from all source files in the program, then also delete it here. |
| 34 | 34 | # |
| 35 | 35 | # |
| | 36 | from optparse import make_option |
| | 37 | |
| 36 | 38 | from deluge.ui.console.main import BaseCommand |
| 37 | 39 | import deluge.ui.console.colors as colors |
| 38 | 40 | from deluge.ui.client import client |
| 39 | 41 | import deluge.component as component |
| 40 | 42 | |
| 41 | | from optparse import make_option |
| 42 | | |
| 43 | | |
| 44 | 43 | class Command(BaseCommand): |
| 45 | 44 | """Update tracker for torrent(s)""" |
| 46 | | usage = "Usage: update-tracker [ * | <torrent-id> [<torrent-id> ...] ]" |
| | 45 | option_list = BaseCommand.option_list + ( |
| | 46 | make_option('-I', '--intense-match', action='store_true', default=False, dest='intense_match', |
| | 47 | help='Consider torrents which have the pattern anywhere in the name a match(slower)'), |
| | 48 | ) |
| | 49 | usage = "Usage: update-tracker [ -I ] [ * | <torrent-id> [<torrent-id> ...] ]" |
| 47 | 50 | aliases = ['reannounce'] |
| 48 | 51 | |
| 49 | 52 | def handle(self, *args, **options): |
| … |
… |
def handle(self, *args, **options):
|
| 56 | 59 | |
| 57 | 60 | torrent_ids = [] |
| 58 | 61 | for arg in args: |
| 59 | | torrent_ids.extend(self.console.match_torrent(arg)) |
| | 62 | torrent_ids.extend(self.console.match_torrent(arg, options['intense_match'])) |
| 60 | 63 | |
| 61 | 64 | client.core.force_reannounce(torrent_ids) |
| 62 | 65 | |
diff --git a/deluge/ui/console/main.py b/deluge/ui/console/main.py
index 9ec0279a44efc1a39d3b8dbe0e4ed37415101eaf..abaa814f0afcc926321ad3c9c6169763084ba420 100644
|
a
|
b
|
def on_torrents_status(torrents):
|
| 293 | 293 | client.core.get_session_state().addCallback(on_session_state) |
| 294 | 294 | |
| 295 | 295 | |
| 296 | | def match_torrent(self, string): |
| | 296 | def match_torrent(self, string, intense_match): |
| 297 | 297 | """ |
| 298 | 298 | Returns a list of torrent_id matches for the string. It will search both |
| 299 | 299 | torrent_ids and torrent names, but will only return torrent_ids. |
| 300 | 300 | |
| 301 | 301 | :param string: str, the string to match on |
| | 302 | :param intense_match: bool, whether we want to match anywhere or just from beginning |
| 302 | 303 | |
| 303 | 304 | :returns: list of matching torrent_ids. Will return an empty list if |
| 304 | 305 | no matches are found. |
| 305 | 306 | |
| 306 | 307 | """ |
| 307 | 308 | if self.interactive and isinstance(self.screen,deluge.ui.console.modes.legacy.Legacy): |
| 308 | | return self.screen.match_torrent(string) |
| | 309 | return self.screen.match_torrent(string, intense_match) |
| 309 | 310 | ret = [] |
| 310 | 311 | string = string.decode(self.encoding) |
| 311 | | for tid, name in self.torrents: |
| 312 | | if tid.startswith(string) or name.startswith(string): |
| 313 | | ret.append(tid) |
| | 312 | if intense_match: |
| | 313 | for tid, name in self.torrents: |
| | 314 | if tid.startswith(string) or string in name: |
| | 315 | ret.append(tid) |
| | 316 | else: |
| | 317 | for tid, name in self.torrents: |
| | 318 | if tid.startswith(string) or name.startswith(string): |
| | 319 | ret.append(tid) |
| 314 | 320 | |
| 315 | 321 | return ret |
| 316 | 322 | |
diff --git a/deluge/ui/console/modes/legacy.py b/deluge/ui/console/modes/legacy.py
index c59654dda77e435cb4a4dde949ab58828efe1c1b..9331a720a12c8afc2d3f30a3e25c5996b37adc3e 100644
|
a
|
b
|
def get_torrent_name(self, torrent_id):
|
| 578 | 578 | |
| 579 | 579 | return None |
| 580 | 580 | |
| 581 | | def match_torrent(self, string): |
| | 581 | def match_torrent(self, string, intense_match): |
| 582 | 582 | """ |
| 583 | 583 | Returns a list of torrent_id matches for the string. It will search both |
| 584 | 584 | torrent_ids and torrent names, but will only return torrent_ids. |
| 585 | 585 | |
| 586 | 586 | :param string: str, the string to match on |
| | 587 | :param intense_match: bool, whether we want to match anywhere or just from beginning |
| 587 | 588 | |
| 588 | 589 | :returns: list of matching torrent_ids. Will return an empty list if |
| 589 | 590 | no matches are found. |
| 590 | 591 | |
| 591 | 592 | """ |
| 592 | 593 | ret = [] |
| 593 | | for tid, name in self.torrents: |
| 594 | | if tid.startswith(string) or name.startswith(string): |
| 595 | | ret.append(tid) |
| | 594 | if intense_match: |
| | 595 | for tid, name in self.torrents: |
| | 596 | if tid.startswith(string) or string in name: |
| | 597 | ret.append(tid) |
| | 598 | else: |
| | 599 | for tid, name in self.torrents: |
| | 600 | if tid.startswith(string) or name.startswith(string): |
| | 601 | ret.append(tid) |
| 596 | 602 | |
| 597 | 603 | return ret |
| 598 | 604 | |