home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / lib / hplip / fab < prev    next >
Encoding:
Text File  |  2006-08-30  |  3.4 KB  |  133 lines

  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # (c) Copyright 2003-2006 Hewlett-Packard Development Company, L.P.
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  19. #
  20. # Author: Don Welch
  21. #
  22.  
  23. __version__ = '1.1'
  24. __title__ = "Fax Address Book"
  25. __doc__ = "A simple fax address book for HPLIP."
  26.  
  27. from base.g import *
  28. from base import utils
  29.  
  30. import getopt
  31.  
  32. # PyQt
  33. if not utils.checkPyQtImport():
  34.     log.error("PyQt/Qt initialization error. Please check install of PyQt/Qt and try again.")
  35.     sys.exit(1)
  36.  
  37. from qt import *
  38.  
  39. from ui.faxaddrbookform import FaxAddrBookForm
  40.  
  41. app = None
  42. addrbook = None
  43.  
  44. def additional_copyright():
  45.     log.info("Includes code from KirbyBase 1.8.1")
  46.     log.info("Copyright (c) Jamey Cribbs (jcribbs@twmi.rr.com)")
  47.     log.info("Licensed under the Python Software Foundation License.")
  48.     log.info("")
  49.  
  50. USAGE = [(__doc__, "", "name", True),
  51.          ("Usage: hp-fab [OPTIONS]", "", "summary", True),
  52.          utils.USAGE_OPTIONS,
  53.          utils.USAGE_LOGGING1, utils.USAGE_LOGGING2, utils.USAGE_LOGGING3,
  54.          utils.USAGE_HELP,
  55.          utils.USAGE_SEEALSO,
  56.          ("hp-sendfax", "", "seealso", False),
  57.          ]
  58.          
  59. def usage(typ='text'):
  60.     if typ == 'text':
  61.         utils.log_title(__title__, __version__)
  62.         additional_copyright()
  63.         
  64.     utils.format_text(USAGE, typ, __title__, 'hp-fab', __version__)
  65.     sys.exit(0)
  66.  
  67.     
  68.  
  69.  
  70. def main(args):
  71.     try:
  72.         opts, args = getopt.getopt(sys.argv[1:], 'l:hg', 
  73.             ['level=', 'help', 'help-rest', 'help-man'])
  74.  
  75.     except getopt.GetoptError:
  76.         usage()
  77.  
  78.     if os.getenv("HPLIP_DEBUG"):
  79.         log.set_level('debug')
  80.         
  81.     for o, a in opts:
  82.  
  83.         if o in ('-l', '--logging'):
  84.             log_level = a.lower().strip()
  85.             if not log.set_level(log_level):
  86.                 usage()
  87.                 
  88.         elif o == '-g':
  89.             log.set_level('debug')
  90.  
  91.         elif o in ('-h', '--help'):
  92.             usage()
  93.             
  94.         elif o == '--help-rest':
  95.             usage('rest')
  96.             
  97.         elif o == '--help-man':
  98.             usage('man')
  99.             
  100.  
  101.     utils.log_title(__title__, __version__)
  102.     additional_copyright()
  103.     
  104.     log.set_module('fab')
  105.  
  106.     # Security: Do *not* create files that other users can muck around with
  107.     os.umask (0077)
  108.  
  109.     # create the main application object
  110.     global app
  111.     app = QApplication(sys.argv)
  112.  
  113.     global addrbook
  114.     addrbook = FaxAddrBookForm()
  115.     addrbook.show()
  116.     app.setMainWidget(addrbook)
  117.  
  118.     user_config = os.path.expanduser('~/.hplip.conf')
  119.     loc = utils.loadTranslators(app, user_config)
  120.  
  121.     try:
  122.         log.debug("Starting GUI loop...")
  123.         app.exec_loop()
  124.     except KeyboardInterrupt:
  125.         pass
  126.     except:
  127.         log.exception()
  128.  
  129.     return 0
  130.  
  131. if __name__ == "__main__":
  132.     sys.exit(main(sys.argv[1:]))
  133.