def __processLocksSubjects(self, subjects): """look if some subjects from a list currently are locked into the pipeline Args: subjects: a list of the subject Returns: a list of subjects that is not lock """ locks = [] for subject in subjects: if subject.isLock(): locks.append(subject) if locks: if len(locks) == 1: subject = locks[0] tags = {"name": subject.getName(), "lock":subject.getLock()} msg = util.parseTemplate(tags, os.path.join(self.arguments.toadDir, "templates", "files", "lock.tpl")) else: subjectsNames = [] locksFileNames = [] for subject in locks: subjectsNames.append(subject.getName()) locksFileNames.append(subject.getLock()) tags = {"names": ", ".join(subjectsNames) ,"locks":"\t,\n".join(locksFileNames)} msg = util.parseTemplate(tags, os.path.join(self.arguments.toadDir, "templates", "files", "locks.tpl")) if self.config.getboolean('arguments', 'prompt'): answer = util.displayContinueQuitRemoveMessage(msg) if answer == "y": self.info("Locks subjects will be ignored during execution\n") subjects = [subject for subject in subjects if subject not in locks] elif answer == "r": self.info("Removing locks and continue the pipeline\n") for lock in locks: if os.path.isfile(lock.getLock()): os.remove(lock.getLock()) else: self.error("Please submit the pipeline again\n") else: self.warning(msg) return subjects
def parseTemplate(self, dict, template): """provide simpler string substitutions as described in PEP 292 Args: dict: dictionary-like object with keys that match the placeholders in the template template: object passed to the constructors template argument. Returns: the string substitute """ return util.parseTemplate(dict, template)