Use a new global DEV_NULL instead of hard-coding /dev/null into the system
command helper functions. See #6479 for some motivation.
This commit is contained in:
parent
9d11fefe1b
commit
19e5b3f9d1
|
@ -34,6 +34,7 @@
|
|||
#
|
||||
# <see CVS and SVN checkin messages for history>
|
||||
#
|
||||
# 1.0.7 - added DEV_NULL
|
||||
# 1.0.6 - added linux_distribution()
|
||||
# 1.0.5 - fixed Java support to allow running the module on Jython
|
||||
# 1.0.4 - added IronPython support
|
||||
|
@ -91,7 +92,7 @@
|
|||
|
||||
__copyright__ = """
|
||||
Copyright (c) 1999-2000, Marc-Andre Lemburg; mailto:mal@lemburg.com
|
||||
Copyright (c) 2000-2008, eGenix.com Software GmbH; mailto:info@egenix.com
|
||||
Copyright (c) 2000-2009, eGenix.com Software GmbH; mailto:info@egenix.com
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee or royalty is hereby granted,
|
||||
|
@ -110,10 +111,25 @@ __copyright__ = """
|
|||
|
||||
"""
|
||||
|
||||
__version__ = '1.0.6'
|
||||
__version__ = '1.0.7'
|
||||
|
||||
import sys,string,os,re
|
||||
|
||||
### Globals & Constants
|
||||
|
||||
# Determine the platform's /dev/null device
|
||||
try:
|
||||
DEV_NULL = os.devnull
|
||||
except AttributeError:
|
||||
# os.devnull was added in Python 2.4, so emulate it for earlier
|
||||
# Python versions
|
||||
if sys.platform in ('dos','win32','win16','os2'):
|
||||
# Use the old CP/M NUL as device name
|
||||
DEV_NULL = 'NUL'
|
||||
else:
|
||||
# Standard Unix uses /dev/null
|
||||
DEV_NULL = '/dev/null'
|
||||
|
||||
### Platform specific APIs
|
||||
|
||||
_libc_search = re.compile(r'(__libc_init)'
|
||||
|
@ -926,7 +942,7 @@ def _syscmd_uname(option,default=''):
|
|||
# XXX Others too ?
|
||||
return default
|
||||
try:
|
||||
f = os.popen('uname %s 2> /dev/null' % option)
|
||||
f = os.popen('uname %s 2> %s' % (option, DEV_NULL))
|
||||
except (AttributeError,os.error):
|
||||
return default
|
||||
output = string.strip(f.read())
|
||||
|
@ -951,7 +967,7 @@ def _syscmd_file(target,default=''):
|
|||
return default
|
||||
target = _follow_symlinks(target)
|
||||
try:
|
||||
f = os.popen('file "%s" 2> /dev/null' % target)
|
||||
f = os.popen('file "%s" 2> %s' % (target, DEV_NULL))
|
||||
except (AttributeError,os.error):
|
||||
return default
|
||||
output = string.strip(f.read())
|
||||
|
|
Loading…
Reference in New Issue