예제 #1
0
def server(bind='127.0.0.1', port=8000, migrate_cmd=False):
    if os.environ.get("RUN_MAIN") != "true":
        from cms.utils.compat.dj import get_user_model
        if DJANGO_1_6:
            from south.management.commands import syncdb, migrate
            if migrate_cmd:
                syncdb.Command().handle_noargs(interactive=False,
                                               verbosity=1,
                                               database='default')
                migrate.Command().handle(interactive=False, verbosity=1)
            else:
                syncdb.Command().handle_noargs(interactive=False,
                                               verbosity=1,
                                               database='default',
                                               migrate=False,
                                               migrate_all=True)
                migrate.Command().handle(interactive=False,
                                         verbosity=1,
                                         fake=True)
        else:
            call_command("migrate", database='default')
        User = get_user_model()
        if not User.objects.filter(is_superuser=True).exists():
            usr = User()

            if (User.USERNAME_FIELD != 'email'):
                setattr(usr, User.USERNAME_FIELD, 'admin')

            usr.email = '*****@*****.**'
            usr.set_password('admin')
            usr.is_superuser = True
            usr.is_staff = True
            usr.is_active = True
            usr.save()
            print('')
            print(
                "A admin user (username: admin, password: admin) has been created."
            )
            print('')
    from django.contrib.staticfiles.management.commands import runserver
    rs = runserver.Command()
    rs.stdout = sys.stdout
    rs.stderr = sys.stderr
    rs.use_ipv6 = False
    rs._raw_ipv6 = False
    rs.addr = bind
    rs.port = port
    autoreload.main(
        rs.inner_run, (), {
            'addrport': '%s:%s' % (bind, port),
            'insecure_serving': True,
            'use_threading': True
        })
예제 #2
0
  def InitialSetup(self):
    # syncdb
    self._RunCommand(syncdb.Command(), args=['--all', '--noinput', '-v', '0'])

    # migrate
    self._RunCommand(migrate.Command(), args=['--all', '--fake', '-v', '0'])

    # kb_set_defaults
    self._RunCommand(kb_set_defaults.Command(), args=['--force'])
예제 #3
0
    def handle(self, **options):
        self.do_epoch_upgrades()
        run(syncdb.Command(), args=['--noinput', '-v', '0'])
        run(migrate.Command(), args=['-v', '0'])
        run(kb_regen_stats.Command())
        run(collectstatic.Command(), args=['--noinput'])

        site = models.KegbotSite.get()
        site.epoch = EPOCH
        site.save()
예제 #4
0
    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!'
예제 #5
0
    def handle(self, **options):
        self.do_epoch_upgrades()
        run(syncdb.Command(), args=['--noinput', '-v', '0'])
        run(migrate.Command(), args=['-v', '0'])
        run(kb_regen_stats.Command())
        run(collectstatic.Command(), args=['--noinput'])

        site = models.KegbotSite.get()
        site.epoch = EPOCH
        site.server_version = get_version()
        site.save()

        # Refresh any news (since we have a new version).
        try:
            checkin.checkin(timeout=5.0, quiet=True)
        except (checkin.CheckinError, Exception) as e:
            pass

        print ''
        print 'Upgrade complete!'
예제 #6
0
 def handle(self, **options):
   run(syncdb.Command(), args=['--noinput', '-v', '0'])
   run(migrate.Command(), args=['-v', '0'])
   run(kb_regen_stats.Command())
   run(collectstatic.Command())