diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-07-16 23:52:17 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-07-16 23:52:17 +0200 |
commit | a1c441101d15c58ea15082a86df2b3552f01106a (patch) | |
tree | 68e69287247e2d548b2e035f2e10b210b180409e /pyLoadCli.py | |
parent | started to integrate package generator (diff) | |
download | pyload-a1c441101d15c58ea15082a86df2b3552f01106a.tar.xz |
improvements, command line link checker
Diffstat (limited to 'pyLoadCli.py')
-rwxr-xr-x | pyLoadCli.py | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/pyLoadCli.py b/pyLoadCli.py index db5952104..a59832c73 100755 --- a/pyLoadCli.py +++ b/pyLoadCli.py @@ -23,7 +23,7 @@ from getopt import GetoptError, getopt import gettext import os from os import _exit -from os.path import join, exists +from os.path import join, exists, abspath import sys from sys import exit from threading import Thread, Lock @@ -41,6 +41,10 @@ else: sys.stdout = getwriter(enc)(sys.stdout, errors = "replace") +#original working dir +OWD = abspath("") + + from module import InitHomeDir from module.cli.printer import * from module.cli import AddPackage, ManageFiles @@ -311,6 +315,32 @@ class Cli: pack = self.client.getPackageInfo(int(pid)) self.client.movePackage((pack.dest + 1) % 2, pack.pid) + elif command == "check": + links = [] + for url in args: + if exists(join(OWD, url)): + f = open(join(OWD, url), "rb") + links.extend([x.strip() for x in f.readlines() if x.strip()]) + else: + links.append(url) + + print _("Checking %d links:") % len(links) + print + rid = client.checkOnlineStatus(links) + while True: + sleep(1) + result = client.pollResults(rid) + for pack in result.itervalues(): + for url, status in pack.iteritems(): + if status.status == 2: check = "Online" + elif status.status == 1: check = "Offline" + else: check = "Unknown" + + print "%-30s: %-30s %-8s\t %s" % (url, status.name, formatSize(status.size), check) + + if "ALL_INFO_FETCHED" in result: break + + elif command == "pause": self.client.pause() @@ -416,6 +446,7 @@ def print_commands(): ("move <pid> <pid2>...", _("Move Packages from Queue to Collector or vice versa")), ("restart_file <fid> <fid2>...", _("Restart files")), ("restart_package <pid> <pid2>...", _("Restart packages")), + ("check <linklist|url> ...", _("Check online status")), ("pause", _("Pause the server")), ("unpause", _("continue downloads")), ("toggle", _("Toggle pause/unpause")), |