update 17/02/2022 - 16h30
parent
568014b522
commit
b5f8091a67
133
Log/log_file.log
133
Log/log_file.log
|
@ -142163,3 +142163,136 @@ INFO:werkzeug: * Restarting with stat
|
|||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 797-962-469
|
||||
INFO:werkzeug: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 797-962-469
|
||||
INFO:werkzeug: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
|
||||
INFO:werkzeug: * Detected change in 'C:\\Perso\\myclass.com\\Ela_back\\MySy_Back_Office\\class_mgt.py', reloading
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 797-962-469
|
||||
INFO:werkzeug: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
|
||||
INFO:werkzeug: * Detected change in 'C:\\Perso\\myclass.com\\Ela_back\\MySy_Back_Office\\class_mgt.py', reloading
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 797-962-469
|
||||
INFO:werkzeug: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
|
||||
INFO:werkzeug: * Detected change in 'C:\\Perso\\myclass.com\\Ela_back\\MySy_Back_Office\\main.py', reloading
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 797-962-469
|
||||
INFO:werkzeug: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
|
||||
INFO:werkzeug: * Detected change in 'C:\\Perso\\myclass.com\\Ela_back\\MySy_Back_Office\\class_mgt.py', reloading
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 797-962-469
|
||||
INFO:werkzeug: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
|
||||
INFO:werkzeug: * Detected change in 'C:\\Perso\\myclass.com\\Ela_back\\MySy_Back_Office\\class_mgt.py', reloading
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 797-962-469
|
||||
INFO:werkzeug: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
|
||||
INFO:werkzeug: * Detected change in 'C:\\Perso\\myclass.com\\Ela_back\\MySy_Back_Office\\class_mgt.py', reloading
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 797-962-469
|
||||
INFO:werkzeug: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
|
||||
INFO:root:2022-02-17 16:02:55.978715 : add_class_mass - La valeur 'token' n'est pas presente dans liste
|
||||
INFO:werkzeug:127.0.0.1 - - [17/Feb/2022 16:02:55] "POST /myclass/api/add_class_mass/ HTTP/1.1" 200 -
|
||||
INFO:root:2022-02-17 16:03:46.875216 : add_class_mass : entete du fichier csv. 'external_code.1' n'est pas acceptée
|
||||
INFO:werkzeug:127.0.0.1 - - [17/Feb/2022 16:03:46] "POST /myclass/api/add_class_mass/ HTTP/1.1" 200 -
|
||||
INFO:root:2022-02-17 16:04:59.785794 : add_class_mass - 'domaine'
|
||||
INFO:werkzeug:127.0.0.1 - - [17/Feb/2022 16:04:59] "POST /myclass/api/add_class_mass/ HTTP/1.1" 200 -
|
||||
INFO:root:2022-02-17 16:05:43.943204 : add_class_mass : entete du fichier csv. 'domaine' n'est pas acceptée
|
||||
INFO:werkzeug:127.0.0.1 - - [17/Feb/2022 16:05:43] "POST /myclass/api/add_class_mass/ HTTP/1.1" 200 -
|
||||
INFO:root:2022-02-17 16:05:49.657331 : add_class_mass : entete du fichier csv. 'domaine' n'est pas acceptée
|
||||
INFO:werkzeug:127.0.0.1 - - [17/Feb/2022 16:05:49] "POST /myclass/api/add_class_mass/ HTTP/1.1" 200 -
|
||||
INFO:werkzeug: * Detected change in 'C:\\Perso\\myclass.com\\Ela_back\\MySy_Back_Office\\class_mgt.py', reloading
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 797-962-469
|
||||
INFO:werkzeug: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
|
||||
INFO:werkzeug: * Detected change in 'C:\\Perso\\myclass.com\\Ela_back\\MySy_Back_Office\\class_mgt.py', reloading
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 797-962-469
|
||||
INFO:werkzeug: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
|
||||
INFO:root:2022-02-17 16:07:24.440763 : add_class - La valeur 'presentiel' n'est pas presente dans liste
|
||||
INFO:werkzeug:127.0.0.1 - - [17/Feb/2022 16:07:24] "POST /myclass/api/add_class_mass/ HTTP/1.1" 200 -
|
||||
INFO:werkzeug: * Detected change in 'C:\\Perso\\myclass.com\\Ela_back\\MySy_Back_Office\\class_mgt.py', reloading
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 797-962-469
|
||||
INFO:werkzeug: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
|
||||
INFO:werkzeug: * Detected change in 'C:\\Perso\\myclass.com\\Ela_back\\MySy_Back_Office\\class_mgt.py', reloading
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 797-962-469
|
||||
INFO:werkzeug: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
|
||||
INFO:werkzeug: * Detected change in 'C:\\Perso\\myclass.com\\Ela_back\\MySy_Back_Office\\class_mgt.py', reloading
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 797-962-469
|
||||
INFO:werkzeug: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
|
||||
INFO:root:2022-02-17 16:09:19.348996 : add_class - La valeur 'partner_mail' n'est pas presente dans liste
|
||||
INFO:werkzeug:127.0.0.1 - - [17/Feb/2022 16:09:19] "POST /myclass/api/add_class_mass/ HTTP/1.1" 200 -
|
||||
INFO:werkzeug: * Detected change in 'C:\\Perso\\myclass.com\\Ela_back\\MySy_Back_Office\\class_mgt.py', reloading
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 797-962-469
|
||||
INFO:werkzeug: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
|
||||
INFO:root:2022-02-17 16:10:04.121247 : add_class - 'token'
|
||||
INFO:werkzeug:127.0.0.1 - - [17/Feb/2022 16:10:04] "POST /myclass/api/add_class_mass/ HTTP/1.1" 200 -
|
||||
INFO:werkzeug: * Detected change in 'C:\\Perso\\myclass.com\\Ela_back\\MySy_Back_Office\\class_mgt.py', reloading
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 797-962-469
|
||||
INFO:werkzeug: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
|
||||
INFO:root:2022-02-17 16:10:47.779061 : add_class - 'token'
|
||||
INFO:werkzeug:127.0.0.1 - - [17/Feb/2022 16:10:47] "POST /myclass/api/add_class_mass/ HTTP/1.1" 200 -
|
||||
INFO:werkzeug: * Detected change in 'C:\\Perso\\myclass.com\\Ela_back\\MySy_Back_Office\\class_mgt.py', reloading
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 797-962-469
|
||||
INFO:werkzeug: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
|
||||
INFO:root:2022-02-17 16:12:13.277721 : add_class - 'token'
|
||||
INFO:werkzeug:127.0.0.1 - - [17/Feb/2022 16:12:13] "POST /myclass/api/add_class_mass/ HTTP/1.1" 200 -
|
||||
INFO:werkzeug: * Detected change in 'C:\\Perso\\myclass.com\\Ela_back\\MySy_Back_Office\\class_mgt.py', reloading
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 797-962-469
|
||||
INFO:werkzeug: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
|
||||
INFO:root:2022-02-17 16:13:15.801615 : Le token n'est pas valide
|
||||
INFO:root:2022-02-17 16:13:16.415864 : add_class - L'email ou le token ne sont pas valident
|
||||
INFO:werkzeug:127.0.0.1 - - [17/Feb/2022 16:13:16] "POST /myclass/api/add_class_mass/ HTTP/1.1" 200 -
|
||||
INFO:werkzeug: * Detected change in 'C:\\Perso\\myclass.com\\Ela_back\\MySy_Back_Office\\class_mgt.py', reloading
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 797-962-469
|
||||
INFO:werkzeug: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
|
||||
INFO:werkzeug:127.0.0.1 - - [17/Feb/2022 16:14:31] "POST /myclass/api/add_class_mass/ HTTP/1.1" 200 -
|
||||
INFO:werkzeug: * Detected change in 'C:\\Perso\\myclass.com\\Ela_back\\MySy_Back_Office\\class_mgt.py', reloading
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 797-962-469
|
||||
INFO:werkzeug: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
|
||||
INFO:werkzeug: * Detected change in 'C:\\Perso\\myclass.com\\Ela_back\\MySy_Back_Office\\class_mgt.py', reloading
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 797-962-469
|
||||
INFO:werkzeug: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
|
||||
INFO:werkzeug: * Detected change in 'C:\\Perso\\myclass.com\\Ela_back\\MySy_Back_Office\\class_mgt.py', reloading
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 797-962-469
|
||||
INFO:werkzeug: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
|
||||
INFO:root:2022-02-17 16:16:34.619173 : add_class - 'token'
|
||||
INFO:werkzeug:127.0.0.1 - - [17/Feb/2022 16:16:34] "POST /myclass/api/add_class_mass/ HTTP/1.1" 200 -
|
||||
INFO:werkzeug: * Detected change in 'C:\\Perso\\myclass.com\\Ela_back\\MySy_Back_Office\\class_mgt.py', reloading
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 797-962-469
|
||||
INFO:werkzeug: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
|
||||
INFO:root:2022-02-17 16:18:13.690495 : add_class -la formation avec l'external code PA1201910' existe deja, impossible de créer le compte partenaire
|
||||
INFO:werkzeug:127.0.0.1 - - [17/Feb/2022 16:18:13] "POST /myclass/api/add_class_mass/ HTTP/1.1" 200 -
|
||||
INFO:werkzeug:127.0.0.1 - - [17/Feb/2022 16:19:26] "POST /myclass/api/add_class_mass/ HTTP/1.1" 200 -
|
||||
|
|
104
class_mgt.py
104
class_mgt.py
|
@ -11,7 +11,9 @@ from datetime import datetime
|
|||
import prj_common as mycommon
|
||||
import secrets
|
||||
import inspect
|
||||
|
||||
import os
|
||||
import csv
|
||||
import pandas as pd
|
||||
|
||||
class JSONEncoder(json.JSONEncoder):
|
||||
def default(self, o):
|
||||
|
@ -126,9 +128,6 @@ def add_class(diction):
|
|||
if diction['mots_cle']:
|
||||
mydata['mots_cle'] = diction['mots_cle']
|
||||
|
||||
|
||||
|
||||
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
mydata['token'] = diction['token']
|
||||
|
@ -706,3 +705,100 @@ def get_all_class_by_attribut(attribut, value):
|
|||
return False
|
||||
|
||||
|
||||
|
||||
|
||||
'''
|
||||
Cette fontion import un fichier excel de formation
|
||||
'''
|
||||
|
||||
def add_class_mass(file=None, Folder=None, diction=None):
|
||||
try:
|
||||
|
||||
'''
|
||||
# Verification que les champs reçus dans l'API sont bien dans la liste des champs autorisés
|
||||
# Cela evite le cas ou une entité tierce ajouter les valeurs inconnu dans l'API
|
||||
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
|
||||
# field_list.
|
||||
'''
|
||||
field_list = ['token']
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Creation formation : Le champ '" + val + "' n'existe pas, Creation formation annulée")
|
||||
return False, " Verifier votre API"
|
||||
|
||||
'''
|
||||
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente,
|
||||
On controle que les champs obligatoires sont presents dans la liste
|
||||
'''
|
||||
field_list_obligatoire = ['token']
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
return False, " Verifier votre API"
|
||||
|
||||
|
||||
status, saved_file = mycommon.Upload_Save_CSV_File(file, Folder)
|
||||
if (status == False):
|
||||
return False, "Impossible d'inserer les formation en masse "
|
||||
|
||||
#" Lecture du fichier "
|
||||
print(" Lecture du fichier : "+saved_file)
|
||||
nb_line = 0
|
||||
|
||||
df = pd.read_csv(saved_file, encoding='utf8', on_bad_lines='skip', sep=';')
|
||||
|
||||
# Dictionnaire des champs utilisables
|
||||
'''
|
||||
# Verification que les noms des colonne sont bien corrects"
|
||||
'''
|
||||
field_list = ['external_code', 'title', 'description', 'trainer', 'institut_formation', 'distantiel', 'presentiel',
|
||||
'price', 'domaine', 'url','duree_formation','partner_mail', 'plus_produit', 'mots_cle']
|
||||
|
||||
total_rows = len(df)
|
||||
|
||||
print(df.columns)
|
||||
for val in df.columns:
|
||||
if str(val).lower() not in field_list:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3])+" : entete du fichier csv. '" + val + "' n'est pas acceptée")
|
||||
return False, " Entete du fichier csv. '" + val + "' n'est pas acceptée"
|
||||
|
||||
|
||||
x = range(0, total_rows)
|
||||
|
||||
print(" Domaine ===> Code formation ")
|
||||
for n in x:
|
||||
mydata = {}
|
||||
mydata['external_code'] = str(df['external_code'].values[n])
|
||||
mydata['title'] = str(df['domaine'].values[n])
|
||||
mydata['description'] = str(df['description'].values[n])
|
||||
mydata['trainer'] = str(df['trainer'].values[n])
|
||||
mydata['institut_formation'] = str(df['institut_formation'].values[n])
|
||||
mydata['distantiel'] = str(df['presentiel'].values[n])
|
||||
mydata['url'] = str(df['url'].values[n])
|
||||
mydata['duree_formation'] = str(df['duree_formation'].values[n])
|
||||
mydata['plus_produit'] = str(df['plus_produit'].values[n])
|
||||
mydata['mots_cle'] = str(df['mots_cle'].values[n])
|
||||
mydata['distantiel'] = str(df['distantiel'].values[n])
|
||||
mydata['presentiel'] = str(df['presentiel'].values[n])
|
||||
mydata['partner_mail'] = "empty"
|
||||
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
mydata['token'] = diction['token']
|
||||
|
||||
print( mydata)
|
||||
status, retval = add_class(mydata)
|
||||
|
||||
if( status is False ):
|
||||
return status, retval
|
||||
|
||||
print(str(total_rows)+" formations ont été inserées")
|
||||
|
||||
return True, str(total_rows)+" formations ont été inserées"
|
||||
|
||||
except Exception as e:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - " + str(e))
|
||||
return False, "Impossible d'inserer les formation en masse "
|
||||
|
|
4
main.py
4
main.py
|
@ -718,9 +718,9 @@ def add_class_mass():
|
|||
|
||||
if request.method == 'POST':
|
||||
# Create variable for uploaded file
|
||||
f = request.files['Filee']
|
||||
f = request.files['File']
|
||||
|
||||
status, retval = wp.add_class_mass(f, app.config['UPLOAD_FOLDER'])
|
||||
status, retval = cm.add_class_mass(f, app.config['UPLOAD_FOLDER'], payload)
|
||||
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
|
51
wrapper.py
51
wrapper.py
|
@ -851,54 +851,3 @@ def get_stored_recherche(diction):
|
|||
mycommon.myprint(str(inspect.stack()[0][3])+" - "+str(e))
|
||||
return False, "Impossible de recuperer les recherches du user "
|
||||
|
||||
|
||||
|
||||
'''
|
||||
Cette fontion import un fichier excel de formation
|
||||
'''
|
||||
|
||||
def add_class_mass(file=None, Folder=None):
|
||||
try:
|
||||
|
||||
status, saved_file = mycommon.Upload_Save_CSV_File(file, Folder)
|
||||
if (status == False):
|
||||
return False, "Impossible d'inserer les formation en masse "
|
||||
|
||||
#" Lecture du fichier "
|
||||
print(" Lecture du fichier : "+saved_file)
|
||||
nb_line = 0
|
||||
|
||||
df = pd.read_csv(saved_file, encoding='utf8', on_bad_lines='skip', sep=';')
|
||||
|
||||
# Dictionnaire des champs utilisables
|
||||
'''
|
||||
# Verification que les noms des colonne sont bien corrects"
|
||||
'''
|
||||
field_list = ["domaine", "organisme", "code", "titre", "description", "duree", "prix"]
|
||||
|
||||
total_rows = len(df)
|
||||
print(" les colonnes ")
|
||||
print(df.columns)
|
||||
|
||||
for val in df.columns:
|
||||
if str(val).lower() not in field_list:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3])+" : entete du fichier csv. '" + val + "' n'est pas acceptée")
|
||||
return False, " Entete du fichier csv. '" + val + "' n'est pas acceptée"
|
||||
|
||||
|
||||
x = range(0, total_rows)
|
||||
|
||||
print(" Domaine ===> Code formation ")
|
||||
for n in x:
|
||||
print( str(df['Domaine'].values[n]) +" ---- "+str(df['Code'].values[n]) )
|
||||
|
||||
|
||||
|
||||
print(str(total_rows)+" formations ont été inserées")
|
||||
|
||||
return True, str(total_rows)+" formations ont été inserées"
|
||||
|
||||
except Exception as e:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - " + str(e))
|
||||
return False, "Impossible d'inserer les formation en masse "
|
||||
|
|
Loading…
Reference in New Issue