Esempio n. 1
0
    def handle(self, *args, **options):
        verbosity = int(options["verbosity"])
        if verbosity == 0:
            borme.importer.logger.setLevel(logging.ERROR)
        elif verbosity == 1:  # default
            borme.importer.logger.setLevel(logging.INFO)
        elif verbosity == 2:
            borme.importer.logger.setLevel(logging.INFO)
        elif verbosity > 2:
            borme.importer.logger.setLevel(logging.DEBUG)
        if verbosity > 2:
            logging.getLogger().setLevel(logging.DEBUG)
        start_time = time.time()

        if args:
            for filename in args:
                print(filename)
                import_borme_pdf(filename)

            config = Config.objects.first()
            if config:
                config.last_modified = timezone.now()
            else:
                config = Config(last_modified=timezone.now())
            config.version = get_git_revision_short_hash()
            config.save()

        # Elapsed time
        elapsed_time = time.time() - start_time
        print("\nElapsed time: %.2f seconds" % elapsed_time)
    def handle(self, *args, **options):
        verbosity = int(options['verbosity'])
        if verbosity == 0:
            borme.importer.logger.setLevel(logging.ERROR)
        elif verbosity == 1:  # default
            borme.importer.logger.setLevel(logging.INFO)
        elif verbosity == 2:
            borme.importer.logger.setLevel(logging.INFO)
        elif verbosity > 2:
            borme.importer.logger.setLevel(logging.DEBUG)
        if verbosity > 2:
            logging.getLogger().setLevel(logging.DEBUG)
        start_time = time.time()

        if args:
            for filename in args:
                print(filename)
                import_borme_pdf(filename)

            config = Config.objects.first()
            if config:
                config.last_modified = timezone.now()
            else:
                config = Config(last_modified=timezone.now())
            config.version = get_git_revision_short_hash()
            config.save()

        # Elapsed time
        elapsed_time = time.time() - start_time
        print('\nElapsed time: %.2f seconds' % elapsed_time)
Esempio n. 3
0
    def handle(self, *args, **options):
        start_time = time.time()

        import_borme_download(options['from'][0], options['to'][0], local_only=options['local_only'], no_missing=options['no_missing'])

        config = Config.objects.first()
        if config:
            config.last_modified = timezone.now()
        else:
            config = Config(last_modified=timezone.now())
        config.version = get_git_revision_short_hash()
        config.save()

        # Elapsed time
        elapsed_time = time.time() - start_time
        print('\nElapsed time: %.2f seconds' % elapsed_time)
Esempio n. 4
0
    def handle(self, *args, **options):
        start_time = time.time()

        import_borme_download(options['from'][0],
                              options['to'][0],
                              local_only=options['local_only'],
                              no_missing=options['no_missing'])

        config = Config.objects.first()
        if config:
            config.last_modified = timezone.now()
        else:
            config = Config(last_modified=timezone.now())
        config.version = get_git_revision_short_hash()
        config.save()

        # Elapsed time
        elapsed_time = time.time() - start_time
        print('\nElapsed time: %.2f seconds' % elapsed_time)
Esempio n. 5
0
    def handle(self, *args, **options):
        self.set_verbosity(int(options['verbosity']))
        start_time = time.time()

        for filename in options["files"]:
            print(filename)
            borme.parser.importer.from_json_file(filename)

        config = Config.objects.first()
        if config:
            config.last_modified = timezone.now()
        else:
            config = Config(last_modified=timezone.now())
        config.version = get_git_revision_short_hash()
        config.save()

        # Update Full Text Search
        # psql_update_documents()

        # Elapsed time
        elapsed_time = time.time() - start_time
        print('\nElapsed time: %.2f seconds' % elapsed_time)
Esempio n. 6
0
    def handle(self, *args, **options):
        self.set_verbosity(int(options['verbosity']))

        loop = asyncio.get_event_loop()
        start_time = time.time()
        
        q = asyncio.Queue()
        tasks = []
        for i in range(THREADS):
            task = asyncio.ensure_future((worker(q)))
            tasks.append(task)
            #t = ThreadConvertJSON(q)
            #t.setDaemon(True)
            #t.start()

        for filename in options["files"]:
            q.put_nowait((filename)) 

        #q.join()

        loop.run_until_complete(asyncio.gather(*tasks, return_exceptions=True))
        loop.close()
 
        config = Config.objects.first()
        if config:
            config.last_modified = timezone.now()
        else:
            config = Config(last_modified=timezone.now())
        config.version = get_git_revision_short_hash()
        config.save()

        # Update Full Text Search
        # psql_update_documents()

        # Elapsed time
        elapsed_time = time.time() - start_time
        print('\nElapsed time: %.2f seconds' % elapsed_time)