home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / python2.6 / dist-packages / UpdateManager / HelpViewer.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-10-12  |  1.4 KB  |  42 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import os
  5. import subprocess
  6. KNOWN_VIEWERS = [
  7.     '/usr/bin/yelp']
  8.  
  9. class HelpViewer:
  10.     
  11.     def __init__(self, docu):
  12.         self.command = []
  13.         self.docu = docu
  14.         for viewer in KNOWN_VIEWERS:
  15.             if os.path.exists(viewer):
  16.                 self.command = [
  17.                     viewer,
  18.                     'ghelp:%s' % docu]
  19.                 break
  20.                 continue
  21.         
  22.  
  23.     
  24.     def check(self):
  25.         '''check if a viewer is available'''
  26.         if self.command == []:
  27.             return False
  28.         return True
  29.  
  30.     
  31.     def run(self):
  32.         '''open the documentation in the viewer'''
  33.         if os.getuid() == 0 and os.environ.has_key('SUDO_USER'):
  34.             self.command = [
  35.                 'sudo',
  36.                 '-u',
  37.                 os.environ['SUDO_USER']] + self.command
  38.         
  39.         subprocess.Popen(self.command)
  40.  
  41.  
  42.