diff --git a/.github/workflows/py_unit_tests.yml b/.github/workflows/py_unit_tests.yml index 67a36cc..6ccb063 100644 --- a/.github/workflows/py_unit_tests.yml +++ b/.github/workflows/py_unit_tests.yml @@ -46,6 +46,6 @@ jobs: if: ${{ always() }} - name: Linting with Ruff - run: ruff --output-format=github . + run: ruff check --ignore=E721,E722,E401 --output-format=github . # continue-on-error: true # need to remove this later on to catch the errors anf fail the workflow on linting errors \ No newline at end of file diff --git a/src/app_inspect.py b/src/app_inspect.py index 28a0454..3df2dad 100644 --- a/src/app_inspect.py +++ b/src/app_inspect.py @@ -140,8 +140,9 @@ def _perform_checks(self, check_type="APP_INSPECT"): try: response = requests.request("GET", "{}/{}".format( self.STATUS_CHECK_URL, request_id), headers=self.headers, data={}, timeout=TIMEOUT_MAX) - except: + except Exception as e: # continue if there is any error (specifically 10 times for timeout error) + utils.debug(f"No action needed. {e}") continue utils.info("App package status check (check_type={}) response: status_code={}, text={}".format( diff --git a/src/helpers/splunk_app_details.py b/src/helpers/splunk_app_details.py index c4393ab..2142f86 100644 --- a/src/helpers/splunk_app_details.py +++ b/src/helpers/splunk_app_details.py @@ -1,4 +1,3 @@ -import os import json import helpers.github_action_utils as utils from helpers.splunk_config_parser import SplunkConfigParser diff --git a/src/main.py b/src/main.py index a3c493b..b95c655 100644 --- a/src/main.py +++ b/src/main.py @@ -1,7 +1,6 @@ import os import shutil import sys -import re import traceback sys.path.append(os.path.dirname(__file__)) diff --git a/src/ucc_gen.py b/src/ucc_gen.py index 8e14a42..489135d 100644 --- a/src/ucc_gen.py +++ b/src/ucc_gen.py @@ -9,7 +9,7 @@ def build(): utils.info("Running ucc-gen command.") # copy folder to generate build, rather than affecting the original repo checkout - utils.execute_system_command(f"rm -rf ucc_build_dir") + utils.execute_system_command("rm -rf ucc_build_dir") shutil.copytree(GlobalVariables.ORIGINAL_REPO_DIR_NAME, "ucc_build_dir") org_ta_dir = os.path.join(GlobalVariables.ORIGINAL_REPO_DIR_NAME, GlobalVariables.APP_DIR_NAME) diff --git a/src/utilities/ucc_additional_packaging/additional_packaging.py b/src/utilities/ucc_additional_packaging/additional_packaging.py index d9cc1d8..8844104 100644 --- a/src/utilities/ucc_additional_packaging/additional_packaging.py +++ b/src/utilities/ucc_additional_packaging/additional_packaging.py @@ -77,7 +77,7 @@ def modify_original_input_py_file(addon_name, input_name): # print(f"file_content2 = {file_content}") # Update validate_input method - pattern_validate_input_fun = rf"def validate_input[\w\W]*return\n" + pattern_validate_input_fun = r"def validate_input[\w\W]*return\n" replacement_content_validate_input_fun = f"def validate_input(self, definition: smi.ValidationDefinition):\n {input_name}_handler.validate_input(self, definition)\n\n" file_content = re.sub(pattern_validate_input_fun, replacement_content_validate_input_fun, file_content) @@ -85,7 +85,7 @@ def modify_original_input_py_file(addon_name, input_name): # print(f"file_content3 = {file_content}") # Update stream_events method - pattern_stream_events_fun = rf"def stream_events[\w\W]*(?:\n\n)" + pattern_stream_events_fun = r"def stream_events[\w\W]*(?:\n\n)" replacement_content_stream_events_fun = f"def stream_events(self, inputs: smi.InputDefinition, event_writer: smi.EventWriter):\n {input_name}_handler.stream_events(self, inputs, event_writer)\n\n\n" file_content = re.sub(pattern_stream_events_fun, replacement_content_stream_events_fun, file_content) diff --git a/tests/test_splunk_app_details.py b/tests/test_splunk_app_details.py index 3a49ce9..fe9a886 100644 --- a/tests/test_splunk_app_details.py +++ b/tests/test_splunk_app_details.py @@ -85,7 +85,7 @@ def test_fetch_app_package_id_from_app_conf_valid(): [package] id = my_app ''') as file_path: - with pytest.raises(Exception) as excinfo: + with pytest.raises(Exception): app_package_id = fetch_app_package_id_from_app_conf(file_path) assert app_package_id == "my_app" diff --git a/tests/test_splunk_config_parser.py b/tests/test_splunk_config_parser.py index 64de16c..27a8b42 100644 --- a/tests/test_splunk_config_parser.py +++ b/tests/test_splunk_config_parser.py @@ -19,11 +19,11 @@ def _util_conf_path(self, file_name): def test_file_not_found(self): with self.assertRaises(Exception): - conf = SplunkConfigParser(self._util_conf_path('no_file.conf')) + SplunkConfigParser(self._util_conf_path('no_file.conf')) def test_read_config_file(self): conf = SplunkConfigParser(self._util_conf_path('read_config_file.conf')) - assert conf != None + assert conf is not None def test_get_config_sections(self): conf = SplunkConfigParser(self._util_conf_path('read_config_file.conf')) @@ -55,7 +55,7 @@ def test_parse_2_multiline_value(self): def test_invalid_config(self): with self.assertRaisesRegex(Exception, "SplunkConfigParser: Unable to parse the Splunk config file properly."): - conf = SplunkConfigParser(self._util_conf_path('invalid_config.conf')) + SplunkConfigParser(self._util_conf_path('invalid_config.conf')) def test_empty_config(self): conf = SplunkConfigParser(self._util_conf_path('empty_config.conf'))