예제 #1
0
 def diagnostic_dialog(self, parent):
     """Show diagnostic information"""
     dialog = gtk.Dialog(_("System information"), parent)
     dialog.resize(600, 400)
     txtbuffer = gtk.TextBuffer()
     import Diagnostic
     txt = Diagnostic.diagnostic_info()
     txtbuffer.set_text(txt)
     textview = gtk.TextView(txtbuffer)
     textview.set_editable(False)
     swindow = gtk.ScrolledWindow()
     swindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
     swindow.add_with_viewport(textview)
     dialog.vbox.pack_start(swindow)
     dialog.add_buttons(
         gtk.STOCK_COPY, 100, gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
     dialog.show_all()
     while True:
         rc = dialog.run()
         if 100 == rc:
             clipboard = gtk.clipboard_get()
             clipboard.set_text(txt)
         else:
             break
     dialog.hide()
예제 #2
0
파일: CLI.py 프로젝트: hamrogeet/stackfor
def process_cmd_line():
    """Parse the command line and execute given commands."""
    # TRANSLATORS: This is the command line usage.  Don't translate
    # %prog, but do translate usage, options, cleaner, and option.
    # More information about the command line is here
    # http://bleachbit.sourceforge.net/documentation/command-line
    usage = _("usage: %prog [options] cleaner.option1 cleaner.option2")
    parser = optparse.OptionParser(usage)
    parser.add_option("-l", "--list-cleaners", action="store_true",
                      help=_("list cleaners"))
    parser.add_option("-c", "--clean", action="store_true",
                      # TRANSLATORS: predefined cleaners are for applications, such as Firefox and Flash.
                      # This is different than cleaning an arbitrary file, such as a
                      # spreadsheet on the desktop.
                      help=_("run cleaners to delete files and make other permanent changes"))
    parser.add_option("-s", "--shred", action="store_true",
                      help=_("shred specific files or folders"))
    parser.add_option("--sysinfo", action="store_true",
                      help=_("show system information"))
    parser.add_option("--gui", action="store_true",
                      help=_("launch the graphical interface"))
    if 'nt' == os.name:
        uac_help = _("do not prompt for administrator privileges")
    else:
        uac_help = optparse.SUPPRESS_HELP
    parser.add_option("--no-uac", action="store_true", help=uac_help)
    parser.add_option("-p", "--preview", action="store_true",
                      help=_("preview files to be deleted and other changes"))
    parser.add_option("--preset", action="store_true",
                      help=_("use options set in the graphical interface"))
    if 'nt' == os.name:
        parser.add_option("--update-winapp2", action="store_true",
                          help=_("update winapp2.ini, if a new version is available"))
    parser.add_option("-v", "--version", action="store_true",
                      help=_("output version information and exit"))
    parser.add_option('-o', '--overwrite', action='store_true',
                      help=_('overwrite files to hide contents'))
    (options, args) = parser.parse_args()
    did_something = False
    if options.version:
        print """
BleachBit version %s
Copyright (C) 2014 Andrew Ziem.  All rights reserved.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.""" % APP_VERSION
        sys.exit(0)
    if 'nt' == os.name and options.update_winapp2:
        import Update
        print "Checking online for updates to winapp2.ini"
        Update.check_updates(False, True,
                             lambda x: sys.stdout.write("%s\n" % x),
                             lambda: None)
        # updates can be combined with --list, --preview, --clean
        did_something = True
    if options.list_cleaners:
        list_cleaners()
        sys.exit(0)
    if options.preview or options.clean:
        operations = args_to_operations(args, options.preset)
        if not operations:
            print 'ERROR: No work to do.  Specify options.'
            sys.exit(1)
    if options.preview:
        preview_or_clean(operations, False)
        sys.exit(0)
    if options.overwrite:
        if not options.clean or options.shred:
            print 'NOTE: --overwrite is intended only for use with --clean'
        Options.options.set('shred', True, commit=False)
    if options.clean:
        preview_or_clean(operations, True)
        sys.exit(0)
    if options.gui:
        import gtk
        import GUI
        shred_paths = args if options.shred else None
        GUI.GUI(uac=not options.no_uac, shred_paths=shred_paths)
        gtk.main()
        sys.exit(0)
    if options.shred:
        # delete arbitrary files without GUI
        # create a temporary cleaner object
        backends['_gui'] = create_simple_cleaner(args)
        operations = {'_gui': ['files']}
        preview_or_clean(operations, True)
        sys.exit(0)
    if options.sysinfo:
        import Diagnostic
        print Diagnostic.diagnostic_info()
        sys.exit(0)
    if not did_something:
        parser.print_help()