Skip to content

Commit 5b8fc36

Browse files
committed
Switch from python module to install to module to run
1 parent ad7ce15 commit 5b8fc36

File tree

7 files changed

+54
-45
lines changed

7 files changed

+54
-45
lines changed

README.md

+20-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ Il faut pour alimenter la base OSM locale dans laquelle puise BANO :
2222

2323
Autres outils : parallel.
2424

25+
## Installation
26+
27+
Mettre en place un environnement virtuel python :
28+
```
29+
virtualenv venv
30+
source venv/bin/activate
31+
pip install -r requirements.txt
32+
```
33+
2534
## Configuration
2635

2736
Première étape avant de lancer les chargements de données : il faut adapter le fichier `config` à votre environnement, en déclarant différents chemins. Ce fichier est utilisé en début de plusieurs scripts pour connaître le chemin de différents répertoires.
@@ -55,6 +64,16 @@ load_osm_france_db.sh http://download.openstreetmap.fr/extracts/europe/france/fr
5564

5665
## Utilisation
5766

58-
Pour connaître les commandes du module bano : `bano --help`.
67+
### Commande `bano`
68+
69+
Activer l'environnement virtuel python (si pas déjà activé) :
70+
```
71+
source venv/bin/activate
72+
```
73+
74+
Pour connaître les commandes du module bano :
75+
```
76+
python -m bano --help
77+
```
5978

6079
Quasiment toutes les options sont utilisées dans le script `cron_bano`.

bano/__init__.py

Whitespace-only changes.

bano/bin.py renamed to bano/__main__.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def main():
3434

3535
subparser = subparsers.add_parser(
3636
"process_commune_lieux-dits",
37-
help="Traite unitairement les lieux-dits d'une commune",
37+
help="Traite unitairement les lieux-dits d'une commune",
3838
description="Traite unitairement les lieux-dits d'une commune"
3939
)
4040
group = subparser.add_mutually_exclusive_group(required=True)
@@ -54,7 +54,7 @@ def main():
5454

5555
subparser = subparsers.add_parser(
5656
"ban2fantoir",
57-
help="Ajoute dans FANTOIR des libellés BAN",
57+
help="Ajoute dans FANTOIR des libellés BAN",
5858
description="Ajoute dans FANTOIR des libellés BAN"
5959
)
6060
subparser.add_argument(
@@ -205,3 +205,7 @@ def main():
205205
import ipdb
206206

207207
ipdb.set_trace()
208+
209+
210+
if __name__ == "__main__":
211+
main()

cron_bano.sh

+23-22
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@ source config
1212

1313
./arborescence.sh
1414

15-
pip install -e .
15+
16+
bano="python -m bano"
1617

1718
# Sources
18-
cat deplist.txt | parallel -j 4 export LANG=$LANG\; bano download_bal CADASTRE {1}
19-
cat deplist.txt | parallel -j 4 export LANG=$LANG\; bano download_bal BAL {1}
20-
cat deplist.txt | parallel -j 4 export LANG=$LANG\; bano download_ban {1}
21-
cat deplist.txt | parallel -j 4 export LANG=$LANG\; bano download_cadastre lieux_dits {1}
22-
# bano update_code_cadastre
23-
bano download_commune_summary
24-
bano update_bis_table
25-
bano remove_chars_in_ban
19+
cat deplist.txt | parallel -j 4 export LANG=$LANG\; $bano download_bal CADASTRE {1}
20+
cat deplist.txt | parallel -j 4 export LANG=$LANG\; $bano download_bal BAL {1}
21+
cat deplist.txt | parallel -j 4 export LANG=$LANG\; $bano download_ban {1}
22+
cat deplist.txt | parallel -j 4 export LANG=$LANG\; $bano download_cadastre lieux_dits {1}
23+
# $bano update_code_cadastre
24+
$bano download_commune_summary
25+
$bano update_bis_table
26+
$bano remove_chars_in_ban
2627
./copy_table_from_osm_to_cadastre.sh rep_b_as_bis
2728

2829

@@ -31,17 +32,17 @@ bano remove_chars_in_ban
3132
# le reste de la semaine, ciblage des communes ayant eu des modifs dans OSM dans les dernières 24h
3233
if [ `date +%u` -eq 7 ]
3334
then
34-
bano update_insee_lists
35-
cat insee_locales.csv | parallel -j 4 export LANG=$LANG\; bano process_commune BAL --code_insee {1}
36-
cat deplist.txt | parallel -j 4 export LANG=$LANG\; bano process_commune BAN --depts {1}
37-
cat deplist.txt | parallel -j 4 export LANG=$LANG\; bano process_commune OSM --depts {1}
38-
cat deplist.txt | parallel -j 4 export LANG=$LANG\; bano process_commune_lieux-dits --depts {1}
35+
$bano update_insee_lists
36+
cat insee_locales.csv | parallel -j 4 export LANG=$LANG\; $bano process_commune BAL --code_insee {1}
37+
cat deplist.txt | parallel -j 4 export LANG=$LANG\; $bano process_commune BAN --depts {1}
38+
cat deplist.txt | parallel -j 4 export LANG=$LANG\; $bano process_commune OSM --depts {1}
39+
cat deplist.txt | parallel -j 4 export LANG=$LANG\; $bano process_commune_lieux-dits --depts {1}
3940
else
40-
bano update_insee_lists
41-
cat insee_locales.csv | parallel -j 4 export LANG=$LANG\; bano process_commune BAL --code_insee {1}
42-
cat insee_osm.csv | parallel -j 4 export LANG=$LANG\; bano process_commune BAN --code_insee {1}
43-
cat insee_osm.csv | parallel -j 4 export LANG=$LANG\; bano process_commune OSM --code_insee {1}
44-
cat deplist.txt | parallel -j 4 export LANG=$LANG\; bano process_commune_lieux-dits --depts {1}
41+
$bano update_insee_lists
42+
cat insee_locales.csv | parallel -j 4 export LANG=$LANG\; $bano process_commune BAL --code_insee {1}
43+
cat insee_osm.csv | parallel -j 4 export LANG=$LANG\; $bano process_commune BAN --code_insee {1}
44+
cat insee_osm.csv | parallel -j 4 export LANG=$LANG\; $bano process_commune OSM --code_insee {1}
45+
cat deplist.txt | parallel -j 4 export LANG=$LANG\; $bano process_commune_lieux-dits --depts {1}
4546
fi
4647

4748
# Mise à jour quotidienne dans la base cadastre des couches des polygones postaux d'OSM et des statuts admin de communes en vue des exports
@@ -58,11 +59,11 @@ $pgsql_OSM -f sql/create_table_polygones_postaux.sql
5859
$pgsql_CADASTRE -f sql/post_copie_ban_odbl.sql
5960

6061
# exports
61-
cat deplist.txt | parallel -j 4 bano export {1}
62+
cat deplist.txt | parallel -j 4 $bano export {1}
6263

6364
# copie+zip dans le dossier web
64-
cat deplist.txt | parallel -j 4 bano publish {1}
65-
bano publish_aggregate
65+
cat deplist.txt | parallel -j 4 $bano publish {1}
66+
$bano publish_aggregate
6667

6768
# ménage PostgreSQL
6869
$pgsql_CADASTRE -c "VACUUM cumul_adresses;"

requirements.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
beautifulsoup4==4.6.3
2+
psycopg2-binary==2.9.3
3+
requests==2.21.0
4+
lxml
5+
ipdb==0.13.9

setup.cfg

-18
This file was deleted.

setup.py

-2
This file was deleted.

0 commit comments

Comments
 (0)