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
def _optPathChecks(self, aValue, aProgramPath): opt_value = aValue if (len(opt_value) > 0) and (opt_value[0] != "/"): opt_value = PathUtils.include_trailing_path_delimiter(aProgramPath) + opt_value opt_value = PathUtils.real_path(opt_value) if not PathUtils.valid_path(opt_value): raise FileNotFoundError("Path resolution for [%s] failed, [%s] could not be located" % (self._optionString(), opt_value)) if PathUtils.check_dir(opt_value): opt_value = PathUtils.include_trailing_path_delimiter(opt_value) return opt_value
def convert_meta_args(aConversionParms): if aConversionParms.meta_args is None: if (aConversionParms.plusargs is not None) and len( aConversionParms.cmp_plusargs): pass else: print('Meta args not specified.') sys.exit(1) meta_args = aConversionParms.meta_args if aConversionParms.rtl_root is None: rtl_root = os.environ.get("PROJ_ROOT", None) if rtl_root is None: print('No RTL root defined.') sys.exit(1) else: rtl_root = aConversionParms.rtl_root if not PathUtils.check_dir(rtl_root): print("RTL root does not exist or is not a directory: %s" % rtl_root) sys.exit(1) script_dir, script_name = PathUtils.split_path( PathUtils.real_path(sys.argv[0])) make_file_path = PathUtils.include_trailing_path_delimiter( script_dir) + "applications/rtl/MetaArgs.make" if not PathUtils.check_file(make_file_path): print("File not exist: %s" % make_file_path) sys.exit(1) #print("meta args %s, rtl root %s, make file: %s" % (meta_args, rtl_root, make_file_path)) meta_args_conv = MetaArgsConversion(rtl_root, make_file_path) if aConversionParms.net: conversion_result = meta_args_conv.convertNetResult(meta_args) elif len(aConversionParms.cmp_plusargs): if (aConversionParms.plusargs is not None) and len(aConversionParms.plusargs) > 0: conversion_result = meta_args_conv.comparePlusAndPlus( aConversionParms.plusargs, aConversionParms.cmp_plusargs) else: conversion_result = meta_args_conv.compareMetaAndPlus( meta_args, aConversionParms.cmp_plusargs) else: conversion_result = meta_args_conv.convertRawResult(meta_args, True) print(conversion_result)
def get_svn_revision(arg_class, arg_path): if not PathUtils.check_dir(arg_path): return 0, "Invalid path: %s" % arg_path cmd_output, valid = SysUtils.get_command_output("svn info %s" % arg_path) if not valid: return 0, "Command error: %s" % cmd_output for line in cmd_output.split('\n'): if line.startswith("Revision: "): match_obj = re.match(VersionCtrlUtils.svn_revision_pattern, line) rev_value = int(match_obj.group(1)) return rev_value, None return 0, "Revision info not found"
def __init__(self, aCmdLineOptions): """Iintialize the object :param CmdLineOptions aCmdLineOptions: """ super().__init__(RtlCmdLineOptions.cOptions, aCmdLineOptions) rtl_root = self.mAppParameters.parameter("root") if not PathUtils.check_dir(rtl_root): raise Exception(rtl_root + " is not a directory.") meta_conv_path = PathUtils.append_path(aCmdLineOptions.mProgramPath, "metaargs_to_plusargs.py") self.mAppParameters.setParameter("meta_converter", meta_conv_path) # determine svn revision information and store as a parameter version_data = VersionCtrlUtils.get_scm_revisions(rtl_root) version_output = VersionCtrlUtils.get_version_output(version_data) Msg.info("RTL Version Data:\n%s" % version_output) self.mAppParameters.setParameter("version", version_data) self.mAppParameters.setParameter("version_dir", rtl_root)