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

mozilla / relman-auto-nag / #5402

06 Feb 2025 01:34AM CUT coverage: 21.189% (-0.01%) from 21.2%
#5402

push

coveralls-python

web-flow
Bump pre-commit from 4.0.1 to 4.1.0 (#2580)

Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 4.0.1 to 4.1.0.
- [Release notes](https://github.com/pre-commit/pre-commit/releases)
- [Changelog](https://github.com/pre-commit/pre-commit/blob/main/CHANGELOG.md)
- [Commits](https://github.com/pre-commit/pre-commit/compare/v4.0.1...v4.1.0)

---
updated-dependencies:
- dependency-name: pre-commit
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

426 of 2950 branches covered (14.44%)

1942 of 9165 relevant lines covered (21.19%)

0.21 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