diff options
Diffstat (limited to 'rpki/rpkic.py')
-rw-r--r-- | rpki/rpkic.py | 53 |
1 files changed, 33 insertions, 20 deletions
diff --git a/rpki/rpkic.py b/rpki/rpkic.py index 8ce28b59..8529026b 100644 --- a/rpki/rpkic.py +++ b/rpki/rpkic.py @@ -124,7 +124,7 @@ class main(Cmd): global rpki # pylint: disable=W0602 try: - cfg = rpki.config.parser(self.cfg_file, "myrpki") + cfg = rpki.config.parser(set_filename = self.cfg_file, section = "myrpki") cfg.set_global_flags() except IOError, e: sys.exit("%s: %s" % (e.strerror, e.filename)) @@ -132,26 +132,35 @@ class main(Cmd): self.histfile = cfg.get("history_file", os.path.expanduser("~/.rpkic_history")) self.autosync = cfg.getboolean("autosync", True, section = "rpkic") - import django + # This should go away now that we have rpki.django_settings, but + # let's get a verbose log with it present first to see what + # changes. - from django.conf import settings + use_south = True + setup_db = False - settings.configure( - DATABASES = { "default" : { - "ENGINE" : "django.db.backends.mysql", - "NAME" : cfg.get("sql-database", section = "irdbd"), - "USER" : cfg.get("sql-username", section = "irdbd"), - "PASSWORD" : cfg.get("sql-password", section = "irdbd"), - "HOST" : "", - "PORT" : "", - "OPTIONS" : { "init_command": "SET storage_engine=INNODB" }}}, - INSTALLED_APPS = ("rpki.irdb",), - MIDDLEWARE_CLASSES = (), # API change, feh - ) + if use_south: + os.environ.update(DJANGO_SETTINGS_MODULE = "rpki.django_settings") - if django.VERSION >= (1, 7): # API change, feh - from django.apps import apps - apps.populate(settings.INSTALLED_APPS) + else: + import django + from django.conf import settings + settings.configure( + DATABASES = { "default" : { + "ENGINE" : "django.db.backends.mysql", + "NAME" : cfg.get("sql-database", section = "irdbd"), + "USER" : cfg.get("sql-username", section = "irdbd"), + "PASSWORD" : cfg.get("sql-password", section = "irdbd"), + "HOST" : "", + "PORT" : "", + "OPTIONS" : { "init_command": "SET storage_engine=INNODB" }}}, + INSTALLED_APPS = ("rpki.irdb",), + MIDDLEWARE_CLASSES = (), # API change, feh + ) + + if django.VERSION >= (1, 7): # API change, feh + from django.apps import apps + apps.populate(settings.INSTALLED_APPS) import rpki.irdb # pylint: disable=W0621 @@ -173,8 +182,12 @@ class main(Cmd): except rpki.config.ConfigParser.Error: pass - import django.core.management - django.core.management.call_command("syncdb", verbosity = 0, load_initial_data = False) + if setup_db: + import django.core.management + django.core.management.call_command("syncdb", verbosity = 3, load_initial_data = False) + + if setup_db and use_south: + django.core.management.call_command("migrate", verbosity = 3) self.zoo = rpki.irdb.Zookeeper(cfg = cfg, handle = self.handle, logstream = sys.stdout) |