diff options
Diffstat (limited to 'pyload/cli')
-rw-r--r-- | pyload/cli/AddPackage.py | 3 | ||||
-rw-r--r-- | pyload/cli/Cli.py | 8 | ||||
-rw-r--r-- | pyload/cli/Handler.py | 6 | ||||
-rw-r--r-- | pyload/cli/ManageFiles.py | 25 |
4 files changed, 18 insertions, 24 deletions
diff --git a/pyload/cli/AddPackage.py b/pyload/cli/AddPackage.py index cc0bf2f7c..b4e978bc5 100644 --- a/pyload/cli/AddPackage.py +++ b/pyload/cli/AddPackage.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -#Copyright (C) 2011-2014 RaNaN +# Copyright (C) 2011-2014 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 @@ -20,6 +20,7 @@ from pyload.cli.Handler import Handler from pyload.utils.printer import * + class AddPackage(Handler): """ let the user add packages """ diff --git a/pyload/cli/Cli.py b/pyload/cli/Cli.py index f05e98b1a..cc285f060 100644 --- a/pyload/cli/Cli.py +++ b/pyload/cli/Cli.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -#Copyright (C) 2008-2014 RaNaN +# Copyright (C) 2008-2014 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 @@ -50,7 +50,7 @@ from pyload.remote.thriftbackend.ThriftClient import ThriftClient, NoConnection, from Getch import Getch from rename_process import renameProcess -class Cli: +class Cli(object): def __init__(self, client, command): self.client = client self.command = command @@ -468,7 +468,7 @@ def writeConfig(opts): cfgfile.write("[cli]") for opt in opts: cfgfile.write("%s=%s\n" % (opt, opts[opt])) - except: + except Exception: print _("Couldn't write user config file") @@ -476,7 +476,7 @@ def main(): config = {"addr": "127.0.0.1", "port": "7227", "language": "en"} try: config["language"] = os.environ["LANG"][0:2] - except: + except Exception: pass if (not exists(join(pypath, "locale", config["language"]))) or config["language"] == "": diff --git a/pyload/cli/Handler.py b/pyload/cli/Handler.py index 37b0d7b99..6ded952ec 100644 --- a/pyload/cli/Handler.py +++ b/pyload/cli/Handler.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -#Copyright (C) 2011-2014 RaNaN +# Copyright (C) 2011-2014 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 @@ -16,7 +16,9 @@ # along with this program; if not, see <http://www.gnu.org/licenses/>. # ### -class Handler: + + +class Handler(object): def __init__(self, cli): self.cli = cli self.init() diff --git a/pyload/cli/ManageFiles.py b/pyload/cli/ManageFiles.py index 335ea1ec1..9bf49c54c 100644 --- a/pyload/cli/ManageFiles.py +++ b/pyload/cli/ManageFiles.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -#Copyright (C) 2011-2014 RaNaN +# Copyright (C) 2011-2014 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 @@ -25,15 +25,15 @@ from pyload.utils.printer import * from pyload.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 @@ -81,7 +81,7 @@ class ManageFiles(Handler): #look into package try: self.package = int(input) - except: + except Exception: pass self.cache = None @@ -90,7 +90,6 @@ class ManageFiles(Handler): self.mode = "" self.setInput() - def renderBody(self, line): if self.package < 0: println(line, white(_("Manage Packages:"))) @@ -111,7 +110,7 @@ class ManageFiles(Handler): 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: @@ -135,7 +134,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: @@ -146,10 +145,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 @@ -159,7 +156,6 @@ class ManageFiles(Handler): else: data = self.client.getCollector() - self.cache = data self.time = time() @@ -168,15 +164,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): @@ -196,8 +189,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(",")] |