From 0fed9f8749fa92904316a3e7293267971927869b Mon Sep 17 00:00:00 2001 From: Enrique Martin Date: Thu, 10 Aug 2023 14:07:57 +0200 Subject: [PATCH] Changed some functions names and added _print_debug for all modules --- .../extras/pandoraPlugintools/agents.py | 14 +++++++++ .../extras/pandoraPlugintools/discovery.py | 30 ++++++++++++++----- .../extras/pandoraPlugintools/encryption.py | 14 +++++++++ .../extras/pandoraPlugintools/general.py | 18 +++++++++-- .../extras/pandoraPlugintools/http.py | 14 +++++++++ .../extras/pandoraPlugintools/modules.py | 14 +++++++++ .../extras/pandoraPlugintools/output.py | 13 ++++++++ .../extras/pandoraPlugintools/threads.py | 14 +++++++++ .../extras/pandoraPlugintools/transfer.py | 14 +++++++++ 9 files changed, 135 insertions(+), 10 deletions(-) diff --git a/pandora_server/extras/pandoraPlugintools/agents.py b/pandora_server/extras/pandoraPlugintools/agents.py index e97fde4628..85cfdd5ed9 100644 --- a/pandora_server/extras/pandoraPlugintools/agents.py +++ b/pandora_server/extras/pandoraPlugintools/agents.py @@ -27,6 +27,20 @@ BSD = FREEBSD or OPENBSD or NETBSD SUNOS = sys.platform.startswith(("sunos", "solaris")) AIX = sys.platform.startswith("aix") +#### +# Internal: Alias for output.print_debug function +######################################################################################### + +def _print_debug( + var = "", + print_errors: bool = False + ): + """ + Prints any list, dict, string, float or integer as a json + """ + from .output import print_debug + print_debug(var, print_errors) + #### # Set a global variable with the specified name and assigns a value to it. ######################################################################################### diff --git a/pandora_server/extras/pandoraPlugintools/discovery.py b/pandora_server/extras/pandoraPlugintools/discovery.py index f83251c2d0..60473ed13e 100644 --- a/pandora_server/extras/pandoraPlugintools/discovery.py +++ b/pandora_server/extras/pandoraPlugintools/discovery.py @@ -10,10 +10,24 @@ SUMMARY = {} INFO = "" MONITORING_DATA = [] +#### +# Internal: Alias for output.print_debug function +######################################################################################### + +def _print_debug( + var = "", + print_errors: bool = False + ): + """ + Prints any list, dict, string, float or integer as a json + """ + from .output import print_debug + print_debug(var, print_errors) + #### # Set error level to value ######################################################################################### -def set_error_level( +def set_disco_error_level( value: int = 0 ): """ @@ -29,7 +43,7 @@ def set_error_level( #### # Set fixed value to summary key ######################################################################################### -def set_summary_value( +def set_disco_summary_value( key: str = "", value = None ): @@ -47,7 +61,7 @@ def set_summary_value( #### # Add value to summary key ######################################################################################### -def add_summary_value( +def add_disco_summary_value( key: str = "", value = None ): @@ -70,7 +84,7 @@ def add_summary_value( #### # Set fixed value to info ######################################################################################### -def set_info_value( +def set_disco_info_value( value: str = "" ): """ @@ -86,7 +100,7 @@ def set_info_value( #### # Add data to info ######################################################################################### -def add_info_value( +def add_disco_info_value( value: str = "" ): """ @@ -102,7 +116,7 @@ def add_info_value( #### # Set fixed value to monitoring data ######################################################################################### -def set_monitoring_data( +def set_disco_monitoring_data( data: list = [] ): """ @@ -115,7 +129,7 @@ def set_monitoring_data( #### # Add value to monitoring data ######################################################################################### -def add_monitoring_data( +def add_disco_monitoring_data( data: dict = {} ): """ @@ -128,7 +142,7 @@ def add_monitoring_data( #### # Print JSON output and exit script ######################################################################################### -def print_output(): +def disco_output(): """ Prints the JSON output and exits the script. diff --git a/pandora_server/extras/pandoraPlugintools/encryption.py b/pandora_server/extras/pandoraPlugintools/encryption.py index af43b2aca3..4b6408c120 100644 --- a/pandora_server/extras/pandoraPlugintools/encryption.py +++ b/pandora_server/extras/pandoraPlugintools/encryption.py @@ -18,6 +18,20 @@ from binascii import unhexlify _PASSWORD = "default_salt" +#### +# Internal: Alias for output.print_debug function +######################################################################################### + +def _print_debug( + var = "", + print_errors: bool = False + ): + """ + Prints any list, dict, string, float or integer as a json + """ + from .output import print_debug + print_debug(var, print_errors) + #### # Internal use only: Get AES cipher ######################################################################################### diff --git a/pandora_server/extras/pandoraPlugintools/general.py b/pandora_server/extras/pandoraPlugintools/general.py index 8a097f462a..8c85cd4bc7 100644 --- a/pandora_server/extras/pandoraPlugintools/general.py +++ b/pandora_server/extras/pandoraPlugintools/general.py @@ -291,6 +291,20 @@ _ENT2CHR = { # Construct the character to entity mapping. _CHR2ENT = {v: "&" + k + ";" for k, v in _ENT2CHR.items()} +#### +# Internal: Alias for output.print_debug function +######################################################################################### + +def _print_debug( + var = "", + print_errors: bool = False + ): + """ + Prints any list, dict, string, float or integer as a json + """ + from .output import print_debug + print_debug(var, print_errors) + #### # Convert the input_string encoded in html entity to clear char string. ######################################################################################### @@ -367,8 +381,8 @@ def generate_md5( ######################################################################################### def now( - print_flag: bool = False, - utimestamp: bool = False + utimestamp: bool = False, + print_flag: bool = False ) -> str: """ Returns time in yyyy/mm/dd HH:MM:SS format by default. Use 1 as an argument diff --git a/pandora_server/extras/pandoraPlugintools/http.py b/pandora_server/extras/pandoraPlugintools/http.py index a4d0e38efe..1ababef7f5 100644 --- a/pandora_server/extras/pandoraPlugintools/http.py +++ b/pandora_server/extras/pandoraPlugintools/http.py @@ -3,6 +3,20 @@ from requests.auth import HTTPBasicAuth from requests.auth import HTTPDigestAuth from requests.sessions import Session +#### +# Internal: Alias for output.print_debug function +######################################################################################### + +def _print_debug( + var = "", + print_errors: bool = False + ): + """ + Prints any list, dict, string, float or integer as a json + """ + from .output import print_debug + print_debug(var, print_errors) + #### # Auth URL session ######################################################################################### diff --git a/pandora_server/extras/pandoraPlugintools/modules.py b/pandora_server/extras/pandoraPlugintools/modules.py index 8a5be45812..091c6d136c 100644 --- a/pandora_server/extras/pandoraPlugintools/modules.py +++ b/pandora_server/extras/pandoraPlugintools/modules.py @@ -1,3 +1,17 @@ +#### +# Internal: Alias for output.print_debug function +######################################################################################### + +def _print_debug( + var = "", + print_errors: bool = False + ): + """ + Prints any list, dict, string, float or integer as a json + """ + from .output import print_debug + print_debug(var, print_errors) + #### # Init module template ######################################################################################### diff --git a/pandora_server/extras/pandoraPlugintools/output.py b/pandora_server/extras/pandoraPlugintools/output.py index d4c9bd5edc..1488d548f6 100644 --- a/pandora_server/extras/pandoraPlugintools/output.py +++ b/pandora_server/extras/pandoraPlugintools/output.py @@ -2,6 +2,19 @@ import sys import os import json +#### +# Internal: Alias for output.print_debug function +######################################################################################### + +def _print_debug( + var = "", + print_errors: bool = False + ): + """ + Prints any list, dict, string, float or integer as a json + """ + print_debug(var, print_errors) + #### # Prints message in stdout ######################################################################################### diff --git a/pandora_server/extras/pandoraPlugintools/threads.py b/pandora_server/extras/pandoraPlugintools/threads.py index 0dcaf7d72a..2b83879b85 100644 --- a/pandora_server/extras/pandoraPlugintools/threads.py +++ b/pandora_server/extras/pandoraPlugintools/threads.py @@ -11,6 +11,20 @@ _MANAGER = Manager() _SHARED_DICT = _MANAGER.dict() _SHARED_DICT_LOCK = _MANAGER.Lock() +#### +# Internal: Alias for output.print_debug function +######################################################################################### + +def _print_debug( + var = "", + print_errors: bool = False + ): + """ + Prints any list, dict, string, float or integer as a json + """ + from .output import print_debug + print_debug(var, print_errors) + #### # Internal use only: Run a given function in a thread ######################################################################################### diff --git a/pandora_server/extras/pandoraPlugintools/transfer.py b/pandora_server/extras/pandoraPlugintools/transfer.py index 9e9a121da4..66d177f55e 100644 --- a/pandora_server/extras/pandoraPlugintools/transfer.py +++ b/pandora_server/extras/pandoraPlugintools/transfer.py @@ -20,6 +20,20 @@ GLOBAL_VARIABLES = { 'tentacle_extra_opts' : '' } +#### +# Internal: Alias for output.print_debug function +######################################################################################### + +def _print_debug( + var = "", + print_errors: bool = False + ): + """ + Prints any list, dict, string, float or integer as a json + """ + from .output import print_debug + print_debug(var, print_errors) + #### # Set a global variable with the specified name and assigns a value to it. #########################################################################################