Page MenuHomeDevCentral

D1205.id3092.diff
No OneTemporary

D1205.id3092.diff

diff --git a/pillar/top.sls b/pillar/top.sls
--- a/pillar/top.sls
+++ b/pillar/top.sls
@@ -18,3 +18,4 @@
- paas-jails.jails
- webserver-legacy.sites
- viperserv.bots
+ - viperserv.fantoir
diff --git a/pillar/viperserv/fantoir.sls b/pillar/viperserv/fantoir.sls
new file mode 100644
--- /dev/null
+++ b/pillar/viperserv/fantoir.sls
@@ -0,0 +1,12 @@
+# -------------------------------------------------------------
+# Salt — Deploy eggdrop park
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# Created: 2017-11-14
+# License: Trivial work, not eligible to copyright
+# ------------------------------------------------------------
+
+fantoir:
+ dataset_url: http://www.data.gouv.fr/fr/datasets/r/008e7b8f-f52c-4dc6-89ca-3bed2b103746
+ dataset_hash: 4915aead5c3901cb6808137217a94b1e14a8e3d5
+ distname: FANTOIR1017
diff --git a/roles/viperserv/fantoir/files/extract_streets.py b/roles/viperserv/fantoir/files/extract_streets.py
new file mode 100644
--- /dev/null
+++ b/roles/viperserv/fantoir/files/extract_streets.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python3
+
+# -------------------------------------------------------------
+# FANTOIR — Extract streets
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# Created: 2017-11-14
+# License: Trivial work, not eligible to copyright
+# Data license: FANTOIR is licensed under Licence Ouverte
+# -------------------------------------------------------------
+
+
+import sys
+
+
+def extract_streets(filename_source, filename_out):
+ with open(filename_out, 'w') as fd:
+ for line in open(filename_source, 'r'):
+ # Streets and other « voies » are the record where
+ # the 109th position (« type de voie ») is 1.
+ if len(line) < 109:
+ continue
+
+ if line[108] == "1":
+ fd.write(line)
+
+
+argc = len(sys.argv)
+if (argc != 3):
+ print("Usage: {} <FANTOIR filename> <street filename>".format(sys.argv[0]),
+ file=sys.stderr)
+ sys.exit(1)
+
+extract_streets(sys.argv[1], sys.argv[2])
diff --git a/roles/viperserv/fantoir/init.sls b/roles/viperserv/fantoir/init.sls
new file mode 100644
--- /dev/null
+++ b/roles/viperserv/fantoir/init.sls
@@ -0,0 +1,69 @@
+# -------------------------------------------------------------
+# Salt — Deploy eggdrop park
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# Created: 2017-11-14
+# License: Trivial work, not eligible to copyright
+# Data license: FANTOIR is licensed under Licence Ouverte
+# -------------------------------------------------------------
+
+# -------------------------------------------------------------
+# Data directories
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+/srv/viperserv/data:
+ file.directory:
+ - user: viperserv
+ - group: nasqueron-irc
+ - dir_mode: 770
+
+/srv/viperserv/data/dist:
+ file.directory:
+ - user: viperserv
+ - group: nasqueron-irc
+ - dir_mode: 770
+
+# -------------------------------------------------------------
+# Fetch and extract data
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+/srv/viperserv/data/dist/fantoir.zip:
+ file.managed:
+ - source: {{ pillar['fantoir']['dataset_url'] }}
+ - source_hash: {{ pillar['fantoir']['dataset_hash'] }}
+ - user: viperserv
+ - group: nasqueron-irc
+
+viperserv_fantoir_archive:
+ archive.extracted:
+ - name: /srv/viperserv/data
+ - source: /srv/viperserv/data/dist/fantoir.zip
+ - enforce_toplevel: False
+ - user: viperserv
+ - group: nasqueron-irc
+ - require:
+ - file: /srv/viperserv/data/dist/fantoir.zip
+
+/srv/viperserv/data/FANTOIR.txt:
+ file.symlink:
+ - target: /srv/viperserv/data/{{ pillar['fantoir']['distname'] }}
+ - user: viperserv
+ - group: nasqueron-irc
+ - require:
+ - archive: viperserv_fantoir_archive
+
+# -------------------------------------------------------------
+# Street data
+#
+# If the 109th character is "1", this is a 'voie'.
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+viperserv_fantoir_streets:
+ cmd.script:
+ - source: salt://roles/viperserv/fantoir/files/extract_streets.py
+ - args: FANTOIR.txt FANTOIR_STREETS.txt
+ - cwd: /srv/viperserv/data/
+ - creates: /srv/viperserv/data/FANTOIR_STREETS.txt
+ - runas: viperserv
+ - require:
+ - file: /srv/viperserv/data/FANTOIR.txt
diff --git a/roles/viperserv/init.sls b/roles/viperserv/init.sls
--- a/roles/viperserv/init.sls
+++ b/roles/viperserv/init.sls
@@ -18,3 +18,4 @@
include:
- .account
- .eggdrop
+ - .fantoir

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 27, 01:40 (11 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2264057
Default Alt Text
D1205.id3092.diff (4 KB)

Event Timeline