Mercurial > python-cmd2
comparison cmd2.py @ 418:b5f904daae83
fix xclip trapping bug
author | catherine.devlin@gmail.com |
---|---|
date | Wed, 02 Feb 2011 08:13:03 -0500 |
parents | db32ab37051b |
children | fd8a2da973cb |
comparison
equal
deleted
inserted
replaced
417:db32ab37051b | 418:b5f904daae83 |
---|---|
187 can_clip = False | 187 can_clip = False |
188 try: | 188 try: |
189 subprocess.check_call('xclip -o -sel clip', shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE) | 189 subprocess.check_call('xclip -o -sel clip', shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE) |
190 can_clip = True | 190 can_clip = True |
191 except AttributeError: # check_call not defined, Python < 2.5 | 191 except AttributeError: # check_call not defined, Python < 2.5 |
192 teststring = 'Testing for presence of xclip.' | 192 try: |
193 xclipproc = subprocess.Popen('xclip -sel clip', shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE) | 193 teststring = 'Testing for presence of xclip.' |
194 xclipproc.stdin.write(teststring) | 194 xclipproc = subprocess.Popen('xclip -sel clip', shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE) |
195 xclipproc.stdin.close() | 195 xclipproc.stdin.write(teststring) |
196 xclipproc = subprocess.Popen('xclip -o -sel clip', shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE) | 196 xclipproc.stdin.close() |
197 if xclipproc.stdout.read() == teststring: | 197 xclipproc = subprocess.Popen('xclip -o -sel clip', shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE) |
198 can_clip = True | 198 if xclipproc.stdout.read() == teststring: |
199 except (subprocess.CalledProcessError, OSError, IOError): | 199 can_clip = True |
200 pass | 200 except (subprocess.CalledProcessError, OSError, IOError): |
201 pass | |
201 if can_clip: | 202 if can_clip: |
202 def get_paste_buffer(): | 203 def get_paste_buffer(): |
203 xclipproc = subprocess.Popen('xclip -o -sel clip', shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE) | 204 xclipproc = subprocess.Popen('xclip -o -sel clip', shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE) |
204 return xclipproc.stdout.read() | 205 return xclipproc.stdout.read() |
205 def write_to_paste_buffer(txt): | 206 def write_to_paste_buffer(txt): |