Skip to content

Commit

Permalink
flake8 docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
Nina.Hakansson committed Apr 15, 2024
1 parent 1f6f8ba commit c22870c
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 43 deletions.
6 changes: 3 additions & 3 deletions nwcsafpps_runner/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""Reading configuration settings for NWCSAF/pps runner(s).
"""
"""Reading configuration settings for NWCSAF/PPS runner(s)."""

import os
import socket
Expand All @@ -30,13 +29,14 @@


def load_config_from_file(filepath):
"""Load the yaml config from file, given the file-path"""
"""Load the yaml config from file, given the file-path."""
with open(filepath, 'r') as fp_:
config = yaml.load(fp_, Loader=yaml.FullLoader)
return config


def move_service_dict_attributes_to_top_level(options, service):
"""Mover attributes in dict service to top level."""
if service in options and isinstance(options[service], dict):
service_config = options.pop(service)
for key in service_config:
Expand Down
6 changes: 1 addition & 5 deletions nwcsafpps_runner/l1c_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""The level-1c processing tools
"""
"""The level-1c processing tools."""

import logging
from multiprocessing import Manager, Process, cpu_count
Expand Down Expand Up @@ -170,7 +169,6 @@ def _get_message_data(self, message):

def get_level1_files_from_dataset(self, level1_dataset):
"""Get the level-1 files from the dataset."""

if self.service in ['seviri-l1c']:
self.level1_files = get_seviri_level1_files_from_dataset(level1_dataset)
else:
Expand All @@ -179,7 +177,6 @@ def get_level1_files_from_dataset(self, level1_dataset):

def check_platform_name_consistent_with_service(self):
"""Check that the platform name is consistent with the service name."""

if self.platform_name.lower() not in SUPPORTED_SATELLITES.get(self.service, []):
errmsg = ("%s: Platform name not supported for this service: %s",
str(self.platform_name), self.service)
Expand All @@ -188,7 +185,6 @@ def check_platform_name_consistent_with_service(self):

def get_seviri_level1_files_from_dataset(level1_dataset):
"""Get the seviri level-1 filenames from the dataset and return as list."""

pro_files = False
epi_files = False
level1_files = []
Expand Down
3 changes: 1 addition & 2 deletions nwcsafpps_runner/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""The log handling.
"""
"""The log handling."""

import logging
import logging.config
Expand Down
8 changes: 2 additions & 6 deletions nwcsafpps_runner/message_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,18 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""Message utilities.
"""
"""Message utilities."""

import logging
import os
import socket
from urllib.parse import urlunsplit

from posttroll.message import Message

LOG = logging.getLogger(__name__)


def prepare_nwp_message(result_file, publish_topic):
"""Prepare message for NWP files."""
to_send = {}
to_send["uri"] = result_file
filename = os.path.basename(result_file)
Expand All @@ -46,7 +44,6 @@ def prepare_nwp_message(result_file, publish_topic):

def prepare_l1c_message(result_file, mda, **kwargs):
"""Prepare the output message for the level-1c file creation."""

if not result_file:
return

Expand Down Expand Up @@ -79,7 +76,6 @@ def prepare_l1c_message(result_file, mda, **kwargs):

def publish_l1c(publisher, publish_msg, publish_topic):
"""Publish the messages that l1c files are ready."""

LOG.debug('Publish topic = %s', publish_topic)
for topic in publish_topic:
msg = Message(topic, "file", publish_msg).encode()
Expand Down
15 changes: 8 additions & 7 deletions nwcsafpps_runner/publish_and_listen.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""Publisher and Listener classes for the PPS runners.
"""
"""Publisher and Listener classes for the PPS runner."""

import logging
import threading
Expand All @@ -38,18 +37,19 @@
class FileListener(threading.Thread):

def __init__(self, queue, subscribe_topics):
"""Init the file listener."""
threading.Thread.__init__(self)
self.loop = True
self.queue = queue
self.subscribe_topics = subscribe_topics

def stop(self):
"""Stops the file listener."""
"""Stop the file listener."""
self.loop = False
self.queue.put(None)

def run(self):

"""Run the file listener."""
LOG.debug("Subscribe topics = %s", str(self.subscribe_topics))
with posttroll.subscriber.Subscribe("", self.subscribe_topics, True) as subscr:

Expand All @@ -64,7 +64,7 @@ def run(self):
self.queue.put(msg)

def check_message(self, msg):

"""Check the message."""
if not msg:
return False

Expand Down Expand Up @@ -93,6 +93,7 @@ class FilePublisher(threading.Thread):
"""

