本文整理汇总了Python中bleachbit.FileUtilities.exe_exists方法的典型用法代码示例。如果您正苦于以下问题:Python FileUtilities.exe_exists方法的具体用法?Python FileUtilities.exe_exists怎么用?Python FileUtilities.exe_exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bleachbit.FileUtilities
的用法示例。
在下文中一共展示了FileUtilities.exe_exists方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __is_broken_xdg_desktop_application
# 需要导入模块: from bleachbit import FileUtilities [as 别名]
# 或者: from bleachbit.FileUtilities import exe_exists [as 别名]
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: get_commands
# 需要导入模块: from bleachbit import FileUtilities [as 别名]
# 或者: from bleachbit.FileUtilities import exe_exists [as 别名]
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')
示例3: run_cleaner_cmd
# 需要导入模块: from bleachbit import FileUtilities [as 别名]
# 或者: from bleachbit.FileUtilities import exe_exists [as 别名]
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