• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / relman-auto-nag / #5247

01 Oct 2024 12:36PM CUT coverage: 21.657% (+0.01%) from 21.646%
#5247

push

coveralls-python

jgraham
Make webcompat platform bugs without keyword use BQ data

This is considered the canonical source for the list of webcompat core bugs,
so using it as the backend for the bug-bot rules avoids needing to duplicate
the logic across multiple systems.

585 of 3506 branches covered (16.69%)

0 of 13 new or added lines in 1 file covered. (0.0%)

2 existing lines in 2 files now uncovered.

1940 of 8958 relevant lines covered (21.66%)

0.22 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/bugbot/log.py
1
# This Source Code Form is subject to the terms of the Mozilla Public
2
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
3
# You can obtain one at http://mozilla.org/MPL/2.0/.
4

5
import argparse
×
6
import os
×
7

8
from libmozdata import utils as lmdutils
×
9

10
from . import mail, utils
×
11

12

13
def clean():
×
14
    path = utils.get_config("common", "log")
×
15
    os.remove(path)
×
16

17

18
def get_msg(path):
×
19
    with open(path, "r") as In:
×
20
        data = In.read()
×
21
    errors = 0
×
22
    for line in data.split("\n"):
×
23
        if "ERROR" in line or "CRITICAL" in line:
×
24
            errors += 1
×
25

26
    if errors == 1:
×
27
        return data, []
×
28

29
    return "There are {} errors: see the log in attachment.".format(errors), [path]
×
30

31

32
def send():
×
33
    path = utils.get_config("common", "log")
×
34
    try:
×
35
        n = os.path.getsize(path)
×
36
        if n != 0:
×
37
            login_info = utils.get_login_info()
×
38
            date = lmdutils.get_date("today")
×
39
            msg, files = get_msg(path)
×
40
            mail.send(
×
41
                login_info["ldap_username"],
42
                utils.get_config("common", "on-errors"),
43
                "[bugbot] Something bad happened when running BugBot the {}".format(
44
                    date
45
                ),
46
                msg,
47
                html=False,
48
                login=login_info,
49
                dryrun=False,
50
                files=files,
51
            )
52
    except Exception:
×
53
        pass
×
54

55

56
if __name__ == "__main__":
×
57
    parser = argparse.ArgumentParser(description="Manage logs")
×
58
    parser.add_argument(
×
59
        "-c", "--clean", dest="clean", action="store_true", help="Remove the log files"
60
    )
61
    parser.add_argument(
×
62
        "-s",
63
        "--send",
64
        dest="send",
65
        action="store_true",
66
        help="Send the log if not empty",
67
    )
68
    args = parser.parse_args()
×
69
    if args.clean:
×
70
        clean()
×
71
    if args.send:
×
72
        send()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc