|
@@ -23,15 +23,19 @@ import sys
|
|
|
import traceback
|
|
import traceback
|
|
|
import pkg_resources
|
|
import pkg_resources
|
|
|
|
|
|
|
|
|
|
+from django.utils.translation import ugettext as _
|
|
|
|
|
+
|
|
|
import desktop
|
|
import desktop
|
|
|
|
|
+
|
|
|
from desktop.lib.paths import get_desktop_root
|
|
from desktop.lib.paths import get_desktop_root
|
|
|
|
|
|
|
|
-from django.utils.translation import ugettext as _
|
|
|
|
|
|
|
|
|
|
# Directories where apps and libraries are to be found
|
|
# Directories where apps and libraries are to be found
|
|
|
-APP_DIRS = [get_desktop_root('core-apps'),
|
|
|
|
|
- get_desktop_root('apps'),
|
|
|
|
|
- get_desktop_root('libs')]
|
|
|
|
|
|
|
+APP_DIRS = [
|
|
|
|
|
+ get_desktop_root('core-apps'),
|
|
|
|
|
+ get_desktop_root('apps'),
|
|
|
|
|
+ get_desktop_root('libs')
|
|
|
|
|
+]
|
|
|
|
|
|
|
|
LOG = logging.getLogger(__name__)
|
|
LOG = logging.getLogger(__name__)
|
|
|
|
|
|
|
@@ -42,7 +46,7 @@ LOG = logging.getLogger(__name__)
|
|
|
# List of DesktopModuleInfo that have been loaded
|
|
# List of DesktopModuleInfo that have been loaded
|
|
|
DESKTOP_LIBS = None
|
|
DESKTOP_LIBS = None
|
|
|
DESKTOP_APPS = None
|
|
DESKTOP_APPS = None
|
|
|
-DESKTOP_MODULES = [ ] # Sum of APPS and LIBS
|
|
|
|
|
|
|
+DESKTOP_MODULES = [] # Sum of APPS and LIBS
|
|
|
|
|
|
|
|
def _import_module_or_none(module):
|
|
def _import_module_or_none(module):
|
|
|
"""Like import_module, but returns None if the module does not exist.
|
|
"""Like import_module, but returns None if the module does not exist.
|
|
@@ -133,10 +137,12 @@ class DesktopModuleInfo(object):
|
|
|
self.display_name = self.config_key
|
|
self.display_name = self.config_key
|
|
|
|
|
|
|
|
# Look for static directory in two places:
|
|
# Look for static directory in two places:
|
|
|
- new_style, old_style = [ os.path.abspath(p) for p in [
|
|
|
|
|
- os.path.join(module_root, "static", self.name),
|
|
|
|
|
- os.path.join(self.root_dir, "static")
|
|
|
|
|
- ]]
|
|
|
|
|
|
|
+ new_style, old_style = [
|
|
|
|
|
+ os.path.abspath(p) for p in [
|
|
|
|
|
+ os.path.join(module_root, "static", self.name),
|
|
|
|
|
+ os.path.join(self.root_dir, "static")
|
|
|
|
|
+ ]
|
|
|
|
|
+ ]
|
|
|
|
|
|
|
|
self.static_dir = None
|
|
self.static_dir = None
|
|
|
if os.path.isdir(new_style):
|
|
if os.path.isdir(new_style):
|
|
@@ -225,13 +231,12 @@ def load_libs():
|
|
|
|
|
|
|
|
if DESKTOP_LIBS is not None:
|
|
if DESKTOP_LIBS is not None:
|
|
|
raise Exception("load_apps already has been called.")
|
|
raise Exception("load_apps already has been called.")
|
|
|
- DESKTOP_LIBS = [ ]
|
|
|
|
|
|
|
+ DESKTOP_LIBS = []
|
|
|
|
|
|
|
|
for lib in pkg_resources.iter_entry_points("desktop.sdk.lib"):
|
|
for lib in pkg_resources.iter_entry_points("desktop.sdk.lib"):
|
|
|
m = lib.load()
|
|
m = lib.load()
|
|
|
DESKTOP_LIBS.append(DesktopModuleInfo(m))
|
|
DESKTOP_LIBS.append(DesktopModuleInfo(m))
|
|
|
|
|
|
|
|
-
|
|
|
|
|
LOG.debug("Loaded Desktop Libraries: " + ", ".join(a.name for a in DESKTOP_LIBS))
|
|
LOG.debug("Loaded Desktop Libraries: " + ", ".join(a.name for a in DESKTOP_LIBS))
|
|
|
DESKTOP_MODULES += DESKTOP_LIBS
|
|
DESKTOP_MODULES += DESKTOP_LIBS
|
|
|
# Desktop itself is "special"; neither an app or a lib, but
|
|
# Desktop itself is "special"; neither an app or a lib, but
|
|
@@ -241,10 +246,9 @@ def load_libs():
|
|
|
|
|
|
|
|
|
|
|
|
|
def load_apps(app_blacklist):
|
|
def load_apps(app_blacklist):
|
|
|
- """Loads the applications from the directories in APP_DIRS.
|
|
|
|
|
|
|
+ """
|
|
|
|
|
+ Loads the applications from the directories in APP_DIRS.
|
|
|
Sets DESKTOP_MODULES and DJANGO_APPS globals in this module.
|
|
Sets DESKTOP_MODULES and DJANGO_APPS globals in this module.
|
|
|
-
|
|
|
|
|
- TODO(todd) make this a singleton perhaps if people are anti-global?
|
|
|
|
|
"""
|
|
"""
|
|
|
global DESKTOP_MODULES
|
|
global DESKTOP_MODULES
|
|
|
global DESKTOP_APPS
|
|
global DESKTOP_APPS
|