~ubuntu-core-dev/update-manager/main

« back to all changes in this revision

Viewing changes to UpdateManager/HelpViewer.py

  • Committer: Michael Vogt
  • Date: 2005-11-15 14:44:23 UTC
  • Revision ID: egon@top-20051115144423-5d01f44d63b99ecc
* build-system tweaks

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# helpviewer.py
2
 
# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 4; coding: utf-8 -*-
3
 
 
4
 
import os
5
 
import subprocess
6
 
 
7
 
# Hardcoded list of available help viewers
8
 
# FIXME: khelpcenter support would be nice
9
 
#KNOWN_VIEWERS = ["/usr/bin/yelp", "/usr/bin/khelpcenter"]
10
 
KNOWN_VIEWERS = ["/usr/bin/yelp"]
11
 
 
12
 
 
13
 
class HelpViewer:
14
 
    def __init__(self, docu):
15
 
        self.command = []
16
 
        self.docu = docu
17
 
        for viewer in KNOWN_VIEWERS:
18
 
            if os.path.exists(viewer):
19
 
                self.command = [viewer, "help:%s" % docu]
20
 
                break
21
 
 
22
 
    def check(self):
23
 
        """check if a viewer is available"""
24
 
        if self.command == []:
25
 
            return False
26
 
        else:
27
 
            return True
28
 
 
29
 
    def run(self):
30
 
        """open the documentation in the viewer"""
31
 
        # avoid running the help viewer as root
32
 
        if os.getuid() == 0 and 'SUDO_USER' in os.environ:
33
 
            self.command = ['sudo', '-u', os.environ['SUDO_USER']] +\
34
 
                self.command
35
 
        subprocess.Popen(self.command)