options --help and --version should not require a backend to be present

Bug #931474 reported by Göktürk Yüksek
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

If DISPLAY environment variable is unset, running disper with either --help or --version results in:

Traceback (most recent call last):
  File "./disper.py", line 360, in <module>
  File "./disper.py", line 352, in main
    disper = Disper()
  File "./disper.py", line 54, in __init__
    self.switcher = Switcher()
  File "/tmp/dispercur/src/switcher/__init__.py", line 30, in __init__
  File "/tmp/dispercur/src/switcher/__init__.py", line 53, in _probe_backend
    raise Exception('No suitable backend found')
Exception: No suitable backend found

It turns out that at make stage 'help2man' needs to run src/disper.py with '--version' and '--help' options and capture its output. There are several situations where DISPLAY env variable may not be present at that time (in my case it was Gentoo's package manager). I solved the issue by explicitly checking for {'-h', '--help', '--version'} in sys.argv right after initializing the options. The patch is attached.

Disper: 0.3.0
Python: 2.7.2

Revision history for this message
Göktürk Yüksek (gktrk) wrote :
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers