def setupWorkDir( self ):
     work_dir = self.queue_item.work_dir
     PathUtils.mkdir( work_dir )
     # write out the control file
     PathUtils.touch( "%sSTARTED" % PathUtils.include_trailing_path_delimiter( work_dir ))
     if not PathUtils.write_file( self.queue_item.frun_path, self.queue_item.content, "Frun Control" ):
         raise Exception("Failed to write frun file: %s" % self.queue_item.frun_path)
Exemple #2
0
    def initialize_output(self):

        self.mode = self.option_def(CmdLine.Switches[CmdLine.mode], None)
        self.output_root = PathUtils.exclude_trailing_path_delimiter(
            self.option_def(CmdLine.Switches[CmdLine.target_dir],
                            PathUtils.current_dir()))
        Msg.user("Output Root: %s" % (str(self.output_root)))

        # check launcher type here since we need to know if we are running
        # with LSF
        Msg.user("Before Launcher Type", "MASTERRUN")
        self.launcher_type = self.option_def(
            CmdLine.Switches[CmdLine.run_launcher], Defaults.run_launcher)
        Msg.user("Launcher Type: %s" % (str(self.launcher_type)), "MASTERRUN")

        # ok the root output directory has been established.
        # next check to see if there is an expiration if there is handle that
        # and exit the session
        my_expire = self.option_def(CmdLine.Switches[CmdLine.expire], None)

        my_session_type = (Formats.perf_output_dir if SysUtils.found(
            self.mode.find(Modes.perf)) else Formats.regress_output_dir)

        if my_expire is not None:
            self.handle_expire(my_expire, my_session_type)
            raise Exception(
                "Problem with handle_expire, should have terminated .....")

        # Continuing create the full output directory which if exists should
        # be archived or removed
        my_output_base = Formats.main_output_dir % self.output_root
        self.output_dir = "%s/%s/" % (
            PathUtils.exclude_trailing_path_delimiter(my_output_base),
            PathUtils.exclude_trailing_path_delimiter(my_session_type),
        )

        Msg.user("Target Output Dir: %s" % (str(self.output_dir)))

        mod_time = None
        # if there is no expire setting then
        if PathUtils.check_dir(self.output_dir):
            # check modification time of the directory, if it is created very
            # recently, delay a bit when running on LSF.
            # since client machines might hold a stale directory handler still.
            mod_time = PathUtils.time_modified(self.output_dir)
            if self.option_def(CmdLine.Switches[CmdLine.no_archive],
                               Defaults.no_archive):
                PathUtils.rmdir(self.output_dir,
                                True)  # remove output directory tree
            else:
                PathUtils.archive_dir(self.output_dir)

        PathUtils.mkdir(self.output_dir)

        if mod_time is not None:
            self.waitForLfs(mod_time)

        return True