jenkins-bot has submitted this change and it was merged.
Change subject: Fix httplib2 dependency check
......................................................................
Fix httplib2 dependency check
- Move dependency check from threadedhttp.py to http.py
and revise it removing the dependency on setuptools for
running pywikibot (it is still required to use setup.py)
- Add httplib2 version checks, and display the httplib2 __file__
to assist the user identify why they have the wrong version.
Bug: 66618
Change-Id: I66c9a42f80710dec78b6e2b25ccb7b4b949c5740
---
M README-conversion.txt
M pwb.py
M pywikibot/comms/http.py
M pywikibot/comms/threadedhttp.py
4 files changed, 26 insertions(+), 14 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/README-conversion.txt b/README-conversion.txt
index e229ab0..24d62f4 100644
--- a/README-conversion.txt
+++ b/README-conversion.txt
@@ -48,10 +48,9 @@
so that these dependencies will be loaded automatically when the package is
installed, and users won't need to worry about this...]
-To run pywikibot, you will need the httplib2, simplejson, and setuptools
+To run pywikibot, you will need the httplib2 and simplejson:
packages--
* httplib2 : http://code.google.com/p/httplib2/
-* setuptools : http://pypi.python.org/pypi/setuptools/
* simplejson : http://svn.red-bean.com/bob/simplejson/tags/simplejson-1.7.1/docs/index.html
or, if you already have setuptools installed, just execute
diff --git a/pwb.py b/pwb.py
index 2fba1d3..a375826 100644
--- a/pwb.py
+++ b/pwb.py
@@ -108,7 +108,17 @@
import httplib2
except ImportError as e:
print("ImportError: %s" % e)
- print("Did you clone without --recursive? Try running 'git submodule update --init'.")
+ print("Python module httplib2 >= 0.6.0 is required.")
+ print("Did you clone without --recursive?"
+ "Try running 'git submodule update --init'.")
+ sys.exit(1)
+
+from distutils.version import StrictVersion
+if StrictVersion(httplib2.__version__) < StrictVersion("0.6.0"):
+ print("Python module httplib2 (%s) needs to be 0.6.0 or greater." %
+ httplib2.__file__)
+ print("Did you clone without --recursive?"
+ "Try running 'git submodule update --init'.")
sys.exit(1)
if "PYWIKIBOT2_DIR" not in os.environ:
diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py
index affc571..14a55ac 100644
--- a/pywikibot/comms/http.py
+++ b/pywikibot/comms/http.py
@@ -27,6 +27,19 @@
import atexit
import time
+# Verify that a working httplib2 is present.
+try:
+ import httplib2
+except ImportError:
+ print("Error: Python module httplib2 >= 0.6.0 is required.")
+ sys.exit(1)
+
+from distutils.version import StrictVersion
+if StrictVersion(httplib2.__version__) < StrictVersion("0.6.0"):
+ print("Error: Python module httplib2 (%s) is not 0.6.0 or greater." %
+ httplib2.__file__)
+ sys.exit(1)
+
if sys.version_info[0] == 2:
from httplib2 import SSLHandshakeError
import Queue
diff --git a/pywikibot/comms/threadedhttp.py b/pywikibot/comms/threadedhttp.py
index 5dd0840..0f04f5e 100644
--- a/pywikibot/comms/threadedhttp.py
+++ b/pywikibot/comms/threadedhttp.py
@@ -42,17 +42,7 @@
_logger = "comm.threadedhttp"
-# easy_install safeguarded dependencies
-try:
- import httplib2
-except ImportError:
- try:
- import pkg_resources
- pkg_resources.require("httplib2")
- except ImportError:
- pywikibot.error(
- u"Error: You need the python module httplib2 to use this module")
- sys.exit(1)
+import httplib2
class ConnectionPool(object):
--
To view, visit https://gerrit.wikimedia.org/r/139604
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I66c9a42f80710dec78b6e2b25ccb7b4b949c5740
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: config command line option 'modified' fails
......................................................................
config command line option 'modified' fails
- move global name 'base_dir' before the population of _glv
- delete variable 'ov' which is used only in a procedural block
that is executed in the global scope
Bug 66950
Change-Id: I482ce11abd1a0a6b078ef489ee1256fde2320758
---
M pywikibot/config2.py
1 file changed, 3 insertions(+), 4 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 6cca983..4b30df4 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -160,6 +160,8 @@
return base_dir
_base_dir = _get_base_dir()
+# Save base_dir for use by other modules
+base_dir = _base_dir
family_files = {}
@@ -716,7 +718,7 @@
print("WARNING: Type of '%(_key)s' changed" % locals())
print(" %(was)s: %(old)s" % {'was': "Was", 'old': ot})
print(" %(now)s: %(new)s" % {'now': "Now", 'new': nt})
- del nt, ot
+ del nt, ot, ov
else:
print(("WARNING: "
"Configuration variable %(_key)r is defined but unknown.\n"
@@ -741,9 +743,6 @@
transliteration_target = None
elif transliteration_target in ('None', 'none'):
transliteration_target = None
-
-# Save base_dir for use by other modules
-base_dir = _base_dir
#
--
To view, visit https://gerrit.wikimedia.org/r/141288
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I482ce11abd1a0a6b078ef489ee1256fde2320758
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Do not remove imported packages
......................................................................
Do not remove imported packages
Imported modules were hidden in 2009, as part of a large cleanup of the
symbols exported by config.py
https://mediawiki.org/wiki/Special:Code/pywikipedia/4285
While there is benefit in hiding symbols not intended to be public,
hiding the imported modules is not beneficial as it is unlikely that
any config value will be of type module, so they can be differentiated,
and indeed they were already skipped in 'list of config options' code.
https://mediawiki.org/wiki/Special:Code/pywikipedia/4887
The removal of symbols __sys and os currently cause pyflakes error F821.
While this isnt a functional problem, it does prevent reflection and
inspection of the loaded python code, and is unecessary.
Also moved platform import into the only code block that uses it,
meaning it wont be loaded on many systems.
Also removed 're' import, as it was unused.
Change-Id: I783fba623a2825af3273ecad286d47e897c2a674
---
M pywikibot/config2.py
1 file changed, 15 insertions(+), 20 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 6cca983..37579ad 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -9,9 +9,7 @@
#
import os
-import sys as __sys
-import re
-import platform
+import sys
# IMPORTANT:
# Do not change any of the variables in this file. Instead, make
@@ -121,18 +119,19 @@
"""
NAME = "pywikibot"
- for arg in __sys.argv[1:]:
+ for arg in sys.argv[1:]:
if arg.startswith("-dir:"):
base_dir = arg[5:]
- __sys.argv.remove(arg)
+ sys.argv.remove(arg)
break
else:
if "PYWIKIBOT2_DIR" in os.environ:
base_dir = os.environ["PYWIKIBOT2_DIR"]
else:
- is_windows = __sys.platform == 'win32'
+ is_windows = sys.platform == 'win32'
home = os.path.expanduser("~")
if is_windows:
+ import platform
_win_version = int(platform.version()[0])
if _win_version == 5:
base_dir = os.path.join(home, "Application Data", NAME)
@@ -194,7 +193,7 @@
# This default code should work fine, so you don't have to think about it.
# TODO: consider getting rid of this config variable.
try:
- console_encoding = __sys.stdout.encoding
+ console_encoding = sys.stdout.encoding
except:
# When using pywikibot inside a daemonized twisted application,
# we get "StdioOnnaStick instance has no attribute 'encoding'"
@@ -250,7 +249,7 @@
# ANSI colors.
try:
# Don't print colorized when the output is, for example, piped to a file.
- colorized_output = __sys.stdout.isatty()
+ colorized_output = sys.stdout.isatty()
except:
colorized_output = False
@@ -258,7 +257,7 @@
# The command for the editor you want to use. If set to None, a simple Tkinter
# editor will be used.
# On Windows systems, this script tries to determine the default text editor.
-if __sys.platform == 'win32':
+if sys.platform == 'win32':
try:
import _winreg
_key1 = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER,
@@ -643,7 +642,6 @@
from holger(a)trillke.net 2002/03/18
"""
- import os
dpath = os.path.normpath(os.path.dirname(path))
if not os.path.exists(dpath):
os.makedirs(dpath)
@@ -658,13 +656,11 @@
directories in the path that do not already exist are created.
"""
- import os.path
return makepath(os.path.join(base_dir, *filename))
def shortpath(path):
"""Return a file path relative to config.base_dir."""
- import os.path
if path.startswith(base_dir):
return path[len(base_dir) + len(os.path.sep):]
return path
@@ -687,8 +683,8 @@
_filestatus = os.stat(_filename)
_filemode = _filestatus[0]
_fileuid = _filestatus[4]
- if __sys.platform == 'win32' or _fileuid in [os.getuid(), 0]:
- if __sys.platform == 'win32' or _filemode & 0o02 == 0 or True:
+ if sys.platform == 'win32' or _fileuid in [os.getuid(), 0]:
+ if sys.platform == 'win32' or _filemode & 0o02 == 0 or True:
exec(compile(open(_filename).read(), _filename, 'exec'))
else:
print("WARNING: Skipped '%(fn)s': writeable by others."
@@ -724,14 +720,14 @@
# Fix up default console_encoding
if console_encoding is None:
- if __sys.platform == 'win32':
+ if sys.platform == 'win32':
console_encoding = 'cp850'
else:
console_encoding = 'iso-8859-1'
# Fix up transliteration_target
if transliteration_target == 'not set':
- if __sys.platform == 'win32':
+ if sys.platform == 'win32':
transliteration_target = console_encoding
print("WARNING: Running on Windows and transliteration_target is not "
"set.")
@@ -752,7 +748,7 @@
if __name__ == "__main__":
import types
_all = 1
- for _arg in __sys.argv[1:]:
+ for _arg in sys.argv[1:]:
if _arg == "modified":
_all = 0
else:
@@ -769,7 +765,6 @@
# cleanup all locally-defined variables
for __var in list(globals().keys()):
if __var.startswith("_") and not __var.startswith("__"):
- del __sys.modules[__name__].__dict__[__var]
+ del sys.modules[__name__].__dict__[__var]
-del __var, __sys
-del os, re
+del __var
--
To view, visit https://gerrit.wikimedia.org/r/141289
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I783fba623a2825af3273ecad286d47e897c2a674
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Russell Blau <russblau(a)imapmail.org>
Gerrit-Reviewer: jenkins-bot <>