Skip to content

Commit

Permalink
automatic update script
Browse files Browse the repository at this point in the history
  • Loading branch information
davidvlaminck committed Jun 11, 2024
1 parent 1fd48fa commit 8ab2621
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions model_update/automatic_update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import logging
import urllib.request
from pathlib import Path
from subprocess import Popen, PIPE

from otlmow_modelbuilder.ModelBuilder import ModelBuilder
from otlmow_modelbuilder.OSLOInMemoryCreator import OSLOInMemoryCreator

from model_update.ModelUpdater import ModelUpdater

logging.basicConfig(level=logging.INFO, format='%(message)s')

urllib.request.urlretrieve("https://github.com/davidvlaminck/OTLMOW-ModelBuilder/raw/master/otlmow_modelbuilder"
"/InputFiles/latest/OTL.db", 'OTL.db')
urllib.request.urlretrieve("https://github.com/davidvlaminck/OTLMOW-ModelBuilder/raw/master/otlmow_modelbuilder"
"/InputFiles/latest/Geometrie_Artefact.db", 'Geometrie_Artefact.db')
urllib.request.urlretrieve("https://github.com/davidvlaminck/OTLMOW-ModelBuilder/raw/master/otlmow_modelbuilder"
"/settings_otlmow_modelbuilder.json", 'settings_otlmow_modelbuilder.json')

current_dir = Path(__file__).parent
otl_subset_path = Path(current_dir / 'OTL.db')
GA_file_path = Path(current_dir / 'Geometrie_Artefact.db')
model_directory = Path(current_dir.parent / 'otlmow_model')
settings_path = Path(current_dir / 'settings_otlmow_modelbuilder.json')

with OSLOInMemoryCreator(otl_subset_path) as memory_creator:
version = memory_creator.get_otl_version()

ModelBuilder.build_otl_datamodel(otl_subset_location=otl_subset_path, geometry_artefact_location=GA_file_path,
directory=model_directory, settings_path=settings_path,
environment='prd')

cmd = "git add ./../otlmow_model/OtlmowModel"
p = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True)
stdout, stderr = p.communicate()

updater = ModelUpdater(github_root=current_dir.parent)
enums_updated = updater.find_changed_enums()
updater.update_model(otl_version=version, created_by='david.vlaminck', enums_updated=enums_updated)

0 comments on commit 8ab2621

Please sign in to comment.