summaryrefslogtreecommitdiffstats
path: root/module/api
diff options
context:
space:
mode:
Diffstat (limited to 'module/api')
-rw-r--r--module/api/ApiComponent.py2
-rw-r--r--module/api/ConfigApi.py9
-rw-r--r--module/api/CoreApi.py20
-rw-r--r--module/api/FileApi.py2
4 files changed, 18 insertions, 15 deletions
diff --git a/module/api/ApiComponent.py b/module/api/ApiComponent.py
index c3b8c974b..3948086c2 100644
--- a/module/api/ApiComponent.py
+++ b/module/api/ApiComponent.py
@@ -18,6 +18,6 @@ class ApiComponent(Iface):
self.core = core
assert isinstance(user, User)
self.user = user
- self.userHandle = 0
+ self.primaryUID = 0
# No instantiating!
raise Exception() \ No newline at end of file
diff --git a/module/api/ConfigApi.py b/module/api/ConfigApi.py
index 55e0aa49b..9df9455a2 100644
--- a/module/api/ConfigApi.py
+++ b/module/api/ConfigApi.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-from module.Api import Api, UserContext, RequirePerm, Permission, ConfigHolder, ConfigItem, ConfigInfo
+from module.Api import Api, RequirePerm, Permission, ConfigHolder, ConfigItem, ConfigInfo
from module.utils import to_string
from ApiComponent import ApiComponent
@@ -9,7 +9,6 @@ from ApiComponent import ApiComponent
class ConfigApi(ApiComponent):
""" Everything related to configuration """
- @UserContext
def getConfigValue(self, section, option):
"""Retrieve config value.
@@ -21,7 +20,6 @@ class ConfigApi(ApiComponent):
value = self.core.config.get(section, option, self.user)
return to_string(value)
- @UserContext
def setConfigValue(self, section, option, value):
"""Set new config value.
@@ -56,7 +54,6 @@ class ConfigApi(ApiComponent):
return [ConfigInfo(section, config.name, config.description, False, False)
for section, config, values in self.core.config.iterCoreSections()]
- @UserContext
@RequirePerm(Permission.Plugins)
def getPluginConfig(self):
"""All plugins and addons the current user has configured
@@ -75,7 +72,6 @@ class ConfigApi(ApiComponent):
return data
- @UserContext
@RequirePerm(Permission.Plugins)
def getAvailablePlugins(self):
"""List of all available plugins, that are configurable
@@ -88,7 +84,6 @@ class ConfigApi(ApiComponent):
self.core.pluginManager.isUserPlugin(name))
for name, config, values in self.core.config.iterSections(self.user)]
- @UserContext
@RequirePerm(Permission.Plugins)
def configurePlugin(self, plugin):
"""Get complete config options for desired section
@@ -99,7 +94,6 @@ class ConfigApi(ApiComponent):
pass
- @UserContext
@RequirePerm(Permission.Plugins)
def saveConfig(self, config):
"""Used to save a configuration, core config can only be saved by admins
@@ -108,7 +102,6 @@ class ConfigApi(ApiComponent):
"""
pass
- @UserContext
@RequirePerm(Permission.Plugins)
def deleteConfig(self, plugin):
"""Deletes modified config
diff --git a/module/api/CoreApi.py b/module/api/CoreApi.py
index 4de8c1f96..9338954d0 100644
--- a/module/api/CoreApi.py
+++ b/module/api/CoreApi.py
@@ -1,12 +1,13 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-from module.Api import Api, RequirePerm, Permission, ServerStatus
+from module.Api import Api, RequirePerm, Permission, ServerStatus, PackageStats
from module.utils.fs import join, free_space
from module.utils import compare_time
from ApiComponent import ApiComponent
+
class CoreApi(ApiComponent):
""" This module provides methods for general interaction with the core, like status or progress retrieval """
@@ -18,7 +19,8 @@ class CoreApi(ApiComponent):
@RequirePerm(Permission.All)
def getWSAddress(self):
"""Gets and address for the websocket based on configuration"""
- # TODO
+ # TODO SSL (wss)
+ return "ws://%%s:%d" % self.core.config['remote']['port']
@RequirePerm(Permission.All)
def getServerStatus(self):
@@ -26,10 +28,17 @@ class CoreApi(ApiComponent):
:return: `ServerStatus`
"""
- serverStatus = ServerStatus(self.core.files.getQueueCount(), self.core.files.getFileCount(), 0,
- not self.core.threadManager.pause and self.isTimeDownload(), self.core.threadManager.pause,
- self.core.config['reconnect']['activated'] and self.isTimeReconnect())
+ queue = self.core.files.getQueueStats(self.primaryUID)
+ total = self.core.files.getDownloadStats(self.primaryUID)
+
+ serverStatus = ServerStatus(0,
+ PackageStats(total[0], total[0] - queue[0], total[1], total[1] - queue[1]),
+ 0,
+ not self.core.threadManager.pause and self.isTimeDownload(),
+ self.core.threadManager.pause,
+ self.core.config['reconnect']['activated'] and self.isTimeReconnect())
+ # TODO multi user
for pyfile in self.core.threadManager.getActiveDownloads():
serverStatus.speed += pyfile.getSpeed() #bytes/s
@@ -117,5 +126,6 @@ class CoreApi(ApiComponent):
end = self.core.config['reconnect']['endTime'].split(":")
return compare_time(start, end) and self.core.config["reconnect"]["activated"]
+
if Api.extend(CoreApi):
del CoreApi \ No newline at end of file
diff --git a/module/api/FileApi.py b/module/api/FileApi.py
index 8f09f3cb7..a5d5a8535 100644
--- a/module/api/FileApi.py
+++ b/module/api/FileApi.py
@@ -80,7 +80,7 @@ class FileApi(ApiComponent):
@RequirePerm(Permission.All)
def searchSuggestions(self, pattern):
- names = self.core.db.getMatchingFilenames(pattern, self.userHandle)
+ names = self.core.db.getMatchingFilenames(pattern, self.primaryUID)
# TODO: stemming and reducing the names to provide better suggestions
return uniqify(names)