diff options
author | VG <vg@devys.org> | 2016-12-09 12:10:53 +0100 |
---|---|---|
committer | VG <vg@devys.org> | 2016-12-09 12:10:53 +0100 |
commit | f0e69d196e8733fe888aa5f18d6aeca11a79e739 (patch) | |
tree | 645a8f090f94a2d40f0f8921df1df8c1ed5c5abb | |
parent | f942001c3eea6fedb838ebf22720ab507c77e192 (diff) | |
download | clip-f0e69d196e8733fe888aa5f18d6aeca11a79e739.tar.gz clip-f0e69d196e8733fe888aa5f18d6aeca11a79e739.tar.bz2 clip-f0e69d196e8733fe888aa5f18d6aeca11a79e739.zip |
fix first and empty use case
-rwxr-xr-x | clip | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -52,8 +52,12 @@ if __name__ == '__main__': clipboard_filepath = '/dev/shm/%s-clipboard' % getpass.getuser() if(sys.stdin.isatty()): # Should write clipboard contents out to stdout - with secure_open(clipboard_filepath, 'rb') as fo: - sys.stdout.buffer.write(fo.read()) + try: + with secure_open(clipboard_filepath, 'rb') as fo: + sys.stdout.buffer.write(fo.read()) + except FileNotFoundError: + # equivalent to an empty file + pass elif(sys.stdout.isatty()): # Should save stdin to clipboard with secure_open(clipboard_filepath, 'wb') as fo: |