Ejemplo 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)
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
    def handle(self, *args, **options):
        self.set_verbosity(int(options['verbosity']))
        start_time = time.time()

        date = datetime.date.today()
        datestr = date.strftime('%Y-%m-%d')
        success = import_borme_download(datestr,
                                        datestr,
                                        local_only=options['local_only'])

        if success:
            update_previous_xml(date)

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

        # Update Full Text Search
        # psql_update_documents()

        # Elapsed time
        elapsed_time = time.time() - start_time
        print('\nElapsed time: %.2f seconds' % elapsed_time)
Ejemplo n.º 4
0
 def handle(self, *args, **options):
     config = Config.objects.first()
     version = get_git_revision_short_hash()
     print(version)
     if config:
         config.version = version
     else:
         date = timezone.make_aware(timezone.datetime(2000, 1, 1))
         config = Config(version=version, last_modified=date)
     config.save()
Ejemplo n.º 5
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)
Ejemplo n.º 6
0
    def handle(self, *args, **options):
        start_time = time.time()

        date = datetime.date.today()
        datestr = date.strftime('%Y-%m-%d')
        success = import_borme_download(datestr, datestr, local_only=options['local_only'])
        if success:
            update_previous_xml(date)

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

        # Elapsed time
        elapsed_time = time.time() - start_time
        print('\nElapsed time: %.2f seconds' % elapsed_time)
Ejemplo n.º 7
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)
Ejemplo n.º 8
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)
Ejemplo n.º 9
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)