Skip to content

Commit

Permalink
update: install_db.sh => update TAXREF version + add makefile + fix b…
Browse files Browse the repository at this point in the history
…abel config
  • Loading branch information
juggler31 committed Sep 25, 2024
1 parent 6993f2d commit 2fc70e8
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 3 deletions.
54 changes: 54 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
-include Makefile.perso.mk

###########################
# colors #
###########################
PRINT_COLOR = printf
COLOR_SUCCESS = \033[1;32m
COLOR_DEBUG = \033[36m
COLOR_RESET = \033[0m

###########################
# Virtual env #
###########################

ACTIVATE_VENV:=. venv/bin/activate

###########################
# Run project #
###########################

.PHONY: serve
serve:
$(call display_cmd, "Start serve")
$(ACTIVATE_VENV) && flask --app ./atlas/app run --debug -h 0.0.0.0

###########################
# Check code #
###########################

.PHONY: flake8
flake8:
$(call display_cmd, "Check with flake8")
$(ACTIVATE_VENV) && pip install flake8 && flake8 atlas

###########################
# Manage translations #
###########################

.PHONY: messages
messages:
$(call display_cmd, "Extract translations")
$(ACTIVATE_VENV) && pybabel extract -F atlas/babel.cfg -o messages.pot atlas
$(ACTIVATE_VENV) && pybabel update -i messages.pot -d atlas/translations

.PHONY: compile_messages
compile_messages:
$(call display_cmd, "Apply translations")
$(ACTIVATE_VENV) && pybabel compile -d atlas/translations

define display_cmd
@$(PRINT_COLOR) "\n$(COLOR_SUCCESS) ################# $(COLOR_RESET)\n"
@$(PRINT_COLOR) "$(COLOR_SUCCESS) ### Test $(1) $(COLOR_RESET)\n"
@$(PRINT_COLOR) "\n$(COLOR_SUCCESS) ################# $(COLOR_RESET)\n\n"
endef
1 change: 0 additions & 1 deletion atlas/babel.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[python: **.py]
[jinja2: **/templates/**/**.html]
[jinja2: **/static/custom/templates/**.sample]
extensions=jinja2.ext.autoescape,jinja2.ext.with_
4 changes: 2 additions & 2 deletions install_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ if ! database_exists $db_name
# EN: Import of the shape of the communes ($communes_shp) in the DB (if parameter import_commune_shp = TRUE) / atlas.l_communes
if $import_commune_shp
then
ogr2ogr -f "ESRI Shapefile" -t_srs EPSG:4326 ./data/ref/communes_4326.shp $communes_shp
ogr2ogr -f "ESRI Shapefile" -t_srs EPSG:4326 ./data/ref/communes_4326.shp $communes_shp
sudo -u postgres -s shp2pgsql -W "LATIN1" -s 4326 -D -I ./data/ref/communes_4326.shp atlas.l_communes | sudo -n -u postgres -s psql -d $db_name &>> log/install_db.log
sudo -u postgres -s psql -d $db_name -c "ALTER TABLE atlas.l_communes RENAME COLUMN "$colonne_nom_commune" TO commune_maj;" &>> log/install_db.log
sudo -u postgres -s psql -d $db_name -c "ALTER TABLE atlas.l_communes RENAME COLUMN "$colonne_insee" TO insee;" &>> log/install_db.log
Expand Down Expand Up @@ -232,7 +232,7 @@ if ! database_exists $db_name
then
wget https://raw.githubusercontent.com/PnX-SI/TaxHub/$taxhub_release/data/inpn/data_inpn_taxhub.sql -P /tmp/taxhub

array=( TAXREF_INPN_v11.zip ESPECES_REGLEMENTEES_v11.zip LR_FRANCE_20160000.zip )
array=( TAXREF_v14_2020.zip BDC-Statuts-v14.zip ESPECES_REGLEMENTEES_v11.zip LR_FRANCE_20160000.zip )
for i in "${array[@]}"
do
if [ ! -f '/tmp/taxhub/'$i ]
Expand Down

0 comments on commit 2fc70e8

Please sign in to comment.