def test_get_version(self): self.assertNotEqual("0.0.0", util.get_version()) try: util.get_version_object() except ValueError as e: self.fail("Illegal version: " + str(e)) self.assertTrue(util.get_version_object().version >= (0, 9, 23))
def test_get_version(self): self.assertNotEqual('0.0.0', util.get_version()) try: util.get_version_object() except ValueError as e: self.fail('Illegal version: ' + str(e)) self.assertTrue(util.get_version_object().version >= (0, 9, 23))
def __call__(self, request): request.need_setup = False request.need_upgrade = False request.kbsite = None installed_version = models.KegbotSite.get_installed_version() if installed_version is None: request.need_setup = True else: request.installed_version_string = str(installed_version) request.need_upgrade = must_upgrade(installed_version, get_version_object()) if not request.need_setup and not request.need_upgrade: request.kbsite = models.KegbotSite.objects.get(name='default') if request.kbsite.is_setup: timezone.activate(request.kbsite.timezone) request.plugins = dict( (p.get_short_name(), p) for p in list(plugin_util.get_plugins().values())) else: request.need_setup = True request.backend = get_kegbot_backend() return self.get_response(request)
def upgrade(request): context = {} if request.method == "POST": try: management.call_command("migrate", no_input=True) site = models.KegbotSite.get() app_version = get_version_object() site.server_version = str(app_version) site.save() return redirect("kb-home") except Exception as e: logger.exception("Error installing database") context["error_message"] = str(e) context["error_stack"] = traceback.format_exc() try: logger.info("Checking database status ...") dbstatus.check_db_status() logger.info("Database status OK.") except dbstatus.DatabaseNotInitialized: context["message"] = "Database not initialized" except dbstatus.NeedMigration: context["message"] = "Database upgrade needed" return render(request, "setup_wizard/upgrade.html", context=context)
def handle(self, *args, **options): installed_version = models.KegbotSite.get_installed_version() app_version = get_version_object() force = options.get("force") if installed_version is None: print("Kegbot is not installed; run setup-kegbot.py first.") sys.exit(1) if installed_version == app_version and not force: print("Version {} already installed.".format(installed_version)) return if installed_version > app_version: print( "Installed version {} is newer than app version {}".format( installed_version, app_version ) ) sys.exit(1) if installed_version < MINIMUM_INSTALLED_VERSION: print("") print("ERROR: This version of Kegbot can only upgrade systems running on version") print( "v{} or newer. Please install Kegbot v{} and run `kegbot upgrade` again.".format( MINIMUM_INSTALLED_VERSION, MINIMUM_INSTALLED_VERSION ) ) print("(Existing version: {})".format(installed_version)) print("") print("More help: https://github.com/Kegbot/kegbot-server/wiki/Upgrading-Old-Versions") print("") sys.exit(1) print("Upgrading from {} to {}".format(installed_version, app_version)) self.do_version_upgrades(installed_version) run(migrate.Command(), args=["--noinput", "-v", "0"]) if not options.get("skip_stats"): run(regen_stats.Command()) if not options.get("skip_static"): run(collectstatic.Command(), args=["--noinput"]) site = models.KegbotSite.get() site.server_version = str(app_version) site.save() # Refresh any news (since we have a new version). try: checkin.checkin(timeout=5.0, quiet=True) except (checkin.CheckinError, Exception): pass print("") print("Upgrade complete!")
def handle(self, *args, **options): installed_version = models.KegbotSite.get_installed_version() app_version = get_version_object() force = options.get('force') if installed_version is None: print 'Kegbot is not installed; run setup-kegbot.py first.' sys.exit(1) if installed_version == app_version and not force: print 'Version {} already installed.'.format(installed_version) return if installed_version > app_version: print 'Installed version {} is newer than app version {}'.format( installed_version, app_version) sys.exit(1) if installed_version < MINIMUM_INSTALLED_VERSION: print '' print 'ERROR: This version of Kegbot can only upgrade systems running on version' print 'v{} or newer. Please install Kegbot v{} and run `kegbot upgrade` again.'.format( MINIMUM_INSTALLED_VERSION, MINIMUM_INSTALLED_VERSION) print '' print 'More help: https://github.com/Kegbot/kegbot-server/wiki/Upgrading-Old-Versions' print '' sys.exit(1) print 'Upgrading from {} to {}'.format(installed_version, app_version) self.do_version_upgrades(installed_version) run(syncdb.Command(), args=['--noinput', '-v', '0']) run(migrate.Command(), args=['-v', '0']) if not options.get('skip_stats'): run(regen_stats.Command()) if not options.get('skip_static'): run(collectstatic.Command(), args=['--noinput']) site = models.KegbotSite.get() site.server_version = str(app_version) site.save() # Refresh any news (since we have a new version). try: checkin.checkin(timeout=5.0, quiet=True) except (checkin.CheckinError, Exception): pass print '' print 'Upgrade complete!'
def __call__(self, request): request.need_setup = False request.need_upgrade = False request.kbsite = None # Skip all checks if we're in the setup wizard. if request.path.startswith("/setup"): request.session = {} request.session["_auth_user_backend"] = None return self.get_response(request) # First confirm the database is working. try: dbstatus.check_db_status() except dbstatus.DatabaseNotInitialized: logger.warning("Database is not initialized, sending to setup ...") request.need_setup = True request.need_upgrade = True except dbstatus.NeedMigration: logger.warning("Database needs migration, sending to setup ...") request.need_upgrade = True # If the database looks good, check the data. if not request.need_setup: installed_version = models.KegbotSite.get_installed_version() if installed_version is None: logger.warning("Kegbot not installed, sending to setup ...") request.need_setup = True else: request.installed_version_string = str(installed_version) if must_upgrade(installed_version, get_version_object()): logger.warning( "Kegbot upgrade required, sending to setup ...") request.need_upgrade = True # Lastly verify the kbsite record. if not request.need_setup: request.kbsite = models.KegbotSite.objects.get(name="default") if not request.kbsite.is_setup: logger.warning("Setup incomplete, sending to setup ...") request.need_setup = True return self.get_response(request)
def process_request(self, request): request.need_setup = False request.need_upgrade = False request.kbsite = None installed_version = models.KegbotSite.get_installed_version() if installed_version is None: request.need_setup = True else: request.installed_version_string = str(installed_version) request.need_upgrade = must_upgrade(installed_version, get_version_object()) if not request.need_setup and not request.need_upgrade: request.kbsite = models.KegbotSite.objects.get(name='default') if request.kbsite.is_setup: timezone.activate(request.kbsite.timezone) request.plugins = dict((p.get_short_name(), p) for p in plugin_util.get_plugins().values()) else: request.need_setup = True request.backend = get_kegbot_backend() return None