To add OAuth support to pywikibot, we need to add OAuth to httplib2 or allow and alternative http client such as python-requests.
This task is to evaluate the second alternative in more detail.
To add OAuth support to pywikibot, we need to add OAuth to httplib2 or allow and alternative http client such as python-requests.
This task is to evaluate the second alternative in more detail.
Subject | Repo | Branch | Lines +/- | |
---|---|---|---|---|
Switch from httplib2 to requests | pywikibot/core | master | +124 -785 |
Status | Subtype | Assigned | Task | ||
---|---|---|---|---|---|
Resolved | VcamX | T98671 Investigate using python-requests for OAuth | |||
Resolved | VcamX | T98439 Add support for using python-requests |
@jayvdb This is the travis ci test report. I reviewed the patch and also tried to follow its idea but found it break some internal things. So I made the patch myself. I checkouted a new branch based on the commit from master branch, which showed itself pass the test on travis ci.
Test 7 and 8 failed because requests introduced some warning to stderr, which cause some assertIsNone(stderr_other) failed. So I think we could ignore this assertion error.
Test 12 failed because AssertionError: LockedPage not raised by save. I think this test is for non-sysop account. But pywikibot doesn't figure out my account is sysop, so not to skip this test, which cause saving a locked page succeed. This also showed on travis ci report for the base commit using my account.
I almost replaced httplib2 with requests. And I removed some tests for httplib2, also modified some test case to fit with requests lib. You could check those modification. Sorry about those small and messy commits. I could squash them If you want :)
Hi @VcamX github allows you to compare your branch with the master branch relatively easy (at least if you rebase your changes only): https://github.com/wikimedia/pywikibot-core/compare/master...VcamX:requests
Regarding the error that LockedPage: The username and not sysop username is defined in the .travis.yml file so afaik all tests on Travis assume the test is not done by a sysop account. If you configure a sysop account in pywikibot as a normal user account it assumes that this account is not a sysop account. There is practically no reliable way to determine if your account is a sysop account which is why @jayvdb is working on a patch (or actually has submitted it already) which tries to avoid this difference (see also T71283). I guess noone is using a sysop account to be run on Travis which so we didn't noticed that yet. In theory you could change in your .travis.yml that it also defines sysopusernames although better would be to change that test to check if the configured user has the permission to edit that page.
I agree this assertion is very likely to not be a significant problem, however we need the tests to pass. ;-)
It looks like this is a problem only with the Python 2.6 builds, so any solution should use 'if sys.version_info < (2, 7):' so the 'solution' doesnt affect more modern python versions which dont need fixing.
There are three possible options that I can see quickly, which may or may not work:
Well according to https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning it only affects versions below 2.7.9 and Travis is using 2.7.9 so only the 2.6 tests have that problem.
In your setup.py, you require 'requests >=2, <3' , but pwb.py reports 'Python module requests >= 2.7.0 is required.'
Does requests pre 2.7 not include __version__?
@XZise I tried to run that test locally. It's under tests/edit_failure_tests.py. I'm using the same user-config.py as travis ci test. It showed that it skipped all 3 tests. That means pywikibot figure out I'm using a sysop account. It's confusing.
The test results are looking good. Could you please put a patch up for review in Gerrit. There are a large group of the devs together at a Hackathon, who can review the patch.
The one area which isnt covered by tests is async_request . Either we need to create tests for that, or we need to manually verify that works correctly after this patch.
Change 213977 had a related patch set uploaded (by VcamX):
Switch from httplib2 to requests