Skip to content

Commit

Permalink
fix deepsource warnings 1
Browse files Browse the repository at this point in the history
  • Loading branch information
adriansev committed Nov 7, 2023
1 parent 5e839ef commit 90ca737
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
16 changes: 9 additions & 7 deletions alienpy/setup_logging.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
'''alienpy:: Setup logging'''
"""alienpy:: Setup logging"""

import os
import sys
import logging
from .global_vars import * # nosec PYL-W0614

from .global_vars import ALIENPY_FANCY_PRINT, TMPDIR, USER_HOME, rich_print

#############################################
### ENABLE LOGGING BEFORE ANYTHIN ELSE
#############################################
def print_out(msg: str, toLog: bool = False):


def print_out(msg: str, toLog: bool = False) -> None:
"""wrapper for print/log to stdout"""
if toLog:
logging.log(90, msg)
else:
Expand All @@ -19,7 +22,8 @@ def print_out(msg: str, toLog: bool = False):
print(msg, flush = True)


def print_err(msg: str, toLog: bool = False):
def print_err(msg: str, toLog: bool = False) -> None:
"""wrapper for print/log to stderr"""
if toLog:
logging.log(95, msg)
else:
Expand All @@ -29,9 +33,8 @@ def print_err(msg: str, toLog: bool = False):
print(msg, file = sys.stderr, flush = True)


def setup_logging(debug: bool = False, debug_file:str = f'{USER_HOME}/alien_py.log'):
def setup_logging(debug: bool = False, debug_file:str = f'{USER_HOME}/alien_py.log') -> None:
"""Setup logging machinery"""

logging.addLevelName(90, 'STDOUT')
logging.addLevelName(95, 'STDERR')

Expand Down Expand Up @@ -62,4 +65,3 @@ def setup_logging(debug: bool = False, debug_file:str = f'{USER_HOME}/alien_py.l
if __name__ == '__main__':
print('This file should not be executed!', file = sys.stderr, flush = True)
sys.exit(95)

2 changes: 1 addition & 1 deletion alienpy/wb_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from .async_tools import syncify
from .wb_async import wb_create, wb_close, wb_sendmsg, wb_sendmsg_multi, IsWbConnected
from .tools_nowb import deltat_ms_perf, deltat_us_perf, is_help, writePidFile, read_conf_file, is_my_pid, isReachable, path_readable, CreateJsonCommand, GetMeta, GetResults, PrintDict
from .tools_nowb import deltat_ms_perf, deltat_us_perf, is_help, writePidFile, read_conf_file, is_my_pid, isReachable, path_readable, CreateJsonCommand, PrintDict
from .tools_stackcmd import push2stack # , deque_pop_pos
from .connect_ssl import get_certs_names

Expand Down
1 change: 1 addition & 0 deletions alienpy/xrd_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import subprocess
import shlex
from typing import Union
import logging

from .global_vars import * # nosec PYL-W0614
from .setup_logging import print_err
Expand Down

0 comments on commit 90ca737

Please sign in to comment.