Commit dd1052d7 authored by Tres Seaver's avatar Tres Seaver

distribute / setuptools noise OFF.

parent 11571375
...@@ -4,6 +4,9 @@ Change History ...@@ -4,6 +4,9 @@ Change History
2.1.1dev (unreleased) 2.1.1dev (unreleased)
===================== =====================
- Suppress the useless ``Link to <URL> ***BLOCKED*** by --allow-hosts``
error message being emitted by distribute / setuptools.
2.1.0 (2013-03-23) 2.1.0 (2013-03-23)
================== ==================
......
...@@ -81,6 +81,25 @@ buildout_and_distribute_path = [ ...@@ -81,6 +81,25 @@ buildout_and_distribute_path = [
FILE_SCHEME = re.compile('file://', re.I).match FILE_SCHEME = re.compile('file://', re.I).match
class _Monkey(object):
def __init__(self, module, **kw):
mdict = self._mdict = module.__dict__
self._before = mdict.copy()
self._overrides = kw
def __enter__(self):
self._mdict.update(self._overrides)
return self
def __exit__(self, exc_type, exc_value, traceback):
self._mdict.clear()
self._mdict.update(self._before)
class _NoWarn(object):
def warn(self, *args, **kw):
pass
_no_warn = _NoWarn()
class AllowHostsPackageIndex(setuptools.package_index.PackageIndex): class AllowHostsPackageIndex(setuptools.package_index.PackageIndex):
"""Will allow urls that are local to the system. """Will allow urls that are local to the system.
...@@ -90,7 +109,12 @@ class AllowHostsPackageIndex(setuptools.package_index.PackageIndex): ...@@ -90,7 +109,12 @@ class AllowHostsPackageIndex(setuptools.package_index.PackageIndex):
def url_ok(self, url, fatal=False): def url_ok(self, url, fatal=False):
if FILE_SCHEME(url): if FILE_SCHEME(url):
return True return True
return setuptools.package_index.PackageIndex.url_ok(self, url, False) # distutils has its own logging, which can't be hooked / suppressed,
# so we monkey-patch the 'log' submodule to suppress the stupid
# "Link to <URL> ***BLOCKED*** by --allow-hosts" message.
with _Monkey(setuptools.package_index, log=_no_warn):
return setuptools.package_index.PackageIndex.url_ok(
self, url, False)
_indexes = {} _indexes = {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment