本文整理汇总了Python中qisys.ui.info_count函数的典型用法代码示例。如果您正苦于以下问题:Python info_count函数的具体用法?Python info_count怎么用?Python info_count使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了info_count函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: install
def install(self, dest_dir, *args, **kwargs):
""" Install the projects and the packages to the dest_dir """
installed = list()
projects = self.deps_solver.get_dep_projects(self.projects, self.dep_types)
packages = self.deps_solver.get_dep_packages(self.projects, self.dep_types)
if "install_tc_packages" in kwargs:
install_tc_packages = kwargs["install_tc_packages"]
del kwargs["install_tc_packages"]
if not install_tc_packages:
packages = list()
# Compute the real path where to install the packages:
prefix = kwargs.get("prefix", "/")
prefix = prefix[1:]
real_dest = os.path.join(dest_dir, prefix)
components = kwargs.get("components")
build_type = "Release"
if projects:
ui.info(ui.green, "the following projects")
for project in projects:
ui.info(ui.green, " *", ui.blue, project.name)
if packages:
ui.info(ui.green, "and the following packages")
for package in packages:
ui.info(ui.green, " *", ui.blue, package.name)
ui.info(ui.green, "will be installed to", ui.blue, real_dest)
runtime_only = self.dep_types == ["runtime"]
if runtime_only:
ui.info(ui.green, "(runtime components only)")
build_type = projects[0].build_type
release = build_type == "Release"
if packages:
ui.info(ui.green, ":: ", "installing packages")
for i, package in enumerate(packages):
ui.info_count(i, len(packages),
ui.green, "Installing",
ui.blue, package.name,
update_title=True)
files = package.install(real_dest, components=components,
release=release)
installed.extend(files)
# Remove qitest.json so that we don't append tests twice
# when running qibuild install --with-tests twice
qitest_json = os.path.join(dest_dir, "qitest.json")
qisys.sh.rm(qitest_json)
if projects:
ui.info(ui.green, ":: ", "installing projects")
for i, project in enumerate(projects):
ui.info_count(i, len(projects),
ui.green, "Installing",
ui.blue, project.name,
update_title=True)
files = project.install(dest_dir, **kwargs)
installed.extend(files)
return installed
示例2: do
def do(args):
test_runners = qitest.parsers.get_test_runners(args)
# rule to check for tests which doesn't follow naming convention
expr = re.compile("^test_.*")
warn_name_count = 0
warn_type_count = 0
for test_runner in test_runners:
ui.info("Tests in ", test_runner.project.sdk_directory)
for i, test in enumerate(test_runner.tests):
n = len(test_runner.tests)
name = test["name"]
name_ok = re.match(expr, name)
type_ok = (test.get("pytest") or test.get("gtest"))
if name_ok and type_ok:
ui.info_count(i, n, test["name"])
else:
message = ""
if not name_ok:
warn_name_count += 1
message += "(invalid name) "
if not type_ok:
warn_type_count += 1
message += "(no type)"
ui.info_count(i, n, name, ui.brown, message)
if warn_name_count:
msg = "%i on %i tests do not respect naming convention" % (warn_name_count, len(test_runner.tests))
ui.warning(msg)
if warn_type_count:
msg = "%i on %i tests do not have any type" % (warn_type_count, len(test_runner.tests))
ui.warning(msg)
示例3: configure_virtualenv
def configure_virtualenv(config, python_worktree, build_worktree=None,
remote_packages=None, site_packages=True):
if not remote_packages:
remote_packages = list()
# create a new virtualenv
python_worktree.config = config
venv_path = python_worktree.venv_path
pip = python_worktree.pip
try:
virtualenv.create_environment(python_worktree.venv_path,
site_packages=site_packages)
except:
ui.error("Failed to create virtualenv")
return
# Install all Python projects using pip install -e .
python_projects = python_worktree.python_projects
for i, project in enumerate(python_projects):
ui.info_count(i, len(python_projects),
ui.green, "Configuring", ui.reset, ui.blue, project.src)
cmd = [pip, "install", "--editable", "."]
qisys.command.call(cmd, cwd=project.path)
# Write a qi.pth file containing path to C/C++ extensions
if build_worktree:
handle_extensions(venv_path, python_worktree, build_worktree)
# Install the extension in the virtualenv
binaries_path = virtualenv.path_locations(venv_path)[-1]
pip_binary = os.path.join(binaries_path, "pip")
if remote_packages:
cmd = [pip_binary, "install"] + remote_packages
subprocess.check_call(cmd)
示例4: do
def do(args):
"""Main entry point"""
git_worktree = qisrc.parsers.get_git_worktree(args)
sync_ok = git_worktree.sync()
git_projects = qisrc.parsers.get_git_projects(git_worktree, args,
default_all=True,
use_build_deps=True)
if not git_projects:
qisrc.worktree.on_no_matching_projects(git_worktree, groups=args.groups)
return
git_worktree.configure_projects(git_projects)
skipped = list()
failed = list()
ui.info(ui.green, ":: Syncing projects ...")
max_src = max(len(x.src) for x in git_projects)
for (i, git_project) in enumerate(git_projects):
ui.info_count(i, len(git_projects),
ui.blue, git_project.src.ljust(max_src), end="\r")
(status, out) = git_project.sync(rebase_devel=args.rebase_devel)
if status is None:
ui.info("\n", "\n", ui.brown, git_project.src, " [skipped]")
skipped.append((git_project.src, out))
if status is False:
ui.info("\n", "\n", git_project.src, ui.red, " [failed]")
failed.append((git_project.src, out))
if out:
print ui.indent(out, num=2)
#clean the screen
ui.info_count(i, len(git_projects), ui.blue, " ".ljust(max_src), end="\r")
print_overview(len(git_projects), len(skipped), len(failed))
if failed or not sync_ok:
sys.exit(1)
示例5: do
def do(args):
doc_worktree = qidoc.parsers.get_doc_worktree(args)
doc_projects = qidoc.parsers.get_doc_projects(doc_worktree, args)
to_clean = list()
for doc_project in doc_projects:
# FIXME
# this can create an empty build dir for nothing, so
# we remove it if we don't need it
try:
build_dir = doc_project.build_dir
except AttributeError:
continue
if not os.path.exists(build_dir):
continue
if qisys.sh.is_empty(build_dir):
qisys.sh.rm(build_dir)
continue
to_clean.append(build_dir)
if not to_clean:
ui.info(ui.green, "Nothing to clean")
return
if not args.force:
ui.info(ui.green, "Build directories that will be removed", ui.white, "(use -f to apply")
for i, build_dir in enumerate(to_clean):
if args.force:
ui.info_count(i, len(to_clean), ui.green, "Cleaning", ui.reset, build_dir)
qisys.sh.rm(build_dir)
else:
ui.info_count(i, len(to_clean), build_dir)
示例6: install
def install(self, destdir, clean=False):
""" Install the doc projects to a dest dir
"""
projects = self.get_dep_projects()
ui.info(ui.blue, "::", ui.reset, "Building all projects")
for i, project in enumerate(projects):
ui.info_count(i, len(projects),
ui.green, "Building",
ui.blue, project.name)
options = {
"version" : self.version,
"hosted" : self.hosted,
"build_type" : self.build_type,
"rel_paths" : True,
}
if clean:
project.clean()
project.configure(**options)
project.build(build_type=self.build_type, language=self.language)
if clean:
qisys.sh.rm(destdir)
qisys.sh.mkdir(destdir)
ui.info(ui.blue, "::", ui.reset, "Installing all projects")
for i, project in enumerate(projects):
real_dest = os.path.join(destdir, project.dest)
ui.info_count(i, len(projects),
ui.green, "Installing",
ui.blue, project.name,
ui.reset, "->", ui.white, real_dest)
project.install(real_dest)
示例7: intl_update
def intl_update(self):
ui.info(ui.blue, "::", ui.reset, "Generating message catalogs ...")
import sphinx
from sphinx_intl.commands import run as sphinx_intl_run
# First step: run sphinx-build -b gettext
cmd = [sys.executable, "-c", self.build_dir, "-b", "gettext"]
cmd.append(self.source_dir)
locale_dir = os.path.join(self.source_dir, "locale")
cmd.append(locale_dir)
rc = 0
try:
sphinx.main(argv=cmd)
except SystemExit as e:
rc = e.code
if rc != 0:
raise SphinxBuildError(self)
ui.info()
# Second step: run sphinx-intl update -l <lingua> for every lingua
ui.info(ui.blue, "::", ui.reset, "Updating .po files ...")
for i, lingua in enumerate(self.linguas):
ui.info_count(i, len(self.linguas), ui.blue, lingua)
cmd = ["update",
"-c", os.path.join(self.build_dir, "conf.py"),
"--pot-dir", locale_dir,
"--locale-dir", locale_dir,
"--language", lingua]
sphinx_intl_run(cmd)
示例8: summary
def summary(self):
""" Display the tests results.
Called at the end of self.run()
Sets ``self.ok``
"""
if not self.tests:
self.ok = False
return
num_tests = len(self.results)
failures = [x for x in self.results.values() if x.ok is False]
num_failed = len(failures)
message = "Ran %i tests in %is" % (num_tests, self.elapsed_time)
ui.info(message)
self.ok = (not failures) and not self._interrupted
if self.ok:
ui.info(ui.green, "All pass. Congrats!")
return
if num_failed != 0:
ui.error(num_failed, "failures")
if failures:
max_len = max(len(x.test["name"]) for x in failures)
for i, failure in enumerate(failures):
ui.info_count(i, num_failed,
ui.blue, failure.test["name"].ljust(max_len + 2),
ui.reset, *failure.message)
示例9: install
def install(self, dest, *args, **kwargs):
"""
Just copy the Python scripts, modules and packages.
If there are extensions written in CMake, they will be
installed by the CMakeBuilder.
"""
if not self.projects:
return
n = len(self.projects)
for i, project in enumerate(self.projects):
ui.info_count(i, n, ui.green, "Installing",
ui.reset, ui.blue, project.name)
project.install(dest)
# Also install a python wrapper so that everything goes smoothly
to_write = """\
#!/bin/bash
SDK_DIR="$(dirname "$(readlink -f $0 2>/dev/null)")"
export LD_LIBRARY_PATH="${SDK_DIR}/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
export PYTHONPATH="${SDK_DIR}/lib/python2.7/site-packages${PYTHONPATH:+:$PYTHONPATH}"
exec python "[email protected]"
"""
python_wrapper = os.path.join(dest, "python")
with open(python_wrapper, "w") as fp:
fp.write(to_write)
os.chmod(python_wrapper, 0o755)
示例10: checkout
def checkout(self, branch, force=False):
""" Called by ``qisrc checkout``
For each project, checkout the branch if it is different than
the default branch of the manifest.
"""
ui.info(ui.green, ":: Checkout projects ...")
errors = list()
manifest_xml = os.path.join(self._syncer.manifest_repo, "manifest.xml")
manifest = qisrc.manifest.Manifest(manifest_xml)
max_src = max([len(x.src) for x in self.git_projects])
n = len(self.git_projects)
for i, project in enumerate(self.git_projects):
ui.info_count(i, n, ui.bold, "Checkout",
ui.reset, ui.blue, project.src.ljust(max_src), end="\r")
if project.default_branch is None:
continue
branch_name = project.default_branch.name
remote_name = project.default_remote.name
git = qisrc.git.Git(project.path)
ok, err = git.safe_checkout(branch_name, remote_name, force=force)
if not ok:
errors.append((project.src, err))
if not errors:
return
ui.error("Failed to checkout some projects")
for (project, error) in errors:
ui.info(project, ":", error)
示例11: configure_projects
def configure_projects(self, projects=None):
""" Configure the given projects so that the actual git config matches
the one coming from the manifest :
Configure default remotes, default branches and code review, then save config
To be called _after_ sync()
"""
if projects is None:
projects = self.git_worktree.get_git_projects()
if not projects:
return
to_configure = list()
srcs = {project.src: project for project in projects}
for repo in self.new_repos:
if repo.src in srcs.keys():
to_configure.append(repo)
if not to_configure:
return
ui.info(ui.green, ":: Setup git projects ...")
max_src = max(len(x.src) for x in to_configure)
n = len(to_configure)
for i, repo in enumerate(to_configure):
ui.info_count(i, n, ui.white, "Setup", ui.reset,
ui.blue, repo.src.ljust(max_src), end="\r")
git_project = srcs[repo.src]
git_project.read_remote_config(repo)
git_project.apply_config()
ui.info(" " * (max_src + 19), end="\r")
self.git_worktree.save_git_config()
示例12: handle_extensions
def handle_extensions(venv_path, python_worktree, build_worktree):
"""
Check if there is a build project matching the given source,
and add the correct path to the virtualenv.
"""
extensions_projects = list()
build_projects = build_worktree.build_projects
for project in python_worktree.python_projects:
parent_project = qisys.parsers.find_parent_project(build_projects,
project.path)
if parent_project:
extensions_projects.append(parent_project)
if extensions_projects:
ui.info()
ui.info(ui.blue, "::", ui.reset, "Registering C++ extensions")
to_write = ""
for i, project in enumerate(extensions_projects):
ui.info_count(i, len(extensions_projects),
ui.blue, project.name)
qi_pth_src = os.path.join(project.sdk_directory, "qi.pth")
if os.path.exists(qi_pth_src):
with open(qi_pth_src, "r") as fp:
to_write += fp.read()
if not to_write.endswith("\n"):
to_write += "\n"
lib_path = virtualenv.path_locations(venv_path)[1]
qi_pth_dest = os.path.join(venv_path, lib_path, "site-packages/qi.pth")
with open(qi_pth_dest, "a") as fp:
fp.write(to_write)
示例13: foreach
def foreach(projects, cmd, ignore_errors=True):
"""
Execute the command on every project
:param ignore_errors: whether to stop at first failure
"""
errors = list()
ui.info(ui.green, "Running `%s` on every project" % " ".join(cmd))
for i, project in enumerate(projects):
ui.info_count(i, len(projects), ui.blue, project.src)
command = cmd[:]
try:
qisys.command.call(command, cwd=project.path)
except qisys.command.CommandFailedException:
if ignore_errors:
errors.append(project)
continue
else:
raise
if not errors:
return
print()
ui.info(ui.red, "Command failed on the following projects:")
for project in errors:
ui.info(ui.green, " * ", ui.reset, ui.blue, project.src)
sys.exit(1)
示例14: handle_pure_python
def handle_pure_python(venv_path, python_worktree, env=None):
""" Add the paths of all python projects to the virtualenv """
lib_path = virtualenv.path_locations(venv_path)[1]
qi_pth_dest = os.path.join(venv_path, lib_path, "site-packages/qi.pth")
res = True
with open(qi_pth_dest, "w") as fp:
fp.write("")
for i, project in enumerate(python_worktree.python_projects):
ui.info_count(i, len(python_worktree.python_projects),
ui.blue, project.name)
if project.setup_with_distutils:
cmd = [python_worktree.pip, "install"]
if not ui.CONFIG["verbose"]:
cmd.append("--quiet")
cmd.extend(["--editable", "."])
rc = qisys.command.call(cmd, cwd=project.path, ignore_ret_code=True,
env=env)
if rc != 0:
ui.warning("Failed to run pip install on", project.src)
res = False
else:
ui.debug("Adding python path for project", project.name, ":\n",
project.python_path)
for path in project.python_path:
fp.write(path + "\n")
return res
示例15: push_projects
def push_projects(git_projects, dry_run=False):
""" Push Projects """
if not git_projects:
return
ui.info(ui.green, "Pushing ", len(git_projects), "projects")
for i, git_project in enumerate(git_projects):
default_branch = git_project.default_branch.name
remote_branch = git_project.default_branch.remote_branch
ui.info_count(i, len(git_projects), git_project.src)
git = qisrc.git.Git(git_project.path)
if git_project.review:
push_remote = git_project.review_remote
else:
push_remote = git_project.default_remote
remote_ref = "%s/%s" % (push_remote.name, remote_branch)
display_changes(git, default_branch, remote_ref)
answer = qisys.interact.ask_yes_no("OK to push?", default=False)
if not answer:
return
to_push = "%s:%s" % (default_branch, remote_branch)
push_args = [push_remote.name, to_push]
push_args.append("--force")
if dry_run:
push_args.append("--dry-run")
rc, out = git.push(*push_args, raises=False)
if rc == 0:
ui.info(out)
else:
ui.error(out)