Beispiel #1
0
    def handle(self, **options):
        if (not options['flush_rqdata'] and
            not options['flush_lru'] and
            not options['flush_django_cache'] and
            not options['flush_all']):
            raise CommandError("No options were provided. Use one of "
                               "--django-cache, --rqdata, --lru "
                               "or --all.")

        self.stdout.write('Flushing cache...')

        if options['flush_rqdata'] or options['flush_all']:
            # Flush all rq data, dirty counter and restore Pootle revision
            # value.
            r_con = get_redis_connection('redis')
            r_con.flushdb()
            self.stdout.write('RQ data removed.')
            Revision.set(Unit.max_revision())
            self.stdout.write('Max unit revision restored.')

        if options['flush_django_cache'] or options['flush_all']:
            r_con = get_redis_connection('default')
            r_con.flushdb()
            self.stdout.write('All default Django cache data removed.')

        if options['flush_lru'] or options['flush_all']:
            r_con = get_redis_connection('lru')
            r_con.flushdb()
            self.stdout.write('All lru cache data removed.')
Beispiel #2
0
    def handle(self, **options):
        if (not options['flush_stats'] and not options['flush_rqdata']
                and not options['flush_django_cache']
                and not options['flush_all']):
            raise CommandError("No options were provided. Use one of "
                               "--django-cache, --rqdata, --stats or --all.")

        self.stdout.write('Flushing cache...')

        if options['flush_stats'] or options['flush_all']:
            # Delete all stats cache data.
            r_con = get_redis_connection('stats')
            r_con.flushdb()
            self.stdout.write('All stats data removed.')

        if options['flush_rqdata'] or options['flush_all']:
            # Flush all rq data, dirty counter and restore Pootle revision
            # value.
            r_con = get_redis_connection('redis')
            r_con.flushdb()
            self.stdout.write('RQ data removed.')
            Revision.set(Unit.max_revision())
            self.stdout.write('Max unit revision restored.')

        if options['flush_django_cache'] or options['flush_all']:
            r_con = get_redis_connection('default')
            r_con.flushdb()
            self.stdout.write('All default Django cache data removed.')
Beispiel #3
0
    def handle(self, **options):
        if (not options['flush_rqdata'] and not options['flush_lru']
                and not options['flush_django_cache']
                and not options['flush_all']):
            raise CommandError("No options were provided. Use one of "
                               "--django-cache, --rqdata, --lru "
                               "or --all.")

        if options['flush_rqdata'] or options['flush_all']:
            if rq_workers_are_running():
                self.stdout.write("Nothing has been flushed. "
                                  "Stop RQ workers before running this "
                                  "command with --rqdata or --all option.")
                sys.exit()

        self.stdout.write('Flushing cache...')
        if options['flush_rqdata'] or options['flush_all']:
            # Flush all rq data, dirty counter and restore Pootle revision
            # value.
            r_con = get_redis_connection('redis')
            r_con.flushdb()
            self.stdout.write('RQ data removed.')
            Revision.set(Unit.max_revision())
            self.stdout.write('Max unit revision restored.')

        if options['flush_django_cache'] or options['flush_all']:
            r_con = get_redis_connection('default')
            r_con.flushdb()
            self.stdout.write('All default Django cache data removed.')

        if options['flush_lru'] or options['flush_all']:
            r_con = get_redis_connection('lru')
            r_con.flushdb()
            self.stdout.write('All lru cache data removed.')
Beispiel #4
0
    def setup_redis(self, revision=None):
        from pootle.core.models import Revision

        if revision is None:
            Revision.initialize(force=True)
        else:
            Revision.set(revision)
Beispiel #5
0
def fs_plugin_base(tutorial, tmpdir, settings, system, english, zulu):
    from django.core.cache import caches

    import pootle_fs_pytest

    from pootle.core.models import Revision
    from pootle_store.models import Unit

    caches["exports"].clear()

    Revision.set(Unit.max_revision())

    dir_path = str(tmpdir.dirpath())
    repo_path = os.path.join(dir_path, "__src__")
    src_path = os.path.abspath(
        os.path.join(
            os.path.dirname(pootle_fs_pytest.__file__),
            "data/fs/example_fs"))
    settings.POOTLE_FS_PATH = dir_path
    tutorial_path = os.path.join(dir_path, tutorial.code)
    if os.path.exists(tutorial_path):
        shutil.rmtree(tutorial_path)
    if os.path.exists(repo_path):
        shutil.rmtree(repo_path)
    return tutorial, src_path, repo_path, dir_path
Beispiel #6
0
    def handle_noargs(self, **options):
        if options["restore"]:
            from pootle_store.models import Unit

            Revision.set(Unit.max_revision())

        self.stdout.write("%s" % Revision.get())
Beispiel #7
0
    def handle(self, **options):
        if options["restore"]:
            from pootle_store.models import Unit

            Revision.set(Unit.max_revision())

        self.stdout.write("%s" % Revision.get())
Beispiel #8
0
def revision(request, clear_cache):
    """Sets up the cached revision counter for each test call."""
    from pootle.core.models import Revision
    from pootle_store.models import Unit

    if request.node.get_marker("django_db"):
        Revision.set(Unit.max_revision())
    else:
        Revision.initialize()
Beispiel #9
0
def fs_plugin_base(tutorial, tmpdir, settings, system, english, zulu):
    from django.core.cache import caches

    import pootle_fs_pytest

    from pootle.core.models import Revision
    from pootle_store.models import Unit

    caches["exports"].clear()

    Revision.set(Unit.max_revision())

    dir_path = str(tmpdir.dirpath())
    repo_path = os.path.join(dir_path, "__src__")
    src_path = os.path.abspath(
        os.path.join(os.path.dirname(pootle_fs_pytest.__file__),
                     "data/fs/example_fs"))
    settings.POOTLE_FS_PATH = dir_path
    tutorial_path = os.path.join(dir_path, tutorial.code)
    if os.path.exists(tutorial_path):
        shutil.rmtree(tutorial_path)
    if os.path.exists(repo_path):
        shutil.rmtree(repo_path)
    return tutorial, src_path, repo_path, dir_path
Beispiel #10
0
def revision(clear_cache):
    """Sets up the cached revision counter for each test call."""
    from pootle.core.models import Revision
    from pootle_store.models import Unit

    Revision.set(Unit.max_revision())
Beispiel #11
0
    def handle(self, **options):
        if options['restore']:
            from pootle_store.models import Unit
            Revision.set(Unit.max_revision())

        self.stdout.write('%s' % Revision.get())
Beispiel #12
0
    def handle_noargs(self, **options):
        if options['restore']:
            from pootle_store.models import Unit
            Revision.set(Unit.max_revision())

        self.stdout.write('%s' % Revision.get())