# Path: ronin/utils/strings.py
# def stringify(value):
#     """
#     Casts the value to a Unicode string. If the value is a function, calls it using
#     :func:`ronin.contexts.current_context` as its only argument, and recurses until a
#     non-FunctionType value is returned.
#     
#     None values are preserved, whether None is directly sent to this function or is the return
#     value of function argument.
#     
#     This function is the heart of Rōnin's deferred value capability, as it allows lambdas to be
#     passed around instead of strings.
#     
#     :param value: value or None
#     :type value: str|FunctionType
#     :returns: stringified value or None
#     :rtype: str
#     """
#     
#     if value is None:
#         return None
#     elif hasattr(value, '__call__'):
#         with current_context() as ctx:
#             value = value(ctx)
#         return stringify(value)
#     else:
#         try:
#             return to_str(value)
#         except UnicodeDecodeError:
#             return str(value).decode(_ENCODING)
# 
# Path: ronin/contexts.py
# def current_context(immutable=True):
#     """
#     Returns the current context if there is one, otherwise raises :class:`NoContextException`.
#     
#     By default, the context will be treated as immutable.
#     
#     :param immutable: set to False in order to allow changes to the context
#     :type immutable: bool
#     :returns: current context
#     :rtype: :class:`Context`
#     """
# 
#     ctx = Context._peek_thread_local()
#     if ctx is None:
#         raise NoContextException()
#     return Context(ctx, True) if immutable else ctx


from .strings import stringify
from ..contexts import current_context
from subprocess import check_output, CalledProcessError
import sys, platform
    :returns: bits
    :rtype: integer
    """

    # Note: platform.architecture() extracts the bits from the Python executable,
    # which is not we want here (we might be running 32bit Python on a 64bit OS)
    machine = platform.machine() # i386, x86_64, AMD64
    return 64 if machine.endswith('64') else 32


def which(command, exception=True):
    """
    Finds the absolute path to a command on this host machine.
    
    Works by invoking the operating system's ``which`` command, which configured via the context's
    ``platform.which_command``. See also :func:`configure_which`.

    :param command: command
    :type command: str|FunctionType
    :param exception: set to False in order to return None upon failure, instead of raising an
     exception
    :type exception: bool
    :returns: absolute path to command
    :rtype: str
    :raises ~ronin.utils.platform.WhichException: if ``exception`` is True and could not find
     command
    """

    command = stringify(command)
    try:

# Path: ronin/utils/strings.py
# def stringify(value):
#     """
#     Casts the value to a Unicode string. If the value is a function, calls it using
#     :func:`ronin.contexts.current_context` as its only argument, and recurses until a
#     non-FunctionType value is returned.
#     
#     None values are preserved, whether None is directly sent to this function or is the return
#     value of function argument.
#     
#     This function is the heart of Rōnin's deferred value capability, as it allows lambdas to be
#     passed around instead of strings.
#     
#     :param value: value or None
#     :type value: str|FunctionType
#     :returns: stringified value or None
#     :rtype: str
#     """
#     
#     if value is None:
#         return None
#     elif hasattr(value, '__call__'):
#         with current_context() as ctx:
#             value = value(ctx)
#         return stringify(value)
#     else:
#         try:
#             return to_str(value)
#         except UnicodeDecodeError:
#             return str(value).decode(_ENCODING)
# 
# Path: ronin/contexts.py
# def current_context(immutable=True):
#     """
#     Returns the current context if there is one, otherwise raises :class:`NoContextException`.
#     
#     By default, the context will be treated as immutable.
#     
#     :param immutable: set to False in order to allow changes to the context
#     :type immutable: bool
#     :returns: current context
#     :rtype: :class:`Context`
#     """
# 
#     ctx = Context._peek_thread_local()
#     if ctx is None:
#         raise NoContextException()
#     return Context(ctx, True) if immutable else ctx


# Path: ronin/utils/platform.py
from .strings import stringify
from ..contexts import current_context
from subprocess import check_output, CalledProcessError
import sys, platform

    :returns: bits
    :rtype: integer
    """

    # Note: platform.architecture() extracts the bits from the Python executable,
    # which is not we want here (we might be running 32bit Python on a 64bit OS)
    machine = platform.machine() # i386, x86_64, AMD64
    return 64 if machine.endswith('64') else 32


def which(command, exception=True):
    """
    Finds the absolute path to a command on this host machine.
    
    Works by invoking the operating system's ``which`` command, which configured via the context's
    ``platform.which_command``. See also :func:`configure_which`.

    :param command: command
    :type command: str|FunctionType
    :param exception: set to False in order to return None upon failure, instead of raising an
     exception
    :type exception: bool
    :returns: absolute path to command
    :rtype: str
    :raises ~ronin.utils.platform.WhichException: if ``exception`` is True and could not find
     command
    """

    command = stringify(command)
    try:

        with current_context() as ctx: