Bonjour à tous,
Suite à la nouvelle version de wapt, la fonction remove_tree n'ignore plus les erreurs.
Est-il possible de définir un message d'erreur personnalisé dans ces cas là ?
J'ai tenté /remove_tree(r'c:\mon_dossier', onerror=print('mon_message'))/ mais la syntaxe est incorrecte.
J'ai également cherché avec la création de fonction
/def truc():// // print(r'coucou')/
/remove_tree(r'c:\mon_dossier', onerror=truc) /ou avec une autre syntaxe /remove_tree(r'c:\mon_dossier', onerror=truc())/ //
Je présume que je ne suis plus très loin de la bonne syntaxe mais les différentes doc en ligne n'ont pour l'instant pas apportée l'information recherchée.
C'est à peu près ça.
La fonction à fournir doit récupérer 3 paramètres : (func, path, error)
def print_error(func, path, error): print(u'Erreur lors de %s pour %s : %s' % (func.__name__, path, repr(error[1])))
remove_tree(r'c:\mon_dossier', onerror=print_error)
Erreur lors de listdir pour c:\mon_dossier : WindowsError(3, 'Le chemin d\x92acc\xe8s sp\xe9cifi\xe9 est introuvable') Erreur lors de rmdir pour c:\mon_dossier : WindowsError(2, 'Le fichier sp\xe9cifi\xe9 est introuvable')
Le 28/03/2018 à 16:52, Latieule Joel a écrit :
Bonjour à tous,
Suite à la nouvelle version de wapt, la fonction remove_tree n'ignore plus les erreurs.
Est-il possible de définir un message d'erreur personnalisé dans ces cas là ?
J'ai tenté /remove_tree(r'c:\mon_dossier', onerror=print('mon_message'))/ mais la syntaxe est incorrecte.
J'ai également cherché avec la création de fonction
/def truc():// // print(r'coucou')/
/remove_tree(r'c:\mon_dossier', onerror=truc) /ou avec une autre syntaxe /remove_tree(r'c:\mon_dossier', onerror=truc())/
Je présume que je ne suis plus très loin de la bonne syntaxe mais les différentes doc en ligne n'ont pour l'instant pas apportée l'information recherchée.
-- Joël LATIEULE - 06.38.02.33.27 / TICE
Collège Victor Hugo - 0110021n 5 boulevard Marcel Sembat, 11100 Narbonne 04.68.90.24.00
WAPT mailing list WAPT@lists.tranquil.it http://lists.tranquil.it/listinfo/wapt
Excellent et encore merci Hubert,
D'un point de vue esthétique, est ce qu'il existe un paramètre qui permet d'afficher les accents correctement sans jouer avec des remplacements de texte ?
C'est purement esthétique, si un tel paramètres n'existe pas je creuserai plus quand j'aurai amélioré mes connaissances en python.
Le 28/03/2018 à 17:10, Hubert TOUVET a écrit :
C'est à peu près ça.
La fonction à fournir doit récupérer 3 paramètres : (func, path, error)
def print_error(func, path, error): print(u'Erreur lors de %s pour %s : %s' % (func.__name__, path, repr(error[1])))
remove_tree(r'c:\mon_dossier', onerror=print_error)
Erreur lors de listdir pour c:\mon_dossier : WindowsError(3, 'Le chemin d\x92acc\xe8s sp\xe9cifi\xe9 est introuvable') Erreur lors de rmdir pour c:\mon_dossier : WindowsError(2, 'Le fichier sp\xe9cifi\xe9 est introuvable')
Le 28/03/2018 à 16:52, Latieule Joel a écrit :
Bonjour à tous,
Suite à la nouvelle version de wapt, la fonction remove_tree n'ignore plus les erreurs.
Est-il possible de définir un message d'erreur personnalisé dans ces cas là ?
J'ai tenté /remove_tree(r'c:\mon_dossier', onerror=print('mon_message'))/ mais la syntaxe est incorrecte.
J'ai également cherché avec la création de fonction
/def truc():// // print(r'coucou')/
/remove_tree(r'c:\mon_dossier', onerror=truc) /ou avec une autre syntaxe /remove_tree(r'c:\mon_dossier', onerror=truc())/
Je présume que je ne suis plus très loin de la bonne syntaxe mais les différentes doc en ligne n'ont pour l'instant pas apportée l'information recherchée.
-- Joël LATIEULE - 06.38.02.33.27 / TICE
Collège Victor Hugo - 0110021n 5 boulevard Marcel Sembat, 11100 Narbonne 04.68.90.24.00
WAPT mailing list WAPT@lists.tranquil.it http://lists.tranquil.it/listinfo/wapt
WAPT mailing list WAPT@lists.tranquil.it http://lists.tranquil.it/listinfo/wapt
import sys
def print_error(func, path, error): print(u'Erreur lors de %s pour %s : %s' % (func.__name__, path, str(error[1]).decode(sys.getfilesystemencoding()) ))
remove_tree(r'c:\mon_dossier', onerror=print_error)
Erreur lors de listdir pour c:\mon_dossier : [Error 3] Le chemin d’accès spécifié est introuvable: 'c:\mon_dossier/*.*' Erreur lors de rmdir pour c:\mon_dossier : [Error 2] Le fichier spécifié est introuvable: 'c:\mon_dossier'
Le 28/03/2018 à 19:43, Latieule Joel a écrit :
Excellent et encore merci Hubert,
D'un point de vue esthétique, est ce qu'il existe un paramètre qui permet d'afficher les accents correctement sans jouer avec des remplacements de texte ?
C'est purement esthétique, si un tel paramètres n'existe pas je creuserai plus quand j'aurai amélioré mes connaissances en python.
Le 28/03/2018 à 17:10, Hubert TOUVET a écrit :
C'est à peu près ça.
La fonction à fournir doit récupérer 3 paramètres : (func, path, error)
def print_error(func, path, error): print(u'Erreur lors de %s pour %s : %s' % (func.__name__, path, repr(error[1])))
remove_tree(r'c:\mon_dossier', onerror=print_error)
Erreur lors de listdir pour c:\mon_dossier : WindowsError(3, 'Le chemin d\x92acc\xe8s sp\xe9cifi\xe9 est introuvable') Erreur lors de rmdir pour c:\mon_dossier : WindowsError(2, 'Le fichier sp\xe9cifi\xe9 est introuvable')
Le 28/03/2018 à 16:52, Latieule Joel a écrit :
Bonjour à tous,
Suite à la nouvelle version de wapt, la fonction remove_tree n'ignore plus les erreurs.
Est-il possible de définir un message d'erreur personnalisé dans ces cas là ?
J'ai tenté /remove_tree(r'c:\mon_dossier', onerror=print('mon_message'))/ mais la syntaxe est incorrecte.
J'ai également cherché avec la création de fonction
/def truc():// // print(r'coucou')/
/remove_tree(r'c:\mon_dossier', onerror=truc) /ou avec une autre syntaxe /remove_tree(r'c:\mon_dossier', onerror=truc())/
Je présume que je ne suis plus très loin de la bonne syntaxe mais les différentes doc en ligne n'ont pour l'instant pas apportée l'information recherchée.
-- Joël LATIEULE - 06.38.02.33.27 / TICE
Collège Victor Hugo - 0110021n 5 boulevard Marcel Sembat, 11100 Narbonne 04.68.90.24.00
WAPT mailing list WAPT@lists.tranquil.it http://lists.tranquil.it/listinfo/wapt
WAPT mailing list WAPT@lists.tranquil.it http://lists.tranquil.it/listinfo/wapt
-- Joël LATIEULE - 06.38.02.33.27 / TICE
Collège Victor Hugo - 0110021n 5 boulevard Marcel Sembat, 11100 Narbonne 04.68.90.24.00
WAPT mailing list WAPT@lists.tranquil.it http://lists.tranquil.it/listinfo/wapt
Dingue... ça à l'air tellement simple.
J'ai encore beaucoup à découvrir mais merci de me montrer le chemin ;-)
Le 28/03/2018 à 19:54, Hubert TOUVET a écrit :
import sys
def print_error(func, path, error): print(u'Erreur lors de %s pour %s : %s' % (func.__name__, path, str(error[1]).decode(sys.getfilesystemencoding()) ))
remove_tree(r'c:\mon_dossier', onerror=print_error)
Erreur lors de listdir pour c:\mon_dossier : [Error 3] Le chemin d’accès spécifié est introuvable: 'c:\mon_dossier/*.*' Erreur lors de rmdir pour c:\mon_dossier : [Error 2] Le fichier spécifié est introuvable: 'c:\mon_dossier'
Le 28/03/2018 à 19:43, Latieule Joel a écrit :
Excellent et encore merci Hubert,
D'un point de vue esthétique, est ce qu'il existe un paramètre qui permet d'afficher les accents correctement sans jouer avec des remplacements de texte ?
C'est purement esthétique, si un tel paramètres n'existe pas je creuserai plus quand j'aurai amélioré mes connaissances en python.
Le 28/03/2018 à 17:10, Hubert TOUVET a écrit :
C'est à peu près ça.
La fonction à fournir doit récupérer 3 paramètres : (func, path, error)
def print_error(func, path, error): print(u'Erreur lors de %s pour %s : %s' % (func.__name__, path, repr(error[1])))
remove_tree(r'c:\mon_dossier', onerror=print_error)
Erreur lors de listdir pour c:\mon_dossier : WindowsError(3, 'Le chemin d\x92acc\xe8s sp\xe9cifi\xe9 est introuvable') Erreur lors de rmdir pour c:\mon_dossier : WindowsError(2, 'Le fichier sp\xe9cifi\xe9 est introuvable')
Le 28/03/2018 à 16:52, Latieule Joel a écrit :
Bonjour à tous,
Suite à la nouvelle version de wapt, la fonction remove_tree n'ignore plus les erreurs.
Est-il possible de définir un message d'erreur personnalisé dans ces cas là ?
J'ai tenté /remove_tree(r'c:\mon_dossier', onerror=print('mon_message'))/ mais la syntaxe est incorrecte.
J'ai également cherché avec la création de fonction
/def truc():// // print(r'coucou')/
/remove_tree(r'c:\mon_dossier', onerror=truc) /ou avec une autre syntaxe /remove_tree(r'c:\mon_dossier', onerror=truc())/
Je présume que je ne suis plus très loin de la bonne syntaxe mais les différentes doc en ligne n'ont pour l'instant pas apportée l'information recherchée.
-- Joël LATIEULE - 06.38.02.33.27 / TICE
Collège Victor Hugo - 0110021n 5 boulevard Marcel Sembat, 11100 Narbonne 04.68.90.24.00
WAPT mailing list WAPT@lists.tranquil.it http://lists.tranquil.it/listinfo/wapt
WAPT mailing list WAPT@lists.tranquil.it http://lists.tranquil.it/listinfo/wapt
-- Joël LATIEULE - 06.38.02.33.27 / TICE
Collège Victor Hugo - 0110021n 5 boulevard Marcel Sembat, 11100 Narbonne 04.68.90.24.00
WAPT mailing list WAPT@lists.tranquil.it http://lists.tranquil.it/listinfo/wapt
WAPT mailing list WAPT@lists.tranquil.it http://lists.tranquil.it/listinfo/wapt
Pour finaliser le script je cherche à interrompre l'installation du paquet en question si une condition n'est pas validée.
J'ai tenté avec la commande exit() qui fonctionne avec PyScripter mais lors des tests depuis la console, le paquet semble se mettre en pause et l'installation n'est pas interrompu.
J'ai tenté ceci
import sys
def print_error(func, path, error): print(u'Erreur lors de %s pour %s : %s' % (func.__name__, path, str(error[1]).decode(sys.getfilesystemencoding()) )) *exit(3)*
remove_tree(r'c:\mon_dossier', onerror=print_error)
Existe une méthode plus "propre" ou au moins efficace pour sortir de l'installation d'un paquet ?
Joël LATIEULE - 06.38.02.33.27 / TICE
Collège Victor Hugo - 0110021n 5 boulevard Marcel Sembat, 11100 Narbonne 04.68.90.24.00
Le 28/03/2018 à 19:54, Hubert TOUVET a écrit :
import sys
def print_error(func, path, error): print(u'Erreur lors de %s pour %s : %s' % (func.__name__, path, str(error[1]).decode(sys.getfilesystemencoding()) ))
remove_tree(r'c:\mon_dossier', onerror=print_error)
Erreur lors de listdir pour c:\mon_dossier : [Error 3] Le chemin d’accès spécifié est introuvable: 'c:\mon_dossier/*.*' Erreur lors de rmdir pour c:\mon_dossier : [Error 2] Le fichier spécifié est introuvable: 'c:\mon_dossier'
Le 28/03/2018 à 19:43, Latieule Joel a écrit :
Excellent et encore merci Hubert,
D'un point de vue esthétique, est ce qu'il existe un paramètre qui permet d'afficher les accents correctement sans jouer avec des remplacements de texte ?
C'est purement esthétique, si un tel paramètres n'existe pas je creuserai plus quand j'aurai amélioré mes connaissances en python.
Le 28/03/2018 à 17:10, Hubert TOUVET a écrit :
C'est à peu près ça.
La fonction à fournir doit récupérer 3 paramètres : (func, path, error)
def print_error(func, path, error): print(u'Erreur lors de %s pour %s : %s' % (func.__name__, path, repr(error[1])))
remove_tree(r'c:\mon_dossier', onerror=print_error)
Erreur lors de listdir pour c:\mon_dossier : WindowsError(3, 'Le chemin d\x92acc\xe8s sp\xe9cifi\xe9 est introuvable') Erreur lors de rmdir pour c:\mon_dossier : WindowsError(2, 'Le fichier sp\xe9cifi\xe9 est introuvable')
Le 28/03/2018 à 16:52, Latieule Joel a écrit :
Bonjour à tous,
Suite à la nouvelle version de wapt, la fonction remove_tree n'ignore plus les erreurs.
Est-il possible de définir un message d'erreur personnalisé dans ces cas là ?
J'ai tenté /remove_tree(r'c:\mon_dossier', onerror=print('mon_message'))/ mais la syntaxe est incorrecte.
J'ai également cherché avec la création de fonction
/def truc():// // print(r'coucou')/
/remove_tree(r'c:\mon_dossier', onerror=truc) /ou avec une autre syntaxe /remove_tree(r'c:\mon_dossier', onerror=truc())/
Je présume que je ne suis plus très loin de la bonne syntaxe mais les différentes doc en ligne n'ont pour l'instant pas apportée l'information recherchée.
-- Joël LATIEULE - 06.38.02.33.27 / TICE
Collège Victor Hugo - 0110021n 5 boulevard Marcel Sembat, 11100 Narbonne 04.68.90.24.00
WAPT mailing list WAPT@lists.tranquil.it http://lists.tranquil.it/listinfo/wapt
WAPT mailing list WAPT@lists.tranquil.it http://lists.tranquil.it/listinfo/wapt
-- Joël LATIEULE - 06.38.02.33.27 / TICE
Collège Victor Hugo - 0110021n 5 boulevard Marcel Sembat, 11100 Narbonne 04.68.90.24.00
WAPT mailing list WAPT@lists.tranquil.it http://lists.tranquil.it/listinfo/wapt
WAPT mailing list WAPT@lists.tranquil.it http://lists.tranquil.it/listinfo/wapt