# Path: rock/constants.py
# MOUNT_PATH = os.environ.get('ROCK_MOUNT_PATH', '/')
# RUNTIMES = ['node', 'perl', 'php', 'python', 'ruby']
# SHELL = (os.environ.get('ROCK_SHELL') or '/bin/bash -c').split()
# 
# Path: rock/exceptions.py
# class ConfigError(Error):
#     pass


import os
    from io import StringIO
    from StringIO import StringIO
from rock import constants
from rock.exceptions import ConfigError


try:
    basestring

    def isstr(s):
        return isinstance(s, basestring)
except NameError:  # pragma: no cover
    def isstr(s):
        return isinstance(s, str)


def raw(text):
    return text.replace('\\', '\\\\')


class Shell(object):

    def __init__(self):
        self.stdin = StringIO()

    def __enter__(self):
        return self

    def __exit__(self, type, value, traceback):
        self.run()

    def run(self):
        if not isexecutable(constants.SHELL[0]):
            raise ConfigError('invalid ROCK_SHELL: %s' % constants.SHELL)

# Path: rock/constants.py
# MOUNT_PATH = os.environ.get('ROCK_MOUNT_PATH', '/')
# RUNTIMES = ['node', 'perl', 'php', 'python', 'ruby']
# SHELL = (os.environ.get('ROCK_SHELL') or '/bin/bash -c').split()
# 
# Path: rock/exceptions.py
# class ConfigError(Error):
#     pass


# Path: rock/utils.py
import os
    from io import StringIO
    from StringIO import StringIO
from rock import constants
from rock.exceptions import ConfigError



try:
    basestring

    def isstr(s):
        return isinstance(s, basestring)
except NameError:  # pragma: no cover
    def isstr(s):
        return isinstance(s, str)


def raw(text):
    return text.replace('\\', '\\\\')


class Shell(object):

    def __init__(self):
        self.stdin = StringIO()

    def __enter__(self):
        return self

    def __exit__(self, type, value, traceback):
        self.run()

    def run(self):
        if not isexecutable(constants.SHELL[0]):
            raise ConfigError('invalid ROCK_SHELL: %s' % constants.SHELL)

        os.execl(*(constants.SHELL + [self.stdin.getvalue()]))