def WorkHorse(cls, rules): """Runs the workhorse for the command. Args: rules: list: List of rules to be handled. Return: (list, list): Returns a tuple of list in the form (successful_rules, failed_rules) specifying rules that succeeded and ones that failed. """ # Create the user friendly link to bin dir if it doesn't already exist. FileUtils.CreateLink(FileUtils.GetEDir(), FileUtils.GetBinDir()) # Create the link to the web test directory if it exists if os.path.exists(FileUtils.GetWebTestHtmlLink()): FileUtils.CreateLink(FileUtils.GetWebTestHtmlLink(), FileUtils.GetWebTestHtmlDir()) gen_makefile = GenMakefile(Flags.ARGS.debug) gen_makefile.GenMainMakeFile() (success_genmake, failed_genmake) = gen_makefile.GenAutoMakeFileFromRules( rules, Flags.ARGS.allowed_rule_types) (success_make, failed_make) = cls._MakeRules(success_genmake, gen_makefile.GetMakeFileName()) return (success_make, failed_genmake + failed_make)
def __CreateInitialSubDirs(self): """Creates all necessary directories.""" # Check if we have to create any output directory if not Flags.ARGS.out_dirs and Flags.ARGS.nolog_output: return # Create the user friendly link to pipeline dir if it doesn't already exist. FileUtils.CreateLink(FileUtils.GetPipelineLinkDir(), FileUtils.GetPipelineDir()) # Create the output directory. if Flags.ARGS.out_dirs or not Flags.ARGS.log_to_tmp: self._pipeline_output_dir = os.path.join( FileUtils.GetPipelineDir(), self._id) FileUtils.MakeDirs(self._pipeline_output_dir) # Create the log dir if required. if not Flags.ARGS.nolog_output: if Flags.ARGS.log_to_tmp: log_root = os.path.join('/tmp', 'pipeline', self.pipeline_id()) else: log_root = self._pipeline_output_dir self._pipeline_log_dir = os.path.join(log_root, 'log', self.pipeline_date()) FileUtils.MakeDirs(self._pipeline_log_dir) # Create all the subdirs. self._subdirs = {} for i in Flags.ARGS.out_dirs: subdir = os.path.join(self.pipeline_output_dir(), i) FileUtils.MakeDirs(subdir) self._subdirs['PIPELINE_' + i.upper() + '_DIR'] = subdir
def WorkHorse(cls, tasks): """Runs the workhorse for the command. Args: tasks: OrderedDict {int, set(string)}: Dict from priority to set of tasks to execute at the priority. Note: the dict is ordered by priority. Return: (list, list): Returns a tuple of list in the form (successful_tasks, failed_tasks) specifying tasks that succeeded and ones that failed. """ all_tasks = [] dirs_to_publish = set() publish_dir_to_task_map = {} for set_tasks in tasks.values(): for task in set_tasks: all_tasks += [task] publish_dir = PipelineUtils.GetPublishDirForTask(task) if not publish_dir: continue dirs_to_publish |= set([publish_dir]) publish_dir_to_task_map[publish_dir] = (publish_dir_to_task_map.get(publish_dir, []) + [publish_dir]) # Check if there are any directories to publish. if not dirs_to_publish: TermColor.Error('Did not find any dirs to publish. Do not forget to specify publish root ' 'using --publish_root') return ([], all_tasks) # Run all the copy tasks. successful_dirs = []; failed_dirs = [] for dir in dirs_to_publish: publish_dir = cls._GetActualPublishDir(dir) if not publish_dir: failed_dirs += [publish_dir] continue (parent, name) = os.path.split(publish_dir) TermColor.Info('Making current: %s' % publish_dir) with FileUtils.PushDir(parent): FileUtils.CreateLink('current', name) successful_dirs += [publish_dir] # Get the reverse mapping from dirs to tasks. successful_tasks = []; failed_tasks = [] for i in successful_dirs: successful_tasks += publish_dir_to_task_map.get(i, []) for i in failed_dirs: failed_tasks += publish_dir_to_task_map.get(i, []) return (successful_tasks, failed_tasks)
def __init__(self, rule_name): """initializes the state Args: rule_name (string) - the rule name Raises: UnsupportedRuleError: raises exception if the rule type is not yet supported. add to the RULE_TYPES lists """ # Create the user friendly link to bin dir if it doesn't already exist. FileUtils.CreateLink(FileUtils.GetEDir(), FileUtils.GetBinDir()) rule_name = Utils.RuleNormalizedName(rule_name) Rules.LoadRule(rule_name) self._rule = Rules.GetRule(rule_name) if not self._rule['_type'] in Packager.RULE_PACKAGER: err = 'Rule type %s not supported' % self._rule._type TermColor.Error(err) raise UnsupportedRuleError(err) self._packager = Packager.RULE_PACKAGER[self._rule['_type']]