diff options
Diffstat (limited to 'module/cli/ManageFiles.py')
-rw-r--r-- | module/cli/ManageFiles.py | 50 |
1 files changed, 12 insertions, 38 deletions
diff --git a/module/cli/ManageFiles.py b/module/cli/ManageFiles.py index 4d0377d9d..ca1070113 100644 --- a/module/cli/ManageFiles.py +++ b/module/cli/ManageFiles.py @@ -1,40 +1,23 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- -# -#Copyright (C) 2011 RaNaN -# -#This program is free software; you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation; either version 3 of the License, -#or (at your option) any later version. -# -#This program is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -#See the GNU General Public License for more details. -# -#You should have received a copy of the GNU General Public License -# along with this program; if not, see <http://www.gnu.org/licenses/>. -# -### +# @author: RaNaN from itertools import islice from time import time -from Handler import Handler -from printer import * +from pyload.cli.Handler import Handler +from pyload.utils.printer import * + +from pyload.api import Destination, PackageData -from module.Api import Destination, PackageData class ManageFiles(Handler): """ possibility to manage queue/collector """ def init(self): self.target = Destination.Queue - self.pos = 0 #position in queue + self.pos = 0 #position in queue self.package = -1 #choosen package - self.mode = "" # move/delete/restart - + self.mode = "" # move/delete/restart self.cache = None self.links = None self.time = 0 @@ -82,7 +65,7 @@ class ManageFiles(Handler): #look into package try: self.package = int(input) - except: + except Exception: pass self.cache = None @@ -91,7 +74,6 @@ class ManageFiles(Handler): self.mode = "" self.setInput() - def renderBody(self, line): if self.package < 0: println(line, white(_("Manage Packages:"))) @@ -107,12 +89,12 @@ class ManageFiles(Handler): elif self.mode == "r": println(line, _("What do you want to restart?")) - println(line + 1, "Enter single number, comma seperated numbers or ranges. eg. 1,2,3 or 1-3.") + println(line + 1, "Enter single number, comma seperated numbers or ranges. eg. 1, 2, 3 or 1-3.") line += 2 else: println(line, _("Choose what yout want to do or enter package number.")) println(line + 1, ("%s - %%s, %s - %%s, %s - %%s" % (mag("d"), mag("m"), mag("r"))) % ( - _("delete"), _("move"), _("restart"))) + _("delete"), _("move"), _("restart"))) line += 2 if self.package < 0: @@ -136,7 +118,7 @@ class ManageFiles(Handler): for value in islice(pack.links, self.pos, self.pos + 5): try: println(line, mag(value.fid) + ": %s | %s | %s" % ( - value.name, value.statusmsg, value.plugin)) + value.name, value.statusmsg, value.plugin)) line += 1 i += 1 except Exception, e: @@ -147,10 +129,8 @@ class ManageFiles(Handler): println(line, mag("p") + _(" - previous") + " | " + mag("n") + _(" - next")) println(line + 1, mag("0.") + _(" back to main menu")) - return line + 2 - def getPackages(self): if self.cache and self.time + 2 < time(): return self.cache @@ -160,7 +140,6 @@ class ManageFiles(Handler): else: data = self.client.getCollector() - self.cache = data self.time = time() @@ -169,15 +148,12 @@ class ManageFiles(Handler): def getLinks(self): if self.links and self.time + 1 < time(): return self.links - try: data = self.client.getPackageData(self.package) - except: + except Exception: data = PackageData(links=[]) - self.links = data self.time = time() - return data def parseInput(self, inp, package=True): @@ -197,8 +173,6 @@ class ManageFiles(Handler): for l in self.links.links: if l.lid in r: ret.append(l.lid) - return ret - else: return [int(x) for x in inp.split(",")] |