Python mako.exceptions.RuntimeException() Examples

The following are 30 code examples of mako.exceptions.RuntimeException(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module mako.exceptions , or try the search function .
Example #1
Source File: runtime.py    From ansible-cmdb with GNU General Public License v3.0 6 votes vote down vote up
def capture(context, callable_, *args, **kwargs):
    """Execute the given template def, capturing the output into
    a buffer.

    See the example in :ref:`namespaces_python_modules`.

    """

    if not compat.callable(callable_):
        raise exceptions.RuntimeException(
                        "capture() function expects a callable as "
                        "its argument (i.e. capture(func, *args, **kwargs))"
                        )
    context._push_buffer()
    try:
        callable_(*args, **kwargs)
    finally:
        buf = context._pop_buffer()
    return buf.getvalue() 
Example #2
Source File: runtime.py    From teleport with Apache License 2.0 6 votes vote down vote up
def capture(context, callable_, *args, **kwargs):
    """Execute the given template def, capturing the output into
    a buffer.

    See the example in :ref:`namespaces_python_modules`.

    """

    if not callable(callable_):
        raise exceptions.RuntimeException(
            "capture() function expects a callable as "
            "its argument (i.e. capture(func, *args, **kwargs))"
        )
    context._push_buffer()
    try:
        callable_(*args, **kwargs)
    finally:
        buf = context._pop_buffer()
    return buf.getvalue() 
Example #3
Source File: runtime.py    From Tautulli with GNU General Public License v3.0 6 votes vote down vote up
def capture(context, callable_, *args, **kwargs):
    """Execute the given template def, capturing the output into
    a buffer.

    See the example in :ref:`namespaces_python_modules`.

    """

    if not callable(callable_):
        raise exceptions.RuntimeException(
            "capture() function expects a callable as "
            "its argument (i.e. capture(func, *args, **kwargs))"
        )
    context._push_buffer()
    try:
        callable_(*args, **kwargs)
    finally:
        buf = context._pop_buffer()
    return buf.getvalue() 
Example #4
Source File: runtime.py    From teleport with Apache License 2.0 6 votes vote down vote up
def capture(context, callable_, *args, **kwargs):
    """Execute the given template def, capturing the output into
    a buffer.

    See the example in :ref:`namespaces_python_modules`.

    """

    if not compat.callable(callable_):
        raise exceptions.RuntimeException(
            "capture() function expects a callable as "
            "its argument (i.e. capture(func, *args, **kwargs))"
        )
    context._push_buffer()
    try:
        callable_(*args, **kwargs)
    finally:
        buf = context._pop_buffer()
    return buf.getvalue() 
Example #5
Source File: runtime.py    From teleport with Apache License 2.0 6 votes vote down vote up
def capture(context, callable_, *args, **kwargs):
    """Execute the given template def, capturing the output into
    a buffer.

    See the example in :ref:`namespaces_python_modules`.

    """

    if not callable(callable_):
        raise exceptions.RuntimeException(
            "capture() function expects a callable as "
            "its argument (i.e. capture(func, *args, **kwargs))"
        )
    context._push_buffer()
    try:
        callable_(*args, **kwargs)
    finally:
        buf = context._pop_buffer()
    return buf.getvalue() 
Example #6
Source File: runtime.py    From jbox with MIT License 6 votes vote down vote up
def capture(context, callable_, *args, **kwargs):
    """Execute the given template def, capturing the output into
    a buffer.

    See the example in :ref:`namespaces_python_modules`.

    """

    if not compat.callable(callable_):
        raise exceptions.RuntimeException(
            "capture() function expects a callable as "
            "its argument (i.e. capture(func, *args, **kwargs))"
        )
    context._push_buffer()
    try:
        callable_(*args, **kwargs)
    finally:
        buf = context._pop_buffer()
    return buf.getvalue() 
Example #7
Source File: runtime.py    From SA-ctf_scoreboard with Creative Commons Zero v1.0 Universal 6 votes vote down vote up
def capture(context, callable_, *args, **kwargs):
    """Execute the given template def, capturing the output into
    a buffer.

    See the example in :ref:`namespaces_python_modules`.

    """

    if not compat.callable(callable_):
        raise exceptions.RuntimeException(
            "capture() function expects a callable as "
            "its argument (i.e. capture(func, *args, **kwargs))"
        )
    context._push_buffer()
    try:
        callable_(*args, **kwargs)
    finally:
        buf = context._pop_buffer()
    return buf.getvalue() 
Example #8
Source File: runtime.py    From mako with MIT License 6 votes vote down vote up
def capture(context, callable_, *args, **kwargs):
    """Execute the given template def, capturing the output into
    a buffer.

    See the example in :ref:`namespaces_python_modules`.

    """

    if not callable(callable_):
        raise exceptions.RuntimeException(
            "capture() function expects a callable as "
            "its argument (i.e. capture(func, *args, **kwargs))"
        )
    context._push_buffer()
    try:
        callable_(*args, **kwargs)
    finally:
        buf = context._pop_buffer()
    return buf.getvalue() 
Example #9
Source File: runtime.py    From misp42splunk with GNU Lesser General Public License v3.0 6 votes vote down vote up
def capture(context, callable_, *args, **kwargs):
    """Execute the given template def, capturing the output into
    a buffer.

    See the example in :ref:`namespaces_python_modules`.

    """

    if not callable(callable_):
        raise exceptions.RuntimeException(
            "capture() function expects a callable as "
            "its argument (i.e. capture(func, *args, **kwargs))"
        )
    context._push_buffer()
    try:
        callable_(*args, **kwargs)
    finally:
        buf = context._pop_buffer()
    return buf.getvalue() 
Example #10
Source File: runtime.py    From android_universal with MIT License 6 votes vote down vote up
def capture(context, callable_, *args, **kwargs):
    """Execute the given template def, capturing the output into
    a buffer.

    See the example in :ref:`namespaces_python_modules`.

    """

    if not compat.callable(callable_):
        raise exceptions.RuntimeException(
            "capture() function expects a callable as "
            "its argument (i.e. capture(func, *args, **kwargs))"
        )
    context._push_buffer()
    try:
        callable_(*args, **kwargs)
    finally:
        buf = context._pop_buffer()
    return buf.getvalue() 
Example #11
Source File: runtime.py    From misp42splunk with GNU Lesser General Public License v3.0 6 votes vote down vote up
def capture(context, callable_, *args, **kwargs):
    """Execute the given template def, capturing the output into
    a buffer.

    See the example in :ref:`namespaces_python_modules`.

    """

    if not callable(callable_):
        raise exceptions.RuntimeException(
            "capture() function expects a callable as "
            "its argument (i.e. capture(func, *args, **kwargs))"
        )
    context._push_buffer()
    try:
        callable_(*args, **kwargs)
    finally:
        buf = context._pop_buffer()
    return buf.getvalue() 
Example #12
Source File: util.py    From SA-ctf_scoreboard with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
def load(self, name):
        if name in self.impls:
            return self.impls[name]()
        else:
            import pkg_resources
            for impl in pkg_resources.iter_entry_points(
                    self.group,
                    name):
                self.impls[name] = impl.load
                return impl.load()
            else:
                from mako import exceptions
                raise exceptions.RuntimeException(
                    "Can't load plugin %s %s" %
                    (self.group, name)) 
Example #13
Source File: beaker_cache.py    From SA-ctf_scoreboard with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
def __init__(self, cache):
        if not has_beaker:
            raise exceptions.RuntimeException(
                "Can't initialize Beaker plugin; Beaker is not installed.")
        global _beaker_cache
        if _beaker_cache is None:
            if 'manager' in cache.template.cache_args:
                _beaker_cache = cache.template.cache_args['manager']
            else:
                _beaker_cache = beaker_cache.CacheManager()
        super(BeakerCacheImpl, self).__init__(cache) 
Example #14
Source File: runtime.py    From SA-ctf_scoreboard with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
def __getattr__(self, key):
        raise exceptions.RuntimeException("No loop context is established") 
Example #15
Source File: test_util.py    From docassemble with MIT License 5 votes vote down vote up
def test_load_plugin_failure(self):
        loader = util.PluginLoader("fakegroup")
        assert_raises_message(
            exceptions.RuntimeException,
            "Can't load plugin fakegroup fake",
            loader.load, "fake"
        ) 
Example #16
Source File: test_loop.py    From docassemble with MIT License 5 votes vote down vote up
def test_out_of_context_access(self):
        template = Template("""${loop.index}""")
        assert_raises_message(
            exceptions.RuntimeException,
            "No loop context is established",
            template.render
        ) 
Example #17
Source File: runtime.py    From mako with MIT License 5 votes vote down vote up
def __getattr__(self, key):
        raise exceptions.RuntimeException("No loop context is established") 
Example #18
Source File: util.py    From Tautulli with GNU General Public License v3.0 5 votes vote down vote up
def load(self, name):
        if name in self.impls:
            return self.impls[name]()
        else:
            import pkg_resources

            for impl in pkg_resources.iter_entry_points(self.group, name):
                self.impls[name] = impl.load
                return impl.load()
            else:
                from mako import exceptions

                raise exceptions.RuntimeException(
                    "Can't load plugin %s %s" % (self.group, name)
                ) 
Example #19
Source File: runtime.py    From Tautulli with GNU General Public License v3.0 5 votes vote down vote up
def __getattr__(self, key):
        raise exceptions.RuntimeException("No loop context is established") 
Example #20
Source File: beaker_cache.py    From Tautulli with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, cache):
        if not has_beaker:
            raise exceptions.RuntimeException(
                "Can't initialize Beaker plugin; Beaker is not installed."
            )
        global _beaker_cache
        if _beaker_cache is None:
            if "manager" in cache.template.cache_args:
                _beaker_cache = cache.template.cache_args["manager"]
            else:
                _beaker_cache = beaker_cache.CacheManager()
        super(BeakerCacheImpl, self).__init__(cache) 
Example #21
Source File: util.py    From ansible-cmdb with GNU General Public License v3.0 5 votes vote down vote up
def load(self, name):
        if name in self.impls:
            return self.impls[name]()
        else:
            import pkg_resources
            for impl in pkg_resources.iter_entry_points(
                                self.group,
                                name):
                self.impls[name] = impl.load
                return impl.load()
            else:
                from mako import exceptions
                raise exceptions.RuntimeException(
                        "Can't load plugin %s %s" %
                        (self.group, name)) 
Example #22
Source File: runtime.py    From ansible-cmdb with GNU General Public License v3.0 5 votes vote down vote up
def __getattr__(self, key):
        raise exceptions.RuntimeException("No loop context is established") 
Example #23
Source File: beaker_cache.py    From ansible-cmdb with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, cache):
        if not has_beaker:
            raise exceptions.RuntimeException(
                "Can't initialize Beaker plugin; Beaker is not installed.")
        global _beaker_cache
        if _beaker_cache is None:
            if 'manager' in cache.template.cache_args:
                _beaker_cache = cache.template.cache_args['manager']
            else:
                _beaker_cache = beaker_cache.CacheManager()
        super(BeakerCacheImpl, self).__init__(cache) 
Example #24
Source File: util.py    From android_universal with MIT License 5 votes vote down vote up
def load(self, name):
        if name in self.impls:
            return self.impls[name]()
        else:
            import pkg_resources
            for impl in pkg_resources.iter_entry_points(
                    self.group,
                    name):
                self.impls[name] = impl.load
                return impl.load()
            else:
                from mako import exceptions
                raise exceptions.RuntimeException(
                    "Can't load plugin %s %s" %
                    (self.group, name)) 
Example #25
Source File: runtime.py    From android_universal with MIT License 5 votes vote down vote up
def __getattr__(self, key):
        raise exceptions.RuntimeException("No loop context is established") 
Example #26
Source File: beaker_cache.py    From android_universal with MIT License 5 votes vote down vote up
def __init__(self, cache):
        if not has_beaker:
            raise exceptions.RuntimeException(
                "Can't initialize Beaker plugin; Beaker is not installed.")
        global _beaker_cache
        if _beaker_cache is None:
            if 'manager' in cache.template.cache_args:
                _beaker_cache = cache.template.cache_args['manager']
            else:
                _beaker_cache = beaker_cache.CacheManager()
        super(BeakerCacheImpl, self).__init__(cache) 
Example #27
Source File: runtime.py    From teleport with Apache License 2.0 5 votes vote down vote up
def __getattr__(self, key):
        raise exceptions.RuntimeException("No loop context is established") 
Example #28
Source File: runtime.py    From misp42splunk with GNU Lesser General Public License v3.0 5 votes vote down vote up
def __getattr__(self, key):
        raise exceptions.RuntimeException("No loop context is established") 
Example #29
Source File: beaker_cache.py    From misp42splunk with GNU Lesser General Public License v3.0 5 votes vote down vote up
def __init__(self, cache):
        if not has_beaker:
            raise exceptions.RuntimeException(
                "Can't initialize Beaker plugin; Beaker is not installed."
            )
        global _beaker_cache
        if _beaker_cache is None:
            if "manager" in cache.template.cache_args:
                _beaker_cache = cache.template.cache_args["manager"]
            else:
                _beaker_cache = beaker_cache.CacheManager()
        super(BeakerCacheImpl, self).__init__(cache) 
Example #30
Source File: util.py    From misp42splunk with GNU Lesser General Public License v3.0 5 votes vote down vote up
def load(self, name):
        if name in self.impls:
            return self.impls[name]()
        else:
            import pkg_resources

            for impl in pkg_resources.iter_entry_points(self.group, name):
                self.impls[name] = impl.load
                return impl.load()
            else:
                from mako import exceptions

                raise exceptions.RuntimeException(
                    "Can't load plugin %s %s" % (self.group, name)
                )