-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
correction des bugs de download pendant la validation #1368
Conversation
Rapport de QA : |
Possible de mettre à disposition le tutoriel en question qui fait planter ? Il a quelque chose de particulier ce tuto ? Y'a t-il une backtrace de l'erreur correspondante au memoryu error ? |
J'ai juste importé le tuto "irisht". Puis j'ai ajouté une image dans l'introduction de la première chapitre ainsi que dans sa conclusion. J'ai sauvegardé. J'ai demandé la validation et après la validation, lors de la redirection vers le tutoriel, j'ai un "internal server error occured, please contact administrator" et cette stacktrace : Traceback (most recent call last):
File "C:\Python27\lib\wsgiref\handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", line 67, in __call__
return self.application(environ, start_response)
File "C:\Python27\lib\site-packages\django\core\handlers\wsgi.py", line 206, in __call__
response = self.get_response(request)
File "C:\Python27\lib\site-packages\django\core\handlers\base.py", line 194, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "C:\Python27\lib\site-packages\django\core\handlers\base.py", line 229, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
File "C:\Python27\lib\site-packages\django\views\debug.py", line 69, in technical_500_response
html = reporter.get_traceback_html()
File "C:\Python27\lib\site-packages\django\views\debug.py", line 323, in get_traceback_html
c = Context(self.get_traceback_data())
File "C:\Python27\lib\site-packages\django\views\debug.py", line 284, in get_traceback_data
frame['vars'] = [(k, force_escape(pprint(v))) for k, v in frame['vars']]
File "C:\Python27\lib\site-packages\django\template\defaultfilters.py", line 44, in _dec
return func(*args, **kwargs)
File "C:\Python27\lib\site-packages\django\template\defaultfilters.py", line 414, in force_escape
return escape(value)
File "C:\Python27\lib\site-packages\django\utils\functional.py", line 203, in wrapper
return func(*args, **kwargs)
File "C:\Python27\lib\site-packages\django\utils\html.py", line 39, in escape
return mark_safe(force_text(text).replace('&', '&').replace('<', '<').replace('>', '>').replace('"', '"').replace("'", ''')) |
C'est bon, le problème a disparu (c'était mon ordi qui en avait marre ^^).
Environment:
Request Method: POST
Request URL: http://127.0.0.1:8000/tutoriels/validation/valid/
Django Version: 1.6.5
Python Version: 2.7.0
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sitemaps',
'django.contrib.humanize',
'easy_thumbnails',
'easy_thumbnails.optimize',
'south',
'crispy_forms',
'email_obfuscator',
'haystack',
'munin',
'zds.utils',
'zds.pages',
'zds.gallery',
'zds.mp',
'zds.article',
'zds.forum',
'zds.tutorial',
'zds.member',
'django.contrib.admin',
'debug_toolbar')
Installed Middleware:
(u'debug_toolbar.middleware.DebugToolbarMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'zds.utils.ThreadLocals',
'zds.middlewares.SetLastVisitMiddleware.SetLastVisitMiddleware')
Traceback:
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response
112. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "D:\zds-site\zds\member\decorator.py" in _can_write_and_read_now
20. return func(request, *args, **kwargs)
File "C:\Python27\lib\site-packages\django\contrib\auth\decorators.py" in _wrapped_view
22. return view_func(request, *args, **kwargs)
File "C:\Python27\lib\site-packages\django\views\decorators\http.py" in inner
41. return func(request, *args, **kwargs)
File "C:\Python27\lib\site-packages\django\contrib\auth\decorators.py" in _wrapped_view
22. return view_func(request, *args, **kwargs)
File "D:\zds-site\zds\tutorial\views.py" in valid_tutorial
354. (output, err) = MEP(tutorial, tutorial.sha_validation)
File "D:\zds-site\zds\tutorial\views.py" in MEP
2914. get_url_images(md_file_contenu, tutorial.get_prod_path())
File "D:\zds-site\zds\tutorial\views.py" in get_url_images
2805. urlretrieve(img[1], down_path)
File "C:\Python27\lib\urllib.py" in urlretrieve
91. return _urlopener.retrieve(url, filename, reporthook, data)
File "C:\Python27\lib\urllib.py" in retrieve
241. tfp = open(filename, 'wb')
Exception Type: IOError at /tutoriels/validation/valid/
Exception Value: [Errno 13] Permission denied: u'D:\\zds-site\\tutoriels-public\\6_big-tuto-pour-image\\images'
Environment:
Request Method: POST
Request URL: http://127.0.0.1:8000/tutoriels/validation/valid/
Django Version: 1.6.5
Python Version: 2.7.0
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sitemaps',
'django.contrib.humanize',
'easy_thumbnails',
'easy_thumbnails.optimize',
'south',
'crispy_forms',
'email_obfuscator',
'haystack',
'munin',
'zds.utils',
'zds.pages',
'zds.gallery',
'zds.mp',
'zds.article',
'zds.forum',
'zds.tutorial',
'zds.member',
'django.contrib.admin',
'debug_toolbar')
Installed Middleware:
(u'debug_toolbar.middleware.DebugToolbarMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'zds.utils.ThreadLocals',
'zds.middlewares.SetLastVisitMiddleware.SetLastVisitMiddleware')
Traceback:
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response
112. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "D:\zds-site\zds\member\decorator.py" in _can_write_and_read_now
20. return func(request, *args, **kwargs)
File "C:\Python27\lib\site-packages\django\contrib\auth\decorators.py" in _wrapped_view
22. return view_func(request, *args, **kwargs)
File "C:\Python27\lib\site-packages\django\views\decorators\http.py" in inner
41. return func(request, *args, **kwargs)
File "C:\Python27\lib\site-packages\django\contrib\auth\decorators.py" in _wrapped_view
22. return view_func(request, *args, **kwargs)
File "D:\zds-site\zds\tutorial\views.py" in valid_tutorial
354. (output, err) = MEP(tutorial, tutorial.sha_validation)
File "D:\zds-site\zds\tutorial\views.py" in MEP
2914. get_url_images(md_file_contenu, tutorial.get_prod_path())
File "D:\zds-site\zds\tutorial\views.py" in get_url_images
2805. urlretrieve(img[1], down_path)
File "C:\Python27\lib\urllib.py" in urlretrieve
91. return _urlopener.retrieve(url, filename, reporthook, data)
File "C:\Python27\lib\urllib.py" in retrieve
237. fp = self.open(url, data)
File "C:\Python27\lib\urllib.py" in open
205. return getattr(self, name)(url)
File "C:\Python27\lib\urllib.py" in open_http
342. h.endheaders(data)
File "C:\Python27\lib\httplib.py" in endheaders
940. self._send_output(message_body)
File "C:\Python27\lib\httplib.py" in _send_output
803. self.send(msg)
File "C:\Python27\lib\httplib.py" in send
755. self.connect()
File "C:\Python27\lib\httplib.py" in connect
736. self.timeout, self.source_address)
File "C:\Python27\lib\socket.py" in create_connection
551. for res in getaddrinfo(host, port, 0, SOCK_STREAM):
Exception Type: IOError at /tutoriels/validation/valid/
Exception Value: [Errno socket error] [Errno 11001] getaddrinfo failed |
Thanks For return ... SO NOW, QA CAN CONTINUE |
je n'ai plus les "authorisation error" donc toute la partie "lien correct" est OK. Environment:
Request Method: POST
Request URL: http://127.0.0.1:8000/tutoriels/validation/valid/
Django Version: 1.6.5
Python Version: 2.7.0
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sitemaps',
'django.contrib.humanize',
'easy_thumbnails',
'easy_thumbnails.optimize',
'south',
'crispy_forms',
'email_obfuscator',
'haystack',
'munin',
'zds.utils',
'zds.pages',
'zds.gallery',
'zds.mp',
'zds.article',
'zds.forum',
'zds.tutorial',
'zds.member',
'django.contrib.admin',
'debug_toolbar')
Installed Middleware:
(u'debug_toolbar.middleware.DebugToolbarMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'zds.utils.ThreadLocals',
'zds.middlewares.SetLastVisitMiddleware.SetLastVisitMiddleware')
Traceback:
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response
112. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "D:\zds-site\zds\member\decorator.py" in _can_write_and_read_now
20. return func(request, *args, **kwargs)
File "C:\Python27\lib\site-packages\django\contrib\auth\decorators.py" in _wrapped_view
22. return view_func(request, *args, **kwargs)
File "C:\Python27\lib\site-packages\django\views\decorators\http.py" in inner
41. return func(request, *args, **kwargs)
File "C:\Python27\lib\site-packages\django\contrib\auth\decorators.py" in _wrapped_view
22. return view_func(request, *args, **kwargs)
File "D:\zds-site\zds\tutorial\views.py" in valid_tutorial
354. (output, err) = MEP(tutorial, tutorial.sha_validation)
File "D:\zds-site\zds\tutorial\views.py" in MEP
2919. get_url_images(md_file_contenu, tutorial.get_prod_path())
File "D:\zds-site\zds\tutorial\views.py" in get_url_images
2807. urlretrieve(img[1], down_path)
File "C:\Python27\lib\urllib.py" in urlretrieve
91. return _urlopener.retrieve(url, filename, reporthook, data)
File "C:\Python27\lib\urllib.py" in retrieve
237. fp = self.open(url, data)
File "C:\Python27\lib\urllib.py" in open
205. return getattr(self, name)(url)
File "C:\Python27\lib\urllib.py" in open_http
342. h.endheaders(data)
File "C:\Python27\lib\httplib.py" in endheaders
940. self._send_output(message_body)
File "C:\Python27\lib\httplib.py" in _send_output
803. self.send(msg)
File "C:\Python27\lib\httplib.py" in send
755. self.connect()
File "C:\Python27\lib\httplib.py" in connect
736. self.timeout, self.source_address)
File "C:\Python27\lib\socket.py" in create_connection
551. for res in getaddrinfo(host, port, 0, SOCK_STREAM):
Exception Type: IOError at /tutoriels/validation/valid/
Exception Value: [Errno socket error] [Errno 11001] getaddrinfo failed |
Petite info : cette erreur n'arrive que si l'image qui "n'existe pas" vient d'un site inexistant. En effet, quand je tente avec Je pense qu'il faudrait donc imaginer plutôt un truc du genre: try:
addr = get_addr(...);
except IOError:
addr = "url_par_defaut"
finally:
mettre l'image dans le tuto(addr) |
En fait c'est même pire que ça : tu ne fais aucune vérification du type/mime : si je voulais je pourrais mettre des fichiers viraux sur le serveur grâce à ça : il suffit que le serveur ne réponde pas 404 ! |
Désolé je n'avais pas vu la partie de la QA concernant les erreurs socket. C'est maintenant corrigé. Pour les fichiers viraux, tu auras du mal car après coup, je vérifie que le fichier téléchargé est bien une image, car le type/mime peut-être trafiqué aussi. SO, QA CAN CONTINUE ! |
|
Je pense qu'il ne faudrait pas arrêter la validation a cause d'une image qui dépasse notre limite gallerie. La limite de la gallerie est là avant tout pour éviter les uploads massifs de tout et n'importe quoi. Si un tutoriel contient une image externe un peu trop lourde, et que le valido est déjà en train de la valider, c'est qu'il doit y avoir une bonne raison. Donc je pense que c'est a merger |
100% d'accord avec @firm1. Donc comme la QA est OK sur tout le reste, je merge :) |
correction des bugs de download pendant la validation
parfait. Je disais juste ça pour que ça soit sûr. faut que chacun en ait connaissance, AMHA. |
Cette PR permet de corriger le bug qui faisait que dans un tuto, si on a un lien d'image qui pointe sur une url qui n'est pas vraiment une image, la validation buguait. Maintenant, quelque soit les liens d'image dans le texte, si l'url de destination n'est pas une url d'image, on remplace l'image inexistante par une image vide.
L'idéal serait de virer l'image, mais pour le coup, je vous avoue que je ne peux pas faire mieux.
Note pour QA
Tester la validation de tutos avec des liens plus ou moins chelous.