0

This is the error: Permission Error: Copying of text from this document is not allowed.

I am opening a .exe file on windows. So regular try except block does not seem to catch it. Neither does OSError.

TheProgramMAN123
  • 487
  • 1
  • 5
  • 13
  • 1
    https://stackoverflow.com/questions/25079140/python-subprocess-popen-check-for-success-and-errors#25079374 may be able to help. You'll have to deal with errors directly from a `subprocess` object. – Major Sep 12 '18 at 19:38
  • I tried subprocess.CalledProcessError The problem is I want to call Permission Error, I get an error if I do subprocess.CalledProcessError. – TheProgramMAN123 Sep 13 '18 at 02:12

2 Answers2

1

I solved it with the following:

try:
    """code here"""
except subprocess.CalledProcessError:
    """unlock files and try again"""
TheProgramMAN123
  • 487
  • 1
  • 5
  • 13
0

Try

exception PermissionError

Raised when trying to run an operation without the adequate access rights - for example filesystem permissions. Corresponds to errno EACCES and EPERM.

If you specified irrelevant Exception while trying to catch permission error, I wouldn't be surprised they it is caught

David Hu
  • 78
  • 7