diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bf4fd6c9bedc45c740ca97bd71e995098c94536c..a2943f44e19b2f07d020e28b8919bcfcc9ac59c6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,7 +6,7 @@ include: file: templates/python.yml variables: - SKIP_PYPI_UPLOAD: !!str true + SKIP_PYPI_UPLOAD: 'true' build-wheel: extends: .python3-build @@ -88,7 +88,7 @@ release: image: registry.gitlab.com/gitlab-org/release-cli:latest tags: [host01.shore.co.il] script: - - !!str true + - 'true' only: - tags needs: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c182dc40b71fc042d28b73b0a92ae0c7f2624a51..f9c600456991cc7f57258684730b39a6128c8851 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,48 +1,75 @@ --- repos: - - repo: https://github.com/pre-commit/pre-commit-hooks + - repo: https://github.com/pre-commit/pre-commit-hooks.git rev: v4.0.1 hooks: - - id: check-executables-have-shebangs + - id: check-added-large-files - id: check-merge-conflict - id: check-toml + - id: detect-private-key + - id: end-of-file-fixer - id: trailing-whitespace + exclude: \.diff$ - - repo: https://github.com/Yelp/detect-secrets + - repo: https://github.com/codespell-project/codespell.git + rev: v2.1.0 + hooks: + - id: codespell + + - repo: https://github.com/Yelp/detect-secrets.git rev: v1.1.0 hooks: - id: detect-secrets - - repo: https://github.com/codespell-project/codespell.git - rev: v2.1.0 + - repo: https://gitlab.com/devopshq/gitlab-ci-linter.git + rev: v1.0.2 hooks: - - id: codespell + - id: gitlab-ci-linter + args: + - "--server" + - https://git.shore.co.il - - repo: https://github.com/adrienverge/yamllint - rev: v1.26.1 + - repo: https://git.shore.co.il/nimrod/yamltool.git + rev: v0.1.2 + hooks: + - id: yamltool + + - repo: https://github.com/adrienverge/yamllint.git + rev: v1.26.3 hooks: - id: yamllint - - repo: https://github.com/ambv/black - rev: 21.6b0 + - repo: https://git.shore.co.il/nimrod/pre-commit-hooks.git + rev: v0.2.0 hooks: - - id: black - args: - - | - --line-length=79 + - id: poetry-check - - repo: https://github.com/Lucas-C/pre-commit-hooks-markup + - repo: https://github.com/Lucas-C/pre-commit-hooks-markup.git rev: v1.0.1 hooks: - id: rst-linter - repo: https://github.com/myint/rstcheck.git - rev: 3f92957478422df87bd730abde66f089cc1ee19b # pragma: allowlist secret + rev: master hooks: - id: rstcheck - - repo: https://github.com/PyCQA/prospector - rev: 1.3.1 + - repo: https://github.com/ambv/black.git + rev: 21.10b0 + hooks: + - id: black + args: + - | + --line-length=79 + + - repo: https://github.com/PyCQA/isort + rev: 5.10.1 + hooks: + - id: isort + args: ["--filter-files", "--profile", "black"] + + - repo: https://github.com/PyCQA/prospector.git + rev: 1.6.0 hooks: - id: prospector args: @@ -67,7 +94,7 @@ repos: additional_dependencies: - bandit - pyroma - exclude: ^tests/.* + exclude: tests - repo: https://gitlab.com/pycqa/flake8.git rev: 3.9.2 @@ -79,36 +106,7 @@ repos: additional_dependencies: - flake8-bugbear - - repo: https://gitlab.com/devopshq/gitlab-ci-linter - rev: v1.0.3 - hooks: - - id: gitlab-ci-linter - args: - - "--server" - - https://git.shore.co.il - - - - repo: https://github.com/timothycrosley/isort - rev: 5.9.1 - hooks: - - id: isort - additional_dependencies: - - toml - - repo: https://github.com/asottile/pyupgrade rev: v2.23.2 hooks: - id: pyupgrade - - - repo: local - hooks: - - id: poetry check - name: poetry check - language: system - entry: poetry - args: [check] - description: Checks pyproject.toml - always_run: true - pass_filenames: false - types: [toml] - files: pyproject\.toml diff --git a/mnpw/nagios.py b/mnpw/nagios.py index a3e96c535ce391357ff01a59cd7ecfabb26bdf8e..e3afca09069726cbffe5796d9a23b4d6e23717eb 100644 --- a/mnpw/nagios.py +++ b/mnpw/nagios.py @@ -158,10 +158,10 @@ class Check: timeout=timeout, universal_newlines=True, ) - except FileNotFoundError: - raise RuntimeError(f"Command {self.Command} not found.") - except subprocess.TimeoutExpired: - raise RuntimeError("Timeout exceeded.") + except FileNotFoundError as ex: + raise RuntimeError(f"Command {self.Command} not found.") from ex + except subprocess.TimeoutExpired as ex: + raise RuntimeError("Timeout exceeded.") from ex self.ExitCode = proc.returncode logging.info(f"Exit code is {self.ExitCode}.") self._stdout = proc.stdout