コード例 #1
0
ファイル: Unix.py プロジェクト: JulianVolodia/bleachbit
def __is_broken_xdg_desktop_application(config, desktop_pathname):
    """Returns boolean whether application deskop entry file is broken"""
    if not config.has_option('Desktop Entry', 'Exec'):
        logger.info("is_broken_xdg_menu: missing required option 'Exec': '%s'", desktop_pathname)
        return True
    exe = config.get('Desktop Entry', 'Exec').split(" ")[0]
    if not FileUtilities.exe_exists(exe):
        logger.info("is_broken_xdg_menu: executable '%s' does not exist '%s'", exe, desktop_pathname)
        return True
    if 'env' == exe:
        # Wine v1.0 creates .desktop files like this
        # Exec=env WINEPREFIX="/home/z/.wine" wine "C:\\Program
        # Files\\foo\\foo.exe"
        execs = shlex.split(config.get('Desktop Entry', 'Exec'))
        wineprefix = None
        del execs[0]
        while True:
            if 0 <= execs[0].find("="):
                (name, value) = execs[0].split("=")
                if 'WINEPREFIX' == name:
                    wineprefix = value
                del execs[0]
            else:
                break
        if not FileUtilities.exe_exists(execs[0]):
            logger.info("is_broken_xdg_menu: executable '%s' does not exist '%s'", execs[0], desktop_pathname)
            return True
        # check the Windows executable exists
        if wineprefix:
            windows_exe = wine_to_linux_path(wineprefix, execs[1])
            if not os.path.exists(windows_exe):
                logger.info("is_broken_xdg_menu: Windows executable '%s' does not exist '%s'",
                            windows_exe, desktop_pathname)
                return True
    return False
コード例 #2
0
ファイル: Unix.py プロジェクト: thezilione/bleachbit
def __is_broken_xdg_desktop_application(config, desktop_pathname):
    """Returns boolean whether application deskop entry file is broken"""
    if not config.has_option('Desktop Entry', 'Exec'):
        logger.info("is_broken_xdg_menu: missing required option 'Exec': '%s'", desktop_pathname)
        return True
    exe = config.get('Desktop Entry', 'Exec').split(" ")[0]
    if not FileUtilities.exe_exists(exe):
        logger.info("is_broken_xdg_menu: executable '%s' does not exist '%s'", exe, desktop_pathname)
        return True
    if 'env' == exe:
        # Wine v1.0 creates .desktop files like this
        # Exec=env WINEPREFIX="/home/z/.wine" wine "C:\\Program
        # Files\\foo\\foo.exe"
        execs = shlex.split(config.get('Desktop Entry', 'Exec'))
        wineprefix = None
        del execs[0]
        while True:
            if 0 <= execs[0].find("="):
                (name, value) = execs[0].split("=")
                if 'WINEPREFIX' == name:
                    wineprefix = value
                del execs[0]
            else:
                break
        if not FileUtilities.exe_exists(execs[0]):
            logger.info("is_broken_xdg_menu: executable '%s' does not exist '%s'", execs[0], desktop_pathname)
            return True
        # check the Windows executable exists
        if wineprefix:
            windows_exe = wine_to_linux_path(wineprefix, execs[1])
            if not os.path.exists(windows_exe):
                logger.info("is_broken_xdg_menu: Windows executable '%s' does not exist '%s'",
                            windows_exe, desktop_pathname)
                return True
    return False
コード例 #3
0
def run_cleaner_cmd(cmd,
                    args,
                    freed_space_regex=r'[\d.]+[kMGTE]?B?',
                    error_line_regexes=None):
    """Runs a specified command and returns how much space was (reportedly) freed.
    The subprocess shouldn't need any user input and the user should have the
    necessary rights.
    freed_space_regex gets applied to every output line, if the re matches,
    add values captured by the single group in the regex"""
    if not FileUtilities.exe_exists(cmd):
        raise RuntimeError(_('Executable not found: %s') % cmd)
    freed_space_regex = re.compile(freed_space_regex)
    error_line_regexes = [
        re.compile(regex) for regex in error_line_regexes or []
    ]

    env = {'LC_ALL': 'C', 'PATH': os.getenv('PATH')}
    output = subprocess.check_output([cmd] + args,
                                     stderr=subprocess.STDOUT,
                                     universal_newlines=True,
                                     env=env)
    freed_space = 0
    for line in output.split('\n'):
        m = freed_space_regex.match(line)
        if m is not None:
            freed_space += FileUtilities.human_to_bytes(m.group(1))
        for error_re in error_line_regexes:
            if error_re.search(line):
                raise RuntimeError('Invalid output from %s: %s' % (cmd, line))

    return freed_space
