main.main()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 21
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 21
rs 9.9
c 0
b 0
f 0
cc 1
nop 0
1
import logging
2
from logging.handlers import RotatingFileHandler
3
from multiprocessing import Process
4
import meter
5
import offlinemeter
6
import virtualmeter
7
8
9
def main():
10
    """main"""
11
    # create logger
12
    logger = logging.getLogger('myems-normalization')
13
    # specifies the lowest-severity log message a logger will handle,
14
    # where debug is the lowest built-in severity level and critical is the highest built-in severity.
15
    # For example, if the severity level is INFO, the logger will handle only INFO, WARNING, ERROR, and CRITICAL
16
    # messages and will ignore DEBUG messages.
17
    logger.setLevel(logging.ERROR)
18
    # create file handler which logs messages
19
    fh = RotatingFileHandler('myems-normalization.log', maxBytes=1024*1024, backupCount=1)
20
    # create formatter and add it to the handlers
21
    formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
22
    fh.setFormatter(formatter)
23
    # add the handlers to logger
24
    logger.addHandler(fh)
25
26
    # calculate energy consumption in hourly period
27
    Process(target=meter.calculate_hourly, args=(logger,)).start()
28
    Process(target=virtualmeter.calculate_hourly, args=(logger,)).start()
29
    Process(target=offlinemeter.calculate_hourly, args=(logger,)).start()
30
31
32
if __name__ == '__main__':
33
    main()
34
35
36