summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcatherine devlin <catherine.devlin@gmail.com>2011-02-02 08:13:03 -0500
committercatherine devlin <catherine.devlin@gmail.com>2011-02-02 08:13:03 -0500
commit98cca9f46ff80d2a0b58fe09afeaba6b75d2c7b6 (patch)
tree85d5170e8059daeeae3e4d763fce05ae7bd0be89
parent5655bd33f1796046c00823409c6d386b195717b1 (diff)
downloadcmd2-hg-98cca9f46ff80d2a0b58fe09afeaba6b75d2c7b6.tar.gz
fix xclip trapping bug
-rwxr-xr-xcmd2.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/cmd2.py b/cmd2.py
index d859c37..0740043 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -189,15 +189,16 @@ else:
subprocess.check_call('xclip -o -sel clip', shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
can_clip = True
except AttributeError: # check_call not defined, Python < 2.5
- 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 (subprocess.CalledProcessError, OSError, IOError):
- pass
+ 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 (subprocess.CalledProcessError, OSError, IOError):
+ pass
if can_clip:
def get_paste_buffer():
xclipproc = subprocess.Popen('xclip -o -sel clip', shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE)