コード例 #1
0
    def preview_or_run_operations(self, really_delete, operations=None):
        """Preview operations or run operations (delete files)"""
		
        assert(isinstance(really_delete, bool))
        import Worker
        self.start_time = None
        if None == operations:
            operations = {}
            for operation in self.get_selected_operations():
                operations[operation] = self.get_operation_options(operation)
        assert(isinstance(operations, dict))
        if 0 == len(operations):
            GuiBasic.message_dialog(self.window,
                                    _("You must select an operation"),
                                    gtk.MESSAGE_WARNING, gtk.BUTTONS_OK)
            return
        try:
            self.set_sensitive(True)
            self.textbuffer.set_text("")
            self.progressbar.show()
            print "STOP NOW"
            print self,stop_now
            self.worker = Worker.Worker(self, really_delete, operations, self.stop_now)
        except:
            traceback.print_exc()
            err = str(sys.exc_info()[1])
            self.append_text(err + "\n", 'error')
        else:
            self.start_time = time.time()
            worker = self.worker.run()
            gobject.idle_add(worker.next)
コード例 #2
0
ファイル: Windows.py プロジェクト: pythonmagic/bleachbit
def get_autostart_path():
    """Return the path of the BleachBit shortcut in the user's startup folder"""
    try:
        startupdir = shell.SHGetSpecialFolderPath(None, shellcon.CSIDL_STARTUP)
    except:
        # example of failure
        # https://www.bleachbit.org/forum/error-windows-7-x64-bleachbit-091
        logger = logging.getLogger(__name__)
        logger.exception('exception in get_autostart_path()')
        msg = 'Error finding user startup folder: %s ' % (str(
            sys.exc_info()[1]))
        import GuiBasic
        GuiBasic.message_dialog(None, msg)
        # as a fallback, guess
        # Windows XP: C:\Documents and Settings\(username)\Start Menu\Programs\Startup
        # Windows 7:
        # C:\Users\(username)\AppData\Roaming\Microsoft\Windows\Start
        # Menu\Programs\Startup
        startupdir = os.path.expandvars(
            '$USERPROFILE\\Start Menu\\Programs\\Startup')
        if not os.path.exists(startupdir):
            startupdir = os.path.expandvars(
                '$APPDATA\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup'
            )
    return os.path.join(startupdir, 'bleachbit.lnk')
コード例 #3
0
ファイル: Common.py プロジェクト: hotelzululima/bleachbit
def environ(varname, csidl):
    try:
        os.environ[varname] = shell.SHGetSpecialFolderPath(None, csidl)
    except:
        traceback.print_exc()
        msg = 'Error setting environemnt variable "%s": %s ' % (varname, str(sys.exc_info()[1]))
        import GuiBasic
        GuiBasic.message_dialog(None, msg)
コード例 #4
0
ファイル: Common.py プロジェクト: kleopatra999/bleachbit
def environ(varname, csidl):
    try:
        os.environ[varname] = shell.SHGetSpecialFolderPath(None, csidl)
    except:
        traceback.print_exc()
        msg = 'Error setting environemnt variable "%s": %s ' % (
            varname, str(sys.exc_info()[1]))
        import GuiBasic
        GuiBasic.message_dialog(None, msg)
コード例 #5
0
 def set_cleaner(self, path, model, parent_window, value=None):
     """Activate or deactive option of cleaner."""
     if None == value:
         # if not value given, toggle current value
         value = not model[path][1]
     assert(type(value) is types.BooleanType)
     assert(type(model) is gtk.TreeStore)
     cleaner_id = None
     i = path
     if type(i) is str:
         # type is either str or gtk.TreeIter
         i = model.get_iter(path)
     parent = model.iter_parent(i)
     if None != parent:
         # this is an option (child), not a cleaner (parent)
         cleaner_id = model[parent][2]
         option_id = model[path][2]
     if cleaner_id and value:
         # when toggling an option, present any warnings
         warning = backends[cleaner_id].get_warning(option_id)
         # TRANSLATORS: %(cleaner) may be Firefox, System, etc.
         # %(option) may be cache, logs, cookies, etc.
         # %(warning) may be 'This option is really slow'
         msg = _("Warning regarding %(cleaner)s - %(option)s:\n\n%(warning)s") % \
             {'cleaner': model[parent][0],
              'option': model[path][0],
              'warning': warning}
         if warning:
             resp = GuiBasic.message_dialog(parent_window,
                                            msg,
                                            gtk.MESSAGE_WARNING, gtk.BUTTONS_OK_CANCEL)
             if gtk.RESPONSE_OK != resp:
                 # user cancelled, so don't toggle option
                 return
     model[path][1] = value
コード例 #6
0
ファイル: Windows.py プロジェクト: hotelzululima/bleachbit
def get_autostart_path():
    """Return the path of the BleachBit shortcut in the user's startup folder"""
    try:
        startupdir = shell.SHGetSpecialFolderPath(None, shellcon.CSIDL_STARTUP)
    except:
        # example of failure http://bleachbit.sourceforge.net/forum/error-windows-7-x64-bleachbit-091
        traceback.print_exc()
        msg = 'Error finding user startup folder: %s ' % (str(sys.exc_info()[1]))
        import GuiBasic
        GuiBasic.message_dialog(None, msg)
        # as a fallback, guess
        # Windows XP: C:\Documents and Settings\(username)\Start Menu\Programs\Startup
        # Windows 7: C:\Users\(username)\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
        startupdir = os.path.expandvars('$USERPROFILE\\Start Menu\\Programs\\Startup')
        if not os.path.exists(startupdir):
            startupdir = os.path.expandvars('$APPDATA\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup')
    return os.path.join(startupdir, 'bleachbit.lnk')