Example #1
0
 def localise(self, packages):
     local_repo = config.get('local_packages_path')
     self.logger.info('Localising..')
     for package in packages:
         copy_package(package, local_repo, keep_timestamp=True)
     self.logger.info(f'{len(packages)} packages localised.')
     self.packagesChanged.emit()
Example #2
0
def _get_application_parent_environ():
    from rez.config import config
    from rez.shells import create_shell

    if not config.get("inherit_parent_environment", True):
        # bleeding-rez, isolate enabled.
        sh = create_shell()
        return sh.environment()

    return (allzparkconfig.application_parent_environment()
            or os.environ.copy())
Example #3
0
def _color(str_, fore_color=None, back_color=None, styles=None):
    """ Return the string wrapped with the appropriate styling escape sequences.

    Args:
      str_ (str): The string to be wrapped.
      fore_color (str, optional): Any foreground color supported by the
        `Colorama`_ module.
      back_color (str, optional): Any background color supported by the
        `Colorama`_ module.
      styles (list of str, optional): Any styles supported by the `Colorama`_
        module.

    Returns:
      str: The string styled with the appropriate escape sequences.

    .. _Colorama:
        https://pypi.python.org/pypi/colorama
    """
    # TODO: Colorama is documented to work on Windows and trivial test case
    # proves this to be the case, but it doesn't work in Rez.  If the initialise
    # is called in sec/rez/__init__.py then it does work, however as discussed
    # in the following comment this is not always desirable.  So until we can
    # work out why we forcibly turn it off.
    if not config.get("color_enabled", False) or platform_.name == "windows":
        return str_

    # lazily init colorama. This is important - we don't want to init at startup,
    # because colorama prints a RESET_ALL character atexit. This in turn adds
    # unexpected output when capturing the output of a command run in a
    # ResolvedContext, for example.
    _init_colorama()

    colored = ""
    if not styles:
        styles = []

    if fore_color:
        colored += getattr(colorama.Fore, fore_color.upper(), '')
    if back_color:
        colored += getattr(colorama.Back, back_color.upper(), '')
    for style in styles:
        colored += getattr(colorama.Style, style.upper(), '')

    return colored + str_ + colorama.Style.RESET_ALL
Example #4
0
def _color(str_, fore_color=None, back_color=None, styles=None):
    """ Return the string wrapped with the appropriate styling escape sequences.

    Args:
      str_ (str): The string to be wrapped.
      fore_color (str, optional): Any foreground color supported by the
        `Colorama`_ module.
      back_color (str, optional): Any background color supported by the
        `Colorama`_ module.
      styles (list of str, optional): Any styles supported by the `Colorama`_
        module.

    Returns:
      str: The string styled with the appropriate escape sequences.

    .. _Colorama:
        https://pypi.python.org/pypi/colorama
    """
    # TODO: Colorama is documented to work on Windows and trivial test case
    # proves this to be the case, but it doesn't work in Rez.  If the initialise
    # is called in sec/rez/__init__.py then it does work, however as discussed
    # in the following comment this is not always desirable.  So until we can
    # work out why we forcibly turn it off.
    if not config.get("color_enabled", False) or platform_.name == "windows":
        return str_

    # lazily init colorama. This is important - we don't want to init at startup,
    # because colorama prints a RESET_ALL character atexit. This in turn adds
    # unexpected output when capturing the output of a command run in a
    # ResolvedContext, for example.
    _init_colorama()

    colored = ""
    if not styles:
        styles = []

    if fore_color:
        colored += getattr(colorama.Fore, fore_color.upper(), '')
    if back_color:
        colored += getattr(colorama.Back, back_color.upper(), '')
    for style in styles:
        colored += getattr(colorama.Style, style.upper(), '')

    return colored + str_ + colorama.Style.RESET_ALL
