summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2017-01-31 00:54:01 -0500
committerTodd Leonhardt <todd.leonhardt@gmail.com>2017-01-31 00:54:01 -0500
commit1c2983833cd7ae42c99be69fcdcd6d644e264bac (patch)
treec654b3293bf651e6f8f736c1bc1aac094a9a852d /cmd2.py
parent6640ce2bab32a25414cd009646ecd7cf3cdfb11d (diff)
downloadcmd2-git-1c2983833cd7ae42c99be69fcdcd6d644e264bac.tar.gz
It turns out that setting the stdout and stderr arguments for subprocess.check_call to None doesn't ignore the output, you actually need to pipe it to DEVNULL and that symbol doesn't exist in subprocess namespace prior to Python 3.3
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/cmd2.py b/cmd2.py
index 38cf7bb1..1ab53b60 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -242,8 +242,10 @@ elif sys.platform == 'darwin':
# because the child process will block if it generates enough output to a pipe to fill up the OS pipe buffer.
# Starting with Python 3.5 there is a newer, safer API based on the run() function.
- # test for pbcopy - AFAIK, should always be installed on MacOS
- subprocess.check_call('pbcopy -help', shell=True, stdin=subprocess.PIPE, stdout=None, stderr=None)
+ # Python 3.3+ supports subprocess.DEVNULL, but that isn't defined for Python 2.7
+ with open(os.devnull, 'w') as DEVNULL:
+ # test for pbcopy - AFAIK, should always be installed on MacOS
+ subprocess.check_call('pbcopy -help', shell=True, stdin=subprocess.PIPE, stdout=DEVNULL, stderr=DEVNULL)
can_clip = True
except (subprocess.CalledProcessError, OSError, IOError):
pass
@@ -269,7 +271,8 @@ else:
# Running on Linux
can_clip = False
try:
- subprocess.check_call('xclip -o -sel clip', shell=True, stdin=subprocess.PIPE, stdout=None, stderr=None)
+ with open(os.devnull, 'w') as DEVNULL:
+ subprocess.check_call('xclip -o -sel clip', shell=True, stdin=subprocess.PIPE, stdout=DEVNULL, stderr=DEVNULL)
can_clip = True
except AttributeError: # check_call not defined, Python < 2.5
try: