def checkBugNr(self): """Attempts to verify that a specified bug number really exists.""" import subprocess import shutil if not self.m_args.new_group: return True bug = self.m_args.new_group[0] nr = bug[1] insect = shutil.which("insect") if not insect: # cannot check bug validity without some bugzilla CLI, assume it's # fine return True try: # don't suppress output, might be a helpful pointer to see the # actual bug summary once more on success subprocess.check_call( [insect, "info", "-1", str(nr)], shell=False, close_fds=True) except subprocess.CalledProcessError: printerr("ERROR: bug {}#{} doesn't seem to exist".format(*bug)) return False return True
def checkDuplicate(self, entry): if entry.action == self.m_args.action: printerr( "ERROR: action to be added already exists in {}:{}".format( entry.path, entry.linenr)) return False return True
def run(self): self.m_args = self.m_parser.parse_args() # tuple of auth types matching the profiles self.m_auth_types = tuple( getattr(self.m_args, profile) for profile in PROFILES) if not self.sanityCheck(): printerr("Not adding new action since sanity check(s) failed") sys.exit(2) self.addAction()
def checkProfileAuthTypeOrder(self): """Checks that authentication types are not getting weaker in stronger profiles.""" ret = True strongest = [self.AUTH_TYPES[0]] * 3 for profile, auth_types in zip(PROFILES, self.m_auth_types): for nr, old, new in zip(range(len(strongest)), strongest, auth_types): if self.AUTH_TYPES.index(old) > self.AUTH_TYPES.index(new): printerr( "ERROR: Auth type for {} in profile {} is weaker than in profile {}" .format(self.AUTH_CATEGORIES[nr], profile, PROFILES[PROFILES.index(profile) - 1])) ret = False strongest = auth_types return ret
def checkDuplicate(self, entry): seen = self.m_actions_seen.get(entry.action, None) if not seen: self.m_actions_seen[entry.action] = entry else: if entry.settings == seen.settings: self.m_lines_to_drop.add(entry.linenr) print("{}:{}: removing redundant entry with same settings as in line {}".format( entry.path.name.ljust(35), str(entry.linenr).rjust(3), seen.linenr )) else: printerr("{}:{}: {}: conflicting duplicate entry ({}), previously seen in line {} ({})".format( seen.path.name.ljust(35), str(entry.linenr).rjust(3), seen.action, ':'.join(entry.settings), seen.linenr, ':'.join(seen.settings) ))