diff options
Diffstat (limited to 'module/remote')
36 files changed, 3320 insertions, 8323 deletions
diff --git a/module/remote/JSONClient.py b/module/remote/JSONClient.py new file mode 100644 index 000000000..a2c07a132 --- /dev/null +++ b/module/remote/JSONClient.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from urllib import urlopen, urlencode +from httplib import UNAUTHORIZED, FORBIDDEN + +from json_converter import loads, dumps +from apitypes import Unauthorized, Forbidden + +class JSONClient: + URL = "http://localhost:8001/api" + + def __init__(self, url=None): + self.url = url or self.URL + self.session = None + + def request(self, path, data): + ret = urlopen(self.url + path, urlencode(data)) + if ret.code == 400: + raise loads(ret.read()) + if ret.code == 404: + raise AttributeError("Unknown Method") + if ret.code == 500: + raise Exception("Remote Exception") + if ret.code == UNAUTHORIZED: + raise Unauthorized() + if ret.code == FORBIDDEN: + raise Forbidden() + return ret.read() + + def login(self, username, password): + self.session = loads(self.request("/login", {'username': username, 'password': password})) + return self.session + + def logout(self): + self.call("logout") + self.session = None + + def call(self, func, *args, **kwargs): + # Add the current session + kwargs["session"] = self.session + path = "/" + func + "/" + "/".join(dumps(x) for x in args) + data = dict((k, dumps(v)) for k, v in kwargs.iteritems()) + rep = self.request(path, data) + return loads(rep) + + def __getattr__(self, item): + def call(*args, **kwargs): + return self.call(item, *args, **kwargs) + + return call + +if __name__ == "__main__": + api = JSONClient() + api.login("User", "test") + print api.getServerVersion()
\ No newline at end of file diff --git a/module/remote/RemoteManager.py b/module/remote/RemoteManager.py index 36eb52a4a..dd567653b 100644 --- a/module/remote/RemoteManager.py +++ b/module/remote/RemoteManager.py @@ -63,9 +63,7 @@ class RemoteManager(): self.backends = [] if self.core.remote: - self.available.append("ThriftBackend") -# else: -# self.available.append("SocketBackend") + self.available.append("WebSocketBackend") def startBackends(self): diff --git a/module/remote/SocketBackend.py b/module/remote/SocketBackend.py deleted file mode 100644 index 1a157cf1d..000000000 --- a/module/remote/SocketBackend.py +++ /dev/null @@ -1,25 +0,0 @@ -# -*- coding: utf-8 -*- - -import SocketServer - -from RemoteManager import BackendBase - -class RequestHandler(SocketServer.BaseRequestHandler): - - def setup(self): - pass - - def handle(self): - - print self.request.recv(1024) - - - -class SocketBackend(BackendBase): - - def setup(self, host, port): - #local only - self.server = SocketServer.ThreadingTCPServer(("localhost", port), RequestHandler) - - def serve(self): - self.server.serve_forever() diff --git a/module/remote/ThriftBackend.py b/module/remote/ThriftBackend.py deleted file mode 100644 index b4a2bb25e..000000000 --- a/module/remote/ThriftBackend.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- 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: mkaay, RaNaN -""" -from os.path import exists - -from module.remote.RemoteManager import BackendBase - -from thriftbackend.Processor import Processor -from thriftbackend.Protocol import ProtocolFactory -from thriftbackend.Socket import ServerSocket -from thriftbackend.Transport import TransportFactory -#from thriftbackend.Transport import TransportFactoryCompressed - -from thrift.server import TServer - -class ThriftBackend(BackendBase): - def setup(self, host, port): - processor = Processor(self.core.api) - - key = None - cert = None - - if self.core.config['ssl']['activated']: - if exists(self.core.config['ssl']['cert']) and exists(self.core.config['ssl']['key']): - self.core.log.info(_("Using SSL ThriftBackend")) - key = self.core.config['ssl']['key'] - cert = self.core.config['ssl']['cert'] - - transport = ServerSocket(port, host, key, cert) - - -# tfactory = TransportFactoryCompressed() - tfactory = TransportFactory() - pfactory = ProtocolFactory() - - self.server = TServer.TThreadedServer(processor, transport, tfactory, pfactory) - #self.server = TNonblockingServer.TNonblockingServer(processor, transport, tfactory, pfactory) - - #server = TServer.TThreadPoolServer(processor, transport, tfactory, pfactory) - - def serve(self): - self.server.serve() diff --git a/module/remote/WSClient.py b/module/remote/WSClient.py new file mode 100644 index 000000000..793a6ef28 --- /dev/null +++ b/module/remote/WSClient.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from websocket import create_connection +from httplib import UNAUTHORIZED, FORBIDDEN + +from json_converter import loads, dumps +from apitypes import Unauthorized, Forbidden + +class WSClient: + URL = "ws://localhost:7227/api" + + def __init__(self, url=None): + self.url = url or self.URL + self.ws = None + + def connect(self): + self.ws = create_connection(self.URL) + + def close(self): + self.ws.close() + + def login(self, username, password): + if not self.ws: self.connect() + return self.call("login", username, password) + + def call(self, func, *args, **kwargs): + if not self.ws: + raise Exception("Not Connected") + + if kwargs: + self.ws.send(dumps([func, args, kwargs])) + else: # omit kwargs + self.ws.send(dumps([func, args])) + + code, result = loads(self.ws.recv()) + if code == 400: + raise result + if code == 404: + raise AttributeError("Unknown Method") + elif code == 500: + raise Exception("Remote Exception: %s" % result) + elif code == UNAUTHORIZED: + raise Unauthorized() + elif code == FORBIDDEN: + raise Forbidden() + + return result + + def __getattr__(self, item): + def call(*args, **kwargs): + return self.call(item, *args, **kwargs) + + return call + +if __name__ == "__main__": + api = WSClient() + api.login("User", "test") + print api.getServerVersion()
\ No newline at end of file diff --git a/module/remote/WebSocketBackend.py b/module/remote/WebSocketBackend.py new file mode 100644 index 000000000..2d22664c6 --- /dev/null +++ b/module/remote/WebSocketBackend.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +############################################################################### +# Copyright(c) 2008-2012 pyLoad Team +# http://www.pyload.org +# +# This file is part of pyLoad. +# pyLoad is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# Subjected to the terms and conditions in LICENSE +# +# @author: RaNaN +############################################################################### + +import logging + +from module.remote.RemoteManager import BackendBase + +from mod_pywebsocket import util +def get_class_logger(o=None): + return logging.getLogger('log') + +# Monkey patch for our logger +util.get_class_logger = get_class_logger + +class WebSocketBackend(BackendBase): + def setup(self, host, port): + + from wsbackend.Server import WebSocketServer, DefaultOptions + from wsbackend.Dispatcher import Dispatcher + from wsbackend.ApiHandler import ApiHandler + from wsbackend.AsyncHandler import AsyncHandler + + options = DefaultOptions() + options.server_host = host + options.port = port + options.dispatcher = Dispatcher() + options.dispatcher.addHandler(ApiHandler.PATH, ApiHandler(self.core.api)) + options.dispatcher.addHandler(AsyncHandler.PATH, AsyncHandler(self.core.api)) + + self.server = WebSocketServer(options) + + + def serve(self): + self.server.serve_forever() diff --git a/module/remote/__init__.py b/module/remote/__init__.py index 9298f5337..e69de29bb 100644 --- a/module/remote/__init__.py +++ b/module/remote/__init__.py @@ -1,2 +0,0 @@ -# -*- coding: utf-8 -*- -activated = True diff --git a/module/remote/apitypes.py b/module/remote/apitypes.py new file mode 100644 index 000000000..196491083 --- /dev/null +++ b/module/remote/apitypes.py @@ -0,0 +1,536 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Autogenerated by pyload +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +class BaseObject(object): + __slots__ = [] + + def __str__(self): + return "<%s %s>" % (self.__class__.__name__, ", ".join("%s=%s" % (k,getattr(self,k)) for k in self.__slots__)) + +class ExceptionObject(Exception): + __slots__ = [] + +class DownloadState: + All = 0 + Finished = 1 + Unfinished = 2 + Failed = 3 + Unmanaged = 4 + +class DownloadStatus: + NA = 0 + Offline = 1 + Online = 2 + Queued = 3 + Paused = 4 + Finished = 5 + Skipped = 6 + Failed = 7 + Starting = 8 + Waiting = 9 + Downloading = 10 + TempOffline = 11 + Aborted = 12 + Decrypting = 13 + Processing = 14 + Custom = 15 + Unknown = 16 + +class FileStatus: + Ok = 0 + Missing = 1 + Remote = 2 + +class InputType: + NA = 0 + Text = 1 + Int = 2 + File = 3 + Folder = 4 + Textbox = 5 + Password = 6 + Bool = 7 + Click = 8 + Select = 9 + Multiple = 10 + List = 11 + Table = 12 + +class Interaction: + All = 0 + Notification = 1 + Captcha = 2 + Query = 4 + +class MediaType: + All = 0 + Other = 1 + Audio = 2 + Image = 4 + Video = 8 + Document = 16 + Archive = 32 + +class PackageStatus: + Ok = 0 + Paused = 1 + Folder = 2 + Remote = 3 + +class Permission: + All = 0 + Add = 1 + Delete = 2 + Modify = 4 + Download = 8 + Accounts = 16 + Interaction = 32 + Plugins = 64 + +class Role: + Admin = 0 + User = 1 + +class AccountInfo(BaseObject): + __slots__ = ['plugin', 'loginname', 'owner', 'valid', 'validuntil', 'trafficleft', 'maxtraffic', 'premium', 'activated', 'shared', 'options'] + + def __init__(self, plugin=None, loginname=None, owner=None, valid=None, validuntil=None, trafficleft=None, maxtraffic=None, premium=None, activated=None, shared=None, options=None): + self.plugin = plugin + self.loginname = loginname + self.owner = owner + self.valid = valid + self.validuntil = validuntil + self.trafficleft = trafficleft + self.maxtraffic = maxtraffic + self.premium = premium + self.activated = activated + self.shared = shared + self.options = options + +class AddonInfo(BaseObject): + __slots__ = ['func_name', 'description', 'value'] + + def __init__(self, func_name=None, description=None, value=None): + self.func_name = func_name + self.description = description + self.value = value + +class AddonService(BaseObject): + __slots__ = ['func_name', 'description', 'arguments', 'media'] + + def __init__(self, func_name=None, description=None, arguments=None, media=None): + self.func_name = func_name + self.description = description + self.arguments = arguments + self.media = media + +class ConfigHolder(BaseObject): + __slots__ = ['name', 'label', 'description', 'long_description', 'items', 'info'] + + def __init__(self, name=None, label=None, description=None, long_description=None, items=None, info=None): + self.name = name + self.label = label + self.description = description + self.long_description = long_description + self.items = items + self.info = info + +class ConfigInfo(BaseObject): + __slots__ = ['name', 'label', 'description', 'category', 'user_context', 'activated'] + + def __init__(self, name=None, label=None, description=None, category=None, user_context=None, activated=None): + self.name = name + self.label = label + self.description = description + self.category = category + self.user_context = user_context + self.activated = activated + +class ConfigItem(BaseObject): + __slots__ = ['name', 'label', 'description', 'input', 'default_value', 'value'] + + def __init__(self, name=None, label=None, description=None, input=None, default_value=None, value=None): + self.name = name + self.label = label + self.description = description + self.input = input + self.default_value = default_value + self.value = value + +class DownloadInfo(BaseObject): + __slots__ = ['url', 'plugin', 'hash', 'status', 'statusmsg', 'error'] + + def __init__(self, url=None, plugin=None, hash=None, status=None, statusmsg=None, error=None): + self.url = url + self.plugin = plugin + self.hash = hash + self.status = status + self.statusmsg = statusmsg + self.error = error + +class DownloadProgress(BaseObject): + __slots__ = ['fid', 'pid', 'speed', 'status'] + + def __init__(self, fid=None, pid=None, speed=None, status=None): + self.fid = fid + self.pid = pid + self.speed = speed + self.status = status + +class EventInfo(BaseObject): + __slots__ = ['eventname', 'event_args'] + + def __init__(self, eventname=None, event_args=None): + self.eventname = eventname + self.event_args = event_args + +class FileDoesNotExists(ExceptionObject): + __slots__ = ['fid'] + + def __init__(self, fid=None): + self.fid = fid + +class FileInfo(BaseObject): + __slots__ = ['fid', 'name', 'package', 'owner', 'size', 'status', 'media', 'added', 'fileorder', 'download'] + + def __init__(self, fid=None, name=None, package=None, owner=None, size=None, status=None, media=None, added=None, fileorder=None, download=None): + self.fid = fid + self.name = name + self.package = package + self.owner = owner + self.size = size + self.status = status + self.media = media + self.added = added + self.fileorder = fileorder + self.download = download + +class Forbidden(ExceptionObject): + pass + +class Input(BaseObject): + __slots__ = ['type', 'data'] + + def __init__(self, type=None, data=None): + self.type = type + self.data = data + +class InteractionTask(BaseObject): + __slots__ = ['iid', 'type', 'input', 'default_value', 'title', 'description', 'plugin'] + + def __init__(self, iid=None, type=None, input=None, default_value=None, title=None, description=None, plugin=None): + self.iid = iid + self.type = type + self.input = input + self.default_value = default_value + self.title = title + self.description = description + self.plugin = plugin + +class InvalidConfigSection(ExceptionObject): + __slots__ = ['section'] + + def __init__(self, section=None): + self.section = section + +class LinkStatus(BaseObject): + __slots__ = ['url', 'name', 'plugin', 'size', 'status', 'packagename'] + + def __init__(self, url=None, name=None, plugin=None, size=None, status=None, packagename=None): + self.url = url + self.name = name + self.plugin = plugin + self.size = size + self.status = status + self.packagename = packagename + +class OnlineCheck(BaseObject): + __slots__ = ['rid', 'data'] + + def __init__(self, rid=None, data=None): + self.rid = rid + self.data = data + +class PackageDoesNotExists(ExceptionObject): + __slots__ = ['pid'] + + def __init__(self, pid=None): + self.pid = pid + +class PackageInfo(BaseObject): + __slots__ = ['pid', 'name', 'folder', 'root', 'owner', 'site', 'comment', 'password', 'added', 'tags', 'status', 'shared', 'packageorder', 'stats', 'fids', 'pids'] + + def __init__(self, pid=None, name=None, folder=None, root=None, owner=None, site=None, comment=None, password=None, added=None, tags=None, status=None, shared=None, packageorder=None, stats=None, fids=None, pids=None): + self.pid = pid + self.name = name + self.folder = folder + self.root = root + self.owner = owner + self.site = site + self.comment = comment + self.password = password + self.added = added + self.tags = tags + self.status = status + self.shared = shared + self.packageorder = packageorder + self.stats = stats + self.fids = fids + self.pids = pids + +class PackageStats(BaseObject): + __slots__ = ['linkstotal', 'linksdone', 'sizetotal', 'sizedone'] + + def __init__(self, linkstotal=None, linksdone=None, sizetotal=None, sizedone=None): + self.linkstotal = linkstotal + self.linksdone = linksdone + self.sizetotal = sizetotal + self.sizedone = sizedone + +class ProgressInfo(BaseObject): + __slots__ = ['plugin', 'name', 'statusmsg', 'eta', 'done', 'total', 'download'] + + def __init__(self, plugin=None, name=None, statusmsg=None, eta=None, done=None, total=None, download=None): + self.plugin = plugin + self.name = name + self.statusmsg = statusmsg + self.eta = eta + self.done = done + self.total = total + self.download = download + +class ServerStatus(BaseObject): + __slots__ = ['speed', 'linkstotal', 'linksqueue', 'sizetotal', 'sizequeue', 'notifications', 'paused', 'download', 'reconnect'] + + def __init__(self, speed=None, linkstotal=None, linksqueue=None, sizetotal=None, sizequeue=None, notifications=None, paused=None, download=None, reconnect=None): + self.speed = speed + self.linkstotal = linkstotal + self.linksqueue = linksqueue + self.sizetotal = sizetotal + self.sizequeue = sizequeue + self.notifications = notifications + self.paused = paused + self.download = download + self.reconnect = reconnect + +class ServiceDoesNotExists(ExceptionObject): + __slots__ = ['plugin', 'func'] + + def __init__(self, plugin=None, func=None): + self.plugin = plugin + self.func = func + +class ServiceException(ExceptionObject): + __slots__ = ['msg'] + + def __init__(self, msg=None): + self.msg = msg + +class TreeCollection(BaseObject): + __slots__ = ['root', 'files', 'packages'] + + def __init__(self, root=None, files=None, packages=None): + self.root = root + self.files = files + self.packages = packages + +class Unauthorized(ExceptionObject): + pass + +class UserData(BaseObject): + __slots__ = ['uid', 'name', 'email', 'role', 'permission', 'folder', 'traffic', 'dllimit', 'dlquota', 'hddquota', 'user', 'templateName'] + + def __init__(self, uid=None, name=None, email=None, role=None, permission=None, folder=None, traffic=None, dllimit=None, dlquota=None, hddquota=None, user=None, templateName=None): + self.uid = uid + self.name = name + self.email = email + self.role = role + self.permission = permission + self.folder = folder + self.traffic = traffic + self.dllimit = dllimit + self.dlquota = dlquota + self.hddquota = hddquota + self.user = user + self.templateName = templateName + +class UserDoesNotExists(ExceptionObject): + __slots__ = ['user'] + + def __init__(self, user=None): + self.user = user + +class Iface(object): + def addFromCollector(self, name, paused): + pass + def addLinks(self, pid, links): + pass + def addLocalFile(self, pid, name, path): + pass + def addPackage(self, name, links, password): + pass + def addPackageChild(self, name, links, password, root, paused): + pass + def addPackageP(self, name, links, password, paused): + pass + def addToCollector(self, links): + pass + def addUser(self, username, password): + pass + def callAddon(self, plugin, func, arguments): + pass + def callAddonHandler(self, plugin, func, pid_or_fid): + pass + def checkOnlineStatus(self, urls): + pass + def checkOnlineStatusContainer(self, urls, filename, data): + pass + def checkURLs(self, urls): + pass + def createPackage(self, name, folder, root, password, site, comment, paused): + pass + def deleteCollLink(self, url): + pass + def deleteCollPack(self, name): + pass + def deleteConfig(self, plugin): + pass + def deleteFiles(self, fids): + pass + def deletePackages(self, pids): + pass + def findFiles(self, pattern): + pass + def findPackages(self, tags): + pass + def freeSpace(self): + pass + def generateAndAddPackages(self, links, paused): + pass + def generateDownloadLink(self, fid, timeout): + pass + def generatePackages(self, links): + pass + def getAccountTypes(self): + pass + def getAccounts(self, refresh): + pass + def getAddonHandler(self): + pass + def getAllFiles(self): + pass + def getAllUserData(self): + pass + def getAvailablePlugins(self): + pass + def getCollector(self): + pass + def getConfig(self): + pass + def getConfigValue(self, section, option): + pass + def getCoreConfig(self): + pass + def getFileInfo(self, fid): + pass + def getFileTree(self, pid, full): + pass + def getFilteredFileTree(self, pid, full, state): + pass + def getFilteredFiles(self, state): + pass + def getInteractionTasks(self, mode): + pass + def getLog(self, offset): + pass + def getPackageContent(self, pid): + pass + def getPackageInfo(self, pid): + pass + def getPluginConfig(self): + pass + def getProgressInfo(self): + pass + def getServerStatus(self): + pass + def getServerVersion(self): + pass + def getUserData(self): + pass + def getWSAddress(self): + pass + def hasAddonHandler(self, plugin, func): + pass + def isInteractionWaiting(self, mode): + pass + def loadConfig(self, name): + pass + def login(self, username, password): + pass + def moveFiles(self, fids, pid): + pass + def movePackage(self, pid, root): + pass + def orderFiles(self, fids, pid, position): + pass + def orderPackage(self, pids, position): + pass + def parseURLs(self, html, url): + pass + def pauseServer(self): + pass + def pollResults(self, rid): + pass + def quit(self): + pass + def recheckPackage(self, pid): + pass + def removeAccount(self, account): + pass + def removeUser(self, uid): + pass + def renameCollPack(self, name, new_name): + pass + def restart(self): + pass + def restartFailed(self): + pass + def restartFile(self, fid): + pass + def restartPackage(self, pid): + pass + def saveConfig(self, config): + pass + def searchSuggestions(self, pattern): + pass + def setConfigValue(self, section, option, value): + pass + def setInteractionResult(self, iid, result): + pass + def setPackageFolder(self, pid, path): + pass + def setPassword(self, username, old_password, new_password): + pass + def stopAllDownloads(self): + pass + def stopDownloads(self, fids): + pass + def togglePause(self): + pass + def toggleReconnect(self): + pass + def unpauseServer(self): + pass + def updateAccount(self, plugin, login, password): + pass + def updateAccountInfo(self, account): + pass + def updatePackage(self, pack): + pass + def updateUserData(self, data): + pass + def uploadContainer(self, filename, data): + pass + diff --git a/module/remote/apitypes_debug.py b/module/remote/apitypes_debug.py new file mode 100644 index 000000000..96673cc99 --- /dev/null +++ b/module/remote/apitypes_debug.py @@ -0,0 +1,135 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Autogenerated by pyload +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +from ttypes import * + +enums = [ + "DownloadState", + "DownloadStatus", + "FileStatus", + "InputType", + "Interaction", + "MediaType", + "PackageStatus", + "Permission", + "Role", +] + +classes = { + 'AccountInfo' : [basestring, basestring, int, bool, int, int, int, bool, bool, bool, (dict, basestring, basestring)], + 'AddonInfo' : [basestring, basestring, basestring], + 'AddonService' : [basestring, basestring, (list, basestring), (None, int)], + 'ConfigHolder' : [basestring, basestring, basestring, basestring, (list, ConfigItem), (None, (list, AddonInfo))], + 'ConfigInfo' : [basestring, basestring, basestring, basestring, bool, (None, bool)], + 'ConfigItem' : [basestring, basestring, basestring, Input, basestring, basestring], + 'DownloadInfo' : [basestring, basestring, basestring, int, basestring, basestring], + 'DownloadProgress' : [int, int, int, int], + 'EventInfo' : [basestring, (list, basestring)], + 'FileDoesNotExists' : [int], + 'FileInfo' : [int, basestring, int, int, int, int, int, int, int, (None, DownloadInfo)], + 'Input' : [int, (None, basestring)], + 'InteractionTask' : [int, int, Input, (None, basestring), basestring, basestring, basestring], + 'InvalidConfigSection' : [basestring], + 'LinkStatus' : [basestring, basestring, basestring, int, int, basestring], + 'OnlineCheck' : [int, (None, (dict, basestring, LinkStatus))], + 'PackageDoesNotExists' : [int], + 'PackageInfo' : [int, basestring, basestring, int, int, basestring, basestring, basestring, int, (list, basestring), int, bool, int, PackageStats, (list, int), (list, int)], + 'PackageStats' : [int, int, int, int], + 'ProgressInfo' : [basestring, basestring, basestring, int, int, int, (None, DownloadProgress)], + 'ServerStatus' : [int, int, int, int, int, bool, bool, bool, bool], + 'ServiceDoesNotExists' : [basestring, basestring], + 'ServiceException' : [basestring], + 'TreeCollection' : [PackageInfo, (dict, int, FileInfo), (dict, int, PackageInfo)], + 'UserData' : [int, basestring, basestring, int, int, basestring, int, int, basestring, int, int, basestring], + 'UserDoesNotExists' : [basestring], +} + +methods = { + 'addFromCollector': int, + 'addLinks': None, + 'addLocalFile': None, + 'addPackage': int, + 'addPackageChild': int, + 'addPackageP': int, + 'addToCollector': None, + 'addUser': UserData, + 'callAddon': None, + 'callAddonHandler': None, + 'checkOnlineStatus': OnlineCheck, + 'checkOnlineStatusContainer': OnlineCheck, + 'checkURLs': (dict, basestring, list), + 'createPackage': int, + 'deleteCollLink': None, + 'deleteCollPack': None, + 'deleteConfig': None, + 'deleteFiles': None, + 'deletePackages': None, + 'findFiles': TreeCollection, + 'findPackages': TreeCollection, + 'freeSpace': int, + 'generateAndAddPackages': (list, int), + 'generateDownloadLink': basestring, + 'generatePackages': (dict, basestring, list), + 'getAccountTypes': (list, basestring), + 'getAccounts': (list, AccountInfo), + 'getAddonHandler': (dict, basestring, list), + 'getAllFiles': TreeCollection, + 'getAllUserData': (dict, int, UserData), + 'getAvailablePlugins': (list, ConfigInfo), + 'getCollector': (list, LinkStatus), + 'getConfig': (dict, basestring, ConfigHolder), + 'getConfigValue': basestring, + 'getCoreConfig': (list, ConfigInfo), + 'getFileInfo': FileInfo, + 'getFileTree': TreeCollection, + 'getFilteredFileTree': TreeCollection, + 'getFilteredFiles': TreeCollection, + 'getInteractionTasks': (list, InteractionTask), + 'getLog': (list, basestring), + 'getPackageContent': TreeCollection, + 'getPackageInfo': PackageInfo, + 'getPluginConfig': (list, ConfigInfo), + 'getProgressInfo': (list, ProgressInfo), + 'getServerStatus': ServerStatus, + 'getServerVersion': basestring, + 'getUserData': UserData, + 'getWSAddress': basestring, + 'hasAddonHandler': bool, + 'isInteractionWaiting': bool, + 'loadConfig': ConfigHolder, + 'login': bool, + 'moveFiles': bool, + 'movePackage': bool, + 'orderFiles': None, + 'orderPackage': None, + 'parseURLs': (dict, basestring, list), + 'pauseServer': None, + 'pollResults': OnlineCheck, + 'quit': None, + 'recheckPackage': None, + 'removeAccount': None, + 'removeUser': None, + 'renameCollPack': None, + 'restart': None, + 'restartFailed': None, + 'restartFile': None, + 'restartPackage': None, + 'saveConfig': None, + 'searchSuggestions': (list, basestring), + 'setConfigValue': None, + 'setInteractionResult': None, + 'setPackageFolder': bool, + 'setPassword': bool, + 'stopAllDownloads': None, + 'stopDownloads': None, + 'togglePause': bool, + 'toggleReconnect': bool, + 'unpauseServer': None, + 'updateAccount': None, + 'updateAccountInfo': None, + 'updatePackage': None, + 'updateUserData': None, + 'uploadContainer': int, +} diff --git a/module/remote/create_apitypes.py b/module/remote/create_apitypes.py new file mode 100644 index 000000000..7755b5c57 --- /dev/null +++ b/module/remote/create_apitypes.py @@ -0,0 +1,181 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import re +import inspect +import sys +from os.path import abspath, dirname, join + +path = dirname(abspath(__file__)) +module = join(path, "..", "..") + +sys.path.append(join(module, "lib")) +sys.path.append(join(module, "remote")) + +from thrift.Thrift import TType +from thriftgen.pyload import ttypes +from thriftgen.pyload import Pyload + +type_map = { + TType.BOOL: 'bool', + TType.DOUBLE: 'float', + TType.I16: 'int', + TType.I32: 'int', + TType.I64: 'int', + TType.STRING: 'basestring', + TType.MAP: 'dict', + TType.LIST: 'list', + TType.SET: 'set', + TType.VOID: 'None', + TType.STRUCT: 'BaseObject', + TType.UTF8: 'unicode', +} + +def get_spec(spec, optional=False): + """ analyze the generated spec file and writes information into file """ + if spec[1] == TType.STRUCT: + return spec[3][0].__name__ + elif spec[1] == TType.LIST: + if spec[3][0] == TType.STRUCT: + ttype = spec[3][1][0].__name__ + else: + ttype = type_map[spec[3][0]] + return "(list, %s)" % ttype + elif spec[1] == TType.MAP: + if spec[3][2] == TType.STRUCT: + ttype = spec[3][3][0].__name__ + else: + ttype = type_map[spec[3][2]] + + return "(dict, %s, %s)" % (type_map[spec[3][0]], ttype) + else: + return type_map[spec[1]] + +optional_re = "%d: +optional +[a-z0-9<>_-]+ +%s" + +def main(): + + enums = [] + classes = [] + tf = open(join(path, "pyload.thrift"), "rb").read() + + print "generating apitypes.py" + + for name in dir(ttypes): + klass = getattr(ttypes, name) + + if name in ("TBase", "TExceptionBase") or name.startswith("_") or not (issubclass(klass, ttypes.TBase) or issubclass(klass, ttypes.TExceptionBase)): + continue + + if hasattr(klass, "thrift_spec"): + classes.append(klass) + else: + enums.append(klass) + + + f = open(join(path, "apitypes.py"), "wb") + f.write( + """#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Autogenerated by pyload +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +class BaseObject(object): +\t__slots__ = [] + +\tdef __str__(self): +\t\treturn "<%s %s>" % (self.__class__.__name__, ", ".join("%s=%s" % (k,getattr(self,k)) for k in self.__slots__)) + +class ExceptionObject(Exception): +\t__slots__ = [] + +""") + + dev = open(join(path, "apitypes_debug.py"), "wb") + dev.write("""#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Autogenerated by pyload +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n +from ttypes import *\n +""") + + dev.write("enums = [\n") + + ## generate enums + for enum in enums: + name = enum.__name__ + f.write("class %s:\n" % name) + + for attr in sorted(dir(enum), key=lambda x: getattr(enum, x)): + if attr.startswith("_") or attr in ("read", "write"): continue + f.write("\t%s = %s\n" % (attr, getattr(enum, attr))) + + dev.write('\t"%s",\n' % name) + f.write("\n") + + dev.write("]\n\n") + + dev.write("classes = {\n") + + for klass in classes: + name = klass.__name__ + base = "ExceptionObject" if issubclass(klass, ttypes.TExceptionBase) else "BaseObject" + f.write("class %s(%s):\n" % (name, base)) + + # No attributes, don't write further info + if not klass.__slots__: + f.write("\tpass\n\n") + continue + + f.write("\t__slots__ = %s\n\n" % klass.__slots__) + dev.write("\t'%s' : [" % name) + + #create init + args = ["self"] + ["%s=None" % x for x in klass.__slots__] + specs = [] + + f.write("\tdef __init__(%s):\n" % ", ".join(args)) + for i, attr in enumerate(klass.__slots__): + f.write("\t\tself.%s = %s\n" % (attr, attr)) + + spec = klass.thrift_spec[i+1] + # assert correct order, so the list of types is enough for check + assert spec[2] == attr + # dirty way to check optional attribute, since it is not in the generated code + # can produce false positives, but these are not critical + optional = re.search(optional_re % (i+1, attr), tf, re.I) + if optional: + specs.append("(None, %s)" % get_spec(spec)) + else: + specs.append(get_spec(spec)) + + f.write("\n") + dev.write(", ".join(specs) + "],\n") + + dev.write("}\n\n") + + f.write("class Iface(object):\n") + dev.write("methods = {\n") + + for name in dir(Pyload.Iface): + if name.startswith("_"): continue + + func = inspect.getargspec(getattr(Pyload.Iface, name)) + + f.write("\tdef %s(%s):\n\t\tpass\n" % (name, ", ".join(func.args))) + + spec = getattr(Pyload, "%s_result" % name).thrift_spec + if not spec or not spec[0]: + dev.write("\t'%s': None,\n" % name) + else: + spec = spec[0] + dev.write("\t'%s': %s,\n" % (name, get_spec(spec))) + + f.write("\n") + dev.write("}\n") + + f.close() + dev.close() + +if __name__ == "__main__": + main()
\ No newline at end of file diff --git a/module/remote/create_jstypes.py b/module/remote/create_jstypes.py new file mode 100644 index 000000000..ad05ec9a8 --- /dev/null +++ b/module/remote/create_jstypes.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from os.path import abspath, dirname, join + +path = dirname(abspath(__file__)) +module = join(path, "..") + +import apitypes +from apitypes_debug import enums + +# generate js enums +def main(): + + print "generating apitypes.js" + + f = open(join(module, 'web', 'static', 'js', 'utils', 'apitypes.js'), 'wb') + f.write("""// Autogenerated, do not edit! +define([], function() { +\treturn { +""") + + for name in enums: + enum = getattr(apitypes, name) + values = dict([(attr, getattr(enum, attr)) for attr in dir(enum) if not attr.startswith("_")]) + + f.write("\t\t%s: %s,\n" % (name, str(values))) + + f.write("\t};\n});") + f.close() + + +if __name__ == "__main__": + main() diff --git a/module/remote/json_converter.py b/module/remote/json_converter.py new file mode 100644 index 000000000..50f0309bd --- /dev/null +++ b/module/remote/json_converter.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +try: + from module.common.json_layer import json +except ImportError: + import json + + +import apitypes +from apitypes import BaseObject +from apitypes import ExceptionObject + +# compact json separator +separators = (',', ':') + +# json encoder that accepts api objects +class BaseEncoder(json.JSONEncoder): + + def default(self, o): + if isinstance(o, BaseObject) or isinstance(o, ExceptionObject): + ret = {"@class" : o.__class__.__name__} + for att in o.__slots__: + ret[att] = getattr(o, att) + return ret + + return json.JSONEncoder.default(self, o) + +# more compact representation, only clients with information of the classes can handle it +class BaseEncoderCompact(json.JSONEncoder): + + def default(self, o): + if isinstance(o, BaseObject) or isinstance(o, ExceptionObject): + ret = {"@compact" : [o.__class__.__name__]} + ret["@compact"].extend(getattr(o, attr) for attr in o.__slots__) + return ret + + return json.JSONEncoder.default(self, o) + +def convert_obj(dct): + if '@class' in dct: + cls = getattr(apitypes, dct['@class']) + del dct['@class'] + return cls(**dct) + elif '@compact' in dct: + cls = getattr(apitypes, dct['@compact'][0]) + return cls(*dct['@compact'][1:]) + + return dct + +def dumps(*args, **kwargs): + if 'compact' in kwargs: + kwargs['cls'] = BaseEncoderCompact + del kwargs['compact'] + else: + kwargs['cls'] = BaseEncoder + + kwargs['separators'] = separators + return json.dumps(*args, **kwargs) + + +def loads(*args, **kwargs): + kwargs['object_hook'] = convert_obj + return json.loads(*args, **kwargs)
\ No newline at end of file diff --git a/module/remote/pyload.thrift b/module/remote/pyload.thrift new file mode 100644 index 000000000..57d7e0a0a --- /dev/null +++ b/module/remote/pyload.thrift @@ -0,0 +1,538 @@ +namespace java org.pyload.thrift + +typedef i32 FileID +typedef i32 PackageID +typedef i32 ResultID +typedef i32 InteractionID +typedef i32 UserID +typedef i64 UTCDate +typedef i64 ByteCount +typedef list<string> LinkList +typedef string PluginName +typedef string JSONString + +// NA - Not Available +enum DownloadStatus { + NA, + Offline, + Online, + Queued, + Paused, + Finished, + Skipped, + Failed, + Starting, + Waiting, + Downloading, + TempOffline, + Aborted, + Decrypting, + Processing, + Custom, + Unknown +} + +// Download states, combination of several downloadstatuses +// defined in Api +enum DownloadState { + All, + Finished, + Unfinished, + Failed, + Unmanaged // internal state +} + +enum MediaType { + All = 0 + Other = 1, + Audio = 2, + Image = 4, + Video = 8, + Document = 16, + Archive = 32, +} + +enum FileStatus { + Ok, + Missing, + Remote, // file is available at remote location +} + +enum PackageStatus { + Ok, + Paused, + Folder, + Remote, +} + +// types for user interaction +// some may only be place holder currently not supported +// also all input - output combination are not reasonable, see InteractionManager for further info +// Todo: how about: time, ip, s.o. +enum InputType { + NA, + Text, + Int, + File, + Folder, + Textbox, + Password, + Bool, // confirm like, yes or no dialog + Click, // for positional captchas + Select, // select from list + Multiple, // multiple choice from list of elements + List, // arbitary list of elements + Table // table like data structure +} +// more can be implemented by need + +// this describes the type of the outgoing interaction +// ensure they can be logcial or'ed +enum Interaction { + All = 0, + Notification = 1, + Captcha = 2, + Query = 4, +} + +enum Permission { + All = 0, // requires no permission, but login + Add = 1, // can add packages + Delete = 2, // can delete packages + Modify = 4, // modify some attribute of downloads + Download = 8, // can download from webinterface + Accounts = 16, // can access accounts + Interaction = 32, // can interact with plugins + Plugins = 64 // user can configure plugins and activate addons +} + +enum Role { + Admin = 0, //admin has all permissions implicit + User = 1 +} + +struct Input { + 1: InputType type, + 2: optional JSONString data, +} + +struct DownloadProgress { + 1: FileID fid, + 2: PackageID pid, + 3: ByteCount speed, // per second + 4: DownloadStatus status, +} + +struct ProgressInfo { + 1: PluginName plugin, + 2: string name, + 3: string statusmsg, + 4: i32 eta, // in seconds + 5: ByteCount done, + 6: ByteCount total, // arbitary number, size in case of files + 7: optional DownloadProgress download +} + +// download info for specific file +struct DownloadInfo { + 1: string url, + 2: PluginName plugin, + 3: string hash, + 4: DownloadStatus status, + 5: string statusmsg, + 6: string error, +} + +struct FileInfo { + 1: FileID fid, + 2: string name, + 3: PackageID package, + 4: UserID owner, + 5: ByteCount size, + 6: FileStatus status, + 7: MediaType media, + 8: UTCDate added, + 9: i16 fileorder, + 10: optional DownloadInfo download, +} + +struct PackageStats { + 1: i16 linkstotal, + 2: i16 linksdone, + 3: ByteCount sizetotal, + 4: ByteCount sizedone, +} + +struct PackageInfo { + 1: PackageID pid, + 2: string name, + 3: string folder, + 4: PackageID root, + 5: UserID owner, + 6: string site, + 7: string comment, + 8: string password, + 9: UTCDate added, + 10: list<string> tags, + 11: PackageStatus status, + 12: bool shared, + 13: i16 packageorder, + 14: PackageStats stats, + 15: list<FileID> fids, + 16: list<PackageID> pids, +} + +// thrift does not allow recursive datatypes, so all data is accumulated and mapped with id +struct TreeCollection { + 1: PackageInfo root, + 2: map<FileID, FileInfo> files, + 3: map<PackageID, PackageInfo> packages +} + +// general info about link, used for collector and online results +struct LinkStatus { + 1: string url, + 2: string name, + 3: PluginName plugin, + 4: ByteCount size, // size <= 0 : unknown + 5: DownloadStatus status, + 6: string packagename, +} + +struct ServerStatus { + 1: ByteCount speed, + 2: i16 linkstotal, + 3: i16 linksqueue, + 4: ByteCount sizetotal, + 5: ByteCount sizequeue, + 6: bool notifications, + 7: bool paused, + 8: bool download, + 9: bool reconnect, +} + +struct InteractionTask { + 1: InteractionID iid, + 2: Interaction type, + 3: Input input, + 4: optional JSONString default_value, + 5: string title, + 6: string description, + 7: PluginName plugin, +} + +struct AddonService { + 1: string func_name, + 2: string description, + 3: list<string> arguments, + 4: optional i16 media, +} + +struct AddonInfo { + 1: string func_name, + 2: string description, + 3: JSONString value, +} + +struct ConfigItem { + 1: string name, + 2: string label, + 3: string description, + 4: Input input, + 5: JSONString default_value, + 6: JSONString value, +} + +struct ConfigHolder { + 1: string name, // for plugin this is the PluginName + 2: string label, + 3: string description, + 4: string long_description, + 5: list<ConfigItem> items, + 6: optional list<AddonInfo> info, +} + +struct ConfigInfo { + 1: string name + 2: string label, + 3: string description, + 4: string category, + 5: bool user_context, + 6: optional bool activated, +} + +struct EventInfo { + 1: string eventname, + 2: list<JSONString> event_args, //will contain json objects +} + +struct UserData { + 1: UserID uid, + 2: string name, + 3: string email, + 4: i16 role, + 5: i16 permission, + 6: string folder, + 7: ByteCount traffic + 8: i16 dllimit + 9: string dlquota, + 10: ByteCount hddquota, + 11: UserID user, + 12: string templateName +} + +struct AccountInfo { + 1: PluginName plugin, + 2: string loginname, + 3: UserID owner, + 4: bool valid, + 5: UTCDate validuntil, + 6: ByteCount trafficleft, + 7: ByteCount maxtraffic, + 8: bool premium, + 9: bool activated, + 10: bool shared, + 11: map<string, string> options, +} + +struct OnlineCheck { + 1: ResultID rid, // -1 -> nothing more to get + 2: map<string, LinkStatus> data, // url to result +} + +// exceptions + +exception PackageDoesNotExists { + 1: PackageID pid +} + +exception FileDoesNotExists { + 1: FileID fid +} + +exception UserDoesNotExists { + 1: string user +} + +exception ServiceDoesNotExists { + 1: string plugin + 2: string func +} + +exception ServiceException { + 1: string msg +} + +exception InvalidConfigSection { + 1: string section +} + +exception Unauthorized { +} + +exception Forbidden { +} + + +service Pyload { + + /////////////////////// + // Core Status + /////////////////////// + + string getServerVersion(), + string getWSAddress(), + ServerStatus getServerStatus(), + list<ProgressInfo> getProgressInfo(), + + list<string> getLog(1: i32 offset), + ByteCount freeSpace(), + + void pauseServer(), + void unpauseServer(), + bool togglePause(), + bool toggleReconnect(), + + void quit(), + void restart(), + + /////////////////////// + // Configuration + /////////////////////// + + map<string, ConfigHolder> getConfig(), + string getConfigValue(1: string section, 2: string option), + + // two methods with ambigous classification, could be configuration or addon/plugin related + list<ConfigInfo> getCoreConfig(), + list<ConfigInfo> getPluginConfig(), + list<ConfigInfo> getAvailablePlugins(), + + ConfigHolder loadConfig(1: string name), + + void setConfigValue(1: string section, 2: string option, 3: string value), + void saveConfig(1: ConfigHolder config), + void deleteConfig(1: PluginName plugin), + + /////////////////////// + // Download Preparing + /////////////////////// + + map<PluginName, LinkList> checkURLs(1: LinkList urls), + map<PluginName, LinkList> parseURLs(1: string html, 2: string url), + + // parses results and generates packages + OnlineCheck checkOnlineStatus(1: LinkList urls), + OnlineCheck checkOnlineStatusContainer(1: LinkList urls, 2: string filename, 3: binary data) + + // poll results from previously started online check + OnlineCheck pollResults(1: ResultID rid), + + // packagename -> urls + map<string, LinkList> generatePackages(1: LinkList links), + + /////////////////////// + // Download + /////////////////////// + + list<PackageID> generateAndAddPackages(1: LinkList links, 2: bool paused), + + PackageID createPackage(1: string name, 2: string folder, 3: PackageID root, 4: string password, + 5: string site, 6: string comment, 7: bool paused), + + PackageID addPackage(1: string name, 2: LinkList links, 3: string password), + // same as above with paused attribute + PackageID addPackageP(1: string name, 2: LinkList links, 3: string password, 4: bool paused), + + // pid -1 is toplevel + PackageID addPackageChild(1: string name, 2: LinkList links, 3: string password, 4: PackageID root, 5: bool paused), + + PackageID uploadContainer(1: string filename, 2: binary data), + + void addLinks(1: PackageID pid, 2: LinkList links) throws (1: PackageDoesNotExists e), + void addLocalFile(1: PackageID pid, 2: string name, 3: string path) throws (1: PackageDoesNotExists e) + + // these are real file operations and WILL delete files on disk + void deleteFiles(1: list<FileID> fids), + void deletePackages(1: list<PackageID> pids), // delete the whole folder recursive + + // Modify Downloads + + void restartPackage(1: PackageID pid), + void restartFile(1: FileID fid), + void recheckPackage(1: PackageID pid), + void restartFailed(), + void stopDownloads(1: list<FileID> fids), + void stopAllDownloads(), + + /////////////////////// + // Collector + /////////////////////// + + list<LinkStatus> getCollector(), + + void addToCollector(1: LinkList links), + PackageID addFromCollector(1: string name, 2: bool paused), + void renameCollPack(1: string name, 2: string new_name), + void deleteCollPack(1: string name), + void deleteCollLink(1: string url), + + //////////////////////////// + // File Information retrieval + //////////////////////////// + + TreeCollection getAllFiles(), + TreeCollection getFilteredFiles(1: DownloadState state), + + // pid -1 for root, full=False only delivers first level in tree + TreeCollection getFileTree(1: PackageID pid, 2: bool full), + TreeCollection getFilteredFileTree(1: PackageID pid, 2: bool full, 3: DownloadState state), + + // same as above with full=False + TreeCollection getPackageContent(1: PackageID pid), + + PackageInfo getPackageInfo(1: PackageID pid) throws (1: PackageDoesNotExists e), + FileInfo getFileInfo(1: FileID fid) throws (1: FileDoesNotExists e), + + TreeCollection findFiles(1: string pattern), + TreeCollection findPackages(1: list<string> tags), + list<string> searchSuggestions(1: string pattern), + + // Modify Files/Packages + + // moving package while downloading is not possible, so they will return bool to indicate success + void updatePackage(1: PackageInfo pack) throws (1: PackageDoesNotExists e), + bool setPackageFolder(1: PackageID pid, 2: string path) throws (1: PackageDoesNotExists e), + + // as above, this will move files on disk + bool movePackage(1: PackageID pid, 2: PackageID root) throws (1: PackageDoesNotExists e), + bool moveFiles(1: list<FileID> fids, 2: PackageID pid) throws (1: PackageDoesNotExists e), + + void orderPackage(1: list<PackageID> pids, 2: i16 position), + void orderFiles(1: list<FileID> fids, 2: PackageID pid, 3: i16 position), + + /////////////////////// + // User Interaction + /////////////////////// + + // mode = interaction types binary ORed + bool isInteractionWaiting(1: i16 mode), + list<InteractionTask> getInteractionTasks(1: i16 mode), + void setInteractionResult(1: InteractionID iid, 2: JSONString result), + + // generate a download link, everybody can download the file until timeout reached + string generateDownloadLink(1: FileID fid, 2: i16 timeout), + + /////////////////////// + // Account Methods + /////////////////////// + + list<AccountInfo> getAccounts(1: bool refresh), + list<string> getAccountTypes(), + void updateAccount(1: PluginName plugin, 2: string login, 3: string password), + void updateAccountInfo(1: AccountInfo account), + void removeAccount(1: AccountInfo account), + + ///////////////////////// + // Auth+User Information + ///////////////////////// + + bool login(1: string username, 2: string password), + // returns own user data + UserData getUserData(), + + // all user, for admins only + map<UserID, UserData> getAllUserData(), + + UserData addUser(1: string username, 2:string password), + + // normal user can only update their own userdata and not all attributes + void updateUserData(1: UserData data), + void removeUser(1: UserID uid), + + // works contextual, admin can change every password + bool setPassword(1: string username, 2: string old_password, 3: string new_password), + + /////////////////////// + // Addon Methods + /////////////////////// + + //map<PluginName, list<AddonInfo>> getAllInfo(), + //list<AddonInfo> getInfoByPlugin(1: PluginName plugin), + + map<PluginName, list<AddonService>> getAddonHandler(), + bool hasAddonHandler(1: PluginName plugin, 2: string func), + + void callAddon(1: PluginName plugin, 2: string func, 3: list<JSONString> arguments) + throws (1: ServiceDoesNotExists e, 2: ServiceException ex), + + // special variant of callAddon that works on the media types, acccepting integer + void callAddonHandler(1: PluginName plugin, 2: string func, 3: PackageID pid_or_fid) + throws (1: ServiceDoesNotExists e, 2: ServiceException ex), + + + //scheduler + + // TODO + +} diff --git a/module/remote/socketbackend/create_ttypes.py b/module/remote/socketbackend/create_ttypes.py deleted file mode 100644 index 05662cb50..000000000 --- a/module/remote/socketbackend/create_ttypes.py +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import inspect -import sys -from os.path import abspath, dirname, join - -path = dirname(abspath(__file__)) -module = join(path, "..", "..") - -sys.path.append(join(module, "lib")) -sys.path.append(join(module, "remote")) - -from thriftbackend.thriftgen.pyload import ttypes -from thriftbackend.thriftgen.pyload.Pyload import Iface - - -def main(): - - enums = [] - classes = [] - - print "generating lightweight ttypes.py" - - for name in dir(ttypes): - klass = getattr(ttypes, name) - - if name in ("TBase", "TExceptionBase") or name.startswith("_") or not (issubclass(klass, ttypes.TBase) or issubclass(klass, ttypes.TExceptionBase)): - continue - - if hasattr(klass, "thrift_spec"): - classes.append(klass) - else: - enums.append(klass) - - - f = open(join(path, "ttypes.py"), "wb") - - f.write( - """#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Autogenerated by pyload -# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - -class BaseObject(object): -\t__slots__ = [] - -""") - - ## generate enums - for enum in enums: - name = enum.__name__ - f.write("class %s:\n" % name) - - for attr in dir(enum): - if attr.startswith("_") or attr in ("read", "write"): continue - - f.write("\t%s = %s\n" % (attr, getattr(enum, attr))) - - f.write("\n") - - for klass in classes: - name = klass.__name__ - base = "Exception" if issubclass(klass, ttypes.TExceptionBase) else "BaseObject" - f.write("class %s(%s):\n" % (name, base)) - f.write("\t__slots__ = %s\n\n" % klass.__slots__) - - #create init - args = ["self"] + ["%s=None" % x for x in klass.__slots__] - - f.write("\tdef __init__(%s):\n" % ", ".join(args)) - for attr in klass.__slots__: - f.write("\t\tself.%s = %s\n" % (attr, attr)) - - f.write("\n") - - f.write("class Iface:\n") - - for name in dir(Iface): - if name.startswith("_"): continue - - func = inspect.getargspec(getattr(Iface, name)) - - f.write("\tdef %s(%s):\n\t\tpass\n" % (name, ", ".join(func.args))) - - f.write("\n") - - f.close() - -if __name__ == "__main__": - main()
\ No newline at end of file diff --git a/module/remote/socketbackend/ttypes.py b/module/remote/socketbackend/ttypes.py deleted file mode 100644 index f8ea121fa..000000000 --- a/module/remote/socketbackend/ttypes.py +++ /dev/null @@ -1,383 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Autogenerated by pyload -# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - -class BaseObject(object): - __slots__ = [] - -class Destination: - Collector = 0 - Queue = 1 - -class DownloadStatus: - Aborted = 9 - Custom = 11 - Decrypting = 10 - Downloading = 12 - Failed = 8 - Finished = 0 - Offline = 1 - Online = 2 - Processing = 13 - Queued = 3 - Skipped = 4 - Starting = 7 - TempOffline = 6 - Unknown = 14 - Waiting = 5 - -class ElementType: - File = 1 - Package = 0 - -class Input: - BOOL = 4 - CHOICE = 6 - CLICK = 5 - LIST = 8 - MULTIPLE = 7 - NONE = 0 - PASSWORD = 3 - TABLE = 9 - TEXT = 1 - TEXTBOX = 2 - -class Output: - CAPTCHA = 1 - NOTIFICATION = 4 - QUESTION = 2 - -class AccountInfo(BaseObject): - __slots__ = ['validuntil', 'login', 'options', 'valid', 'trafficleft', 'maxtraffic', 'premium', 'type'] - - def __init__(self, validuntil=None, login=None, options=None, valid=None, trafficleft=None, maxtraffic=None, premium=None, type=None): - self.validuntil = validuntil - self.login = login - self.options = options - self.valid = valid - self.trafficleft = trafficleft - self.maxtraffic = maxtraffic - self.premium = premium - self.type = type - -class CaptchaTask(BaseObject): - __slots__ = ['tid', 'data', 'type', 'resultType'] - - def __init__(self, tid=None, data=None, type=None, resultType=None): - self.tid = tid - self.data = data - self.type = type - self.resultType = resultType - -class ConfigItem(BaseObject): - __slots__ = ['name', 'description', 'value', 'type'] - - def __init__(self, name=None, description=None, value=None, type=None): - self.name = name - self.description = description - self.value = value - self.type = type - -class ConfigSection(BaseObject): - __slots__ = ['name', 'description', 'items', 'outline'] - - def __init__(self, name=None, description=None, items=None, outline=None): - self.name = name - self.description = description - self.items = items - self.outline = outline - -class DownloadInfo(BaseObject): - __slots__ = ['fid', 'name', 'speed', 'eta', 'format_eta', 'bleft', 'size', 'format_size', 'percent', 'status', 'statusmsg', 'format_wait', 'wait_until', 'packageID', 'packageName', 'plugin'] - - def __init__(self, fid=None, name=None, speed=None, eta=None, format_eta=None, bleft=None, size=None, format_size=None, percent=None, status=None, statusmsg=None, format_wait=None, wait_until=None, packageID=None, packageName=None, plugin=None): - self.fid = fid - self.name = name - self.speed = speed - self.eta = eta - self.format_eta = format_eta - self.bleft = bleft - self.size = size - self.format_size = format_size - self.percent = percent - self.status = status - self.statusmsg = statusmsg - self.format_wait = format_wait - self.wait_until = wait_until - self.packageID = packageID - self.packageName = packageName - self.plugin = plugin - -class EventInfo(BaseObject): - __slots__ = ['eventname', 'id', 'type', 'destination'] - - def __init__(self, eventname=None, id=None, type=None, destination=None): - self.eventname = eventname - self.id = id - self.type = type - self.destination = destination - -class FileData(BaseObject): - __slots__ = ['fid', 'url', 'name', 'plugin', 'size', 'format_size', 'status', 'statusmsg', 'packageID', 'error', 'order'] - - def __init__(self, fid=None, url=None, name=None, plugin=None, size=None, format_size=None, status=None, statusmsg=None, packageID=None, error=None, order=None): - self.fid = fid - self.url = url - self.name = name - self.plugin = plugin - self.size = size - self.format_size = format_size - self.status = status - self.statusmsg = statusmsg - self.packageID = packageID - self.error = error - self.order = order - -class FileDoesNotExists(Exception): - __slots__ = ['fid'] - - def __init__(self, fid=None): - self.fid = fid - -class InteractionTask(BaseObject): - __slots__ = ['iid', 'input', 'structure', 'preset', 'output', 'data', 'title', 'description', 'plugin'] - - def __init__(self, iid=None, input=None, structure=None, preset=None, output=None, data=None, title=None, description=None, plugin=None): - self.iid = iid - self.input = input - self.structure = structure - self.preset = preset - self.output = output - self.data = data - self.title = title - self.description = description - self.plugin = plugin - -class OnlineCheck(BaseObject): - __slots__ = ['rid', 'data'] - - def __init__(self, rid=None, data=None): - self.rid = rid - self.data = data - -class OnlineStatus(BaseObject): - __slots__ = ['name', 'plugin', 'packagename', 'status', 'size'] - - def __init__(self, name=None, plugin=None, packagename=None, status=None, size=None): - self.name = name - self.plugin = plugin - self.packagename = packagename - self.status = status - self.size = size - -class PackageData(BaseObject): - __slots__ = ['pid', 'name', 'folder', 'site', 'password', 'dest', 'order', 'linksdone', 'sizedone', 'sizetotal', 'linkstotal', 'links', 'fids'] - - def __init__(self, pid=None, name=None, folder=None, site=None, password=None, dest=None, order=None, linksdone=None, sizedone=None, sizetotal=None, linkstotal=None, links=None, fids=None): - self.pid = pid - self.name = name - self.folder = folder - self.site = site - self.password = password - self.dest = dest - self.order = order - self.linksdone = linksdone - self.sizedone = sizedone - self.sizetotal = sizetotal - self.linkstotal = linkstotal - self.links = links - self.fids = fids - -class PackageDoesNotExists(Exception): - __slots__ = ['pid'] - - def __init__(self, pid=None): - self.pid = pid - -class ServerStatus(BaseObject): - __slots__ = ['pause', 'active', 'queue', 'total', 'speed', 'download', 'reconnect'] - - def __init__(self, pause=None, active=None, queue=None, total=None, speed=None, download=None, reconnect=None): - self.pause = pause - self.active = active - self.queue = queue - self.total = total - self.speed = speed - self.download = download - self.reconnect = reconnect - -class ServiceCall(BaseObject): - __slots__ = ['plugin', 'func', 'arguments', 'parseArguments'] - - def __init__(self, plugin=None, func=None, arguments=None, parseArguments=None): - self.plugin = plugin - self.func = func - self.arguments = arguments - self.parseArguments = parseArguments - -class ServiceDoesNotExists(Exception): - __slots__ = ['plugin', 'func'] - - def __init__(self, plugin=None, func=None): - self.plugin = plugin - self.func = func - -class ServiceException(Exception): - __slots__ = ['msg'] - - def __init__(self, msg=None): - self.msg = msg - -class UserData(BaseObject): - __slots__ = ['name', 'email', 'role', 'permission', 'templateName'] - - def __init__(self, name=None, email=None, role=None, permission=None, templateName=None): - self.name = name - self.email = email - self.role = role - self.permission = permission - self.templateName = templateName - -class Iface: - def addFiles(self, pid, links): - pass - def addPackage(self, name, links, dest): - pass - def call(self, info): - pass - def checkOnlineStatus(self, urls): - pass - def checkOnlineStatusContainer(self, urls, filename, data): - pass - def checkURLs(self, urls): - pass - def deleteFiles(self, fids): - pass - def deleteFinished(self): - pass - def deletePackages(self, pids): - pass - def freeSpace(self): - pass - def generateAndAddPackages(self, links, dest): - pass - def generatePackages(self, links): - pass - def getAccountTypes(self): - pass - def getAccounts(self, refresh): - pass - def getAllInfo(self): - pass - def getAllUserData(self): - pass - def getCaptchaTask(self, exclusive): - pass - def getCaptchaTaskStatus(self, tid): - pass - def getCollector(self): - pass - def getCollectorData(self): - pass - def getConfig(self): - pass - def getConfigValue(self, category, option, section): - pass - def getEvents(self, uuid): - pass - def getFileData(self, fid): - pass - def getFileOrder(self, pid): - pass - def getInfoByPlugin(self, plugin): - pass - def getLog(self, offset): - pass - def getPackageData(self, pid): - pass - def getPackageInfo(self, pid): - pass - def getPackageOrder(self, destination): - pass - def getPluginConfig(self): - pass - def getQueue(self): - pass - def getQueueData(self): - pass - def getServerVersion(self): - pass - def getServices(self): - pass - def getUserData(self, username, password): - pass - def hasService(self, plugin, func): - pass - def isCaptchaWaiting(self): - pass - def isTimeDownload(self): - pass - def isTimeReconnect(self): - pass - def kill(self): - pass - def login(self, username, password): - pass - def moveFiles(self, fids, pid): - pass - def movePackage(self, destination, pid): - pass - def orderFile(self, fid, position): - pass - def orderPackage(self, pid, position): - pass - def parseURLs(self, html, url): - pass - def pauseServer(self): - pass - def pollResults(self, rid): - pass - def pullFromQueue(self, pid): - pass - def pushToQueue(self, pid): - pass - def recheckPackage(self, pid): - pass - def removeAccount(self, plugin, account): - pass - def restart(self): - pass - def restartFailed(self): - pass - def restartFile(self, fid): - pass - def restartPackage(self, pid): - pass - def setCaptchaResult(self, tid, result): - pass - def setConfigValue(self, category, option, value, section): - pass - def setPackageData(self, pid, data): - pass - def setPackageName(self, pid, name): - pass - def statusDownloads(self): - pass - def statusServer(self): - pass - def stopAllDownloads(self): - pass - def stopDownloads(self, fids): - pass - def togglePause(self): - pass - def toggleReconnect(self): - pass - def unpauseServer(self): - pass - def updateAccount(self, plugin, account, password, options): - pass - def uploadContainer(self, filename, data): - pass - diff --git a/module/remote/thriftbackend/Processor.py b/module/remote/thriftbackend/Processor.py deleted file mode 100644 index a8b87c82c..000000000 --- a/module/remote/thriftbackend/Processor.py +++ /dev/null @@ -1,77 +0,0 @@ -# -*- coding: utf-8 -*- - -from thriftgen.pyload import Pyload - -class Processor(Pyload.Processor): - def __init__(self, *args, **kwargs): - Pyload.Processor.__init__(self, *args, **kwargs) - self.authenticated = {} - - def process(self, iprot, oprot): - trans = oprot.trans - if trans not in self.authenticated: - self.authenticated[trans] = False - oldclose = trans.close - - def wrap(): - if self in self.authenticated: - del self.authenticated[trans] - oldclose() - - trans.close = wrap - authenticated = self.authenticated[trans] - (name, type, seqid) = iprot.readMessageBegin() - - # unknown method - if name not in self._processMap: - iprot.skip(Pyload.TType.STRUCT) - iprot.readMessageEnd() - x = Pyload.TApplicationException(Pyload.TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % name) - oprot.writeMessageBegin(name, Pyload.TMessageType.EXCEPTION, seqid) - x.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - return - - # not logged in - elif not authenticated and not name == "login": - iprot.skip(Pyload.TType.STRUCT) - iprot.readMessageEnd() - # 20 - Not logged in (in situ declared error code) - x = Pyload.TApplicationException(20, 'Not logged in') - oprot.writeMessageBegin(name, Pyload.TMessageType.EXCEPTION, seqid) - x.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - return - - elif not authenticated and name == "login": - args = Pyload.login_args() - args.read(iprot) - iprot.readMessageEnd() - result = Pyload.login_result() - # api login - self.authenticated[trans] = self._handler.checkAuth(args.username, args.password, trans.remoteaddr[0]) - - result.success = True if self.authenticated[trans] else False - oprot.writeMessageBegin("login", Pyload.TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - elif self._handler.isAuthorized(name, authenticated): - self._processMap[name](self, seqid, iprot, oprot) - - else: - #no permission - iprot.skip(Pyload.TType.STRUCT) - iprot.readMessageEnd() - # 21 - Not authorized - x = Pyload.TApplicationException(21, 'Not authorized') - oprot.writeMessageBegin(name, Pyload.TMessageType.EXCEPTION, seqid) - x.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - return - - return True diff --git a/module/remote/thriftbackend/Protocol.py b/module/remote/thriftbackend/Protocol.py deleted file mode 100644 index c42d01459..000000000 --- a/module/remote/thriftbackend/Protocol.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- - -from thrift.protocol import TBinaryProtocol - -class Protocol(TBinaryProtocol.TBinaryProtocol): - def writeString(self, str): - try: - str = str.encode("utf8", "ignore") - except Exception, e: - pass - - self.writeI32(len(str)) - self.trans.write(str) - - def readString(self): - len = self.readI32() - str = self.trans.readAll(len) - try: - str = str.decode("utf8", "ignore") - except: - pass - - return str - - -class ProtocolFactory(TBinaryProtocol.TBinaryProtocolFactory): - - def getProtocol(self, trans): - prot = Protocol(trans, self.strictRead, self.strictWrite) - return prot
\ No newline at end of file diff --git a/module/remote/thriftbackend/Socket.py b/module/remote/thriftbackend/Socket.py deleted file mode 100644 index 2243f9df2..000000000 --- a/module/remote/thriftbackend/Socket.py +++ /dev/null @@ -1,129 +0,0 @@ -# -*- coding: utf-8 -*- - -import sys -import socket -import errno - -from time import sleep - -from thrift.transport.TSocket import TSocket, TServerSocket, TTransportException - -WantReadError = Exception #overwritten when ssl is used - -class SecureSocketConnection: - def __init__(self, connection): - self.__dict__["connection"] = connection - - def __getattr__(self, name): - return getattr(self.__dict__["connection"], name) - - def __setattr__(self, name, value): - setattr(self.__dict__["connection"], name, value) - - def shutdown(self, how=1): - self.__dict__["connection"].shutdown() - - def accept(self): - connection, address = self.__dict__["connection"].accept() - return SecureSocketConnection(connection), address - - def send(self, buff): - try: - return self.__dict__["connection"].send(buff) - except WantReadError: - sleep(0.1) - return self.send(buff) - - def recv(self, buff): - try: - return self.__dict__["connection"].recv(buff) - except WantReadError: - sleep(0.1) - return self.recv(buff) - -class Socket(TSocket): - def __init__(self, host='localhost', port=7228, ssl=False): - TSocket.__init__(self, host, port) - self.ssl = ssl - - def open(self): - if self.ssl: - SSL = __import__("OpenSSL", globals(), locals(), "SSL", -1).SSL - WantReadError = SSL.WantReadError - ctx = SSL.Context(SSL.SSLv23_METHOD) - c = SSL.Connection(ctx, socket.socket(socket.AF_INET, socket.SOCK_STREAM)) - c.set_connect_state() - self.handle = SecureSocketConnection(c) - else: - self.handle = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - - #errno 104 connection reset - - self.handle.settimeout(self._timeout) - self.handle.connect((self.host, self.port)) - - def read(self, sz): - try: - buff = self.handle.recv(sz) - except socket.error, e: - if (e.args[0] == errno.ECONNRESET and - (sys.platform == 'darwin' or sys.platform.startswith('freebsd'))): - # freebsd and Mach don't follow POSIX semantic of recv - # and fail with ECONNRESET if peer performed shutdown. - # See corresponding comment and code in TSocket::read() - # in lib/cpp/src/transport/TSocket.cpp. - self.close() - # Trigger the check to raise the END_OF_FILE exception below. - buff = '' - else: - raise - except Exception, e: - # SSL connection was closed - if e.args == (-1, 'Unexpected EOF'): - buff = '' - elif e.args == ([('SSL routines', 'SSL23_GET_CLIENT_HELLO', 'unknown protocol')],): - #a socket not using ssl tried to connect - buff = '' - else: - raise - - if not len(buff): - raise TTransportException(type=TTransportException.END_OF_FILE, message='TSocket read 0 bytes') - return buff - - -class ServerSocket(TServerSocket, Socket): - def __init__(self, port=7228, host="0.0.0.0", key="", cert=""): - self.host = host - self.port = port - self.key = key - self.cert = cert - self.handle = None - - def listen(self): - if self.cert and self.key: - SSL = __import__("OpenSSL", globals(), locals(), "SSL", -1).SSL - WantReadError = SSL.WantReadError - ctx = SSL.Context(SSL.SSLv23_METHOD) - ctx.use_privatekey_file(self.key) - ctx.use_certificate_file(self.cert) - - tmpConnection = SSL.Connection(ctx, socket.socket(socket.AF_INET, socket.SOCK_STREAM)) - tmpConnection.set_accept_state() - self.handle = SecureSocketConnection(tmpConnection) - - else: - self.handle = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - - - self.handle.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - if hasattr(self.handle, 'set_timeout'): - self.handle.set_timeout(None) - self.handle.bind((self.host, self.port)) - self.handle.listen(128) - - def accept(self): - client, addr = self.handle.accept() - result = Socket() - result.setHandle(client) - return result diff --git a/module/remote/thriftbackend/ThriftClient.py b/module/remote/thriftbackend/ThriftClient.py deleted file mode 100644 index 74363cf62..000000000 --- a/module/remote/thriftbackend/ThriftClient.py +++ /dev/null @@ -1,109 +0,0 @@ -# -*- coding: utf-8 -*- - -import sys -from socket import error -from os.path import dirname, abspath, join -from traceback import print_exc - -try: - import thrift -except ImportError: - sys.path.append(abspath(join(dirname(abspath(__file__)), "..", "..", "lib"))) - -from thrift.transport import TTransport -#from thrift.transport.TZlibTransport import TZlibTransport -from Socket import Socket -from Protocol import Protocol - -# modules should import ttypes from here, when want to avoid importing API - -from thriftgen.pyload import Pyload -from thriftgen.pyload.ttypes import * - -ConnectionClosed = TTransport.TTransportException - -class WrongLogin(Exception): - pass - -class NoConnection(Exception): - pass - -class NoSSL(Exception): - pass - -class ThriftClient: - def __init__(self, host="localhost", port=7227, user="", password=""): - - self.createConnection(host, port) - try: - self.transport.open() - except error, e: - if e.args and e.args[0] in (111, 10061): - raise NoConnection - else: - print_exc() - raise NoConnection - - try: - correct = self.client.login(user, password) - except error, e: - if e.args and e.args[0] == 104: - #connection reset by peer, probably wants ssl - try: - self.createConnection(host, port, True) - #set timeout or a ssl socket will block when querying none ssl server - self.socket.setTimeout(10) - - except ImportError: - #@TODO untested - raise NoSSL - try: - self.transport.open() - correct = self.client.login(user, password) - finally: - self.socket.setTimeout(None) - elif e.args and e.args[0] == 32: - raise NoConnection - else: - print_exc() - raise NoConnection - - if not correct: - self.transport.close() - raise WrongLogin - - def createConnection(self, host, port, ssl=False): - self.socket = Socket(host, port, ssl) - self.transport = TTransport.TBufferedTransport(self.socket) -# self.transport = TZlibTransport(TTransport.TBufferedTransport(self.socket)) - - protocol = Protocol(self.transport) - self.client = Pyload.Client(protocol) - - def close(self): - self.transport.close() - - def __getattr__(self, item): - return getattr(self.client, item) - -if __name__ == "__main__": - - client = ThriftClient(user="User", password="pwhere") - - print client.getServerVersion() - print client.statusServer() - print client.statusDownloads() - q = client.getQueue() - -# for p in q: -# data = client.getPackageData(p.pid) -# print data -# print "Package Name: ", data.name - - - print client.getServices() - print client.call(Pyload.ServiceCall("UpdateManager", "recheckForUpdates")) - - print client.getConfigValue("download", "limit_speed", "core") - - client.close()
\ No newline at end of file diff --git a/module/remote/thriftbackend/ThriftTest.py b/module/remote/thriftbackend/ThriftTest.py deleted file mode 100644 index 69ac6a745..000000000 --- a/module/remote/thriftbackend/ThriftTest.py +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import sys -from os.path import join,abspath,dirname - -path = join((abspath(dirname(__file__))), "..","..", "lib") -sys.path.append(path) - -from thriftgen.pyload import Pyload -from thriftgen.pyload.ttypes import * -from Socket import Socket - -from thrift import Thrift -from thrift.transport import TTransport - -from Protocol import Protocol - -from time import time - -import xmlrpclib - -def bench(f, *args, **kwargs): - s = time() - ret = [f(*args, **kwargs) for i in range(0,100)] - e = time() - try: - print "%s: %f s" % (f._Method__name, e-s) - except : - print "%s: %f s" % (f.__name__, e-s) - return ret - -from getpass import getpass -user = raw_input("user ") -passwd = getpass("password ") - -server_url = "http%s://%s:%s@%s:%s/" % ( - "", - user, - passwd, - "127.0.0.1", - 7227 -) -proxy = xmlrpclib.ServerProxy(server_url, allow_none=True) - -bench(proxy.get_server_version) -bench(proxy.status_server) -bench(proxy.status_downloads) -#bench(proxy.get_queue) -#bench(proxy.get_collector) -print -try: - - # Make socket - transport = Socket('localhost', 7228, False) - - # Buffering is critical. Raw sockets are very slow - transport = TTransport.TBufferedTransport(transport) - - # Wrap in a protocol - protocol = Protocol(transport) - - # Create a client to use the protocol encoder - client = Pyload.Client(protocol) - - # Connect! - transport.open() - - print "Login", client.login(user, passwd) - - bench(client.getServerVersion) - bench(client.statusServer) - bench(client.statusDownloads) - #bench(client.getQueue) - #bench(client.getCollector) - - print - print client.getServerVersion() - print client.statusServer() - print client.statusDownloads() - q = client.getQueue() - - for p in q: - data = client.getPackageData(p.pid) - print data - print "Package Name: ", data.name - - # Close! - transport.close() - -except Thrift.TException, tx: - print 'ThriftExpection: %s' % tx.message diff --git a/module/remote/thriftbackend/Transport.py b/module/remote/thriftbackend/Transport.py deleted file mode 100644 index 5772c5a9e..000000000 --- a/module/remote/thriftbackend/Transport.py +++ /dev/null @@ -1,37 +0,0 @@ -# -*- coding: utf-8 -*- - -from thrift.transport.TTransport import TBufferedTransport -from thrift.transport.TZlibTransport import TZlibTransport - -class Transport(TBufferedTransport): - DEFAULT_BUFFER = 4096 - - def __init__(self, trans, rbuf_size = DEFAULT_BUFFER): - TBufferedTransport.__init__(self, trans, rbuf_size) - self.handle = trans.handle - self.remoteaddr = trans.handle.getpeername() - -class TransportCompressed(TZlibTransport): - DEFAULT_BUFFER = 4096 - - def __init__(self, trans, rbuf_size = DEFAULT_BUFFER): - TZlibTransport.__init__(self, trans, rbuf_size) - self.handle = trans.handle - self.remoteaddr = trans.handle.getpeername() - -class TransportFactory: - def getTransport(self, trans): - buffered = Transport(trans) - return buffered - -class TransportFactoryCompressed: - _last_trans = None - _last_z = None - - def getTransport(self, trans, compresslevel=9): - if trans == self._last_trans: - return self._last_z - ztrans = TransportCompressed(Transport(trans), compresslevel) - self._last_trans = trans - self._last_z = ztrans - return ztrans
\ No newline at end of file diff --git a/module/remote/thriftbackend/__init__.py b/module/remote/thriftbackend/__init__.py deleted file mode 100644 index e69de29bb..000000000 --- a/module/remote/thriftbackend/__init__.py +++ /dev/null diff --git a/module/remote/thriftbackend/pyload.thrift b/module/remote/thriftbackend/pyload.thrift deleted file mode 100644 index 1542e651a..000000000 --- a/module/remote/thriftbackend/pyload.thrift +++ /dev/null @@ -1,337 +0,0 @@ -namespace java org.pyload.thrift - -typedef i32 FileID -typedef i32 PackageID -typedef i32 TaskID -typedef i32 ResultID -typedef i32 InteractionID -typedef list<string> LinkList -typedef string PluginName -typedef byte Progress -typedef byte Priority - - -enum DownloadStatus { - Finished - Offline, - Online, - Queued, - Skipped, - Waiting, - TempOffline, - Starting, - Failed, - Aborted, - Decrypting, - Custom, - Downloading, - Processing, - Unknown -} - -enum Destination { - Collector, - Queue -} - -enum ElementType { - Package, - File -} - -// types for user interaction -// some may only be place holder currently not supported -// also all input - output combination are not reasonable, see InteractionManager for further info -enum Input { - NONE, - TEXT, - TEXTBOX, - PASSWORD, - BOOL, // confirm like, yes or no dialog - CLICK, // for positional captchas - CHOICE, // choice from list - MULTIPLE, // multiple choice from list of elements - LIST, // arbitary list of elements - TABLE // table like data structure -} -// more can be implemented by need - -// this describes the type of the outgoing interaction -// ensure they can be logcial or'ed -enum Output { - CAPTCHA = 1, - QUESTION = 2, - NOTIFICATION = 4, -} - -struct DownloadInfo { - 1: FileID fid, - 2: string name, - 3: i64 speed, - 4: i32 eta, - 5: string format_eta, - 6: i64 bleft, - 7: i64 size, - 8: string format_size, - 9: Progress percent, - 10: DownloadStatus status, - 11: string statusmsg, - 12: string format_wait, - 13: i64 wait_until, - 14: PackageID packageID, - 15: string packageName, - 16: PluginName plugin, -} - -struct ServerStatus { - 1: bool pause, - 2: i16 active, - 3: i16 queue, - 4: i16 total, - 5: i64 speed, - 6: bool download, - 7: bool reconnect -} - -struct ConfigItem { - 1: string name, - 2: string description, - 3: string value, - 4: string type, -} - -struct ConfigSection { - 1: string name, - 2: string description, - 3: list<ConfigItem> items, - 4: optional string outline -} - -struct FileData { - 1: FileID fid, - 2: string url, - 3: string name, - 4: PluginName plugin, - 5: i64 size, - 6: string format_size, - 7: DownloadStatus status, - 8: string statusmsg, - 9: PackageID packageID, - 10: string error, - 11: i16 order -} - -struct PackageData { - 1: PackageID pid, - 2: string name, - 3: string folder, - 4: string site, - 5: string password, - 6: Destination dest, - 7: i16 order, - 8: optional i16 linksdone, - 9: optional i64 sizedone, - 10: optional i64 sizetotal, - 11: optional i16 linkstotal, - 12: optional list<FileData> links, - 13: optional list<FileID> fids -} - -struct InteractionTask { - 1: InteractionID iid, - 2: Input input, - 3: list<string> structure, - 4: list<string> preset, - 5: Output output, - 6: list<string> data, - 7: string title, - 8: string description, - 9: string plugin, -} - -struct CaptchaTask { - 1: i16 tid, - 2: binary data, - 3: string type, - 4: string resultType -} - -struct EventInfo { - 1: string eventname, - 2: optional i32 id, - 3: optional ElementType type, - 4: optional Destination destination -} - -struct UserData { - 1: string name, - 2: string email, - 3: i32 role, - 4: i32 permission, - 5: string templateName -} - -struct AccountInfo { - 1: i64 validuntil, - 2: string login, - 3: map<string, list<string>> options, - 4: bool valid, - 5: i64 trafficleft, - 6: i64 maxtraffic, - 7: bool premium, - 8: string type, -} - -struct ServiceCall { - 1: PluginName plugin, - 2: string func, - 3: optional list<string> arguments, - 4: optional bool parseArguments, //default False -} - -struct OnlineStatus { - 1: string name, - 2: PluginName plugin, - 3: string packagename, - 4: DownloadStatus status, - 5: i64 size, // size <= 0 : unknown -} - -struct OnlineCheck { - 1: ResultID rid, // -1 -> nothing more to get - 2: map<string, OnlineStatus> data, //url to result -} - - -// exceptions - -exception PackageDoesNotExists{ - 1: PackageID pid -} - -exception FileDoesNotExists{ - 1: FileID fid -} - -exception ServiceDoesNotExists{ - 1: string plugin - 2: string func -} - -exception ServiceException{ - 1: string msg -} - -service Pyload { - - //config - string getConfigValue(1: string category, 2: string option, 3: string section), - void setConfigValue(1: string category, 2: string option, 3: string value, 4: string section), - map<string, ConfigSection> getConfig(), - map<string, ConfigSection> getPluginConfig(), - - // server status - void pauseServer(), - void unpauseServer(), - bool togglePause(), - ServerStatus statusServer(), - i64 freeSpace(), - string getServerVersion(), - void kill(), - void restart(), - list<string> getLog(1: i32 offset), - bool isTimeDownload(), - bool isTimeReconnect(), - bool toggleReconnect(), - - // download preparing - - // packagename - urls - map<string, LinkList> generatePackages(1: LinkList links), - map<PluginName, LinkList> checkURLs(1: LinkList urls), - map<PluginName, LinkList> parseURLs(1: string html, 2: string url), - - // parses results and generates packages - OnlineCheck checkOnlineStatus(1: LinkList urls), - OnlineCheck checkOnlineStatusContainer(1: LinkList urls, 2: string filename, 3: binary data) - - // poll results from previosly started online check - OnlineCheck pollResults(1: ResultID rid), - - // downloads - information - list<DownloadInfo> statusDownloads(), - 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), - 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 - list<PackageID> generateAndAddPackages(1: LinkList links, 2: Destination dest), - 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), - void restartFile(1: FileID fid), - void recheckPackage(1: PackageID pid), - void stopAllDownloads(), - void stopDownloads(1: list<FileID> fids), - void setPackageName(1: PackageID pid, 2: string name), - void movePackage(1: Destination destination, 2: PackageID pid), - void moveFiles(1: list<FileID> fids, 2: PackageID pid), - 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) throws (1: PackageDoesNotExists e), - list<PackageID> deleteFinished(), - void restartFailed(), - - //events - list<EventInfo> getEvents(1: string uuid) - - //accounts - list<AccountInfo> getAccounts(1: bool refresh), - list<string> getAccountTypes() - void updateAccount(1: PluginName plugin, 2: string account, 3: string password, 4: map<string, string> options), - void removeAccount(1: PluginName plugin, 2: string account), - - //auth - bool login(1: string username, 2: string password), - UserData getUserData(1: string username, 2:string password), - map<string, UserData> getAllUserData(), - - //services - - // servicename : description - map<PluginName, map<string, string>> getServices(), - bool hasService(1: PluginName plugin, 2: string func), - string call(1: ServiceCall info) throws (1: ServiceDoesNotExists ex, 2: ServiceException e), - - - //info - // {plugin: {name: value}} - map<PluginName, map<string,string>> getAllInfo(), - map<string, string> getInfoByPlugin(1: PluginName plugin), - - //scheduler - - // TODO - - - // User interaction - - //captcha - bool isCaptchaWaiting(), - CaptchaTask getCaptchaTask(1: bool exclusive), - string getCaptchaTaskStatus(1: TaskID tid), - void setCaptchaResult(1: TaskID tid, 2: string result), -} diff --git a/module/remote/thriftbackend/thriftgen/__init__.py b/module/remote/thriftbackend/thriftgen/__init__.py deleted file mode 100644 index e69de29bb..000000000 --- a/module/remote/thriftbackend/thriftgen/__init__.py +++ /dev/null diff --git a/module/remote/thriftbackend/thriftgen/pyload/Pyload-remote b/module/remote/thriftbackend/thriftgen/pyload/Pyload-remote deleted file mode 100755 index bfaf5b078..000000000 --- a/module/remote/thriftbackend/thriftgen/pyload/Pyload-remote +++ /dev/null @@ -1,571 +0,0 @@ -#!/usr/bin/env python -# -# Autogenerated by Thrift Compiler (0.9.0-dev) -# -# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -# -# options string: py:slots,dynamic -# - -import sys -import pprint -from urlparse import urlparse -from thrift.transport import TTransport -from thrift.transport import TSocket -from thrift.transport import THttpClient -from thrift.protocol import TBinaryProtocol - -import Pyload -from ttypes import * - -if len(sys.argv) <= 1 or sys.argv[1] == '--help': - print '' - print 'Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] function [arg1 [arg2...]]' - print '' - print 'Functions:' - print ' string getConfigValue(string category, string option, string section)' - print ' void setConfigValue(string category, string option, string value, string section)' - print ' getConfig()' - print ' getPluginConfig()' - print ' void pauseServer()' - print ' void unpauseServer()' - print ' bool togglePause()' - print ' ServerStatus statusServer()' - print ' i64 freeSpace()' - print ' string getServerVersion()' - print ' void kill()' - print ' void restart()' - print ' getLog(i32 offset)' - print ' bool isTimeDownload()' - print ' bool isTimeReconnect()' - print ' bool toggleReconnect()' - print ' generatePackages(LinkList links)' - print ' checkURLs(LinkList urls)' - print ' parseURLs(string html, string url)' - print ' OnlineCheck checkOnlineStatus(LinkList urls)' - print ' OnlineCheck checkOnlineStatusContainer(LinkList urls, string filename, string data)' - print ' OnlineCheck pollResults(ResultID rid)' - print ' statusDownloads()' - print ' PackageData getPackageData(PackageID pid)' - print ' PackageData getPackageInfo(PackageID pid)' - print ' FileData getFileData(FileID fid)' - print ' getQueue()' - print ' getCollector()' - print ' getQueueData()' - print ' getCollectorData()' - print ' getPackageOrder(Destination destination)' - print ' getFileOrder(PackageID pid)' - print ' generateAndAddPackages(LinkList links, Destination dest)' - 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)' - print ' void restartFile(FileID fid)' - print ' void recheckPackage(PackageID pid)' - print ' void stopAllDownloads()' - print ' void stopDownloads( fids)' - print ' void setPackageName(PackageID pid, string name)' - print ' void movePackage(Destination destination, PackageID pid)' - print ' void moveFiles( fids, PackageID pid)' - print ' void orderPackage(PackageID pid, i16 position)' - print ' void orderFile(FileID fid, i16 position)' - print ' void setPackageData(PackageID pid, data)' - print ' deleteFinished()' - print ' void restartFailed()' - print ' getEvents(string uuid)' - print ' getAccounts(bool refresh)' - print ' getAccountTypes()' - print ' void updateAccount(PluginName plugin, string account, string password, options)' - print ' void removeAccount(PluginName plugin, string account)' - print ' bool login(string username, string password)' - print ' UserData getUserData(string username, string password)' - print ' getAllUserData()' - print ' getServices()' - print ' bool hasService(PluginName plugin, string func)' - print ' string call(ServiceCall info)' - print ' getAllInfo()' - print ' getInfoByPlugin(PluginName plugin)' - print ' bool isCaptchaWaiting()' - print ' CaptchaTask getCaptchaTask(bool exclusive)' - print ' string getCaptchaTaskStatus(TaskID tid)' - print ' void setCaptchaResult(TaskID tid, string result)' - print '' - sys.exit(0) - -pp = pprint.PrettyPrinter(indent = 2) -host = 'localhost' -port = 9090 -uri = '' -framed = False -http = False -argi = 1 - -if sys.argv[argi] == '-h': - parts = sys.argv[argi+1].split(':') - host = parts[0] - if len(parts) > 1: - port = int(parts[1]) - argi += 2 - -if sys.argv[argi] == '-u': - url = urlparse(sys.argv[argi+1]) - parts = url[1].split(':') - host = parts[0] - if len(parts) > 1: - port = int(parts[1]) - else: - port = 80 - uri = url[2] - if url[4]: - uri += '?%s' % url[4] - http = True - argi += 2 - -if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed': - framed = True - argi += 1 - -cmd = sys.argv[argi] -args = sys.argv[argi+1:] - -if http: - transport = THttpClient.THttpClient(host, port, uri) -else: - socket = TSocket.TSocket(host, port) - if framed: - transport = TTransport.TFramedTransport(socket) - else: - transport = TTransport.TBufferedTransport(socket) -protocol = TBinaryProtocol.TBinaryProtocol(transport) -client = Pyload.Client(protocol) -transport.open() - -if cmd == 'getConfigValue': - if len(args) != 3: - print 'getConfigValue requires 3 args' - sys.exit(1) - pp.pprint(client.getConfigValue(args[0],args[1],args[2],)) - -elif cmd == 'setConfigValue': - if len(args) != 4: - print 'setConfigValue requires 4 args' - sys.exit(1) - pp.pprint(client.setConfigValue(args[0],args[1],args[2],args[3],)) - -elif cmd == 'getConfig': - if len(args) != 0: - print 'getConfig requires 0 args' - sys.exit(1) - pp.pprint(client.getConfig()) - -elif cmd == 'getPluginConfig': - if len(args) != 0: - print 'getPluginConfig requires 0 args' - sys.exit(1) - pp.pprint(client.getPluginConfig()) - -elif cmd == 'pauseServer': - if len(args) != 0: - print 'pauseServer requires 0 args' - sys.exit(1) - pp.pprint(client.pauseServer()) - -elif cmd == 'unpauseServer': - if len(args) != 0: - print 'unpauseServer requires 0 args' - sys.exit(1) - pp.pprint(client.unpauseServer()) - -elif cmd == 'togglePause': - if len(args) != 0: - print 'togglePause requires 0 args' - sys.exit(1) - pp.pprint(client.togglePause()) - -elif cmd == 'statusServer': - if len(args) != 0: - print 'statusServer requires 0 args' - sys.exit(1) - pp.pprint(client.statusServer()) - -elif cmd == 'freeSpace': - if len(args) != 0: - print 'freeSpace requires 0 args' - sys.exit(1) - pp.pprint(client.freeSpace()) - -elif cmd == 'getServerVersion': - if len(args) != 0: - print 'getServerVersion requires 0 args' - sys.exit(1) - pp.pprint(client.getServerVersion()) - -elif cmd == 'kill': - if len(args) != 0: - print 'kill requires 0 args' - sys.exit(1) - pp.pprint(client.kill()) - -elif cmd == 'restart': - if len(args) != 0: - print 'restart requires 0 args' - sys.exit(1) - pp.pprint(client.restart()) - -elif cmd == 'getLog': - if len(args) != 1: - print 'getLog requires 1 args' - sys.exit(1) - pp.pprint(client.getLog(eval(args[0]),)) - -elif cmd == 'isTimeDownload': - if len(args) != 0: - print 'isTimeDownload requires 0 args' - sys.exit(1) - pp.pprint(client.isTimeDownload()) - -elif cmd == 'isTimeReconnect': - if len(args) != 0: - print 'isTimeReconnect requires 0 args' - sys.exit(1) - pp.pprint(client.isTimeReconnect()) - -elif cmd == 'toggleReconnect': - if len(args) != 0: - print 'toggleReconnect requires 0 args' - sys.exit(1) - pp.pprint(client.toggleReconnect()) - -elif cmd == 'generatePackages': - if len(args) != 1: - print 'generatePackages requires 1 args' - sys.exit(1) - pp.pprint(client.generatePackages(eval(args[0]),)) - -elif cmd == 'checkURLs': - if len(args) != 1: - print 'checkURLs requires 1 args' - sys.exit(1) - pp.pprint(client.checkURLs(eval(args[0]),)) - -elif cmd == 'parseURLs': - if len(args) != 2: - print 'parseURLs requires 2 args' - sys.exit(1) - pp.pprint(client.parseURLs(args[0],args[1],)) - -elif cmd == 'checkOnlineStatus': - if len(args) != 1: - print 'checkOnlineStatus requires 1 args' - sys.exit(1) - pp.pprint(client.checkOnlineStatus(eval(args[0]),)) - -elif cmd == 'checkOnlineStatusContainer': - if len(args) != 3: - print 'checkOnlineStatusContainer requires 3 args' - sys.exit(1) - pp.pprint(client.checkOnlineStatusContainer(eval(args[0]),args[1],args[2],)) - -elif cmd == 'pollResults': - if len(args) != 1: - print 'pollResults requires 1 args' - sys.exit(1) - pp.pprint(client.pollResults(eval(args[0]),)) - -elif cmd == 'statusDownloads': - if len(args) != 0: - print 'statusDownloads requires 0 args' - sys.exit(1) - pp.pprint(client.statusDownloads()) - -elif cmd == 'getPackageData': - if len(args) != 1: - print 'getPackageData requires 1 args' - sys.exit(1) - pp.pprint(client.getPackageData(eval(args[0]),)) - -elif cmd == 'getPackageInfo': - if len(args) != 1: - print 'getPackageInfo requires 1 args' - sys.exit(1) - pp.pprint(client.getPackageInfo(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 == 'getQueue': - if len(args) != 0: - print 'getQueue requires 0 args' - sys.exit(1) - pp.pprint(client.getQueue()) - -elif cmd == 'getCollector': - if len(args) != 0: - print 'getCollector requires 0 args' - sys.exit(1) - pp.pprint(client.getCollector()) - -elif cmd == 'getQueueData': - if len(args) != 0: - print 'getQueueData requires 0 args' - sys.exit(1) - pp.pprint(client.getQueueData()) - -elif cmd == 'getCollectorData': - if len(args) != 0: - print 'getCollectorData requires 0 args' - 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 == 'generateAndAddPackages': - if len(args) != 2: - print 'generateAndAddPackages requires 2 args' - sys.exit(1) - pp.pprint(client.generateAndAddPackages(eval(args[0]),eval(args[1]),)) - -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' - sys.exit(1) - pp.pprint(client.pushToQueue(eval(args[0]),)) - -elif cmd == 'pullFromQueue': - if len(args) != 1: - print 'pullFromQueue requires 1 args' - sys.exit(1) - pp.pprint(client.pullFromQueue(eval(args[0]),)) - -elif cmd == 'restartPackage': - if len(args) != 1: - print 'restartPackage requires 1 args' - sys.exit(1) - pp.pprint(client.restartPackage(eval(args[0]),)) - -elif cmd == 'restartFile': - if len(args) != 1: - print 'restartFile requires 1 args' - sys.exit(1) - pp.pprint(client.restartFile(eval(args[0]),)) - -elif cmd == 'recheckPackage': - if len(args) != 1: - print 'recheckPackage requires 1 args' - sys.exit(1) - pp.pprint(client.recheckPackage(eval(args[0]),)) - -elif cmd == 'stopAllDownloads': - if len(args) != 0: - print 'stopAllDownloads requires 0 args' - sys.exit(1) - pp.pprint(client.stopAllDownloads()) - -elif cmd == 'stopDownloads': - if len(args) != 1: - print 'stopDownloads requires 1 args' - sys.exit(1) - pp.pprint(client.stopDownloads(eval(args[0]),)) - -elif cmd == 'setPackageName': - if len(args) != 2: - print 'setPackageName requires 2 args' - sys.exit(1) - pp.pprint(client.setPackageName(eval(args[0]),args[1],)) - -elif cmd == 'movePackage': - if len(args) != 2: - print 'movePackage requires 2 args' - sys.exit(1) - pp.pprint(client.movePackage(eval(args[0]),eval(args[1]),)) - -elif cmd == 'moveFiles': - if len(args) != 2: - print 'moveFiles requires 2 args' - sys.exit(1) - pp.pprint(client.moveFiles(eval(args[0]),eval(args[1]),)) - -elif cmd == 'orderPackage': - if len(args) != 2: - print 'orderPackage requires 2 args' - sys.exit(1) - pp.pprint(client.orderPackage(eval(args[0]),eval(args[1]),)) - -elif cmd == 'orderFile': - if len(args) != 2: - print 'orderFile requires 2 args' - sys.exit(1) - pp.pprint(client.orderFile(eval(args[0]),eval(args[1]),)) - -elif cmd == 'setPackageData': - if len(args) != 2: - print 'setPackageData requires 2 args' - sys.exit(1) - pp.pprint(client.setPackageData(eval(args[0]),eval(args[1]),)) - -elif cmd == 'deleteFinished': - if len(args) != 0: - print 'deleteFinished requires 0 args' - sys.exit(1) - pp.pprint(client.deleteFinished()) - -elif cmd == 'restartFailed': - if len(args) != 0: - print 'restartFailed requires 0 args' - sys.exit(1) - pp.pprint(client.restartFailed()) - -elif cmd == 'getEvents': - if len(args) != 1: - print 'getEvents requires 1 args' - sys.exit(1) - pp.pprint(client.getEvents(args[0],)) - -elif cmd == 'getAccounts': - if len(args) != 1: - print 'getAccounts requires 1 args' - sys.exit(1) - pp.pprint(client.getAccounts(eval(args[0]),)) - -elif cmd == 'getAccountTypes': - if len(args) != 0: - print 'getAccountTypes requires 0 args' - sys.exit(1) - pp.pprint(client.getAccountTypes()) - -elif cmd == 'updateAccount': - if len(args) != 4: - print 'updateAccount requires 4 args' - sys.exit(1) - pp.pprint(client.updateAccount(eval(args[0]),args[1],args[2],eval(args[3]),)) - -elif cmd == 'removeAccount': - if len(args) != 2: - print 'removeAccount requires 2 args' - sys.exit(1) - pp.pprint(client.removeAccount(eval(args[0]),args[1],)) - -elif cmd == 'login': - if len(args) != 2: - print 'login requires 2 args' - sys.exit(1) - pp.pprint(client.login(args[0],args[1],)) - -elif cmd == 'getUserData': - if len(args) != 2: - print 'getUserData requires 2 args' - sys.exit(1) - pp.pprint(client.getUserData(args[0],args[1],)) - -elif cmd == 'getAllUserData': - if len(args) != 0: - print 'getAllUserData requires 0 args' - sys.exit(1) - pp.pprint(client.getAllUserData()) - -elif cmd == 'getServices': - if len(args) != 0: - print 'getServices requires 0 args' - sys.exit(1) - pp.pprint(client.getServices()) - -elif cmd == 'hasService': - if len(args) != 2: - print 'hasService requires 2 args' - sys.exit(1) - pp.pprint(client.hasService(eval(args[0]),args[1],)) - -elif cmd == 'call': - if len(args) != 1: - print 'call requires 1 args' - sys.exit(1) - pp.pprint(client.call(eval(args[0]),)) - -elif cmd == 'getAllInfo': - if len(args) != 0: - print 'getAllInfo requires 0 args' - sys.exit(1) - pp.pprint(client.getAllInfo()) - -elif cmd == 'getInfoByPlugin': - if len(args) != 1: - print 'getInfoByPlugin requires 1 args' - sys.exit(1) - pp.pprint(client.getInfoByPlugin(eval(args[0]),)) - -elif cmd == 'isCaptchaWaiting': - if len(args) != 0: - print 'isCaptchaWaiting requires 0 args' - sys.exit(1) - pp.pprint(client.isCaptchaWaiting()) - -elif cmd == 'getCaptchaTask': - if len(args) != 1: - print 'getCaptchaTask requires 1 args' - sys.exit(1) - pp.pprint(client.getCaptchaTask(eval(args[0]),)) - -elif cmd == 'getCaptchaTaskStatus': - if len(args) != 1: - print 'getCaptchaTaskStatus requires 1 args' - sys.exit(1) - pp.pprint(client.getCaptchaTaskStatus(eval(args[0]),)) - -elif cmd == 'setCaptchaResult': - if len(args) != 2: - print 'setCaptchaResult requires 2 args' - sys.exit(1) - pp.pprint(client.setCaptchaResult(eval(args[0]),args[1],)) - -else: - print 'Unrecognized method %s' % cmd - sys.exit(1) - -transport.close() diff --git a/module/remote/thriftbackend/thriftgen/pyload/Pyload.py b/module/remote/thriftbackend/thriftgen/pyload/Pyload.py deleted file mode 100644 index 78a42f16a..000000000 --- a/module/remote/thriftbackend/thriftgen/pyload/Pyload.py +++ /dev/null @@ -1,5534 +0,0 @@ -# -# Autogenerated by Thrift Compiler (0.9.0-dev) -# -# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -# -# options string: py:slots,dynamic -# - -from thrift.Thrift import TType, TMessageType, TException -from ttypes import * -from thrift.Thrift import TProcessor -from thrift.protocol.TBase import TBase, TExceptionBase - - -class Iface(object): - def getConfigValue(self, category, option, section): - """ - Parameters: - - category - - option - - section - """ - pass - - def setConfigValue(self, category, option, value, section): - """ - Parameters: - - category - - option - - value - - section - """ - pass - - def getConfig(self, ): - pass - - def getPluginConfig(self, ): - pass - - def pauseServer(self, ): - pass - - def unpauseServer(self, ): - pass - - def togglePause(self, ): - pass - - def statusServer(self, ): - pass - - def freeSpace(self, ): - pass - - def getServerVersion(self, ): - pass - - def kill(self, ): - pass - - def restart(self, ): - pass - - def getLog(self, offset): - """ - Parameters: - - offset - """ - pass - - def isTimeDownload(self, ): - pass - - def isTimeReconnect(self, ): - pass - - def toggleReconnect(self, ): - pass - - def generatePackages(self, links): - """ - Parameters: - - links - """ - pass - - def checkURLs(self, urls): - """ - Parameters: - - urls - """ - pass - - def parseURLs(self, html, url): - """ - Parameters: - - html - - url - """ - pass - - def checkOnlineStatus(self, urls): - """ - Parameters: - - urls - """ - pass - - def checkOnlineStatusContainer(self, urls, filename, data): - """ - Parameters: - - urls - - filename - - data - """ - pass - - def pollResults(self, rid): - """ - Parameters: - - rid - """ - pass - - def statusDownloads(self, ): - pass - - def getPackageData(self, pid): - """ - Parameters: - - pid - """ - pass - - def getPackageInfo(self, pid): - """ - Parameters: - - pid - """ - pass - - def getFileData(self, fid): - """ - Parameters: - - fid - """ - pass - - def getQueue(self, ): - pass - - def getCollector(self, ): - pass - - def getQueueData(self, ): - pass - - def getCollectorData(self, ): - pass - - def getPackageOrder(self, destination): - """ - Parameters: - - destination - """ - pass - - def getFileOrder(self, pid): - """ - Parameters: - - pid - """ - pass - - def generateAndAddPackages(self, links, dest): - """ - Parameters: - - links - - dest - """ - pass - - def addPackage(self, name, links, dest): - """ - Parameters: - - name - - links - - dest - """ - pass - - def addFiles(self, pid, links): - """ - Parameters: - - pid - - links - """ - pass - - def uploadContainer(self, filename, data): - """ - Parameters: - - filename - - data - """ - pass - - def deleteFiles(self, fids): - """ - Parameters: - - fids - """ - pass - - def deletePackages(self, pids): - """ - Parameters: - - pids - """ - pass - - def pushToQueue(self, pid): - """ - Parameters: - - pid - """ - pass - - def pullFromQueue(self, pid): - """ - Parameters: - - pid - """ - pass - - def restartPackage(self, pid): - """ - Parameters: - - pid - """ - pass - - def restartFile(self, fid): - """ - Parameters: - - fid - """ - pass - - def recheckPackage(self, pid): - """ - Parameters: - - pid - """ - pass - - def stopAllDownloads(self, ): - pass - - def stopDownloads(self, fids): - """ - Parameters: - - fids - """ - pass - - def setPackageName(self, pid, name): - """ - Parameters: - - pid - - name - """ - pass - - def movePackage(self, destination, pid): - """ - Parameters: - - destination - - pid - """ - pass - - def moveFiles(self, fids, pid): - """ - Parameters: - - fids - - pid - """ - pass - - def orderPackage(self, pid, position): - """ - Parameters: - - pid - - position - """ - pass - - def orderFile(self, fid, position): - """ - Parameters: - - fid - - position - """ - pass - - def setPackageData(self, pid, data): - """ - Parameters: - - pid - - data - """ - pass - - def deleteFinished(self, ): - pass - - def restartFailed(self, ): - pass - - def getEvents(self, uuid): - """ - Parameters: - - uuid - """ - pass - - def getAccounts(self, refresh): - """ - Parameters: - - refresh - """ - pass - - def getAccountTypes(self, ): - pass - - def updateAccount(self, plugin, account, password, options): - """ - Parameters: - - plugin - - account - - password - - options - """ - pass - - def removeAccount(self, plugin, account): - """ - Parameters: - - plugin - - account - """ - pass - - def login(self, username, password): - """ - Parameters: - - username - - password - """ - pass - - def getUserData(self, username, password): - """ - Parameters: - - username - - password - """ - pass - - def getAllUserData(self, ): - pass - - def getServices(self, ): - pass - - def hasService(self, plugin, func): - """ - Parameters: - - plugin - - func - """ - pass - - def call(self, info): - """ - Parameters: - - info - """ - pass - - def getAllInfo(self, ): - pass - - def getInfoByPlugin(self, plugin): - """ - Parameters: - - plugin - """ - pass - - def isCaptchaWaiting(self, ): - pass - - def getCaptchaTask(self, exclusive): - """ - Parameters: - - exclusive - """ - pass - - def getCaptchaTaskStatus(self, tid): - """ - Parameters: - - tid - """ - pass - - def setCaptchaResult(self, tid, result): - """ - Parameters: - - tid - - result - """ - pass - - -class Client(Iface): - def __init__(self, iprot, oprot=None): - self._iprot = self._oprot = iprot - if oprot is not None: - self._oprot = oprot - self._seqid = 0 - - def getConfigValue(self, category, option, section): - """ - Parameters: - - category - - option - - section - """ - self.send_getConfigValue(category, option, section) - return self.recv_getConfigValue() - - def send_getConfigValue(self, category, option, section): - self._oprot.writeMessageBegin('getConfigValue', TMessageType.CALL, self._seqid) - args = getConfigValue_args() - args.category = category - args.option = option - args.section = section - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getConfigValue(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getConfigValue_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "getConfigValue failed: unknown result"); - - def setConfigValue(self, category, option, value, section): - """ - Parameters: - - category - - option - - value - - section - """ - self.send_setConfigValue(category, option, value, section) - self.recv_setConfigValue() - - def send_setConfigValue(self, category, option, value, section): - self._oprot.writeMessageBegin('setConfigValue', TMessageType.CALL, self._seqid) - args = setConfigValue_args() - args.category = category - args.option = option - args.value = value - args.section = section - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_setConfigValue(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = setConfigValue_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - return - - def getConfig(self, ): - self.send_getConfig() - return self.recv_getConfig() - - def send_getConfig(self, ): - self._oprot.writeMessageBegin('getConfig', TMessageType.CALL, self._seqid) - args = getConfig_args() - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getConfig(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getConfig_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "getConfig failed: unknown result"); - - def getPluginConfig(self, ): - self.send_getPluginConfig() - return self.recv_getPluginConfig() - - def send_getPluginConfig(self, ): - self._oprot.writeMessageBegin('getPluginConfig', TMessageType.CALL, self._seqid) - args = getPluginConfig_args() - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getPluginConfig(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getPluginConfig_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "getPluginConfig failed: unknown result"); - - def pauseServer(self, ): - self.send_pauseServer() - self.recv_pauseServer() - - def send_pauseServer(self, ): - self._oprot.writeMessageBegin('pauseServer', TMessageType.CALL, self._seqid) - args = pauseServer_args() - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_pauseServer(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = pauseServer_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - return - - def unpauseServer(self, ): - self.send_unpauseServer() - self.recv_unpauseServer() - - def send_unpauseServer(self, ): - self._oprot.writeMessageBegin('unpauseServer', TMessageType.CALL, self._seqid) - args = unpauseServer_args() - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_unpauseServer(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = unpauseServer_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - return - - def togglePause(self, ): - self.send_togglePause() - return self.recv_togglePause() - - def send_togglePause(self, ): - self._oprot.writeMessageBegin('togglePause', TMessageType.CALL, self._seqid) - args = togglePause_args() - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_togglePause(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = togglePause_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "togglePause failed: unknown result"); - - def statusServer(self, ): - self.send_statusServer() - return self.recv_statusServer() - - def send_statusServer(self, ): - self._oprot.writeMessageBegin('statusServer', TMessageType.CALL, self._seqid) - args = statusServer_args() - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_statusServer(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = statusServer_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "statusServer failed: unknown result"); - - def freeSpace(self, ): - self.send_freeSpace() - return self.recv_freeSpace() - - def send_freeSpace(self, ): - self._oprot.writeMessageBegin('freeSpace', TMessageType.CALL, self._seqid) - args = freeSpace_args() - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_freeSpace(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = freeSpace_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "freeSpace failed: unknown result"); - - def getServerVersion(self, ): - self.send_getServerVersion() - return self.recv_getServerVersion() - - def send_getServerVersion(self, ): - self._oprot.writeMessageBegin('getServerVersion', TMessageType.CALL, self._seqid) - args = getServerVersion_args() - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getServerVersion(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getServerVersion_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "getServerVersion failed: unknown result"); - - def kill(self, ): - self.send_kill() - self.recv_kill() - - def send_kill(self, ): - self._oprot.writeMessageBegin('kill', TMessageType.CALL, self._seqid) - args = kill_args() - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_kill(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = kill_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - return - - def restart(self, ): - self.send_restart() - self.recv_restart() - - def send_restart(self, ): - self._oprot.writeMessageBegin('restart', TMessageType.CALL, self._seqid) - args = restart_args() - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_restart(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = restart_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - return - - def getLog(self, offset): - """ - Parameters: - - offset - """ - self.send_getLog(offset) - return self.recv_getLog() - - def send_getLog(self, offset): - self._oprot.writeMessageBegin('getLog', TMessageType.CALL, self._seqid) - args = getLog_args() - args.offset = offset - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getLog(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getLog_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "getLog failed: unknown result"); - - def isTimeDownload(self, ): - self.send_isTimeDownload() - return self.recv_isTimeDownload() - - def send_isTimeDownload(self, ): - self._oprot.writeMessageBegin('isTimeDownload', TMessageType.CALL, self._seqid) - args = isTimeDownload_args() - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_isTimeDownload(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = isTimeDownload_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "isTimeDownload failed: unknown result"); - - def isTimeReconnect(self, ): - self.send_isTimeReconnect() - return self.recv_isTimeReconnect() - - def send_isTimeReconnect(self, ): - self._oprot.writeMessageBegin('isTimeReconnect', TMessageType.CALL, self._seqid) - args = isTimeReconnect_args() - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_isTimeReconnect(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = isTimeReconnect_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "isTimeReconnect failed: unknown result"); - - def toggleReconnect(self, ): - self.send_toggleReconnect() - return self.recv_toggleReconnect() - - def send_toggleReconnect(self, ): - self._oprot.writeMessageBegin('toggleReconnect', TMessageType.CALL, self._seqid) - args = toggleReconnect_args() - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_toggleReconnect(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = toggleReconnect_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "toggleReconnect failed: unknown result"); - - def generatePackages(self, links): - """ - Parameters: - - links - """ - self.send_generatePackages(links) - return self.recv_generatePackages() - - def send_generatePackages(self, links): - self._oprot.writeMessageBegin('generatePackages', TMessageType.CALL, self._seqid) - args = generatePackages_args() - args.links = links - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_generatePackages(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = generatePackages_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "generatePackages failed: unknown result"); - - def checkURLs(self, urls): - """ - Parameters: - - urls - """ - self.send_checkURLs(urls) - return self.recv_checkURLs() - - def send_checkURLs(self, urls): - self._oprot.writeMessageBegin('checkURLs', TMessageType.CALL, self._seqid) - args = checkURLs_args() - args.urls = urls - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_checkURLs(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = checkURLs_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "checkURLs failed: unknown result"); - - def parseURLs(self, html, url): - """ - Parameters: - - html - - url - """ - self.send_parseURLs(html, url) - return self.recv_parseURLs() - - def send_parseURLs(self, html, url): - self._oprot.writeMessageBegin('parseURLs', TMessageType.CALL, self._seqid) - args = parseURLs_args() - args.html = html - args.url = url - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_parseURLs(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = parseURLs_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "parseURLs failed: unknown result"); - - def checkOnlineStatus(self, urls): - """ - Parameters: - - urls - """ - self.send_checkOnlineStatus(urls) - return self.recv_checkOnlineStatus() - - def send_checkOnlineStatus(self, urls): - self._oprot.writeMessageBegin('checkOnlineStatus', TMessageType.CALL, self._seqid) - args = checkOnlineStatus_args() - args.urls = urls - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_checkOnlineStatus(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = checkOnlineStatus_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "checkOnlineStatus failed: unknown result"); - - def checkOnlineStatusContainer(self, urls, filename, data): - """ - Parameters: - - urls - - filename - - data - """ - self.send_checkOnlineStatusContainer(urls, filename, data) - return self.recv_checkOnlineStatusContainer() - - def send_checkOnlineStatusContainer(self, urls, filename, data): - self._oprot.writeMessageBegin('checkOnlineStatusContainer', TMessageType.CALL, self._seqid) - args = checkOnlineStatusContainer_args() - args.urls = urls - args.filename = filename - args.data = data - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_checkOnlineStatusContainer(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = checkOnlineStatusContainer_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "checkOnlineStatusContainer failed: unknown result"); - - def pollResults(self, rid): - """ - Parameters: - - rid - """ - self.send_pollResults(rid) - return self.recv_pollResults() - - def send_pollResults(self, rid): - self._oprot.writeMessageBegin('pollResults', TMessageType.CALL, self._seqid) - args = pollResults_args() - args.rid = rid - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_pollResults(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = pollResults_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "pollResults failed: unknown result"); - - def statusDownloads(self, ): - self.send_statusDownloads() - return self.recv_statusDownloads() - - def send_statusDownloads(self, ): - self._oprot.writeMessageBegin('statusDownloads', TMessageType.CALL, self._seqid) - args = statusDownloads_args() - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_statusDownloads(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = statusDownloads_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "statusDownloads failed: unknown result"); - - def getPackageData(self, pid): - """ - Parameters: - - pid - """ - self.send_getPackageData(pid) - return self.recv_getPackageData() - - 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_getPackageData(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.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"); - - def getPackageInfo(self, pid): - """ - Parameters: - - pid - """ - self.send_getPackageInfo(pid) - return self.recv_getPackageInfo() - - 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_getPackageInfo(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - 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, "getPackageInfo failed: unknown result"); - - def getFileData(self, fid): - """ - Parameters: - - fid - """ - self.send_getFileData(fid) - return self.recv_getFileData() - - def send_getFileData(self, fid): - self._oprot.writeMessageBegin('getFileData', TMessageType.CALL, self._seqid) - args = getFileData_args() - args.fid = fid - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getFileData(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getFileData_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, "getFileData failed: unknown result"); - - def getQueue(self, ): - self.send_getQueue() - return self.recv_getQueue() - - def send_getQueue(self, ): - self._oprot.writeMessageBegin('getQueue', TMessageType.CALL, self._seqid) - args = getQueue_args() - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getQueue(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getQueue_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "getQueue failed: unknown result"); - - def getCollector(self, ): - self.send_getCollector() - return self.recv_getCollector() - - def send_getCollector(self, ): - self._oprot.writeMessageBegin('getCollector', TMessageType.CALL, self._seqid) - args = getCollector_args() - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getCollector(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getCollector_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "getCollector failed: unknown result"); - - def getQueueData(self, ): - self.send_getQueueData() - return self.recv_getQueueData() - - def send_getQueueData(self, ): - self._oprot.writeMessageBegin('getQueueData', TMessageType.CALL, self._seqid) - args = getQueueData_args() - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getQueueData(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getQueueData_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "getQueueData failed: unknown result"); - - def getCollectorData(self, ): - self.send_getCollectorData() - return self.recv_getCollectorData() - - def send_getCollectorData(self, ): - self._oprot.writeMessageBegin('getCollectorData', TMessageType.CALL, self._seqid) - args = getCollectorData_args() - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getCollectorData(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getCollectorData_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - 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 generateAndAddPackages(self, links, dest): - """ - Parameters: - - links - - dest - """ - self.send_generateAndAddPackages(links, dest) - return self.recv_generateAndAddPackages() - - def send_generateAndAddPackages(self, links, dest): - self._oprot.writeMessageBegin('generateAndAddPackages', TMessageType.CALL, self._seqid) - args = generateAndAddPackages_args() - args.links = links - args.dest = dest - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_generateAndAddPackages(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = generateAndAddPackages_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "generateAndAddPackages 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: - - pid - - links - """ - self.send_addFiles(pid, links) - self.recv_addFiles() - - def send_addFiles(self, pid, links): - self._oprot.writeMessageBegin('addFiles', TMessageType.CALL, self._seqid) - args = addFiles_args() - args.pid = pid - args.links = links - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_addFiles(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = addFiles_result() - result.read(self._iprot) - 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: - - pid - """ - self.send_pushToQueue(pid) - self.recv_pushToQueue() - - def send_pushToQueue(self, pid): - self._oprot.writeMessageBegin('pushToQueue', TMessageType.CALL, self._seqid) - args = pushToQueue_args() - args.pid = pid - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_pushToQueue(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = pushToQueue_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - return - - def pullFromQueue(self, pid): - """ - Parameters: - - pid - """ - self.send_pullFromQueue(pid) - self.recv_pullFromQueue() - - def send_pullFromQueue(self, pid): - self._oprot.writeMessageBegin('pullFromQueue', TMessageType.CALL, self._seqid) - args = pullFromQueue_args() - args.pid = pid - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_pullFromQueue(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = pullFromQueue_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - return - - def restartPackage(self, pid): - """ - Parameters: - - pid - """ - self.send_restartPackage(pid) - self.recv_restartPackage() - - def send_restartPackage(self, pid): - self._oprot.writeMessageBegin('restartPackage', TMessageType.CALL, self._seqid) - args = restartPackage_args() - args.pid = pid - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_restartPackage(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = restartPackage_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - return - - def restartFile(self, fid): - """ - Parameters: - - fid - """ - self.send_restartFile(fid) - self.recv_restartFile() - - def send_restartFile(self, fid): - self._oprot.writeMessageBegin('restartFile', TMessageType.CALL, self._seqid) - args = restartFile_args() - args.fid = fid - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_restartFile(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = restartFile_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - return - - def recheckPackage(self, pid): - """ - Parameters: - - pid - """ - self.send_recheckPackage(pid) - self.recv_recheckPackage() - - def send_recheckPackage(self, pid): - self._oprot.writeMessageBegin('recheckPackage', TMessageType.CALL, self._seqid) - args = recheckPackage_args() - args.pid = pid - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_recheckPackage(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = recheckPackage_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - return - - def stopAllDownloads(self, ): - self.send_stopAllDownloads() - self.recv_stopAllDownloads() - - def send_stopAllDownloads(self, ): - self._oprot.writeMessageBegin('stopAllDownloads', TMessageType.CALL, self._seqid) - args = stopAllDownloads_args() - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_stopAllDownloads(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = stopAllDownloads_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - return - - def stopDownloads(self, fids): - """ - Parameters: - - fids - """ - self.send_stopDownloads(fids) - self.recv_stopDownloads() - - def send_stopDownloads(self, fids): - self._oprot.writeMessageBegin('stopDownloads', TMessageType.CALL, self._seqid) - args = stopDownloads_args() - args.fids = fids - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_stopDownloads(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = stopDownloads_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - return - - def setPackageName(self, pid, name): - """ - Parameters: - - pid - - name - """ - self.send_setPackageName(pid, name) - self.recv_setPackageName() - - def send_setPackageName(self, pid, name): - self._oprot.writeMessageBegin('setPackageName', TMessageType.CALL, self._seqid) - args = setPackageName_args() - args.pid = pid - args.name = name - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_setPackageName(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = setPackageName_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - return - - def movePackage(self, destination, pid): - """ - Parameters: - - destination - - pid - """ - self.send_movePackage(destination, pid) - self.recv_movePackage() - - def send_movePackage(self, destination, pid): - self._oprot.writeMessageBegin('movePackage', TMessageType.CALL, self._seqid) - args = movePackage_args() - args.destination = destination - args.pid = pid - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_movePackage(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = movePackage_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - return - - def moveFiles(self, fids, pid): - """ - Parameters: - - fids - - pid - """ - self.send_moveFiles(fids, pid) - self.recv_moveFiles() - - def send_moveFiles(self, fids, pid): - self._oprot.writeMessageBegin('moveFiles', TMessageType.CALL, self._seqid) - args = moveFiles_args() - args.fids = fids - args.pid = pid - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_moveFiles(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = moveFiles_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - return - - def orderPackage(self, pid, position): - """ - Parameters: - - pid - - position - """ - self.send_orderPackage(pid, position) - self.recv_orderPackage() - - def send_orderPackage(self, pid, position): - self._oprot.writeMessageBegin('orderPackage', TMessageType.CALL, self._seqid) - args = orderPackage_args() - args.pid = pid - args.position = position - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_orderPackage(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = orderPackage_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - return - - def orderFile(self, fid, position): - """ - Parameters: - - fid - - position - """ - self.send_orderFile(fid, position) - self.recv_orderFile() - - def send_orderFile(self, fid, position): - self._oprot.writeMessageBegin('orderFile', TMessageType.CALL, self._seqid) - args = orderFile_args() - args.fid = fid - args.position = position - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_orderFile(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = orderFile_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - return - - def setPackageData(self, pid, data): - """ - Parameters: - - pid - - data - """ - self.send_setPackageData(pid, data) - self.recv_setPackageData() - - def send_setPackageData(self, pid, data): - self._oprot.writeMessageBegin('setPackageData', TMessageType.CALL, self._seqid) - args = setPackageData_args() - args.pid = pid - args.data = data - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_setPackageData(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = setPackageData_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.e is not None: - raise result.e - return - - def deleteFinished(self, ): - self.send_deleteFinished() - return self.recv_deleteFinished() - - def send_deleteFinished(self, ): - self._oprot.writeMessageBegin('deleteFinished', TMessageType.CALL, self._seqid) - args = deleteFinished_args() - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_deleteFinished(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = deleteFinished_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "deleteFinished failed: unknown result"); - - def restartFailed(self, ): - self.send_restartFailed() - self.recv_restartFailed() - - def send_restartFailed(self, ): - self._oprot.writeMessageBegin('restartFailed', TMessageType.CALL, self._seqid) - args = restartFailed_args() - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_restartFailed(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = restartFailed_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - return - - def getEvents(self, uuid): - """ - Parameters: - - uuid - """ - self.send_getEvents(uuid) - return self.recv_getEvents() - - def send_getEvents(self, uuid): - self._oprot.writeMessageBegin('getEvents', TMessageType.CALL, self._seqid) - args = getEvents_args() - args.uuid = uuid - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getEvents(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getEvents_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "getEvents failed: unknown result"); - - def getAccounts(self, refresh): - """ - Parameters: - - refresh - """ - self.send_getAccounts(refresh) - return self.recv_getAccounts() - - def send_getAccounts(self, refresh): - self._oprot.writeMessageBegin('getAccounts', TMessageType.CALL, self._seqid) - args = getAccounts_args() - args.refresh = refresh - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getAccounts(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getAccounts_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "getAccounts failed: unknown result"); - - def getAccountTypes(self, ): - self.send_getAccountTypes() - return self.recv_getAccountTypes() - - def send_getAccountTypes(self, ): - self._oprot.writeMessageBegin('getAccountTypes', TMessageType.CALL, self._seqid) - args = getAccountTypes_args() - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getAccountTypes(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getAccountTypes_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "getAccountTypes failed: unknown result"); - - def updateAccount(self, plugin, account, password, options): - """ - Parameters: - - plugin - - account - - password - - options - """ - self.send_updateAccount(plugin, account, password, options) - self.recv_updateAccount() - - def send_updateAccount(self, plugin, account, password, options): - self._oprot.writeMessageBegin('updateAccount', TMessageType.CALL, self._seqid) - args = updateAccount_args() - args.plugin = plugin - args.account = account - args.password = password - args.options = options - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_updateAccount(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = updateAccount_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - return - - def removeAccount(self, plugin, account): - """ - Parameters: - - plugin - - account - """ - self.send_removeAccount(plugin, account) - self.recv_removeAccount() - - def send_removeAccount(self, plugin, account): - self._oprot.writeMessageBegin('removeAccount', TMessageType.CALL, self._seqid) - args = removeAccount_args() - args.plugin = plugin - args.account = account - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_removeAccount(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = removeAccount_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - return - - def login(self, username, password): - """ - Parameters: - - username - - password - """ - self.send_login(username, password) - return self.recv_login() - - def send_login(self, username, password): - self._oprot.writeMessageBegin('login', TMessageType.CALL, self._seqid) - args = login_args() - args.username = username - args.password = password - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_login(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = login_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "login failed: unknown result"); - - def getUserData(self, username, password): - """ - Parameters: - - username - - password - """ - self.send_getUserData(username, password) - return self.recv_getUserData() - - def send_getUserData(self, username, password): - self._oprot.writeMessageBegin('getUserData', TMessageType.CALL, self._seqid) - args = getUserData_args() - args.username = username - args.password = password - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getUserData(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getUserData_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "getUserData failed: unknown result"); - - def getAllUserData(self, ): - self.send_getAllUserData() - return self.recv_getAllUserData() - - def send_getAllUserData(self, ): - self._oprot.writeMessageBegin('getAllUserData', TMessageType.CALL, self._seqid) - args = getAllUserData_args() - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getAllUserData(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getAllUserData_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "getAllUserData failed: unknown result"); - - def getServices(self, ): - self.send_getServices() - return self.recv_getServices() - - def send_getServices(self, ): - self._oprot.writeMessageBegin('getServices', TMessageType.CALL, self._seqid) - args = getServices_args() - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getServices(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getServices_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "getServices failed: unknown result"); - - def hasService(self, plugin, func): - """ - Parameters: - - plugin - - func - """ - self.send_hasService(plugin, func) - return self.recv_hasService() - - def send_hasService(self, plugin, func): - self._oprot.writeMessageBegin('hasService', TMessageType.CALL, self._seqid) - args = hasService_args() - args.plugin = plugin - args.func = func - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_hasService(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = hasService_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "hasService failed: unknown result"); - - def call(self, info): - """ - Parameters: - - info - """ - self.send_call(info) - return self.recv_call() - - def send_call(self, info): - self._oprot.writeMessageBegin('call', TMessageType.CALL, self._seqid) - args = call_args() - args.info = info - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_call(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = call_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - if result.ex is not None: - raise result.ex - if result.e is not None: - raise result.e - raise TApplicationException(TApplicationException.MISSING_RESULT, "call failed: unknown result"); - - def getAllInfo(self, ): - self.send_getAllInfo() - return self.recv_getAllInfo() - - def send_getAllInfo(self, ): - self._oprot.writeMessageBegin('getAllInfo', TMessageType.CALL, self._seqid) - args = getAllInfo_args() - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getAllInfo(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getAllInfo_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "getAllInfo failed: unknown result"); - - def getInfoByPlugin(self, plugin): - """ - Parameters: - - plugin - """ - self.send_getInfoByPlugin(plugin) - return self.recv_getInfoByPlugin() - - def send_getInfoByPlugin(self, plugin): - self._oprot.writeMessageBegin('getInfoByPlugin', TMessageType.CALL, self._seqid) - args = getInfoByPlugin_args() - args.plugin = plugin - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getInfoByPlugin(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getInfoByPlugin_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "getInfoByPlugin failed: unknown result"); - - def isCaptchaWaiting(self, ): - self.send_isCaptchaWaiting() - return self.recv_isCaptchaWaiting() - - def send_isCaptchaWaiting(self, ): - self._oprot.writeMessageBegin('isCaptchaWaiting', TMessageType.CALL, self._seqid) - args = isCaptchaWaiting_args() - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_isCaptchaWaiting(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = isCaptchaWaiting_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "isCaptchaWaiting failed: unknown result"); - - def getCaptchaTask(self, exclusive): - """ - Parameters: - - exclusive - """ - self.send_getCaptchaTask(exclusive) - return self.recv_getCaptchaTask() - - def send_getCaptchaTask(self, exclusive): - self._oprot.writeMessageBegin('getCaptchaTask', TMessageType.CALL, self._seqid) - args = getCaptchaTask_args() - args.exclusive = exclusive - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getCaptchaTask(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getCaptchaTask_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "getCaptchaTask failed: unknown result"); - - def getCaptchaTaskStatus(self, tid): - """ - Parameters: - - tid - """ - self.send_getCaptchaTaskStatus(tid) - return self.recv_getCaptchaTaskStatus() - - def send_getCaptchaTaskStatus(self, tid): - self._oprot.writeMessageBegin('getCaptchaTaskStatus', TMessageType.CALL, self._seqid) - args = getCaptchaTaskStatus_args() - args.tid = tid - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_getCaptchaTaskStatus(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = getCaptchaTaskStatus_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "getCaptchaTaskStatus failed: unknown result"); - - def setCaptchaResult(self, tid, result): - """ - Parameters: - - tid - - result - """ - self.send_setCaptchaResult(tid, result) - self.recv_setCaptchaResult() - - def send_setCaptchaResult(self, tid, result): - self._oprot.writeMessageBegin('setCaptchaResult', TMessageType.CALL, self._seqid) - args = setCaptchaResult_args() - args.tid = tid - args.result = result - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_setCaptchaResult(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = setCaptchaResult_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - return - - -class Processor(Iface, TProcessor): - def __init__(self, handler): - self._handler = handler - self._processMap = {} - self._processMap["getConfigValue"] = Processor.process_getConfigValue - self._processMap["setConfigValue"] = Processor.process_setConfigValue - self._processMap["getConfig"] = Processor.process_getConfig - self._processMap["getPluginConfig"] = Processor.process_getPluginConfig - self._processMap["pauseServer"] = Processor.process_pauseServer - self._processMap["unpauseServer"] = Processor.process_unpauseServer - self._processMap["togglePause"] = Processor.process_togglePause - self._processMap["statusServer"] = Processor.process_statusServer - self._processMap["freeSpace"] = Processor.process_freeSpace - self._processMap["getServerVersion"] = Processor.process_getServerVersion - self._processMap["kill"] = Processor.process_kill - self._processMap["restart"] = Processor.process_restart - self._processMap["getLog"] = Processor.process_getLog - self._processMap["isTimeDownload"] = Processor.process_isTimeDownload - self._processMap["isTimeReconnect"] = Processor.process_isTimeReconnect - self._processMap["toggleReconnect"] = Processor.process_toggleReconnect - self._processMap["generatePackages"] = Processor.process_generatePackages - self._processMap["checkURLs"] = Processor.process_checkURLs - self._processMap["parseURLs"] = Processor.process_parseURLs - self._processMap["checkOnlineStatus"] = Processor.process_checkOnlineStatus - self._processMap["checkOnlineStatusContainer"] = Processor.process_checkOnlineStatusContainer - self._processMap["pollResults"] = Processor.process_pollResults - self._processMap["statusDownloads"] = Processor.process_statusDownloads - self._processMap["getPackageData"] = Processor.process_getPackageData - self._processMap["getPackageInfo"] = Processor.process_getPackageInfo - self._processMap["getFileData"] = Processor.process_getFileData - 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["generateAndAddPackages"] = Processor.process_generateAndAddPackages - 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 - self._processMap["restartFile"] = Processor.process_restartFile - self._processMap["recheckPackage"] = Processor.process_recheckPackage - self._processMap["stopAllDownloads"] = Processor.process_stopAllDownloads - self._processMap["stopDownloads"] = Processor.process_stopDownloads - self._processMap["setPackageName"] = Processor.process_setPackageName - self._processMap["movePackage"] = Processor.process_movePackage - self._processMap["moveFiles"] = Processor.process_moveFiles - 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["getEvents"] = Processor.process_getEvents - self._processMap["getAccounts"] = Processor.process_getAccounts - self._processMap["getAccountTypes"] = Processor.process_getAccountTypes - self._processMap["updateAccount"] = Processor.process_updateAccount - self._processMap["removeAccount"] = Processor.process_removeAccount - self._processMap["login"] = Processor.process_login - self._processMap["getUserData"] = Processor.process_getUserData - self._processMap["getAllUserData"] = Processor.process_getAllUserData - self._processMap["getServices"] = Processor.process_getServices - self._processMap["hasService"] = Processor.process_hasService - self._processMap["call"] = Processor.process_call - self._processMap["getAllInfo"] = Processor.process_getAllInfo - self._processMap["getInfoByPlugin"] = Processor.process_getInfoByPlugin - self._processMap["isCaptchaWaiting"] = Processor.process_isCaptchaWaiting - self._processMap["getCaptchaTask"] = Processor.process_getCaptchaTask - self._processMap["getCaptchaTaskStatus"] = Processor.process_getCaptchaTaskStatus - self._processMap["setCaptchaResult"] = Processor.process_setCaptchaResult - - def process(self, iprot, oprot): - (name, type, seqid) = iprot.readMessageBegin() - if name not in self._processMap: - iprot.skip(TType.STRUCT) - iprot.readMessageEnd() - x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name)) - oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid) - x.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - return - else: - self._processMap[name](self, seqid, iprot, oprot) - return True - - def process_getConfigValue(self, seqid, iprot, oprot): - args = getConfigValue_args() - args.read(iprot) - iprot.readMessageEnd() - result = getConfigValue_result() - result.success = self._handler.getConfigValue(args.category, args.option, args.section) - oprot.writeMessageBegin("getConfigValue", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_setConfigValue(self, seqid, iprot, oprot): - args = setConfigValue_args() - args.read(iprot) - iprot.readMessageEnd() - result = setConfigValue_result() - self._handler.setConfigValue(args.category, args.option, args.value, args.section) - oprot.writeMessageBegin("setConfigValue", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getConfig(self, seqid, iprot, oprot): - args = getConfig_args() - args.read(iprot) - iprot.readMessageEnd() - result = getConfig_result() - result.success = self._handler.getConfig() - oprot.writeMessageBegin("getConfig", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getPluginConfig(self, seqid, iprot, oprot): - args = getPluginConfig_args() - args.read(iprot) - iprot.readMessageEnd() - result = getPluginConfig_result() - result.success = self._handler.getPluginConfig() - oprot.writeMessageBegin("getPluginConfig", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_pauseServer(self, seqid, iprot, oprot): - args = pauseServer_args() - args.read(iprot) - iprot.readMessageEnd() - result = pauseServer_result() - self._handler.pauseServer() - oprot.writeMessageBegin("pauseServer", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_unpauseServer(self, seqid, iprot, oprot): - args = unpauseServer_args() - args.read(iprot) - iprot.readMessageEnd() - result = unpauseServer_result() - self._handler.unpauseServer() - oprot.writeMessageBegin("unpauseServer", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_togglePause(self, seqid, iprot, oprot): - args = togglePause_args() - args.read(iprot) - iprot.readMessageEnd() - result = togglePause_result() - result.success = self._handler.togglePause() - oprot.writeMessageBegin("togglePause", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_statusServer(self, seqid, iprot, oprot): - args = statusServer_args() - args.read(iprot) - iprot.readMessageEnd() - result = statusServer_result() - result.success = self._handler.statusServer() - oprot.writeMessageBegin("statusServer", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_freeSpace(self, seqid, iprot, oprot): - args = freeSpace_args() - args.read(iprot) - iprot.readMessageEnd() - result = freeSpace_result() - result.success = self._handler.freeSpace() - oprot.writeMessageBegin("freeSpace", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getServerVersion(self, seqid, iprot, oprot): - args = getServerVersion_args() - args.read(iprot) - iprot.readMessageEnd() - result = getServerVersion_result() - result.success = self._handler.getServerVersion() - oprot.writeMessageBegin("getServerVersion", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_kill(self, seqid, iprot, oprot): - args = kill_args() - args.read(iprot) - iprot.readMessageEnd() - result = kill_result() - self._handler.kill() - oprot.writeMessageBegin("kill", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_restart(self, seqid, iprot, oprot): - args = restart_args() - args.read(iprot) - iprot.readMessageEnd() - result = restart_result() - self._handler.restart() - oprot.writeMessageBegin("restart", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getLog(self, seqid, iprot, oprot): - args = getLog_args() - args.read(iprot) - iprot.readMessageEnd() - result = getLog_result() - result.success = self._handler.getLog(args.offset) - oprot.writeMessageBegin("getLog", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_isTimeDownload(self, seqid, iprot, oprot): - args = isTimeDownload_args() - args.read(iprot) - iprot.readMessageEnd() - result = isTimeDownload_result() - result.success = self._handler.isTimeDownload() - oprot.writeMessageBegin("isTimeDownload", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_isTimeReconnect(self, seqid, iprot, oprot): - args = isTimeReconnect_args() - args.read(iprot) - iprot.readMessageEnd() - result = isTimeReconnect_result() - result.success = self._handler.isTimeReconnect() - oprot.writeMessageBegin("isTimeReconnect", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_toggleReconnect(self, seqid, iprot, oprot): - args = toggleReconnect_args() - args.read(iprot) - iprot.readMessageEnd() - result = toggleReconnect_result() - result.success = self._handler.toggleReconnect() - oprot.writeMessageBegin("toggleReconnect", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_generatePackages(self, seqid, iprot, oprot): - args = generatePackages_args() - args.read(iprot) - iprot.readMessageEnd() - result = generatePackages_result() - result.success = self._handler.generatePackages(args.links) - oprot.writeMessageBegin("generatePackages", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_checkURLs(self, seqid, iprot, oprot): - args = checkURLs_args() - args.read(iprot) - iprot.readMessageEnd() - result = checkURLs_result() - result.success = self._handler.checkURLs(args.urls) - oprot.writeMessageBegin("checkURLs", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_parseURLs(self, seqid, iprot, oprot): - args = parseURLs_args() - args.read(iprot) - iprot.readMessageEnd() - result = parseURLs_result() - result.success = self._handler.parseURLs(args.html, args.url) - oprot.writeMessageBegin("parseURLs", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_checkOnlineStatus(self, seqid, iprot, oprot): - args = checkOnlineStatus_args() - args.read(iprot) - iprot.readMessageEnd() - result = checkOnlineStatus_result() - result.success = self._handler.checkOnlineStatus(args.urls) - oprot.writeMessageBegin("checkOnlineStatus", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_checkOnlineStatusContainer(self, seqid, iprot, oprot): - args = checkOnlineStatusContainer_args() - args.read(iprot) - iprot.readMessageEnd() - result = checkOnlineStatusContainer_result() - result.success = self._handler.checkOnlineStatusContainer(args.urls, args.filename, args.data) - oprot.writeMessageBegin("checkOnlineStatusContainer", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_pollResults(self, seqid, iprot, oprot): - args = pollResults_args() - args.read(iprot) - iprot.readMessageEnd() - result = pollResults_result() - result.success = self._handler.pollResults(args.rid) - oprot.writeMessageBegin("pollResults", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_statusDownloads(self, seqid, iprot, oprot): - args = statusDownloads_args() - args.read(iprot) - iprot.readMessageEnd() - result = statusDownloads_result() - result.success = self._handler.statusDownloads() - oprot.writeMessageBegin("statusDownloads", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getPackageData(self, seqid, iprot, oprot): - args = getPackageData_args() - args.read(iprot) - iprot.readMessageEnd() - 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_getPackageInfo(self, seqid, iprot, oprot): - args = getPackageInfo_args() - args.read(iprot) - iprot.readMessageEnd() - result = getPackageInfo_result() - try: - result.success = self._handler.getPackageInfo(args.pid) - except PackageDoesNotExists, e: - result.e = e - oprot.writeMessageBegin("getPackageInfo", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getFileData(self, seqid, iprot, oprot): - args = getFileData_args() - args.read(iprot) - iprot.readMessageEnd() - result = getFileData_result() - try: - result.success = self._handler.getFileData(args.fid) - except FileDoesNotExists, e: - result.e = e - oprot.writeMessageBegin("getFileData", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getQueue(self, seqid, iprot, oprot): - args = getQueue_args() - args.read(iprot) - iprot.readMessageEnd() - result = getQueue_result() - result.success = self._handler.getQueue() - oprot.writeMessageBegin("getQueue", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getCollector(self, seqid, iprot, oprot): - args = getCollector_args() - args.read(iprot) - iprot.readMessageEnd() - result = getCollector_result() - result.success = self._handler.getCollector() - oprot.writeMessageBegin("getCollector", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getQueueData(self, seqid, iprot, oprot): - args = getQueueData_args() - args.read(iprot) - iprot.readMessageEnd() - result = getQueueData_result() - result.success = self._handler.getQueueData() - oprot.writeMessageBegin("getQueueData", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getCollectorData(self, seqid, iprot, oprot): - args = getCollectorData_args() - args.read(iprot) - iprot.readMessageEnd() - result = getCollectorData_result() - result.success = self._handler.getCollectorData() - oprot.writeMessageBegin("getCollectorData", TMessageType.REPLY, seqid) - result.write(oprot) - 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_generateAndAddPackages(self, seqid, iprot, oprot): - args = generateAndAddPackages_args() - args.read(iprot) - iprot.readMessageEnd() - result = generateAndAddPackages_result() - result.success = self._handler.generateAndAddPackages(args.links, args.dest) - oprot.writeMessageBegin("generateAndAddPackages", 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) - iprot.readMessageEnd() - result = addFiles_result() - self._handler.addFiles(args.pid, args.links) - oprot.writeMessageBegin("addFiles", TMessageType.REPLY, seqid) - result.write(oprot) - 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) - iprot.readMessageEnd() - result = pushToQueue_result() - self._handler.pushToQueue(args.pid) - oprot.writeMessageBegin("pushToQueue", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_pullFromQueue(self, seqid, iprot, oprot): - args = pullFromQueue_args() - args.read(iprot) - iprot.readMessageEnd() - result = pullFromQueue_result() - self._handler.pullFromQueue(args.pid) - oprot.writeMessageBegin("pullFromQueue", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_restartPackage(self, seqid, iprot, oprot): - args = restartPackage_args() - args.read(iprot) - iprot.readMessageEnd() - result = restartPackage_result() - self._handler.restartPackage(args.pid) - oprot.writeMessageBegin("restartPackage", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_restartFile(self, seqid, iprot, oprot): - args = restartFile_args() - args.read(iprot) - iprot.readMessageEnd() - result = restartFile_result() - self._handler.restartFile(args.fid) - oprot.writeMessageBegin("restartFile", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_recheckPackage(self, seqid, iprot, oprot): - args = recheckPackage_args() - args.read(iprot) - iprot.readMessageEnd() - result = recheckPackage_result() - self._handler.recheckPackage(args.pid) - oprot.writeMessageBegin("recheckPackage", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_stopAllDownloads(self, seqid, iprot, oprot): - args = stopAllDownloads_args() - args.read(iprot) - iprot.readMessageEnd() - result = stopAllDownloads_result() - self._handler.stopAllDownloads() - oprot.writeMessageBegin("stopAllDownloads", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_stopDownloads(self, seqid, iprot, oprot): - args = stopDownloads_args() - args.read(iprot) - iprot.readMessageEnd() - result = stopDownloads_result() - self._handler.stopDownloads(args.fids) - oprot.writeMessageBegin("stopDownloads", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_setPackageName(self, seqid, iprot, oprot): - args = setPackageName_args() - args.read(iprot) - iprot.readMessageEnd() - result = setPackageName_result() - self._handler.setPackageName(args.pid, args.name) - oprot.writeMessageBegin("setPackageName", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_movePackage(self, seqid, iprot, oprot): - args = movePackage_args() - args.read(iprot) - iprot.readMessageEnd() - result = movePackage_result() - self._handler.movePackage(args.destination, args.pid) - oprot.writeMessageBegin("movePackage", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_moveFiles(self, seqid, iprot, oprot): - args = moveFiles_args() - args.read(iprot) - iprot.readMessageEnd() - result = moveFiles_result() - self._handler.moveFiles(args.fids, args.pid) - oprot.writeMessageBegin("moveFiles", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_orderPackage(self, seqid, iprot, oprot): - args = orderPackage_args() - args.read(iprot) - iprot.readMessageEnd() - result = orderPackage_result() - self._handler.orderPackage(args.pid, args.position) - oprot.writeMessageBegin("orderPackage", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_orderFile(self, seqid, iprot, oprot): - args = orderFile_args() - args.read(iprot) - iprot.readMessageEnd() - result = orderFile_result() - self._handler.orderFile(args.fid, args.position) - oprot.writeMessageBegin("orderFile", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_setPackageData(self, seqid, iprot, oprot): - args = setPackageData_args() - args.read(iprot) - iprot.readMessageEnd() - result = setPackageData_result() - 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() - oprot.trans.flush() - - def process_deleteFinished(self, seqid, iprot, oprot): - args = deleteFinished_args() - args.read(iprot) - iprot.readMessageEnd() - result = deleteFinished_result() - result.success = self._handler.deleteFinished() - oprot.writeMessageBegin("deleteFinished", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_restartFailed(self, seqid, iprot, oprot): - args = restartFailed_args() - args.read(iprot) - iprot.readMessageEnd() - result = restartFailed_result() - self._handler.restartFailed() - oprot.writeMessageBegin("restartFailed", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getEvents(self, seqid, iprot, oprot): - args = getEvents_args() - args.read(iprot) - iprot.readMessageEnd() - result = getEvents_result() - result.success = self._handler.getEvents(args.uuid) - oprot.writeMessageBegin("getEvents", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getAccounts(self, seqid, iprot, oprot): - args = getAccounts_args() - args.read(iprot) - iprot.readMessageEnd() - result = getAccounts_result() - result.success = self._handler.getAccounts(args.refresh) - oprot.writeMessageBegin("getAccounts", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getAccountTypes(self, seqid, iprot, oprot): - args = getAccountTypes_args() - args.read(iprot) - iprot.readMessageEnd() - result = getAccountTypes_result() - result.success = self._handler.getAccountTypes() - oprot.writeMessageBegin("getAccountTypes", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_updateAccount(self, seqid, iprot, oprot): - args = updateAccount_args() - args.read(iprot) - iprot.readMessageEnd() - result = updateAccount_result() - self._handler.updateAccount(args.plugin, args.account, args.password, args.options) - oprot.writeMessageBegin("updateAccount", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_removeAccount(self, seqid, iprot, oprot): - args = removeAccount_args() - args.read(iprot) - iprot.readMessageEnd() - result = removeAccount_result() - self._handler.removeAccount(args.plugin, args.account) - oprot.writeMessageBegin("removeAccount", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_login(self, seqid, iprot, oprot): - args = login_args() - args.read(iprot) - iprot.readMessageEnd() - result = login_result() - result.success = self._handler.login(args.username, args.password) - oprot.writeMessageBegin("login", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getUserData(self, seqid, iprot, oprot): - args = getUserData_args() - args.read(iprot) - iprot.readMessageEnd() - result = getUserData_result() - result.success = self._handler.getUserData(args.username, args.password) - oprot.writeMessageBegin("getUserData", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getAllUserData(self, seqid, iprot, oprot): - args = getAllUserData_args() - args.read(iprot) - iprot.readMessageEnd() - result = getAllUserData_result() - result.success = self._handler.getAllUserData() - oprot.writeMessageBegin("getAllUserData", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getServices(self, seqid, iprot, oprot): - args = getServices_args() - args.read(iprot) - iprot.readMessageEnd() - result = getServices_result() - result.success = self._handler.getServices() - oprot.writeMessageBegin("getServices", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_hasService(self, seqid, iprot, oprot): - args = hasService_args() - args.read(iprot) - iprot.readMessageEnd() - result = hasService_result() - result.success = self._handler.hasService(args.plugin, args.func) - oprot.writeMessageBegin("hasService", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_call(self, seqid, iprot, oprot): - args = call_args() - args.read(iprot) - iprot.readMessageEnd() - result = call_result() - try: - result.success = self._handler.call(args.info) - except ServiceDoesNotExists, ex: - result.ex = ex - except ServiceException, e: - result.e = e - oprot.writeMessageBegin("call", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getAllInfo(self, seqid, iprot, oprot): - args = getAllInfo_args() - args.read(iprot) - iprot.readMessageEnd() - result = getAllInfo_result() - result.success = self._handler.getAllInfo() - oprot.writeMessageBegin("getAllInfo", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getInfoByPlugin(self, seqid, iprot, oprot): - args = getInfoByPlugin_args() - args.read(iprot) - iprot.readMessageEnd() - result = getInfoByPlugin_result() - result.success = self._handler.getInfoByPlugin(args.plugin) - oprot.writeMessageBegin("getInfoByPlugin", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_isCaptchaWaiting(self, seqid, iprot, oprot): - args = isCaptchaWaiting_args() - args.read(iprot) - iprot.readMessageEnd() - result = isCaptchaWaiting_result() - result.success = self._handler.isCaptchaWaiting() - oprot.writeMessageBegin("isCaptchaWaiting", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getCaptchaTask(self, seqid, iprot, oprot): - args = getCaptchaTask_args() - args.read(iprot) - iprot.readMessageEnd() - result = getCaptchaTask_result() - result.success = self._handler.getCaptchaTask(args.exclusive) - oprot.writeMessageBegin("getCaptchaTask", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_getCaptchaTaskStatus(self, seqid, iprot, oprot): - args = getCaptchaTaskStatus_args() - args.read(iprot) - iprot.readMessageEnd() - result = getCaptchaTaskStatus_result() - result.success = self._handler.getCaptchaTaskStatus(args.tid) - oprot.writeMessageBegin("getCaptchaTaskStatus", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_setCaptchaResult(self, seqid, iprot, oprot): - args = setCaptchaResult_args() - args.read(iprot) - iprot.readMessageEnd() - result = setCaptchaResult_result() - self._handler.setCaptchaResult(args.tid, args.result) - oprot.writeMessageBegin("setCaptchaResult", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - -# HELPER FUNCTIONS AND STRUCTURES - -class getConfigValue_args(TBase): - """ - Attributes: - - category - - option - - section - """ - - __slots__ = [ - 'category', - 'option', - 'section', - ] - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'category', None, None, ), # 1 - (2, TType.STRING, 'option', None, None, ), # 2 - (3, TType.STRING, 'section', None, None, ), # 3 - ) - - def __init__(self, category=None, option=None, section=None,): - self.category = category - self.option = option - self.section = section - - -class getConfigValue_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.STRING, 'success', None, None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class setConfigValue_args(TBase): - """ - Attributes: - - category - - option - - value - - section - """ - - __slots__ = [ - 'category', - 'option', - 'value', - 'section', - ] - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'category', None, None, ), # 1 - (2, TType.STRING, 'option', None, None, ), # 2 - (3, TType.STRING, 'value', None, None, ), # 3 - (4, TType.STRING, 'section', None, None, ), # 4 - ) - - def __init__(self, category=None, option=None, value=None, section=None,): - self.category = category - self.option = option - self.value = value - self.section = section - - -class setConfigValue_result(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class getConfig_args(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class getConfig_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.MAP, 'success', (TType.STRING,None,TType.STRUCT,(ConfigSection, ConfigSection.thrift_spec)), None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class getPluginConfig_args(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class getPluginConfig_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.MAP, 'success', (TType.STRING,None,TType.STRUCT,(ConfigSection, ConfigSection.thrift_spec)), None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class pauseServer_args(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class pauseServer_result(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class unpauseServer_args(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class unpauseServer_result(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class togglePause_args(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class togglePause_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.BOOL, 'success', None, None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class statusServer_args(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class statusServer_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.STRUCT, 'success', (ServerStatus, ServerStatus.thrift_spec), None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class freeSpace_args(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class freeSpace_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.I64, 'success', None, None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class getServerVersion_args(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class getServerVersion_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.STRING, 'success', None, None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class kill_args(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class kill_result(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class restart_args(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class restart_result(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class getLog_args(TBase): - """ - Attributes: - - offset - """ - - __slots__ = [ - 'offset', - ] - - thrift_spec = ( - None, # 0 - (1, TType.I32, 'offset', None, None, ), # 1 - ) - - def __init__(self, offset=None,): - self.offset = offset - - -class getLog_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.LIST, 'success', (TType.STRING,None), None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class isTimeDownload_args(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class isTimeDownload_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.BOOL, 'success', None, None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class isTimeReconnect_args(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class isTimeReconnect_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.BOOL, 'success', None, None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class toggleReconnect_args(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class toggleReconnect_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.BOOL, 'success', None, None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class generatePackages_args(TBase): - """ - Attributes: - - links - """ - - __slots__ = [ - 'links', - ] - - thrift_spec = ( - None, # 0 - (1, TType.LIST, 'links', (TType.STRING,None), None, ), # 1 - ) - - def __init__(self, links=None,): - self.links = links - - -class generatePackages_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.MAP, 'success', (TType.STRING,None,TType.LIST,(TType.STRING,None)), None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class checkURLs_args(TBase): - """ - Attributes: - - urls - """ - - __slots__ = [ - 'urls', - ] - - thrift_spec = ( - None, # 0 - (1, TType.LIST, 'urls', (TType.STRING,None), None, ), # 1 - ) - - def __init__(self, urls=None,): - self.urls = urls - - -class checkURLs_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.MAP, 'success', (TType.STRING,None,TType.LIST,(TType.STRING,None)), None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class parseURLs_args(TBase): - """ - Attributes: - - html - - url - """ - - __slots__ = [ - 'html', - 'url', - ] - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'html', None, None, ), # 1 - (2, TType.STRING, 'url', None, None, ), # 2 - ) - - def __init__(self, html=None, url=None,): - self.html = html - self.url = url - - -class parseURLs_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.MAP, 'success', (TType.STRING,None,TType.LIST,(TType.STRING,None)), None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class checkOnlineStatus_args(TBase): - """ - Attributes: - - urls - """ - - __slots__ = [ - 'urls', - ] - - thrift_spec = ( - None, # 0 - (1, TType.LIST, 'urls', (TType.STRING,None), None, ), # 1 - ) - - def __init__(self, urls=None,): - self.urls = urls - - -class checkOnlineStatus_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.STRUCT, 'success', (OnlineCheck, OnlineCheck.thrift_spec), None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class checkOnlineStatusContainer_args(TBase): - """ - Attributes: - - urls - - filename - - data - """ - - __slots__ = [ - 'urls', - 'filename', - 'data', - ] - - thrift_spec = ( - None, # 0 - (1, TType.LIST, 'urls', (TType.STRING,None), None, ), # 1 - (2, TType.STRING, 'filename', None, None, ), # 2 - (3, TType.STRING, 'data', None, None, ), # 3 - ) - - def __init__(self, urls=None, filename=None, data=None,): - self.urls = urls - self.filename = filename - self.data = data - - -class checkOnlineStatusContainer_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.STRUCT, 'success', (OnlineCheck, OnlineCheck.thrift_spec), None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class pollResults_args(TBase): - """ - Attributes: - - rid - """ - - __slots__ = [ - 'rid', - ] - - thrift_spec = ( - None, # 0 - (1, TType.I32, 'rid', None, None, ), # 1 - ) - - def __init__(self, rid=None,): - self.rid = rid - - -class pollResults_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.STRUCT, 'success', (OnlineCheck, OnlineCheck.thrift_spec), None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class statusDownloads_args(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class statusDownloads_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.LIST, 'success', (TType.STRUCT,(DownloadInfo, DownloadInfo.thrift_spec)), None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class getPackageData_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 getPackageData_result(TBase): - """ - Attributes: - - success - - e - """ - - __slots__ = [ - 'success', - 'e', - ] - - thrift_spec = ( - (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, e=None,): - self.success = success - self.e = e - - -class getPackageInfo_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 getPackageInfo_result(TBase): - """ - Attributes: - - success - - e - """ - - __slots__ = [ - 'success', - 'e', - ] - - thrift_spec = ( - (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, e=None,): - self.success = success - self.e = e - - -class getFileData_args(TBase): - """ - Attributes: - - fid - """ - - __slots__ = [ - 'fid', - ] - - thrift_spec = ( - None, # 0 - (1, TType.I32, 'fid', None, None, ), # 1 - ) - - def __init__(self, fid=None,): - self.fid = fid - - -class getFileData_result(TBase): - """ - Attributes: - - success - - e - """ - - __slots__ = [ - 'success', - 'e', - ] - - thrift_spec = ( - (0, TType.STRUCT, 'success', (FileData, FileData.thrift_spec), None, ), # 0 - (1, TType.STRUCT, 'e', (FileDoesNotExists, FileDoesNotExists.thrift_spec), None, ), # 1 - ) - - def __init__(self, success=None, e=None,): - self.success = success - self.e = e - - -class getQueue_args(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class getQueue_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 getCollector_args(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class getCollector_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 getQueueData_args(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -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 getCollectorData_args(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class getCollectorData_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 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 generateAndAddPackages_args(TBase): - """ - Attributes: - - links - - dest - """ - - __slots__ = [ - 'links', - 'dest', - ] - - thrift_spec = ( - None, # 0 - (1, TType.LIST, 'links', (TType.STRING,None), None, ), # 1 - (2, TType.I32, 'dest', None, None, ), # 2 - ) - - def __init__(self, links=None, dest=None,): - self.links = links - self.dest = dest - - -class generateAndAddPackages_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.LIST, 'success', (TType.I32,None), None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -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 addPackage_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.I32, 'success', None, None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class addFiles_args(TBase): - """ - Attributes: - - pid - - links - """ - - __slots__ = [ - 'pid', - 'links', - ] - - thrift_spec = ( - None, # 0 - (1, TType.I32, 'pid', None, None, ), # 1 - (2, TType.LIST, 'links', (TType.STRING,None), None, ), # 2 - ) - - def __init__(self, pid=None, links=None,): - self.pid = pid - self.links = links - - -class addFiles_result(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -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: - - pid - """ - - __slots__ = [ - 'pid', - ] - - thrift_spec = ( - None, # 0 - (1, TType.I32, 'pid', None, None, ), # 1 - ) - - def __init__(self, pid=None,): - self.pid = pid - - -class pushToQueue_result(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class pullFromQueue_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 pullFromQueue_result(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class restartPackage_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 restartPackage_result(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class restartFile_args(TBase): - """ - Attributes: - - fid - """ - - __slots__ = [ - 'fid', - ] - - thrift_spec = ( - None, # 0 - (1, TType.I32, 'fid', None, None, ), # 1 - ) - - def __init__(self, fid=None,): - self.fid = fid - - -class restartFile_result(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class recheckPackage_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 recheckPackage_result(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class stopAllDownloads_args(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class stopAllDownloads_result(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class stopDownloads_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 stopDownloads_result(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class setPackageName_args(TBase): - """ - Attributes: - - pid - - name - """ - - __slots__ = [ - 'pid', - 'name', - ] - - thrift_spec = ( - None, # 0 - (1, TType.I32, 'pid', None, None, ), # 1 - (2, TType.STRING, 'name', None, None, ), # 2 - ) - - def __init__(self, pid=None, name=None,): - self.pid = pid - self.name = name - - -class setPackageName_result(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class movePackage_args(TBase): - """ - Attributes: - - destination - - pid - """ - - __slots__ = [ - 'destination', - 'pid', - ] - - thrift_spec = ( - None, # 0 - (1, TType.I32, 'destination', None, None, ), # 1 - (2, TType.I32, 'pid', None, None, ), # 2 - ) - - def __init__(self, destination=None, pid=None,): - self.destination = destination - self.pid = pid - - -class movePackage_result(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class moveFiles_args(TBase): - """ - Attributes: - - fids - - pid - """ - - __slots__ = [ - 'fids', - 'pid', - ] - - thrift_spec = ( - None, # 0 - (1, TType.LIST, 'fids', (TType.I32,None), None, ), # 1 - (2, TType.I32, 'pid', None, None, ), # 2 - ) - - def __init__(self, fids=None, pid=None,): - self.fids = fids - self.pid = pid - - -class moveFiles_result(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class orderPackage_args(TBase): - """ - Attributes: - - pid - - position - """ - - __slots__ = [ - 'pid', - 'position', - ] - - thrift_spec = ( - None, # 0 - (1, TType.I32, 'pid', None, None, ), # 1 - (2, TType.I16, 'position', None, None, ), # 2 - ) - - def __init__(self, pid=None, position=None,): - self.pid = pid - self.position = position - - -class orderPackage_result(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class orderFile_args(TBase): - """ - Attributes: - - fid - - position - """ - - __slots__ = [ - 'fid', - 'position', - ] - - thrift_spec = ( - None, # 0 - (1, TType.I32, 'fid', None, None, ), # 1 - (2, TType.I16, 'position', None, None, ), # 2 - ) - - def __init__(self, fid=None, position=None,): - self.fid = fid - self.position = position - - -class orderFile_result(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class setPackageData_args(TBase): - """ - Attributes: - - pid - - data - """ - - __slots__ = [ - 'pid', - 'data', - ] - - thrift_spec = ( - None, # 0 - (1, TType.I32, 'pid', None, None, ), # 1 - (2, TType.MAP, 'data', (TType.STRING,None,TType.STRING,None), None, ), # 2 - ) - - def __init__(self, pid=None, data=None,): - self.pid = pid - self.data = data - - -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): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class deleteFinished_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.LIST, 'success', (TType.I32,None), None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class restartFailed_args(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class restartFailed_result(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class getEvents_args(TBase): - """ - Attributes: - - uuid - """ - - __slots__ = [ - 'uuid', - ] - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'uuid', None, None, ), # 1 - ) - - def __init__(self, uuid=None,): - self.uuid = uuid - - -class getEvents_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.LIST, 'success', (TType.STRUCT,(EventInfo, EventInfo.thrift_spec)), None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class getAccounts_args(TBase): - """ - Attributes: - - refresh - """ - - __slots__ = [ - 'refresh', - ] - - thrift_spec = ( - None, # 0 - (1, TType.BOOL, 'refresh', None, None, ), # 1 - ) - - def __init__(self, refresh=None,): - self.refresh = refresh - - -class getAccounts_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.LIST, 'success', (TType.STRUCT,(AccountInfo, AccountInfo.thrift_spec)), None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class getAccountTypes_args(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class getAccountTypes_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.LIST, 'success', (TType.STRING,None), None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class updateAccount_args(TBase): - """ - Attributes: - - plugin - - account - - password - - options - """ - - __slots__ = [ - 'plugin', - 'account', - 'password', - 'options', - ] - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'plugin', None, None, ), # 1 - (2, TType.STRING, 'account', None, None, ), # 2 - (3, TType.STRING, 'password', None, None, ), # 3 - (4, TType.MAP, 'options', (TType.STRING,None,TType.STRING,None), None, ), # 4 - ) - - def __init__(self, plugin=None, account=None, password=None, options=None,): - self.plugin = plugin - self.account = account - self.password = password - self.options = options - - -class updateAccount_result(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class removeAccount_args(TBase): - """ - Attributes: - - plugin - - account - """ - - __slots__ = [ - 'plugin', - 'account', - ] - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'plugin', None, None, ), # 1 - (2, TType.STRING, 'account', None, None, ), # 2 - ) - - def __init__(self, plugin=None, account=None,): - self.plugin = plugin - self.account = account - - -class removeAccount_result(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class login_args(TBase): - """ - Attributes: - - username - - password - """ - - __slots__ = [ - 'username', - 'password', - ] - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'username', None, None, ), # 1 - (2, TType.STRING, 'password', None, None, ), # 2 - ) - - def __init__(self, username=None, password=None,): - self.username = username - self.password = password - - -class login_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.BOOL, 'success', None, None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class getUserData_args(TBase): - """ - Attributes: - - username - - password - """ - - __slots__ = [ - 'username', - 'password', - ] - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'username', None, None, ), # 1 - (2, TType.STRING, 'password', None, None, ), # 2 - ) - - def __init__(self, username=None, password=None,): - self.username = username - self.password = password - - -class getUserData_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.STRUCT, 'success', (UserData, UserData.thrift_spec), None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class getAllUserData_args(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class getAllUserData_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.MAP, 'success', (TType.STRING,None,TType.STRUCT,(UserData, UserData.thrift_spec)), None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class getServices_args(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class getServices_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.MAP, 'success', (TType.STRING,None,TType.MAP,(TType.STRING,None,TType.STRING,None)), None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class hasService_args(TBase): - """ - Attributes: - - plugin - - func - """ - - __slots__ = [ - 'plugin', - 'func', - ] - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'plugin', None, None, ), # 1 - (2, TType.STRING, 'func', None, None, ), # 2 - ) - - def __init__(self, plugin=None, func=None,): - self.plugin = plugin - self.func = func - - -class hasService_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.BOOL, 'success', None, None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class call_args(TBase): - """ - Attributes: - - info - """ - - __slots__ = [ - 'info', - ] - - thrift_spec = ( - None, # 0 - (1, TType.STRUCT, 'info', (ServiceCall, ServiceCall.thrift_spec), None, ), # 1 - ) - - def __init__(self, info=None,): - self.info = info - - -class call_result(TBase): - """ - Attributes: - - success - - ex - - e - """ - - __slots__ = [ - 'success', - 'ex', - 'e', - ] - - thrift_spec = ( - (0, TType.STRING, 'success', None, None, ), # 0 - (1, TType.STRUCT, 'ex', (ServiceDoesNotExists, ServiceDoesNotExists.thrift_spec), None, ), # 1 - (2, TType.STRUCT, 'e', (ServiceException, ServiceException.thrift_spec), None, ), # 2 - ) - - def __init__(self, success=None, ex=None, e=None,): - self.success = success - self.ex = ex - self.e = e - - -class getAllInfo_args(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class getAllInfo_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.MAP, 'success', (TType.STRING,None,TType.MAP,(TType.STRING,None,TType.STRING,None)), None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class getInfoByPlugin_args(TBase): - """ - Attributes: - - plugin - """ - - __slots__ = [ - 'plugin', - ] - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'plugin', None, None, ), # 1 - ) - - def __init__(self, plugin=None,): - self.plugin = plugin - - -class getInfoByPlugin_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.MAP, 'success', (TType.STRING,None,TType.STRING,None), None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class isCaptchaWaiting_args(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - - -class isCaptchaWaiting_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.BOOL, 'success', None, None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class getCaptchaTask_args(TBase): - """ - Attributes: - - exclusive - """ - - __slots__ = [ - 'exclusive', - ] - - thrift_spec = ( - None, # 0 - (1, TType.BOOL, 'exclusive', None, None, ), # 1 - ) - - def __init__(self, exclusive=None,): - self.exclusive = exclusive - - -class getCaptchaTask_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.STRUCT, 'success', (CaptchaTask, CaptchaTask.thrift_spec), None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class getCaptchaTaskStatus_args(TBase): - """ - Attributes: - - tid - """ - - __slots__ = [ - 'tid', - ] - - thrift_spec = ( - None, # 0 - (1, TType.I32, 'tid', None, None, ), # 1 - ) - - def __init__(self, tid=None,): - self.tid = tid - - -class getCaptchaTaskStatus_result(TBase): - """ - Attributes: - - success - """ - - __slots__ = [ - 'success', - ] - - thrift_spec = ( - (0, TType.STRING, 'success', None, None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - -class setCaptchaResult_args(TBase): - """ - Attributes: - - tid - - result - """ - - __slots__ = [ - 'tid', - 'result', - ] - - thrift_spec = ( - None, # 0 - (1, TType.I32, 'tid', None, None, ), # 1 - (2, TType.STRING, 'result', None, None, ), # 2 - ) - - def __init__(self, tid=None, result=None,): - self.tid = tid - self.result = result - - -class setCaptchaResult_result(TBase): - - __slots__ = [ - ] - - thrift_spec = ( - ) - diff --git a/module/remote/thriftbackend/thriftgen/pyload/__init__.py b/module/remote/thriftbackend/thriftgen/pyload/__init__.py deleted file mode 100644 index ce7f52598..000000000 --- a/module/remote/thriftbackend/thriftgen/pyload/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__all__ = ['ttypes', 'constants', 'Pyload'] diff --git a/module/remote/thriftbackend/thriftgen/pyload/constants.py b/module/remote/thriftbackend/thriftgen/pyload/constants.py deleted file mode 100644 index f8960dc63..000000000 --- a/module/remote/thriftbackend/thriftgen/pyload/constants.py +++ /dev/null @@ -1,11 +0,0 @@ -# -# Autogenerated by Thrift Compiler (0.9.0-dev) -# -# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -# -# options string: py:slots,dynamic -# - -from thrift.Thrift import TType, TMessageType, TException -from ttypes import * - diff --git a/module/remote/thriftbackend/thriftgen/pyload/ttypes.py b/module/remote/thriftbackend/thriftgen/pyload/ttypes.py deleted file mode 100644 index 1299b515d..000000000 --- a/module/remote/thriftbackend/thriftgen/pyload/ttypes.py +++ /dev/null @@ -1,835 +0,0 @@ -# -# Autogenerated by Thrift Compiler (0.9.0-dev) -# -# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -# -# options string: py:slots,dynamic -# - -from thrift.Thrift import TType, TMessageType, TException - -from thrift.protocol.TBase import TBase, TExceptionBase - - -class DownloadStatus(TBase): - Finished = 0 - Offline = 1 - Online = 2 - Queued = 3 - Skipped = 4 - Waiting = 5 - TempOffline = 6 - Starting = 7 - Failed = 8 - Aborted = 9 - Decrypting = 10 - Custom = 11 - Downloading = 12 - Processing = 13 - Unknown = 14 - - _VALUES_TO_NAMES = { - 0: "Finished", - 1: "Offline", - 2: "Online", - 3: "Queued", - 4: "Skipped", - 5: "Waiting", - 6: "TempOffline", - 7: "Starting", - 8: "Failed", - 9: "Aborted", - 10: "Decrypting", - 11: "Custom", - 12: "Downloading", - 13: "Processing", - 14: "Unknown", - } - - _NAMES_TO_VALUES = { - "Finished": 0, - "Offline": 1, - "Online": 2, - "Queued": 3, - "Skipped": 4, - "Waiting": 5, - "TempOffline": 6, - "Starting": 7, - "Failed": 8, - "Aborted": 9, - "Decrypting": 10, - "Custom": 11, - "Downloading": 12, - "Processing": 13, - "Unknown": 14, - } - -class Destination(TBase): - Collector = 0 - Queue = 1 - - _VALUES_TO_NAMES = { - 0: "Collector", - 1: "Queue", - } - - _NAMES_TO_VALUES = { - "Collector": 0, - "Queue": 1, - } - -class ElementType(TBase): - Package = 0 - File = 1 - - _VALUES_TO_NAMES = { - 0: "Package", - 1: "File", - } - - _NAMES_TO_VALUES = { - "Package": 0, - "File": 1, - } - -class Input(TBase): - NONE = 0 - TEXT = 1 - TEXTBOX = 2 - PASSWORD = 3 - BOOL = 4 - CLICK = 5 - CHOICE = 6 - MULTIPLE = 7 - LIST = 8 - TABLE = 9 - - _VALUES_TO_NAMES = { - 0: "NONE", - 1: "TEXT", - 2: "TEXTBOX", - 3: "PASSWORD", - 4: "BOOL", - 5: "CLICK", - 6: "CHOICE", - 7: "MULTIPLE", - 8: "LIST", - 9: "TABLE", - } - - _NAMES_TO_VALUES = { - "NONE": 0, - "TEXT": 1, - "TEXTBOX": 2, - "PASSWORD": 3, - "BOOL": 4, - "CLICK": 5, - "CHOICE": 6, - "MULTIPLE": 7, - "LIST": 8, - "TABLE": 9, - } - -class Output(TBase): - CAPTCHA = 1 - QUESTION = 2 - NOTIFICATION = 4 - - _VALUES_TO_NAMES = { - 1: "CAPTCHA", - 2: "QUESTION", - 4: "NOTIFICATION", - } - - _NAMES_TO_VALUES = { - "CAPTCHA": 1, - "QUESTION": 2, - "NOTIFICATION": 4, - } - - -class DownloadInfo(TBase): - """ - Attributes: - - fid - - name - - speed - - eta - - format_eta - - bleft - - size - - format_size - - percent - - status - - statusmsg - - format_wait - - wait_until - - packageID - - packageName - - plugin - """ - - __slots__ = [ - 'fid', - 'name', - 'speed', - 'eta', - 'format_eta', - 'bleft', - 'size', - 'format_size', - 'percent', - 'status', - 'statusmsg', - 'format_wait', - 'wait_until', - 'packageID', - 'packageName', - 'plugin', - ] - - thrift_spec = ( - None, # 0 - (1, TType.I32, 'fid', None, None, ), # 1 - (2, TType.STRING, 'name', None, None, ), # 2 - (3, TType.I64, 'speed', None, None, ), # 3 - (4, TType.I32, 'eta', None, None, ), # 4 - (5, TType.STRING, 'format_eta', None, None, ), # 5 - (6, TType.I64, 'bleft', None, None, ), # 6 - (7, TType.I64, 'size', None, None, ), # 7 - (8, TType.STRING, 'format_size', None, None, ), # 8 - (9, TType.BYTE, 'percent', None, None, ), # 9 - (10, TType.I32, 'status', None, None, ), # 10 - (11, TType.STRING, 'statusmsg', None, None, ), # 11 - (12, TType.STRING, 'format_wait', None, None, ), # 12 - (13, TType.I64, 'wait_until', None, None, ), # 13 - (14, TType.I32, 'packageID', None, None, ), # 14 - (15, TType.STRING, 'packageName', None, None, ), # 15 - (16, TType.STRING, 'plugin', None, None, ), # 16 - ) - - def __init__(self, fid=None, name=None, speed=None, eta=None, format_eta=None, bleft=None, size=None, format_size=None, percent=None, status=None, statusmsg=None, format_wait=None, wait_until=None, packageID=None, packageName=None, plugin=None,): - self.fid = fid - self.name = name - self.speed = speed - self.eta = eta - self.format_eta = format_eta - self.bleft = bleft - self.size = size - self.format_size = format_size - self.percent = percent - self.status = status - self.statusmsg = statusmsg - self.format_wait = format_wait - self.wait_until = wait_until - self.packageID = packageID - self.packageName = packageName - self.plugin = plugin - - -class ServerStatus(TBase): - """ - Attributes: - - pause - - active - - queue - - total - - speed - - download - - reconnect - """ - - __slots__ = [ - 'pause', - 'active', - 'queue', - 'total', - 'speed', - 'download', - 'reconnect', - ] - - thrift_spec = ( - None, # 0 - (1, TType.BOOL, 'pause', None, None, ), # 1 - (2, TType.I16, 'active', None, None, ), # 2 - (3, TType.I16, 'queue', None, None, ), # 3 - (4, TType.I16, 'total', None, None, ), # 4 - (5, TType.I64, 'speed', None, None, ), # 5 - (6, TType.BOOL, 'download', None, None, ), # 6 - (7, TType.BOOL, 'reconnect', None, None, ), # 7 - ) - - def __init__(self, pause=None, active=None, queue=None, total=None, speed=None, download=None, reconnect=None,): - self.pause = pause - self.active = active - self.queue = queue - self.total = total - self.speed = speed - self.download = download - self.reconnect = reconnect - - -class ConfigItem(TBase): - """ - Attributes: - - name - - description - - value - - type - """ - - __slots__ = [ - 'name', - 'description', - 'value', - 'type', - ] - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'name', None, None, ), # 1 - (2, TType.STRING, 'description', None, None, ), # 2 - (3, TType.STRING, 'value', None, None, ), # 3 - (4, TType.STRING, 'type', None, None, ), # 4 - ) - - def __init__(self, name=None, description=None, value=None, type=None,): - self.name = name - self.description = description - self.value = value - self.type = type - - -class ConfigSection(TBase): - """ - Attributes: - - name - - description - - items - - outline - """ - - __slots__ = [ - 'name', - 'description', - 'items', - 'outline', - ] - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'name', None, None, ), # 1 - (2, TType.STRING, 'description', None, None, ), # 2 - (3, TType.LIST, 'items', (TType.STRUCT,(ConfigItem, ConfigItem.thrift_spec)), None, ), # 3 - (4, TType.STRING, 'outline', None, None, ), # 4 - ) - - def __init__(self, name=None, description=None, items=None, outline=None,): - self.name = name - self.description = description - self.items = items - self.outline = outline - - -class FileData(TBase): - """ - Attributes: - - fid - - url - - name - - plugin - - size - - format_size - - status - - statusmsg - - packageID - - error - - order - """ - - __slots__ = [ - 'fid', - 'url', - 'name', - 'plugin', - 'size', - 'format_size', - 'status', - 'statusmsg', - 'packageID', - 'error', - 'order', - ] - - thrift_spec = ( - None, # 0 - (1, TType.I32, 'fid', None, None, ), # 1 - (2, TType.STRING, 'url', None, None, ), # 2 - (3, TType.STRING, 'name', None, None, ), # 3 - (4, TType.STRING, 'plugin', None, None, ), # 4 - (5, TType.I64, 'size', None, None, ), # 5 - (6, TType.STRING, 'format_size', None, None, ), # 6 - (7, TType.I32, 'status', None, None, ), # 7 - (8, TType.STRING, 'statusmsg', None, None, ), # 8 - (9, TType.I32, 'packageID', None, None, ), # 9 - (10, TType.STRING, 'error', None, None, ), # 10 - (11, TType.I16, 'order', None, None, ), # 11 - ) - - def __init__(self, fid=None, url=None, name=None, plugin=None, size=None, format_size=None, status=None, statusmsg=None, packageID=None, error=None, order=None,): - self.fid = fid - self.url = url - self.name = name - self.plugin = plugin - self.size = size - self.format_size = format_size - self.status = status - self.statusmsg = statusmsg - self.packageID = packageID - self.error = error - self.order = order - - -class PackageData(TBase): - """ - Attributes: - - pid - - name - - folder - - site - - password - - dest - - order - - linksdone - - sizedone - - sizetotal - - linkstotal - - links - - fids - """ - - __slots__ = [ - 'pid', - 'name', - 'folder', - 'site', - 'password', - 'dest', - 'order', - 'linksdone', - 'sizedone', - 'sizetotal', - 'linkstotal', - 'links', - 'fids', - ] - - 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.I16, 'linksdone', None, None, ), # 8 - (9, TType.I64, 'sizedone', None, None, ), # 9 - (10, TType.I64, 'sizetotal', None, None, ), # 10 - (11, TType.I16, 'linkstotal', None, None, ), # 11 - (12, TType.LIST, 'links', (TType.STRUCT,(FileData, FileData.thrift_spec)), None, ), # 12 - (13, TType.LIST, 'fids', (TType.I32,None), None, ), # 13 - ) - - def __init__(self, pid=None, name=None, folder=None, site=None, password=None, dest=None, order=None, linksdone=None, sizedone=None, sizetotal=None, linkstotal=None, links=None, fids=None,): - self.pid = pid - self.name = name - self.folder = folder - self.site = site - self.password = password - self.dest = dest - self.order = order - self.linksdone = linksdone - self.sizedone = sizedone - self.sizetotal = sizetotal - self.linkstotal = linkstotal - self.links = links - self.fids = fids - - -class InteractionTask(TBase): - """ - Attributes: - - iid - - input - - structure - - preset - - output - - data - - title - - description - - plugin - """ - - __slots__ = [ - 'iid', - 'input', - 'structure', - 'preset', - 'output', - 'data', - 'title', - 'description', - 'plugin', - ] - - thrift_spec = ( - None, # 0 - (1, TType.I32, 'iid', None, None, ), # 1 - (2, TType.I32, 'input', None, None, ), # 2 - (3, TType.LIST, 'structure', (TType.STRING,None), None, ), # 3 - (4, TType.LIST, 'preset', (TType.STRING,None), None, ), # 4 - (5, TType.I32, 'output', None, None, ), # 5 - (6, TType.LIST, 'data', (TType.STRING,None), None, ), # 6 - (7, TType.STRING, 'title', None, None, ), # 7 - (8, TType.STRING, 'description', None, None, ), # 8 - (9, TType.STRING, 'plugin', None, None, ), # 9 - ) - - def __init__(self, iid=None, input=None, structure=None, preset=None, output=None, data=None, title=None, description=None, plugin=None,): - self.iid = iid - self.input = input - self.structure = structure - self.preset = preset - self.output = output - self.data = data - self.title = title - self.description = description - self.plugin = plugin - - -class CaptchaTask(TBase): - """ - Attributes: - - tid - - data - - type - - resultType - """ - - __slots__ = [ - 'tid', - 'data', - 'type', - 'resultType', - ] - - thrift_spec = ( - None, # 0 - (1, TType.I16, 'tid', None, None, ), # 1 - (2, TType.STRING, 'data', None, None, ), # 2 - (3, TType.STRING, 'type', None, None, ), # 3 - (4, TType.STRING, 'resultType', None, None, ), # 4 - ) - - def __init__(self, tid=None, data=None, type=None, resultType=None,): - self.tid = tid - self.data = data - self.type = type - self.resultType = resultType - - -class EventInfo(TBase): - """ - Attributes: - - eventname - - id - - type - - destination - """ - - __slots__ = [ - 'eventname', - 'id', - 'type', - 'destination', - ] - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'eventname', None, None, ), # 1 - (2, TType.I32, 'id', None, None, ), # 2 - (3, TType.I32, 'type', None, None, ), # 3 - (4, TType.I32, 'destination', None, None, ), # 4 - ) - - def __init__(self, eventname=None, id=None, type=None, destination=None,): - self.eventname = eventname - self.id = id - self.type = type - self.destination = destination - - -class UserData(TBase): - """ - Attributes: - - name - - email - - role - - permission - - templateName - """ - - __slots__ = [ - 'name', - 'email', - 'role', - 'permission', - 'templateName', - ] - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'name', None, None, ), # 1 - (2, TType.STRING, 'email', None, None, ), # 2 - (3, TType.I32, 'role', None, None, ), # 3 - (4, TType.I32, 'permission', None, None, ), # 4 - (5, TType.STRING, 'templateName', None, None, ), # 5 - ) - - def __init__(self, name=None, email=None, role=None, permission=None, templateName=None,): - self.name = name - self.email = email - self.role = role - self.permission = permission - self.templateName = templateName - - -class AccountInfo(TBase): - """ - Attributes: - - validuntil - - login - - options - - valid - - trafficleft - - maxtraffic - - premium - - type - """ - - __slots__ = [ - 'validuntil', - 'login', - 'options', - 'valid', - 'trafficleft', - 'maxtraffic', - 'premium', - 'type', - ] - - thrift_spec = ( - None, # 0 - (1, TType.I64, 'validuntil', None, None, ), # 1 - (2, TType.STRING, 'login', None, None, ), # 2 - (3, TType.MAP, 'options', (TType.STRING,None,TType.LIST,(TType.STRING,None)), None, ), # 3 - (4, TType.BOOL, 'valid', None, None, ), # 4 - (5, TType.I64, 'trafficleft', None, None, ), # 5 - (6, TType.I64, 'maxtraffic', None, None, ), # 6 - (7, TType.BOOL, 'premium', None, None, ), # 7 - (8, TType.STRING, 'type', None, None, ), # 8 - ) - - def __init__(self, validuntil=None, login=None, options=None, valid=None, trafficleft=None, maxtraffic=None, premium=None, type=None,): - self.validuntil = validuntil - self.login = login - self.options = options - self.valid = valid - self.trafficleft = trafficleft - self.maxtraffic = maxtraffic - self.premium = premium - self.type = type - - -class ServiceCall(TBase): - """ - Attributes: - - plugin - - func - - arguments - - parseArguments - """ - - __slots__ = [ - 'plugin', - 'func', - 'arguments', - 'parseArguments', - ] - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'plugin', None, None, ), # 1 - (2, TType.STRING, 'func', None, None, ), # 2 - (3, TType.LIST, 'arguments', (TType.STRING,None), None, ), # 3 - (4, TType.BOOL, 'parseArguments', None, None, ), # 4 - ) - - def __init__(self, plugin=None, func=None, arguments=None, parseArguments=None,): - self.plugin = plugin - self.func = func - self.arguments = arguments - self.parseArguments = parseArguments - - -class OnlineStatus(TBase): - """ - Attributes: - - name - - plugin - - packagename - - status - - size - """ - - __slots__ = [ - 'name', - 'plugin', - 'packagename', - 'status', - 'size', - ] - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'name', None, None, ), # 1 - (2, TType.STRING, 'plugin', None, None, ), # 2 - (3, TType.STRING, 'packagename', None, None, ), # 3 - (4, TType.I32, 'status', None, None, ), # 4 - (5, TType.I64, 'size', None, None, ), # 5 - ) - - def __init__(self, name=None, plugin=None, packagename=None, status=None, size=None,): - self.name = name - self.plugin = plugin - self.packagename = packagename - self.status = status - self.size = size - - -class OnlineCheck(TBase): - """ - Attributes: - - rid - - data - """ - - __slots__ = [ - 'rid', - 'data', - ] - - thrift_spec = ( - None, # 0 - (1, TType.I32, 'rid', None, None, ), # 1 - (2, TType.MAP, 'data', (TType.STRING,None,TType.STRUCT,(OnlineStatus, OnlineStatus.thrift_spec)), None, ), # 2 - ) - - def __init__(self, rid=None, data=None,): - self.rid = rid - self.data = data - - -class PackageDoesNotExists(TExceptionBase): - """ - Attributes: - - pid - """ - - __slots__ = [ - 'pid', - ] - - thrift_spec = ( - None, # 0 - (1, TType.I32, 'pid', None, None, ), # 1 - ) - - def __init__(self, pid=None,): - self.pid = pid - - def __str__(self): - return repr(self) - - -class FileDoesNotExists(TExceptionBase): - """ - Attributes: - - fid - """ - - __slots__ = [ - 'fid', - ] - - thrift_spec = ( - None, # 0 - (1, TType.I32, 'fid', None, None, ), # 1 - ) - - def __init__(self, fid=None,): - self.fid = fid - - def __str__(self): - return repr(self) - - -class ServiceDoesNotExists(TExceptionBase): - """ - Attributes: - - plugin - - func - """ - - __slots__ = [ - 'plugin', - 'func', - ] - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'plugin', None, None, ), # 1 - (2, TType.STRING, 'func', None, None, ), # 2 - ) - - def __init__(self, plugin=None, func=None,): - self.plugin = plugin - self.func = func - - def __str__(self): - return repr(self) - - -class ServiceException(TExceptionBase): - """ - Attributes: - - msg - """ - - __slots__ = [ - 'msg', - ] - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'msg', None, None, ), # 1 - ) - - def __init__(self, msg=None,): - self.msg = msg - - def __str__(self): - return repr(self) - diff --git a/module/remote/ttypes.py b/module/remote/ttypes.py new file mode 100644 index 000000000..1f91403d5 --- /dev/null +++ b/module/remote/ttypes.py @@ -0,0 +1,534 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Autogenerated by pyload +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +class BaseObject(object): + __slots__ = [] + + def __str__(self): + return "<%s %s>" % (self.__class__.__name__, ", ".join("%s=%s" % (k,getattr(self,k)) for k in self.__slots__)) + +class ExceptionObject(Exception): + __slots__ = [] + +class DownloadState: + All = 0 + Finished = 1 + Unfinished = 2 + Failed = 3 + Unmanaged = 4 + +class DownloadStatus: + NA = 0 + Offline = 1 + Online = 2 + Queued = 3 + Paused = 4 + Finished = 5 + Skipped = 6 + Failed = 7 + Starting = 8 + Waiting = 9 + Downloading = 10 + TempOffline = 11 + Aborted = 12 + Decrypting = 13 + Processing = 14 + Custom = 15 + Unknown = 16 + +class FileStatus: + Ok = 0 + Missing = 1 + Remote = 2 + +class Input: + NA = 0 + Text = 1 + Int = 2 + File = 3 + Folder = 4 + Textbox = 5 + Password = 6 + Bool = 7 + Click = 8 + Select = 9 + Multiple = 10 + List = 11 + Table = 12 + +class MediaType: + All = 0 + Other = 1 + Audio = 2 + Image = 4 + Video = 8 + Document = 16 + Archive = 32 + +class Output: + All = 0 + Notification = 1 + Captcha = 2 + Query = 4 + +class PackageStatus: + Ok = 0 + Paused = 1 + Folder = 2 + Remote = 3 + +class Permission: + All = 0 + Add = 1 + Delete = 2 + Modify = 4 + Download = 8 + Accounts = 16 + Interaction = 32 + Plugins = 64 + +class Role: + Admin = 0 + User = 1 + +class AccountInfo(BaseObject): + __slots__ = ['plugin', 'loginname', 'owner', 'valid', 'validuntil', 'trafficleft', 'maxtraffic', 'premium', 'activated', 'shared', 'options'] + + def __init__(self, plugin=None, loginname=None, owner=None, valid=None, validuntil=None, trafficleft=None, maxtraffic=None, premium=None, activated=None, shared=None, options=None): + self.plugin = plugin + self.loginname = loginname + self.owner = owner + self.valid = valid + self.validuntil = validuntil + self.trafficleft = trafficleft + self.maxtraffic = maxtraffic + self.premium = premium + self.activated = activated + self.shared = shared + self.options = options + +class AddonInfo(BaseObject): + __slots__ = ['func_name', 'description', 'value'] + + def __init__(self, func_name=None, description=None, value=None): + self.func_name = func_name + self.description = description + self.value = value + +class AddonService(BaseObject): + __slots__ = ['func_name', 'description', 'arguments', 'media'] + + def __init__(self, func_name=None, description=None, arguments=None, media=None): + self.func_name = func_name + self.description = description + self.arguments = arguments + self.media = media + +class ConfigHolder(BaseObject): + __slots__ = ['name', 'label', 'description', 'long_description', 'items', 'info', 'handler'] + + def __init__(self, name=None, label=None, description=None, long_description=None, items=None, info=None, handler=None): + self.name = name + self.label = label + self.description = description + self.long_description = long_description + self.items = items + self.info = info + self.handler = handler + +class ConfigInfo(BaseObject): + __slots__ = ['name', 'label', 'description', 'category', 'user_context', 'activated'] + + def __init__(self, name=None, label=None, description=None, category=None, user_context=None, activated=None): + self.name = name + self.label = label + self.description = description + self.category = category + self.user_context = user_context + self.activated = activated + +class ConfigItem(BaseObject): + __slots__ = ['name', 'label', 'description', 'type', 'default_value', 'value'] + + def __init__(self, name=None, label=None, description=None, type=None, default_value=None, value=None): + self.name = name + self.label = label + self.description = description + self.type = type + self.default_value = default_value + self.value = value + +class DownloadInfo(BaseObject): + __slots__ = ['url', 'plugin', 'hash', 'status', 'statusmsg', 'error'] + + def __init__(self, url=None, plugin=None, hash=None, status=None, statusmsg=None, error=None): + self.url = url + self.plugin = plugin + self.hash = hash + self.status = status + self.statusmsg = statusmsg + self.error = error + +class DownloadProgress(BaseObject): + __slots__ = ['fid', 'pid', 'speed', 'status'] + + def __init__(self, fid=None, pid=None, speed=None, status=None): + self.fid = fid + self.pid = pid + self.speed = speed + self.status = status + +class EventInfo(BaseObject): + __slots__ = ['eventname', 'event_args'] + + def __init__(self, eventname=None, event_args=None): + self.eventname = eventname + self.event_args = event_args + +class FileDoesNotExists(ExceptionObject): + __slots__ = ['fid'] + + def __init__(self, fid=None): + self.fid = fid + +class FileInfo(BaseObject): + __slots__ = ['fid', 'name', 'package', 'owner', 'size', 'status', 'media', 'added', 'fileorder', 'download'] + + def __init__(self, fid=None, name=None, package=None, owner=None, size=None, status=None, media=None, added=None, fileorder=None, download=None): + self.fid = fid + self.name = name + self.package = package + self.owner = owner + self.size = size + self.status = status + self.media = media + self.added = added + self.fileorder = fileorder + self.download = download + +class Forbidden(ExceptionObject): + pass + +class InteractionTask(BaseObject): + __slots__ = ['iid', 'input', 'data', 'output', 'default_value', 'title', 'description', 'plugin'] + + def __init__(self, iid=None, input=None, data=None, output=None, default_value=None, title=None, description=None, plugin=None): + self.iid = iid + self.input = input + self.data = data + self.output = output + self.default_value = default_value + self.title = title + self.description = description + self.plugin = plugin + +class InvalidConfigSection(ExceptionObject): + __slots__ = ['section'] + + def __init__(self, section=None): + self.section = section + +class LinkStatus(BaseObject): + __slots__ = ['url', 'name', 'plugin', 'size', 'status', 'packagename'] + + def __init__(self, url=None, name=None, plugin=None, size=None, status=None, packagename=None): + self.url = url + self.name = name + self.plugin = plugin + self.size = size + self.status = status + self.packagename = packagename + +class OnlineCheck(BaseObject): + __slots__ = ['rid', 'data'] + + def __init__(self, rid=None, data=None): + self.rid = rid + self.data = data + +class PackageDoesNotExists(ExceptionObject): + __slots__ = ['pid'] + + def __init__(self, pid=None): + self.pid = pid + +class PackageInfo(BaseObject): + __slots__ = ['pid', 'name', 'folder', 'root', 'owner', 'site', 'comment', 'password', 'added', 'tags', 'status', 'shared', 'packageorder', 'stats', 'fids', 'pids'] + + def __init__(self, pid=None, name=None, folder=None, root=None, owner=None, site=None, comment=None, password=None, added=None, tags=None, status=None, shared=None, packageorder=None, stats=None, fids=None, pids=None): + self.pid = pid + self.name = name + self.folder = folder + self.root = root + self.owner = owner + self.site = site + self.comment = comment + self.password = password + self.added = added + self.tags = tags + self.status = status + self.shared = shared + self.packageorder = packageorder + self.stats = stats + self.fids = fids + self.pids = pids + +class PackageStats(BaseObject): + __slots__ = ['linkstotal', 'linksdone', 'sizetotal', 'sizedone'] + + def __init__(self, linkstotal=None, linksdone=None, sizetotal=None, sizedone=None): + self.linkstotal = linkstotal + self.linksdone = linksdone + self.sizetotal = sizetotal + self.sizedone = sizedone + +class ProgressInfo(BaseObject): + __slots__ = ['plugin', 'name', 'statusmsg', 'eta', 'done', 'total', 'download'] + + def __init__(self, plugin=None, name=None, statusmsg=None, eta=None, done=None, total=None, download=None): + self.plugin = plugin + self.name = name + self.statusmsg = statusmsg + self.eta = eta + self.done = done + self.total = total + self.download = download + +class ServerStatus(BaseObject): + __slots__ = ['queuedDownloads', 'totalDownloads', 'speed', 'pause', 'download', 'reconnect'] + + def __init__(self, queuedDownloads=None, totalDownloads=None, speed=None, pause=None, download=None, reconnect=None): + self.queuedDownloads = queuedDownloads + self.totalDownloads = totalDownloads + self.speed = speed + self.pause = pause + self.download = download + self.reconnect = reconnect + +class ServiceDoesNotExists(ExceptionObject): + __slots__ = ['plugin', 'func'] + + def __init__(self, plugin=None, func=None): + self.plugin = plugin + self.func = func + +class ServiceException(ExceptionObject): + __slots__ = ['msg'] + + def __init__(self, msg=None): + self.msg = msg + +class TreeCollection(BaseObject): + __slots__ = ['root', 'files', 'packages'] + + def __init__(self, root=None, files=None, packages=None): + self.root = root + self.files = files + self.packages = packages + +class Unauthorized(ExceptionObject): + pass + +class UserData(BaseObject): + __slots__ = ['uid', 'name', 'email', 'role', 'permission', 'folder', 'traffic', 'dllimit', 'dlquota', 'hddquota', 'user', 'templateName'] + + def __init__(self, uid=None, name=None, email=None, role=None, permission=None, folder=None, traffic=None, dllimit=None, dlquota=None, hddquota=None, user=None, templateName=None): + self.uid = uid + self.name = name + self.email = email + self.role = role + self.permission = permission + self.folder = folder + self.traffic = traffic + self.dllimit = dllimit + self.dlquota = dlquota + self.hddquota = hddquota + self.user = user + self.templateName = templateName + +class UserDoesNotExists(ExceptionObject): + __slots__ = ['user'] + + def __init__(self, user=None): + self.user = user + +class Iface(object): + def addFromCollector(self, name, paused): + pass + def addLinks(self, pid, links): + pass + def addLocalFile(self, pid, name, path): + pass + def addPackage(self, name, links, password): + pass + def addPackageChild(self, name, links, password, root, paused): + pass + def addPackageP(self, name, links, password, paused): + pass + def addToCollector(self, links): + pass + def addUser(self, username, password): + pass + def callAddon(self, plugin, func, arguments): + pass + def callAddonHandler(self, plugin, func, pid_or_fid): + pass + def checkOnlineStatus(self, urls): + pass + def checkOnlineStatusContainer(self, urls, filename, data): + pass + def checkURLs(self, urls): + pass + def configurePlugin(self, plugin): + pass + def createPackage(self, name, folder, root, password, site, comment, paused): + pass + def deleteCollLink(self, url): + pass + def deleteCollPack(self, name): + pass + def deleteConfig(self, plugin): + pass + def deleteFiles(self, fids): + pass + def deletePackages(self, pids): + pass + def findFiles(self, pattern): + pass + def findPackages(self, tags): + pass + def freeSpace(self): + pass + def generateAndAddPackages(self, links, paused): + pass + def generateDownloadLink(self, fid, timeout): + pass + def generatePackages(self, links): + pass + def getAccountTypes(self): + pass + def getAccounts(self, refresh): + pass + def getAddonHandler(self): + pass + def getAllFiles(self): + pass + def getAllUserData(self): + pass + def getAutocompletion(self, pattern): + pass + def getAvailablePlugins(self): + pass + def getCollector(self): + pass + def getConfig(self): + pass + def getConfigValue(self, section, option): + pass + def getCoreConfig(self): + pass + def getEvents(self, uuid): + pass + def getFileInfo(self, fid): + pass + def getFileTree(self, pid, full): + pass + def getFilteredFileTree(self, pid, full, state): + pass + def getFilteredFiles(self, state): + pass + def getInteractionTask(self, mode): + pass + def getLog(self, offset): + pass + def getNotifications(self): + pass + def getPackageContent(self, pid): + pass + def getPackageInfo(self, pid): + pass + def getPluginConfig(self): + pass + def getProgressInfo(self): + pass + def getServerStatus(self): + pass + def getServerVersion(self): + pass + def getUserData(self): + pass + def getWSAddress(self): + pass + def hasAddonHandler(self, plugin, func): + pass + def isInteractionWaiting(self, mode): + pass + def login(self, username, password): + pass + def moveFiles(self, fids, pid): + pass + def movePackage(self, pid, root): + pass + def orderFiles(self, fids, pid, position): + pass + def orderPackage(self, pids, position): + pass + def parseURLs(self, html, url): + pass + def pauseServer(self): + pass + def pollResults(self, rid): + pass + def quit(self): + pass + def recheckPackage(self, pid): + pass + def removeAccount(self, plugin, account): + pass + def removeUser(self, uid): + pass + def renameCollPack(self, name, new_name): + pass + def restart(self): + pass + def restartFailed(self): + pass + def restartFile(self, fid): + pass + def restartPackage(self, pid): + pass + def saveConfig(self, config): + pass + def setConfigHandler(self, plugin, iid, value): + pass + def setConfigValue(self, section, option, value): + pass + def setInteractionResult(self, iid, result): + pass + def setPackageFolder(self, pid, path): + pass + def setPassword(self, username, old_password, new_password): + pass + def stopAllDownloads(self): + pass + def stopDownloads(self, fids): + pass + def togglePause(self): + pass + def toggleReconnect(self): + pass + def unpauseServer(self): + pass + def updateAccount(self, plugin, account, password): + pass + def updateAccountInfo(self, account): + pass + def updatePackage(self, pack): + pass + def updateUserData(self, data): + pass + def uploadContainer(self, filename, data): + pass + diff --git a/module/remote/wsbackend/AbstractHandler.py b/module/remote/wsbackend/AbstractHandler.py new file mode 100644 index 000000000..07cc79c74 --- /dev/null +++ b/module/remote/wsbackend/AbstractHandler.py @@ -0,0 +1,133 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +############################################################################### +# Copyright(c) 2008-2012 pyLoad Team +# http://www.pyload.org +# +# This file is part of pyLoad. +# pyLoad is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# Subjected to the terms and conditions in LICENSE +# +# @author: RaNaN +############################################################################### + +from mod_pywebsocket.msgutil import send_message +from mod_pywebsocket.util import get_class_logger +from module.remote.json_converter import loads, dumps + + +class AbstractHandler: + """ + Abstract Handler providing common methods shared across WebSocket handlers + """ + PATH = "/" + + OK = 200 + BAD_REQUEST = 400 + UNAUTHORIZED = 401 + FORBIDDEN = 403 + NOT_FOUND = 404 + ERROR = 500 + + def __init__(self, api): + self.log = get_class_logger() + self.api = api + self.core = api.core + + def do_extra_handshake(self, req): + self.log.debug("WS Connected: %s" % req) + req.api = None #when api is set client is logged in + + # allow login via session when webinterface is active + if self.core.config['webinterface']['activated']: + cookie = req.headers_in.getheader('Cookie') + s = self.load_session(cookie) + if s: + uid = s.get('uid', None) + req.api = self.api.withUserContext(uid) + self.log.debug("WS authenticated user with cookie: %d" % uid) + + self.on_open(req) + + def on_open(self, req): + pass + + def load_session(self, cookies): + from Cookie import SimpleCookie + from beaker.session import Session + from module.web.webinterface import session + + cookies = SimpleCookie(cookies) + sid = cookies.get(session.options['key']) + if not sid: + return None + + s = Session({}, use_cookies=False, id=sid.value, **session.options) + if s.is_new: + return None + + return s + + def passive_closing_handshake(self, req): + self.log.debug("WS Closed: %s" % req) + self.on_close(req) + + def on_close(self, req): + pass + + def transfer_data(self, req): + raise NotImplemented + + def handle_call(self, msg, req): + """ Parses the msg for an argument call. If func is null an response was already sent. + + :return: func, args, kwargs + """ + try: + o = loads(msg) + except ValueError, e: #invalid json object + self.log.debug("Invalid Request: %s" % e) + self.send_result(req, self.ERROR, "No JSON request") + return None, None, None + + if not isinstance(o, basestring) and type(o) != list and len(o) not in range(1, 4): + self.log.debug("Invalid Api call: %s" % o) + self.send_result(req, self.ERROR, "Invalid Api call") + return None, None, None + + # called only with name, no args + if isinstance(o, basestring): + return o, [], {} + elif len(o) == 1: # arguments omitted + return o[0], [], {} + elif len(o) == 2: + func, args = o + if type(args) == list: + return func, args, {} + else: + return func, [], args + else: + return tuple(o) + + def do_login(self, req, args, kwargs): + user = self.api.checkAuth(*args, **kwargs) + if user: + req.api = self.api.withUserContext(user.uid) + return self.send_result(req, self.OK, True) + else: + return self.send_result(req, self.FORBIDDEN, "Forbidden") + + def do_logout(self, req): + req.api = None + return self.send_result(req, self.OK, True) + + def send_result(self, req, code, result): + return send_message(req, dumps([code, result])) + + def send(self, req, obj): + return send_message(req, dumps(obj))
\ No newline at end of file diff --git a/module/remote/wsbackend/ApiHandler.py b/module/remote/wsbackend/ApiHandler.py new file mode 100644 index 000000000..e985e10be --- /dev/null +++ b/module/remote/wsbackend/ApiHandler.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +############################################################################### +# Copyright(c) 2008-2012 pyLoad Team +# http://www.pyload.org +# +# This file is part of pyLoad. +# pyLoad is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# Subjected to the terms and conditions in LICENSE +# +# @author: RaNaN +############################################################################### + +from mod_pywebsocket.msgutil import receive_message + +from module.Api import ExceptionObject + +from AbstractHandler import AbstractHandler + +class ApiHandler(AbstractHandler): + """Provides access to the API. + + Send your request as json encoded string in the following manner: + ["function", [*args]] or ["function", {**kwargs}] + + the result will be: + + [code, result] + + Don't forget to login first. + Non json request will be ignored. + """ + + PATH = "/api" + + def transfer_data(self, req): + while True: + try: + line = receive_message(req) + except TypeError, e: # connection closed + self.log.debug("WS Error: %s" % e) + return self.passive_closing_handshake(req) + + self.handle_message(line, req) + + def handle_message(self, msg, req): + + func, args, kwargs = self.handle_call(msg, req) + if not func: + return # handle_call already sent the result + + if func == 'login': + return self.do_login(req, args, kwargs) + elif func == 'logout': + return self.do_logout(req) + else: + if not req.api: + return self.send_result(req, self.FORBIDDEN, "Forbidden") + + if not self.api.isAuthorized(func, req.api.user): + return self.send_result(req, self.UNAUTHORIZED, "Unauthorized") + + try: + result = getattr(req.api, func)(*args, **kwargs) + except ExceptionObject, e: + return self.send_result(req, self.BAD_REQUEST, e) + except AttributeError: + return self.send_result(req, self.NOT_FOUND, "Not Found") + except Exception, e: + self.core.print_exc() + return self.send_result(req, self.ERROR, str(e)) + + # None is invalid json type + if result is None: result = True + + return self.send_result(req, self.OK, result)
\ No newline at end of file diff --git a/module/remote/wsbackend/AsyncHandler.py b/module/remote/wsbackend/AsyncHandler.py new file mode 100644 index 000000000..d9e302fbb --- /dev/null +++ b/module/remote/wsbackend/AsyncHandler.py @@ -0,0 +1,164 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +############################################################################### +# Copyright(c) 2008-2012 pyLoad Team +# http://www.pyload.org +# +# This file is part of pyLoad. +# pyLoad is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# Subjected to the terms and conditions in LICENSE +# +# @author: RaNaN +############################################################################### + +import re +from Queue import Queue, Empty +from threading import Lock +from time import time + +from mod_pywebsocket.msgutil import receive_message + +from module.Api import EventInfo, Interaction +from module.utils import lock +from AbstractHandler import AbstractHandler + +class Mode: + STANDBY = 1 + RUNNING = 2 + +class AsyncHandler(AbstractHandler): + """ + Handler that provides asynchronous information about server status, running downloads, occurred events. + + Progress information are continuous and will be pushed in a fixed interval when available. + After connect you have to login and can set the interval by sending the json command ["setInterval", xy]. + To start receiving updates call "start", afterwards no more incoming messages will be accepted! + """ + + PATH = "/async" + COMMAND = "start" + + PROGRESS_INTERVAL = 2 + EVENT_PATTERN = re.compile(r"^(package|file|interaction)", re.I) + INTERACTION = Interaction.All + + def __init__(self, api): + AbstractHandler.__init__(self, api) + self.clients = [] + self.lock = Lock() + + self.core.evm.addEvent("event", self.add_event) + + @lock + def on_open(self, req): + req.queue = Queue() + req.interval = self.PROGRESS_INTERVAL + req.events = self.EVENT_PATTERN + req.interaction = self.INTERACTION + req.mode = Mode.STANDBY + req.t = time() # time when update should be pushed + self.clients.append(req) + + @lock + def on_close(self, req): + try: + del req.queue + self.clients.remove(req) + except ValueError: # ignore when not in list + pass + + @lock + def add_event(self, event, *args): + # Convert arguments to json suited instance + event = EventInfo(event, [x.toInfoData() if hasattr(x, 'toInfoData') else x for x in args]) + + for req in self.clients: + # filter events that these user is no owner of + # TODO: events are security critical, this should be revised later + # TODO: permissions? interaction etc + if not req.api.user.isAdmin(): + skip = False + for arg in args: + if hasattr(arg, 'owner') and arg.owner != req.api.primaryUID: + skip = True + break + + # user should not get this event + if skip: break + + if req.events.search(event.eventname): + self.log.debug("Pushing event %s" % event) + req.queue.put(event) + + def transfer_data(self, req): + while True: + + if req.mode == Mode.STANDBY: + try: + line = receive_message(req) + except TypeError, e: # connection closed + self.log.debug("WS Error: %s" % e) + return self.passive_closing_handshake(req) + + self.mode_standby(line, req) + else: + if self.mode_running(req): + return self.passive_closing_handshake(req) + + def mode_standby(self, msg, req): + """ accepts calls before pushing updates """ + func, args, kwargs = self.handle_call(msg, req) + if not func: + return # Result was already sent + + if func == 'login': + return self.do_login(req, args, kwargs) + + elif func == 'logout': + return self.do_logout(req) + + else: + if not req.api: + return self.send_result(req, self.FORBIDDEN, "Forbidden") + + if func == "setInterval": + req.interval = args[0] + elif func == "setEvents": + req.events = re.compile(args[0], re.I) + elif func == "setInteraction": + req.interaction = args[0] + elif func == self.COMMAND: + req.mode = Mode.RUNNING + + + def mode_running(self, req): + """ Listen for events, closes socket when returning True """ + try: + # block length of update interval if necessary + ev = req.queue.get(True, req.interval) + try: + self.send(req, ev) + except TypeError: + self.log.debug("Event %s not converted" % ev) + ev.event_args = [] + # Resend the event without arguments + self.send(req, ev) + + except Empty: + pass + + if req.t <= time(): + # TODO: server status is not enough + # modify core api to include progress? think of other needed information to show + # eta is quite wrong currently + # notifications + self.send(req, self.api.getServerStatus()) + self.send(req, self.api.getProgressInfo()) + + # update time for next update + req.t = time() + req.interval
\ No newline at end of file diff --git a/module/remote/wsbackend/Dispatcher.py b/module/remote/wsbackend/Dispatcher.py new file mode 100644 index 000000000..44cc7555e --- /dev/null +++ b/module/remote/wsbackend/Dispatcher.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +############################################################################### +# Copyright(c) 2008-2012 pyLoad Team +# http://www.pyload.org +# +# This file is part of pyLoad. +# pyLoad is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# Subjected to the terms and conditions in LICENSE +# +# @author: RaNaN +############################################################################### + +from mod_pywebsocket import util +from mod_pywebsocket.dispatch import Dispatcher as BaseDispatcher + +class Dispatcher(BaseDispatcher): + + def __init__(self): + self._logger = util.get_class_logger(self) + + self._handler_suite_map = {} + self._source_warnings = [] + + def addHandler(self, path, handler): + self._handler_suite_map[path] = handler
\ No newline at end of file diff --git a/module/remote/wsbackend/Server.py b/module/remote/wsbackend/Server.py new file mode 100644 index 000000000..9b52f5464 --- /dev/null +++ b/module/remote/wsbackend/Server.py @@ -0,0 +1,724 @@ +#!/usr/bin/env python +# +# Copyright 2012, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +# A copy of standalone.py with uneeded stuff removed +# some logging methods removed +# Added api attribute to request + +import BaseHTTPServer +import CGIHTTPServer +import SocketServer +import httplib +import logging +import os +import re +import select +import socket +import sys +import threading + +_HAS_SSL = False +_HAS_OPEN_SSL = False + +from mod_pywebsocket import common +from mod_pywebsocket import dispatch +from mod_pywebsocket import handshake +from mod_pywebsocket import http_header_util +from mod_pywebsocket import memorizingfile +from mod_pywebsocket import util + + +_DEFAULT_LOG_MAX_BYTES = 1024 * 256 +_DEFAULT_LOG_BACKUP_COUNT = 5 + +_DEFAULT_REQUEST_QUEUE_SIZE = 128 + +# 1024 is practically large enough to contain WebSocket handshake lines. +_MAX_MEMORIZED_LINES = 1024 + +def import_ssl(): + global _HAS_SSL, _HAS_OPEN_SSL + try: + import ssl + _HAS_SSL = True + except ImportError: + try: + import OpenSSL.SSL + _HAS_OPEN_SSL = True + except ImportError: + pass + + +class _StandaloneConnection(object): + """Mimic mod_python mp_conn.""" + + def __init__(self, request_handler): + """Construct an instance. + + Args: + request_handler: A WebSocketRequestHandler instance. + """ + + self._request_handler = request_handler + + def get_local_addr(self): + """Getter to mimic mp_conn.local_addr.""" + + return (self._request_handler.server.server_name, + self._request_handler.server.server_port) + local_addr = property(get_local_addr) + + def get_remote_addr(self): + """Getter to mimic mp_conn.remote_addr. + + Setting the property in __init__ won't work because the request + handler is not initialized yet there.""" + + return self._request_handler.client_address + remote_addr = property(get_remote_addr) + + def write(self, data): + """Mimic mp_conn.write().""" + + return self._request_handler.wfile.write(data) + + def read(self, length): + """Mimic mp_conn.read().""" + + return self._request_handler.rfile.read(length) + + def get_memorized_lines(self): + """Get memorized lines.""" + + return self._request_handler.rfile.get_memorized_lines() + + +class _StandaloneRequest(object): + """Mimic mod_python request.""" + + def __init__(self, request_handler, use_tls): + """Construct an instance. + + Args: + request_handler: A WebSocketRequestHandler instance. + """ + + self._logger = util.get_class_logger(self) + + self._request_handler = request_handler + self.connection = _StandaloneConnection(request_handler) + self._use_tls = use_tls + self.headers_in = request_handler.headers + + def get_uri(self): + """Getter to mimic request.uri.""" + + return self._request_handler.path + uri = property(get_uri) + + def get_method(self): + """Getter to mimic request.method.""" + + return self._request_handler.command + method = property(get_method) + + def get_protocol(self): + """Getter to mimic request.protocol.""" + + return self._request_handler.request_version + protocol = property(get_protocol) + + def is_https(self): + """Mimic request.is_https().""" + + return self._use_tls + + def _drain_received_data(self): + """Don't use this method from WebSocket handler. Drains unread data + in the receive buffer. + """ + + raw_socket = self._request_handler.connection + drained_data = util.drain_received_data(raw_socket) + + if drained_data: + self._logger.debug( + 'Drained data following close frame: %r', drained_data) + + +class _StandaloneSSLConnection(object): + """A wrapper class for OpenSSL.SSL.Connection to provide makefile method + which is not supported by the class. + """ + + def __init__(self, connection): + self._connection = connection + + def __getattribute__(self, name): + if name in ('_connection', 'makefile'): + return object.__getattribute__(self, name) + return self._connection.__getattribute__(name) + + def __setattr__(self, name, value): + if name in ('_connection', 'makefile'): + return object.__setattr__(self, name, value) + return self._connection.__setattr__(name, value) + + def makefile(self, mode='r', bufsize=-1): + return socket._fileobject(self._connection, mode, bufsize) + + +def _alias_handlers(dispatcher, websock_handlers_map_file): + """Set aliases specified in websock_handler_map_file in dispatcher. + + Args: + dispatcher: dispatch.Dispatcher instance + websock_handler_map_file: alias map file + """ + + fp = open(websock_handlers_map_file) + try: + for line in fp: + if line[0] == '#' or line.isspace(): + continue + m = re.match('(\S+)\s+(\S+)', line) + if not m: + logging.warning('Wrong format in map file:' + line) + continue + try: + dispatcher.add_resource_path_alias( + m.group(1), m.group(2)) + except dispatch.DispatchException, e: + logging.error(str(e)) + finally: + fp.close() + + +class WebSocketServer(SocketServer.ThreadingMixIn, BaseHTTPServer.HTTPServer): + """HTTPServer specialized for WebSocket.""" + + # Overrides SocketServer.ThreadingMixIn.daemon_threads + daemon_threads = True + # Overrides BaseHTTPServer.HTTPServer.allow_reuse_address + allow_reuse_address = True + + def __init__(self, options): + """Override SocketServer.TCPServer.__init__ to set SSL enabled + socket object to self.socket before server_bind and server_activate, + if necessary. + """ + # Removed dispatcher init here + self._logger = logging.getLogger("log") + + self.request_queue_size = options.request_queue_size + self.__ws_is_shut_down = threading.Event() + self.__ws_serving = False + + SocketServer.BaseServer.__init__( + self, (options.server_host, options.port), WebSocketRequestHandler) + + # Expose the options object to allow handler objects access it. We name + # it with websocket_ prefix to avoid conflict. + self.websocket_server_options = options + + self._create_sockets() + self.server_bind() + self.server_activate() + + def _create_sockets(self): + self.server_name, self.server_port = self.server_address + self._sockets = [] + if not self.server_name: + # On platforms that doesn't support IPv6, the first bind fails. + # On platforms that supports IPv6 + # - If it binds both IPv4 and IPv6 on call with AF_INET6, the + # first bind succeeds and the second fails (we'll see 'Address + # already in use' error). + # - If it binds only IPv6 on call with AF_INET6, both call are + # expected to succeed to listen both protocol. + addrinfo_array = [ + (socket.AF_INET6, socket.SOCK_STREAM, '', '', ''), + (socket.AF_INET, socket.SOCK_STREAM, '', '', '')] + else: + addrinfo_array = socket.getaddrinfo(self.server_name, + self.server_port, + socket.AF_UNSPEC, + socket.SOCK_STREAM, + socket.IPPROTO_TCP) + for addrinfo in addrinfo_array: + family, socktype, proto, canonname, sockaddr = addrinfo + try: + socket_ = socket.socket(family, socktype) + except Exception, e: + self._logger.info('Skip by failure: %r', e) + continue + if self.websocket_server_options.use_tls: + if _HAS_SSL: + if self.websocket_server_options.tls_client_auth: + client_cert_ = ssl.CERT_REQUIRED + else: + client_cert_ = ssl.CERT_NONE + socket_ = ssl.wrap_socket(socket_, + keyfile=self.websocket_server_options.private_key, + certfile=self.websocket_server_options.certificate, + ssl_version=ssl.PROTOCOL_SSLv23, + ca_certs=self.websocket_server_options.tls_client_ca, + cert_reqs=client_cert_) + if _HAS_OPEN_SSL: + ctx = OpenSSL.SSL.Context(OpenSSL.SSL.SSLv23_METHOD) + ctx.use_privatekey_file( + self.websocket_server_options.private_key) + ctx.use_certificate_file( + self.websocket_server_options.certificate) + socket_ = OpenSSL.SSL.Connection(ctx, socket_) + self._sockets.append((socket_, addrinfo)) + + def server_bind(self): + """Override SocketServer.TCPServer.server_bind to enable multiple + sockets bind. + """ + + failed_sockets = [] + + for socketinfo in self._sockets: + socket_, addrinfo = socketinfo + if self.allow_reuse_address: + socket_.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + try: + socket_.bind(self.server_address) + except Exception, e: + self._logger.info('Skip by failure: %r', e) + socket_.close() + failed_sockets.append(socketinfo) + if self.server_address[1] == 0: + # The operating system assigns the actual port number for port + # number 0. This case, the second and later sockets should use + # the same port number. Also self.server_port is rewritten + # because it is exported, and will be used by external code. + self.server_address = ( + self.server_name, socket_.getsockname()[1]) + self.server_port = self.server_address[1] + self._logger.info('Port %r is assigned', self.server_port) + + for socketinfo in failed_sockets: + self._sockets.remove(socketinfo) + + def server_activate(self): + """Override SocketServer.TCPServer.server_activate to enable multiple + sockets listen. + """ + + failed_sockets = [] + + for socketinfo in self._sockets: + socket_, addrinfo = socketinfo + self._logger.debug('Listen on: %r', addrinfo) + try: + socket_.listen(self.request_queue_size) + except Exception, e: + self._logger.info('Skip by failure: %r', e) + socket_.close() + failed_sockets.append(socketinfo) + + for socketinfo in failed_sockets: + self._sockets.remove(socketinfo) + + if len(self._sockets) == 0: + self._logger.critical( + 'No sockets activated. Use info log level to see the reason.') + + def server_close(self): + """Override SocketServer.TCPServer.server_close to enable multiple + sockets close. + """ + + for socketinfo in self._sockets: + socket_, addrinfo = socketinfo + self._logger.info('Close on: %r', addrinfo) + socket_.close() + + def fileno(self): + """Override SocketServer.TCPServer.fileno.""" + + self._logger.critical('Not supported: fileno') + return self._sockets[0][0].fileno() + + def handle_error(self, rquest, client_address): + """Override SocketServer.handle_error.""" + + self._logger.error( + 'Exception in processing request from: %r\n%s', + client_address, + util.get_stack_trace()) + # Note: client_address is a tuple. + + def get_request(self): + """Override TCPServer.get_request to wrap OpenSSL.SSL.Connection + object with _StandaloneSSLConnection to provide makefile method. We + cannot substitute OpenSSL.SSL.Connection.makefile since it's readonly + attribute. + """ + + accepted_socket, client_address = self.socket.accept() + if self.websocket_server_options.use_tls and _HAS_OPEN_SSL: + accepted_socket = _StandaloneSSLConnection(accepted_socket) + return accepted_socket, client_address + + def serve_forever(self, poll_interval=0.5): + """Override SocketServer.BaseServer.serve_forever.""" + + self.__ws_serving = True + self.__ws_is_shut_down.clear() + handle_request = self.handle_request + if hasattr(self, '_handle_request_noblock'): + handle_request = self._handle_request_noblock + else: + self._logger.warning('Fallback to blocking request handler') + try: + while self.__ws_serving: + r, w, e = select.select( + [socket_[0] for socket_ in self._sockets], + [], [], poll_interval) + for socket_ in r: + self.socket = socket_ + handle_request() + self.socket = None + finally: + self.__ws_is_shut_down.set() + + def shutdown(self): + """Override SocketServer.BaseServer.shutdown.""" + + self.__ws_serving = False + self.__ws_is_shut_down.wait() + + +class WebSocketRequestHandler(CGIHTTPServer.CGIHTTPRequestHandler): + """CGIHTTPRequestHandler specialized for WebSocket.""" + + # Use httplib.HTTPMessage instead of mimetools.Message. + MessageClass = httplib.HTTPMessage + + def setup(self): + """Override SocketServer.StreamRequestHandler.setup to wrap rfile + with MemorizingFile. + + This method will be called by BaseRequestHandler's constructor + before calling BaseHTTPRequestHandler.handle. + BaseHTTPRequestHandler.handle will call + BaseHTTPRequestHandler.handle_one_request and it will call + WebSocketRequestHandler.parse_request. + """ + + # Call superclass's setup to prepare rfile, wfile, etc. See setup + # definition on the root class SocketServer.StreamRequestHandler to + # understand what this does. + CGIHTTPServer.CGIHTTPRequestHandler.setup(self) + + self.rfile = memorizingfile.MemorizingFile( + self.rfile, + max_memorized_lines=_MAX_MEMORIZED_LINES) + + def __init__(self, request, client_address, server): + self._logger = util.get_class_logger(self) + + self._options = server.websocket_server_options + + # Overrides CGIHTTPServerRequestHandler.cgi_directories. + self.cgi_directories = self._options.cgi_directories + # Replace CGIHTTPRequestHandler.is_executable method. + if self._options.is_executable_method is not None: + self.is_executable = self._options.is_executable_method + + # This actually calls BaseRequestHandler.__init__. + CGIHTTPServer.CGIHTTPRequestHandler.__init__( + self, request, client_address, server) + + def parse_request(self): + """Override BaseHTTPServer.BaseHTTPRequestHandler.parse_request. + + Return True to continue processing for HTTP(S), False otherwise. + + See BaseHTTPRequestHandler.handle_one_request method which calls + this method to understand how the return value will be handled. + """ + + # We hook parse_request method, but also call the original + # CGIHTTPRequestHandler.parse_request since when we return False, + # CGIHTTPRequestHandler.handle_one_request continues processing and + # it needs variables set by CGIHTTPRequestHandler.parse_request. + # + # Variables set by this method will be also used by WebSocket request + # handling (self.path, self.command, self.requestline, etc. See also + # how _StandaloneRequest's members are implemented using these + # attributes). + if not CGIHTTPServer.CGIHTTPRequestHandler.parse_request(self): + return False + + if self._options.use_basic_auth: + auth = self.headers.getheader('Authorization') + if auth != self._options.basic_auth_credential: + self.send_response(401) + self.send_header('WWW-Authenticate', + 'Basic realm="Pywebsocket"') + self.end_headers() + self._logger.info('Request basic authentication') + return True + + host, port, resource = http_header_util.parse_uri(self.path) + if resource is None: + self._logger.info('Invalid URI: %r', self.path) + self._logger.info('Fallback to CGIHTTPRequestHandler') + return True + server_options = self.server.websocket_server_options + if host is not None: + validation_host = server_options.validation_host + if validation_host is not None and host != validation_host: + self._logger.info('Invalid host: %r (expected: %r)', + host, + validation_host) + self._logger.info('Fallback to CGIHTTPRequestHandler') + return True + if port is not None: + validation_port = server_options.validation_port + if validation_port is not None and port != validation_port: + self._logger.info('Invalid port: %r (expected: %r)', + port, + validation_port) + self._logger.info('Fallback to CGIHTTPRequestHandler') + return True + self.path = resource + + request = _StandaloneRequest(self, self._options.use_tls) + + try: + # Fallback to default http handler for request paths for which + # we don't have request handlers. + if not self._options.dispatcher.get_handler_suite(self.path): + self._logger.info('No handler for resource: %r', + self.path) + self._logger.info('Fallback to CGIHTTPRequestHandler') + return True + except dispatch.DispatchException, e: + self._logger.info('%s', e) + self.send_error(e.status) + return False + + # If any Exceptions without except clause setup (including + # DispatchException) is raised below this point, it will be caught + # and logged by WebSocketServer. + + try: + try: + handshake.do_handshake( + request, + self._options.dispatcher, + allowDraft75=self._options.allow_draft75, + strict=self._options.strict) + except handshake.VersionException, e: + self._logger.info('%s', e) + self.send_response(common.HTTP_STATUS_BAD_REQUEST) + self.send_header(common.SEC_WEBSOCKET_VERSION_HEADER, + e.supported_versions) + self.end_headers() + return False + except handshake.HandshakeException, e: + # Handshake for ws(s) failed. + self._logger.info('%s', e) + self.send_error(e.status) + return False + + request._dispatcher = self._options.dispatcher + self._options.dispatcher.transfer_data(request) + except handshake.AbortedByUserException, e: + self._logger.info('%s', e) + return False + + def log_request(self, code='-', size='-'): + """Override BaseHTTPServer.log_request.""" + + self._logger.info('"%s" %s %s', + self.requestline, str(code), str(size)) + + def log_error(self, *args): + """Override BaseHTTPServer.log_error.""" + + # Despite the name, this method is for warnings than for errors. + # For example, HTTP status code is logged by this method. + self._logger.warning('%s - %s', + self.address_string(), + args[0] % args[1:]) + + def is_cgi(self): + """Test whether self.path corresponds to a CGI script. + + Add extra check that self.path doesn't contains .. + Also check if the file is a executable file or not. + If the file is not executable, it is handled as static file or dir + rather than a CGI script. + """ + + if CGIHTTPServer.CGIHTTPRequestHandler.is_cgi(self): + if '..' in self.path: + return False + # strip query parameter from request path + resource_name = self.path.split('?', 2)[0] + # convert resource_name into real path name in filesystem. + scriptfile = self.translate_path(resource_name) + if not os.path.isfile(scriptfile): + return False + if not self.is_executable(scriptfile): + return False + return True + return False + + +def _get_logger_from_class(c): + return logging.getLogger('%s.%s' % (c.__module__, c.__name__)) + + +def _configure_logging(options): + logging.addLevelName(common.LOGLEVEL_FINE, 'FINE') + + logger = logging.getLogger() + logger.setLevel(logging.getLevelName(options.log_level.upper())) + if options.log_file: + handler = logging.handlers.RotatingFileHandler( + options.log_file, 'a', options.log_max, options.log_count) + else: + handler = logging.StreamHandler() + formatter = logging.Formatter( + '[%(asctime)s] [%(levelname)s] %(name)s: %(message)s') + handler.setFormatter(formatter) + logger.addHandler(handler) + + deflate_log_level_name = logging.getLevelName( + options.deflate_log_level.upper()) + _get_logger_from_class(util._Deflater).setLevel( + deflate_log_level_name) + _get_logger_from_class(util._Inflater).setLevel( + deflate_log_level_name) + +class DefaultOptions: + server_host = '' + port = common.DEFAULT_WEB_SOCKET_PORT + use_tls = False + private_key = '' + certificate = '' + ca_certificate = '' + dispatcher = None + request_queue_size = _DEFAULT_REQUEST_QUEUE_SIZE + use_basic_auth = False + + allow_draft75 = False + strict = False + validation_host = None + validation_port = None + cgi_directories = '' + is_executable_method = False + +def _main(args=None): + """You can call this function from your own program, but please note that + this function has some side-effects that might affect your program. For + example, util.wrap_popen3_for_win use in this method replaces implementation + of os.popen3. + """ + + options, args = _parse_args_and_config(args=args) + + os.chdir(options.document_root) + + _configure_logging(options) + + # TODO(tyoshino): Clean up initialization of CGI related values. Move some + # of code here to WebSocketRequestHandler class if it's better. + options.cgi_directories = [] + options.is_executable_method = None + if options.cgi_paths: + options.cgi_directories = options.cgi_paths.split(',') + if sys.platform in ('cygwin', 'win32'): + cygwin_path = None + # For Win32 Python, it is expected that CYGWIN_PATH + # is set to a directory of cygwin binaries. + # For example, websocket_server.py in Chromium sets CYGWIN_PATH to + # full path of third_party/cygwin/bin. + if 'CYGWIN_PATH' in os.environ: + cygwin_path = os.environ['CYGWIN_PATH'] + util.wrap_popen3_for_win(cygwin_path) + + def __check_script(scriptpath): + return util.get_script_interp(scriptpath, cygwin_path) + + options.is_executable_method = __check_script + + if options.use_tls: + if not (_HAS_SSL or _HAS_OPEN_SSL): + logging.critical('TLS support requires ssl or pyOpenSSL module.') + sys.exit(1) + if not options.private_key or not options.certificate: + logging.critical( + 'To use TLS, specify private_key and certificate.') + sys.exit(1) + + if options.tls_client_auth: + if not options.use_tls: + logging.critical('TLS must be enabled for client authentication.') + sys.exit(1) + if not _HAS_SSL: + logging.critical('Client authentication requires ssl module.') + + if not options.scan_dir: + options.scan_dir = options.websock_handlers + + if options.use_basic_auth: + options.basic_auth_credential = 'Basic ' + base64.b64encode( + options.basic_auth_credential) + + try: + if options.thread_monitor_interval_in_sec > 0: + # Run a thread monitor to show the status of server threads for + # debugging. + ThreadMonitor(options.thread_monitor_interval_in_sec).start() + + server = WebSocketServer(options) + server.serve_forever() + except Exception, e: + logging.critical('mod_pywebsocket: %s' % e) + logging.critical('mod_pywebsocket: %s' % util.get_stack_trace()) + sys.exit(1) + + +if __name__ == '__main__': + _main(sys.argv[1:]) + + +# vi:sts=4 sw=4 et diff --git a/module/remote/socketbackend/__init__.py b/module/remote/wsbackend/__init__.py index de6d13128..de6d13128 100644 --- a/module/remote/socketbackend/__init__.py +++ b/module/remote/wsbackend/__init__.py |