Auto register static files
This commit is contained in:
@@ -80,10 +80,14 @@ class Loader:
|
||||
|
||||
def loadPlugins(self, module, name):
|
||||
try:
|
||||
module.start()
|
||||
klass = module.start()
|
||||
|
||||
if klass and getattr(klass, 'auto_register_static'):
|
||||
klass.registerStatic(module.__file__)
|
||||
|
||||
return True
|
||||
except Exception, e:
|
||||
log.error("Failed loading plugin '%s': %s" % (name, traceback.format_exc()))
|
||||
log.error("Failed loading plugin '%s': %s" % (module.__file__, traceback.format_exc()))
|
||||
return False
|
||||
|
||||
def addModule(self, priority, type, module, name):
|
||||
|
||||
@@ -15,11 +15,19 @@ class CoreNotifier(Notification):
|
||||
def __init__(self):
|
||||
|
||||
addEvent('notify', self.notify)
|
||||
addEvent('notify.core', self.frontend)
|
||||
addEvent('notify.frontend', self.frontend)
|
||||
|
||||
addApiView('core_notifier.listener', self.listener)
|
||||
|
||||
self.registerStatic(__file__)
|
||||
self.registerEvents()
|
||||
|
||||
|
||||
def registerEvents(self):
|
||||
|
||||
# Library update, frontend refresh
|
||||
def onLibraryUpdate(data):
|
||||
fireEvent('notify.frontend', type = 'library.update', data = data)
|
||||
addEvent('library.update', onLibraryUpdate)
|
||||
|
||||
def notify(self, message = '', data = {}, type = None):
|
||||
self.add(data = {
|
||||
@@ -38,7 +46,6 @@ class CoreNotifier(Notification):
|
||||
|
||||
messages = []
|
||||
for message in self.messages:
|
||||
print message['time'], (time.time() - 5)
|
||||
#delete message older then 15s
|
||||
if message['time'] > (time.time() - 15):
|
||||
messages.append(message)
|
||||
|
||||
@@ -14,6 +14,7 @@ log = CPLog(__name__)
|
||||
class Plugin(object):
|
||||
|
||||
enabled_option = 'enabled'
|
||||
auto_register_static = True
|
||||
|
||||
def conf(self, attr, default = None):
|
||||
return Env.setting(attr, self.getName().lower(), default = default)
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
from couchpotato.api import addApiView
|
||||
from couchpotato.core.helpers.request import getParam, jsonified
|
||||
from couchpotato.core.plugins.base import Plugin
|
||||
import os
|
||||
import string
|
||||
|
||||
if os.name == 'nt':
|
||||
import win32file
|
||||
|
||||
class FileBrowser():
|
||||
class FileBrowser(Plugin):
|
||||
|
||||
def __init__(self):
|
||||
addApiView('directory.list', self.view)
|
||||
|
||||
@@ -3,5 +3,7 @@ from couchpotato.core.plugins.base import Plugin
|
||||
|
||||
class Extension(Plugin):
|
||||
|
||||
auto_register_static = False
|
||||
|
||||
def __init__(self):
|
||||
self.registerStatic(__file__, add_to_head = False)
|
||||
|
||||
@@ -25,8 +25,6 @@ class FileManager(Plugin):
|
||||
|
||||
addApiView('file.cache/<path:file>', self.showImage)
|
||||
|
||||
self.registerStatic(__file__)
|
||||
|
||||
def showImage(self, file = ''):
|
||||
|
||||
cache_dir = Env.get('cache_dir')
|
||||
|
||||
@@ -100,6 +100,6 @@ class LibraryPlugin(Plugin):
|
||||
|
||||
library_dict = library.to_dict({'titles': {}, 'files':{}})
|
||||
|
||||
fireEvent('notify.core', type = 'library.update', data = library_dict)
|
||||
fireEvent('library.update', data = library_dict)
|
||||
|
||||
return library_dict
|
||||
|
||||
@@ -10,8 +10,6 @@ class MetaData(Plugin):
|
||||
def __init__(self):
|
||||
addEvent('renaming.after', self.add)
|
||||
|
||||
self.registerStatic(__file__)
|
||||
|
||||
addEvent('app.load', self.add)
|
||||
|
||||
def add(self, data = {}):
|
||||
|
||||
@@ -19,8 +19,6 @@ class MoviePlugin(Plugin):
|
||||
addApiView('movie.edit', self.edit)
|
||||
addApiView('movie.delete', self.delete)
|
||||
|
||||
self.registerStatic(__file__)
|
||||
|
||||
def list(self):
|
||||
|
||||
params = getParams()
|
||||
|
||||
@@ -17,8 +17,6 @@ class ProfilePlugin(Plugin):
|
||||
addApiView('profile.save', self.save)
|
||||
addApiView('profile.delete', self.delete)
|
||||
|
||||
self.registerStatic(__file__)
|
||||
|
||||
def all(self):
|
||||
|
||||
db = get_session()
|
||||
|
||||
@@ -33,8 +33,6 @@ class QualityPlugin(Plugin):
|
||||
addEvent('quality.guess', self.guess)
|
||||
addEvent('app.load', self.fill)
|
||||
|
||||
self.registerStatic(__file__)
|
||||
|
||||
def all(self):
|
||||
|
||||
db = get_session()
|
||||
|
||||
@@ -26,8 +26,6 @@ class StatusPlugin(Plugin):
|
||||
addEvent('status.all', self.all)
|
||||
addEvent('app.load', self.fill)
|
||||
|
||||
self.registerStatic(__file__)
|
||||
|
||||
def all(self):
|
||||
|
||||
db = get_session()
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
from couchpotato.core.event import fireEvent
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.plugins.base import Plugin
|
||||
|
||||
@@ -6,6 +5,4 @@ log = CPLog(__name__)
|
||||
|
||||
|
||||
class Wizard(Plugin):
|
||||
|
||||
def __init__(self):
|
||||
self.registerStatic(__file__)
|
||||
pass
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
from couchpotato.core.event import addEvent
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.plugins.base import Plugin
|
||||
from couchpotato.environment import Env
|
||||
import os
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
from .main import IMDB
|
||||
|
||||
def start():
|
||||
pass
|
||||
return IMDB()
|
||||
|
||||
config = []
|
||||
|
||||
@@ -31,11 +31,6 @@ class Newznab(NZBProvider, RSS):
|
||||
|
||||
time_between_searches = 1 # Seconds
|
||||
|
||||
def __init__(self):
|
||||
super(NZBProvider, self).__init__()
|
||||
|
||||
self.registerStatic(__file__)
|
||||
|
||||
def feed(self):
|
||||
|
||||
hosts = self.getHosts()
|
||||
|
||||
Reference in New Issue
Block a user