本文整理汇总了Python中rez.utils.logging_.print_warning函数的典型用法代码示例。如果您正苦于以下问题:Python print_warning函数的具体用法?Python print_warning怎么用?Python print_warning使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_warning函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: send_email
def send_email(self, subject, body):
if not self.settings.recipients:
return # nothing to do, sending email to nobody
if not self.settings.smtp_host:
print_warning("did not send release email: "
"SMTP host is not specified")
return
recipients = self.get_recipients()
if not recipients:
return
print "Sending release email to:"
print '\n'.join("- %s" % x for x in recipients)
msg = MIMEText(body)
msg["Subject"] = subject
msg["From"] = self.settings.sender
msg["To"] = str(',').join(recipients)
try:
s = smtplib.SMTP(self.settings.smtp_host, self.settings.smtp_port)
s.sendmail(from_addr=self.settings.sender,
to_addrs=recipients,
msg=msg.as_string())
print 'Email(s) sent.'
except Exception, e:
print_error("release email delivery failed: %s" % str(e))
开发者ID:LumaPictures,项目名称:rez,代码行数:29,代码来源:emailer.py
示例2: find_python
def find_python(python_version=None):
"""Find a pip exe using the given python version.
Returns:
2-tuple:
str: pip executable;
`ResolvedContext`: Context containing pip, or None if we fell back
to system pip.
"""
python_exe = "python"
try:
context = create_context(python_version)
except BuildError as e:
# fall back on system pip. Not ideal but at least it's something
from rez.backport.shutilwhich import which
python_exe = which("python")
if python_exe:
print_warning(
"python rez package could not be found; system 'python' "
"command (%s) will be used instead." % python_exe)
context = None
else:
raise e
return python_exe, context
开发者ID:mottosso,项目名称:rez,代码行数:28,代码来源:pip.py
示例3: create_release_hooks
def create_release_hooks(names, source_path):
hooks = []
for name in names:
try:
hook = create_release_hook(name, source_path)
hooks.append(hook)
except:
print_warning("Release hook '%s' is not available." % name)
return hooks
开发者ID:RovioAnimation,项目名称:rez,代码行数:9,代码来源:release_hook.py
示例4: create_release_hooks
def create_release_hooks(names, source_path):
hooks = []
for name in names:
try:
hook = create_release_hook(name, source_path)
hooks.append(hook)
except Exception:
import traceback
print_warning("Release hook '%s' is not available." % name)
print_debug(traceback.format_exc())
return hooks
开发者ID:LumaPictures,项目名称:rez,代码行数:11,代码来源:release_hook.py
示例5: create_release_tag
def create_release_tag(self, tag_name, message=None):
data = self._read_stub()
if "tags" not in data:
data["tags"] = {}
elif tag_name in data["tags"]:
print_warning("Skipped tag creation, tag '%s' already exists" % tag_name)
return
print "Creating tag '%s'..." % tag_name
data["tags"][tag_name] = message
self._write_stub(data)
开发者ID:LumaPictures,项目名称:rez,代码行数:11,代码来源:stub.py
示例6: check_format_version
def check_format_version(filename, data):
format_version_ = data.pop("format_version", None)
if format_version_ is not None:
try:
format_version_ = int(format_version_)
except:
return
if format_version_ > format_version:
print_warning(
"Loading from %s may fail: newer format version (%d) than current "
"format version (%d)" % (filename, format_version_, format_version))
开发者ID:instinct-vfx,项目名称:rez,代码行数:13,代码来源:filesystem.py
示例7: test_print
def test_print(self):
"""Test valid msg and nargs combinations for print_*."""
for msg in ("Hello", "Hello %s", "Hello %s %s"):
logging_.print_debug(msg)
logging_.print_info(msg)
logging_.print_warning(msg)
logging_.print_error(msg)
logging_.print_critical(msg)
for nargs in ([], ["foo"], ["foo", "bar"]):
logging_.print_debug(msg, *nargs)
logging_.print_info(msg, *nargs)
logging_.print_warning(msg, *nargs)
logging_.print_error(msg, *nargs)
logging_.print_critical(msg, *nargs)
开发者ID:instinct-vfx,项目名称:rez,代码行数:15,代码来源:test_logging.py
示例8: _physical_cores_base
def _physical_cores_base(self):
if self.logical_cores == 1:
# if we only have one core, we only have one core... no need to
# bother with platform-specific stuff...
# we do this check for all because on some platforms, the output
# of various commands (dmesg, lscpu, /proc/cpuinfo) can be
# very different if there's only one cpu, and don't want to have
# to deal with that case
return 1
cores = self._physical_cores()
if cores is None:
from rez.utils.logging_ import print_warning
print_warning("Could not determine number of physical cores - "
"falling back on logical cores value")
cores = self.logical_cores
return cores
开发者ID:instinct-vfx,项目名称:rez,代码行数:17,代码来源:platform_.py
示例9: _convert_to_rex
def _convert_to_rex(self, commands):
if isinstance(commands, list):
from rez.utils.backcompat import convert_old_commands
msg = "package %r is using old-style commands." % self.uri
if config.disable_rez_1_compatibility or config.error_old_commands:
raise SchemaError(None, msg)
elif config.warn("old_commands"):
print_warning(msg)
commands = convert_old_commands(commands)
if isinstance(commands, basestring):
return SourceCode(commands)
elif callable(commands):
return SourceCode.from_function(commands)
else:
return commands
开发者ID:saddingtonbaynes,项目名称:rez,代码行数:17,代码来源:package_resources_.py
示例10: bind_cli
def bind_cli(cls, parser):
"""
Uses a 'parse_build_args.py' file to add options, if found.
"""
try:
with open("./parse_build_args.py") as f:
source = f.read()
except Exception as e:
return
# detect what extra args have been added
before_args = set(x.dest for x in parser._actions)
try:
exec source in {"parser": parser}
except Exception as e:
print_warning("Error in ./parse_build_args.py: %s" % str(e))
after_args = set(x.dest for x in parser._actions)
extra_args = after_args - before_args
# store extra args onto parser so we can get to it in self.build()
setattr(parser, "_rezbuild_extra_args", list(extra_args))
开发者ID:Pixomondo,项目名称:rez,代码行数:23,代码来源:custom.py
示例11: bind
def bind(name, path, import_name=None, version_range=None, version=None,
requires=None, pure_python=None, tools=None, extra_module_names=[],
extra_attrs={}):
import_name = import_name or name
if version is None:
version = get_version_in_python(
name,
["import %s" % import_name,
"print %s.__version__" % import_name])
check_version(version, version_range)
py_major_minor = '.'.join(str(x) for x in sys.version_info[:2])
py_req = "python-%s" % py_major_minor
found_tools = {}
if pure_python is None:
raise NotImplementedError # detect
elif pure_python:
variant = [py_req]
else:
variant = system.variant + [py_req]
for tool in (tools or []):
try:
src = find_exe(tool)
found_tools[tool] = src
log("found tool '%s': %s" % (tool, src))
except RezBindError as e:
print_warning(str(e))
def make_root(variant, root):
pypath = make_dirs(root, "python")
copy_module(import_name, pypath)
if found_tools:
binpath = make_dirs(root, "bin")
for tool, src in sorted(found_tools.items()):
dest = os.path.join(binpath, tool)
shutil.copy2(src, dest)
for name_ in extra_module_names:
copy_module(name_, pypath)
with make_package(name, path, make_root=make_root) as pkg:
pkg.version = version
pkg.variants = [variant]
if requires:
pkg.requires = requires
if found_tools:
pkg.tools = list(found_tools)
pkg.commands = commands_with_bin
else:
pkg.commands = commands
for key, value in extra_attrs.iteritems():
pkg[key] = value
return pkg.installed_variants
开发者ID:LumaPictures,项目名称:rez,代码行数:62,代码来源:_pymodule.py
示例12: make_package
def make_package(name, path, make_base=None, make_root=None, skip_existing=True,
warn_on_skip=True):
"""Make and install a package.
Example:
>>> def make_root(variant, path):
>>> os.symlink("/foo_payload/misc/python27", "ext")
>>>
>>> with make_package('foo', '/packages', make_root=make_root) as pkg:
>>> pkg.version = '1.0.0'
>>> pkg.description = 'does foo things'
>>> pkg.requires = ['python-2.7']
Args:
name (str): Package name.
path (str): Package repository path to install package into.
make_base (callable): Function that is used to create the package
payload, if applicable.
make_root (callable): Function that is used to create the package
variant payloads, if applicable.
skip_existing (bool): If True, detect if a variant already exists, and
skip with a warning message if so.
warn_on_skip (bool): If True, print warning when a variant is skipped.
Yields:
`PackageMaker` object.
Note:
Both `make_base` and `make_root` are called once per variant install,
and have the signature (variant, path).
Note:
The 'installed_variants' attribute on the `PackageMaker` instance will
be appended with variant(s) created by this function, if any.
"""
maker = PackageMaker(name)
yield maker
# post-with-block:
#
package = maker.get_package()
cwd = os.getcwd()
src_variants = []
# skip those variants that already exist
if skip_existing:
for variant in package.iter_variants():
variant_ = variant.install(path, dry_run=True)
if variant_ is None:
src_variants.append(variant)
else:
maker.skipped_variants.append(variant_)
if warn_on_skip:
print_warning("Skipping installation: Package variant already "
"exists: %s" % variant_.uri)
else:
src_variants = package.iter_variants()
with retain_cwd():
# install the package variant(s) into the filesystem package repo at `path`
for variant in src_variants:
variant_ = variant.install(path)
base = variant_.base
if make_base and base:
if not os.path.exists(base):
os.makedirs(base)
os.chdir(base)
make_base(variant_, base)
root = variant_.root
if make_root and root:
if not os.path.exists(root):
os.makedirs(root)
os.chdir(root)
make_root(variant_, root)
maker.installed_variants.append(variant_)
开发者ID:mottosso,项目名称:rez,代码行数:80,代码来源:package_maker__.py
示例13: _copy_variant_payload
#.........这里部分代码省略.........
else:
ctxt = with_noop()
# copy the variant payload
with ctxt:
safe_makedirs(variant_install_path)
# determine files not to copy
skip_files = []
if is_varianted and not src_variant.parent.hashed_variants:
# Detect overlapped variants. This is the case where one variant subpath
# might be A, and another is A/B. We must ensure that A/B is not created
# as a symlink during shallow install of variant A - that would then
# cause A/B payload to be installed back into original package, possibly
# corrupting it.
#
# Here we detect this case, and create a list of dirs not to copy/link,
# because they are in fact a subpath dir for another variant.
#
# Note that for hashed variants, we don't do this check because overlapped
# variants are not possible.
#
skip_files.extend(_get_overlapped_variant_dirs(src_variant))
else:
# just skip package definition file
for name in config.plugins.package_repository.filesystem.package_filenames:
for fmt in (FileFormat.py, FileFormat.yaml):
filename = name + '.' + fmt.extension
skip_files.append(filename)
# copy/link all topmost files within the variant root
for name in os.listdir(variant_root):
if name in skip_files:
filepath = os.path.join(variant_root, name)
if verbose:
if is_varianted:
msg = ("Did not copy %s - this is part of an "
"overlapping variant's root path.")
else:
msg = "Did not copy package definition file %s"
print_info(msg, filepath)
continue
src_path = os.path.join(variant_root, name)
dest_path = os.path.join(variant_install_path, name)
if os.path.islink(src_path):
copy_func(src_path, dest_path)
else:
maybe_symlink(src_path, dest_path)
# copy permissions of source variant dirs onto dest
src_package = src_variant.parent
src_pkg_repo = src_package.repository
src_pkg_payload_path = src_pkg_repo.get_package_payload_path(
package_name=src_package.name,
package_version=src_package.version
)
shutil.copystat(src_pkg_payload_path, dest_pkg_payload_path)
subpath = src_variant_subpath
while subpath:
src_path = os.path.join(src_pkg_payload_path, subpath)
dest_path = os.path.join(dest_pkg_payload_path, subpath)
shutil.copystat(src_path, dest_path)
subpath = os.path.dirname(subpath)
# create the variant shortlink
if src_variant.parent.hashed_variants:
try:
# base _v dir
base_shortlinks_path = os.path.join(
dest_pkg_payload_path,
src_package.config.variant_shortlinks_dirname
)
safe_makedirs(base_shortlinks_path)
# shortlink
rel_variant_path = os.path.relpath(
variant_install_path, base_shortlinks_path)
create_unique_base26_symlink(
base_shortlinks_path, rel_variant_path)
except Exception as e:
# Treat any error as warning - lack of shortlink is not
# a breaking issue, it just means the variant root path
# will be long.
#
print_warning(
"Error creating variant shortlink for %s: %s: %s",
variant_install_path, e.__class__.__name__, e
)
开发者ID:mottosso,项目名称:rez,代码行数:101,代码来源:package_copy.py
示例14: repo_operation
def repo_operation(self):
exc_type = ReleaseVCSError if self.skip_repo_errors else None
try:
yield
except exc_type as e:
print_warning("THE FOLLOWING ERROR WAS SKIPPED:\n%s" % str(e))
开发者ID:rvsiy,项目名称:rez,代码行数:6,代码来源:build_process_.py
示例15: _unsupported_option
def _unsupported_option(cls, option, val):
if val and config.warn("shell_startup"):
print_warning("%s ignored, not supported by %s shell"
% (option, cls.name()))
开发者ID:rvsiy,项目名称:rez,代码行数:4,代码来源:shells.py
示例16: spawn_shell
#.........这里部分代码省略.........
def _create_ex():
return RexExecutor(interpreter=self.new_shell(),
parent_environ={},
add_default_namespaces=False)
executor = _create_ex()
if self.settings.prompt:
newprompt = '${REZ_ENV_PROMPT}%s' % self.settings.prompt
executor.interpreter._saferefenv('REZ_ENV_PROMPT')
executor.env.REZ_ENV_PROMPT = newprompt
if d["command"] is not None:
_record_shell(executor, files=files)
shell_command = d["command"]
else:
if d["stdin"]:
assert(self.stdin_arg)
shell_command = "%s %s" % (self.executable, self.stdin_arg)
quiet = True
elif do_rcfile:
assert(self.rcfile_arg)
shell_command = "%s %s" % (self.executable, self.rcfile_arg)
else:
shell_command = self.executable
if do_rcfile:
# hijack rcfile to insert our own script
ex = _create_ex()
_record_shell(ex, files=files, print_msg=(not quiet))
filename = "rcfile.%s" % self.file_extension()
filepath = _write_shell(ex, filename)
shell_command += " %s" % filepath
elif envvar:
# hijack env-var to insert our own script
ex = _create_ex()
_record_shell(ex, files=files, print_msg=(not quiet))
filename = "%s.%s" % (envvar, self.file_extension())
filepath = _write_shell(ex, filename)
executor.setenv(envvar, filepath)
else:
# hijack $HOME to insert our own script
files = [x for x in files if x not in bind_files] + list(bind_files)
if files:
for file in files:
if file in bind_files:
bind_rez = True
files_ = [file] if d["source_bind_files"] else []
else:
bind_rez = False
files_ = [file]
ex = _create_ex()
ex.setenv('HOME', os.environ.get('HOME', ''))
_record_shell(ex, files=files_, bind_rez=bind_rez,
print_msg=bind_rez)
_write_shell(ex, os.path.basename(file))
executor.setenv("HOME", tmpdir)
# keep history
if self.histfile and self.histvar:
histfile = os.path.expanduser(self.histfile)
if os.path.exists(histfile):
executor.setenv(self.histvar, histfile)
else:
if config.warn("shell_startup"):
print_warning(
"WARNING: Could not configure environment from "
"within the target shell (%s); this has been done "
"in the parent process instead." % self.name())
executor.source(context_file)
if shell_command: # an empty string means 'run no command and exit'
executor.command(shell_command)
executor.command("exit %s" % self.last_command_status)
code = executor.get_output()
target_file = os.path.join(tmpdir, "rez-shell.%s" % self.file_extension())
with open(target_file, 'w') as f:
f.write(code)
if d["stdin"] and stdin and (stdin is not True):
Popen_args["stdin"] = stdin
cmd = []
if pre_command:
if isinstance(pre_command, basestring):
cmd = pre_command.strip().split()
else:
cmd = pre_command
cmd.extend([self.executable, target_file])
try:
p = subprocess.Popen(cmd, env=env, **Popen_args)
except Exception as e:
cmd_str = ' '.join(map(pipes.quote, cmd))
raise RezSystemError("Error running command:\n%s\n%s"
% (cmd_str, str(e)))
return p
开发者ID:rvsiy,项目名称:rez,代码行数:101,代码来源:shells.py
示例17: _overruled_option
def _overruled_option(cls, option, overruling_option, val):
if val and config.warn("shell_startup"):
print_warning("%s ignored by %s shell - overruled by %s option"
% (option, cls.name(), overruling_option))
开发者ID:rvsiy,项目名称:rez,代码行数:4,代码来源:shells.py
示例18: _build_variant_base
def _build_variant_base(self, variant, build_type, install_path=None,
clean=False, install=False, **kwargs):
# create build/install paths
install_path = install_path or self.package.config.local_packages_path
package_install_path = self.get_package_install_path(install_path)
variant_build_path = self.build_path
if variant.index is None:
variant_install_path = package_install_path
else:
subpath = variant._non_shortlinked_subpath
variant_build_path = os.path.join(variant_build_path, subpath)
variant_install_path = os.path.join(package_install_path, subpath)
# create directories (build, install)
if clean and os.path.exists(variant_build_path):
shutil.rmtree(variant_build_path)
safe_makedirs(variant_build_path)
# find last dir of installation path that exists, and possibly make it
# writable during variant installation
#
last_dir = get_existing_path(variant_install_path,
topmost_path=install_path)
if last_dir:
ctxt = make_path_writable(last_dir)
else:
ctxt = with_noop()
with ctxt:
if install:
# inform package repo that a variant is about to be built/installed
pkg_repo = package_repository_manager.get_repository(install_path)
pkg_repo.pre_variant_install(variant.resource)
if not os.path.exists(variant_install_path):
safe_makedirs(variant_install_path)
# if hashed variants are enabled, create the variant shortlink
if variant.parent.hashed_variants:
try:
# create the dir containing all shortlinks
base_shortlinks_path = os.path.join(
package_install_path,
variant.parent.config.variant_shortlinks_dirname
)
safe_makedirs(base_shortlinks_path)
# create the shortlink
rel_variant_path = os.path.relpath(
variant_install_path, base_shortlinks_path)
create_unique_base26_symlink(
base_shortlinks_path, rel_variant_path)
except Exception as e:
# Treat any error as warning - lack of shortlink is not
# a breaking issue, it just means the variant root path
# will be long.
#
print_warning(
"Error creating variant shortlink for %s: %s: %s",
variant_install_path, e.__class__.__name__, e
)
# Re-evaluate the variant, so that variables such as 'building' and
# 'build_variant_index' are set, and any early-bound package attribs
# are re-evaluated wrt these vars. This is done so that attribs such as
# 'requires' can change depending on whether a build is occurring or not.
#
# Note that this re-evaluated variant is ONLY used here, for the purposes
# of creating the build context. The variant that is actually installed
# is the one evaluated where 'building' is False.
#
re_evaluated_package = variant.parent.get_reevaluated({
"building": True,
"build_variant_index": variant.index or 0,
"build_variant_requires": variant.variant_requires
})
re_evaluated_variant = re_evaluated_package.get_variant(variant.index)
# create build environment
context, rxt_filepath = self.create_build_context(
variant=re_evaluated_variant,
build_type=build_type,
build_path=variant_build_path)
# run build system
build_system_name = self.build_system.name()
self._print("\nInvoking %s build system...", build_system_name)
build_result = self.build_system.build(
context=context,
variant=variant,
build_path=variant_build_path,
install_path=variant_install_path,
install=install,
build_type=build_type)
#.........这里部分代码省略.........
开发者ID:mottosso,项目名称:rez,代码行数:101,代码来源:local.py
注:本文中的rez.utils.logging_.print_warning函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论