Пример #1
0
    def load(self):

        # Msg.dbg( "ForrestRun::load" )

        my_frun_path = self.option_def(CmdLine.Switches[CmdLine.control_name],
                                       None)
        if my_frun_path is None:
            raise Exception(
                "F-Run Control File Not Found on the Forrest Run Command Line: Given Path: %s",
                str((my_frun_path)))

        # good to here
        self.locate_frun(my_frun_path)

        Msg.user("File Path: %s" % (my_frun_path))

        my_content = open(self.frun_name).read()
        my_glb, my_loc = SysUtils.exec_content(my_content)
        Msg.dbg(str(my_loc))

        self.fcontrol = my_loc["control_items"]

        my_ctrl_dict = self.fcontrol[0]

        my_ctrl_item = ControlItem()
        my_ctrl_item.load(self._mAppsInfo, my_ctrl_dict)

        # Msg.lout( my_ctrl_dict, "user", "Forrest Parent Data ...." )

        self.check_simulator()

        self.fctrl = ExecuteController(self._mAppsInfo)
        self.fctrl.set_frun(self.frun_name)
        self.fctrl.load(my_ctrl_item)
Пример #2
0
class ForrestRun(object):
    def __init__(self, aAppsInfo):
        self.module_dir, self.module_name = PathUtils.split_path(
            PathUtils.real_path(sys.argv[0]))
        self._mAppsInfo = aAppsInfo
        self.load_message_levels(CmdLine.Switches[CmdLine.msg_lev],
                                 Defaults.msg_level)

        self.frun_name = None
        self.frun_dir = None

        self.item_data = {}
        self.options = {}

    def load_message_levels(self, arg_msg_lev, arg_def_lev):
        # load from the command line if specified or use the default
        my_lev_str = self.option_def(arg_msg_lev, arg_def_lev)
        #my_def = "crit+err+warn+info+noinfo"

        #my_lev_str = self.option_def( "all", my_def, "-l"  )

        # if a (+) or a (-) is found then the command line will be appended to or demoted by
        if (my_lev_str[0] == '+') or (my_lev_str[0] == '-'):
            # use the default string to build a format string, then append the passed in value
            my_fmt_str = "%s%s%s" % (arg_def_lev, "\%", "s")
            my_lev_str = my_fmt_str % (my_lev_str)

        # print( my_lev_str )
        # finally no matter what set the levels that are to be active

        my_level = Msg.translate_levelstr(my_lev_str)
        # print( "Before: %x" % my_level )

        Msg.set_level(my_level)

    def option_def(self, aSwitch, aDefVal=None, aConversionFunc=None):
        # TODO deprecate this
        return_value = self._mAppsInfo.mCmdLineOpts.option_def(
            aSwitch, aDefVal)
        if aConversionFunc and return_value is not None:
            try:
                return_value = aConversionFunc(return_value)
            except (TypeError, ValueError) as ex:
                Msg.warn(
                    'Invalid value "{}" provided for "{}".  Using default.'.
                    format(repr(return_value), aSwitch))
                return aDefVal

        return return_value

    def load(self):

        # Msg.dbg( "ForrestRun::load" )

        my_frun_path = self.option_def(CmdLine.Switches[CmdLine.control_name],
                                       None)
        if my_frun_path is None:
            raise Exception(
                "F-Run Control File Not Found on the Forrest Run Command Line: Given Path: %s",
                str((my_frun_path)))

        # good to here
        self.locate_frun(my_frun_path)

        Msg.user("File Path: %s" % (my_frun_path))

        my_content = open(self.frun_name).read()
        my_glb, my_loc = SysUtils.exec_content(my_content)
        Msg.dbg(str(my_loc))

        self.fcontrol = my_loc["control_items"]

        my_ctrl_dict = self.fcontrol[0]

        my_ctrl_item = ControlItem()
        my_ctrl_item.load(self._mAppsInfo, my_ctrl_dict)

        # Msg.lout( my_ctrl_dict, "user", "Forrest Parent Data ...." )

        self.check_simulator()

        self.fctrl = ExecuteController(self._mAppsInfo)
        self.fctrl.set_frun(self.frun_name)
        self.fctrl.load(my_ctrl_item)

    def run(self):
        Msg.dbg("ForrestRun::run()")
        self.fctrl.process()

    def locate_frun(self, arg_frun_path):

        Msg.user("Directory set to %s" % (PathUtils.current_dir()))
        # if the control file contains a path then split that into the directory and the file
        my_frun_dir, my_frun_name = PathUtils.split_path(arg_frun_path)
        # always convert to full path
        my_cur_dir = PathUtils.real_path(PathUtils.current_dir())

        # gots to have a source directory as part of the file name
        if my_frun_dir is None:
            my_frun_dir = my_cur_dir

        else:
            # always convert to full path. If the frun was loaded correctly then we can conclude that
            # the path tendered is either a relative path from the starting directory or a full path
            # to that file. If it is not a full path then it will need to be converted to a full path
            # and all links removed
            my_frun_dir = PathUtils.real_path(my_frun_dir)

        # Msg.user( "FRun Dir: %s, FRun Name: %s, Cur Dir: %s" % ( str( my_frun_dir ), str( my_frun_name ), my_cur_dir ), "FRUN-DIR")

        # change into the directory to generate and simulate
        if not PathUtils.chdir(my_frun_dir):
            raise Exception("F-Run Directory[%s] Not Found" %
                            (str(my_frun_dir)))

        self.frun_name = my_frun_name
        self.frun_dir = my_frun_dir
        # self.frun_path =

        # Msg.user( "FRun Dir: %s, FRun Name: %s, Cur Dir: %s" % ( str( self.frun_dir ), str( self.frun_name ),  PathUtils.current_dir() ), "FRUN-DIR")

    def check_simulator(self):

        if SysUtils.check_host("SAN"):

            Msg.dbg("System is in Green Zone .....")
            my_gcc_path = "/project/software/public/gcc/5.1/centos6.6/lib64"
            my_lib_path = SysUtils.envar("LD_LIBRARY_PATH", None)

            if not my_lib_path:
                SysUtils.envar_set("LD_LIBRARY_PATH", my_gcc_path)
            elif my_lib_path.find(my_gcc_path) < 0:
                SysUtils.envar_set("LD_LIBRARY_PATH", "%s:%s",
                                   (my_gcc_path, my_lib_path))

            Msg.dbg("LD_LIB_PATH: %s " % (str(my_lib_path)))
            Msg.dbg("\"LD_LIBRARY_PATH\" = %s" %
                    (str(SysUtils.envar("LD_LIBRARY_PATH", None))))

        else:
            Msg.dbg("System is Red Zone or Yellow Zone")

        return True
Пример #3
0
class ForrestRun(ModuleRun):
    def __init__(self, aAppsInfo):
        super().__init__(CmdLine.Switches[CmdLine.msg_lev], Defaults.msg_level,
                         aAppsInfo)

        self.frun_name = None
        self.frun_dir = None

        self.item_data = {}
        self.options = {}

    def load(self):

        # Msg.dbg( "ForrestRun::load" )

        my_frun_path = self.option_def(CmdLine.Switches[CmdLine.control_name],
                                       None)
        if my_frun_path is None:
            raise Exception(
                "F-Run Control File Not Found on the Forrest Run Command Line: Given Path: %s",
                str((my_frun_path)))

        # good to here
        self.locate_frun(my_frun_path)

        Msg.user("File Path: %s" % (my_frun_path))

        my_content = open(self.frun_name).read()
        my_glb, my_loc = SysUtils.exec_content(my_content)
        Msg.dbg(str(my_loc))

        self.fcontrol = my_loc["control_items"]

        my_ctrl_dict = self.fcontrol[0]

        my_ctrl_item = ControlItem()
        my_ctrl_item.load(self._mAppsInfo, my_ctrl_dict)

        # Msg.lout( my_ctrl_dict, "user", "Forrest Parent Data ...." )

        self.check_simulator()

        self.fctrl = ExecuteController(self._mAppsInfo)
        self.fctrl.set_frun(self.frun_name)
        self.fctrl.load(my_ctrl_item)

    def run(self):
        Msg.dbg("ForrestRun::run()")
        self.fctrl.process()

    def locate_frun(self, arg_frun_path):

        Msg.user("Directory set to %s" % (PathUtils.current_dir()))
        # if the control file contains a path then split that into the directory and the file
        my_frun_dir, my_frun_name = PathUtils.split_path(arg_frun_path)
        # always convert to full path
        my_cur_dir = PathUtils.real_path(PathUtils.current_dir())

        # gots to have a source directory as part of the file name
        if my_frun_dir is None:
            my_frun_dir = my_cur_dir

        else:
            # always convert to full path. If the frun was loaded correctly then we can conclude that
            # the path tendered is either a relative path from the starting directory or a full path
            # to that file. If it is not a full path then it will need to be converted to a full path
            # and all links removed
            my_frun_dir = PathUtils.real_path(my_frun_dir)

        # Msg.user( "FRun Dir: %s, FRun Name: %s, Cur Dir: %s" % ( str( my_frun_dir ), str( my_frun_name ), my_cur_dir ), "FRUN-DIR")

        # change into the directory to generate and simulate
        if not PathUtils.chdir(my_frun_dir):
            raise Exception("F-Run Directory[%s] Not Found" %
                            (str(my_frun_dir)))

        self.frun_name = my_frun_name
        self.frun_dir = my_frun_dir
        # self.frun_path =

        # Msg.user( "FRun Dir: %s, FRun Name: %s, Cur Dir: %s" % ( str( self.frun_dir ), str( self.frun_name ),  PathUtils.current_dir() ), "FRUN-DIR")

    def check_simulator(self):

        if SysUtils.check_host("SAN"):

            Msg.dbg("System is in Green Zone .....")
            my_gcc_path = "/project/software/public/gcc/5.1/centos6.6/lib64"
            my_lib_path = SysUtils.envar("LD_LIBRARY_PATH", None)

            if not my_lib_path:
                SysUtils.envar_set("LD_LIBRARY_PATH", my_gcc_path)
            elif my_lib_path.find(my_gcc_path) < 0:
                SysUtils.envar_set("LD_LIBRARY_PATH", "%s:%s",
                                   (my_gcc_path, my_lib_path))

            Msg.dbg("LD_LIB_PATH: %s " % (str(my_lib_path)))
            Msg.dbg("\"LD_LIBRARY_PATH\" = %s" %
                    (str(SysUtils.envar("LD_LIBRARY_PATH", None))))

        else:
            Msg.dbg("System is Red Zone or Yellow Zone")

        return True
Пример #4
0
class ForrestRun(ModuleRun):
    def __init__(self):
        super().__init__(CmdLine.Switches[CmdLine.msg_lev], Defaults.msg_level)

        self.frun_name = None
        self.frun_dir = None
        self.fctrl = None

        self.item_data = {}
        self.options = {}

        self.fcontrol = None

    def init_app_setup(self):
        try:
            self.m_app_setup = ApplicationsSetup(
                CommandLineParameters,
                sys.argv,
                CmdLineUtils.basic_command_line_argument_retrieval(
                    sys.argv[1:], "-w", "--workflow", str, 1).workflow[0],
            )
            self.m_app_info = self.m_app_setup.getApplicationsInfo()
        except TypeError:
            # catches error that is thrown when trying to iterate through a
            # None type variable (if workflow argument does not exist)
            self.m_app_setup = ApplicationsSetup(CommandLineParameters,
                                                 sys.argv)
            self.m_app_info = self.m_app_setup.getApplicationsInfo()
        except SystemExit as aSysExit:
            sys.exit(int(str(aSysExit)))
        except Exception as ex:
            print("[ERROR] - An Unhandled Error has Occurred during "
                  "applications setup of " + str(sys.argv[0]))
            traceback.print_exc(file=sys.stdout)
            sys.exit(43)

    def load(self):
        my_frun_path = self.option_def(CmdLine.Switches[CmdLine.control_name],
                                       None)
        if my_frun_path is None:
            raise Exception(
                "F-Run Control File Not Found on the Forrest Run Command "
                "Line: Given Path: %s",
                str((my_frun_path)),
            )

        self.locate_frun(my_frun_path)

        Msg.user("File Path: %s" % (my_frun_path))

        my_content = open(self.frun_name).read()
        my_glb, my_loc = SysUtils.exec_content(my_content)
        Msg.dbg(str(my_loc))

        self.fcontrol = my_loc["control_items"]

        my_ctrl_dict = self.fcontrol[0]

        my_ctrl_item = ControlItem()
        my_ctrl_item.load(self.m_app_info, my_ctrl_dict)

        # Msg.lout( my_ctrl_dict, "user", "Forrest Parent Data ...." )

        self.check_simulator()

        self.fctrl = ExecuteController(self.m_app_info)
        self.fctrl.set_frun(self.frun_name)
        self.fctrl.load(my_ctrl_item)

    def run(self):
        Msg.dbg("ForrestRun::run()")
        self.fctrl.process()

    def locate_frun(self, arg_frun_path):
        Msg.user("Directory set to %s" % (PathUtils.current_dir()))
        # if the control file contains a path then split that into the
        # directory and the file
        my_frun_dir, my_frun_name = PathUtils.split_path(arg_frun_path)
        # always convert to full path
        my_cur_dir = PathUtils.real_path(PathUtils.current_dir())

        # gots to have a source directory as part of the file name
        if my_frun_dir is None:
            my_frun_dir = my_cur_dir

        else:
            # always convert to full path. If the frun was loaded correctly
            # then we can conclude that the path tendered is either a relative
            # path from the starting directory or a full path to that file. If
            # it is not a full path then it will need to be converted to a
            # full path and all links removed
            my_frun_dir = PathUtils.real_path(my_frun_dir)

        # change into the directory to generate and simulate
        if not PathUtils.chdir(my_frun_dir):
            raise Exception("F-Run Directory[%s] Not Found" %
                            (str(my_frun_dir)))

        self.frun_name = my_frun_name
        self.frun_dir = my_frun_dir

    def check_simulator(self):
        if SysUtils.check_host("SAN"):
            Msg.dbg("System is in Green Zone .....")
            my_gcc_path = "/project/software/public/gcc/5.1/centos6.6/lib64"
            my_lib_path = SysUtils.envar("LD_LIBRARY_PATH", None)

            if not my_lib_path:
                SysUtils.envar_set("LD_LIBRARY_PATH", my_gcc_path)
            elif my_lib_path.find(my_gcc_path) < 0:
                SysUtils.envar_set("LD_LIBRARY_PATH",
                                   "%s:%s" % (my_gcc_path, my_lib_path))

            Msg.dbg("LD_LIB_PATH: %s " % (str(my_lib_path)))
            Msg.dbg('"LD_LIBRARY_PATH" = %s' %
                    (str(SysUtils.envar("LD_LIBRARY_PATH", None))))

        else:
            Msg.dbg("System is Red Zone or Yellow Zone")

        return True