Import cleanup
This commit is contained in:
1 parent
060859483a
commit
2ed53df008
3 files changed
+12
-10
No files matched your search
@@ -6,20 +6,20 @@ import traceback
|
|||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
|
|
||||||
class Loader(object):
|
|
||||||
|
|
||||||
|
class Loader(object):
|
||||||
plugins = {}
|
plugins = {}
|
||||||
providers = {}
|
providers = {}
|
||||||
modules = {}
|
modules = {}
|
||||||
|
|
||||||
def addPath(self, root, base_path, priority, recursive=False):
|
def addPath(self, root, base_path, priority, recursive = False):
|
||||||
for filename in os.listdir(os.path.join(root, *base_path)):
|
for filename in os.listdir(os.path.join(root, *base_path)):
|
||||||
path = os.path.join(os.path.join(root, *base_path), filename)
|
path = os.path.join(os.path.join(root, *base_path), filename)
|
||||||
if os.path.isdir(path) and filename[:2] != '__':
|
if os.path.isdir(path) and filename[:2] != '__':
|
||||||
if not u'__init__.py' in os.listdir(path):
|
if not u'__init__.py' in os.listdir(path):
|
||||||
return
|
return
|
||||||
new_base_path = ''.join(s + '.' for s in base_path) + filename
|
new_base_path = ''.join(s + '.' for s in base_path) + filename
|
||||||
self.paths[new_base_path.replace('.', '_')] = (priority, new_base_path, path)
|
self.paths[new_base_path.replace('.', '_')] = (priority, new_base_path, path)
|
||||||
if recursive:
|
if recursive:
|
||||||
self.addPath(root, base_path + [filename], priority, recursive = True)
|
self.addPath(root, base_path + [filename], priority, recursive = True)
|
||||||
|
|
||||||
@@ -98,14 +98,16 @@ class Loader(object):
|
|||||||
|
|
||||||
for cur_file in glob.glob(os.path.join(dir_name, '*')):
|
for cur_file in glob.glob(os.path.join(dir_name, '*')):
|
||||||
name = os.path.basename(cur_file)
|
name = os.path.basename(cur_file)
|
||||||
if os.path.isdir(os.path.join(dir_name, name)):
|
if os.path.isdir(os.path.join(dir_name, name)) and name != 'static':
|
||||||
module_name = '%s.%s' % (module, name)
|
module_name = '%s.%s' % (module, name)
|
||||||
self.addModule(priority, plugin_type, module_name, name)
|
self.addModule(priority, plugin_type, module_name, name)
|
||||||
|
|
||||||
def loadSettings(self, module, name, save = True):
|
def loadSettings(self, module, name, save = True):
|
||||||
|
|
||||||
if not hasattr(module, 'config'):
|
if not hasattr(module, 'config'):
|
||||||
log.warning('Skip loading settings for plugin %s as it has no config section' % module.__file__)
|
log.debug('Skip loading settings for plugin %s as it has no config section' % module.__file__)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for section in module.config:
|
for section in module.config:
|
||||||
fireEvent('settings.options', section['name'], section)
|
fireEvent('settings.options', section['name'], section)
|
||||||
@@ -120,8 +122,9 @@ class Loader(object):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def loadPlugins(self, module, name):
|
def loadPlugins(self, module, name):
|
||||||
|
|
||||||
if not hasattr(module, 'start'):
|
if not hasattr(module, 'start'):
|
||||||
log.warning('Skip startup for plugin %s as it has no start section' % module.__file__)
|
log.debug('Skip startup for plugin %s as it has no start section' % module.__file__)
|
||||||
return False
|
return False
|
||||||
try:
|
try:
|
||||||
module.start()
|
module.start()
|
||||||
@@ -150,7 +153,7 @@ class Loader(object):
|
|||||||
m = getattr(m, sub)
|
m = getattr(m, sub)
|
||||||
return m
|
return m
|
||||||
except ImportError:
|
except ImportError:
|
||||||
log.warning("Skip loading module plugin '%s' as it seems not to be a module." % name)
|
log.debug('Skip loading module plugin %s: %s', (name, traceback.format_exc()))
|
||||||
return None
|
return None
|
||||||
except:
|
except:
|
||||||
raise
|
raise
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
from couchpotato.core.event import addEvent
|
from couchpotato.core.event import addEvent
|
||||||
from couchpotato.core.logger import CPLog
|
|
||||||
from couchpotato.core.plugins.base import Plugin
|
from couchpotato.core.plugins.base import Plugin
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from couchpotato.core.helpers.encoding import tryUrlencode, toUnicode
|
|||||||
from couchpotato.core.helpers.variable import tryInt
|
from couchpotato.core.helpers.variable import tryInt
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.providers.base import MultiProvider
|
from couchpotato.core.providers.base import MultiProvider
|
||||||
from couchpotato.core.providers.movie.base import MovieProvider
|
from couchpotato.core.providers.info.base import MovieProvider
|
||||||
from couchpotato.core.providers.torrent.base import TorrentProvider
|
from couchpotato.core.providers.torrent.base import TorrentProvider
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user