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

Open-MSS / MSS / 23598793952

26 Mar 2026 02:08PM UTC coverage: 69.889% (+0.06%) from 69.834%
23598793952

Pull #3033

github

web-flow
Merge d7227ea70 into 29ba126c7
Pull Request #3033: refactor server.py for using Blueprint

598 of 980 new or added lines in 13 files covered. (61.02%)

9 existing lines in 2 files now uncovered.

14602 of 20893 relevant lines covered (69.89%)

1.4 hits per line

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

64.1
/mslib/utils/__init__.py
1
# -*- coding: utf-8 -*-
2
"""
3

4
    mslib.utils
5
    ~~~~~~~~~~~~~~
6

7
    Collection of utility routines for the Mission Support System.
8

9
    This file is part of MSS.
10

11
    :copyright: Copyright 2008-2014 Deutsches Zentrum fuer Luft- und Raumfahrt e.V.
12
    :copyright: Copyright 2011-2014 Marc Rautenhaus (mr)
13
    :copyright: Copyright 2016-2026 by the MSS team, see AUTHORS.
14
    :license: APACHE-2.0, see LICENSE for details.
15

16
    Licensed under the Apache License, Version 2.0 (the "License");
17
    you may not use this file except in compliance with the License.
18
    You may obtain a copy of the License at
19

20
       http://www.apache.org/licenses/LICENSE-2.0
21

22
    Unless required by applicable law or agreed to in writing, software
23
    distributed under the License is distributed on an "AS IS" BASIS,
24
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25
    See the License for the specific language governing permissions and
26
    limitations under the License.
27
"""
28

29
import logging
2✔
30

31

32
class FatalUserError(Exception):
2✔
33
    def __init__(self, error_string):
2✔
34
        logging.debug("%s", error_string)
2✔
35

36

37
def setup_logging(args):
2✔
38
    logger = logging.getLogger()
2✔
39
    # this is necessary as "someone" has already initialized logging, preventing basicConfig from doing stuff
40
    for ch in logger.handlers:
2✔
41
        logger.removeHandler(ch)
2✔
42

43
    debug_formatter = logging.Formatter("%(asctime)s (%(module)s.%(funcName)s:%(lineno)s): %(levelname)s: %(message)s")
2✔
44
    default_formatter = logging.Formatter("%(levelname)s: %(message)s")
2✔
45

46
    # Console handler (suppress DEBUG by default)
47
    ch = logging.StreamHandler()
2✔
48
    if args.debug:
2✔
49
        logger.setLevel(logging.DEBUG)
×
50
        ch.setLevel(logging.DEBUG)
×
51
        ch.setFormatter(debug_formatter)
×
52
    else:
53
        logger.setLevel(logging.INFO)
2✔
54
        ch.setLevel(logging.INFO)
2✔
55
        ch.setFormatter(default_formatter)
2✔
56
    logger.addHandler(ch)
2✔
57
    # File handler (always on DEBUG level)
58
    # TODO: Change this to write to a rotating log handler (so that the file size
59
    # is kept constant). (mr, 2011-02-25)
60
    if args.logfile:
2✔
61
        logfile = args.logfile
×
62
        try:
×
63
            fh = logging.FileHandler(logfile, "w")
×
64
        except (OSError, IOError) as ex:
×
65
            logger.error("Could not open logfile '%s': %s %s", logfile, type(ex), ex)
×
66
        else:
67
            logger.setLevel(logging.DEBUG)
×
68
            fh.setLevel(logging.DEBUG)
×
69
            fh.setFormatter(debug_formatter)
×
70
            logger.addHandler(fh)
×
71

72

73
def conditional_decorator(dec, condition):
2✔
74
    def decorator(func):
2✔
75
        if not condition:
2✔
76
            # Return the function unchanged, not decorated.
77
            return func
2✔
78
        return dec(func)
×
79
    return decorator
2✔
80

81

82
def prefix_route(route_function, prefix='', mask='{0}{1}'):
2✔
83
    """
84
    https://stackoverflow.com/questions/18967441/add-a-prefix-to-all-flask-routes/18969161#18969161
85
    Defines a new route function with a prefix.
86
    The mask argument is a `format string` formatted with, in that order:
87
      prefix, route
88
    """
89
    def newroute(route, *args, **kwargs):
2✔
90
        """ prefix route """
UNCOV
91
        return route_function(mask.format(prefix, route), *args, **kwargs)
×
92
    return newroute
2✔
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

© 2026 Coveralls, Inc