#!/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 getServerVersion()' print ' ServerStatus statusServer()' print ' void pauseServer()' print ' void unpauseServer()' print ' bool togglePause()' print ' ByteCount freeSpace()' print ' void kill()' print ' void restart()' print ' getLog(i32 offset)' print ' bool isTimeDownload()' print ' bool isTimeReconnect()' print ' bool toggleReconnect()' print ' void scanDownloadFolder()' print ' getProgressInfo()' print ' string getConfigValue(string section, string option)' print ' void setConfigValue(string section, string option, string value)' print ' getConfig()' print ' getPluginConfig()' print ' ConfigSection configureSection(string section)' print ' void setConfigHandler(PluginName plugin, InteractionID iid, ValueString value)' 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 ' generatePackages(LinkList links)' print ' generateAndAddPackages(LinkList links, bool paused)' print ' autoAddLinks(LinkList links)' print ' PackageID createPackage(string name, string folder, PackageID root, string password, string site, string comment, bool paused)' print ' PackageID addPackage(string name, LinkList links, string password)' print ' PackageID addPackageP(string name, LinkList links, string password, bool paused)' print ' PackageID addPackageChild(string name, LinkList links, string password, PackageID root, bool paused)' print ' PackageID uploadContainer(string filename, string data)' print ' void addLinks(PackageID pid, LinkList links)' print ' void deleteFiles( fids)' print ' void deletePackages( pids)' print ' getCollector()' print ' void addToCollector(LinkList links)' print ' PackageID addFromCollector(string name, bool paused)' print ' void renameCollPack(string name, string new_name)' print ' void deleteCollPack(string name)' print ' void deleteCollLink(string url)' print ' PackageView getAllFiles()' print ' PackageView getAllUnfinishedFiles()' print ' PackageView getFileTree(PackageID pid, bool full)' print ' PackageView getUnfinishedFileTree(PackageID pid, bool full)' print ' PackageView getPackageContent(PackageID pid)' print ' PackageInfo getPackageInfo(PackageID pid)' print ' FileInfo getFileInfo(FileID fid)' print ' findFiles(string pattern)' print ' void restartPackage(PackageID pid)' print ' void restartFile(FileID fid)' print ' void recheckPackage(PackageID pid)' print ' void stopDownloads( fids)' print ' void stopAllDownloads()' print ' void restartFailed()' print ' void setFilePaused(FileID fid, bool paused)' print ' void setPackagePaused(PackageID pid, bool paused)' print ' bool setPackageFolder(PackageID pid, string path)' print ' void setPackageData(PackageID pid, data)' print ' bool movePackage(PackageID pid, PackageID root)' print ' bool moveFiles( fids, PackageID pid)' print ' void orderPackage( pids, i16 position)' print ' void orderFiles( fids, PackageID pid, i16 position)' print ' bool isInteractionWaiting(i16 mode)' print ' InteractionTask getInteractionTask(i16 mode)' print ' void setInteractionResult(InteractionID iid, ValueString result)' print ' string generateDownloadLink(FileID fid, i16 timeout)' print ' getAddonHandler()' print ' void callAddonHandler(PluginName plugin, string func, PackageID pid_or_fid)' 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(PluginName plugin, string func, string arguments)' print ' getAllInfo()' print ' getInfoByPlugin(PluginName plugin)' 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 == 'getServerVersion': if len(args) != 0: print 'getServerVersion requires 0 args' sys.exit(1) pp.pprint(client.getServerVersion()) elif cmd == 'statusServer': if len(args) != 0: print 'statusServer requires 0 args' sys.exit(1) pp.pprint(client.statusServer()) 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 == 'freeSpace': if len(args) != 0: print 'freeSpace requires 0 args' sys.exit(1) pp.pprint(client.freeSpace()) 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 == 'scanDownloadFolder': if len(args) != 0: print 'scanDownloadFolder requires 0 args' sys.exit(1) pp.pprint(client.scanDownloadFolder()) elif cmd == 'getProgressInfo': if len(args) != 0: print 'getProgressInfo requires 0 args' sys.exit(1) pp.pprint(client.getProgressInfo()) elif cmd == 'getConfigValue': if len(args) != 2: print 'getConfigValue requires 2 args' sys.exit(1) pp.pprint(client.getConfigValue(args[0],args[1],)) elif cmd == 'setConfigValue': if len(args) != 3: print 'setConfigValue requires 3 args' sys.exit(1) pp.pprint(client.setConfigValue(args[0],args[1],args[2],)) 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 == 'configureSection': if len(args) != 1: print 'configureSection requires 1 args' sys.exit(1) pp.pprint(client.configureSection(args[0],)) elif cmd == 'setConfigHandler': if len(args) != 3: print 'setConfigHandler requires 3 args' sys.exit(1) pp.pprint(client.setConfigHandler(eval(args[0]),eval(args[1]),eval(args[2]),)) 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 == 'generatePackages': if len(args) != 1: print 'generatePackages requires 1 args' sys.exit(1) pp.pprint(client.generatePackages(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 == 'autoAddLinks': if len(args) != 1: print 'autoAddLinks requires 1 args' sys.exit(1) pp.pprint(client.autoAddLinks(eval(args[0]),)) elif cmd == 'createPackage': if len(args) != 7: print 'createPackage requires 7 args' sys.exit(1) pp.pprint(client.createPackage(args[0],args[1],eval(args[2]),args[3],args[4],args[5],eval(args[6]),)) elif cmd == 'addPackage': if len(args) != 3: print 'addPackage requires 3 args' sys.exit(1) pp.pprint(client.addPackage(args[0],eval(args[1]),args[2],)) elif cmd == 'addPackageP': if len(args) != 4: print 'addPackageP requires 4 args' sys.exit(1) pp.pprint(client.addPackageP(args[0],eval(args[1]),args[2],eval(args[3]),)) elif cmd == 'addPackageChild': if len(args) != 5: print 'addPackageChild requires 5 args' sys.exit(1) pp.pprint(client.addPackageChild(args[0],eval(args[1]),args[2],eval(args[3]),eval(args[4]),)) 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 == 'addLinks': if len(args) != 2: print 'addLinks requires 2 args' sys.exit(1) pp.pprint(client.addLinks(eval(args[0]),eval(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 == 'getCollector': if len(args) != 0: print 'getCollector requires 0 args' sys.exit(1) pp.pprint(client.getCollector()) elif cmd == 'addToCollector': if len(args) != 1: print 'addToCollector requires 1 args' sys.exit(1) pp.pprint(client.addToCollector(eval(args[0]),)) elif cmd == 'addFromCollector': if len(args) != 2: print 'addFromCollector requires 2 args' sys.exit(1) pp.pprint(client.addFromCollector(args[0],eval(args[1]),)) elif cmd == 'renameCollPack': if len(args) != 2: print 'renameCollPack requires 2 args' sys.exit(1) pp.pprint(client.renameCollPack(args[0],args[1],)) elif cmd == 'deleteCollPack': if len(args) != 1: print 'deleteCollPack requires 1 args' sys.exit(1) pp.pprint(client.deleteCollPack(args[0],)) elif cmd == 'deleteCollLink': if len(args) != 1: print 'deleteCollLink requires 1 args' sys.exit(1) pp.pprint(client.deleteCollLink(args[0],)) elif cmd == 'getAllFiles': if len(args) != 0: print 'getAllFiles requires 0 args' sys.exit(1) pp.pprint(client.getAllFiles()) elif cmd == 'getAllUnfinishedFiles': if len(args) != 0: print 'getAllUnfinishedFiles requires 0 args' sys.exit(1) pp.pprint(client.getAllUnfinishedFiles()) elif cmd == 'getFileTree': if len(args) != 2: print 'getFileTree requires 2 args' sys.exit(1) pp.pprint(client.getFileTree(eval(args[0]),eval(args[1]),)) elif cmd == 'getUnfinishedFileTree': if len(args) != 2: print 'getUnfinishedFileTree requires 2 args' sys.exit(1) pp.pprint(client.getUnfinishedFileTree(eval(args[0]),eval(args[1]),)) elif cmd == 'getPackageContent': if len(args) != 1: print 'getPackageContent requires 1 args' sys.exit(1) pp.pprint(client.getPackageContent(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 == 'getFileInfo': if len(args) != 1: print 'getFileInfo requires 1 args' sys.exit(1) pp.pprint(client.getFileInfo(eval(args[0]),)) elif cmd == 'findFiles': if len(args) != 1: print 'findFiles requires 1 args' sys.exit(1) pp.pprint(client.findFiles(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 == 'stopDownloads': if len(args) != 1: print 'stopDownloads requires 1 args' sys.exit(1) pp.pprint(client.stopDownloads(eval(args[0]),)) elif cmd == 'stopAllDownloads': if len(args) != 0: print 'stopAllDownloads requires 0 args' sys.exit(1) pp.pprint(client.stopAllDownloads()) elif cmd == 'restartFailed': if len(args) != 0: print 'restartFailed requires 0 args' sys.exit(1) pp.pprint(client.restartFailed()) elif cmd == 'setFilePaused': if len(args) != 2: print 'setFilePaused requires 2 args' sys.exit(1) pp.pprint(client.setFilePaused(eval(args[0]),eval(args[1]),)) elif cmd == 'setPackagePaused': if len(args) != 2: print 'setPackagePaused requires 2 args' sys.exit(1) pp.pprint(client.setPackagePaused(eval(args[0]),eval(args[1]),)) elif cmd == 'setPackageFolder': if len(args) != 2: print 'setPackageFolder requires 2 args' sys.exit(1) pp.pprint(client.setPackageFolder(eval(args[0]),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 == '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 == 'orderFiles': if len(args) != 3: print 'orderFiles requires 3 args' sys.exit(1) pp.pprint(client.orderFiles(eval(args[0]),eval(args[1]),eval(args[2]),)) elif cmd == 'isInteractionWaiting': if len(args) != 1: print 'isInteractionWaiting requires 1 args' sys.exit(1) pp.pprint(client.isInteractionWaiting(eval(args[0]),)) elif cmd == 'getInteractionTask': if len(args) != 1: print 'getInteractionTask requires 1 args' sys.exit(1) pp.pprint(client.getInteractionTask(eval(args[0]),)) elif cmd == 'setInteractionResult': if len(args) != 2: print 'setInteractionResult requires 2 args' sys.exit(1) pp.pprint(client.setInteractionResult(eval(args[0]),eval(args[1]),)) elif cmd == 'generateDownloadLink': if len(args) != 2: print 'generateDownloadLink requires 2 args' sys.exit(1) pp.pprint(client.generateDownloadLink(eval(args[0]),eval(args[1]),)) elif cmd == 'getAddonHandler': if len(args) != 0: print 'getAddonHandler requires 0 args' sys.exit(1) pp.pprint(client.getAddonHandler()) elif cmd == 'callAddonHandler': if len(args) != 3: print 'callAddonHandler requires 3 args' sys.exit(1) pp.pprint(client.callAddonHandler(eval(args[0]),args[1],eval(args[2]),)) 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) != 3: print 'call requires 3 args' sys.exit(1) pp.pprint(client.call(eval(args[0]),args[1],args[2],)) 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]),)) else: print 'Unrecognized method %s' % cmd sys.exit(1) transport.close()