コード例 #4
0
ファイル: Action.py プロジェクト: zoonytoons/bleachbit
    def get_commands(self):
        # Checking allows auto-hide to work for non-APT systems
        if not FileUtilities.exe_exists('yum'):
            raise StopIteration

        yield Command.Function(
            None,
            Unix.yum_clean,
            'yum clean all')
コード例 #5
0
ファイル: Action.py プロジェクト: tstenner/bleachbit
    def get_commands(self):
        # Checking allows auto-hide to work for non-APT systems
        if not FileUtilities.exe_exists('yum'):
            raise StopIteration

        yield Command.Function(
            None,
            Unix.yum_clean,
            'yum clean all')
コード例 #6
0
ファイル: Action.py プロジェクト: schlangens/bleachbit
    def get_commands(self):
        # Checking allows auto-hide to work for non-APT systems
        if not FileUtilities.exe_exists('dnf'):
            raise StopIteration

        yield Command.Function(
            None,
            Unix.dnf_autoremove,
            'dnf autoremove')
コード例 #7
0
ファイル: Unix.py プロジェクト: JulianVolodia/bleachbit
def run_cleaner_cmd(cmd, args, freed_space_regex=r'[\d.]+[kMGTE]?B?', error_line_regexes=None):
    """Runs a specified command and returns how much space was (reportedly) freed.
    The subprocess shouldn't need any user input and the user should have the
    necessary rights.
    freed_space_regex gets applied to every output line, if the re matches,
    add values captured by the single group in the regex"""
    if not FileUtilities.exe_exists(cmd):
        raise RuntimeError(_('Executable not found: %s') % cmd)
    freed_space_regex = re.compile(freed_space_regex)
    error_line_regexes = [re.compile(regex) for regex in error_line_regexes or []]

    output = subprocess.check_output([cmd]+args, stderr=subprocess.STDOUT,
                                     universal_newlines=True, env={'LC_ALL': 'C'})

    freed_space = 0
    for line in output.split('\n'):
        m = freed_space_regex.match(line)
        if m is not None:
            freed_space += FileUtilities.human_to_bytes(m.group(1))
        for error_re in error_line_regexes:
            if error_re.search(line):
                raise RuntimeError('Invalid output from %s: %s' % (cmd, line))

    return freed_space
コード例 #8
0
ファイル: Action.py プロジェクト: zoonytoons/bleachbit
 def get_commands(self):
     if FileUtilities.exe_exists('journalctl'):
         yield Command.Function(None, Unix.journald_clean, 'journalctl --vacuum-time=1')
コード例 #9
0
ファイル: Action.py プロジェクト: zoonytoons/bleachbit
 def get_commands(self):
     # Checking executable allows auto-hide to work for non-APT systems
     if FileUtilities.exe_exists('apt-get'):
         yield Command.Function(None,
                                Unix.apt_clean,
                                'apt-get clean')
コード例 #10
0
ファイル: Action.py プロジェクト: vilhelmgray/bleachbit
    def get_commands(self):
        # Checking allows auto-hide to work for non-APT systems
        if not FileUtilities.exe_exists('dnf'):
            return

        yield Command.Function(None, Unix.dnf_clean, 'dnf clean all')
コード例 #11
0
ファイル: Action.py プロジェクト: tstenner/bleachbit
 def get_commands(self):
     if FileUtilities.exe_exists('journalctl'):
         yield Command.Function(None, Unix.journald_clean, 'journalctl --vacuum-time=1')
コード例 #12
0
ファイル: Action.py プロジェクト: tstenner/bleachbit
 def get_commands(self):
     # Checking executable allows auto-hide to work for non-APT systems
     if FileUtilities.exe_exists('apt-get'):
         yield Command.Function(None,
                                Unix.apt_clean,
                                'apt-get clean')