python类find_executable()的实例源码

press_sec_bot_plus.py 文件源码 项目:PressSecBotPlus 作者: robmathers 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def html_to_png(html):
    # Use a temp file in the current working directory so that wkhtmltoimage handles relative URLs properly
    temp_file = '.temp.html'
    with open(temp_file, 'w') as f:
        f.write(html.encode('utf-8'))

    command = ['wkhtmltoimage']
    if not find_executable(command[0]):
        raise ImportError('%s not found' % command[0])

    command += ['-f', 'png'] # format output as PNG
    command += ['--zoom', '2'] # retina image
    command += ['--width', '750'] # viewport 750px wide
    command += [temp_file] # read from stdin
    command += ['-'] # write to stdout

    wkhtml_process = Popen(command, stdout=PIPE, stderr=PIPE)
    (output, err) = wkhtml_process.communicate()

    os.remove(temp_file)

    image = Image.open(BytesIO(output))
    image = set_transparent_pixel(image)

    return image
ngrok.py 文件源码 项目:websauna 作者: websauna 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def __init__(self, port:int, auth_token:str, subdomain:str):
        """Build ngrok HTTP tunnel

        Assume ngrok version 2.x. A temporary ngrok configuration file is created where the ngrok token is stored for running the command.

        :param port: localhost port forwarded through tunnel

        :param auth_token: Ngrok auth token to use

        :param subdomain: Use this subdomain for the tunnelling
        """
        assert find_executable("ngrok"), "ngrok command must be installed, see https://ngrok.com/"
        self.port = port
        self.auth_token = auth_token
        self.subdomain = subdomain
        self.ngrok = None
        self.config_file_handle, self.config_file = tempfile.mkstemp()
setup.py 文件源码 项目:zq 作者: vulogov 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def run_cmake(arg=""):
    """
    Forcing to run cmake
    """
    if ds.find_executable('cmake') is None:
        print "CMake  is required to build zql"
        print "Please install cmake version >= 2.8 and re-run setup"
        sys.exit(-1)

    print "Configuring zql build with CMake.... "
    cmake_args = arg
    try:
        build_dir = op.join(op.split(__file__)[0], 'build')
        dd.mkpath(build_dir)
        os.chdir("build")
        ds.spawn(['cmake', '..'] + cmake_args.split())
        ds.spawn(['make', 'clean'])
        ds.spawn(['make'])
        os.chdir("..")
    except ds.DistutilsExecError:
        print "Error while running cmake"
        print "run 'setup.py build --help' for build options"
        print "You may also try editing the settings in CMakeLists.txt file and re-running setup"
        sys.exit(-1)
easy_install.py 文件源码 项目:python- 作者: secondtonone1 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def _use_header(new_header):
        """
        Should _adjust_header use the replaced header?

        On non-windows systems, always use. On
        Windows systems, only use the replaced header if it resolves
        to an executable on the system.
        """
        clean_header = new_header[2:-1].strip('"')
        return sys.platform != 'win32' or find_executable(clean_header)
easy_install.py 文件源码 项目:my-first-blog 作者: AnkurBegining 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def _use_header(new_header):
        """
        Should _adjust_header use the replaced header?

        On non-windows systems, always use. On
        Windows systems, only use the replaced header if it resolves
        to an executable on the system.
        """
        clean_header = new_header[2:-1].strip('"')
        return sys.platform != 'win32' or find_executable(clean_header)
emxccompiler.py 文件源码 项目:kinect-2-libras 作者: inessadl 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def get_versions():
    """ Try to find out the versions of gcc and ld.
        If not possible it returns None for it.
    """
    from distutils.version import StrictVersion
    from distutils.spawn import find_executable
    import re

    gcc_exe = find_executable('gcc')
    if gcc_exe:
        out = os.popen(gcc_exe + ' -dumpversion','r')
        try:
            out_string = out.read()
        finally:
            out.close()
        result = re.search('(\d+\.\d+\.\d+)',out_string)
        if result:
            gcc_version = StrictVersion(result.group(1))
        else:
            gcc_version = None
    else:
        gcc_version = None
    # EMX ld has no way of reporting version number, and we use GCC
    # anyway - so we can link OMF DLLs
    ld_version = None
    return (gcc_version, ld_version)
editor.py 文件源码 项目:Flask_Blog 作者: sugarguo 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def get_editor():
    # Get the editor from the environment.  Prefer VISUAL to EDITOR
    editor = os.environ.get('VISUAL') or os.environ.get('EDITOR')
    if editor:
        return editor

    # None found in the environment.  Fallback to platform-specific defaults.
    for ed in get_default_editors():
        path = find_executable(ed)
        if path is not None:
            return path

    raise EditorError("Unable to find a viable editor on this system."
        "Please consider setting your %s variable" % get_platform_editor_var())
easy_install.py 文件源码 项目:swjtu-pyscraper 作者: Desgard 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def _use_header(new_header):
        """
        Should _adjust_header use the replaced header?

        On non-windows systems, always use. On
        Windows systems, only use the replaced header if it resolves
        to an executable on the system.
        """
        clean_header = new_header[2:-1].strip('"')
        return sys.platform != 'win32' or find_executable(clean_header)
easy_install.py 文件源码 项目:noc-orchestrator 作者: DirceuSilvaLabs 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def _use_header(new_header):
        """
        Should _adjust_header use the replaced header?

        On non-windows systems, always use. On
        Windows systems, only use the replaced header if it resolves
        to an executable on the system.
        """
        clean_header = new_header[2:-1].strip('"')
        return sys.platform != 'win32' or find_executable(clean_header)
