Commit e0778a0d0b04153d2203500d78f21cc55bd744a9
1 parent
14f36f55
Exists in
master
and in
4 other branches
New fake_lesia_names() command to rewrite tables
Showing
4 changed files
with
239 additions
and
5 deletions
Show diff stats
app/commands/commands.py
1 | +import csv | ||
2 | +import os | ||
1 | import sys | 3 | import sys |
2 | import click | 4 | import click |
3 | import random | 5 | import random |
@@ -15,24 +17,75 @@ from app.auth.models import User | @@ -15,24 +17,75 @@ from app.auth.models import User | ||
15 | from . import bp | 17 | from . import bp |
16 | 18 | ||
17 | 19 | ||
18 | -@bp.cli.command("lesia_to_csv") | ||
19 | -def lesia_to_csv(): | 20 | +@bp.cli.command("fake_lesia_names") |
21 | +def fake_lesia_names(): | ||
20 | """ | 22 | """ |
21 | - Extract some datas from lesia db to csv file for later db creation | ||
22 | - - agents | 23 | + Extract fake name from resources files to change names in db. |
24 | + Mainly after a lesia import, for confidential reasons | ||
25 | + | ||
26 | + Changes nams in tables: | ||
27 | + | ||
23 | - services | 28 | - services |
24 | - capacities | 29 | - capacities |
25 | - projects | 30 | - projects |
26 | :return: | 31 | :return: |
27 | """ | 32 | """ |
28 | 33 | ||
34 | + current_app.logger.info("Faking names from resources files") | ||
35 | + # get resources files | ||
36 | + # | ||
37 | + # 1- projects | ||
38 | + # | ||
39 | + fake_projects_file = os.path.join(current_app.config['PDC_RESOURCES_DIR'], 'fake-db-names', 'fake-projects.txt') | ||
40 | + with open(fake_projects_file, newline='') as csvfile: | ||
41 | + spamreader = csv.reader(csvfile, delimiter=';', quotechar='|') | ||
42 | + fake_projects_names = [', '.join(row) for row in spamreader] | ||
43 | + fake_projects_names_iterator = iter(fake_projects_names) | ||
44 | + | ||
45 | + # 2- functions/capacities | ||
46 | + # | ||
47 | + fake_capacities_file = os.path.join(current_app.config['PDC_RESOURCES_DIR'], 'fake-db-names', | ||
48 | + 'fake-capacities.txt') | ||
49 | + with open(fake_capacities_file, newline='') as csvfile: | ||
50 | + spamreader = csv.reader(csvfile, delimiter=';', quotechar='|') | ||
51 | + fake_capacities_names = [row for [row] in spamreader] | ||
52 | + fake_capacities_names_iterator = iter(fake_capacities_names) | ||
53 | + | ||
54 | + # 3- services | ||
55 | + # | ||
56 | + fake_services_file = os.path.join(current_app.config['PDC_RESOURCES_DIR'], 'fake-db-names', | ||
57 | + 'fake-services.txt') | ||
58 | + with open(fake_services_file, newline='') as csvfile: | ||
59 | + spamreader = csv.reader(csvfile, delimiter=';', quotechar='|') | ||
60 | + fake_services_names = [row for row in spamreader] | ||
61 | + fake_services_names_iterator = iter(fake_services_names) | ||
62 | + | ||
63 | + # Skip columns names | ||
64 | + # | ||
65 | + next(fake_projects_names_iterator) | ||
66 | + next(fake_capacities_names_iterator) | ||
67 | + next(fake_services_names_iterator) | ||
68 | + | ||
69 | + for s in Service.query.all(): | ||
70 | + next_service = next(fake_services_names_iterator) | ||
71 | + s.name = next_service[0] | ||
72 | + s.abbr = next_service[1] | ||
73 | + | ||
74 | + for p in Project.query.all(): | ||
75 | + p.name = next(fake_projects_names_iterator) | ||
76 | + | ||
77 | + for c in Capacity.query.all(): | ||
78 | + c.name = next(fake_capacities_names_iterator) | ||
79 | + | ||
80 | + db.session.commit() | ||
81 | + | ||
29 | 82 | ||
30 | @bp.cli.command("feed_from_lesia") | 83 | @bp.cli.command("feed_from_lesia") |
31 | def feed_from_lesia(): | 84 | def feed_from_lesia(): |
32 | """ | 85 | """ |
33 | Feed db with agents from a lesia like mysql database. | 86 | Feed db with agents from a lesia like mysql database. |
34 | 87 | ||
35 | - configure the proper database uri in the db_config.py file. | 88 | + Remember to configure the proper database uri in the db_config.py file. |
36 | """ | 89 | """ |
37 | from .lesia_db import lesia_agent, lesia_session, lesia_service, lesia_project, \ | 90 | from .lesia_db import lesia_agent, lesia_session, lesia_service, lesia_project, \ |
38 | lesia_fonction, lesia_periods, lesia_affectation | 91 | lesia_fonction, lesia_periods, lesia_affectation |
@@ -0,0 +1,60 @@ | @@ -0,0 +1,60 @@ | ||
1 | +name | ||
2 | +Acousticien | ||
3 | +Acousticienne | ||
4 | +Agente de maintenance du bâtiment | ||
5 | +Architecte | ||
6 | +Ascensoriste | ||
7 | +BIM Manager | ||
8 | +Canalisatrice | ||
9 | +Carreleuse | ||
10 | +Charpentière bois | ||
11 | +Charpentière métallique | ||
12 | +Cheffe de chantier | ||
13 | +Coffreuse-boiseuse | ||
14 | +Conductrice d'engins de BTP | ||
15 | +Conductrice de travaux | ||
16 | +Constructrice de route | ||
17 | +Couvreuse | ||
18 | +Dessinatrice en bâtiment | ||
19 | +Diagnostiqueuse immobilier | ||
20 | +Domoticienne | ||
21 | +Echafaudeuse | ||
22 | +Electricienne du bâtiment | ||
23 | +Etanchéiste | ||
24 | +Façadière | ||
25 | +Foreur | ||
26 | +Géomaticien | ||
27 | +Géomètre Expert | ||
28 | +Géomètre topographe | ||
29 | +Grutier | ||
30 | +Grutière | ||
31 | +Ingénieure en efficacité énergétique | ||
32 | +Installatrice de panneaux solaires | ||
33 | +Maçonne | ||
34 | +Matiériste - coloriste | ||
35 | +Mécanicienne d'engins de chantier | ||
36 | +Menuisier | ||
37 | +Menuisière | ||
38 | +Métreuse vérificatrice | ||
39 | +Miroitière | ||
40 | +Monteur en installations sanitaires | ||
41 | +Monteur en installations thermiques | ||
42 | +Monteur levageuse | ||
43 | +Monteuse levageuse | ||
44 | +Opérateur de démolition | ||
45 | +Parqueteur | ||
46 | +Parqueteuse | ||
47 | +Peintre en bâtiment | ||
48 | +Peintre en décors | ||
49 | +Piscinière | ||
50 | +Plaquiste | ||
51 | +Plaquiste Bois | ||
52 | +Plâtrière | ||
53 | +Plombière | ||
54 | +Plongeur professionnel | ||
55 | +Serrurière metallière | ||
56 | +Solière-moquettiste | ||
57 | +Staffeuse ornemaniste | ||
58 | +Terrassier | ||
59 | +Tourneur Fraiseur | ||
60 | +Urbaniste |
@@ -0,0 +1,103 @@ | @@ -0,0 +1,103 @@ | ||
1 | +name; town | ||
2 | +Réservoir de Gaz Naturel Liquéfié (GNL); GRAIN | ||
3 | +Autoroute de Bogota-Girardot; BOGOTA | ||
4 | +Station de traitement d'eau potable de Bakheng; PHNOM PENH | ||
5 | +Barrage de Sambangalou; SAMBANGALOU | ||
6 | +Nouveau Terminal à l'Aéroport de Sihanoukville; SIHANOUKVILLE | ||
7 | +Ligne Ferroviaire Lyon-Turin; AVRIEUX | ||
8 | +Ligne 18, Massy-Palaiseau / Saint-Aubin, Grand Paris Express; MASSY-PALAISEAU | ||
9 | +Ligne 18, Orly / Massy-Palaiseau, Grand Paris Express; ORLY | ||
10 | +Rénovation et extension de l’aéroport Nikola Tesla; BELGRADE | ||
11 | +Old Oak Common Station; LONDRES | ||
12 | +High Speed 2 (HS2); BIRMINGHAM | ||
13 | +Liaison routière I-64 / Hampton Road Bridge Tunnel; HAMPTON | ||
14 | +Extension de la ligne de la Confédération; OTTAWA | ||
15 | +Smart Motorways M4, M5 et M6; ROYAUME-UNI | ||
16 | +City Rail Link; AUCKLAND | ||
17 | +Station d’épuration de Nhieu Loc-Thi Nghe; NOUVEAU | ||
18 | +Station de transfert d’énergie par pompage; ABDELMOUMEN | ||
19 | +Métro, ligne M4 (Sydhavn); COPENHAGUE | ||
20 | +Station de traitement Chamkar Mon; PHNOM PENH | ||
21 | +Ligne 15 sud et ligne 14 sud du Grand Paris Express; PARIS | ||
22 | +Rijnlandroute; KATWIJK | ||
23 | +Extension du port; KINGSTON | ||
24 | +Rénovation de l’hôtel Mandarin Oriental; LONDRES | ||
25 | +Eole Gare CNIT - La Défense; NANTERRE | ||
26 | +Aéroport international Arturo Merino Benítez; SANTIAGO | ||
27 | +Nouvelle Route du Littoral; SAINT-DENIS-LA GRANDE CHALOUPE | ||
28 | +Yamal LNG; SABETTA | ||
29 | +Enceinte de confinement de Tchernobyl; TCHERNOBYL | ||
30 | +Lee Tunnel; LONDRES | ||
31 | +Pont de l'Atlantique; COLÓN | ||
32 | +Tunnel du Femern; PUTTGARDEN-RØDBYHAVN | ||
33 | +Ohio River Bridges - East End Crossing; LOUISVILLE | ||
34 | +Tours Jesselton; KOTA KINABALU | ||
35 | +Projet GATE; ROTTERDAM | ||
36 | +Pont Rion-Antirion; RÍO-ANTIRION | ||
37 | +Métro du Caire, lignes 1, 2 et 3; LE CAIRE | ||
38 | +Liaison ferroviaire du Liefkenshoek; ANVERS | ||
39 | +Wheatstone project; ONSLOW | ||
40 | +2ème Coentunnel; AMSTERDAM | ||
41 | +Tideway East; LONDRES | ||
42 | +Nouveau barrage d'Assiout; ASSIOUT | ||
43 | +Crossrail C510 & C512; LONDRES | ||
44 | +Aéroports internationaux du Cambodge; PHNOM PENH ET SIEM REAP | ||
45 | +New Orbital Highway; DOHA | ||
46 | +Viaduc de la Grande Ravine; LES TROIS-BASSINS | ||
47 | +Pont Vasco de Gama; LISBONNE | ||
48 | +Pont de la Confédération; BORDEN-CARLETON/CAP-TOURMENTIN | ||
49 | +Métro léger (LRT); LUSAIL | ||
50 | +Costa Azul LNG terminal; ENSENADA | ||
51 | +Tunnels ferroviaires d'Hallandsås; SKOTTORP - FÖRSLÖV | ||
52 | +Installations hydrauliques; KINGSTON-LUCEA-MONTEGO BAY-MONA & HOPE-BOGUE | ||
53 | +Tunnel de Shieldhall; GLASGOW | ||
54 | +Tour Menara Hap Seng - Plaza Shell; KOTA KINABALU | ||
55 | +Lusail Car Park; LUSAIL | ||
56 | +Tour Odéon; MONACO | ||
57 | +Tunnels du terminal 5 de l'aéroport d'Heathrow; LONDRES | ||
58 | +Hôtel Hilton Opéra; HANOÏ | ||
59 | +Cinéma Achgabat; ACHGABAT | ||
60 | +Sheraton Park Project; DOHA | ||
61 | +Stade olympique Atatürk; ISTANBUL | ||
62 | +Métro d'Athènes, lignes 2 et 3; ATHÈNES | ||
63 | +Aménagement du Grand Louvre; PARIS | ||
64 | +Réservoirs de gaz naturel liquéfié; RAS LAFFAN | ||
65 | +Métro, ligne "rouge sud"; DOHA | ||
66 | +Tunnel de Mitholz; BERNE | ||
67 | +Second pont sur l'estuaire de la Severn; SEVERN BEACH | ||
68 | +Métro Shatin to Central Link; HONG KONG | ||
69 | +Autoroute EKPPT, ELEFSINA, CORINTHE, PATRAS, PYRGOS; TSAKONA | ||
70 | +Tunnel de Soumagne; SOUMAGNE | ||
71 | +Channel Tunnel Rail Link (HS1); LONDRES | ||
72 | +Pont de Normandie; LE HAVRE - HONFLEUR | ||
73 | +Pont de Kincardine (Clackmannanshire Bridge); KINCARDINE | ||
74 | +Ligne à grande vitesse Sud Europe Atlantique; TOURS-BORDEAUX | ||
75 | +Port 2000; LE HAVRE | ||
76 | +Barrage de Naga Hammadi; NAG HAMMADI | ||
77 | +Projet ITER; CADARACHE | ||
78 | +Hôtel Four Seasons de Prague; PRAGUE | ||
79 | +Banque européenne d'investissement; LUXEMBOURG | ||
80 | +Duplex A86; RUEIL-MALMAISON - VÉLIZY | ||
81 | +Autoroute M11; MOSCOU - SAINT-PÉTERSBOURG | ||
82 | +Autoroute A28; ÉCOMMOY - TOURS | ||
83 | +Autoroute A19; ARTENAY - COURTENAY | ||
84 | +Autoroute A11; ANGERS | ||
85 | +Ambassade de France; JAKARTA | ||
86 | +Berjaya Central Park; KUALA LUMPUR | ||
87 | +Stade de France; SAINT-DENIS | ||
88 | +Lesotho Highlands Water Project; LESOTHO | ||
89 | +Système de traitement des eaux usées; SAN JOSE DE OCOA ET SAN CRISTOBAL | ||
90 | +Tunnels d'accès à la mine; EL TENIENTE | ||
91 | +Usine d’eau potable de la Jouve; SORGUES | ||
92 | +Exona, centre de traitement des eaux usées du SIARCE; CORBEIL-ESSONNES | ||
93 | +Station d'épuration Marne Aval; NOISY-LE-GRAND | ||
94 | +Projet d’amélioration de l’alimentation en eau potable; FAISALABAD | ||
95 | +Station d'épuration de Bruxelles-Sud; BRUXELLES | ||
96 | +Station d’épuration de Campo dell’oro; AJACCIO | ||
97 | +Réhabilitation et extension de la station de traitement d'eau potable; KANTALE | ||
98 | +Stade Olympique "Nid d'oiseau"; PÉKIN | ||
99 | +Station de traitement d’eau; NIROTH | ||
100 | +Station d'épuration; CORK | ||
101 | +Centrale thermique d'Hub River; KARACHI | ||
102 | +Station de pompage PS70; DOHA | ||
103 | +Grand port maritime de La Réunion; LE PORT |
@@ -0,0 +1,18 @@ | @@ -0,0 +1,18 @@ | ||
1 | +name; abbr | ||
2 | +Service Comptabilité et Finances; SCF | ||
3 | +Département Recherche et Développement; DRD | ||
4 | +Ressources Humaines; RH | ||
5 | +Département Production; DP | ||
6 | +Département Marketing et Vente; DMV | ||
7 | +Service Achats; SA | ||
8 | +Direction et Administration Générale; DAG | ||
9 | +Service Logistique; SL | ||
10 | +Service Techniques; ST | ||
11 | +Service Commercial; SC | ||
12 | +Service de Sécurité; SS | ||
13 | +Service Informatique Géographique; SIG | ||
14 | +Service Informatique Développements; SID | ||
15 | +Service Informatique Terrain; SIT | ||
16 | +Département Formation; DF | ||
17 | +Cellule Prévention des Risques; CPR | ||
18 | +Cellule Qualité; CQ |