Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
cmd = convert_old_command_expansions(cmd)
toks = cmd.strip().split()
try:
if toks[0] == "export":
var, value = cmd.split(' ', 1)[1].split('=', 1)
for bookend in ('"', "'"):
if value.startswith(bookend) and value.endswith(bookend):
value = value[1:-1]
break
# As the only old-style commands were Linux/Bash based,
# we assume using the default separator ":" is ok - we don't
# need to use os.pathsep as we don't expected to see a
# Windows path here.
separator = config.env_var_separators.get(var, ":")
# This is a special case. We don't want to include "';'" in
# our env var separators map as it's not really the correct
# behaviour/something we want to promote. It's included here for
# backwards compatibility only, and to not propogate elsewhere.
if var == "CMAKE_MODULE_PATH":
value = value.replace("'%s'" % separator, separator)
value = value.replace('"%s"' % separator, separator)
value = value.replace(":", separator)
parts = value.split(separator)
parts = [x for x in parts if x]
if len(parts) > 1:
idx = None
var1 = "$%s" % var
var2 = "${%s}" % var
def view_graph(graph_str, dest_file=None):
"""View a dot graph in an image viewer."""
from rez.system import system
from rez.config import config
if (system.platform == "linux") and (not os.getenv("DISPLAY")):
print("Unable to open display.", file=sys.stderr)
sys.exit(1)
dest_file = _write_graph(graph_str, dest_file=dest_file)
# view graph
viewed = False
prog = config.image_viewer or 'browser'
print("loading image viewer (%s)..." % prog)
if config.image_viewer:
proc = popen([config.image_viewer, dest_file])
proc.wait()
viewed = not bool(proc.returncode)
if not viewed:
import webbrowser
webbrowser.open_new("file://" + dest_file)
def command(opts, parser, extra_arg_groups=None):
from rez.config import config
from rez.package_bind import bind_package, find_bind_module, \
get_bind_modules, _print_package_list
from rez.utils.formatting import PackageRequest, columnise
if opts.release:
install_path = config.release_packages_path
elif opts.install_path:
install_path = opts.install_path
else:
install_path = config.local_packages_path
if opts.list:
d = get_bind_modules()
rows = [["PACKAGE", "BIND MODULE"],
["-------", "-----------"]]
rows += sorted(d.items())
print('\n'.join(columnise(rows)))
return
if opts.quickstart:
# note: in dependency order, do not change
names = ["platform",
"arch",
"os",
"python",
"rez",
def _track_context(self, context_data, action):
from rez.utils.amqp import publish_message
# create message payload
data = {
"action": action,
"context": context_data
}
self._init_context_tracking_payload_base()
data.update(self.context_tracking_payload)
# publish message
routing_key = (config.context_tracking_amqp["exchange_routing_key"] +
'.' + action.upper())
publish_message(
host=config.context_tracking_host,
amqp_settings=config.context_tracking_amqp,
routing_key=routing_key,
data=data,
block=False
)
# create and execute release process
builder = create_build_process(opts.process,
working_dir,
package=package,
build_system=buildsys,
vcs=vcs,
ensure_latest=(not opts.no_latest),
skip_repo_errors=opts.skip_repo_errors,
ignore_existing_tag=opts.ignore_existing_tag,
verbose=True)
# get release message
release_msg = opts.message
filepath = None
if config.prompt_release_message and not release_msg and not opts.no_message:
from hashlib import sha1
h = sha1(working_dir.encode("utf8")).hexdigest()
filename = "rez-release-message-%s.txt" % h
filepath = os.path.join(config.tmpdir, filename)
header = ""
changelog_token = "###"
if not os.path.exists(filepath):
txt = header
# get changelog and add to release notes file, for reference. They
# get stripped out again before being added as package release notes.
try:
changelog = builder.get_changelog()
"""
multi_launchapp = self.parent
extra = multi_launchapp.get_setting("extra")
use_rez = False
if self.check_rez():
from rez.resolved_context import ResolvedContext
from rez.config import config
# Define variables used to bootstrap tank from overwrite on first reference
# PYTHONPATH is used by tk-maya
# NUKE_PATH is used by tk-nuke
# HIERO_PLUGIN_PATH is used by tk-nuke (nukestudio)
# KATANA_RESOURCES is used by tk-katana
config.parent_variables = ["PYTHONPATH", "HOUDINI_PATH", "NUKE_PATH", "HIERO_PLUGIN_PATH", "KATANA_RESOURCES"]
rez_packages = extra["rez_packages"]
context = ResolvedContext(rez_packages)
use_rez = True
system = sys.platform
shell_type = 'bash'
if system == "linux2":
# on linux, we just run the executable directly
cmd = "%s %s &" % (app_path, app_args)
elif self.parent.get_setting("engine") in ["tk-flame", "tk-flare"]:
# flame and flare works in a different way from other DCCs
# on both linux and mac, they run unix-style command line
# and on the mac the more standardized "open" command cannot
@config.lru_cache("resource_caching", "resource_caching_maxsize")
def _listdir(path, is_file=None):
names = []
if os.path.exists(path):
for name in os.listdir(path):
filepath = os.path.join(path, name)
if is_file is None or os.path.isfile(filepath) == is_file:
names.append(name)
return names
ReleaseVCSError, _NeverError
from rez.utils.logging_ import print_warning
from rez.utils.colorize import heading, Printer
from rez.resolved_context import ResolvedContext
from rez.release_hook import create_release_hooks
from rez.resolver import ResolverStatus
from rez.config import config
from rez.vendor.enum import Enum
from contextlib import contextmanager
from pipes import quote
import getpass
import os.path
import sys
debug_print = config.debug_printer("package_release")
def get_build_process_types():
"""Returns the available build process implementations."""
from rez.plugin_managers import plugin_manager
return plugin_manager.get_plugins('build_process')
def create_build_process(process_type, working_dir, build_system, package=None,
vcs=None, ensure_latest=True, skip_repo_errors=False,
ignore_existing_tag=False, verbose=False, quiet=False):
"""Create a `BuildProcess` instance."""
from rez.plugin_managers import plugin_manager
process_types = get_build_process_types()
if process_type not in process_types:
raise BuildProcessError("Unknown build process: %r" % process_type)
def _data(self):
if not self.schema:
return None
data = self._load()
if config.debug("resources"):
print_debug("Loaded resource: %s" % str(self))
return data
executor.setenv("REZ_USED", self.rez_path)
executor.setenv("REZ_USED_VERSION", self.rez_version)
executor.setenv("REZ_USED_TIMESTAMP", str(self.timestamp))
executor.setenv("REZ_USED_REQUESTED_TIMESTAMP",
str(self.requested_timestamp or 0))
executor.setenv("REZ_USED_REQUEST", request_str)
executor.setenv("REZ_USED_IMPLICIT_PACKAGES", implicit_str)
executor.setenv("REZ_USED_RESOLVE", resolve_str)
executor.setenv("REZ_USED_PACKAGES_PATH", package_paths_str)
if self.building:
executor.setenv("REZ_BUILD_ENV", "1")
# rez-1 environment variables, set in backwards compatibility mode
if config.rez_1_environment_variables and \
not config.disable_rez_1_compatibility:
request_str_ = " ".join([request_str, implicit_str]).strip()
executor.setenv("REZ_VERSION", self.rez_version)
executor.setenv("REZ_PATH", self.rez_path)
executor.setenv("REZ_REQUEST", request_str_)
executor.setenv("REZ_RESOLVE", resolve_str)
executor.setenv("REZ_RAW_REQUEST", request_str_)
executor.setenv("REZ_RESOLVE_MODE", "latest")
# binds objects such as 'request', which are accessible before a resolve
bindings = self._get_pre_resolve_bindings()
for k, v in bindings.items():
executor.bind(k, v)
executor.bind('resolve', VariantsBinding(resolved_pkgs))
#