diff options
-rw-r--r-- | module/Api.py | 72 | ||||
-rw-r--r-- | module/config/ConfigParser.py | 3 | ||||
-rw-r--r-- | module/database/ConfigDatabase.py | 28 | ||||
-rw-r--r-- | module/database/DatabaseBackend.py | 6 | ||||
-rw-r--r-- | module/database/FileDatabase.py | 2 | ||||
-rw-r--r-- | module/remote/socketbackend/ttypes.py | 62 | ||||
-rw-r--r-- | module/remote/thriftbackend/pyload.thrift | 45 | ||||
-rwxr-xr-x | module/remote/thriftbackend/thriftgen/pyload/Pyload-remote | 69 | ||||
-rw-r--r-- | module/remote/thriftbackend/thriftgen/pyload/Pyload.py | 465 | ||||
-rw-r--r-- | module/remote/thriftbackend/thriftgen/pyload/ttypes.py | 63 | ||||
-rw-r--r-- | tests/test_configparser.py | 30 | ||||
-rw-r--r-- | tests/test_filemanager.py | 28 |
12 files changed, 530 insertions, 343 deletions
diff --git a/module/Api.py b/module/Api.py index 4671b9cbd..d530556fa 100644 --- a/module/Api.py +++ b/module/Api.py @@ -123,8 +123,6 @@ class UserApi(object): def user(self): return self._user -# TODO: fix permissions, user context manager - class Api(Iface): """ **pyLoads API** @@ -263,9 +261,6 @@ class Api(Iface): return compare_time(start, end) and self.core.config["reconnect"]["activated"] - def scanDownloadFolder(self): - pass - @RequirePerm(Permission.All) def getProgressInfo(self): """ Status of all currently running tasks @@ -314,43 +309,64 @@ class Api(Iface): def getConfig(self): """Retrieves complete config of core. - :return: list of `ConfigSection` + :return: map of `ConfigHolder` """ - return dict([(section, ConfigSection(section, data.name, data.description, data.long_desc, [ + # TODO + return dict([(section, ConfigHolder(section, data.name, data.description, data.long_desc, [ ConfigItem(option, d.name, d.description, d.type, to_string(d.default), to_string(self.core.config.get(section, option))) for option, d in data.config.iteritems()])) for section, data in self.core.config.getBaseSections()]) - def getPluginConfig(self): - """Retrieves complete config for all plugins. + def getConfigRef(self): + """Config instance, not for RPC""" + return self.core.config + + def getGlobalPlugins(self): + """All global plugins/addons, only admin can use this - :return: list of `ConfigSection` + :return: list of `ConfigInfo` """ - return dict([(section, ConfigSection(section, - data.name, data.description, data.long_desc)) for - section, data in self.core.config.getPluginSections()]) + pass - def configureSection(self, section): - data = self.core.config.config[section] - sec = ConfigSection(section, data.name, data.description, data.long_desc) - sec.items = [ConfigItem(option, d.name, d.description, - d.type, to_string(d.default), to_string(self.core.config.get(section, option))) - for - option, d in data.config.iteritems()] + @UserContext + @RequirePerm(Permission.Plugins) + def getUserPlugins(self): + """List of plugins every user can configure for himself - #TODO: config handler + :return: list of `ConfigInfo` + """ + pass - return sec + @UserContext + @RequirePerm(Permission.Plugins) + def configurePlugin(self, plugin): + """Get complete config options for an plugin + :param plugin: Name of the plugin to configure + :return: :class:`ConfigHolder` + """ - def setConfigHandler(self, plugin, iid, value): pass - def getConfigRef(self): - """Config instance, not for RPC""" - return self.core.config + @UserContext + @RequirePerm(Permission.Plugins) + def saveConfig(self, config): + """Used to save a configuration, core config can only be saved by admins + + :param config: :class:`ConfigHolder + """ + pass + + @UserContext + @RequirePerm(Permission.Plugins) + def deleteConfig(self, config): + pass + + @RequirePerm(Permission.Plugins) + def setConfigHandler(self, plugin, iid, value): + pass ########################## # Download Preparing @@ -475,10 +491,6 @@ class Api(Iface): in self.generatePackages(links).iteritems()] @RequirePerm(Permission.Add) - def autoAddLinks(self, links): - pass - - @RequirePerm(Permission.Add) def createPackage(self, name, folder, root, password="", site="", comment="", paused=False): """Create a new package. diff --git a/module/config/ConfigParser.py b/module/config/ConfigParser.py index 9cc9f1fbe..3cad67bc2 100644 --- a/module/config/ConfigParser.py +++ b/module/config/ConfigParser.py @@ -17,8 +17,7 @@ ConfigData = namedtuple("ConfigData", "name type description default") class ConfigParser: """ - Holds and manages the configuration + meta data. - Actually only the values are read from disk, all meta data has to be provided first via addConfigSection. + Holds and manages the configuration + meta data for core and every user. """ CONFIG = "pyload.conf" diff --git a/module/database/ConfigDatabase.py b/module/database/ConfigDatabase.py new file mode 100644 index 000000000..cc24f6785 --- /dev/null +++ b/module/database/ConfigDatabase.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from module.database import DatabaseMethods, queue, async, inner + +# TODO + +class ConfigMethods(DatabaseMethods): + + @async + def saveConfig(self, plugin, user, config): + pass + + @queue + def loadConfig(self, plugin, user): + pass + + @async + def deleteConfig(self, plugin, user): + pass + + @queue + def loadAllConfigs(self): + pass + + + +ConfigMethods.register()
\ No newline at end of file diff --git a/module/database/DatabaseBackend.py b/module/database/DatabaseBackend.py index 2c494e520..3e6b059c0 100644 --- a/module/database/DatabaseBackend.py +++ b/module/database/DatabaseBackend.py @@ -352,10 +352,10 @@ class DatabaseBackend(Thread): self.c.execute( 'CREATE TABLE IF NOT EXISTS "settings" (' '"plugin" TEXT NOT NULL, ' - '"owner" INTEGER NOT NULL, ' - '"configuration" TEXT NOT NULL, ' + '"user" INTEGER NOT NULL, ' + '"config" TEXT NOT NULL, ' 'FOREIGN KEY(owner) REFERENCES users(uid), ' - 'PRIMARY KEY (plugin, owner) ON CONFLICT REPLACE' + 'PRIMARY KEY (plugin, user) ON CONFLICT REPLACE' ')' ) diff --git a/module/database/FileDatabase.py b/module/database/FileDatabase.py index ab681dc7f..e065b84e2 100644 --- a/module/database/FileDatabase.py +++ b/module/database/FileDatabase.py @@ -75,7 +75,7 @@ class FileMethods(DatabaseMethods): @async def deletePackage(self, pid, owner=None): - # order updated by trigge + # order updated by trigger, as well as links deleted if owner is None: self.c.execute('DELETE FROM packages WHERE pid=?', (pid,)) else: diff --git a/module/remote/socketbackend/ttypes.py b/module/remote/socketbackend/ttypes.py index 569c758fe..fd520f418 100644 --- a/module/remote/socketbackend/ttypes.py +++ b/module/remote/socketbackend/ttypes.py @@ -66,12 +66,12 @@ class PackageStatus: class Permission: Accounts = 16 Add = 1 - Addons = 64 All = 0 Delete = 2 Download = 8 Interaction = 32 Modify = 4 + Plugins = 64 class Role: Admin = 0 @@ -110,29 +110,39 @@ class AddonService(BaseObject): self.arguments = arguments self.media = media -class ConfigItem(BaseObject): - __slots__ = ['name', 'display_name', 'description', 'type', 'default_value', 'value'] - - def __init__(self, name=None, display_name=None, description=None, type=None, default_value=None, value=None): - self.name = name - self.display_name = display_name - self.description = description - self.type = type - self.default_value = default_value - self.value = value +class ConfigHolder(BaseObject): + __slots__ = ['name', 'label', 'description', 'long_description', 'items', 'info', 'handler'] -class ConfigSection(BaseObject): - __slots__ = ['name', 'display_name', 'description', 'long_description', 'items', 'info', 'handler'] - - def __init__(self, name=None, display_name=None, description=None, long_description=None, items=None, info=None, handler=None): + def __init__(self, name=None, label=None, description=None, long_description=None, items=None, info=None, handler=None): self.name = name - self.display_name = display_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', 'saved', 'activated'] + + def __init__(self, name=None, label=None, description=None, saved=None, activated=None): + self.name = name + self.label = label + self.description = description + self.saved = saved + 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'] @@ -341,7 +351,7 @@ class Iface: pass def checkURLs(self, urls): pass - def configureSection(self, section): + def configurePlugin(self, plugin): pass def createPackage(self, name, folder, root, password, site, comment, paused): pass @@ -349,6 +359,8 @@ class Iface: pass def deleteCollPack(self, name): pass + def deleteConfig(self, config): + pass def deleteFiles(self, fids): pass def deletePackages(self, pids): @@ -381,14 +393,14 @@ class Iface: pass def getConfig(self): pass - def getConfigValue(self, section, option): - pass def getEvents(self, uuid): pass def getFileInfo(self, fid): pass def getFileTree(self, pid, full): pass + def getGlobalPlugins(self): + pass def getInfoByPlugin(self, plugin): pass def getInteractionTask(self, mode): @@ -401,8 +413,6 @@ class Iface: pass def getPackageInfo(self, pid): pass - def getPluginConfig(self): - pass def getProgressInfo(self): pass def getServerVersion(self): @@ -411,6 +421,8 @@ class Iface: pass def getUserData(self): pass + def getUserPlugins(self): + pass def hasAddonHandler(self, plugin, func): pass def isInteractionWaiting(self, mode): @@ -453,12 +465,10 @@ class Iface: pass def restartPackage(self, pid): pass - def scanDownloadFolder(self): + def saveConfig(self, config): pass def setConfigHandler(self, plugin, iid, value): pass - def setConfigValue(self, section, option, value): - pass def setFilePaused(self, fid, paused): pass def setInteractionResult(self, iid, result): @@ -483,7 +493,9 @@ class Iface: pass def unpauseServer(self): pass - def updateAccount(self, plugin, account, password, options): + def updateAccount(self, plugin, account, password): + pass + def updateAccountInfo(self, account): pass def updateUserData(self, data): pass diff --git a/module/remote/thriftbackend/pyload.thrift b/module/remote/thriftbackend/pyload.thrift index 23b39fada..fb906e23a 100644 --- a/module/remote/thriftbackend/pyload.thrift +++ b/module/remote/thriftbackend/pyload.thrift @@ -90,7 +90,7 @@ enum Permission { Download = 8, // can download from webinterface Accounts = 16, // can access accounts Interaction = 32, // can interact with plugins - Addons = 64 // user can activate addons + Plugins = 64 // user can configure plugins and activate addons } enum Role { @@ -98,6 +98,8 @@ enum Role { User = 1 } +// TODO: progress vs Download progress ?! + struct ProgressInfo { 1: FileID fid, 2: string name, @@ -217,23 +219,31 @@ struct AddonInfo { struct ConfigItem { 1: string name, - 2: string display_name, + 2: string label, 3: string description, 4: string type, 5: JSONString default_value, 6: JSONString value, } -struct ConfigSection { +struct ConfigHolder { 1: string name, - 2: string display_name, + 2: string label, 3: string description, 4: string long_description, - 5: optional list<ConfigItem> items, + 5: list<ConfigItem> items, 6: optional list<AddonInfo> info, 7: optional list<InteractionTask> handler, // if null plugin is not loaded } +struct ConfigInfo { + 1: string name, + 2: string label, + 3: string description, + 4: bool saved, + 5: bool activated, +} + struct EventInfo { 1: string eventname, 2: list<JSONString> event_args, @@ -250,7 +260,7 @@ struct UserData { 8: i16 dllimit 9: string dlquota, 10: ByteCount hddquota, - 11: UserID user + 11: UserID user, 12: string templateName } @@ -314,17 +324,21 @@ service Pyload { bool isTimeDownload(), bool isTimeReconnect(), bool toggleReconnect(), - void scanDownloadFolder(), + + // TODO + //void scanDownloadFolder(), /////////////////////// // Configuration /////////////////////// - string getConfigValue(1: string section, 2: string option), - void setConfigValue(1: string section, 2: string option, 3: string value), - map<string, ConfigSection> getConfig(), - map<PluginName, ConfigSection> getPluginConfig(), - ConfigSection configureSection(1: string section), + map<string, ConfigHolder> getConfig(), + list<ConfigInfo> getGlobalPlugins(), + list<ConfigInfo> getUserPlugins(), + + ConfigHolder configurePlugin(1: PluginName plugin), + void saveConfig(1: ConfigHolder config), + void deleteConfig(1: ConfigHolder config), void setConfigHandler(1: PluginName plugin, 2: InteractionID iid, 3: JSONString value), /////////////////////// @@ -373,6 +387,8 @@ service Pyload { // Collector /////////////////////// + // TODO: reasonable link collector concept + list<LinkStatus> getCollector(), void addToCollector(1: LinkList links), @@ -462,8 +478,9 @@ service Pyload { /////////////////////// 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), + list<string> getAccountTypes(), + void updateAccount(1: PluginName plugin, 2: string account, 3: string password), + void updateAccountInfo(1: AccountInfo account), void removeAccount(1: PluginName plugin, 2: string account), ///////////////////////// diff --git a/module/remote/thriftbackend/thriftgen/pyload/Pyload-remote b/module/remote/thriftbackend/thriftgen/pyload/Pyload-remote index a84de7978..78d251501 100755 --- a/module/remote/thriftbackend/thriftgen/pyload/Pyload-remote +++ b/module/remote/thriftbackend/thriftgen/pyload/Pyload-remote @@ -35,12 +35,12 @@ if len(sys.argv) <= 1 or sys.argv[1] == '--help': print ' bool isTimeDownload()' print ' bool isTimeReconnect()' print ' bool toggleReconnect()' - print ' void scanDownloadFolder()' - 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 ' getGlobalPlugins()' + print ' getUserPlugins()' + print ' ConfigHolder configurePlugin(PluginName plugin)' + print ' void saveConfig(ConfigHolder config)' + print ' void deleteConfig(ConfigHolder config)' print ' void setConfigHandler(PluginName plugin, InteractionID iid, JSONString value)' print ' checkURLs(LinkList urls)' print ' parseURLs(string html, string url)' @@ -95,7 +95,8 @@ if len(sys.argv) <= 1 or sys.argv[1] == '--help': print ' getEvents(string uuid)' print ' getAccounts(bool refresh)' print ' getAccountTypes()' - print ' void updateAccount(PluginName plugin, string account, string password, options)' + print ' void updateAccount(PluginName plugin, string account, string password)' + print ' void updateAccountInfo(AccountInfo account)' print ' void removeAccount(PluginName plugin, string account)' print ' bool login(string username, string password)' print ' UserData getUserData()' @@ -233,41 +234,41 @@ elif cmd == 'toggleReconnect': sys.exit(1) pp.pprint(client.toggleReconnect()) -elif cmd == 'scanDownloadFolder': +elif cmd == 'getConfig': if len(args) != 0: - print 'scanDownloadFolder requires 0 args' + print 'getConfig requires 0 args' sys.exit(1) - pp.pprint(client.scanDownloadFolder()) + pp.pprint(client.getConfig()) -elif cmd == 'getConfigValue': - if len(args) != 2: - print 'getConfigValue requires 2 args' +elif cmd == 'getGlobalPlugins': + if len(args) != 0: + print 'getGlobalPlugins requires 0 args' sys.exit(1) - pp.pprint(client.getConfigValue(args[0],args[1],)) + pp.pprint(client.getGlobalPlugins()) -elif cmd == 'setConfigValue': - if len(args) != 3: - print 'setConfigValue requires 3 args' +elif cmd == 'getUserPlugins': + if len(args) != 0: + print 'getUserPlugins requires 0 args' sys.exit(1) - pp.pprint(client.setConfigValue(args[0],args[1],args[2],)) + pp.pprint(client.getUserPlugins()) -elif cmd == 'getConfig': - if len(args) != 0: - print 'getConfig requires 0 args' +elif cmd == 'configurePlugin': + if len(args) != 1: + print 'configurePlugin requires 1 args' sys.exit(1) - pp.pprint(client.getConfig()) + pp.pprint(client.configurePlugin(eval(args[0]),)) -elif cmd == 'getPluginConfig': - if len(args) != 0: - print 'getPluginConfig requires 0 args' +elif cmd == 'saveConfig': + if len(args) != 1: + print 'saveConfig requires 1 args' sys.exit(1) - pp.pprint(client.getPluginConfig()) + pp.pprint(client.saveConfig(eval(args[0]),)) -elif cmd == 'configureSection': +elif cmd == 'deleteConfig': if len(args) != 1: - print 'configureSection requires 1 args' + print 'deleteConfig requires 1 args' sys.exit(1) - pp.pprint(client.configureSection(args[0],)) + pp.pprint(client.deleteConfig(eval(args[0]),)) elif cmd == 'setConfigHandler': if len(args) != 3: @@ -594,10 +595,16 @@ elif cmd == 'getAccountTypes': pp.pprint(client.getAccountTypes()) elif cmd == 'updateAccount': - if len(args) != 4: - print 'updateAccount requires 4 args' + if len(args) != 3: + print 'updateAccount requires 3 args' + sys.exit(1) + pp.pprint(client.updateAccount(eval(args[0]),args[1],args[2],)) + +elif cmd == 'updateAccountInfo': + if len(args) != 1: + print 'updateAccountInfo requires 1 args' sys.exit(1) - pp.pprint(client.updateAccount(eval(args[0]),args[1],args[2],eval(args[3]),)) + pp.pprint(client.updateAccountInfo(eval(args[0]),)) elif cmd == 'removeAccount': if len(args) != 2: diff --git a/module/remote/thriftbackend/thriftgen/pyload/Pyload.py b/module/remote/thriftbackend/thriftgen/pyload/Pyload.py index c807d3d9e..4134a4d3e 100644 --- a/module/remote/thriftbackend/thriftgen/pyload/Pyload.py +++ b/module/remote/thriftbackend/thriftgen/pyload/Pyload.py @@ -53,36 +53,33 @@ class Iface(object): def toggleReconnect(self, ): pass - def scanDownloadFolder(self, ): + def getConfig(self, ): + pass + + def getGlobalPlugins(self, ): pass - def getConfigValue(self, section, option): + def getUserPlugins(self, ): + pass + + def configurePlugin(self, plugin): """ Parameters: - - section - - option + - plugin """ pass - def setConfigValue(self, section, option, value): + def saveConfig(self, config): """ Parameters: - - section - - option - - value + - config """ pass - def getConfig(self, ): - pass - - def getPluginConfig(self, ): - pass - - def configureSection(self, section): + def deleteConfig(self, config): """ Parameters: - - section + - config """ pass @@ -472,13 +469,19 @@ class Iface(object): def getAccountTypes(self, ): pass - def updateAccount(self, plugin, account, password, options): + def updateAccount(self, plugin, account, password): """ Parameters: - plugin - account - password - - options + """ + pass + + def updateAccountInfo(self, account): + """ + Parameters: + - account """ pass @@ -879,172 +882,166 @@ class Client(Iface): return result.success raise TApplicationException(TApplicationException.MISSING_RESULT, "toggleReconnect failed: unknown result"); - def scanDownloadFolder(self, ): - self.send_scanDownloadFolder() - self.recv_scanDownloadFolder() + def getConfig(self, ): + self.send_getConfig() + return self.recv_getConfig() - def send_scanDownloadFolder(self, ): - self._oprot.writeMessageBegin('scanDownloadFolder', TMessageType.CALL, self._seqid) - args = scanDownloadFolder_args() + 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_scanDownloadFolder(self, ): + 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 = scanDownloadFolder_result() + result = getConfig_result() result.read(self._iprot) self._iprot.readMessageEnd() - return + if result.success is not None: + return result.success + raise TApplicationException(TApplicationException.MISSING_RESULT, "getConfig failed: unknown result"); - def getConfigValue(self, section, option): - """ - Parameters: - - section - - option - """ - self.send_getConfigValue(section, option) - return self.recv_getConfigValue() + def getGlobalPlugins(self, ): + self.send_getGlobalPlugins() + return self.recv_getGlobalPlugins() - def send_getConfigValue(self, section, option): - self._oprot.writeMessageBegin('getConfigValue', TMessageType.CALL, self._seqid) - args = getConfigValue_args() - args.section = section - args.option = option + def send_getGlobalPlugins(self, ): + self._oprot.writeMessageBegin('getGlobalPlugins', TMessageType.CALL, self._seqid) + args = getGlobalPlugins_args() args.write(self._oprot) self._oprot.writeMessageEnd() self._oprot.trans.flush() - def recv_getConfigValue(self, ): + def recv_getGlobalPlugins(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 = getGlobalPlugins_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"); + raise TApplicationException(TApplicationException.MISSING_RESULT, "getGlobalPlugins failed: unknown result"); - def setConfigValue(self, section, option, value): - """ - Parameters: - - section - - option - - value - """ - self.send_setConfigValue(section, option, value) - self.recv_setConfigValue() + def getUserPlugins(self, ): + self.send_getUserPlugins() + return self.recv_getUserPlugins() - def send_setConfigValue(self, section, option, value): - self._oprot.writeMessageBegin('setConfigValue', TMessageType.CALL, self._seqid) - args = setConfigValue_args() - args.section = section - args.option = option - args.value = value + def send_getUserPlugins(self, ): + self._oprot.writeMessageBegin('getUserPlugins', TMessageType.CALL, self._seqid) + args = getUserPlugins_args() args.write(self._oprot) self._oprot.writeMessageEnd() self._oprot.trans.flush() - def recv_setConfigValue(self, ): + def recv_getUserPlugins(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 = getUserPlugins_result() result.read(self._iprot) self._iprot.readMessageEnd() - return + if result.success is not None: + return result.success + raise TApplicationException(TApplicationException.MISSING_RESULT, "getUserPlugins failed: unknown result"); - def getConfig(self, ): - self.send_getConfig() - return self.recv_getConfig() + def configurePlugin(self, plugin): + """ + Parameters: + - plugin + """ + self.send_configurePlugin(plugin) + return self.recv_configurePlugin() - def send_getConfig(self, ): - self._oprot.writeMessageBegin('getConfig', TMessageType.CALL, self._seqid) - args = getConfig_args() + def send_configurePlugin(self, plugin): + self._oprot.writeMessageBegin('configurePlugin', TMessageType.CALL, self._seqid) + args = configurePlugin_args() + args.plugin = plugin args.write(self._oprot) self._oprot.writeMessageEnd() self._oprot.trans.flush() - def recv_getConfig(self, ): + def recv_configurePlugin(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 = configurePlugin_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"); + raise TApplicationException(TApplicationException.MISSING_RESULT, "configurePlugin failed: unknown result"); - def getPluginConfig(self, ): - self.send_getPluginConfig() - return self.recv_getPluginConfig() + def saveConfig(self, config): + """ + Parameters: + - config + """ + self.send_saveConfig(config) + self.recv_saveConfig() - def send_getPluginConfig(self, ): - self._oprot.writeMessageBegin('getPluginConfig', TMessageType.CALL, self._seqid) - args = getPluginConfig_args() + def send_saveConfig(self, config): + self._oprot.writeMessageBegin('saveConfig', TMessageType.CALL, self._seqid) + args = saveConfig_args() + args.config = config args.write(self._oprot) self._oprot.writeMessageEnd() self._oprot.trans.flush() - def recv_getPluginConfig(self, ): + def recv_saveConfig(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 = saveConfig_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"); + return - def configureSection(self, section): + def deleteConfig(self, config): """ Parameters: - - section + - config """ - self.send_configureSection(section) - return self.recv_configureSection() + self.send_deleteConfig(config) + self.recv_deleteConfig() - def send_configureSection(self, section): - self._oprot.writeMessageBegin('configureSection', TMessageType.CALL, self._seqid) - args = configureSection_args() - args.section = section + def send_deleteConfig(self, config): + self._oprot.writeMessageBegin('deleteConfig', TMessageType.CALL, self._seqid) + args = deleteConfig_args() + args.config = config args.write(self._oprot) self._oprot.writeMessageEnd() self._oprot.trans.flush() - def recv_configureSection(self, ): + def recv_deleteConfig(self, ): (fname, mtype, rseqid) = self._iprot.readMessageBegin() if mtype == TMessageType.EXCEPTION: x = TApplicationException() x.read(self._iprot) self._iprot.readMessageEnd() raise x - result = configureSection_result() + result = deleteConfig_result() result.read(self._iprot) self._iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "configureSection failed: unknown result"); + return def setConfigHandler(self, plugin, iid, value): """ @@ -2684,24 +2681,22 @@ class Client(Iface): return result.success raise TApplicationException(TApplicationException.MISSING_RESULT, "getAccountTypes failed: unknown result"); - def updateAccount(self, plugin, account, password, options): + def updateAccount(self, plugin, account, password): """ Parameters: - plugin - account - password - - options """ - self.send_updateAccount(plugin, account, password, options) + self.send_updateAccount(plugin, account, password) self.recv_updateAccount() - def send_updateAccount(self, plugin, account, password, options): + def send_updateAccount(self, plugin, account, password): 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() @@ -2718,6 +2713,34 @@ class Client(Iface): self._iprot.readMessageEnd() return + def updateAccountInfo(self, account): + """ + Parameters: + - account + """ + self.send_updateAccountInfo(account) + self.recv_updateAccountInfo() + + def send_updateAccountInfo(self, account): + self._oprot.writeMessageBegin('updateAccountInfo', TMessageType.CALL, self._seqid) + args = updateAccountInfo_args() + args.account = account + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_updateAccountInfo(self, ): + (fname, mtype, rseqid) = self._iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(self._iprot) + self._iprot.readMessageEnd() + raise x + result = updateAccountInfo_result() + result.read(self._iprot) + self._iprot.readMessageEnd() + return + def removeAccount(self, plugin, account): """ Parameters: @@ -3153,12 +3176,12 @@ class Processor(Iface, TProcessor): self._processMap["isTimeDownload"] = Processor.process_isTimeDownload self._processMap["isTimeReconnect"] = Processor.process_isTimeReconnect self._processMap["toggleReconnect"] = Processor.process_toggleReconnect - self._processMap["scanDownloadFolder"] = Processor.process_scanDownloadFolder - 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["configureSection"] = Processor.process_configureSection + self._processMap["getGlobalPlugins"] = Processor.process_getGlobalPlugins + self._processMap["getUserPlugins"] = Processor.process_getUserPlugins + self._processMap["configurePlugin"] = Processor.process_configurePlugin + self._processMap["saveConfig"] = Processor.process_saveConfig + self._processMap["deleteConfig"] = Processor.process_deleteConfig self._processMap["setConfigHandler"] = Processor.process_setConfigHandler self._processMap["checkURLs"] = Processor.process_checkURLs self._processMap["parseURLs"] = Processor.process_parseURLs @@ -3214,6 +3237,7 @@ class Processor(Iface, TProcessor): self._processMap["getAccounts"] = Processor.process_getAccounts self._processMap["getAccountTypes"] = Processor.process_getAccountTypes self._processMap["updateAccount"] = Processor.process_updateAccount + self._processMap["updateAccountInfo"] = Processor.process_updateAccountInfo self._processMap["removeAccount"] = Processor.process_removeAccount self._processMap["login"] = Processor.process_login self._processMap["getUserData"] = Processor.process_getUserData @@ -3376,68 +3400,68 @@ class Processor(Iface, TProcessor): oprot.writeMessageEnd() oprot.trans.flush() - def process_scanDownloadFolder(self, seqid, iprot, oprot): - args = scanDownloadFolder_args() + def process_getConfig(self, seqid, iprot, oprot): + args = getConfig_args() args.read(iprot) iprot.readMessageEnd() - result = scanDownloadFolder_result() - self._handler.scanDownloadFolder() - oprot.writeMessageBegin("scanDownloadFolder", TMessageType.REPLY, seqid) + result = getConfig_result() + result.success = self._handler.getConfig() + oprot.writeMessageBegin("getConfig", TMessageType.REPLY, seqid) result.write(oprot) oprot.writeMessageEnd() oprot.trans.flush() - def process_getConfigValue(self, seqid, iprot, oprot): - args = getConfigValue_args() + def process_getGlobalPlugins(self, seqid, iprot, oprot): + args = getGlobalPlugins_args() args.read(iprot) iprot.readMessageEnd() - result = getConfigValue_result() - result.success = self._handler.getConfigValue(args.section, args.option) - oprot.writeMessageBegin("getConfigValue", TMessageType.REPLY, seqid) + result = getGlobalPlugins_result() + result.success = self._handler.getGlobalPlugins() + oprot.writeMessageBegin("getGlobalPlugins", TMessageType.REPLY, seqid) result.write(oprot) oprot.writeMessageEnd() oprot.trans.flush() - def process_setConfigValue(self, seqid, iprot, oprot): - args = setConfigValue_args() + def process_getUserPlugins(self, seqid, iprot, oprot): + args = getUserPlugins_args() args.read(iprot) iprot.readMessageEnd() - result = setConfigValue_result() - self._handler.setConfigValue(args.section, args.option, args.value) - oprot.writeMessageBegin("setConfigValue", TMessageType.REPLY, seqid) + result = getUserPlugins_result() + result.success = self._handler.getUserPlugins() + oprot.writeMessageBegin("getUserPlugins", TMessageType.REPLY, seqid) result.write(oprot) oprot.writeMessageEnd() oprot.trans.flush() - def process_getConfig(self, seqid, iprot, oprot): - args = getConfig_args() + def process_configurePlugin(self, seqid, iprot, oprot): + args = configurePlugin_args() args.read(iprot) iprot.readMessageEnd() - result = getConfig_result() - result.success = self._handler.getConfig() - oprot.writeMessageBegin("getConfig", TMessageType.REPLY, seqid) + result = configurePlugin_result() + result.success = self._handler.configurePlugin(args.plugin) + oprot.writeMessageBegin("configurePlugin", TMessageType.REPLY, seqid) result.write(oprot) oprot.writeMessageEnd() oprot.trans.flush() - def process_getPluginConfig(self, seqid, iprot, oprot): - args = getPluginConfig_args() + def process_saveConfig(self, seqid, iprot, oprot): + args = saveConfig_args() args.read(iprot) iprot.readMessageEnd() - result = getPluginConfig_result() - result.success = self._handler.getPluginConfig() - oprot.writeMessageBegin("getPluginConfig", TMessageType.REPLY, seqid) + result = saveConfig_result() + self._handler.saveConfig(args.config) + oprot.writeMessageBegin("saveConfig", TMessageType.REPLY, seqid) result.write(oprot) oprot.writeMessageEnd() oprot.trans.flush() - def process_configureSection(self, seqid, iprot, oprot): - args = configureSection_args() + def process_deleteConfig(self, seqid, iprot, oprot): + args = deleteConfig_args() args.read(iprot) iprot.readMessageEnd() - result = configureSection_result() - result.success = self._handler.configureSection(args.section) - oprot.writeMessageBegin("configureSection", TMessageType.REPLY, seqid) + result = deleteConfig_result() + self._handler.deleteConfig(args.config) + oprot.writeMessageBegin("deleteConfig", TMessageType.REPLY, seqid) result.write(oprot) oprot.writeMessageEnd() oprot.trans.flush() @@ -4071,12 +4095,23 @@ class Processor(Iface, TProcessor): args.read(iprot) iprot.readMessageEnd() result = updateAccount_result() - self._handler.updateAccount(args.plugin, args.account, args.password, args.options) + self._handler.updateAccount(args.plugin, args.account, args.password) oprot.writeMessageBegin("updateAccount", TMessageType.REPLY, seqid) result.write(oprot) oprot.writeMessageEnd() oprot.trans.flush() + def process_updateAccountInfo(self, seqid, iprot, oprot): + args = updateAccountInfo_args() + args.read(iprot) + iprot.readMessageEnd() + result = updateAccountInfo_result() + self._handler.updateAccountInfo(args.account) + oprot.writeMessageBegin("updateAccountInfo", TMessageType.REPLY, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + def process_removeAccount(self, seqid, iprot, oprot): args = removeAccount_args() args.read(iprot) @@ -4542,7 +4577,7 @@ class toggleReconnect_result(TBase): self.success = success -class scanDownloadFolder_args(TBase): +class getConfig_args(TBase): __slots__ = [ ] @@ -4551,39 +4586,34 @@ class scanDownloadFolder_args(TBase): ) -class scanDownloadFolder_result(TBase): +class getConfig_result(TBase): + """ + Attributes: + - success + """ __slots__ = [ + 'success', ] thrift_spec = ( + (0, TType.MAP, 'success', (TType.STRING,None,TType.STRUCT,(ConfigHolder, ConfigHolder.thrift_spec)), None, ), # 0 ) + def __init__(self, success=None,): + self.success = success -class getConfigValue_args(TBase): - """ - Attributes: - - section - - option - """ + +class getGlobalPlugins_args(TBase): __slots__ = [ - 'section', - 'option', ] thrift_spec = ( - None, # 0 - (1, TType.STRING, 'section', None, None, ), # 1 - (2, TType.STRING, 'option', None, None, ), # 2 ) - def __init__(self, section=None, option=None,): - self.section = section - self.option = option - -class getConfigValue_result(TBase): +class getGlobalPlugins_result(TBase): """ Attributes: - success @@ -4594,59 +4624,60 @@ class getConfigValue_result(TBase): ] thrift_spec = ( - (0, TType.STRING, 'success', None, None, ), # 0 + (0, TType.LIST, 'success', (TType.STRUCT,(ConfigInfo, ConfigInfo.thrift_spec)), None, ), # 0 ) def __init__(self, success=None,): self.success = success -class setConfigValue_args(TBase): - """ - Attributes: - - section - - option - - value - """ +class getUserPlugins_args(TBase): __slots__ = [ - 'section', - 'option', - 'value', ] thrift_spec = ( - None, # 0 - (1, TType.STRING, 'section', None, None, ), # 1 - (2, TType.STRING, 'option', None, None, ), # 2 - (3, TType.STRING, 'value', None, None, ), # 3 ) - def __init__(self, section=None, option=None, value=None,): - self.section = section - self.option = option - self.value = value - -class setConfigValue_result(TBase): +class getUserPlugins_result(TBase): + """ + Attributes: + - success + """ __slots__ = [ + 'success', ] thrift_spec = ( + (0, TType.LIST, 'success', (TType.STRUCT,(ConfigInfo, ConfigInfo.thrift_spec)), None, ), # 0 ) + def __init__(self, success=None,): + self.success = success + -class getConfig_args(TBase): +class configurePlugin_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 getConfig_result(TBase): + +class configurePlugin_result(TBase): """ Attributes: - success @@ -4657,76 +4688,68 @@ class getConfig_result(TBase): ] thrift_spec = ( - (0, TType.MAP, 'success', (TType.STRING,None,TType.STRUCT,(ConfigSection, ConfigSection.thrift_spec)), None, ), # 0 + (0, TType.STRUCT, 'success', (ConfigHolder, ConfigHolder.thrift_spec), None, ), # 0 ) def __init__(self, success=None,): self.success = success -class getPluginConfig_args(TBase): +class saveConfig_args(TBase): + """ + Attributes: + - config + """ __slots__ = [ + 'config', ] thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'config', (ConfigHolder, ConfigHolder.thrift_spec), None, ), # 1 ) + def __init__(self, config=None,): + self.config = config -class getPluginConfig_result(TBase): - """ - Attributes: - - success - """ + +class saveConfig_result(TBase): __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 configureSection_args(TBase): +class deleteConfig_args(TBase): """ Attributes: - - section + - config """ __slots__ = [ - 'section', + 'config', ] thrift_spec = ( None, # 0 - (1, TType.STRING, 'section', None, None, ), # 1 + (1, TType.STRUCT, 'config', (ConfigHolder, ConfigHolder.thrift_spec), None, ), # 1 ) - def __init__(self, section=None,): - self.section = section + def __init__(self, config=None,): + self.config = config -class configureSection_result(TBase): - """ - Attributes: - - success - """ +class deleteConfig_result(TBase): __slots__ = [ - 'success', ] thrift_spec = ( - (0, TType.STRUCT, 'success', (ConfigSection, ConfigSection.thrift_spec), None, ), # 0 ) - def __init__(self, success=None,): - self.success = success - class setConfigHandler_args(TBase): """ @@ -6693,14 +6716,12 @@ class updateAccount_args(TBase): - plugin - account - password - - options """ __slots__ = [ 'plugin', 'account', 'password', - 'options', ] thrift_spec = ( @@ -6708,14 +6729,12 @@ class updateAccount_args(TBase): (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,): + def __init__(self, plugin=None, account=None, password=None,): self.plugin = plugin self.account = account self.password = password - self.options = options class updateAccount_result(TBase): @@ -6727,6 +6746,34 @@ class updateAccount_result(TBase): ) +class updateAccountInfo_args(TBase): + """ + Attributes: + - account + """ + + __slots__ = [ + 'account', + ] + + thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'account', (AccountInfo, AccountInfo.thrift_spec), None, ), # 1 + ) + + def __init__(self, account=None,): + self.account = account + + +class updateAccountInfo_result(TBase): + + __slots__ = [ + ] + + thrift_spec = ( + ) + + class removeAccount_args(TBase): """ Attributes: diff --git a/module/remote/thriftbackend/thriftgen/pyload/ttypes.py b/module/remote/thriftbackend/thriftgen/pyload/ttypes.py index b61d4c479..815c80819 100644 --- a/module/remote/thriftbackend/thriftgen/pyload/ttypes.py +++ b/module/remote/thriftbackend/thriftgen/pyload/ttypes.py @@ -202,7 +202,7 @@ class Permission(TBase): Download = 8 Accounts = 16 Interaction = 32 - Addons = 64 + Plugins = 64 _VALUES_TO_NAMES = { 0: "All", @@ -212,7 +212,7 @@ class Permission(TBase): 8: "Download", 16: "Accounts", 32: "Interaction", - 64: "Addons", + 64: "Plugins", } _NAMES_TO_VALUES = { @@ -223,7 +223,7 @@ class Permission(TBase): "Download": 8, "Accounts": 16, "Interaction": 32, - "Addons": 64, + "Plugins": 64, } class Role(TBase): @@ -734,7 +734,7 @@ class ConfigItem(TBase): """ Attributes: - name - - display_name + - label - description - type - default_value @@ -743,7 +743,7 @@ class ConfigItem(TBase): __slots__ = [ 'name', - 'display_name', + 'label', 'description', 'type', 'default_value', @@ -753,27 +753,27 @@ class ConfigItem(TBase): thrift_spec = ( None, # 0 (1, TType.STRING, 'name', None, None, ), # 1 - (2, TType.STRING, 'display_name', None, None, ), # 2 + (2, TType.STRING, 'label', None, None, ), # 2 (3, TType.STRING, 'description', None, None, ), # 3 (4, TType.STRING, 'type', None, None, ), # 4 (5, TType.STRING, 'default_value', None, None, ), # 5 (6, TType.STRING, 'value', None, None, ), # 6 ) - def __init__(self, name=None, display_name=None, description=None, type=None, default_value=None, value=None,): + def __init__(self, name=None, label=None, description=None, type=None, default_value=None, value=None,): self.name = name - self.display_name = display_name + self.label = label self.description = description self.type = type self.default_value = default_value self.value = value -class ConfigSection(TBase): +class ConfigHolder(TBase): """ Attributes: - name - - display_name + - label - description - long_description - items @@ -783,7 +783,7 @@ class ConfigSection(TBase): __slots__ = [ 'name', - 'display_name', + 'label', 'description', 'long_description', 'items', @@ -794,7 +794,7 @@ class ConfigSection(TBase): thrift_spec = ( None, # 0 (1, TType.STRING, 'name', None, None, ), # 1 - (2, TType.STRING, 'display_name', None, None, ), # 2 + (2, TType.STRING, 'label', None, None, ), # 2 (3, TType.STRING, 'description', None, None, ), # 3 (4, TType.STRING, 'long_description', None, None, ), # 4 (5, TType.LIST, 'items', (TType.STRUCT,(ConfigItem, ConfigItem.thrift_spec)), None, ), # 5 @@ -802,9 +802,9 @@ class ConfigSection(TBase): (7, TType.LIST, 'handler', (TType.STRUCT,(InteractionTask, InteractionTask.thrift_spec)), None, ), # 7 ) - def __init__(self, name=None, display_name=None, description=None, long_description=None, items=None, info=None, handler=None,): + def __init__(self, name=None, label=None, description=None, long_description=None, items=None, info=None, handler=None,): self.name = name - self.display_name = display_name + self.label = label self.description = description self.long_description = long_description self.items = items @@ -812,6 +812,41 @@ class ConfigSection(TBase): self.handler = handler +class ConfigInfo(TBase): + """ + Attributes: + - name + - label + - description + - saved + - activated + """ + + __slots__ = [ + 'name', + 'label', + 'description', + 'saved', + 'activated', + ] + + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'name', None, None, ), # 1 + (2, TType.STRING, 'label', None, None, ), # 2 + (3, TType.STRING, 'description', None, None, ), # 3 + (4, TType.BOOL, 'saved', None, None, ), # 4 + (5, TType.BOOL, 'activated', None, None, ), # 5 + ) + + def __init__(self, name=None, label=None, description=None, saved=None, activated=None,): + self.name = name + self.label = label + self.description = description + self.saved = saved + self.activated = activated + + class EventInfo(TBase): """ Attributes: diff --git a/tests/test_configparser.py b/tests/test_configparser.py new file mode 100644 index 000000000..29ba9e51b --- /dev/null +++ b/tests/test_configparser.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- + +from collections import defaultdict +from helper.Stubs import Core + +from module.database import DatabaseBackend +from module.config.ConfigParser import ConfigParser + +# TODO +class TestConfigParser(): + + @classmethod + def setUpClass(cls): + cls.db = DatabaseBackend(Core()) + cls.db.manager = cls.db.core + cls.db.manager.statusMsg = defaultdict(lambda: "statusmsg") + cls.config = ConfigParser + + + def test_db(self): + pass + + def test_dict(self): + pass + + def test_config(self): + pass + + def test_userconfig(self): + pass
\ No newline at end of file diff --git a/tests/test_filemanager.py b/tests/test_filemanager.py index a9c6d3375..f5bdd9df3 100644 --- a/tests/test_filemanager.py +++ b/tests/test_filemanager.py @@ -82,11 +82,11 @@ class TestFileManager(BenchmarkTest): p.delete() - self.m.getView(-1, True, False) + self.m.getTree(-1, True, False) def test_get_files_root(self): - view = self.m.getView(-1, True, False) + view = self.m.getTree(-1, True, False) for pid in self.pids: assert pid in view.packages @@ -99,14 +99,14 @@ class TestFileManager(BenchmarkTest): def test_get_package_content(self): - view = self.m.getView(choice(self.pids), False, False) + view = self.m.getTree(choice(self.pids), False, False) p = view.root assert len(view.packages) == len(p.pids) for pid in p.pids: assert pid in view.packages def test_get_package_tree(self): - view = self.m.getView(choice(self.pids), True, False) + view = self.m.getTree(choice(self.pids), True, False) for pid in view.root.pids: assert pid in view.packages for fid in view.root.fids: assert fid in view.files @@ -119,7 +119,7 @@ class TestFileManager(BenchmarkTest): self.m.addLinks([("url", "plugin") for i in range(100)], parent) pids = [self.m.addPackage("c", "", parent, "", "", "", False) for i in range(5)] - v = self.m.getView(parent, False, False) + v = self.m.getTree(parent, False, False) self.assert_ordered(pids, 0, 5, v.root.pids, v.packages, True) pid = v.packages.keys()[0] @@ -136,7 +136,7 @@ class TestFileManager(BenchmarkTest): def test_order_files(self): parent = self.m.addPackage("order", "", -1, "", "", "", False) self.m.addLinks([("url", "plugin") for i in range(100)], parent) - v = self.m.getView(parent, False, False) + v = self.m.getTree(parent, False, False) fids = v.root.fids[10:20] v = self.assert_files_ordered(parent, fids, 0) @@ -144,7 +144,7 @@ class TestFileManager(BenchmarkTest): fids = v.root.fids[20:30] self.m.orderFiles(fids, parent, 99) - v = self.m.getView(parent, False, False) + v = self.m.getTree(parent, False, False) assert fids[-1] == v.root.fids[-1] assert fids[0] == v.root.fids[90] self.assert_ordered(fids, 90, 100, v.root.fids, v.files) @@ -153,12 +153,12 @@ class TestFileManager(BenchmarkTest): v = self.assert_files_ordered(parent, fids, 20) self.m.orderFiles(fids, parent, 80) - v = self.m.getView(parent, False, False) + v = self.m.getTree(parent, False, False) self.assert_ordered(fids, 61, 81, v.root.fids, v.files) fids = v.root.fids[50:51] self.m.orderFiles(fids, parent, 99) - v = self.m.getView(parent, False, False) + v = self.m.getTree(parent, False, False) self.assert_ordered(fids, 99, 100, v.root.fids, v.files) fids = v.root.fids[50:51] @@ -168,14 +168,14 @@ class TestFileManager(BenchmarkTest): def assert_files_ordered(self, parent, fids, pos): fs = [self.m.getFile(choice(fids)) for i in range(5)] self.m.orderFiles(fids, parent, pos) - v = self.m.getView(parent, False, False) + v = self.m.getTree(parent, False, False) self.assert_ordered(fids, pos, pos+len(fids), v.root.fids, v.files) return v def assert_pack_ordered(self, parent, pid, pos): self.m.orderPackage(pid, pos) - v = self.m.getView(parent, False, False) + v = self.m.getTree(parent, False, False) self.assert_ordered([pid], pos, pos+1, v.root.pids, v.packages, True) # assert that ordering is total, complete with no gaps @@ -195,15 +195,15 @@ class TestFileManager(BenchmarkTest): pid2 = self.pids[1] self.m.movePackage(pid, -1) - v = self.m.getView(-1, False, False) + v = self.m.getTree(-1, False, False) assert v.root.pids[-1] == pid assert sorted([p.packageorder for p in v.packages.values()]) == range(len(v.packages)) - v = self.m.getView(pid, False, False) + v = self.m.getTree(pid, False, False) fids = v.root.fids[10:20] self.m.moveFiles(fids, pid2) - v = self.m.getView(pid2, False, False) + v = self.m.getTree(pid2, False, False) assert sorted([f.fileorder for f in v.files.values()]) == range(len(v.files)) assert len(v.files) == self.count + len(fids) |