How to use the libmozdata.utils function in libmozdata

To help you get started, we’ve selected a few libmozdata examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozilla / relman-auto-nag / auto_nag / scripts / code_freeze_week.py View on Github external
data["bugid"] = ""

        for info in bugs.values():
            for rev, i in info["land"].items():
                queries.append(Query(url, {"node": rev}, handler_rev, i))

        if queries:
            hgmozilla.Revision(queries=queries).wait()

        # clean
        bug_torm = []
        for bug, info in bugs.items():
            torm = []
            for rev, i in info["land"].items():
                if not i["bugid"] or not (
                    self.date <= lmdutils.get_date_ymd(i["date"]) < self.tomorrow
                ):
                    torm.append(rev)
            for x in torm:
                del info["land"][x]
            if not info["land"]:
                bug_torm.append(bug)
        for x in bug_torm:
            del bugs[x]

        self.get_hg_patches(bugs)
github mozilla / relman-auto-nag / auto_nag / cache.py View on Github external
def get_data(self):
        if self.data is None:
            path = self.get_path()
            self.data = {}
            if os.path.exists(path):
                with open(path, "r") as In:
                    data = json.load(In)
                    for bugid, date in data.items():
                        delta = lmdutils.get_date_ymd("today") - lmdutils.get_date_ymd(
                            date
                        )
                        if delta.days < self.max_days:
                            self.data[str(bugid)] = date
        return self.data
github mozilla / relman-auto-nag / auto_nag / next_release.py View on Github external
for i, c in enumerate(cal):
            if (
                now < c["release date"]
                and i + 1 < len(cal)
                and cal[i + 1]["release date"] == date
            ):
                # The date is just the one after the "normal" release date
                # so here probably someone just changed the date because
                # we're close the merge day
                must_nag = False
                break
        if must_nag:
            bad_date_nrd = date.strftime("%Y-%m-%d")

    owners = ro.get_owners()
    now = lmdutils.get_date_ymd("today")
    for o in owners[::-1]:
        date = o["release date"]
        if now < date:
            if date != next_date:
                bad_date_ro = date.strftime("%Y-%m-%d")
            break

    if bad_date_nrd or bad_date_ro:
        next_date = next_date.strftime("%Y-%m-%d")
        send_mail(next_date, bad_date_nrd, bad_date_ro, dryrun=dryrun)
github mozilla / relman-auto-nag / auto_nag / round_robin.py View on Github external
def get_who_to_nag(self, date):
        fallbacks = {}
        date = lmdutils.get_date_ymd(date)
        days = utils.get_config("round-robin", "days_to_nag", 7)
        next_date = date + relativedelta(days=days)
        for cal in self.all_calendars:
            persons = cal.get_persons(next_date)
            if persons and all(p is not None for _, p in persons):
                continue

            name = cal.get_team_name()
            fb = cal.get_fallback_mozmail()
            if fb not in fallbacks:
                fallbacks[fb] = {}
            if name not in fallbacks[fb]:
                fallbacks[fb][name] = {"nobody": False, "persons": []}
            info = fallbacks[fb][name]

            if not persons:
github mozilla / relman-auto-nag / auto_nag / scripts / workflow / no_priority.py View on Github external
def get_bz_params(self, date):
        fields = ["triage_owner", "flags"]
        params = {
            "bug_type": "defect",
            "include_fields": fields,
            "resolution": "---",
            "f1": "priority",
            "o1": "equals",
            "v1": "--",
        }
        self.date = lmdutils.get_date_ymd(date)
        first = f"-{self.lookup_first * 7}d"
        second = f"-{self.lookup_second * 7}d"
        if self.typ == "first":
            # TODO: change this when https://bugzilla.mozilla.org/1543984 will be fixed
            # Here we have to get bugs where product/component have been set (bug has been triaged)
            # between 4 and 2 weeks
            # If the product/component never changed after bug creation, we need to get them too
            # (second < p < first && c < first) ||
            # (second < c < first && p < first) ||
            # ((second < creation < first) && pc never changed)
            params.update(
                {
                    "f2": "flagtypes.name",
                    "o2": "notequals",
                    "v2": "needinfo?",
                    "j3": "OR",
github mozilla / relman-auto-nag / auto_nag / scripts / code_freeze_week.py View on Github external
def handler_rev(json, data):
            push = json["pushdate"][0]
            push = datetime.datetime.utcfromtimestamp(push)
            push = lmdutils.as_utc(push)
            data["date"] = lmdutils.get_date_str(push)
            data["backedout"] = utils.is_backout(json)
            m = BUG_PAT.search(json["desc"])
            if not m or m.group(1) != data["bugid"]:
                data["bugid"] = ""
github mozilla / relman-auto-nag / auto_nag / db.py View on Github external
def get_ts(date, default=0):
    if isinstance(date, six.integer_types):
        return date
    if date:
        if isinstance(date, six.string_types):
            date = dateutil.parser.parse(date)
        date = int(calendar.timegm(date.timetuple()))
        return date
    if default == "now":
        return lmdutils.get_timestamp("now")
    return default
github mozilla / relman-auto-nag / auto_nag / scripts / assignee_no_login.py View on Github external
def get_bz_params(self, date):
        date = lmdutils.get_date_ymd(date)
        start_date = date - relativedelta(months=self.nmonths)
        fields = ["assigned_to", "triage_owner", "flags"]
        params = {
            "include_fields": fields,
            "resolution": "---",
            "f1": "assignee_last_login",
            "o1": "lessthan",
            "v1": start_date,
        }

        utils.get_empty_assignees(params, negation=True)

        return params