本文整理汇总了Python中spyderlib.utils.programs.find_program函数的典型用法代码示例。如果您正苦于以下问题:Python find_program函数的具体用法?Python find_program怎么用?Python find_program使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了find_program函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_git_revision
def get_git_revision(repopath):
"""Return Git revision for the repository located at repopath
Result is a tuple (latest commit hash, branch), with None values on
error
"""
try:
git = programs.find_program('git')
assert git is not None and osp.isdir(osp.join(repopath, '.git'))
# Revision
commit = subprocess.Popen([git, 'rev-parse', '--short', 'HEAD'],
stdout=subprocess.PIPE,
cwd=repopath).communicate()
commit = commit[0].strip()
if PY3:
commit = commit.decode(sys.getdefaultencoding())
# Branch
branches = subprocess.Popen([git, 'branch'],
stdout=subprocess.PIPE,
cwd=repopath).communicate()
branches = branches[0]
if PY3:
branches = branches.decode(sys.getdefaultencoding())
branches = branches.split('\n')
active_branch = [b for b in branches if b.startswith('*')]
if len(active_branch) != 1:
branch = None
else:
branch = active_branch[0].split(None, 1)[1]
return commit, branch
except (subprocess.CalledProcessError, AssertionError, AttributeError):
return None, None
开发者ID:gyenney,项目名称:Tools,代码行数:34,代码来源:vcs.py
示例2: create_program_action
def create_program_action(parent, text, name, icon=None, nt_name=None):
"""Create action to run a program"""
if is_text_string(icon):
icon = get_icon(icon)
if os.name == "nt" and nt_name is not None:
name = nt_name
path = programs.find_program(name)
if path is not None:
return create_action(parent, text, icon=icon, triggered=lambda: programs.run_program(name))
开发者ID:yoyobbs,项目名称:spyder,代码行数:9,代码来源:qthelpers.py
示例3: create_program_action
def create_program_action(parent, text, icon, name, nt_name=None):
"""Create action to run a program"""
if isinstance(icon, basestring):
icon = get_icon(icon)
if os.name == 'nt' and nt_name is not None:
name = nt_name
path = programs.find_program(name)
if path is not None:
return create_action(parent, text, icon=icon,
triggered=lambda: programs.run_program(name))
开发者ID:jromang,项目名称:retina-old,代码行数:10,代码来源:qthelpers.py
示例4: run_scm_tool
def run_scm_tool(path, tool):
"""If path is a valid SCM repository, run the corresponding SCM tool
Supported SCM tools: 'commit', 'browse'
Return False if the SCM tool is not installed"""
infos = get_scm_infos(get_scm_root(path))
for name, args in infos[tool]:
if programs.find_program(name):
programs.run_program(name, args, cwd=path)
return
else:
raise RuntimeError(_("Please install the %s tool named '%s'")
% (infos['name'], name))
开发者ID:jromang,项目名称:retina-old,代码行数:12,代码来源:scm.py
示例5: run_vcs_tool
def run_vcs_tool(path, action):
"""If path is a valid VCS repository, run the corresponding VCS tool
Supported VCS actions: 'commit', 'browse'
Return False if the VCS tool is not installed"""
info = get_vcs_info(get_vcs_root(path))
tools = info['actions'][action]
for tool, args in tools:
if programs.find_program(tool):
programs.run_program(tool, args, cwd=path)
return
else:
cmdnames = [name for name, args in tools]
raise ActionToolNotFound(info['name'], action, cmdnames)
开发者ID:jromang,项目名称:spyderlib,代码行数:13,代码来源:vcs.py
示例6: get_hg_revision
def get_hg_revision(repopath):
"""Return Mercurial revision for the repository located at repopath
Result is a tuple (global, local, branch), with None values on error
For example:
>>> get_hg_revision(".")
('eba7273c69df+', '2015+', 'default')
"""
try:
hg = programs.find_program('hg')
assert hg is not None and osp.isdir(osp.join(repopath, '.hg'))
output, _err = subprocess.Popen([hg, 'id', '-nib', repopath],
stdout=subprocess.PIPE).communicate()
# output is now: ('eba7273c69df+ 2015+ default\n', None)
return tuple(output.decode().strip().split())
except (subprocess.CalledProcessError, AssertionError, AttributeError):
# print("Error: Failed to get revision number from Mercurial - %s" % exc)
return (None, None, None)
开发者ID:alfonsodiecko,项目名称:PYTHON_DIST,代码行数:17,代码来源:vcs.py
示例7: get_git_revision
def get_git_revision(repopath):
"""Return Git revision for the repository located at repopath
Result is the latest commit hash, with None on error
"""
try:
git = programs.find_program('git')
assert git is not None and osp.isdir(osp.join(repopath, '.git'))
commit = subprocess.Popen([git, 'rev-parse', '--short', 'HEAD'],
stdout=subprocess.PIPE,
cwd=repopath).communicate()
if PY3:
commit = str(commit[0][:-1])
commit = commit[2:-1]
else:
commit = commit[0][:-1]
return commit
except (subprocess.CalledProcessError, AssertionError, AttributeError):
return None
开发者ID:Micseb,项目名称:spyder,代码行数:18,代码来源:vcs.py
示例8: is_hg_installed
def is_hg_installed():
"""Return True if Mercurial is installed"""
return programs.find_program('hg') is not None
开发者ID:jromang,项目名称:spyderlib,代码行数:3,代码来源:vcs.py
示例9: import
from spyderlib import dependencies
from spyderlib.utils import programs
from spyderlib.utils.encoding import to_unicode_from_fs
from spyderlib.utils.qthelpers import create_toolbutton
from spyderlib.config.base import get_conf_path, get_translation
from spyderlib.widgets.onecolumntree import OneColumnTree
from spyderlib.widgets.variableexplorer.texteditor import TextEditor
from spyderlib.widgets.comboboxes import (PythonModulesComboBox,
is_module_or_package)
from spyderlib.py3compat import PY3, to_text_string, getcwd, pickle
_ = get_translation("p_pylint", dirname="spyderplugins")
PYLINT = 'pylint'
if PY3:
if programs.find_program('pylint3'):
PYLINT = 'pylint3'
elif programs.find_program('python3-pylint'):
PYLINT = 'python3-pylint'
PYLINT_PATH = programs.find_program(PYLINT)
def get_pylint_version():
"""Return pylint version"""
global PYLINT_PATH
if PYLINT_PATH is None:
return
process = subprocess.Popen([PYLINT, '--version'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
cwd=osp.dirname(PYLINT_PATH),
开发者ID:gyenney,项目名称:Tools,代码行数:31,代码来源:pylintgui.py
示例10: range
docs_dest = osp.join(app_python_lib, 'spyderlib', 'doc')
shutil.copytree(docs_orig, docs_dest)
# Create a minimal library inside Resources to add it to PYTHONPATH instead of
# app_python_lib. This must be done when the user changes to an interpreter
# that's not the one that comes with the app, to forbid importing modules
# inside the app.
minimal_lib = osp.join(app_python_lib, 'minimal-lib')
os.mkdir(minimal_lib)
minlib_pkgs = ['spyderlib', 'spyderplugins']
for p in minlib_pkgs:
shutil.copytree(osp.join(app_python_lib, p), osp.join(minimal_lib, p))
# Add necessary Python programs to the app
PROGRAMS = ['pylint', 'pep8']
system_progs = [find_program(p) for p in PROGRAMS]
progs_dest = [resources + osp.sep + p for p in PROGRAMS]
for i in range(len(PROGRAMS)):
shutil.copy2(system_progs[i], progs_dest[i])
# Add deps needed for PROGRAMS to the app
deps = []
for package in os.listdir(system_python_lib):
for d in DEPS:
if package.startswith(d):
deps.append(package)
for i in deps:
if osp.isdir(osp.join(system_python_lib, i)):
shutil.copytree(osp.join(system_python_lib, i),
osp.join(app_python_lib, i))
开发者ID:AminJamalzadeh,项目名称:spyder,代码行数:31,代码来源:create_app.py
示例11: start
def start(self, wdir=None, args=None, pythonpath=None):
filename = to_text_string(self.filecombo.currentText())
if wdir is None:
wdir = self._last_wdir
if wdir is None:
wdir = osp.basename(filename)
if args is None:
args = self._last_args
if args is None:
args = []
if pythonpath is None:
pythonpath = self._last_pythonpath
self._last_wdir = wdir
self._last_args = args
self._last_pythonpath = pythonpath
self.datelabel.setText(_('Profiling, please wait...'))
self.process = QProcess(self)
self.process.setProcessChannelMode(QProcess.SeparateChannels)
self.process.setWorkingDirectory(wdir)
self.connect(self.process, SIGNAL("readyReadStandardOutput()"),
self.read_output)
self.connect(self.process, SIGNAL("readyReadStandardError()"),
lambda: self.read_output(error=True))
self.connect(self.process,
SIGNAL("finished(int,QProcess::ExitStatus)"),
self.finished)
self.connect(self.stop_button, SIGNAL("clicked()"), self.process.kill)
if pythonpath is not None:
env = [to_text_string(_pth)
for _pth in self.process.systemEnvironment()]
baseshell.add_pathlist_to_PYTHONPATH(env, pythonpath)
self.process.setEnvironment(env)
self.output = ''
self.error_output = ''
# remove previous results, since memory_profiler appends to output file
# instead of replacing
if osp.isfile(self.DATAPATH):
os.remove(self.DATAPATH)
if os.name == 'nt':
# On Windows, one has to replace backslashes by slashes to avoid
# confusion with escape characters (otherwise, for example, '\t'
# will be interpreted as a tabulation):
filename = osp.normpath(filename).replace(os.sep, '/')
p_args = ['-m', 'memory_profiler', '-o', '"' + self.DATAPATH + '"',
'"' + filename + '"']
if args:
p_args.extend(programs.shell_split(args))
executable = programs.find_program('python')
executable += ' ' + ' '.join(p_args)
executable = executable.replace(os.sep, '/')
self.process.start(executable)
else:
p_args = ['-m', 'memory_profiler', '-o', self.DATAPATH, filename]
if args:
p_args.extend(programs.shell_split(args))
executable = 'python'
self.process.start(executable, p_args)
running = self.process.waitForStarted()
self.set_running_state(running)
if not running:
QMessageBox.critical(self, _("Error"),
_("Process failed to start"))
开发者ID:Nodd,项目名称:spyder_line_profiler,代码行数:69,代码来源:memoryprofilergui.py
示例12: import
# Local imports
from spyderlib import dependencies
from spyderlib.utils import programs
from spyderlib.utils.encoding import to_unicode_from_fs
from spyderlib.utils.qthelpers import get_icon, create_toolbutton
from spyderlib.baseconfig import get_conf_path, get_translation
from spyderlib.widgets.onecolumntree import OneColumnTree
from spyderlib.widgets.texteditor import TextEditor
from spyderlib.widgets.comboboxes import (PythonModulesComboBox,
is_module_or_package)
from spyderlib.py3compat import to_text_string, getcwd, pickle
_ = get_translation("p_pylint", dirname="spyderplugins")
PYLINT_PATH = programs.find_program('pylint')
def get_pylint_version():
"""Return pylint version"""
global PYLINT_PATH
if PYLINT_PATH is None:
return
process = subprocess.Popen(['pylint', '--version'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
cwd=osp.dirname(PYLINT_PATH),
shell=True if os.name == 'nt' else False)
lines = to_unicode_from_fs(process.stdout.read()).splitlines()
if lines:
match = re.match('(pylint|pylint-script.py) ([0-9\.]*)', lines[0])
if match is not None:
开发者ID:dhirschfeld,项目名称:spyderlib,代码行数:30,代码来源:pylintgui.py
示例13:
# -*- coding: utf-8 -*-
"""
Created on Sun May 03 20:58:06 2015
@author: Jayit
"""
import sys
import os
import os.path as osp
import time
import re
import subprocess
from spyderlib.utils import programs
PYLINT_PATH = programs.find_program('\\python-2.7.9\\Scripts\\pylint')
print(PYLINT_PATH)
开发者ID:jayitb,项目名称:Spyderplugin_ratelaws,代码行数:16,代码来源:pylinttest.py
示例14: get_translation
from spyderlib import dependencies
from spyderlib.utils import programs
from spyderlib.utils.encoding import to_unicode_from_fs
from spyderlib.utils.qthelpers import create_toolbutton
from spyderlib.baseconfig import get_conf_path, get_translation
from spyderlib.widgets.onecolumntree import OneColumnTree
from spyderlib.widgets.texteditor import TextEditor
from spyderlib.widgets.comboboxes import PythonModulesComboBox, is_module_or_package
from spyderlib.py3compat import PY3, to_text_string, getcwd, pickle
_ = get_translation("p_pylint", dirname="spyderplugins")
PYLINT = "pylint"
if PY3:
if programs.find_program("pylint3"):
PYLINT = "pylint3"
elif programs.find_program("python3-pylint"):
PYLINT = "python3-pylint"
PYLINT_PATH = programs.find_program(PYLINT)
def get_pylint_version():
"""Return pylint version"""
global PYLINT_PATH
if PYLINT_PATH is None:
return
process = subprocess.Popen(
[PYLINT, "--version"],
stdout=subprocess.PIPE,
开发者ID:ftsiadimos,项目名称:spyder,代码行数:31,代码来源:pylintgui.py
示例15: is_lineprofiler_installed
def is_lineprofiler_installed():
"""Checks if the program and the library for line_profiler is installed
"""
return (programs.is_module_installed('line_profiler')
and programs.find_program('kernprof') is not None)
开发者ID:Nodd,项目名称:spyder_line_profiler,代码行数:5,代码来源:lineprofilergui.py
注:本文中的spyderlib.utils.programs.find_program函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论