summaryrefslogtreecommitdiffstats
path: root/pyload/cli
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-04-13 17:20:59 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-04-13 17:20:59 +0200
commite00ef98491f79ae8aa972ae1473dae4a7b78c07e (patch)
tree31be0c7cdcebb61525bcc387bcf15d265a1c494a /pyload/cli
parentFix except (diff)
downloadpyload-e00ef98491f79ae8aa972ae1473dae4a7b78c07e.tar.xz
Cleanup
Diffstat (limited to 'pyload/cli')
-rw-r--r--pyload/cli/AddPackage.py2
-rw-r--r--pyload/cli/Cli.py14
-rw-r--r--pyload/cli/Handler.py8
-rw-r--r--pyload/cli/ManageFiles.py7
4 files changed, 31 insertions, 0 deletions
diff --git a/pyload/cli/AddPackage.py b/pyload/cli/AddPackage.py
index f7e30b64e..131d0d7d7 100644
--- a/pyload/cli/AddPackage.py
+++ b/pyload/cli/AddPackage.py
@@ -12,6 +12,7 @@ class AddPackage(Handler):
self.name = ""
self.urls = []
+
def onEnter(self, inp):
if inp == "0":
self.cli.reset()
@@ -28,6 +29,7 @@ class AddPackage(Handler):
self.urls.append(inp)
self.setInput()
+
def renderBody(self, line):
println(line, white(_("Add Package:")))
println(line + 1, "")
diff --git a/pyload/cli/Cli.py b/pyload/cli/Cli.py
index d8c8602fc..855ef47cc 100644
--- a/pyload/cli/Cli.py
+++ b/pyload/cli/Cli.py
@@ -36,6 +36,7 @@ from Getch import Getch
from rename_process import renameProcess
class Cli(object):
+
def __init__(self, client, command):
self.client = client
self.command = command
@@ -66,11 +67,13 @@ class Cli(object):
else:
self.processCommand()
+
def reset(self):
""" reset to initial main menu """
self.input = ""
self.headerHandler = self.bodyHandler = self.inputHandler = self
+
def start(self):
""" main loop. handle input """
while True:
@@ -130,11 +133,13 @@ class Cli(object):
def setInput(self, string=""):
self.input = string
+
def setHandler(self, klass):
#create new handler with reference to cli
self.bodyHandler = self.inputHandler = klass(self)
self.input = ""
+
def renderHeader(self, line):
""" prints download status """
#print updated information
@@ -182,6 +187,7 @@ class Cli(object):
return line + 1
+
def renderBody(self, line):
""" prints initial menu """
println(line, white(_("Menu:")))
@@ -195,6 +201,7 @@ class Cli(object):
return line + 8
+
def renderFooter(self, line):
""" prints out the input line with input """
println(line, "")
@@ -212,6 +219,7 @@ class Cli(object):
#set cursor to position
print "\033[" + str(self.inputline) + ";0H"
+
def onChar(self, char):
""" default no special handling for single chars """
if char == "1":
@@ -232,12 +240,15 @@ class Cli(object):
os.system('clear')
sys.exit()
+
def onEnter(self, inp):
pass
+
def onBackSpace(self):
pass
+
def processCommand(self):
command = self.command[0]
args = []
@@ -339,6 +350,7 @@ class Cli(object):
else:
print_commands()
+
def printOnlineCheck(self, client, rid):
while True:
sleep(1)
@@ -354,11 +366,13 @@ class Cli(object):
class RefreshThread(Thread):
+
def __init__(self, cli):
Thread.__init__(self)
self.setDaemon(True)
self.cli = cli
+
def run(self):
while True:
sleep(1)
diff --git a/pyload/cli/Handler.py b/pyload/cli/Handler.py
index 4aab3f0e2..33e5dd8e6 100644
--- a/pyload/cli/Handler.py
+++ b/pyload/cli/Handler.py
@@ -2,6 +2,7 @@
# @author: RaNaN
class Handler(object):
+
def __init__(self, cli):
self.cli = cli
self.init()
@@ -9,24 +10,31 @@ class Handler(object):
client = property(lambda self: self.cli.client)
input = property(lambda self: self.cli.input)
+
def init(self):
pass
+
def onChar(self, char):
pass
+
def onBackSpace(self):
pass
+
def onEnter(self, inp):
pass
+
def setInput(self, inp=""):
self.cli.setInput(inp)
+
def backspace(self):
self.cli.setInput(self.input[:-1])
+
def renderBody(self, line):
""" gets the line where to render output and should return the line number below its content """
return line + 1
diff --git a/pyload/cli/ManageFiles.py b/pyload/cli/ManageFiles.py
index ca1070113..3bf8d1686 100644
--- a/pyload/cli/ManageFiles.py
+++ b/pyload/cli/ManageFiles.py
@@ -22,6 +22,7 @@ class ManageFiles(Handler):
self.links = None
self.time = 0
+
def onChar(self, char):
if char in ("m", "d", "r"):
self.mode = char
@@ -33,12 +34,14 @@ class ManageFiles(Handler):
self.pos += 5
self.backspace()
+
def onBackSpace(self):
if not self.input and self.mode:
self.mode = ""
if not self.input and self.package > -1:
self.package = -1
+
def onEnter(self, input):
if input == "0":
self.cli.reset()
@@ -74,6 +77,7 @@ class ManageFiles(Handler):
self.mode = ""
self.setInput()
+
def renderBody(self, line):
if self.package < 0:
println(line, white(_("Manage Packages:")))
@@ -131,6 +135,7 @@ class ManageFiles(Handler):
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
@@ -145,6 +150,7 @@ class ManageFiles(Handler):
return data
+
def getLinks(self):
if self.links and self.time + 1 < time():
return self.links
@@ -156,6 +162,7 @@ class ManageFiles(Handler):
self.time = time()
return data
+
def parseInput(self, inp, package=True):
inp = inp.strip()
if "-" in inp: