Beispiel #1
0
    def test_local_storage_detection_helper(self):
        staticfiles_storage = storage.staticfiles_storage
        try:
            storage.staticfiles_storage._wrapped = empty
            with override_settings(
                    STATICFILES_STORAGE=
                    'django.contrib.staticfiles.storage.StaticFilesStorage'):
                command = collectstatic.Command()
                self.assertTrue(command.is_local_storage())

            storage.staticfiles_storage._wrapped = empty
            with override_settings(
                    STATICFILES_STORAGE='staticfiles_tests.storage.DummyStorage'
            ):
                command = collectstatic.Command()
                self.assertFalse(command.is_local_storage())

            collectstatic.staticfiles_storage = storage.FileSystemStorage()
            command = collectstatic.Command()
            self.assertTrue(command.is_local_storage())

            collectstatic.staticfiles_storage = DummyStorage()
            command = collectstatic.Command()
            self.assertFalse(command.is_local_storage())
        finally:
            staticfiles_storage._wrapped = empty
            collectstatic.staticfiles_storage = staticfiles_storage
            storage.staticfiles_storage = staticfiles_storage
Beispiel #2
0
 def test_collect_static_files_subclass_of_static_storage(self):
     collectstatic.Command().execute(**self.command_params)
     test_file = os.path.join(settings.STATIC_ROOT, "test.txt")
     test_dir = os.path.join(settings.STATIC_ROOT, "subdir")
     file_mode = os.stat(test_file)[0] & 0o777
     dir_mode = os.stat(test_dir)[0] & 0o777
     self.assertEqual(file_mode, 0o640)
     self.assertEqual(dir_mode, 0o740)
Beispiel #3
0
 def test_collect_static_files_default_permissions(self):
     collectstatic.Command().execute(**self.command_params)
     test_file = os.path.join(settings.STATIC_ROOT, "test.txt")
     test_dir = os.path.join(settings.STATIC_ROOT, "subdir")
     file_mode = os.stat(test_file)[0] & 0o777
     dir_mode = os.stat(test_dir)[0] & 0o777
     self.assertEqual(file_mode, 0o666 & ~self.umask)
     self.assertEqual(dir_mode, 0o777 & ~self.umask)
Beispiel #4
0
    def setUp(self):
        self.STATIC_ROOT = mkdtemp()
        self.NPM_ROOT_PATH = mkdtemp()
        self.cmd = collectstatic.Command()

        # Required when using django-npm's 'npm.finders.NpmFinder'
        # in settings.STATICFILES_FINDERS:
        mkdir(path.join(self.NPM_ROOT_PATH, 'node_modules'))
Beispiel #5
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("(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!")
Beispiel #6
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()
Beispiel #7
0
    def setup_static_assets(self, delete=False):
        if delete:
            os.remove(STATIC_CONFIG)
            return

        # get the static assets to setup proj and create static dir
        management.call_command(collectstatic.Command(), verbosity=0)
        # place the IIS conf file in the static dir
        with open(STATIC_CONFIG, 'w') as f:
            f.write(STATIC_CONFIG_STRING)
Beispiel #8
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!'
Beispiel #9
0
 def __call__(self, request):
     try:
         # Enable verbosity to display more information, leave other options to default.
         result = collectstatic.Command().handle(
             interactive=False,
             verbosity=True,
             link=False,
             clear=False,
             dry_run=False,
             ignore_patterns=[],
             use_default_ignore_patterns=True,
             post_process=False)
         return result
     except CommandError as e:
         raise WebCommand.Failed(str(e))
Beispiel #10
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!'
Beispiel #11
0
 def collectstatic(self, clear):
     args = ['', 'collectstatic', '--noinput']
     clear and args.append('--clear')
     collectstatic.Command().run_from_argv(args)
Beispiel #12
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())
Beispiel #13
0
 def setUp(self):
     self.STATIC_ROOT = mkdtemp()
     self.cmd = collectstatic.Command()