How to use the rez.cli.error function in rez

To help you get started, we’ve selected a few rez examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nerdvegas / rez / to_delete / cli / egg_install.py View on Github external
reqs = distr.requires()
    for req in reqs:
        rezreqs = _convert_requirement(req, package_remappings)
        requires += rezreqs

    if force_platform is None:
        v = pkg_d.get("Platform")
        if native and v.lower() == 'unknown':
            # cannot allow native lib to be unknown
            import rez.filesys
            variant = ["platform-"+system.platform] + variant
        elif v:
            platform_pkgs = platform_remappings.get(v.lower())
            if platform_pkgs is None:
                error(("No remappings are present for the platform '%s'. " +
                       "Please use the --mapping-file option to provide the remapping, or " +
                       "use the --force-platform option.") % v)
                sys.exit(1)
            else:
                if platform_pkgs:
                    variant = platform_pkgs + variant
    else:
        toks = force_platform.replace(',', ' ').strip().split()
        if toks:
            variant = toks + variant

    if variant:
        # add our variant
        d["variants"] = [variant]
    if requires:
        d["requires"] = requires
github nerdvegas / rez / to_delete / cli / egg_install.py View on Github external
error("A problem occurred running easy_install, the command was:\n%s" % install_cmd)
            sys.exit(proc.returncode)

        #########################################################################################
        # extract info from eggs
        #########################################################################################

        # add eggs to python path
        sys.path = [eggs_path] + sys.path
        distrs = list(pkg_r.find_distributions(eggs_path))

        if not distrs:
            error("easy_install failed to install the package")
            sys.exit(1)
        if len(distrs) != 1:
            error("should have only found one package in install directory")
            sys.exit(1)
        distr = distrs[0]

        print
        print "EXTRACTING DATA FROM %s..." % distr.location
        egg_name, d = _get_package_data_from_dist(distr, opts.force_platform,
                                                  package_remappings,
                                                  platform_remappings)

        tools = os.listdir(bin_path)
        if tools:
            d['tools'] = tools

        print
        print "FOUND EGG: %s" % egg_name
        if tools:
github nerdvegas / rez / to_delete / cli / make_project.py View on Github external
if proj_type == "doxygen":
            str_repl["HELP"] = "help: %s file://!ROOT!/doc/html/index.html" % browser
        elif proj_type == "python":
            commands.append("export PYTHONPATH=$PYTHONPATH:!ROOT!/python")

        requires += _project_requires[proj_type]
        build_requires += _project_build_requires[proj_type]

        str_repl["COMMANDS"] = _gen_list("commands", commands)
        str_repl["REQUIRES"] = _gen_list("requires", requires)
        str_repl["BUILD_REQUIRES"] = _gen_list("build_requires", build_requires)

        template_dir = "%s/template/project_types/%s" % (os.getenv("REZ_PATH"), proj_type)
        if not os.path.exists(template_dir):
            error("Internal error - path %s not found." % template_dir)
            sys.exit(1)

        for root, dirs, files in os.walk(template_dir):
            dest_root = _expand_path(root.replace(template_dir, cwd))
            for dir in dirs:
                dest_dir = _expand_path(os.path.join(dest_root, dir))
                _mkdir(dest_dir)

            for file in files:
                fpath = os.path.join(root, file)
                f = open(fpath, 'r')
                s = f.read()
                f.close()

                # do string replacement, and remove extraneous blank lines
                s = _expand(s)
github nerdvegas / rez / src / rez / build_utils.py View on Github external
def _apply_patch(metadata, patch_info, source_path):
    action = patch_info['type']
    if action == 'patch':
        patch = patch_info['file']
        print "applying patch %s" % patch
        patch = os.path.abspath(patch)
        # TODO: handle urls. for now, assume relative
        result = subprocess.call(['patch', '-p1', '-i', patch],
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE,
                                 cwd=source_path)
        if result:
            error("Failed to apply patch: %s" % patch)
            sys.exit(1)
    elif action == 'append':
        path = patch_info['file']
        text = patch_info['text']
        path = os.path.join(source_path, path)
        print "appending %r to %s" % (text, path)
        with open(path, 'a') as f:
            f.write(text)
    elif action == 'prepend':
        path = patch_info['file']
        text = patch_info['text']
        path = os.path.join(source_path, path)
        print "prepending %r to %s" % (text, path)
        with open(path, 'r') as f:
            curr_text = f.read()
        with open(path, 'w') as f:
