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

pytroll / pytroll-pps-runner / 9282584827

29 May 2024 08:14AM UTC coverage: 75.907% (+1.0%) from 74.884%
9282584827

Pull #62

github

web-flow
Merge e7a399b31 into 311997dcf
Pull Request #62: PPS product and level1c collector

389 of 557 branches covered (69.84%)

Branch coverage included in aggregate %.

100 of 135 new or added lines in 6 files covered. (74.07%)

19 existing lines in 2 files now uncovered.

1473 of 1896 relevant lines covered (77.69%)

3.11 hits per line

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

0.0
/nwcsafpps_runner/pps_collector_lib.py
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3

4
# Copyright (c) 2018 - 2021 Pytroll Developers
5

6
# Author(s):
7

8
#   Nina Hakansson <Firstname.Lastname at smhi.se>
9

10
# This program is free software: you can redistribute it and/or modify
11
# it under the terms of the GNU General Public License as published by
12
# the Free Software Foundation, either version 3 of the License, or
13
# (at your option) any later version.
14

15
# This program is distributed in the hope that it will be useful,
16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
# GNU General Public License for more details.
19

20
# You should have received a copy of the GNU General Public License
21
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
22

23

NEW
24
import signal
×
NEW
25
import logging
×
26

NEW
27
from contextlib import closing, suppress
×
NEW
28
from posttroll.publisher import create_publisher_from_dict_config
×
NEW
29
from posttroll.subscriber import Subscribe
×
NEW
30
from nwcsafpps_runner.config import get_config
×
31

NEW
32
from nwcsafpps_runner.message_utils import (publish_l1c,
×
33
                                            prepare_pps_collector_message)
34

NEW
35
LOG = logging.getLogger(__name__)
×
NEW
36
LOOP = True
×
37

38

NEW
39
def _run_subscribe_publisher(subscriber, publisher, options):
×
40
    """The posttroll subscribe/publisher runner."""
NEW
41
    def signal_handler(sig, frame):
×
NEW
42
        LOG.warning('You pressed Ctrl+C!')
×
43
        global LOOP
NEW
44
        LOOP = False
×
45

NEW
46
    signal.signal(signal.SIGINT, signal_handler)
×
47

NEW
48
    while LOOP:
×
NEW
49
        for msg in subscriber.recv():
×
NEW
50
            LOG.debug(
×
51
                "Received message data = %s", msg)
NEW
52
            pub_msg = prepare_pps_collector_message(msg, options)
×
NEW
53
            publish_l1c(publisher, pub_msg, publish_topic=[options["publish_topic"]], msg_type="dataset")
×
NEW
54
            LOG.info("L1c and PPS products collected.")
×
55

NEW
56
def pps_collector_runner(config_file):
×
57
    """The live runner for collecting the NWCSAF/PPS l1c and lvl2 products."""
NEW
58
    LOG.info("Start the NWCSAF/PPS products and level-1c collector runner")
×
59
    
NEW
60
    options = get_config(config_file)
×
NEW
61
    settings = {"name": 'pps-collector-runner',
×
62
                "nameservers": False,
63
                "port": options.get("publish_port", 3002)}
NEW
64
    with Subscribe('', options["subscribe_topics"], True) as sub:
×
NEW
65
        with closing(create_publisher_from_dict_config(settings)) as pub:
×
NEW
66
            pub.start()
×
NEW
67
            _run_subscribe_publisher(sub, pub, options)
×
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