-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/76-dry-run-error
- Loading branch information
Showing
35 changed files
with
692 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: pre-commit | ||
name: py:pre-commit | ||
|
||
on: | ||
pull_request: | ||
|
@@ -11,5 +11,5 @@ jobs: | |
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v3 | ||
- run: python -m pip install .[tests] | ||
- run: pip install .[tests] | ||
- uses: pre-commit/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: py:test | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
codeql-analysis: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Set up Python | ||
id: setup-python | ||
uses: actions/setup-python@v3 | ||
- name: Get the Python path | ||
id: get-python-path | ||
run: echo "python-path=`which python`" | ||
- name: Install dependencies | ||
run: |- | ||
pip install -r ./requirements.txt | ||
pip install pylint --upgrade | ||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v3 | ||
with: | ||
languages: python | ||
queries: security-extended | ||
- name: Perform CodeQL analysis | ||
env: | ||
CODEQL_PYTHON: ${{ steps.get-python-path.outputs.python-path }} | ||
uses: github/codeql-action/analyze@v3 | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [ "3.9", "3.10", "3.11", "3.12" ] | ||
|
||
steps: | ||
- name: Checkout commit | ||
uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: |- | ||
pip install -r ./requirements.txt | ||
- name: Execute tests | ||
run: pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/env bash | ||
|
||
# Check if a version argument is provided | ||
if [ $# -eq 1 ]; then | ||
RADOSLIB_VERSION="$1" | ||
else | ||
# Default version if no argument is provided | ||
RADOSLIB_VERSION="2.0.0" | ||
fi | ||
|
||
# Get the location of the installed rados library | ||
GENERAL_LIB_LOCATION=$(pip show rados | grep -oP "(?<=Location: ).*") | ||
|
||
# Get the installed version of the rados library | ||
RADOSLIB_INSTALLED_VERSION=$(pip show rados | grep Version | awk '{print $2}') | ||
|
||
# Check if the rados library is installed | ||
if [ -z "$GENERAL_LIB_LOCATION" ]; then | ||
echo -e "\033[0;31mERROR: 'rados' library not found. Please make sure it's installed.\033[0m" | ||
exit 1 | ||
fi | ||
|
||
# Check if the installed version matches the expected version | ||
if [ "$RADOSLIB_INSTALLED_VERSION" != "$RADOSLIB_VERSION" ]; then | ||
echo -e "\033[0;31mERROR: 'rados' library version $RADOSLIB_INSTALLED_VERSION does not match the expected version $RADOSLIB_VERSION.\033[0m" | ||
exit 1 | ||
else | ||
echo -e "\033[0;32m'rados' library version $RADOSLIB_INSTALLED_VERSION is correct.\033[0m" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,67 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import sys | ||
import argparse | ||
from argparse import ArgumentParser | ||
from typing import Any, Dict | ||
from .modules import load_modules | ||
from .modules.machine import Machine | ||
from .modules.module import ModuleHandler | ||
from .logger import configure_logging, get_logger | ||
from .yaml import load_config | ||
|
||
|
||
def main() -> None: | ||
def parse_args(args: list[str]) -> argparse.Namespace: | ||
# Putting args-parser in seperate function to make this testable | ||
arg_parser = ArgumentParser("Rookify") | ||
|
||
# --dry-run option | ||
arg_parser.add_argument("--dry-run", action="store_true", dest="dry_run_mode") | ||
args = arg_parser.parse_args() | ||
|
||
arg_parser.add_argument( | ||
"--show-states", | ||
action="store_true", | ||
dest="show_states", | ||
help="Show states of the modules.", | ||
) | ||
|
||
return arg_parser.parse_args(args) | ||
|
||
|
||
def main() -> None: | ||
args = parse_args(sys.argv[1:]) | ||
|
||
# Load configuration file | ||
try: | ||
config = load_config("config.yaml") | ||
config: Dict[str, Any] = load_config("config.yaml") | ||
except FileNotFoundError as err: | ||
raise SystemExit(f"Could not load config: {err}") | ||
|
||
# Configure logging | ||
try: | ||
configure_logging(config["logging"]) | ||
if args.show_states is True: | ||
configure_logging( | ||
{"level": "ERROR", "format": {"renderer": "console", "time": "iso"}} | ||
) | ||
else: | ||
configure_logging(config["logging"]) | ||
except Exception as e: | ||
raise SystemExit(f"Error configuring logging: {e}") | ||
|
||
# Get Logger | ||
log = get_logger() | ||
log.debug("Executing Rookify") | ||
|
||
log.info("Executing Rookify ...") | ||
|
||
machine = Machine(config["general"].get("machine_pickle_file")) | ||
|
||
load_modules(machine, config) | ||
|
||
machine.execute(args.dry_run_mode) | ||
if args.show_states is True: | ||
ModuleHandler.show_states(machine, config) | ||
else: | ||
machine.execute(dry_run_mode=args.dry_run_mode) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.