# Path: sprinter/core/templates.py



import logging
import os
import shutil
import stat
import tempfile
from .templates import source_template
    def __remove_path(self, path):
        """ Remove an object """
        curpath = os.path.abspath(os.curdir)
        if not os.path.exists(path):
            logger.warn("Attempted to remove a non-existent path %s" % path)
            return
        try:
            if os.path.islink(path):
                os.unlink(path)
            elif os.path.isdir(path):
                shutil.rmtree(path)
            else:
                os.unlink(path)

            # in the case we just deleted ourselves out of a valid directory,
            # we move to a valid directory.
            if curpath == path:
                os.chdir(tempfile.gettempdir())

        except OSError:
            logger.error("Unable to remove object at path %s" % path)
            raise DirectoryException("Unable to remove object at path %s" % path)

    def __get_env_handle(self, root_dir):
        """ get the filepath and filehandle to the .env file for the environment """
        env_path = os.path.join(root_dir, '.env')
        gui_path = os.path.join(root_dir, '.gui')
        fh = open(env_path, "w+")
        # .env will source utils.sh if it hasn't already
        fh.write(source_template % (gui_path, gui_path))

# Path: sprinter/core/templates.py



# Path: sprinter/core/directory.py
import logging
import os
import shutil
import stat
import tempfile
from .templates import source_template

    def __remove_path(self, path):
        """ Remove an object """
        curpath = os.path.abspath(os.curdir)
        if not os.path.exists(path):
            logger.warn("Attempted to remove a non-existent path %s" % path)
            return
        try:
            if os.path.islink(path):
                os.unlink(path)
            elif os.path.isdir(path):
                shutil.rmtree(path)
            else:
                os.unlink(path)

            # in the case we just deleted ourselves out of a valid directory,
            # we move to a valid directory.
            if curpath == path:
                os.chdir(tempfile.gettempdir())

        except OSError:
            logger.error("Unable to remove object at path %s" % path)
            raise DirectoryException("Unable to remove object at path %s" % path)

    def __get_env_handle(self, root_dir):
        """ get the filepath and filehandle to the .env file for the environment """
        env_path = os.path.join(root_dir, '.env')
        gui_path = os.path.join(root_dir, '.gui')
        fh = open(env_path, "w+")
        # .env will source utils.sh if it hasn't already
        fh.write(source_template % (gui_path, gui_path))

        fh.write(source_template % (self.shell_util_path,