# Path: problemtools/run/executable.py
# class Executable(Program):
#     """Class for executable files.
#     """
#     def __init__(self, path, args=None):
#         """Instantiate executable object.
# 
#         Args:
#             path (str): path to the executable file.  Must be a file,
#                 and must be executable.
#             args: list of additional command line arguments that
#                 should be passed to the program every time it is executed.
#         """
#         if not os.path.isfile(path) or not os.access(path, os.X_OK):
#             raise ProgramError('%s is not an executable program' % path)
#         self.path = path
#         self.args = args if args is not None else []
# 
#     def __str__(self):
#         """String representation"""
#         return '%s' % (self.path)
# 
#     def compile(self):
#         """Dummy implementation of the compile method -- nothing to check!
#         """
#         return (True, None)
# 
#     def get_runcmd(self, cwd=None, memlim=None):
#         """Command to run the program.
#         """
#         return [self.path] + self.args
# 
#     def should_skip_memory_rlimit(self):
#         """Ugly hack (see program.py for details)."""
#         return True
# 
# Path: problemtools/run/errors.py
# class ProgramError(Exception):
#     """Base exception class for errors within the run package.
#     """
#     pass
# 
# Path: problemtools/run/tools.py
# def get_tool_path(name):
#     """Find the path to one of problemtools' external tools.
# 
#     Args:
#         name (str): which tool is wanted (one of [default_grader,
#             default_validator, interactive, checktestdata, viva.sh])
# 
#     Returns:
#         str, path to the tool, or None if the tool was not found.
#     """
#     return __locate_executable([os.path.join(os.path.dirname(__file__),
#                                              '..', 'support', name),
#                                 os.path.join(os.path.dirname(__file__),
#                                              '..', '..', 'support',
#                                              os.path.splitext(name)[0], name)])


import os
from .executable import Executable
from .errors import ProgramError
from .tools import get_tool_path
"""This module handles execution of scripts in the VIVA input
verification language (http://viva.vanb.org/).
"""



class Viva(Executable):
    """Wrapper class for running VIVA scripts.
    """
    _VIVA_PATH = get_tool_path('viva.sh')

    def __init__(self, path):
        """Create a VIVA wrapper.

        Args:
            path (str): path to .viva source file
        """
        if Viva._VIVA_PATH is None:

# Path: problemtools/run/executable.py
# class Executable(Program):
#     """Class for executable files.
#     """
#     def __init__(self, path, args=None):
#         """Instantiate executable object.
# 
#         Args:
#             path (str): path to the executable file.  Must be a file,
#                 and must be executable.
#             args: list of additional command line arguments that
#                 should be passed to the program every time it is executed.
#         """
#         if not os.path.isfile(path) or not os.access(path, os.X_OK):
#             raise ProgramError('%s is not an executable program' % path)
#         self.path = path
#         self.args = args if args is not None else []
# 
#     def __str__(self):
#         """String representation"""
#         return '%s' % (self.path)
# 
#     def compile(self):
#         """Dummy implementation of the compile method -- nothing to check!
#         """
#         return (True, None)
# 
#     def get_runcmd(self, cwd=None, memlim=None):
#         """Command to run the program.
#         """
#         return [self.path] + self.args
# 
#     def should_skip_memory_rlimit(self):
#         """Ugly hack (see program.py for details)."""
#         return True
# 
# Path: problemtools/run/errors.py
# class ProgramError(Exception):
#     """Base exception class for errors within the run package.
#     """
#     pass
# 
# Path: problemtools/run/tools.py
# def get_tool_path(name):
#     """Find the path to one of problemtools' external tools.
# 
#     Args:
#         name (str): which tool is wanted (one of [default_grader,
#             default_validator, interactive, checktestdata, viva.sh])
# 
#     Returns:
#         str, path to the tool, or None if the tool was not found.
#     """
#     return __locate_executable([os.path.join(os.path.dirname(__file__),
#                                              '..', 'support', name),
#                                 os.path.join(os.path.dirname(__file__),
#                                              '..', '..', 'support',
#                                              os.path.splitext(name)[0], name)])


# Path: problemtools/run/viva.py
import os
from .executable import Executable
from .errors import ProgramError
from .tools import get_tool_path

"""This module handles execution of scripts in the VIVA input
verification language (http://viva.vanb.org/).
"""



class Viva(Executable):
    """Wrapper class for running VIVA scripts.
    """
    _VIVA_PATH = get_tool_path('viva.sh')

    def __init__(self, path):
        """Create a VIVA wrapper.

        Args:
            path (str): path to .viva source file
        """
        if Viva._VIVA_PATH is None:

            raise ProgramError(