def run(self, productName, version, build_number, rule_ids): name = get_release_blob_name(productName, version, build_number, self.dummy) api = Rule(auth=self.auth, api_root=self.api_root) for id_ in rule_ids: api.update_rule(id_, mapping=name)
sys.exit(1) root_name = "-".join(latest_blob_name.split("-")[:-1]) release_name = "%s-%s" % (root_name, buildid) if not args.dry_run: logging.info("Locking rule %s to %s", rule_id, release_name) Rule(api_root=args.api_root, auth=auth, rule_id=rule_id).update_rule(mapping=release_name) else: logging.info("Would've locked rule %s to %s", rule_id, release_name) elif args.action == ["unlock"]: if args.action_args: parser.error("Unlock command does not accept any args.") for rule_id in args.rule_ids: rule = Rule(api_root=args.api_root, auth=auth, rule_id=rule_id) rule_data, _ = rule.get_data() root_name = "-".join(rule_data["mapping"].split("-")[:-1]) release_name = "%s-latest" % root_name if not args.dry_run: logging.info("Unlocking rule %s back to %s", rule_id, release_name) rule.update_rule(mapping=release_name) else: logging.info("Would've unlocked rule %s back to %s", rule_id, release_name)
buildid = None for p in release_data["platforms"].values(): enUS = p.get("locales", {}).get("en-US", {}) next_buildid = enUS.get("buildID") if next_buildid > buildid: buildid = next_buildid if not buildid: logging.error("Couldn't find latest buildid for rule %s", rule_id) sys.exit(1) root_name = "-".join(latest_blob_name.split("-")[:-1]) release_name = "%s-%s" % (root_name, buildid) if not args.dry_run: logging.info("Locking rule %s to %s", rule_id, release_name) rule_api.update_rule(rule_id, mapping=release_name) else: logging.info("Would've locked rule %s to %s", rule_id, release_name) elif args.action == ["unlock"]: if args.action_args: parser.error("Unlock command does not accept any args.") for rule_id in args.rule_ids: rule_data, _ = rule_api.get_data(rule_id) root_name = "-".join(rule_data["mapping"].split("-")[:-1]) release_name = "%s-latest" % root_name if not args.dry_run: logging.info("Unlocking rule %s back to %s", rule_id, release_name) rule_api.update_rule(rule_id, mapping=release_name)
if next_buildid > buildid: buildid = next_buildid if not buildid: logging.error("Couldn't find latest buildid for rule %s", rule_id) sys.exit(1) root_name = "-".join(latest_blob_name.split("-")[:-1]) release_name = "%s-%s" % (root_name, buildid) if not args.dry_run: logging.info("Locking rule %s to %s", rule_id, release_name) Rule(api_root=args.api_root, auth=auth, rule_id=rule_id).update_rule(mapping=release_name) else: logging.info("Would've locked rule %s to %s", rule_id, release_name) elif args.action == ["unlock"]: if args.action_args: parser.error("Unlock command does not accept any args.") for rule_id in args.rule_ids: rule = Rule(api_root=args.api_root, auth=auth, rule_id=rule_id) rule_data, _ = rule.get_data() root_name = "-".join(rule_data["mapping"].split("-")[:-1]) release_name = "%s-latest" % root_name if not args.dry_run: logging.info("Unlocking rule %s back to %s", rule_id, release_name) rule.update_rule(mapping=release_name) else: logging.info("Would've unlocked rule %s back to %s", rule_id, release_name)