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


Python path.iscommand函数代码示例

本文整理汇总了Python中quodlibet.util.path.iscommand函数的典型用法代码示例。如果您正苦于以下问题:Python iscommand函数的具体用法?Python iscommand怎么用?Python iscommand使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: test_pos

    def test_pos(self):
        if not iscommand("msgfmt"):
            return

        self.failIf(os.system("msgfmt -c po/%s.po > /dev/null" % self.lang))
        try:
            os.unlink("messages.mo")
        except OSError:
            pass
开发者ID:vrasidas,项目名称:quodlibet,代码行数:9,代码来源:test_po.py

示例2: test_pos

    def test_pos(self):
        if not iscommand("msgfmt"):
            return

        po_path = os.path.join(PODIR, "%s.po" % self.lang)
        self.failIf(os.system("msgfmt -c %s > /dev/null" % po_path))
        try:
            os.unlink("messages.mo")
        except OSError:
            pass
开发者ID:urielz,项目名称:quodlibet,代码行数:10,代码来源:test_po.py

示例3: test_looks_in_path

 def test_looks_in_path(self):
     path_dirs = set(os.environ['PATH'].split(os.path.pathsep))
     dirs = path_dirs - set(os.defpath.split(os.path.pathsep))
     for d in dirs:
         if os.path.isdir(d):
             for file_path in os.listdir(d):
                 if os.access(os.path.join(d, file_path), os.X_OK):
                     print_d("Testing %s" % file_path)
                     self.failUnless(iscommand(file_path))
                     return
开发者ID:gbtami,项目名称:quodlibet,代码行数:10,代码来源:test_util_path.py

示例4: test_looks_in_path

 def test_looks_in_path(self):
     path_dirs = set(environ['PATH'].split(os.path.pathsep))
     dirs = path_dirs - set(os.defpath.split(os.path.pathsep))
     for d in dirs:
         if os.path.isdir(d):
             for file_path in sorted(os.listdir(d)):
                 p = os.path.join(d, file_path)
                 if os.path.isfile(p) and os.access(p, os.X_OK):
                     print_d("Testing %s" % p)
                     self.failUnless(iscommand(p), msg=p)
                     return
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:11,代码来源:test_util_path.py

示例5: website

def website(site):
    """Open the given URL in the user's default browser"""

    if os.name == "nt" or sys.platform == "darwin":
        return webbrowser.open(site)

    # all commands here return immediately
    for prog in ["xdg-open", "gnome-open"]:
        if not iscommand(prog):
            continue

        status = subprocess.check_call([prog, site])
        if status == 0:
            return True

    # sensible-browser is a debian thing
    blocking_progs = ["sensible-browser"]
    blocking_progs.extend(environ.get("BROWSER", "").split(":"))

    for prog in blocking_progs:
        if not iscommand(prog):
            continue

        # replace %s with the url
        args = prog.split()
        for i, arg in enumerate(args):
            if arg == "%s":
                args[i] = site
                break
        else:
            args.append(site)

        # calling e.g. firefox blocks, so call async and hope for the best
        try:
            spawn(args)
        except RuntimeError:
            continue
        else:
            return True

    return False
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:41,代码来源:__init__.py

示例6: __init__

    def __init__(self, *args, **kwargs):
        super(BurnCD, self).__init__(*args, **kwargs)
        self.prog_name = None

        items = self.burn_programs.items()
        progs = [(iscommand(x[1][0]), x) for x in items]
        progs.sort(reverse=True)

        submenu = Gtk.Menu()
        for (is_cmd, (name, (cmd, arg))) in progs:
            item = Gtk.MenuItem(label=name)
            if not is_cmd:
                item.set_sensitive(False)
            else:
                connect_obj(item, 'activate', self.__set, name)
            submenu.append(item)
        self.set_submenu(submenu)
开发者ID:bossjones,项目名称:quodlibet,代码行数:17,代码来源:k3b.py

