Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# oq-geoviewer
# Copyright (C) 2018-2019 GEM Foundation
#
# oq-geoviewer is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# oq-geoviewer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

# import subprocess
# from django.conf import settings
import os
from django.core.management import call_command
from openquake import gem_taxonomy_data
from django.core.management.base import BaseCommand


class Command(BaseCommand):
help = ("Standard command that will be runned by OpenQuake Engine 'install.py'"
" installer for each django application, if it exists.")

def handle(self, *args, **options):
data_path = os.path.join(os.path.dirname(gem_taxonomy_data.__file__), 'data')
data_file = os.listdir(data_path)[-1]
print("Data_file: [%s]" % data_file)
call_command('migrate', 'django_gem_taxonomy', 'zero')
call_command('migrate', 'django_gem_taxonomy')
call_command('taxonomy_load_standard', "--no-dump", os.path.join(data_path, data_file))
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ def add_arguments(self, parser):
parser.add_argument('json_filename')

# Optional arguments
# parser.add_argument(
# '-p', '--docker-project', nargs=1, help='docker project name',
# default='oqgeoviewer')
parser.add_argument(
'-n', '--no-dump', help='avoid create json files from DB'
, action='store_true', default=False)
# parser.add_argument(
# '-l', '--list', action='store_true', help='Show projects that need'
# ' maintenance')
Expand Down Expand Up @@ -134,9 +134,9 @@ def handle(self, *args, **options):
)

call_command('dumpdata', 'django_gem_taxonomy', indent=4,
output='out/taxonomy_standard_dump.json')
output='/tmp/taxonomy_standard_dump.json')

tax_dump_in = json.load(open('out/taxonomy_standard_dump.json', 'r'))
tax_dump_in = json.load(open('/tmp/taxonomy_standard_dump.json', 'r'))

tax = {}
for el in tax_dump_in:
Expand Down Expand Up @@ -225,5 +225,6 @@ def handle(self, *args, **options):

tax['param'] = copy.deepcopy(tax_json_in['Param'])

json.dump(tax, open('out/taxonomy_standard4taxtweb.json', 'w'),
indent=4)
if not options['no_dump']:
json.dump(tax, open('out/taxonomy_standard4taxtweb.json', 'w'),
indent=4)
2 changes: 1 addition & 1 deletion django_gem_taxonomy/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.4.3'
__version__ = '1.4.4'