Example #5
0
def _color(str_, fore_color=None, back_color=None, styles=None):
    """ Return the string wrapped with the appropriate styling escape sequences.

    Args:
      str_ (str): The string to be wrapped.
      fore_color (str, optional): Any foreground color supported by the
        `Colorama`_ module.
      back_color (str, optional): Any background color supported by the
        `Colorama`_ module.
      styles (list of str, optional): Any styles supported by the `Colorama`_
        module.

    Returns:
      str: The string styled with the appropriate escape sequences.

    .. _Colorama:
        https://pypi.python.org/pypi/colorama
    """
    if not config.get("color_enabled", False):
        return str_

    # lazily init colorama. This is important - we don't want to init at startup,
    # because colorama prints a RESET_ALL character atexit. This in turn adds
    # unexpected output when capturing the output of a command run in a
    # ResolvedContext, for example.
    _init_colorama()

    colored = ""
    if not styles:
        styles = []

    if fore_color:
        colored += getattr(colorama.Fore, fore_color.upper(), '')
    if back_color:
        colored += getattr(colorama.Back, back_color.upper(), '')
    for style in styles:
        colored += getattr(colorama.Style, style.upper(), '')

    return colored + str_ + colorama.Style.RESET_ALL
Example #6
0
    def test_executable(self):
        """Test suite tool can be executed

        Testing suite tool can be found and executed in multiple platforms.
        This test is equivalent to the following commands in shell:
        ```
        $ rez-env pooh --output pooh.rxt
        $ rez-suite --create pooh
        $ rez-suite --add pooh.rxt --context pooh pooh
        $ export PATH=$(pwd)/pooh/bin:$PATH
        $ hunny
        yum yum
        ```

        """
        c_pooh = ResolvedContext(["pooh"])
        s = Suite()
        s.add_context("pooh", c_pooh)

        expected_tools = set(["hunny"])
        self.assertEqual(set(s.get_tools().keys()), expected_tools)

        per_shell = config.get("default_shell")
        suite_path = os.path.join(self.root, "test_suites", per_shell, "pooh")
        s.save(suite_path)

        bin_path = os.path.join(suite_path, "bin")
        env = os.environ.copy()
        # activate rez, to access _rez_fwd
        env["PATH"] = os.pathsep.join([system.rez_bin_path, env["PATH"]])
        # activate suite
        env["PATH"] = os.pathsep.join([bin_path, env["PATH"]])

        output = subprocess.check_output(["hunny"],
                                         shell=True,
                                         env=env,
                                         universal_newlines=True)
        self.assertTrue("yum yum" in output)
Example #7
0
 def __init__(self, buf=sys.stdout):
     self.buf = buf
     self.colorize = (config.get("color_enabled", False) == "force"
                      or stream_is_tty(buf))
Example #8
0
 def is_colorized(self):
     return config.get("color_enabled", False) == "force" or self.is_tty
Example #9
0
def _get_style_from_config(key):
    fore_color = config.get("%s_fore" % key, '')
    back_color = config.get("%s_back" % key, '')
    styles = config.get("%s_styles" % key, None)
    return fore_color, back_color, styles
Example #10
0
 def __init__(self, buf=sys.stdout):
     self.buf = buf
     self.colorize = (config.get("color_enabled", False) == "force") \
                     or stream_is_tty(buf)
Example #11
0
 def is_colorized(self):
     return config.get("color_enabled", False) == "force" or self.is_tty
Example #12
0
def _get_style_from_config(key):
    fore_color = config.get("%s_fore" % key, '')
    back_color = config.get("%s_back" % key, '')
    styles = config.get("%s_styles" % key, None)
    return fore_color, back_color, styles
Example #13
0
    def __init__(self, parent=None):
        self.repos = config.get('packages_path')
        super(RezPackagesModel, self).__init__(0, len(self.repos) + 1)
        self.setHorizontalHeaderLabels(['Package'] + self.repos)

        self.logger = logging.getLogger(__name__)
Example #14
0
def get_local_repo_index():
    packages_path = config.get('packages_path', [])
    local_packages_path = config.get('local_packages_path')
    if local_packages_path in packages_path:
        return packages_path.index(local_packages_path)
    return -1