diff options
-rw-r--r-- | module/Api.py | 725 | ||||
-rw-r--r-- | module/PyFile.py | 4 | ||||
-rw-r--r-- | module/cli/ManageFiles.py | 6 | ||||
-rw-r--r-- | module/remote/ThriftBackend.py | 4 | ||||
-rw-r--r-- | module/remote/thriftbackend/Handler.py | 4 | ||||
-rw-r--r-- | module/remote/thriftbackend/pyload.thrift | 47 | ||||
-rwxr-xr-x | module/remote/thriftbackend/thriftgen/pyload/Pyload-remote | 91 | ||||
-rw-r--r-- | module/remote/thriftbackend/thriftgen/pyload/Pyload.py | 976 | ||||
-rw-r--r-- | module/remote/thriftbackend/thriftgen/pyload/ttypes.py | 73 | ||||
-rw-r--r-- | module/unescape.py | 57 | ||||
-rwxr-xr-x | pyLoadCli.py | 7 | ||||
-rwxr-xr-x | pyLoadCore.py | 21 |
12 files changed, 1380 insertions, 635 deletions
diff --git a/module/Api.py b/module/Api.py new file mode 100644 index 000000000..85e3d233a --- /dev/null +++ b/module/Api.py @@ -0,0 +1,725 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" + 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 base64 import standard_b64encode +from os.path import join +from time import time + +from remote.thriftbackend.thriftgen.pyload.ttypes import * +from remote.thriftbackend.thriftgen.pyload.Pyload import Iface + +from module.PyFile import PyFile +from module.database.UserDatabase import ROLE +from module.utils import freeSpace, compare_time + + +class Api(Iface): + """ + ===pyLoads API=== + + see Thrift specification file remote/thriftbackend/pyload.thrift\ + for information about data structures and what methods are usuable with rpc. + + """ + + def __init__(self, core): + self.core = core + + def _convertPyFile(self, p): + f = FileData(p["id"], p["url"], p["name"], p["plugin"], p["size"], + p["format_size"], p["status"], p["statusmsg"], + p["package"], p["error"], p["order"], p["progress"]) + return f + + def _convertConfigFormat(self, c): + sections = [] + for sectionName, sub in c.iteritems(): + section = ConfigSection() + section.name = sectionName + section.description = sub["desc"] + items = [] + for key, data in sub.iteritems(): + if key == "desc": + continue + item = ConfigItem() + item.name = key + item.description = data["desc"] + item.value = str(data["value"]) if type(data["value"]) != basestring else data["value"] + item.type = data["type"] + items.append(item) + section.items = items + sections.append(section) + return sections + + def getConfigValue(self, category, option, section): + """Retrieve config value. + + :param category: name of category, or plugin + :param option: config option + :param section: 'plugin' or 'core' + :return: config value as string + """ + if section == "core": + return self.core.config[category][option] + elif section == "plugin": + return self.core.config.getPlugin(category, option) + + def setConfigValue(self, category, option, value, section): + """Set new config value. + + :param category: + :param option: + :param value: new config value + :param section: 'plugin' or 'core + """ + if section == "core": + self.core.config[category][option] = value + + if option in ("limit_speed", "max_speed"): #not so nice to update the limit + self.core.requestFactory.updateBucket() + + elif section == "plugin": + self.core.config.setPlugin(category, option, value) + + def getConfig(self): + """Retrieves complete config of core. + + :return: list of `ConfigSection` + """ + return self._convertConfigFormat(self.core.config.config) + + def getPluginConfig(self): + """Retrieves complete config for all plugins. + + :return: list of `ConfigSection` + """ + return self._convertConfigFormat(self.core.config.plugin) + + def pauseServer(self): + """Pause server: Tt wont start any new downloads, but nothing gets aborted.""" + self.core.threadManager.pause = True + + def unpauseServer(self): + """Unpause server: New Downloads will be started.""" + self.core.threadManager.pause = False + + def togglePause(self): + """Toggle pause state. + + :return: new pause state + """ + self.core.threadManager.pause ^= True + return self.core.threadManager.pause + + def toggleReconnect(self): + """Toggle reconnect activation. + + :return: new reconnect state + """ + self.core.config["reconnect"]["activated"] ^= True + return self.core.config["reconnect"]["activated"] + + def statusServer(self): + """Some general information about the current status of pyLoad. + + :return: `ServerStatus` + """ + serverStatus = ServerStatus() + serverStatus.pause = self.core.threadManager.pause + serverStatus.active = len(self.core.threadManager.processingIds()) + serverStatus.queue = self.core.files.getFileCount() #TODO: real amount of queued files + serverStatus.total = self.core.files.getFileCount() + serverStatus.speed = 0 + for pyfile in [x.active for x in self.core.threadManager.threads if x.active and isinstance(x, PyFile)]: + serverStatus.speed += pyfile.getSpeed() #bytes/s + + serverStatus.download = not self.core.threadManager.pause and self.isTimeDownload() + serverStatus.reconnect = self.core.config['reconnect']['activated'] and self.isTimeReconnect() + return serverStatus + + def freeSpace(self): + return freeSpace(self.core.config["general"]["download_folder"]) + + def getServerVersion(self): + return self.core.version + + def kill(self): + """Clean way to quit pyLoad""" + self.core.do_kill = True + + def restart(self): + """Untested""" + self.core.do_restart = True + + def getLog(self, offset): + """Returns most recent log entries. + + :param offset: line offset + :return: List of log entries + """ + filename = join(self.core.config['log']['log_folder'], 'log.txt') + try: + fh = open(filename, "r") + lines = fh.readlines() + fh.close() + if offset >= len(lines): + return [] + return lines[offset:] + except: + return ['No log available'] + + def checkURL(self, urls): + raise NotImplemented #TODO + + def isTimeDownload(self): + """Checks if pyload will start new downloads according to time in config . + + :return: bool + """ + start = self.core.config['downloadTime']['start'].split(":") + end = self.core.config['downloadTime']['end'].split(":") + return compare_time(start, end) + + def isTimeReconnect(self): + """Checks if pyload will try to make a reconnect + + :return: bool + """ + start = self.core.config['reconnect']['startTime'].split(":") + end = self.core.config['reconnect']['endTime'].split(":") + return compare_time(start, end) and self.core.config["reconnect"]["activated"] + + def statusDownloads(self): + """ Status off all currently running downloads. + + :return: list of `DownloadStatus` + """ + data = [] + for pyfile in [x.active for x in self.core.threadManager.threads + self.core.threadManager.localThreads if + x.active]: + if not isinstance(pyfile, PyFile) or not pyfile.hasPlugin(): + continue + + data.append(DownloadInfo( + pyfile.id, pyfile.name, pyfile.getSpeed(), pyfile.getETA(), pyfile.formatETA(), + pyfile.getBytesLeft(), pyfile.getSize(), pyfile.formatSize(), pyfile.getPercent(), + pyfile.status, pyfile.m.statusMsg[pyfile.status], pyfile.formatWait(), + pyfile.waitUntil, pyfile.packageid, pyfile.package().name, pyfile.pluginname)) + + return data + + def addPackage(self, name, links, dest): + """Adds a package, with links to desired destination. + + :param name: name of the new package + :param links: list of urls + :param dest: `Destination` + :return: package id of the new package + """ + if self.core.config['general']['folder_per_package']: + folder = name + else: + folder = "" + + folder = folder.replace("http://", "").replace(":", "").replace("/", "_").replace("\\", "_") + + pid = self.core.files.addPackage(name, folder, dest) + + self.core.files.addLinks(links, pid) + + self.core.log.info(_("Added package %(name)s containing %(count)d links") % {"name": name, "count": len(links)}) + + self.core.files.save() + + return pid + + def getPackageData(self, pid): + """Returns complete information about package, and included files. + + :param pid: package id + :return: `PackageData` with .links attribute + """ + data = self.core.files.getPackageData(int(pid)) + if not data: + raise PackageDoesNotExists(pid) + + pdata = PackageData(data["id"], data["name"], data["folder"], data["site"], data["password"], + data["queue"], data["order"], data["priority"], + links=[self._convertPyFile(x) for x in data["links"].itervalues()]) + + return pdata + + def getPackageInfo(self, pid): + """Returns information about package, without detailed information about containing files + + :param pid: package id + :return: `PackageData` with .fid attribute + """ + data = self.core.files.getPackageData(int(pid)) + if not data: + raise PackageDoesNotExists(pid) + + pdata = PackageData(data["id"], data["name"], data["folder"], data["site"], data["password"], + data["queue"], data["order"], data["priority"], fids=[int(x) for x in data["links"]]) + + return pdata + + def getFileData(self, fid): + """Get complete information about a specific file. + + :param fid: file id + :return: `FileData` + """ + info = self.core.files.getFileData(int(fid)) + fdata = self._convertPyFile(info.values()[0]) + return fdata + + def deleteFiles(self, fids): + """Deletes several file entries from pyload. + + :param fids: list of file ids + """ + for id in fids: + self.core.files.deleteLink(int(id)) + + self.core.files.save() + + def deletePackages(self, pids): + """Deletes packages and containing links. + + :param pids: list of package ids + """ + for id in pids: + self.core.files.deletePackage(int(id)) + + self.core.files.save() + + def getQueue(self): + """Returns info about queue and packages, **not** about files, see `getQueueData` \ + or `getPackageData` instead. + + :return: list of `PackageInfo` + """ + return [PackageData(pack["id"], pack["name"], pack["folder"], pack["site"], + pack["password"], pack["queue"], pack["order"], pack["priority"], + fids=[int(x) for x in pack["links"]]) + for pack in self.core.files.getInfoData(Destination.Queue).itervalues()] + + def getQueueData(self): + """Return complete data about everything in queue, this is very expensive use it sparely.\ + See `getQueue` for alternative. + + :return: list of `PackageData` + """ + return [PackageData(pack["id"], pack["name"], pack["folder"], pack["site"], + pack["password"], pack["queue"], pack["order"], pack["priority"], + links=[self._convertPyFile(x) for x in pack["links"].itervalues()]) + for pack in self.core.files.getCompleteData(Destination.Queue).itervalues()] + + def getCollector(self): + """same as `getQueue` for collector. + + :return: list of `PackageInfo` + """ + return [PackageData(pack["id"], pack["name"], pack["folder"], pack["site"], + pack["password"], pack["queue"], pack["order"], pack["priority"], + fids=[int(x) for x in pack["links"]]) + for pack in self.core.files.getInfoData(Destination.Collector).itervalues()] + + def getCollectorData(self): + """same as `getQueueData` for collector. + + :return: list of `PackageInfo` + """ + return [PackageData(pack["id"], pack["name"], pack["folder"], pack["site"], + pack["password"], pack["queue"], pack["order"], pack["priority"], + links=[self._convertPyFile(x) for x in pack["links"].itervalues()]) + for pack in self.core.files.getCompleteData(Destination.Collector).itervalues()] + + + def addFiles(self, pid, links): + """Adds files to specific package. + + :param pid: package id + :param links: list of urls + """ + self.core.files.addLinks(links, int(pid)) + + self.core.log.info(_("Added %(count)d links to package #%(package)d ") % {"count": len(links), "package": pid}) + self.core.files.save() + + def pushToQueue(self, pid): + """Moves package from Collector to Queue. + + :param pid: package id + """ + self.core.files.setPackageLocation(pid, Destination.Queue) + + def pullFromQueue(self, pid): + """Moves package from Queue to Collector. + + :param pid: package id + """ + self.core.files.setPackageLocation(pid, Destination.Collector) + + def restartPackage(self, pid): + """Restarts a package, resets every containing files. + + :param pid: package id + """ + self.core.files.restartPackage(int(pid)) + + def restartFile(self, fid): + """Resets file status, so it will be downloaded again. + + :param fid: file id + """ + self.core.files.restartFile(int(fid)) + + def recheckPackage(self, pid): + """Proofes online status of all files in a package, also a default action when package is added. + + :param pid: + :return: + """ + self.core.files.reCheckPackage(int(pid)) + + def stopAllDownloads(self): + """Aborts all running downloads.""" + + pyfiles = self.core.files.cache.values() + for pyfile in pyfiles: + pyfile.abortDownload() + + def stopDownloads(self, fids): + """Aborts specific downloads. + + :param fids: list of file ids + :return: + """ + pyfiles = self.core.files.cache.values() + + for pyfile in pyfiles: + if pyfile.id in fids: + pyfile.abortDownload() + + def setPackageName(self, pid, name): + """Renames a package. + + :param pid: package id + :param name: new package name + """ + pack = self.core.files.getPackage(pid) + pack.name = name + pack.sync() + + def movePackage(self, destination, pid): + """Set a new package location. + + :param destination: `Destination` + :param pid: package id + """ + if destination not in (0, 1): return + self.core.files.setPackageLocation(pid, destination) + + def uploadContainer(self, filename, data): + """Uploads and adds a container file to pyLoad. + + :param filename: filename, extension is important so it can correctly decrypted + :param data: file content + """ + th = open(join(self.core.config["general"]["download_folder"], "tmp_" + filename), "wb") + th.write(str(data)) + th.close() + + self.addPackage(th.name, [th.name], Destination.Queue) + + def setPriority(self, pid, priority): + """Set a new priority, so a package will be downloaded before others. + + :param pid: package id + :param priority: + """ + p = self.core.files.getPackage(pid) + p.setPriority(priority) + + def orderPackage(self, pid, position): + """Gives a package a new position. + + :param pid: package id + :param position: + """ + self.core.files.reorderPackage(pid, position) + + def orderFile(self, fid, position): + """Gives a new position to a file within its package. + + :param fid: file id + :param position: + """ + self.core.files.reorderFile(fid, position) + + def setPackageData(self, pid, data): + """Allows to modify several package attributes. + + :param pid: package id + :param data: dict that maps attribute to desired value + """ + p = self.core.files.getPackage(pid) + if not p: raise PackageDoesNotExists(pid) + + for key, value in data.iteritems(): + if key == "id": continue + setattr(p, key, value) + + p.sync() + self.core.files.save() + + def deleteFinished(self): + """Deletes all finished files and completly finished packages. + + :return: list of deleted package ids + """ + deleted = self.core.files.deleteFinishedLinks() + return deleted + + def restartFailed(self): + """Restarts all failed failes.""" + self.core.files.restartFailed() + + def getPackageOrder(self, destination): + """Returns information about package order. + + :param destination: `Destination` + :return: dict mapping order to package id + """ + + packs = self.core.files.getInfoData(destination) + order = {} + + for pid in packs: + pack = self.core.files.getPackageData(int(pid)) + while pack["order"] in order.keys(): #just in case + pack["order"] += 1 + order[pack["order"]] = pack["id"] + return order + + def getFileOrder(self, pid): + """Information about file order within package. + + :param pid: + :return: dict mapping order to file id + """ + rawData = self.core.files.getPackageData(int(pid)) + order = {} + for id, pyfile in rawData["links"].iteritems(): + while pyfile["order"] in order.keys(): #just in case + pyfile["order"] += 1 + order[pyfile["order"]] = pyfile["id"] + return order + + + def isCaptchaWaiting(self): + """Indicates wether a captcha task is available + + :return: bool + """ + self.core.lastClientConnected = time() + task = self.core.captchaManager.getTask() + return not task is None + + def getCaptchaTask(self, exclusive): + """Returns a captcha task + + :param exclusive: unused + :return: `CaptchaTask` + """ + self.core.lastClientConnected = time() + task = self.core.captchaManager.getTask() + if task: + task.setWatingForUser(exclusive=exclusive) + data, type, result = task.getCaptcha() + t = CaptchaTask(int(task.tid), standard_b64encode(data), type, result) + return t + else: + return CaptchaTask() + + def getCaptchaTaskStatus(self, tid): + """Get information about captcha task + + :param tid: task id + :return: string + """ + self.core.lastClientConnected = time() + t = self.core.captchaManager.getTaskByID(tid) + return t.getStatus() if t else "" + + def setCaptchaResult(self, tid, result): + """Set result for a captcha task + + :param tid: task id + :param result: captcha result + """ + self.core.lastClientConnected = time() + task = self.core.captchaManager.getTaskByID(tid) + if task: + task.setResult(result) + self.core.captchaManager.removeTask(task) + + + def getEvents(self, uuid): + """Lists occured events, may be affected to changes in future. + + :param uuid: + :return: list of `Events` + """ + events = self.core.pullManager.getEvents(uuid) + newEvents = [] + + def convDest(d): + return Destination.Queue if d == "queue" else Destination.Collector + + for e in events: + event = Event() + event.event = e[0] + if e[0] in ("update", "remove", "insert"): + event.id = e[3] + event.type = ElementType.Package if e[2] == "pack" else ElementType.File + event.destination = convDest(e[1]) + elif e[0] == "order": + if e[1]: + event.id = e[1] + event.type = ElementType.Package if e[2] == "pack" else ElementType.File + event.destination = convDest(e[3]) + elif e[0] == "reload": + event.destination = convDest(e[1]) + newEvents.append(event) + return newEvents + + def getAccounts(self, refresh): + """Get information about all entered accounts. + + :param refresh: reload account info + :return: list of `AccountInfo` + """ + accs = self.core.accountManager.getAccountInfos(False, refresh) + accounts = [] + for group in accs.values(): + accounts.extend([AccountInfo(acc["validuntil"], acc["login"], acc["options"], acc["valid"], + acc["trafficleft"], acc["maxtraffic"], acc["premium"], acc["type"]) + for acc in group]) + return accounts + + def getAccountTypes(self): + """All available account types. + + :return: list + """ + return self.core.accountManager.getAccountInfos(False, False).keys() + + def updateAccounts(self, data): + """Changes pw/options for specific account. + + :param data: `AccountData` + """ + self.core.accountManager.updateAccount(data.type, data.login, data.password, data.options) + + def removeAccount(self, plugin, account): + """Remove account from pyload. + + :param plugin: pluginname + :param account: accountname + """ + self.core.accountManager.removeAccount(plugin, account) + + def login(self, username, password, remoteip=None): + """Login into pyLoad, this **must** be called when using rpc before any methods can be used. + + :param username: + :param password: + :param remoteip: + :return: bool indicating login was successful + """ + if self.core.config["remote"]["nolocalauth"] and remoteip == "127.0.0.1": + return True + if self.core.startedInGui and remoteip == "127.0.0.1": + return True + + user = self.core.db.checkAuth(username, password) + if user and user["role"] == ROLE.ADMIN: + return True + + return False + + def checkAuth(self, username, password): + """Check authentication and returns details + + :param username: + :param password: + :return: dict with info, empty when login is incorrect + """ + return self.core.db.checkAuth(username, password) + + def getUserData(self, username, password): + """see `checkAuth`""" + return self.checkAuth(username, password) + + + def getServices(self): + """ A dict of available services, these can be defined by hook plugins. + + :return: dict with this style: {"plugin": {"method": "description"}} + """ + data = {} + for plugin, funcs in self.core.hookManager.methods.iteritems(): + data[plugin] = funcs + + return data + + def hasService(self, plugin, func): + """Checks wether a service is available. + + :param plugin: + :param func: + :return: bool + """ + cont = self.core.hookManager.methods + return cont.has_key(plugin) and cont[plugin].has_key(func) + + def call(self, info): + """Calls a service (a method in hook plugin). + + :param info: `ServiceCall` + :return: result + :raises: ServiceDoesNotExists, when its not available + :raises: ServiceException, when a exception was raised + """ + plugin = info.plugin + func = info.func + args = info.arguments + parse = info.parseArguments + + if not self.hasService(plugin, func): + raise ServiceDoesNotExists(plugin, func) + + try: + ret = self.core.hookManager.callRPC(plugin, func, args, parse) + return str(ret) + except Exception, e: + raise ServiceException(e.message)
\ No newline at end of file diff --git a/module/PyFile.py b/module/PyFile.py index 6ab8318fc..b5384c399 100644 --- a/module/PyFile.py +++ b/module/PyFile.py @@ -176,7 +176,6 @@ class PyFile(object): } } - @lock def abortDownload(self): """abort pyfile if possible""" while self.id in self.m.core.threadManager.processingIds(): @@ -186,8 +185,9 @@ class PyFile(object): sleep(0.1) self.abort = False - if hasattr(self, "plugin") and self.plugin and self.plugin.req: + if self.hasPlugin() and self.plugin.req: self.plugin.req.abortDownloads() + self.release() def finishIfDone(self): diff --git a/module/cli/ManageFiles.py b/module/cli/ManageFiles.py index f0f9ec93a..4d0377d9d 100644 --- a/module/cli/ManageFiles.py +++ b/module/cli/ManageFiles.py @@ -24,13 +24,13 @@ from time import time from Handler import Handler from printer import * -from module.remote.thriftbackend.thriftgen.pyload.Pyload import PackageData, PackageDoesNotExists +from module.Api import Destination, PackageData class ManageFiles(Handler): """ possibility to manage queue/collector """ def init(self): - self.target = 1 #queue and collector are swapped + self.target = Destination.Queue self.pos = 0 #position in queue self.package = -1 #choosen package self.mode = "" # move/delete/restart @@ -155,7 +155,7 @@ class ManageFiles(Handler): if self.cache and self.time + 2 < time(): return self.cache - if self.target == 1: + if self.target == Destination.Queue: data = self.client.getQueue() else: data = self.client.getCollector() diff --git a/module/remote/ThriftBackend.py b/module/remote/ThriftBackend.py index 1a56b0435..b4a2bb25e 100644 --- a/module/remote/ThriftBackend.py +++ b/module/remote/ThriftBackend.py @@ -19,7 +19,6 @@ from os.path import exists from module.remote.RemoteManager import BackendBase -from thriftbackend.Handler import Handler from thriftbackend.Processor import Processor from thriftbackend.Protocol import ProtocolFactory from thriftbackend.Socket import ServerSocket @@ -30,8 +29,7 @@ from thrift.server import TServer class ThriftBackend(BackendBase): def setup(self, host, port): - handler = Handler(self) - processor = Processor(handler) + processor = Processor(self.core.api) key = None cert = None diff --git a/module/remote/thriftbackend/Handler.py b/module/remote/thriftbackend/Handler.py index d518c6e88..998ace06b 100644 --- a/module/remote/thriftbackend/Handler.py +++ b/module/remote/thriftbackend/Handler.py @@ -34,7 +34,7 @@ class Handler(Iface): item = ConfigItem() item.name = key item.description = data["desc"] - item.value = str(data["value"]) if type(data["value"]) not in (str, unicode) else data["value"] + item.value = str(data["value"]) if type(data["value"]) != basestring else data["value"] item.type = data["type"] items.append(item) section.items = items @@ -59,7 +59,7 @@ class Handler(Iface): - value - section """ - self.serverMethods.set_conf_val(category, option, value, section) + pass def getConfig(self): c = self.serverMethods.get_config() diff --git a/module/remote/thriftbackend/pyload.thrift b/module/remote/thriftbackend/pyload.thrift index 1a3c2d4e5..07f36aec9 100644 --- a/module/remote/thriftbackend/pyload.thrift +++ b/module/remote/thriftbackend/pyload.thrift @@ -29,8 +29,8 @@ enum DownloadStatus { } enum Destination { - Queue, - Collector + Collector, + Queue } enum ElementType { @@ -62,7 +62,7 @@ struct ServerStatus { 2: i16 active, 3: i16 queue, 4: i16 total, - 5: i32 speed, + 5: i64 speed, 6: bool download, 7: bool reconnect } @@ -104,19 +104,8 @@ struct PackageData { 6: Destination dest, 7: i16 order, 8: Priority priority, - 9: list<FileData> links -} - -struct PackageInfo { - 1: PackageID pid, - 2: string name, - 3: string folder, - 4: string site, - 5: string password, - 6: Destination dest, - 7: i16 order, - 8: Priority priority, - 9: list<FileID> links + 9: optional list<FileID> fids, + 10: optional list<FileData> links } struct CaptchaTask { @@ -221,18 +210,26 @@ service Pyload { ResultID checkOnlineStatus(1: LinkList urls), map<PluginName, list<OnlineStatus>> pollResults(1: ResultID rid), - //downloads + // downloads - information list<DownloadInfo> statusDownloads(), - PackageID addPackage(1: string name, 2: LinkList links, 3: Destination dest), PackageData getPackageData(1: PackageID pid) throws (1: PackageDoesNotExists e), + PackageData getPackageInfo(1: PackageID pid) throws (1: PackageDoesNotExists e), FileData getFileData(1: FileID fid) throws (1: FileDoesNotExists e), - void deleteFiles(1: list<FileID> fids), - void deletePackages(1: list<PackageID> pids), - list<PackageInfo> getQueue(), - list<PackageInfo> getCollector(), + list<PackageData> getQueue(), + list<PackageData> getCollector(), list<PackageData> getQueueData(), list<PackageData> getCollectorData(), + map<i16, PackageID> getPackageOrder(1: Destination destination), + map<i16, FileID> getFileOrder(1: PackageID pid) + + // downloads - adding/deleting + PackageID addPackage(1: string name, 2: LinkList links, 3: Destination dest), void addFiles(1: PackageID pid, 2: LinkList links), + void uploadContainer(1: string filename, 2: binary data), + void deleteFiles(1: list<FileID> fids), + void deletePackages(1: list<PackageID> pids), + + // downloads - modifying void pushToQueue(1: PackageID pid), void pullFromQueue(1: PackageID pid), void restartPackage(1: PackageID pid), @@ -242,15 +239,13 @@ service Pyload { void stopDownloads(1: list<FileID> fids), void setPackageName(1: PackageID pid, 2: string name), void movePackage(1: Destination destination, 2: PackageID pid), - void uploadContainer(1: string filename, 2: binary data), void setPriority(1: PackageID pid, 2: Priority priority) void orderPackage(1: PackageID pid, 2: i16 position), void orderFile(1: FileID fid, 2: i16 position), - void setPackageData(1: PackageID pid, 2: map<string, string> data), + void setPackageData(1: PackageID pid, 2: map<string, string> data) throws (1: PackageDoesNotExists e), void deleteFinished(), void restartFailed(), - map<i16, PackageID> getPackageOrder(1: Destination destination), - map<i16, FileID> getFileOrder(1: PackageID pid) + //captcha bool isCaptchaWaiting(), diff --git a/module/remote/thriftbackend/thriftgen/pyload/Pyload-remote b/module/remote/thriftbackend/thriftgen/pyload/Pyload-remote index 5feb243ef..0e454c816 100755 --- a/module/remote/thriftbackend/thriftgen/pyload/Pyload-remote +++ b/module/remote/thriftbackend/thriftgen/pyload/Pyload-remote @@ -44,16 +44,20 @@ if len(sys.argv) <= 1 or sys.argv[1] == '--help': print ' ResultID checkOnlineStatus(LinkList urls)' print ' pollResults(ResultID rid)' print ' statusDownloads()' - print ' PackageID addPackage(string name, LinkList links, Destination dest)' print ' PackageData getPackageData(PackageID pid)' + print ' PackageData getPackageInfo(PackageID pid)' print ' FileData getFileData(FileID fid)' - print ' void deleteFiles( fids)' - print ' void deletePackages( pids)' print ' getQueue()' print ' getCollector()' print ' getQueueData()' print ' getCollectorData()' + print ' getPackageOrder(Destination destination)' + print ' getFileOrder(PackageID pid)' + print ' PackageID addPackage(string name, LinkList links, Destination dest)' print ' void addFiles(PackageID pid, LinkList links)' + print ' void uploadContainer(string filename, string data)' + print ' void deleteFiles( fids)' + print ' void deletePackages( pids)' print ' void pushToQueue(PackageID pid)' print ' void pullFromQueue(PackageID pid)' print ' void restartPackage(PackageID pid)' @@ -63,15 +67,12 @@ if len(sys.argv) <= 1 or sys.argv[1] == '--help': print ' void stopDownloads( fids)' print ' void setPackageName(PackageID pid, string name)' print ' void movePackage(Destination destination, PackageID pid)' - print ' void uploadContainer(string filename, string data)' print ' void setPriority(PackageID pid, Priority priority)' print ' void orderPackage(PackageID pid, i16 position)' print ' void orderFile(FileID fid, i16 position)' print ' void setPackageData(PackageID pid, data)' print ' void deleteFinished()' print ' void restartFailed()' - print ' getPackageOrder(Destination destination)' - print ' getFileOrder(PackageID pid)' print ' bool isCaptchaWaiting()' print ' CaptchaTask getCaptchaTask(bool exclusive)' print ' string getCaptchaTaskStatus(TaskID tid)' @@ -264,35 +265,23 @@ elif cmd == 'statusDownloads': sys.exit(1) pp.pprint(client.statusDownloads()) -elif cmd == 'addPackage': - if len(args) != 3: - print 'addPackage requires 3 args' - sys.exit(1) - pp.pprint(client.addPackage(args[0],eval(args[1]),eval(args[2]),)) - elif cmd == 'getPackageData': if len(args) != 1: print 'getPackageData requires 1 args' sys.exit(1) pp.pprint(client.getPackageData(eval(args[0]),)) -elif cmd == 'getFileData': - if len(args) != 1: - print 'getFileData requires 1 args' - sys.exit(1) - pp.pprint(client.getFileData(eval(args[0]),)) - -elif cmd == 'deleteFiles': +elif cmd == 'getPackageInfo': if len(args) != 1: - print 'deleteFiles requires 1 args' + print 'getPackageInfo requires 1 args' sys.exit(1) - pp.pprint(client.deleteFiles(eval(args[0]),)) + pp.pprint(client.getPackageInfo(eval(args[0]),)) -elif cmd == 'deletePackages': +elif cmd == 'getFileData': if len(args) != 1: - print 'deletePackages requires 1 args' + print 'getFileData requires 1 args' sys.exit(1) - pp.pprint(client.deletePackages(eval(args[0]),)) + pp.pprint(client.getFileData(eval(args[0]),)) elif cmd == 'getQueue': if len(args) != 0: @@ -318,12 +307,48 @@ elif cmd == 'getCollectorData': sys.exit(1) pp.pprint(client.getCollectorData()) +elif cmd == 'getPackageOrder': + if len(args) != 1: + print 'getPackageOrder requires 1 args' + sys.exit(1) + pp.pprint(client.getPackageOrder(eval(args[0]),)) + +elif cmd == 'getFileOrder': + if len(args) != 1: + print 'getFileOrder requires 1 args' + sys.exit(1) + pp.pprint(client.getFileOrder(eval(args[0]),)) + +elif cmd == 'addPackage': + if len(args) != 3: + print 'addPackage requires 3 args' + sys.exit(1) + pp.pprint(client.addPackage(args[0],eval(args[1]),eval(args[2]),)) + elif cmd == 'addFiles': if len(args) != 2: print 'addFiles requires 2 args' sys.exit(1) pp.pprint(client.addFiles(eval(args[0]),eval(args[1]),)) +elif cmd == 'uploadContainer': + if len(args) != 2: + print 'uploadContainer requires 2 args' + sys.exit(1) + pp.pprint(client.uploadContainer(args[0],args[1],)) + +elif cmd == 'deleteFiles': + if len(args) != 1: + print 'deleteFiles requires 1 args' + sys.exit(1) + pp.pprint(client.deleteFiles(eval(args[0]),)) + +elif cmd == 'deletePackages': + if len(args) != 1: + print 'deletePackages requires 1 args' + sys.exit(1) + pp.pprint(client.deletePackages(eval(args[0]),)) + elif cmd == 'pushToQueue': if len(args) != 1: print 'pushToQueue requires 1 args' @@ -378,12 +403,6 @@ elif cmd == 'movePackage': sys.exit(1) pp.pprint(client.movePackage(eval(args[0]),eval(args[1]),)) -elif cmd == 'uploadContainer': - if len(args) != 2: - print 'uploadContainer requires 2 args' - sys.exit(1) - pp.pprint(client.uploadContainer(args[0],args[1],)) - elif cmd == 'setPriority': if len(args) != 2: print 'setPriority requires 2 args' @@ -420,18 +439,6 @@ elif cmd == 'restartFailed': sys.exit(1) pp.pprint(client.restartFailed()) -elif cmd == 'getPackageOrder': - if len(args) != 1: - print 'getPackageOrder requires 1 args' - sys.exit(1) - pp.pprint(client.getPackageOrder(eval(args[0]),)) - -elif cmd == 'getFileOrder': - if len(args) != 1: - print 'getFileOrder requires 1 args' - sys.exit(1) - pp.pprint(client.getFileOrder(eval(args[0]),)) - elif cmd == 'isCaptchaWaiting': if len(args) != 0: print 'isCaptchaWaiting requires 0 args' diff --git a/module/remote/thriftbackend/thriftgen/pyload/Pyload.py b/module/remote/thriftbackend/thriftgen/pyload/Pyload.py index 187b7fa74..ec850b70c 100644 --- a/module/remote/thriftbackend/thriftgen/pyload/Pyload.py +++ b/module/remote/thriftbackend/thriftgen/pyload/Pyload.py @@ -109,16 +109,14 @@ class Iface(object): def statusDownloads(self, ): pass - def addPackage(self, name, links, dest): + def getPackageData(self, pid): """ Parameters: - - name - - links - - dest + - pid """ pass - def getPackageData(self, pid): + def getPackageInfo(self, pid): """ Parameters: - pid @@ -132,37 +130,68 @@ class Iface(object): """ pass - def deleteFiles(self, fids): + def getQueue(self, ): + pass + + def getCollector(self, ): + pass + + def getQueueData(self, ): + pass + + def getCollectorData(self, ): + pass + + def getPackageOrder(self, destination): """ Parameters: - - fids + - destination """ pass - def deletePackages(self, pids): + def getFileOrder(self, pid): """ Parameters: - - pids + - pid """ pass - def getQueue(self, ): + def addPackage(self, name, links, dest): + """ + Parameters: + - name + - links + - dest + """ pass - def getCollector(self, ): + def addFiles(self, pid, links): + """ + Parameters: + - pid + - links + """ pass - def getQueueData(self, ): + def uploadContainer(self, filename, data): + """ + Parameters: + - filename + - data + """ pass - def getCollectorData(self, ): + def deleteFiles(self, fids): + """ + Parameters: + - fids + """ pass - def addFiles(self, pid, links): + def deletePackages(self, pids): """ Parameters: - - pid - - links + - pids """ pass @@ -227,14 +256,6 @@ class Iface(object): """ pass - def uploadContainer(self, filename, data): - """ - Parameters: - - filename - - data - """ - pass - def setPriority(self, pid, priority): """ Parameters: @@ -273,20 +294,6 @@ class Iface(object): def restartFailed(self, ): pass - def getPackageOrder(self, destination): - """ - Parameters: - - destination - """ - pass - - def getFileOrder(self, pid): - """ - Parameters: - - pid - """ - pass - def isCaptchaWaiting(self, ): pass @@ -956,71 +963,69 @@ class Client(Iface): return result.success raise TApplicationException(TApplicationException.MISSING_RESULT, "statusDownloads failed: unknown result"); - def addPackage(self, name, links, dest): + def getPackageData(self, pid): """ Parameters: - - name - - links - - dest + - pid """ - self.send_addPackage(name, links, dest) - return self.recv_addPackage() + self.send_getPackageData(pid) + return self.recv_getPackageData() - def send_addPackage(self, name, links, dest): - self._oprot.writeMessageBegin('addPackage', TMessageType.CALL, self._seqid) - args = addPackage_args() - args.name = name - args.links = links - args.dest = dest + def send_getPackageData(self, pid): + self._oprot.writeMessageBegin('getPackageData', TMessageType.CALL, self._seqid) + args = getPackageData_args() + args.pid = pid args.write(self._oprot) self._oprot.writeMessageEnd() self._oprot.trans.flush() - def recv_addPackage(self, ): + def recv_getPackageData(self, ): (fname, mtype, rseqid) = self._iprot.readMessageBegin() if mtype == TMessageType.EXCEPTION: x = TApplicationException() x.read(self._iprot) self._iprot.readMessageEnd() raise x - result = addPackage_result() + result = getPackageData_result() result.read(self._iprot) self._iprot.readMessageEnd() if result.success is not None: return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "addPackage failed: unknown result"); + if result.e is not None: + raise result.e + raise TApplicationException(TApplicationException.MISSING_RESULT, "getPackageData failed: unknown result"); - def getPackageData(self, pid): + def getPackageInfo(self, pid): """ Parameters: - pid """ - self.send_getPackageData(pid) - return self.recv_getPackageData() + self.send_getPackageInfo(pid) + return self.recv_getPackageInfo() - def send_getPackageData(self, pid): - self._oprot.writeMessageBegin('getPackageData', TMessageType.CALL, self._seqid) - args = getPackageData_args() + def send_getPackageInfo(self, pid): + self._oprot.writeMessageBegin('getPackageInfo', TMessageType.CALL, self._seqid) + args = getPackageInfo_args() args.pid = pid args.write(self._oprot) self._oprot.writeMessageEnd() self._oprot.trans.flush() - def recv_getPackageData(self, ): + def recv_getPackageInfo(self, ): (fname, mtype, rseqid) = self._iprot.readMessageBegin() if mtype == TMessageType.EXCEPTION: x = TApplicationException() x.read(self._iprot) self._iprot.readMessageEnd() raise x - result = getPackageData_result() + result = getPackageInfo_result() result.read(self._iprot) self._iprot.readMessageEnd() if result.success is not None: return result.success if result.e is not None: raise result.e - raise TApplicationException(TApplicationException.MISSING_RESULT, "getPackageData failed: unknown result"); + raise TApplicationException(TApplicationException.MISSING_RESULT, "getPackageInfo failed: unknown result"); def getFileData(self, fid): """ @@ -1054,62 +1059,6 @@ class Client(Iface): raise result.e raise TApplicationException(TApplicationException.MISSING_RESULT, "getFileData failed: unknown result"); - def deleteFiles(self, fids): - """ - Parameters: - - fids - """ - self.send_deleteFiles(fids) - self.recv_deleteFiles() - - def send_deleteFiles(self, fids): - self._oprot.writeMessageBegin('deleteFiles', TMessageType.CALL, self._seqid) - args = deleteFiles_args() - args.fids = fids - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_deleteFiles(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = deleteFiles_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - return - - def deletePackages(self, pids): - """ - Parameters: - - pids - """ - self.send_deletePackages(pids) - self.recv_deletePackages() - - def send_deletePackages(self, pids): - self._oprot.writeMessageBegin('deletePackages', TMessageType.CALL, self._seqid) - args = deletePackages_args() - args.pids = pids - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_deletePackages(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = deletePackages_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - return - def getQueue(self, ): self.send_getQueue() return self.recv_getQueue() @@ -1210,6 +1159,100 @@ class Client(Iface): return result.success raise TApplicationException(TApplicationException.MISSING_RESULT, "getCollectorData failed: unknown result"); + def getPackageOrder(self, destination): + """ + Parameters: + - destination + """ + self.send_getPackageOrder(destination) + return self.recv_getPackageOrder() + + def send_getPackageOrder(self, destination): + self._oprot.writeMessageBegin('getPackageOrder', TMessageType.CALL, self._seqid) + args = getPackageOrder_args() + args.destination = destination + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_getPackageOrder(self, ): + (fname, mtype, rseqid) = self._iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(self._iprot) + self._iprot.readMessageEnd() + raise x + result = getPackageOrder_result() + result.read(self._iprot) + self._iprot.readMessageEnd() + if result.success is not None: + return result.success + raise TApplicationException(TApplicationException.MISSING_RESULT, "getPackageOrder failed: unknown result"); + + def getFileOrder(self, pid): + """ + Parameters: + - pid + """ + self.send_getFileOrder(pid) + return self.recv_getFileOrder() + + def send_getFileOrder(self, pid): + self._oprot.writeMessageBegin('getFileOrder', TMessageType.CALL, self._seqid) + args = getFileOrder_args() + args.pid = pid + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_getFileOrder(self, ): + (fname, mtype, rseqid) = self._iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(self._iprot) + self._iprot.readMessageEnd() + raise x + result = getFileOrder_result() + result.read(self._iprot) + self._iprot.readMessageEnd() + if result.success is not None: + return result.success + raise TApplicationException(TApplicationException.MISSING_RESULT, "getFileOrder failed: unknown result"); + + def addPackage(self, name, links, dest): + """ + Parameters: + - name + - links + - dest + """ + self.send_addPackage(name, links, dest) + return self.recv_addPackage() + + def send_addPackage(self, name, links, dest): + self._oprot.writeMessageBegin('addPackage', TMessageType.CALL, self._seqid) + args = addPackage_args() + args.name = name + args.links = links + args.dest = dest + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_addPackage(self, ): + (fname, mtype, rseqid) = self._iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(self._iprot) + self._iprot.readMessageEnd() + raise x + result = addPackage_result() + result.read(self._iprot) + self._iprot.readMessageEnd() + if result.success is not None: + return result.success + raise TApplicationException(TApplicationException.MISSING_RESULT, "addPackage failed: unknown result"); + def addFiles(self, pid, links): """ Parameters: @@ -1240,6 +1283,92 @@ class Client(Iface): self._iprot.readMessageEnd() return + def uploadContainer(self, filename, data): + """ + Parameters: + - filename + - data + """ + self.send_uploadContainer(filename, data) + self.recv_uploadContainer() + + def send_uploadContainer(self, filename, data): + self._oprot.writeMessageBegin('uploadContainer', TMessageType.CALL, self._seqid) + args = uploadContainer_args() + args.filename = filename + args.data = data + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_uploadContainer(self, ): + (fname, mtype, rseqid) = self._iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(self._iprot) + self._iprot.readMessageEnd() + raise x + result = uploadContainer_result() + result.read(self._iprot) + self._iprot.readMessageEnd() + return + + def deleteFiles(self, fids): + """ + Parameters: + - fids + """ + self.send_deleteFiles(fids) + self.recv_deleteFiles() + + def send_deleteFiles(self, fids): + self._oprot.writeMessageBegin('deleteFiles', TMessageType.CALL, self._seqid) + args = deleteFiles_args() + args.fids = fids + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_deleteFiles(self, ): + (fname, mtype, rseqid) = self._iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(self._iprot) + self._iprot.readMessageEnd() + raise x + result = deleteFiles_result() + result.read(self._iprot) + self._iprot.readMessageEnd() + return + + def deletePackages(self, pids): + """ + Parameters: + - pids + """ + self.send_deletePackages(pids) + self.recv_deletePackages() + + def send_deletePackages(self, pids): + self._oprot.writeMessageBegin('deletePackages', TMessageType.CALL, self._seqid) + args = deletePackages_args() + args.pids = pids + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_deletePackages(self, ): + (fname, mtype, rseqid) = self._iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(self._iprot) + self._iprot.readMessageEnd() + raise x + result = deletePackages_result() + result.read(self._iprot) + self._iprot.readMessageEnd() + return + def pushToQueue(self, pid): """ Parameters: @@ -1491,36 +1620,6 @@ class Client(Iface): self._iprot.readMessageEnd() return - def uploadContainer(self, filename, data): - """ - Parameters: - - filename - - data - """ - self.send_uploadContainer(filename, data) - self.recv_uploadContainer() - - def send_uploadContainer(self, filename, data): - self._oprot.writeMessageBegin('uploadContainer', TMessageType.CALL, self._seqid) - args = uploadContainer_args() - args.filename = filename - args.data = data - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_uploadContainer(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = uploadContainer_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - return - def setPriority(self, pid, priority): """ Parameters: @@ -1639,6 +1738,8 @@ class Client(Iface): result = setPackageData_result() result.read(self._iprot) self._iprot.readMessageEnd() + if result.e is not None: + raise result.e return def deleteFinished(self, ): @@ -1687,66 +1788,6 @@ class Client(Iface): self._iprot.readMessageEnd() return - def getPackageOrder(self, destination): - """ - Parameters: - - destination - """ - self.send_getPackageOrder(destination) - return self.recv_getPackageOrder() - - def send_getPackageOrder(self, destination): - self._oprot.writeMessageBegin('getPackageOrder', TMessageType.CALL, self._seqid) - args = getPackageOrder_args() - args.destination = destination - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getPackageOrder(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getPackageOrder_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "getPackageOrder failed: unknown result"); - - def getFileOrder(self, pid): - """ - Parameters: - - pid - """ - self.send_getFileOrder(pid) - return self.recv_getFileOrder() - - def send_getFileOrder(self, pid): - self._oprot.writeMessageBegin('getFileOrder', TMessageType.CALL, self._seqid) - args = getFileOrder_args() - args.pid = pid - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getFileOrder(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getFileOrder_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "getFileOrder failed: unknown result"); - def isCaptchaWaiting(self, ): self.send_isCaptchaWaiting() return self.recv_isCaptchaWaiting() @@ -2241,16 +2282,20 @@ class Processor(Iface, TProcessor): self._processMap["checkOnlineStatus"] = Processor.process_checkOnlineStatus self._processMap["pollResults"] = Processor.process_pollResults self._processMap["statusDownloads"] = Processor.process_statusDownloads - self._processMap["addPackage"] = Processor.process_addPackage self._processMap["getPackageData"] = Processor.process_getPackageData + self._processMap["getPackageInfo"] = Processor.process_getPackageInfo self._processMap["getFileData"] = Processor.process_getFileData - self._processMap["deleteFiles"] = Processor.process_deleteFiles - self._processMap["deletePackages"] = Processor.process_deletePackages self._processMap["getQueue"] = Processor.process_getQueue self._processMap["getCollector"] = Processor.process_getCollector self._processMap["getQueueData"] = Processor.process_getQueueData self._processMap["getCollectorData"] = Processor.process_getCollectorData + self._processMap["getPackageOrder"] = Processor.process_getPackageOrder + self._processMap["getFileOrder"] = Processor.process_getFileOrder + self._processMap["addPackage"] = Processor.process_addPackage self._processMap["addFiles"] = Processor.process_addFiles + self._processMap["uploadContainer"] = Processor.process_uploadContainer + self._processMap["deleteFiles"] = Processor.process_deleteFiles + self._processMap["deletePackages"] = Processor.process_deletePackages self._processMap["pushToQueue"] = Processor.process_pushToQueue self._processMap["pullFromQueue"] = Processor.process_pullFromQueue self._processMap["restartPackage"] = Processor.process_restartPackage @@ -2260,15 +2305,12 @@ class Processor(Iface, TProcessor): self._processMap["stopDownloads"] = Processor.process_stopDownloads self._processMap["setPackageName"] = Processor.process_setPackageName self._processMap["movePackage"] = Processor.process_movePackage - self._processMap["uploadContainer"] = Processor.process_uploadContainer self._processMap["setPriority"] = Processor.process_setPriority self._processMap["orderPackage"] = Processor.process_orderPackage self._processMap["orderFile"] = Processor.process_orderFile self._processMap["setPackageData"] = Processor.process_setPackageData self._processMap["deleteFinished"] = Processor.process_deleteFinished self._processMap["restartFailed"] = Processor.process_restartFailed - self._processMap["getPackageOrder"] = Processor.process_getPackageOrder - self._processMap["getFileOrder"] = Processor.process_getFileOrder self._processMap["isCaptchaWaiting"] = Processor.process_isCaptchaWaiting self._processMap["getCaptchaTask"] = Processor.process_getCaptchaTask self._processMap["getCaptchaTaskStatus"] = Processor.process_getCaptchaTaskStatus @@ -2532,27 +2574,30 @@ class Processor(Iface, TProcessor): oprot.writeMessageEnd() oprot.trans.flush() - def process_addPackage(self, seqid, iprot, oprot): - args = addPackage_args() + def process_getPackageData(self, seqid, iprot, oprot): + args = getPackageData_args() args.read(iprot) iprot.readMessageEnd() - result = addPackage_result() - result.success = self._handler.addPackage(args.name, args.links, args.dest) - oprot.writeMessageBegin("addPackage", TMessageType.REPLY, seqid) + result = getPackageData_result() + try: + result.success = self._handler.getPackageData(args.pid) + except PackageDoesNotExists, e: + result.e = e + oprot.writeMessageBegin("getPackageData", TMessageType.REPLY, seqid) result.write(oprot) oprot.writeMessageEnd() oprot.trans.flush() - def process_getPackageData(self, seqid, iprot, oprot): - args = getPackageData_args() + def process_getPackageInfo(self, seqid, iprot, oprot): + args = getPackageInfo_args() args.read(iprot) iprot.readMessageEnd() - result = getPackageData_result() + result = getPackageInfo_result() try: - result.success = self._handler.getPackageData(args.pid) + result.success = self._handler.getPackageInfo(args.pid) except PackageDoesNotExists, e: result.e = e - oprot.writeMessageBegin("getPackageData", TMessageType.REPLY, seqid) + oprot.writeMessageBegin("getPackageInfo", TMessageType.REPLY, seqid) result.write(oprot) oprot.writeMessageEnd() oprot.trans.flush() @@ -2571,28 +2616,6 @@ class Processor(Iface, TProcessor): oprot.writeMessageEnd() oprot.trans.flush() - def process_deleteFiles(self, seqid, iprot, oprot): - args = deleteFiles_args() - args.read(iprot) - iprot.readMessageEnd() - result = deleteFiles_result() - self._handler.deleteFiles(args.fids) - oprot.writeMessageBegin("deleteFiles", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_deletePackages(self, seqid, iprot, oprot): - args = deletePackages_args() - args.read(iprot) - iprot.readMessageEnd() - result = deletePackages_result() - self._handler.deletePackages(args.pids) - oprot.writeMessageBegin("deletePackages", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - def process_getQueue(self, seqid, iprot, oprot): args = getQueue_args() args.read(iprot) @@ -2637,6 +2660,39 @@ class Processor(Iface, TProcessor): oprot.writeMessageEnd() oprot.trans.flush() + def process_getPackageOrder(self, seqid, iprot, oprot): + args = getPackageOrder_args() + args.read(iprot) + iprot.readMessageEnd() + result = getPackageOrder_result() + result.success = self._handler.getPackageOrder(args.destination) + oprot.writeMessageBegin("getPackageOrder", TMessageType.REPLY, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_getFileOrder(self, seqid, iprot, oprot): + args = getFileOrder_args() + args.read(iprot) + iprot.readMessageEnd() + result = getFileOrder_result() + result.success = self._handler.getFileOrder(args.pid) + oprot.writeMessageBegin("getFileOrder", TMessageType.REPLY, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_addPackage(self, seqid, iprot, oprot): + args = addPackage_args() + args.read(iprot) + iprot.readMessageEnd() + result = addPackage_result() + result.success = self._handler.addPackage(args.name, args.links, args.dest) + oprot.writeMessageBegin("addPackage", TMessageType.REPLY, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + def process_addFiles(self, seqid, iprot, oprot): args = addFiles_args() args.read(iprot) @@ -2648,6 +2704,39 @@ class Processor(Iface, TProcessor): oprot.writeMessageEnd() oprot.trans.flush() + def process_uploadContainer(self, seqid, iprot, oprot): + args = uploadContainer_args() + args.read(iprot) + iprot.readMessageEnd() + result = uploadContainer_result() + self._handler.uploadContainer(args.filename, args.data) + oprot.writeMessageBegin("uploadContainer", TMessageType.REPLY, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_deleteFiles(self, seqid, iprot, oprot): + args = deleteFiles_args() + args.read(iprot) + iprot.readMessageEnd() + result = deleteFiles_result() + self._handler.deleteFiles(args.fids) + oprot.writeMessageBegin("deleteFiles", TMessageType.REPLY, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_deletePackages(self, seqid, iprot, oprot): + args = deletePackages_args() + args.read(iprot) + iprot.readMessageEnd() + result = deletePackages_result() + self._handler.deletePackages(args.pids) + oprot.writeMessageBegin("deletePackages", TMessageType.REPLY, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + def process_pushToQueue(self, seqid, iprot, oprot): args = pushToQueue_args() args.read(iprot) @@ -2747,17 +2836,6 @@ class Processor(Iface, TProcessor): oprot.writeMessageEnd() oprot.trans.flush() - def process_uploadContainer(self, seqid, iprot, oprot): - args = uploadContainer_args() - args.read(iprot) - iprot.readMessageEnd() - result = uploadContainer_result() - self._handler.uploadContainer(args.filename, args.data) - oprot.writeMessageBegin("uploadContainer", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - def process_setPriority(self, seqid, iprot, oprot): args = setPriority_args() args.read(iprot) @@ -2796,7 +2874,10 @@ class Processor(Iface, TProcessor): args.read(iprot) iprot.readMessageEnd() result = setPackageData_result() - self._handler.setPackageData(args.pid, args.data) + try: + self._handler.setPackageData(args.pid, args.data) + except PackageDoesNotExists, e: + result.e = e oprot.writeMessageBegin("setPackageData", TMessageType.REPLY, seqid) result.write(oprot) oprot.writeMessageEnd() @@ -2824,28 +2905,6 @@ class Processor(Iface, TProcessor): oprot.writeMessageEnd() oprot.trans.flush() - def process_getPackageOrder(self, seqid, iprot, oprot): - args = getPackageOrder_args() - args.read(iprot) - iprot.readMessageEnd() - result = getPackageOrder_result() - result.success = self._handler.getPackageOrder(args.destination) - oprot.writeMessageBegin("getPackageOrder", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getFileOrder(self, seqid, iprot, oprot): - args = getFileOrder_args() - args.read(iprot) - iprot.readMessageEnd() - result = getFileOrder_result() - result.success = self._handler.getFileOrder(args.pid) - oprot.writeMessageBegin("getFileOrder", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - def process_isCaptchaWaiting(self, seqid, iprot, oprot): args = isCaptchaWaiting_args() args.read(iprot) @@ -3642,52 +3701,48 @@ class statusDownloads_result(TBase): self.success = success -class addPackage_args(TBase): +class getPackageData_args(TBase): """ Attributes: - - name - - links - - dest + - pid """ __slots__ = [ - 'name', - 'links', - 'dest', + 'pid', ] thrift_spec = ( None, # 0 - (1, TType.STRING, 'name', None, None, ), # 1 - (2, TType.LIST, 'links', (TType.STRING,None), None, ), # 2 - (3, TType.I32, 'dest', None, None, ), # 3 + (1, TType.I32, 'pid', None, None, ), # 1 ) - def __init__(self, name=None, links=None, dest=None,): - self.name = name - self.links = links - self.dest = dest + def __init__(self, pid=None,): + self.pid = pid -class addPackage_result(TBase): +class getPackageData_result(TBase): """ Attributes: - success + - e """ __slots__ = [ 'success', + 'e', ] thrift_spec = ( - (0, TType.I32, 'success', None, None, ), # 0 + (0, TType.STRUCT, 'success', (PackageData, PackageData.thrift_spec), None, ), # 0 + (1, TType.STRUCT, 'e', (PackageDoesNotExists, PackageDoesNotExists.thrift_spec), None, ), # 1 ) - def __init__(self, success=None,): + def __init__(self, success=None, e=None,): self.success = success + self.e = e -class getPackageData_args(TBase): +class getPackageInfo_args(TBase): """ Attributes: - pid @@ -3706,7 +3761,7 @@ class getPackageData_args(TBase): self.pid = pid -class getPackageData_result(TBase): +class getPackageInfo_result(TBase): """ Attributes: - success @@ -3769,26 +3824,34 @@ class getFileData_result(TBase): self.e = e -class deleteFiles_args(TBase): +class getQueue_args(TBase): + + __slots__ = [ + ] + + thrift_spec = ( + ) + + +class getQueue_result(TBase): """ Attributes: - - fids + - success """ __slots__ = [ - 'fids', + 'success', ] thrift_spec = ( - None, # 0 - (1, TType.LIST, 'fids', (TType.I32,None), None, ), # 1 + (0, TType.LIST, 'success', (TType.STRUCT,(PackageData, PackageData.thrift_spec)), None, ), # 0 ) - def __init__(self, fids=None,): - self.fids = fids + def __init__(self, success=None,): + self.success = success -class deleteFiles_result(TBase): +class getCollector_args(TBase): __slots__ = [ ] @@ -3797,26 +3860,25 @@ class deleteFiles_result(TBase): ) -class deletePackages_args(TBase): +class getCollector_result(TBase): """ Attributes: - - pids + - success """ __slots__ = [ - 'pids', + 'success', ] thrift_spec = ( - None, # 0 - (1, TType.LIST, 'pids', (TType.I32,None), None, ), # 1 + (0, TType.LIST, 'success', (TType.STRUCT,(PackageData, PackageData.thrift_spec)), None, ), # 0 ) - def __init__(self, pids=None,): - self.pids = pids + def __init__(self, success=None,): + self.success = success -class deletePackages_result(TBase): +class getQueueData_args(TBase): __slots__ = [ ] @@ -3825,16 +3887,34 @@ class deletePackages_result(TBase): ) -class getQueue_args(TBase): +class getQueueData_result(TBase): + """ + Attributes: + - success + """ __slots__ = [ + 'success', ] thrift_spec = ( + (0, TType.LIST, 'success', (TType.STRUCT,(PackageData, PackageData.thrift_spec)), None, ), # 0 ) + def __init__(self, success=None,): + self.success = success -class getQueue_result(TBase): + +class getCollectorData_args(TBase): + + __slots__ = [ + ] + + thrift_spec = ( + ) + + +class getCollectorData_result(TBase): """ Attributes: - success @@ -3845,23 +3925,33 @@ class getQueue_result(TBase): ] thrift_spec = ( - (0, TType.LIST, 'success', (TType.STRUCT,(PackageInfo, PackageInfo.thrift_spec)), None, ), # 0 + (0, TType.LIST, 'success', (TType.STRUCT,(PackageData, PackageData.thrift_spec)), None, ), # 0 ) def __init__(self, success=None,): self.success = success -class getCollector_args(TBase): +class getPackageOrder_args(TBase): + """ + Attributes: + - destination + """ __slots__ = [ + 'destination', ] thrift_spec = ( + None, # 0 + (1, TType.I32, 'destination', None, None, ), # 1 ) + def __init__(self, destination=None,): + self.destination = destination -class getCollector_result(TBase): + +class getPackageOrder_result(TBase): """ Attributes: - success @@ -3872,23 +3962,33 @@ class getCollector_result(TBase): ] thrift_spec = ( - (0, TType.LIST, 'success', (TType.STRUCT,(PackageInfo, PackageInfo.thrift_spec)), None, ), # 0 + (0, TType.MAP, 'success', (TType.I16,None,TType.I32,None), None, ), # 0 ) def __init__(self, success=None,): self.success = success -class getQueueData_args(TBase): +class getFileOrder_args(TBase): + """ + Attributes: + - pid + """ __slots__ = [ + 'pid', ] thrift_spec = ( + None, # 0 + (1, TType.I32, 'pid', None, None, ), # 1 ) + def __init__(self, pid=None,): + self.pid = pid -class getQueueData_result(TBase): + +class getFileOrder_result(TBase): """ Attributes: - success @@ -3899,23 +3999,41 @@ class getQueueData_result(TBase): ] thrift_spec = ( - (0, TType.LIST, 'success', (TType.STRUCT,(PackageData, PackageData.thrift_spec)), None, ), # 0 + (0, TType.MAP, 'success', (TType.I16,None,TType.I32,None), None, ), # 0 ) def __init__(self, success=None,): self.success = success -class getCollectorData_args(TBase): +class addPackage_args(TBase): + """ + Attributes: + - name + - links + - dest + """ __slots__ = [ + 'name', + 'links', + 'dest', ] thrift_spec = ( + None, # 0 + (1, TType.STRING, 'name', None, None, ), # 1 + (2, TType.LIST, 'links', (TType.STRING,None), None, ), # 2 + (3, TType.I32, 'dest', None, None, ), # 3 ) + def __init__(self, name=None, links=None, dest=None,): + self.name = name + self.links = links + self.dest = dest + -class getCollectorData_result(TBase): +class addPackage_result(TBase): """ Attributes: - success @@ -3926,7 +4044,7 @@ class getCollectorData_result(TBase): ] thrift_spec = ( - (0, TType.LIST, 'success', (TType.STRUCT,(PackageData, PackageData.thrift_spec)), None, ), # 0 + (0, TType.I32, 'success', None, None, ), # 0 ) def __init__(self, success=None,): @@ -3965,6 +4083,94 @@ class addFiles_result(TBase): ) +class uploadContainer_args(TBase): + """ + Attributes: + - filename + - data + """ + + __slots__ = [ + 'filename', + 'data', + ] + + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'filename', None, None, ), # 1 + (2, TType.STRING, 'data', None, None, ), # 2 + ) + + def __init__(self, filename=None, data=None,): + self.filename = filename + self.data = data + + +class uploadContainer_result(TBase): + + __slots__ = [ + ] + + thrift_spec = ( + ) + + +class deleteFiles_args(TBase): + """ + Attributes: + - fids + """ + + __slots__ = [ + 'fids', + ] + + thrift_spec = ( + None, # 0 + (1, TType.LIST, 'fids', (TType.I32,None), None, ), # 1 + ) + + def __init__(self, fids=None,): + self.fids = fids + + +class deleteFiles_result(TBase): + + __slots__ = [ + ] + + thrift_spec = ( + ) + + +class deletePackages_args(TBase): + """ + Attributes: + - pids + """ + + __slots__ = [ + 'pids', + ] + + thrift_spec = ( + None, # 0 + (1, TType.LIST, 'pids', (TType.I32,None), None, ), # 1 + ) + + def __init__(self, pids=None,): + self.pids = pids + + +class deletePackages_result(TBase): + + __slots__ = [ + ] + + thrift_spec = ( + ) + + class pushToQueue_args(TBase): """ Attributes: @@ -4215,38 +4421,6 @@ class movePackage_result(TBase): ) -class uploadContainer_args(TBase): - """ - Attributes: - - filename - - data - """ - - __slots__ = [ - 'filename', - 'data', - ] - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'filename', None, None, ), # 1 - (2, TType.STRING, 'data', None, None, ), # 2 - ) - - def __init__(self, filename=None, data=None,): - self.filename = filename - self.data = data - - -class uploadContainer_result(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - class setPriority_args(TBase): """ Attributes: @@ -4367,13 +4541,23 @@ class setPackageData_args(TBase): class setPackageData_result(TBase): + """ + Attributes: + - e + """ __slots__ = [ + 'e', ] thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'e', (PackageDoesNotExists, PackageDoesNotExists.thrift_spec), None, ), # 1 ) + def __init__(self, e=None,): + self.e = e + class deleteFinished_args(TBase): @@ -4411,80 +4595,6 @@ class restartFailed_result(TBase): ) -class getPackageOrder_args(TBase): - """ - Attributes: - - destination - """ - - __slots__ = [ - 'destination', - ] - - thrift_spec = ( - None, # 0 - (1, TType.I32, 'destination', None, None, ), # 1 - ) - - def __init__(self, destination=None,): - self.destination = destination - - -class getPackageOrder_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.MAP, 'success', (TType.I16,None,TType.I32,None), None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class getFileOrder_args(TBase): - """ - Attributes: - - pid - """ - - __slots__ = [ - 'pid', - ] - - thrift_spec = ( - None, # 0 - (1, TType.I32, 'pid', None, None, ), # 1 - ) - - def __init__(self, pid=None,): - self.pid = pid - - -class getFileOrder_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.MAP, 'success', (TType.I16,None,TType.I32,None), None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - class isCaptchaWaiting_args(TBase): __slots__ = [ diff --git a/module/remote/thriftbackend/thriftgen/pyload/ttypes.py b/module/remote/thriftbackend/thriftgen/pyload/ttypes.py index 0b456cc55..da8a2477e 100644 --- a/module/remote/thriftbackend/thriftgen/pyload/ttypes.py +++ b/module/remote/thriftbackend/thriftgen/pyload/ttypes.py @@ -65,17 +65,17 @@ class DownloadStatus(TBase): } class Destination(TBase): - Queue = 0 - Collector = 1 + Collector = 0 + Queue = 1 _VALUES_TO_NAMES = { - 0: "Queue", - 1: "Collector", + 0: "Collector", + 1: "Queue", } _NAMES_TO_VALUES = { - "Queue": 0, - "Collector": 1, + "Collector": 0, + "Queue": 1, } class ElementType(TBase): @@ -200,7 +200,7 @@ class ServerStatus(TBase): (2, TType.I16, 'active', None, None, ), # 2 (3, TType.I16, 'queue', None, None, ), # 3 (4, TType.I16, 'total', None, None, ), # 4 - (5, TType.I32, 'speed', None, None, ), # 5 + (5, TType.I64, 'speed', None, None, ), # 5 (6, TType.BOOL, 'download', None, None, ), # 6 (7, TType.BOOL, 'reconnect', None, None, ), # 7 ) @@ -347,6 +347,7 @@ class PackageData(TBase): - dest - order - priority + - fids - links """ @@ -359,6 +360,7 @@ class PackageData(TBase): 'dest', 'order', 'priority', + 'fids', 'links', ] @@ -372,61 +374,11 @@ class PackageData(TBase): (6, TType.I32, 'dest', None, None, ), # 6 (7, TType.I16, 'order', None, None, ), # 7 (8, TType.BYTE, 'priority', None, None, ), # 8 - (9, TType.LIST, 'links', (TType.STRUCT,(FileData, FileData.thrift_spec)), None, ), # 9 + (9, TType.LIST, 'fids', (TType.I32,None), None, ), # 9 + (10, TType.LIST, 'links', (TType.STRUCT,(FileData, FileData.thrift_spec)), None, ), # 10 ) - def __init__(self, pid=None, name=None, folder=None, site=None, password=None, dest=None, order=None, priority=None, links=None,): - self.pid = pid - self.name = name - self.folder = folder - self.site = site - self.password = password - self.dest = dest - self.order = order - self.priority = priority - self.links = links - - -class PackageInfo(TBase): - """ - Attributes: - - pid - - name - - folder - - site - - password - - dest - - order - - priority - - links - """ - - __slots__ = [ - 'pid', - 'name', - 'folder', - 'site', - 'password', - 'dest', - 'order', - 'priority', - 'links', - ] - - thrift_spec = ( - None, # 0 - (1, TType.I32, 'pid', None, None, ), # 1 - (2, TType.STRING, 'name', None, None, ), # 2 - (3, TType.STRING, 'folder', None, None, ), # 3 - (4, TType.STRING, 'site', None, None, ), # 4 - (5, TType.STRING, 'password', None, None, ), # 5 - (6, TType.I32, 'dest', None, None, ), # 6 - (7, TType.I16, 'order', None, None, ), # 7 - (8, TType.BYTE, 'priority', None, None, ), # 8 - (9, TType.LIST, 'links', (TType.I32,None), None, ), # 9 - ) - - def __init__(self, pid=None, name=None, folder=None, site=None, password=None, dest=None, order=None, priority=None, links=None,): + def __init__(self, pid=None, name=None, folder=None, site=None, password=None, dest=None, order=None, priority=None, fids=None, links=None,): self.pid = pid self.name = name self.folder = folder @@ -435,6 +387,7 @@ class PackageInfo(TBase): self.dest = dest self.order = order self.priority = priority + self.fids = fids self.links = links diff --git a/module/unescape.py b/module/unescape.py index 41a23be5b..d8999e077 100644 --- a/module/unescape.py +++ b/module/unescape.py @@ -1,54 +1,3 @@ -from htmlentitydefs import name2codepoint as n2cp -from urllib import unquote -import re - -def substitute_entity(match): - ent = match.group(2) - if match.group(1) == "#": - return unichr(int(ent)) - else: - cp = n2cp.get(ent) - if cp: - return unichr(cp) - else: - return match.group() - -def unescape(string): - entity_re = re.compile("&(#?)(\d{1,5}|\w{1,8});") - return entity_re.subn(substitute_entity, unquote(string))[0] - - -""" -import re - -def unescape(text): - def fixup(m): - text = m.group(0) - if text[:2] == "&#": - # character reference - try: - if text[:3] == "&#x": - return unichr(int(text[3:-1], 16)) - else: - return unichr(int(text[2:-1])) - except ValueError: - print "erreur de valeur" - pass - else: - # named entity - try: - if text[1:-1] == "amp": - text = "&amp;" - elif text[1:-1] == "gt": - text = "&gt;" - elif text[1:-1] == "lt": - text = "&lt;" - else: - print text[1:-1] - text = unichr(htmlentitydefs.name2codepoint[text[1:-1]]) - except KeyError: - print "keyerror" - pass - return text # leave as is - return re.sub("&#?\w+;", fixup, text) -""" +from module.utils import html_unescape +#deprecated +unescape = html_unescape
\ No newline at end of file diff --git a/pyLoadCli.py b/pyLoadCli.py index 12e601029..f572cf7e5 100755 --- a/pyLoadCli.py +++ b/pyLoadCli.py @@ -30,20 +30,23 @@ from threading import Thread, Lock from time import sleep from traceback import print_exc +import ConfigParser + from codecs import getwriter if os.name == "nt": enc = "cp850" else: enc = "utf8" + sys.stdout = getwriter(enc)(sys.stdout, errors = "replace") from module import InitHomeDir from module.cli.printer import * from module.cli import AddPackage, ManageFiles +from module.Api import Destination from module.utils import formatSize, decode -import ConfigParser from module.remote.thriftbackend.ThriftClient import ThriftClient, NoConnection, NoSSL, WrongLogin, ConnectionClosed from module.lib.Getch import Getch from module.lib.rename_process import renameProcess @@ -233,7 +236,7 @@ class Cli: self.setHandler(ManageFiles) elif char == "3": self.setHandler(ManageFiles) - self.bodyHandler.target = 0 + self.bodyHandler.target = Destination.Collector elif char == "4": self.client.togglePause() self.setInput() diff --git a/pyLoadCore.py b/pyLoadCore.py index 18870023e..1c0c39403 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -137,7 +137,10 @@ class Core(object): print "" print "pyLoad v%s 2008-2011 the pyLoad Team" % CURRENT_VERSION print "" - print "Usage: [python] pyLoadCore.py [options]" + if sys.argv[0].endswith(".py"): + print "Usage: python pyLoadCore.py [options]" + else: + print "Usage: pyLoadCore [options]" print "" print "<Options>" print " -v, --version", " " * 10, "Print version to terminal" @@ -148,9 +151,9 @@ class Core(object): print " -s, --setup", " " * 12, "Run Setup Assistent" print " --configdir=<dir>", " " * 6, "Run with <dir> as config directory" print " --changedir", " "* 12, "Change config dir permanently" - print " --daemon", " " * 15, "Daemonize after start" + print " --daemon", " " * 15, "Daemonmize after start" print " --status", " " * 15, "Display pid if running or False" - print " -q, --quit", " " * 13, "Try to quit running pyLoad" + print " -q, --quit", " " * 13, "Quit running pyLoad instance" print " -h, --help", " " * 13, "Display this help screen" print "" @@ -231,6 +234,8 @@ class Core(object): def start(self, rpc=True, web=True): """ starts the fun :D """ + + self.version = CURRENT_VERSION if not exists("pyload.conf"): from module.setup import Setup @@ -331,7 +336,10 @@ class Core(object): self.lastClientConnected = 0 + from module.Api import Api + self.server_methods = ServerMethods(self) + self.api = Api(self) self.scheduler = Scheduler(self) @@ -543,12 +551,9 @@ class Core(object): return join(pypath, * args) - #################################### - ########## XMLRPC Methods ########## - #################################### - +#TODO: replace with api class class ServerMethods(): - """ methods that can be used by clients with xmlrpc connection""" + """ deprecated""" def __init__(self, core): self.core = core |