Example #1
0
 def read(self, virtual_setup=False):
     clear_modules()
     import django.conf
     from lucterios.framework.tools import set_locale_lang
     if virtual_setup:
         setup_from_none()
     if self.name == '':
         raise AdminException("Instance not precise!")
     if not isfile(self.setting_path) or not isfile(self.instance_conf):
         raise AdminException("Instance not exists !")
     os.environ[django.conf.ENVIRONMENT_VARIABLE] = self.setting_module_name
     if self.setting_module_name in sys.modules.keys():
         mod_set = sys.modules[self.setting_module_name]
         del mod_set
         del sys.modules[self.setting_module_name]
     if not virtual_setup:
         import_module("django.conf")
         django.setup()
         setting_module = django.conf.settings
     else:
         setting_module = import_module(self.setting_module_name)
         set_locale_lang(setting_module.LANGUAGE_CODE)
     self.secret_key = setting_module.SECRET_KEY
     self.extra = setting_module.EXTRA
     self.databases = setting_module.DATABASES
     self.database = setting_module.DATABASES['default']['ENGINE']
     if "sqlite3" in self.database:
         self.database = ('sqlite', {})
     if "mysql" in self.database:
         self.database = ('mysql', self._get_db_info_())
     if "postgresql" in self.database:
         self.database = ('postgresql', self._get_db_info_())
     self.appli_name = setting_module.APPLIS_MODULE.__name__
     self.modules = ()
     for appname in setting_module.INSTALLED_APPS:
         if ("django" not in appname) and (
                 appname != 'lucterios.framework') and (
                     appname != 'lucterios.CORE') and (self.appli_name !=
                                                       appname):
             self.modules = self.modules + (six.text_type(appname), )
     try:
         from lucterios.CORE.parameters import Params
         self.extra[''] = {
             'mode': (Params.getvalue("CORE-connectmode"),
                      Params.gettext("CORE-connectmode"))
         }
     except Exception:
         self.extra[''] = {'mode': None}
     self.print_info_("""Instance %s:
 path\t%s
 appli\t%s
 database\t%s
 modules\t%s
 extra\t%s
 """ % (self.name, self.instance_dir, self.get_appli_txt(),
        self.get_database_txt(), self.get_module_txt(),
        self.get_extra_txt()))
     return
Example #2
0
 def _read_extra(self, extra):
     self.extra = extra
     try:
         from lucterios.CORE.parameters import Params
         self.extra[''] = {
             'mode': (Params.getvalue("CORE-connectmode"),
                      Params.gettext("CORE-connectmode"))
         }
     except Exception:
         self.extra[''] = {'mode': None}
Example #3
0
 def read(self):
     clear_modules()
     import django.conf
     if self.name == '':
         raise AdminException("Instance not precise!")
     if not isfile(self.setting_path) or not isfile(self.instance_conf):
         raise AdminException("Instance not exists !")
     os.environ[django.conf.ENVIRONMENT_VARIABLE] = self.setting_module_name
     if self.setting_module_name in sys.modules.keys():
         mod_set = sys.modules[self.setting_module_name]
         del mod_set
         del sys.modules[self.setting_module_name]
     import_module(self.setting_module_name)
     import_module("django.conf")
     django.setup()
     self.secret_key = django.conf.settings.SECRET_KEY
     self.extra = django.conf.settings.EXTRA
     self.databases = django.conf.settings.DATABASES
     self.database = django.conf.settings.DATABASES['default']['ENGINE']
     if "sqlite3" in self.database:
         self.database = ('sqlite', {})
     if "mysql" in self.database:
         self.database = ('mysql', self._get_db_info_())
     if "postgresql" in self.database:
         self.database = ('postgresql', self._get_db_info_())
     self.appli_name = django.conf.settings.APPLIS_MODULE.__name__
     self.modules = ()
     for appname in django.conf.settings.INSTALLED_APPS:
         if ("django" not in appname) and (appname != 'lucterios.framework') and (appname != 'lucterios.CORE') and (self.appli_name != appname):
             self.modules = self.modules + (six.text_type(appname),)
     from lucterios.CORE.parameters import Params
     from lucterios.framework.error import LucteriosException
     try:
         self.extra[''] = {'mode': (
             Params.getvalue("CORE-connectmode"), Params.gettext("CORE-connectmode"))}
     except LucteriosException:
         self.extra[''] = {'mode': None}
     self.print_info_("""Instance %s:
 path\t%s
 appli\t%s
 database\t%s
 modules\t%s
 extra\t%s
 """ % (self.name, self.instance_dir, self.get_appli_txt(), self.get_database_txt(), self.get_module_txt(), self.get_extra_txt()))
     return