Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.code_pending = True
self.overview_edit = StreamableTextEdit()
self.overview_edit.setStyleSheet("font: 12pt 'Courier'")
self.graph_btn = ViewGraphButton(context_model)
btn_pane = create_pane([None, self.graph_btn], True)
overview_pane = create_pane([self.overview_edit, btn_pane], False)
self.code_edit = SearchableTextEdit()
self.code_edit.setStyleSheet("font: 12pt 'Courier'")
self.code_combo = QtWidgets.QComboBox()
# strip out 'sh' and 'csh', they only differ from bash and tcsh in shell
# startup behaviour, which is irrelevant here
code_types = set(get_shell_types()) - set([system.shell, "sh", "csh"])
code_types = [system.shell] + sorted(code_types) + ["python dict"]
for code_type in code_types:
self.code_combo.addItem(code_type)
label = QtWidgets.QLabel("Format:")
btn_pane = create_pane([None, label, self.code_combo], True)
code_pane = create_pane([self.code_edit, btn_pane], False)
self.environ_widget = ContextEnvironWidget()
self.addTab(overview_pane, "overview")
self.addTab(code_pane, "shell code")
self.addTab(self.environ_widget, "environment")
self.code_combo.currentIndexChanged.connect(self._update_code)
self.currentChanged.connect(self._currentTabChanged)
binpath = make_dirs(root, "bin")
link = os.path.join(binpath, "python")
platform_.symlink(exepath, link)
if builtin_paths:
pypath = make_dirs(root, "python")
for dirname, srcpath in builtin_paths.items():
destpath = os.path.join(pypath, dirname)
log("Copying builtins from %s to %s..." % (srcpath, destpath))
shutil.copytree(srcpath, destpath)
with make_package("python", path, make_root=make_root) as pkg:
pkg.version = version
pkg.tools = ["python"]
pkg.commands = commands
pkg.variants = [system.variant]
if builtin_paths:
pkg.post_commands = post_commands
return pkg.installed_variants
filename = prefix + uuid4().hex + ".json"
filepath = os.path.join(self._pending_dir, filename)
with open(filepath, 'w') as f:
f.write(json.dumps(handle_dict))
# configure executable
if platform.system() == "Windows":
kwargs = {
"creationflags": subprocess.CREATE_NEW_PROCESS_GROUP
}
else:
kwargs = {
"preexec_fn": os.setsid
}
exe = os.path.join(system.rez_bin_path, "rez-pkg-cache")
if not exe:
# this should not happen
raise RuntimeError("Did not find rez-pkg-cache executable")
# start caching subproc
args = [exe, "--daemon", self.path]
try:
with open(os.devnull, 'w') as devnull:
# don't suppress output if selftest running, easier to debug
if system.selftest_is_running:
out_target = None
else:
out_target = devnull
def bind(path, version_range=None, opts=None, parser=None):
version = Version(system.arch)
check_version(version, version_range)
with make_package("arch", path) as pkg:
pkg.version = version
return pkg.installed_variants
parent_variables=parent_variables)
if isinstance(interpreter, Python):
interpreter.set_manager(self.manager)
if shebang:
self.manager.shebang()
self.environ = EnvironmentDict(self.manager)
self.bind('env', AttrDictWrapper(self.environ))
for cmd, func in self.manager.get_public_methods():
self.bind(cmd, func)
if add_default_namespaces:
self.bind('system', system)
# create directories and symlink gcc and g++
def make_root(variant, root):
bin_path = make_dirs(root, 'bin')
gcc_link_path = os.path.join(bin_path, 'gcc')
platform_.symlink(gcc_path, gcc_link_path)
gpp_link_path = os.path.join(bin_path, 'g++')
platform_.symlink(gpp_path, gpp_link_path)
with make_package('gcc', path, make_root=make_root) as pkg:
pkg.version = gcc_version
pkg.tools = ['gcc', 'g++']
pkg.commands = commands
pkg.variants = [system.variant]
return pkg.installed_variants
def bind(path, version_range=None, opts=None, parser=None):
version = Version(system.os)
check_version(version, version_range)
with make_package("os", path) as pkg:
pkg.version = version
pkg.requires = ["platform-%s" % system.platform,
"arch-%s" % system.arch]
return pkg.installed_variants
def bind(path, version_range=None, opts=None, parser=None):
version = Version(system.platform)
check_version(version, version_range)
with make_package("platform", path) as pkg:
pkg.version = version
return pkg.installed_variants
def _record_shell(ex, files, bind_rez=True, print_msg=False):
ex.source(context_file)
if startup_sequence["envvar"]:
ex.unsetenv(startup_sequence["envvar"])
if add_rez and bind_rez:
ex.interpreter._bind_interactive_rez()
if print_msg and add_rez and not quiet:
ex.info('')
ex.info('You are now in a rez-configured environment.')
ex.info('')
if system.is_production_rez_install:
ex.command("rezolve context")
def add_variants_async(self, variants):
"""Update the package cache by adding some or all of the given variants.
This method is called when a context is created or sourced. Variants
are then added to the cache in a separate process.
"""
# A prod install is necessary because add_variants_async works by
# starting a rez-pkg-cache proc, and this can only be done reliably in
# a prod install. On non-windows we could fork instead, but there would
# remain no good solution on windows.
#
if not system.is_production_rez_install:
raise PackageCacheError(
"PackageCache.add_variants_async is only supported in a "
"production rez installation."
)
variants_ = []
# trim down to those variants that are cachable, and not already cached
for variant in variants:
if not variant.parent.is_cachable:
continue
status, _ = self._get_cached_root(variant)
if status == self.VARIANT_NOT_FOUND:
variants_.append(variant)