summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2017-02-05 11:00:44 -0500
committerTodd Leonhardt <todd.leonhardt@gmail.com>2017-02-05 11:00:44 -0500
commit59bd32f5d4d2b04522b54b0a042d2d69fc7ed710 (patch)
treea708455cff1b4633d7a620a1ccfa7b447400256b /cmd2.py
parent7f4fec38a943671e15275ac47b0ec398106159cf (diff)
downloadcmd2-git-59bd32f5d4d2b04522b54b0a042d2d69fc7ed710.tar.gz
Removed an except clause which was only there to support Python 2.4 on Linux.
Since we don't support versions of Python before 2.7 anymore, this was not needed.
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py18
1 files changed, 2 insertions, 16 deletions
diff --git a/cmd2.py b/cmd2.py
index 1f4698f5..1a43a47b 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -234,9 +234,10 @@ pastebufferr = """Redirecting to or from paste buffer requires %s
to be installed on operating system.
%s"""
+# Can we access the clipboard?
+can_clip = False
if sys.platform == "win32":
# Running on Windows
- can_clip = False
try:
import win32clipboard
@@ -265,7 +266,6 @@ if sys.platform == "win32":
write_to_paste_buffer = get_paste_buffer
elif sys.platform == 'darwin':
# Running on Mac OS X
- can_clip = False
try:
# Warning: subprocess.call() and subprocess.check_call() should never be called with stdout=PIPE or stderr=PIPE
# because the child process will block if it generates enough output to a pipe to fill up the OS pipe buffer.
@@ -298,23 +298,10 @@ elif sys.platform == 'darwin':
write_to_paste_buffer = get_paste_buffer
else:
# Running on Linux
- can_clip = False
try:
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:
- teststring = 'Testing for presence of xclip.'
- xclipproc = subprocess.Popen('xclip -sel clip', shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
- xclipproc.stdin.write(teststring)
- xclipproc.stdin.close()
- xclipproc = subprocess.Popen('xclip -o -sel clip', shell=True, stdout=subprocess.PIPE,
- stdin=subprocess.PIPE)
- if xclipproc.stdout.read() == teststring:
- can_clip = True
- except Exception: # hate a bare Exception call, but exception classes vary too much b/t stdlib versions
- pass
except Exception:
pass # something went wrong with xclip and we cannot use it
if can_clip:
@@ -336,7 +323,6 @@ else:
def get_paste_buffer(*args):
raise OSError(pastebufferr % ('xclip', 'On Debian/Ubuntu, install with "sudo apt-get install xclip"'))
-
write_to_paste_buffer = get_paste_buffer
pyparsing.ParserElement.setDefaultWhitespaceChars(' \t')