Skip to content

Commit

Permalink
Pydocstyle updates
Browse files Browse the repository at this point in the history
  • Loading branch information
PalNilsson committed Nov 13, 2023
1 parent 0605078 commit d9c3fd6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
7 changes: 4 additions & 3 deletions pilot/util/activemq.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
# Authors:
# - Paul Nilsson, [email protected], 2022-23

"""Functions for using ActiveMQ."""

import socket
import json
import random
Expand Down Expand Up @@ -101,6 +103,7 @@ def get_messages(self) -> list:
class ActiveMQ:
"""
ActiveMQ class.
Note: the class can be used for either topic or queue messages.
E.g. 'topic': '/queue/panda.pilot' or '/topic/panda.pilot'
X.509 authentication using SSL not possible since key+cert cannot easily be reached from WNs.
Expand Down Expand Up @@ -208,9 +211,7 @@ def send_message(self, message: str) -> None:
self.logger.debug('sent message')

def close_connections(self) -> None:
"""
Close all open connections.
"""
"""Close all open connections."""
for conn in self.connections:
try:
conn.disconnect()
Expand Down
30 changes: 13 additions & 17 deletions pilot/util/auxiliary.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
# Authors:
# - Paul Nilsson, [email protected], 2017-23

"""Auxiliary functions."""

import os
import re
import sys
Expand Down Expand Up @@ -50,10 +52,7 @@


def pilot_version_banner() -> None:
"""
Print a pilot version banner.
"""

"""Print a pilot version banner."""
version = f'*** PanDA Pilot version {get_pilot_version()} ***'
logger.info('*' * len(version))
logger.info(version)
Expand Down Expand Up @@ -90,16 +89,14 @@ def is_virtual_machine() -> bool:


def display_architecture_info() -> None:
"""
Display OS/architecture information from /etc/os-release.
"""
"""Display OS/architecture information from /etc/os-release."""
logger.info("architecture information:")
dump("/etc/os-release")


def get_batchsystem_jobid() -> (str, int):
"""
Identify and return the batch system job id (will be reported to the server)
Identify and return the batch system job id (will be reported to the server).
:return: batch system name (string), batch system job id (int)
"""
Expand Down Expand Up @@ -151,7 +148,7 @@ def get_globaljobid() -> str:

def get_job_scheduler_id() -> str:
"""
Get the job scheduler id from the environment variable PANDA_JSID
Get the job scheduler id from the environment variable PANDA_JSID.
:return: job scheduler id (str)
"""
Expand Down Expand Up @@ -373,7 +370,7 @@ def get_resource_name() -> str:

def get_object_size(obj: Any, seen: Any = None) -> int:
"""
Recursively find the size of any objects
Recursively find the size of any objects.
:param obj: object (Any)
:param seen: logical seen variable (Any)
Expand Down Expand Up @@ -401,9 +398,7 @@ def get_object_size(obj: Any, seen: Any = None) -> int:


def show_memory_usage() -> None:
"""
Display the current memory usage by the pilot process.
"""
"""Display the current memory usage by the pilot process."""
_, _stdout, _ = get_memory_usage(os.getpid())
_value = extract_memory_usage_value(_stdout)
logger.debug(f'current pilot memory usage:\n\n{_stdout}\n\nusage: {_value} kB\n')
Expand Down Expand Up @@ -528,7 +523,7 @@ def locate_core_file(cmd: str = '', pid: int = 0) -> str:


def get_pid_from_command(cmd: str, pattern: str = r'gdb --pid (\d+)') -> int:
"""
r"""
Identify an explicit process id in the given command.
Example:
Expand Down Expand Up @@ -567,6 +562,7 @@ def list_hardware() -> str:
def get_display_info() -> (str, str):
"""
Extract the product and vendor from the lshw command.
E.g.
product: GD 5446 [1013:B8]
vendor: Cirrus Logic [1013]
Expand Down Expand Up @@ -719,6 +715,7 @@ def get_host_name():
def grep_str(patterns: list, stdout: str) -> list:
"""
Search for the patterns in the given stdout.
For expected large stdout, better to use FileHandling::grep()
:param patterns: list of regexp patterns (list)
Expand Down Expand Up @@ -762,14 +759,13 @@ class TimeoutException(Exception):
"""Timeout exception."""

def __init__(self, message: str, timeout: int = None, *args: Any):
"""
Initialize variables.
"""
"""Initialize variables."""
self.timeout = timeout
self.message = message
self._errorCode = 1334
super(TimeoutException, self).__init__(*args)

def __str__(self):
"""Set and return the error string for string representation of the class instance."""
tmp = f' : {repr(self.args)}' if self.args else ''
return f"{self.__class__.__name__}: {self.message}, timeout={self.timeout} seconds{tmp}"

0 comments on commit d9c3fd6

Please sign in to comment.