示例7: mkstemp

        for x in tree.iter():
            if x.tag.startswith("_"):
                x.tag = x.tag[1:]
        fd, name = mkstemp(suffix=".appdata.xml")
        os.close(fd)

        with open(name, "wb") as temp:
            header = open(self.PATH, "rb").read().splitlines()[0]
            temp.write(header + "\n")
            temp.write(ElementTree.tostring(tree.getroot(), encoding="utf-8"))

        # pass to desktop-file-validate
        try:
            subprocess.check_output(
                ["appstream-util", "validate", "--nonet", name],
                stderr=subprocess.STDOUT)
        except subprocess.CalledProcessError as e:
            raise Exception(e.output)
        finally:
            os.remove(name)


@skipUnless(iscommand("appstream-util"), "appstream-util not found")
class TQLAppDataFile(_TAppDataFile):
    PATH = os.path.join(QLDATA_DIR, "quodlibet.appdata.xml.in")


@skipUnless(iscommand("appstream-util"), "appstream-util not found")
class TEFAppDataFile(_TAppDataFile):
    PATH = os.path.join(QLDATA_DIR, "exfalso.appdata.xml.in")
开发者ID:pyromaniac2k,项目名称:quodlibet,代码行数:30,代码来源:test_appdata_files.py

示例8: exists

 def exists(self):
     return iscommand(self.command.split()[0])
开发者ID:Konzertheld,项目名称:quodlibet,代码行数:2,代码来源:openwith.py

示例9: TPEP8

# Copyright 2013 Christoph Reiter
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation

import os
import glob
import subprocess

from quodlibet.util.path import iscommand

from tests import TestCase, skipUnless


@skipUnless(iscommand("pep8"), "pep8 not found")
class TPEP8(TestCase):
    # E12x popped up in pep8 1.4 compared to 1.2..
    # drop them once 1.4 is common enough
    # E261: at least two spaces before inline comment
    IGNORE_ERROROS = ["E12", "E261", "E265", "E713", "W602", "E402", "E731", "W503"]

    def _run(self, path, ignore=None):
        if ignore is None:
            ignore = []
        ignore += self.IGNORE_ERROROS

        p = subprocess.Popen(
            ["pep8", "--ignore=" + ",".join(ignore), path], stderr=subprocess.PIPE, stdout=subprocess.PIPE
        )
开发者ID:SimonLarsen,项目名称:quodlibet,代码行数:30,代码来源:test_pep8.py

示例10: test_both

 def test_both(self):
     self.failIf(iscommand("zzzzzzzzz"))
     self.failIf(iscommand("/bin/zzzzzzzzz"))
     self.failIf(iscommand(""))
     self.failIf(iscommand("/bin"))
     self.failIf(iscommand("X11"))
开发者ID:gbtami,项目名称:quodlibet,代码行数:6,代码来源:test_util_path.py

示例11: test_unix

 def test_unix(self):
     self.failUnless(iscommand("ls"))
     self.failUnless(iscommand("/bin/ls"))
     self.failUnless(iscommand("whoami"))
开发者ID:gbtami,项目名称:quodlibet,代码行数:4,代码来源:test_util_path.py

示例12: active

    @property
    def active(self):
        return self.get_active()

    # Use filter list rather than filter to avoid starting a new process
    # for each filename.
    def filter_list(self, originals, values):
        value = "\n".join(values)
        try:
            data = value.encode('shift-jis', 'replace')
        except UnicodeEncodeError:
            return values

        proc = subprocess.Popen(
            ["kakasi", "-isjis", "-osjis", "-Ha", "-Ka", "-Ja",
             "-Ea", "-ka", "-s"],
            stdin=subprocess.PIPE,
            stdout=subprocess.PIPE)
        result = proc.communicate(data)[0]

        try:
            return result.decode('shift-jis').strip().split("\n")
        except:
            return values


if not iscommand("kakasi"):
    from quodlibet import plugins
    raise plugins.PluginImportException(
        _("Couldn't find the 'Kanji Kana Simple Inverter' (kakasi)."))
开发者ID:LudoBike,项目名称:quodlibet,代码行数:30,代码来源:kakasi.py


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