Skip to content

Commit

Permalink
Merge pull request #225 from datosgobar/auto-index-metadata
Browse files Browse the repository at this point in the history
Indexación automática de metadatos
  • Loading branch information
poligarcia authored Mar 16, 2018
2 parents 9f6ff6c + f882516 commit 41c8f4d
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.core.management import BaseCommand
from pydatajson import DataJson

from series_tiempo_ar_api.apps.management.models import Node
from series_tiempo_ar_api.apps.metadata.indexer.metadata_indexer import MetadataIndexer


Expand All @@ -13,11 +14,17 @@
class Command(BaseCommand):

def add_arguments(self, parser):
parser.add_argument('datajson_url')
parser.add_argument('datajson_url', nargs='*')

def handle(self, *args, **options):
try:
data_json = DataJson(options['datajson_url'])
MetadataIndexer(data_json).index()
except Exception as e:
logger.exception(u'Error en la lectura del catálogo: %s', e)
if options['datajson_url']:
urls = options['datajson_url']
else:
urls = [node.catalog_url for node in Node.objects.filter(indexable=True)]

for url in urls:
try:
data_json = DataJson(url)
MetadataIndexer(data_json).index()
except Exception as e:
logger.exception(u'Error en la lectura del catálogo: %s', e)

0 comments on commit 41c8f4d

Please sign in to comment.