Ejemplo n.º 1
0
    def generate_data(self):
        new_data = {}
        current_data = {}

        logger.info("grabbing current data about release")
        with open(self.abs_data_file) as current_data_f:
            current_data.update(json.load(current_data_f))
            new_data.update(deepcopy(current_data))

        logger.info("updating with custom update data")
        for key_change, key_value in self.changes.items():
            if key_change == "issues":
                new_data['builds'][-1]["issues"].extend(key_value)
            elif key_change == "human_tasks":
                new_data['builds'][-1]["human_tasks"].update(key_value)
            else:
                new_data['builds'][-1][key_change] = key_value

        if new_data["builds"][-1]["aborted"]:
            logger.info("most recent buildnum has been aborted, starting a new buildnum")
            template_buildnum_data = {}
            with open(DATA_TEMPLATES[self.product][self.branch]) as data_template:
                template_buildnum_data.update(json.load(data_template)["builds"][0])
            new_data["builds"].append(template_buildnum_data)
            new_data["builds"][-1]["buildnum"] = len(new_data["builds"])

        if data_unchanged(new_data, current_data):
            logger.warning("no changes found in update call after regenerating data file.")
            logger.warning("nothing to commit. aborting.")
            sys.exit(1)

        return new_data
Ejemplo n.º 2
0
    def generate_data(self):
        new_data = {}
        current_data = {}

        logger.info("grabbing current data about release")
        with open(self.abs_data_file) as current_data_f:
            current_data.update(json.load(current_data_f))
            new_data.update(deepcopy(current_data))

        logger.info("updating with custom update data")
        for key_change, key_value in self.changes.items():
            if key_change == "issues":
                owned_key_value = [
                    "{}: {}".format(getpass.getuser(), k) for k in key_value
                ]
                new_data['builds'][-1]["issues"].extend(owned_key_value)
            elif key_change == "human_tasks":
                new_data['builds'][-1]["human_tasks"].update(key_value)
            else:
                new_data['builds'][-1][key_change] = key_value

        if new_data["builds"][-1]["aborted"]:
            logger.info(
                "most recent buildnum has been aborted, starting a new buildnum"
            )
            template_buildnum_data = {}
            with open(DATA_TEMPLATES[self.product][
                    self.branch]) as data_template:
                template_buildnum_data.update(
                    json.load(data_template)["builds"][0])
            new_data["builds"].append(template_buildnum_data)
            new_data["builds"][-1]["buildnum"] = len(new_data["builds"])

        if data_unchanged(new_data, current_data):
            logger.warning(
                "no changes found in update call after regenerating data file."
            )
            logger.warning("nothing to commit. aborting.")
            sys.exit(1)

        return new_data