easy_install.py 文件源码 项目:jira_worklog_scanner 作者: pgarneau 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def _use_header(new_header):
        """
        Should _adjust_header use the replaced header?

        On non-windows systems, always use. On
        Windows systems, only use the replaced header if it resolves
        to an executable on the system.
        """
        clean_header = new_header[2:-1].strip('"')
        return sys.platform != 'win32' or find_executable(clean_header)
util_which.py 文件源码 项目:python-ceph-cfg 作者: oms4suse 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def path():
        doc = "the path to the exeutable"

        def fget(self):
            if not self._path is None:
                return self._path
            self._path = find_executable(self.name)
            if self._path is None:
                msg = "Could not find executable:{executable}".format(executable=self.name)
                log.error(msg)
                raise ExecutableNotFound(msg)
            return self._path
        return locals()
easy_install.py 文件源码 项目:zanph 作者: zanph 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def _use_header(new_header):
        """
        Should _adjust_header use the replaced header?

        On non-windows systems, always use. On
        Windows systems, only use the replaced header if it resolves
        to an executable on the system.
        """
        clean_header = new_header[2:-1].strip('"')
        return sys.platform != 'win32' or find_executable(clean_header)
emxccompiler.py 文件源码 项目:hostapd-mana 作者: adde88 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def get_versions():
    """ Try to find out the versions of gcc and ld.
        If not possible it returns None for it.
    """
    from distutils.version import StrictVersion
    from distutils.spawn import find_executable
    import re

    gcc_exe = find_executable('gcc')
    if gcc_exe:
        out = os.popen(gcc_exe + ' -dumpversion','r')
        try:
            out_string = out.read()
        finally:
            out.close()
        result = re.search('(\d+\.\d+\.\d+)',out_string)
        if result:
            gcc_version = StrictVersion(result.group(1))
        else:
            gcc_version = None
    else:
        gcc_version = None
    # EMX ld has no way of reporting version number, and we use GCC
    # anyway - so we can link OMF DLLs
    ld_version = None
    return (gcc_version, ld_version)
test_build_clib.py 文件源码 项目:hostapd-mana 作者: adde88 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def test_run(self):
        pkg_dir, dist = self.create_dist()
        cmd = build_clib(dist)

        foo_c = os.path.join(pkg_dir, 'foo.c')
        self.write_file(foo_c, 'int main(void) { return 1;}\n')
        cmd.libraries = [('foo', {'sources': [foo_c]})]

        build_temp = os.path.join(pkg_dir, 'build')
        os.mkdir(build_temp)
        cmd.build_temp = build_temp
        cmd.build_clib = build_temp

        # before we run the command, we want to make sure
        # all commands are present on the system
        # by creating a compiler and checking its executables
        from distutils.ccompiler import new_compiler
        from distutils.sysconfig import customize_compiler

        compiler = new_compiler()
        customize_compiler(compiler)
        for ccmd in compiler.executables.values():
            if ccmd is None:
                continue
            if find_executable(ccmd[0]) is None:
                self.skipTest('The %r command is not found' % ccmd[0])

        # this should work
        cmd.run()

        # let's check the result
        self.assertIn('libfoo.a', os.listdir(build_temp))
setup.py 文件源码 项目:dragonchain 作者: dragonchain 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def finalize_options(self):
        self.root = os.path.abspath(os.path.dirname(__file__))
        self.thrift = find_executable('thrift1')
        if self.thrift is None:
            self.thrift = find_executable('thrift')
easy_install.py 文件源码 项目:Sci-Finder 作者: snverse 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def _use_header(new_header):
        """
        Should _adjust_header use the replaced header?

        On non-windows systems, always use. On
        Windows systems, only use the replaced header if it resolves
        to an executable on the system.
        """
        clean_header = new_header[2:-1].strip('"')
        return sys.platform != 'win32' or find_executable(clean_header)
easy_install.py 文件源码 项目:Sci-Finder 作者: snverse 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def _use_header(new_header):
        """
        Should _adjust_header use the replaced header?

        On non-windows systems, always use. On
        Windows systems, only use the replaced header if it resolves
        to an executable on the system.
        """
        clean_header = new_header[2:-1].strip('"')
        return sys.platform != 'win32' or find_executable(clean_header)
devfixture.py 文件源码 项目:django-devfixtures 作者: dolphinkiss 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def _check_dependencies(self):
        not_found = []
        for executable in REQUIRED_EXEC:
            if not find_executable(executable):
                not_found.append(executable)
        if not_found:
            raise CommandError('The following executables are required: %s, missing: %s' % (REQUIRED_EXEC, not_found))
__init__.py 文件源码 项目:kcli 作者: karmab 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def add_image(self, image, pool, cmd=None):
        shortimage = os.path.basename(image).split('?')[0]
        if pool is not None:
            pool = [p['path'] for p in self._pool_info() if p['name'] == pool]
            if pool:
                poolpath = pool[0]
            else:
                print("Pool not found. Leaving....")
                return
        downloadcmd = 'curl -Lo %s -f %s/%s' % (shortimage, poolpath, image)
        os.system(downloadcmd)
        if cmd is not None and find_executable('virt-customize') is not None:
            cmd = "virt-customize -a %s/%s %s" % (poolpath, image, cmd)
        os.system(cmd)
        return {'result': 'success'}


问题


面经


文章

微信
公众号

扫码关注公众号