def __init__(self, queue, publish_topic, **kwargs):
"""Init the file publisher."""
threading.Thread.__init__(self)
self.loop = True
self.queue = queue
Expand All @@ -107,12 +108,12 @@ def __init__(self, queue, publish_topic, **kwargs):
self.nameservers = [self.nameservers]

def stop(self):
"""Stops the file publisher."""
"""Stop the file publisher."""
self.loop = False
self.queue.put(None)

def run(self):

"""Run the file publisher."""
with Publish(self.runner_name, 0, self.publish_topic, nameservers=self.nameservers) as publisher:

while self.loop:
Expand Down
27 changes: 9 additions & 18 deletions nwcsafpps_runner/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""Utility functions for NWCSAF/pps runner(s).
"""
"""Utility functions for NWCSAF/pps runner(s)."""

import logging
import os
import shlex
Expand All @@ -47,6 +47,10 @@ class FindTimeControlFileError(Exception):
pass


class PpsRunError(Exception):
pass


PPS_OUT_PATTERN = ("S_NWC_{segment}_{orig_platform_name}_{orbit_number:05d}_" +
"{start_time:%Y%m%dT%H%M%S%f}Z_{end_time:%Y%m%dT%H%M%S%f}Z.{extention}")
PPS_OUT_PATTERN_MULTIPLE = ("S_NWC_{segment1}_{segment2}_{orig_platform_name}_{orbit_number:05d}_" +
Expand Down Expand Up @@ -131,9 +135,7 @@ def run_command(cmdstr):


def check_uri(uri):
"""Check that the provided *uri* is on the local host and return the
file path.
"""
"""Check that the provided *uri* is on the local host and return the file path."""
if isinstance(uri, (list, set, tuple)):
paths = [check_uri(ressource) for ressource in uri]
return paths
Expand All @@ -155,10 +157,6 @@ def check_uri(uri):
return url.path


class PpsRunError(Exception):
pass


def get_lvl1c_file_from_msg(msg):
"""Get level1c file from msg."""
destination = msg.data.get('destination')
Expand Down Expand Up @@ -200,7 +198,6 @@ def check_host_ok(msg):

def ready2run(msg, scene, **kwargs):
"""Check whether pps is ready to run or not."""

LOG.info("Got message: " + str(msg))
if not check_host_ok(msg):
return False
Expand Down Expand Up @@ -230,10 +227,7 @@ def terminate_process(popen_obj, scene):


def create_pps_call_command(python_exec, pps_script_name, scene):
"""Create the pps call command.
Supports PPSv2021.
"""
"""Create the pps call command."""
cmdstr = ("%s" % python_exec + " %s " % pps_script_name +
"-af %s" % scene['file4pps'])
LOG.debug("PPS call command: %s", str(cmdstr))
Expand Down Expand Up @@ -295,10 +289,7 @@ def create_xml_timestat_from_ascii(infile, pps_control_path):


def publish_pps_files(input_msg, publish_q, scene, result_files, **kwargs):
"""
Publish messages for the files provided.
"""

"""Publish messages for the files provided."""
servername = kwargs.get('servername')
station = kwargs.get('station', 'unknown')

Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""Setup for pps-runner.
"""
"""Setup for pps-runner."""
from setuptools import find_packages, setup

try:
Expand Down

0 comments on commit c22870c

Please sign in to comment.