Travis-Encrypt icon indicating copy to clipboard operation
Travis-Encrypt copied to clipboard

Exception when using --clipboard [Pyperclip could not find a copy/paste mechanism for your system.]

Open JoelMon opened this issue 6 years ago • 7 comments

System

Ubuntu 10.04

Python Installed

  • python3.8
  • python3.7
  • python2.7

Installation

Installed travis-encrypt via pip3

travis-encrypt (1.3.1)                          - Encrypt passwords for use with Travis CI.
  INSTALLED: 1.3.1 (latest)

Python's Trackback

Traceback (most recent call last):
  File "/home/user/.local/bin/travis-encrypt", line 10, in <module>
    sys.exit(cli())
  File "/home/user/.local/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/user/.local/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/user/.local/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/user/.local/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/user/.local/lib/python3.7/site-packages/travis/cli.py", line 110, in cli
    pyperclip.copy(encrypted_password)
  File "/home/user/.local/lib/python3.7/site-packages/pyperclip/__init__.py", line 616, in lazy_load_stub_copy
    return copy(text)
  File "/home/user/.local/lib/python3.7/site-packages/pyperclip/__init__.py", line 301, in __call__
    raise PyperclipException(EXCEPT_MSG)
pyperclip.PyperclipException: 
    Pyperclip could not find a copy/paste mechanism for your system.
    For more information, please visit https://pyperclip.readthedocs.io/en/latest/introduction.html#not-implemented-error 

JoelMon avatar May 26 '19 23:05 JoelMon

Thanks for the report. Does installing xsel or xclip from apt help solve this problem?

mandeep avatar May 26 '19 23:05 mandeep

Works as expected when xsel or xclip are installed.

Feature request

  • Catch raise PyperclipException exception
    • Exit elegantly instead with an ugly crash trackback
    • Provide more information to the enduser on how to fix the problem

      Travis-Encrypt Error: It seems you do not have a copy/paste mechanism for your system. If on Linux try sudo apt-install xclip.

  • Provide more information in help

    help="Copy the encrypted password to the clipboard. Note: xclip or xsel must be install on the system."

JoelMon avatar May 29 '19 19:05 JoelMon

If you want to incorporate the above ideas, or in part, would it be ok if I give it a shot and merge in? Seems simple enough for me to handle.

JoelMon avatar May 29 '19 23:05 JoelMon

Sure! All PRs are appreciated. :)

mandeep avatar May 30 '19 04:05 mandeep

Wonderful! tomorrow I'll get started.

JoelMon avatar May 30 '19 04:05 JoelMon

What do you think about this error message:

Pyperclip could not find a copy/paste mechanism for your system.

On Windows, no additional modules are needed.
On Mac, the pyobjc module is used, falling back to the pbcopy and pbpaste cli
    commands. (These commands should come with OS X.).
On Linux, install xclip or xsel via package manager. For example, in Debian:
    sudo apt-get install xclip
    sudo apt-get install xsel

Otherwise on Linux, you will need the gtk or PyQt5/PyQt4 modules installed.

gtk and PyQt4 modules are not available for Python 3,
and this module does not work with PyGObject yet.

Note: There seems to be a way to get gtk on Python 3, according to:
    https://askubuntu.com/questions/697397/python3-is-not-supporting-gtk-module

Cygwin is currently not supported.

For more information, please visit https://pyperclip.readthedocs.io/en/latest/introduction.html#not-implemented-error 

Is that good or too much?

JoelMon avatar May 30 '19 13:05 JoelMon

This is a great start! I can think of a few changes.

Instead of writing a message for Windows and Mac, I would write something along the lines of If you're seeing this error on Windows or Mac please visit https://pyperclip.readthedocs.io/en/latest/introduction.html#not-implemented-error or maybe point to the pyperclip issue tracker.

Also, instead of writing things about gtk, PyQt, and PyGObject, I would direct people to the same website. I don't think it's Travis-Encrypt's job to solve dependency issues apart from xsel and xclip.

mandeep avatar May 31 '19 02:05 mandeep