Skip to content

Commit

Permalink
linux / setup.py: do not print warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Aug 31, 2015
1 parent 98befb0 commit 8d66475
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"""

import atexit
import contextlib
import io
import os
import sys
import tempfile
Expand Down Expand Up @@ -42,6 +44,16 @@ def get_description():
return f.read()


@contextlib.contextmanager
def captured_output(stream_name):
orig = getattr(sys, stream_name)
setattr(sys, stream_name, io.StringIO())
try:
yield getattr(sys, stream_name)
finally:
setattr(sys, stream_name, orig)


VERSION = get_version()
VERSION_MACRO = ('PSUTIL_VERSION', int(VERSION.replace('.', '')))

Expand Down Expand Up @@ -132,7 +144,9 @@ def get_ethtool_macro():
atexit.register(os.remove, f.name)
compiler = UnixCCompiler()
try:
compiler.compile([f.name])
with captured_output('stderr'):
with captured_output('stdout'):
compiler.compile([f.name])
except CompileError:
return ("PSUTIL_ETHTOOL_MISSING_TYPES", 1)
else:
Expand Down

0 comments on commit 8d66475

Please sign in to comment.