Esempio n. 1
0
    def test_checkin(self):
        site = models.KegbotSite.get()
        site.registration_id = 'original-regid'
        site.save()

        with patch('requests.post') as mock_post:
            mock_post.return_value = mock_response = Mock()

            mock_response.status_code = 200
            mock_response.json.return_value = {
                'status': 'ok',
                'reg_id': 'new-regid'
            }
            checkin.checkin('http://example.com/checkin', 'test-product', 1.23)
            mock_post.assert_called_with('http://example.com/checkin',
                headers={'User-Agent': 'KegbotServer/0.9.17-pre1'},
                data={
                    'reg_id': u'original-regid',
                    'product': 'test-product',
                    'version': get_version(),
                },
                timeout=1.23)

        site = models.KegbotSite.get()
        self.assertEquals('new-regid', site.registration_id)
Esempio n. 2
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!'
Esempio n. 3
0
def create_or_import(request):
    context = RequestContext(request)

    if request.method == 'GET':
        # Check for updates.
        try:
            context['checkin'] = checkin.checkin(timeout=3.0)
        except (checkin.CheckinError, Exception):
            context['checkin'] = {}

    form = CreateOrImportForm(initial={'mode': 'create'})
    if request.method == 'POST':
        form = CreateOrImportForm(request.POST)
        if form.is_valid():
            if form.cleaned_data['mode'] == 'create':
                try:
                    defaults.set_defaults()
                    messages.success(request, 'Started new site!')
                except defaults.AlreadyInstalledError:
                    messages.warning(request, 'Site already installed, proceeding.')
                return redirect('setup_site_settings')
            else:
                messages.error(request, 'Sorry, imports are not yet supported.')
    context['form'] = form
    print ' '.join(str(type(d)) for d in context.dicts)
    return render_to_response('setup_wizard/create_or_import.html', context_instance=context)
Esempio n. 4
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()

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

        print ''
        print 'Upgrade complete!'
Esempio n. 5
0
def core_checkin_task(self):
    from pykeg.core import checkin
    try:
        checkin.checkin()
    except checkin.CheckinError as exc:
        self.retry(exc=exc)
Esempio n. 6
0
def core_checkin(self):
    try:
        checkin.checkin()
    except checkin.CheckinError as exc:
        self.retry(exc=exc)
Esempio n. 7
0
def core_checkin_task(self):
    from pykeg.core import checkin
    try:
        checkin.checkin()
    except checkin.CheckinError as exc:
        self.retry(exc=exc)
Esempio n. 8
0
def core_checkin(self):
    try:
        checkin.checkin()
    except checkin.CheckinError as exc:
        self.retry(exc=exc)