diff options
| author | Sebastian Heinlein <sebastian.heinlein@web.de> | 2006-03-12 13:26:54 +0100 |
|---|---|---|
| committer | Sebastian Heinlein <sebastian.heinlein@web.de> | 2006-03-12 13:26:54 +0100 |
| commit | c9594feff0700d7c6bfc08dcba408c2d30dadfad (patch) | |
| tree | 897b7d4ae59a35f49301c4164a6a082e3d5b13f6 /UpdateManager/Common | |
| parent | df9feb812dd0c176e89d733121536abbc237123c (diff) | |
| download | python-apt-c9594feff0700d7c6bfc08dcba408c2d30dadfad.tar.gz | |
* only show the help button if a help viewer is installed (currently only
yelp is supported - have not found anyone who could help me on khelpcenter
yet)
* do not run the help viewer as root
* do not depend on the gnome python module anymore
Diffstat (limited to 'UpdateManager/Common')
| -rw-r--r-- | UpdateManager/Common/HelpViewer.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/UpdateManager/Common/HelpViewer.py b/UpdateManager/Common/HelpViewer.py new file mode 100644 index 00000000..c8b099cc --- /dev/null +++ b/UpdateManager/Common/HelpViewer.py @@ -0,0 +1,33 @@ +# helpviewer.py + +import os +import subprocess + +# Hardcoded list of available help viewers +# FIXME: khelpcenter support would be nice +#KNOWN_VIEWERS = ["/usr/bin/yelp", "/usr/bin/khelpcenter"] +KNOWN_VIEWERS = ["/usr/bin/yelp"] + +class HelpViewer: + def __init__(self, docu): + self.command = [] + self.docu = docu + for viewer in KNOWN_VIEWERS: + if os.path.exists(viewer): + self.command = [viewer, "ghelp:%s" % docu] + break + + def check(self): + """check if a viewer is available""" + if self.command == []: + return False + else: + return True + + def run(self): + """open the documentation in the viewer""" + # avoid running the help viewer as root + if os.getuid() == 0 and os.environ.has_key('SUDO_USER'): + self.command = ['sudo', '-u', os.environ['SUDO_USER']] +\ + self.command + subprocess.Popen(self.command) |
