comparison src/core/sat_main.py @ 2105:c96fe007ca41

core(constants): added a constant for profile extension (PLUGIN_EXT): this constant may be modified if needed, which is the case on Android (it's modified by Cagou service's main.py), so platform detection is not needed anymore in sat_main.py.
author Goffi <goffi@goffi.org>
date Sun, 25 Dec 2016 16:43:56 +0100
parents fbeeba721954
children 9c861d07b5b6
comparison
equal deleted inserted replaced
2104:4f189bd1d9ed 2105:c96fe007ca41
33 from sat.memory.memory import Memory 33 from sat.memory.memory import Memory
34 from sat.tools import trigger 34 from sat.tools import trigger
35 from sat.tools import utils 35 from sat.tools import utils
36 from sat.tools.common import dynamic_import 36 from sat.tools.common import dynamic_import
37 from sat.stdui import ui_contact_list, ui_profile_manager 37 from sat.stdui import ui_contact_list, ui_profile_manager
38 import sat.plugins
38 from glob import glob 39 from glob import glob
39 from uuid import uuid4 40 from uuid import uuid4
40 import sys 41 import sys
41 import os.path 42 import os.path
42 import uuid 43 import uuid
152 self.initialised.callback(None) 153 self.initialised.callback(None)
153 log.info(_(u"Backend is ready")) 154 log.info(_(u"Backend is ready"))
154 155
155 def _import_plugins(self): 156 def _import_plugins(self):
156 """Import all plugins found in plugins directory""" 157 """Import all plugins found in plugins directory"""
157 if sys.platform == "android": 158 plugins_path = os.path.dirname(sat.plugins.__file__)
158 # FIXME: android hack to load plugins from proper path 159 plugin_glob = "plugin*." + C.PLUGIN_EXT
159 # TODO: move this in a separate module and/or use sat.conf to specify path
160 plugins_path = "/data/data/org.goffi.cagou.cagou/files/sat/plugins"
161 plugin_glob = "plugin*.pyo"
162 else:
163 import sat.plugins
164 plugins_path = os.path.dirname(sat.plugins.__file__)
165 plugin_glob = "plugin*.py"
166 plug_lst = [os.path.splitext(plugin)[0] for plugin in map(os.path.basename, glob(os.path.join(plugins_path, plugin_glob)))] 160 plug_lst = [os.path.splitext(plugin)[0] for plugin in map(os.path.basename, glob(os.path.join(plugins_path, plugin_glob)))]
167 plugins_to_import = {} # plugins we still have to import 161 plugins_to_import = {} # plugins we still have to import
168 for plug in plug_lst: 162 for plug in plug_lst:
169 plugin_path = 'sat.plugins.' + plug 163 plugin_path = 'sat.plugins.' + plug
170 try: 164 try: