# Path: skema/api.py
# class SkemaSuiteIf(object):
#     """
#     Skema test suite.
# 
#     Abstract class for skema test suite classes.
#     """
# 
#     @abstractmethod
#     def install(self):
#         """
#         Install the test suite.
# 
#         This creates an install directory under the user's XDG_DATA_HOME
#         directory to mark that the suite is installed.  The installer's
#         install() method is then called from this directory to complete any
#         test specific install that may be needed.
#         """
# 
#     @abstractmethod
#     def uninstall(self):
#         """
#         Uninstall the test suite.
# 
#         Uninstalling just recursively removes the test specific directory under
#         the user's XDG_DATA_HOME directory.  This will both mark the suite as
#         removed, and clean up any files that were installed under that
#         directory.  Dependencies are intentionally not removed by this.
#         """
# 
#     @abstractmethod
#     def run(self, quiet=False, output=None):
#         # TODO: Document me
#         pass
# 
#     @abstractmethod
#     def parse(self, resultname):
#         # TODO: Document me
#         pass
# 
# Path: skema/config.py
# def get_config():
#     global _config
#     if _config is not None:
#         return _config
#     _config = SkemaConfig()
#     return _config
# 
# Path: skema/suiteutils.py
# def run_suite(scriptpath):
# 
#     tree = et()
#     tree.parse(scriptpath)
#     titer = tree.iter()
# 
#     config = get_config()
# 
#     suites = []
#     cases = []
#     errors = dict()
#     last_tag = dict()
#     case = ""
#     for elem in titer:
# 
#         if elem.tag == "Suite":
#             continue
# 
#         if elem.tag == "Case":
#             case  = elem.get('name')
#             log_line ("Use Case : '%s'"  % case)
#             cases.append(case)
#             errors[case] = 0
#             result = 0
#             continue
# 
#         if result == 0:
#             tag_func = get_tag(elem.tag)
#             if not tag_func:
#                 log_line ("Tag '%s' not found. Exiting."  % elem.tag)
#                 sys.exit(1)
# 
#             result = tag_func.run(elem, config)
#             if result != 0:
#                 log_result (elem.tag, get_string_from_il_enum(result, "OMX_Error"))
#                 errors[case] = result
#             last_tag[case] = elem.tag
# 
#     if result != 0:
#         config.base_profile_mgr.stop()
# 
#     log_line()
#     log_line()
#     log_line("-------------------------------------------------------------------")
#     msg = "SUITE EXECUTION SUMMARY : " + str(len(cases)) + " test cases executed"
#     log_result (msg, get_string_from_il_enum(result, "OMX_Error"))
#     last_error = 0
#     for case in cases:
#         msg = "CASE : " + case + " (last tag was '" + last_tag[case] + "')"
#         log_result (msg, get_string_from_il_enum(errors[case], "OMX_Error"))
#         if errors[case] != 0:
#             last_error = errors[case]
#     log_line()
#     log_line("-------------------------------------------------------------------")
#     log_line()
# 
#     return last_error
# 
# Path: skema/utils.py
# def log_line(line="", tabs=0):
#     if (line == ""):
#         lansi = "[skema] "
#         l = ""
#     else:
#         l = ('\t' * tabs) + "[" + line + "]"
#         lansi = "[skema] " + bcolors.WARNING + l + bcolors.ENDC
#     logging.info(l)
#     printit (lansi)
# 
# Path: skema/utils.py
# def log_result(tag, err):
#     log_line ()
#     if (err == "OMX_ErrorNone"):
#         l = "[" + tag + " -> '" + err + "']"
#         lansi = "[skema] " + bcolors.OKGREEN + l + bcolors.ENDC
#         logging.info(l)
#     else:
#         l = "[" + tag + " -> '" + err + "']"
#         lansi = "[skema] " + bcolors.FAIL + l + bcolors.ENDC
#         logging.error(l)
# 
#     printit (lansi)
# 
# Path: skema/omxil12.py
# def get_string_from_il_enum(enum, hint):
#     from skema import omxil12
#     for name, val in omxil12.__dict__.iteritems():
#         if enum == val:
#             if name.startswith(hint):
#                 return name
#     raise AttributeError


import os
import glob
import re
import shutil
import time
import logging
from commands import getstatusoutput
from datetime import datetime
from uuid import uuid1
from skema.api import SkemaSuiteIf
from skema.config import get_config
from skema.suiteutils import run_suite
from skema.utils import log_line
from skema.utils import log_result
from skema.omxil12 import get_string_from_il_enum
        rc, output = getstatusoutput(cmd)
        if rc:
            raise RuntimeError("Dependency installation failed. %d : %s" %(rc,output))

    def install(self):
        self._installscript()

class SkemaSuiteRunner(object):
    """Base class for defining an test runner object.

    This class can be used as-is for simple execution with the expectation
    that the run() method will be called from the directory where the test
    was installed.  Steps, if used, should handle changing directories from
    there to the directory where the test was extracted if necessary.
    This class can also be extended for more advanced funcionality.

    """
    def __init__(self):
        self.testoutput = []

    def _runsteps(self, scriptpath, resultsdir, quiet=False):
        outputlog = os.path.join(resultsdir, 'outputlog.txt')
        outputlog2 = os.path.join(resultsdir, 'outputlog2.txt')
        logging.basicConfig (filename=outputlog2, filemode='w', \
                                 format='%(asctime)s - %(levelname)s : %(message)s', \
                                 level=logging.DEBUG)
        logging.info("log")

        result = 0
        with open(outputlog, 'a') as fd:

# Path: skema/api.py
# class SkemaSuiteIf(object):
#     """
#     Skema test suite.
# 
#     Abstract class for skema test suite classes.
#     """
# 
#     @abstractmethod
#     def install(self):
#         """
#         Install the test suite.
# 
#         This creates an install directory under the user's XDG_DATA_HOME
#         directory to mark that the suite is installed.  The installer's
#         install() method is then called from this directory to complete any
#         test specific install that may be needed.
#         """
# 
#     @abstractmethod
#     def uninstall(self):
#         """
#         Uninstall the test suite.
# 
#         Uninstalling just recursively removes the test specific directory under
#         the user's XDG_DATA_HOME directory.  This will both mark the suite as
#         removed, and clean up any files that were installed under that
#         directory.  Dependencies are intentionally not removed by this.
#         """
# 
#     @abstractmethod
#     def run(self, quiet=False, output=None):
#         # TODO: Document me
#         pass
# 
#     @abstractmethod
#     def parse(self, resultname):
#         # TODO: Document me
#         pass
# 
# Path: skema/config.py
# def get_config():
#     global _config
#     if _config is not None:
#         return _config
#     _config = SkemaConfig()
#     return _config
# 
# Path: skema/suiteutils.py
# def run_suite(scriptpath):
# 
#     tree = et()
#     tree.parse(scriptpath)
#     titer = tree.iter()
# 
#     config = get_config()
# 
#     suites = []
#     cases = []
#     errors = dict()
#     last_tag = dict()
#     case = ""
#     for elem in titer:
# 
#         if elem.tag == "Suite":
#             continue
# 
#         if elem.tag == "Case":
#             case  = elem.get('name')
#             log_line ("Use Case : '%s'"  % case)
#             cases.append(case)
#             errors[case] = 0
#             result = 0
#             continue
# 
#         if result == 0:
#             tag_func = get_tag(elem.tag)
#             if not tag_func:
#                 log_line ("Tag '%s' not found. Exiting."  % elem.tag)
#                 sys.exit(1)
# 
#             result = tag_func.run(elem, config)
#             if result != 0:
#                 log_result (elem.tag, get_string_from_il_enum(result, "OMX_Error"))
#                 errors[case] = result
#             last_tag[case] = elem.tag
# 
#     if result != 0:
#         config.base_profile_mgr.stop()
# 
#     log_line()
#     log_line()
#     log_line("-------------------------------------------------------------------")
#     msg = "SUITE EXECUTION SUMMARY : " + str(len(cases)) + " test cases executed"
#     log_result (msg, get_string_from_il_enum(result, "OMX_Error"))
#     last_error = 0
#     for case in cases:
#         msg = "CASE : " + case + " (last tag was '" + last_tag[case] + "')"
#         log_result (msg, get_string_from_il_enum(errors[case], "OMX_Error"))
#         if errors[case] != 0:
#             last_error = errors[case]
#     log_line()
#     log_line("-------------------------------------------------------------------")
#     log_line()
# 
#     return last_error
# 
# Path: skema/utils.py
# def log_line(line="", tabs=0):
#     if (line == ""):
#         lansi = "[skema] "
#         l = ""
#     else:
#         l = ('\t' * tabs) + "[" + line + "]"
#         lansi = "[skema] " + bcolors.WARNING + l + bcolors.ENDC
#     logging.info(l)
#     printit (lansi)
# 
# Path: skema/utils.py
# def log_result(tag, err):
#     log_line ()
#     if (err == "OMX_ErrorNone"):
#         l = "[" + tag + " -> '" + err + "']"
#         lansi = "[skema] " + bcolors.OKGREEN + l + bcolors.ENDC
#         logging.info(l)
#     else:
#         l = "[" + tag + " -> '" + err + "']"
#         lansi = "[skema] " + bcolors.FAIL + l + bcolors.ENDC
#         logging.error(l)
# 
#     printit (lansi)
# 
# Path: skema/omxil12.py
# def get_string_from_il_enum(enum, hint):
#     from skema import omxil12
#     for name, val in omxil12.__dict__.iteritems():
#         if enum == val:
#             if name.startswith(hint):
#                 return name
#     raise AttributeError


# Path: skema/suite.py
import os
import glob
import re
import shutil
import time
import logging
from commands import getstatusoutput
from datetime import datetime
from uuid import uuid1
from skema.api import SkemaSuiteIf
from skema.config import get_config
from skema.suiteutils import run_suite
from skema.utils import log_line
from skema.utils import log_result
from skema.omxil12 import get_string_from_il_enum

        rc, output = getstatusoutput(cmd)
        if rc:
            raise RuntimeError("Dependency installation failed. %d : %s" %(rc,output))

    def install(self):
        self._installscript()

class SkemaSuiteRunner(object):
    """Base class for defining an test runner object.

    This class can be used as-is for simple execution with the expectation
    that the run() method will be called from the directory where the test
    was installed.  Steps, if used, should handle changing directories from
    there to the directory where the test was extracted if necessary.
    This class can also be extended for more advanced funcionality.

    """
    def __init__(self):
        self.testoutput = []

    def _runsteps(self, scriptpath, resultsdir, quiet=False):
        outputlog = os.path.join(resultsdir, 'outputlog.txt')
        outputlog2 = os.path.join(resultsdir, 'outputlog2.txt')
        logging.basicConfig (filename=outputlog2, filemode='w', \
                                 format='%(asctime)s - %(levelname)s : %(message)s', \
                                 level=logging.DEBUG)
        logging.info("log")

        result = 0
        with open(outputlog, 'a') as fd:

            config = get_config()