github nerdvegas / rez / to_delete / cli / egg_install.py View on Github external
def command(opts, parser=None):
    try:
        import yaml
    except ImportError:
        # TODO: save the yaml path gathered on install and import yaml.py directly
        error("rez-egg-install uses the python binary found on the PATH instead of "
              "REZ_PYTHON_BINARY. Ensure that this python has yaml installed.")
        sys.exit(1)
        # This is required to successfully inspect modules, particularly "compiled extensions.

    print "Using python interpreter: %s" % sys.executable

#     pkg_name = opts.pkg

    install_evar = "REZ_EGG_PACKAGES_PATH"
    if opts.local:
        install_evar = "REZ_LOCAL_PACKAGES_PATH"

    install_path = os.getenv(install_evar)
    if not install_path:
        error("Expected $%s to be set." % install_evar)
        sys.exit(1)
github nerdvegas / rez / to_delete / cli / help.py View on Github external
# find pkg and load help metadata
    ##########################################################################################

    # attempt to load the latest
    from rez.packages import pkg_name, iter_packages_in_range
    name = pkg_name(opts.pkg)
    found_pkg = None
    for pkg in iter_packages_in_range(name):
        if pkg.metadata is None:
            continue
        if "help" in pkg.metadata:
            found_pkg = pkg
            break

    if found_pkg is None:
        error("Could not find a package with help for %s" % opts.pkg)
        sys.exit(1)

    help = pkg.metadata.get("help")
    descr = pkg.metadata.get("description")
    if descr:
        print
        print "Description:"
        print descr.strip()
        print

    print "help found for " + pkg.base

    ##########################################################################################
    # determine help command
    ##########################################################################################
    cmds = []
github nerdvegas / rez / to_delete / cli / install.py View on Github external
def _get_repos(ignore_select=False):
        urls = formulae_manager.get_urls()
        if ignore_select or opts.repo is None:
            return list(enumerate(urls))
        idx = opts.repo - 1
        if (idx < 0) or (idx >= len(urls)):
            error("Invalid repository index.")
            sys.exit(1)
        return [(idx, urls[idx])]
github nerdvegas / rez / src / rez / build_utils.py View on Github external
try:
            for url,src_type,rev in urls:
                try:
                    return get_source(url, dest_path,
                                      type=src_type,
                                      revision=rev,
                                      cache_path=cache_path)
                except Exception, e:
                    err_msg = traceback.format_exc()
                    error("Error retrieving source from %s: %s"
                          % (url, err_msg.rstrip()))
                error("Failed to retrieve source from any url")
                sys.exit(1)
        except SourceRetrieverError, e:
            error(str(e))
            sys.exit(1)
github nerdvegas / rez / to_delete / cli / egg_install.py View on Github external
def _get_easy_install_cmd():
    # find easy_install
    proc = sp.Popen("easy_install --version", shell=True, stdout=sp.PIPE, stderr=sp.PIPE)
    out, err = proc.communicate()
    if proc.returncode:
        error("could not find easy_install.")
        return
    if out.split()[1] < '1.1.0':
        error("requires setuptools 1.1 or higher")
        return
    # do not install any dependencies. we will recursively install them
    cmd = "easy_install --no-deps "
    cmd += "--install-dir='%s/lib' "
    cmd += "--script-dir=bin "
    return cmd
github nerdvegas / rez / to_delete / cli / egg_install.py View on Github external
def _get_pip_install_cmd():
    proc = sp.Popen("pip --version", shell=True, stdout=sp.PIPE, stderr=sp.PIPE)
    out, err = proc.communicate()
    if proc.returncode:
        error("could not find pip: %s" % err)
        return
    # do not install any dependencies. we will recursively install them
    cmd = "pip install --no-deps "
    cmd += "--install-option='--install-base=""' "
    cmd += "--install-option='--install-purelib=lib' "
    cmd += "--install-option='--install-platlib=lib' "
    cmd += "--install-option='--install-scripts=bin' "
    cmd += "--install-option='--install-data=data' "
    cmd += " --root='%s' "
    return cmd