You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2020/01/10 21:58:00 UTC

[allura] 03/03: [#8347] drop "poster" dep

This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch db/8347
in repository https://gitbox.apache.org/repos/asf/allura.git

commit f784a726fbd88035daf836110f8e6b7544ca206d
Author: Dave Brondsema <db...@slashdotmedia.com>
AuthorDate: Thu Jan 9 23:36:29 2020 +0000

    [#8347] drop "poster" dep
---
 Allura/setup.py                     |  2 +-
 AlluraTest/alluratest/validation.py | 19 ++++++++++---------
 requirements.in                     |  1 -
 requirements.txt                    |  1 -
 4 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/Allura/setup.py b/Allura/setup.py
index 6f25a17..47bd1bd 100644
--- a/Allura/setup.py
+++ b/Allura/setup.py
@@ -54,7 +54,7 @@ setup(
     packages=find_packages(exclude=['ez_setup']),
     include_package_data=True,
     test_suite='nose.collector',
-    tests_require=['WebTest >= 1.2', 'BeautifulSoup', 'poster', 'nose'],
+    tests_require=['WebTest >= 1.2', 'BeautifulSoup', 'nose'],
     package_data={'allura': ['i18n/*/LC_MESSAGES/*.mo',
                              'templates/**.html',
                              'templates/**.py',
diff --git a/AlluraTest/alluratest/validation.py b/AlluraTest/alluratest/validation.py
index 25d51b6..5076cbe 100644
--- a/AlluraTest/alluratest/validation.py
+++ b/AlluraTest/alluratest/validation.py
@@ -34,9 +34,8 @@ import pkg_resources
 import webtest
 from webtest import TestApp
 from nose.tools import ok_
-from poster.encode import multipart_encode
-from poster.streaminghttp import register_openers
 from ming.utils import LazyProperty
+import requests
 
 from allura.lib import utils
 
@@ -127,23 +126,25 @@ def validate_html5(html_or_response):
         html = html_or_response.body
     else:
         html = html_or_response
-    register_openers()
-    params = [("out", "text"), ("content", html)]
-    datagen, headers = multipart_encode(params)
-    request = urllib2.Request("http://html5.validator.nu/", datagen, headers)
     count = 3
     while True:
         try:
-            resp = urllib2.urlopen(request, timeout=3).read()
+            # TODO switch to http://validator.w3.org/nu/?out=text but it has more validation errors for us to fix
+            # Docs: https://github.com/validator/validator/wiki/Service-%C2%BB-Input-%C2%BB-POST-body   and other pages
+            resp = requests.post('http://html5.validator.nu/nu/?out=text',  # could do out=json
+                                 data=html,
+                                 headers={'Content-Type': str('text/html; charset=utf-8')},
+                                 timeout=3)
+            resp = resp.text
             break
-        except:
+        except Exception:
             resp = "Couldn't connect to validation service to check the HTML"
             count -= 1
             if count == 0:
                 sys.stderr.write('WARNING: ' + resp + '\n')
                 break
 
-    resp = resp.replace('“', '"').replace('”', '"').replace('–', '-')
+    resp = resp.replace(u'“', u'"').replace(u'”', u'"').replace(u'–', u'-')
 
     ignored_errors = [
         'Required attributes missing on element "object"',
diff --git a/requirements.in b/requirements.in
index 7c70916..1596d95 100644
--- a/requirements.in
+++ b/requirements.in
@@ -52,7 +52,6 @@ datadiff
 ipython<6  # Ipython 7 starts to require py3
 mock
 nose
-poster==0.8.1
 pyflakes
 #pylint -- disabled due to [#8346]  (also requires diff versions on py2 vs 3, including transitive deps which gets tricky with pip-compile)
 testfixtures
diff --git a/requirements.txt b/requirements.txt
index 640726b..3ba5fb4 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -58,7 +58,6 @@ pathlib2==2.3.4           # via ipython, pickleshare
 pexpect==4.7.0            # via ipython
 pickleshare==0.7.5        # via ipython
 pillow==6.1.0
-poster==0.8.1
 profanityfilter==2.0.6
 prompt-toolkit==1.0.16    # via ipython
 ptyprocess==0.6.0         # via pexpect