summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2017-06-28 22:02:29 -0400
committerGitHub <noreply@github.com>2017-06-28 22:02:29 -0400
commitf60cf3fc866a3d8c466c29268c3a6c76967ea784 (patch)
tree863cdaf1877fecc7652791b7054e594b11bb5762
parentf52765c63c7b69ec3495098e3fc3891bc7b8a4ce (diff)
parentd86d9440a5a96bdde48b1ca8853941db29c2e8fe (diff)
downloadcmd2-git-f60cf3fc866a3d8c466c29268c3a6c76967ea784.tar.gz
Merge pull request #145 from python-cmd2/xclip_linux
Linux clipboard interaction improvements
-rw-r--r--.travis.yml3
-rwxr-xr-xcmd2.py10
2 files changed, 7 insertions, 6 deletions
diff --git a/.travis.yml b/.travis.yml
index 270fe4f7..5deb0667 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,7 @@
language: python
+
sudo: false # false enables container-based build for fast boot times on Linux
+
matrix:
include:
- os: linux
@@ -37,6 +39,7 @@ matrix:
# env:
# - TOXENV=py36
# - BREW_INSTALL=python3
+
install:
- pip install tox
# - |
diff --git a/cmd2.py b/cmd2.py
index 87140ad4..fb7d78bb 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -398,8 +398,7 @@ else:
# Running on Linux
try:
with open(os.devnull, 'w') as DEVNULL:
- subprocess.check_call('xclip -o -sel clip', shell=True, stdin=subprocess.PIPE, stdout=DEVNULL,
- stderr=DEVNULL)
+ subprocess.check_call(['uptime', '|', 'xclip'], stdout=DEVNULL, stderr=DEVNULL)
can_clip = True
except (subprocess.CalledProcessError, OSError, IOError):
pass # something went wrong with xclip and we cannot use it
@@ -409,8 +408,7 @@ else:
:return: str - contents of the clipboard
"""
- xclipproc = subprocess.Popen('xclip -o -sel clip', shell=True, stdout=subprocess.PIPE,
- stdin=subprocess.PIPE)
+ xclipproc = subprocess.Popen(['xclip', '-o', '-selection', 'clipboard'], stdout=subprocess.PIPE, stdin=subprocess.PIPE)
stdout, stderr = xclipproc.communicate()
if six.PY3:
return stdout.decode()
@@ -422,7 +420,7 @@ else:
:param txt: str - text to paste to the clipboard
"""
- xclipproc = subprocess.Popen('xclip -sel clip', shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
+ xclipproc = subprocess.Popen(['xclip', '-selection', 'clipboard'], stdout=subprocess.PIPE, stdin=subprocess.PIPE)
if six.PY3:
xclipproc.stdin.write(txt.encode())
else:
@@ -430,7 +428,7 @@ else:
xclipproc.stdin.close()
# but we want it in both the "primary" and "mouse" clipboards
- xclipproc = subprocess.Popen('xclip', shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
+ xclipproc = subprocess.Popen(['xclip'], stdout=subprocess.PIPE, stdin=subprocess.PIPE)
if six.PY3:
xclipproc.stdin.write(txt.encode())
else: