def main():
    signal.signal(signal.SIGINT, sig_interrupt_handler)
    my_pwd = None

    print(
        "\n=======================================\n\tInitializing ....\n=======================================\n"
    )
    try:
        my_module = MasterRun()

        # save current working directory
        my_pwd = PathUtils.current_dir()

        Msg.dbg("Original Directory: " + my_pwd)
        Msg.dbg("Processing Command Line and Loading Control File")
        my_module.load()

        if not PathUtils.chdir(my_module.output_dir, True):
            Msg.dbg("Unable to change into: " + my_module.output_dir +
                    ", using the current directory for output")

        Msg.info("\nConcurrent Operations: %s" %
                 (str(my_module.m_app_info.mProcessMax)))
        my_module.run()

        Msg.info("Test Completed ....\n")

    except FileNotFoundError as arg_ex:
        # Msg.error_trace("[ERROR] -  " + str(arg_ex) )
        Msg.err(str(arg_ex))
        Msg.blank()

    except LoadError as arg_ex:
        # Msg.error_trace("[ERROR] -  " + str(arg_ex) )
        Msg.err(str(arg_ex))
        Msg.blank()

    except Exception as arg_ex:

        from force_init import force_usage

        Msg.err("[ERROR] - An Unhandled Error has Occurred during run of " +
                str(sys.argv[0]))
        traceback.print_exc(file=sys.stdout)

    except:
        # traceback.print_exc( file=sys.stdout )
        # print( "An Unhandled Exception Occurred ..." )
        pass

    finally:
        # TODO
        # change back to original directory

        if my_pwd is not None:
            # Msg.dbg( "Restoring Original Directory: " + my_pwd )
            PathUtils.chdir(my_pwd)
Beispiel #2
0
    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
Beispiel #3
0
    def convertRawResult(self, aMetaArgs, aFilter=False):
        current_dir = PathUtils.current_dir()
        PathUtils.chdir(self._mTopSimPath)
        result, is_valid = SysUtils.get_command_output(self._mMakeCommand + aMetaArgs)
        PathUtils.chdir(current_dir)

        if not is_valid:
            print("Converting meta args: %s to raw result failed." % aMetaArgs)
            sys.exit(1)

        if aFilter:
            args_list = result.split(" ")
            args_list = self.filterList(args_list)
            result = " ".join(args_list)

        return result
Beispiel #4
0
if __name__ == "__main__":

    # save current working directory
    my_pwd = PathUtils.current_dir()

    try:
        my_module = UnitTestRun(the_force_root)

        Msg.info("\nForce Path: %s" % (str(the_force_root)))
        Msg.info("Original Directory: " + my_pwd)

        Msg.dbg("Processing Command Line and Loading  Control File")
        my_module.load()

        Msg.dbg("Directory set to %s" % (PathUtils.current_dir()))
        if not PathUtils.chdir(the_force_root, False):
            Msg.dbg(
                "Directory Unchanged, using the current directory for output"
            )

        my_module.run()
        Msg.dbg("Test Completed ....\n")
        Msg.blank()
        sys.exit(40)

    except getopt.GetoptError as arg_ex:

        from force_init import force_usage

        Msg.error_trace("[ERROR] - " + str(arg_ex))
        force_usage(UsageStr)
Beispiel #5
0
    os.setpgid(os.getpid(), os.getpid())

    try:
        my_module = ForrestRun(apps_info)
        my_module.force_path = the_force_root  # TODO remove this very soon

        Msg.dbg("\nForce Path: %s" % (str(the_force_root)))
        Msg.dbg("Original Directory: " + my_pwd)

        # save current working directory

        Msg.dbg("Processing Command Line and Loading Control File")
        my_module.load()

        Msg.dbg("Directory set to %s" % (PathUtils.current_dir()))
        if not PathUtils.chdir(my_module.frun_dir, False):
            Msg.dbg(
                "Directory Unchanged, using the current directory for output")

        my_module.run()
        Msg.dbg("Test Completed ....\n")
        Msg.blank()
        # sys.exit( 0 )

    except Exception as arg_ex:
        from force_init import force_usage
        Msg.err("An Unhandled Error has Occurred during run of " +
                str(sys.argv[0]))
        traceback.print_exc(file=sys.stdout)
        Msg.error_trace(str(arg_ex))
        apps_info.mCmdLineOpts.print_help()
Beispiel #6
0
def main():
    # set up signal handlers,
    signal.signal(signal.SIGINT, handle_signal)
    signal.signal(signal.SIGTERM, handle_signal)

    # initialize variables
    my_hlog = None
    my_org_stdout = None

    # global the_output_path =

    # Step 1: Save the originating directory
    my_pwd = PathUtils.current_dir()

    # Step 3: Extract Pid Group
    os.setpgid(os.getpid(), os.getpid())

    my_module = ForrestRun()

    try:
        my_module.force_path = the_force_root

        my_logfile = my_module.m_app_info.mCmdLineOpts.option_def(
            CmdLine.Switches[CmdLine.logfile], None)

        if my_logfile is not None:
            # print( "Redirecting STDOUT to my_logfile" )
            my_org_stdout = sys.stdout
            my_hlog = open(my_logfile, "w")
            sys.stdout = my_hlog
            Msg.user("Log File: %s" % (str(my_logfile)), "STDLOG")

        Msg.dbg("\nForce Path: %s" % (str(the_force_root)))
        Msg.dbg("Original Directory: " + my_pwd)

        # save current working directory

        Msg.dbg("Processing Command Line and Loading Control File")
        my_module.load()

        Msg.dbg("Directory set to %s" % (PathUtils.current_dir()))
        if not PathUtils.chdir(my_module.frun_dir, False):
            Msg.dbg(
                "Directory Unchanged, using the current directory for output")

        my_module.run()
        Msg.dbg("Test Completed ....\n")
        Msg.blank()
        # sys.exit( 0 )

    except Exception as ex:
        from force_init import force_usage

        Msg.err("An Unhandled Error has Occurred during run of " +
                str(sys.argv[0]))
        traceback.print_exc(file=sys.stdout)
        Msg.error_trace(str(ex))
        my_module.m_app_info.mCmdLineOpts.print_help()
        sys.exit(41)

    except BaseException:
        print("[ERROR] - An Unhandled Error has Occurred during run of " +
              str(sys.argv[0]))
        traceback.print_exc(file=sys.stdout)
        sys.exit(42)

    finally:
        if my_logfile is not None:
            my_hlog.close()
            sys.stdout = my_org_stdout
            with open(my_logfile, "r") as my_hlog:
                print(my_hlog.read())

        if my_pwd is not None:
            PathUtils.chdir(my_pwd)
            Msg.dbg("Returned To: %s" % (PathUtils.current_dir()))
Beispiel #7
0
        sys.exit(44)

    print(
        "\n=======================================\n\tInitializing ....\n=======================================\n"
    )
    try:
        my_module = MasterRun(apps_info)

        # save current working directory
        my_pwd = PathUtils.current_dir()

        Msg.dbg("Original Directory: " + my_pwd)
        Msg.dbg("Processing Command Line and Loading Control File")
        my_module.load()

        if not PathUtils.chdir(my_module.output_dir, True):
            Msg.dbg("Unable to change into: " + my_module.output_dir +
                    ", using the current directory for output")

        Msg.info("\nConcurrent Operations: %s" %
                 (str(my_module._mAppsInfo.mProcessMax)))
        my_module.run()

        Msg.info("Test Completed ....\n")

    #    print( "[ERROR] Parsing Command Line: %s\n" % ( str( arg_ex )))

    except FileNotFoundError as arg_ex:
        # Msg.error_trace("[ERROR] -  " + str(arg_ex) )
        Msg.err(str(arg_ex))
        Msg.blank()