当前位置: 首页>>代码示例>>Python>>正文


Python General.run_external方法代码示例

本文整理汇总了Python中General.run_external方法的典型用法代码示例。如果您正苦于以下问题:Python General.run_external方法的具体用法?Python General.run_external怎么用?Python General.run_external使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在General的用法示例。


在下文中一共展示了General.run_external方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_proc_swaps

# 需要导入模块: import General [as 别名]
# 或者: from General import run_external [as 别名]
def get_proc_swaps():
    """Return the output of 'swapon -s'"""
    # Usually 'swapon -s' is identical to '/proc/swaps'
    # Here is one exception: https://bugs.launchpad.net/ubuntu/+source/bleachbit/+bug/1092792
    (rc, stdout, _) = General.run_external(["swapon", "-s"])
    if 0 == rc:
        return stdout
    print 'debug: "swapoff -s" failed so falling back to /proc/swaps'
    return open("/proc/swaps").read()
开发者ID:hotelzululima,项目名称:bleachbit,代码行数:11,代码来源:Memory.py

示例2: is_process_running_wmic

# 需要导入模块: import General [as 别名]
# 或者: from General import run_external [as 别名]
def is_process_running_wmic(name):
    """Return boolean whether process (like firefox.exe) is running

    Works on Windows XP Professional but not on XP Home
    """

    clean_name = re.sub("[^A-Za-z\.]", "_", name).lower()
    args = ["wmic", "path", "win32_process", "where", "caption='%s'" % clean_name, "get", "Caption"]
    (_, stdout, _) = General.run_external(args)
    return stdout.lower().find(clean_name) > -1
开发者ID:abobov,项目名称:bleachbit,代码行数:12,代码来源:Windows.py

示例3: is_process_running_wmic

# 需要导入模块: import General [as 别名]
# 或者: from General import run_external [as 别名]
def is_process_running_wmic(name):
    """Return boolean whether process (like firefox.exe) is running

    Works on Windows XP Professional but not on XP Home
    """

    clean_name = re.sub('[^A-Za-z\.]', '_', name).lower()
    args = ['wmic', 'path', 'win32_process', 'where', "caption='%s'" % clean_name, 'get', 'Caption']
    (_, stdout, _) = General.run_external(args)
    return stdout.lower().find(clean_name) > -1
开发者ID:hotelzululima,项目名称:bleachbit,代码行数:12,代码来源:Windows.py

示例4: get_swap_uuid

# 需要导入模块: import General [as 别名]
# 或者: from General import run_external [as 别名]
def get_swap_uuid(device):
    """Find the UUID for the swap device"""
    uuid = None
    args = ["blkid", device, "-s", "UUID"]
    (_, stdout, _) = General.run_external(args)
    for line in stdout.split("\n"):
        # example: /dev/sda5: UUID="ee0e85f6-6e5c-42b9-902f-776531938bbf"
        ret = re.search('^%s: UUID="([a-z0-9-]+)"' % device, line)
        if None != ret:
            uuid = ret.group(1)
    print "debug: uuid(%s)='%s'" % (device, uuid)
    return uuid
开发者ID:hotelzululima,项目名称:bleachbit,代码行数:14,代码来源:Memory.py

示例5: disable_swap_linux

# 需要导入模块: import General [as 别名]
# 或者: from General import run_external [as 别名]
def disable_swap_linux():
    """Disable Linux swap and return list of devices"""
    if 0 == count_swap_linux():
        return
    print "debug: disabling swap"
    args = ["swapoff", "-a", "-v"]
    (rc, stdout, stderr) = General.run_external(args)
    if 0 != rc:
        raise RuntimeError(stderr.replace("\n", ""))
    devices = []
    for line in stdout.split('\n'):
        line = line.replace('\n', '')
        if '' == line:
            continue
        ret = parse_swapoff(line)
        if None == ret:
            raise RuntimeError("Unexpected output:\nargs='%(args)s'\nstdout='%(stdout)s'\nstderr='%(stderr)s'"
                               % {'args': str(args), 'stdout': stdout, 'stderr': stderr})
        devices.append(ret)
    return devices
开发者ID:AB9IL,项目名称:bleachbit,代码行数:22,代码来源:Memory.py

示例6: wipe_swap_linux

# 需要导入模块: import General [as 别名]
# 或者: from General import run_external [as 别名]
def wipe_swap_linux(devices, proc_swaps):
    """Shred the Linux swap file and then reinitilize it"""
    if None == devices:
        return
    if 0 < count_swap_linux():
        raise RuntimeError("Cannot wipe swap while it is in use")
    for device in devices:
        print "info: wiping swap device '%s'" % device
        if get_swap_size_linux(device, proc_swaps) > 8 * 1024 ** 3:
            raise RuntimeError("swap device %s is larger than expected" % device)
        uuid = get_swap_uuid(device)
        # wipe
        FileUtilities.wipe_contents(device, truncate=False)
        # reinitialize
        print "debug: reinitializing swap device %s" % device
        args = ["mkswap", device]
        if uuid:
            args.append("-U")
            args.append(uuid)
        (rc, _, stderr) = General.run_external(args)
        if 0 != rc:
            raise RuntimeError(stderr.replace("\n", ""))
开发者ID:hotelzululima,项目名称:bleachbit,代码行数:24,代码来源:Memory.py

示例7: wu_service

# 需要导入模块: import General [as 别名]
# 或者: from General import run_external [as 别名]
 def wu_service():
     General.run_external(args)
     return 0
开发者ID:AlphaPo325,项目名称:bleachbit,代码行数:5,代码来源:Windows.py


注:本文中的General.run_external方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。