home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / apport / apport-checkreports next >
Encoding:
Text File  |  2009-09-25  |  1.1 KB  |  37 lines

  1. #!/usr/bin/python
  2.  
  3. # Check if there are new reports for the invoking user. Exit with 0 if new
  4. # reports are available, or with 1 if not.
  5. #
  6. # Copyright (c) 2006 Canonical Ltd.
  7. # Author: Martin Pitt <martin.pitt@ubuntu.com>
  8. #
  9. # This program is free software; you can redistribute it and/or modify it
  10. # under the terms of the GNU General Public License as published by the
  11. # Free Software Foundation; either version 2 of the License, or (at your
  12. # option) any later version.  See http://www.gnu.org/copyleft/gpl.html for
  13. # the full text of the license.
  14.  
  15. import sys, os.path, optparse
  16.  
  17. from apport.fileutils import get_new_reports, get_new_system_reports
  18.  
  19. # parse command line options
  20. optparser = optparse.OptionParser('%prog [options]')
  21. optparser.add_option('-s', '--system',
  22.     help='Check for crash reports from system users.', action='store_true',
  23.         dest='system', default=False)
  24. options, args = optparser.parse_args()
  25.  
  26. if options.system:
  27.     reports = get_new_system_reports()
  28. else:
  29.     reports = get_new_reports()
  30.  
  31. if len(reports) > 0:
  32.     for r in reports:
  33.         print r.split('.')[0].split('_')[-1]
  34.     sys.exit(0)
  35. else:
  36.     sys.exit(1)
  37.