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

mozilla / relman-auto-nag / #4914

31 Jan 2024 11:52AM CUT coverage: 21.785% (-0.08%) from 21.869%
#4914

push

coveralls-python

PromiseFru
Merge branch 'performancebug-rule' of github.com:PromiseFru/bugbot into performancebug-rule

716 of 3606 branches covered (0.0%)

1928 of 8850 relevant lines covered (21.79%)

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