forked from cerc-io/stack-orchestrator
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code. Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint), .pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run hooks (mypy, ansible-lint). Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408), ~13 mypy type errors, 11 ansible-lint violations, and ruff-format across all Python files including stack-orchestrator subtree. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
7f12270939
commit
fdde3be5c8
52 files changed
+692
-1221
No files matched your search
+6
-17
@@ -2,12 +2,11 @@
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import random
|
||||
import sys
|
||||
from subprocess import Popen
|
||||
|
||||
import psycopg
|
||||
import random
|
||||
|
||||
from subprocess import Popen
|
||||
from fabric import Connection
|
||||
|
||||
|
||||
@@ -27,27 +26,19 @@ def dump_src_db_to_file(db_host, db_port, db_user, db_password, db_name, file_na
|
||||
def establish_ssh_tunnel(ssh_host, ssh_port, ssh_user, db_host, db_port):
|
||||
local_port = random.randint(11000, 12000)
|
||||
conn = Connection(host=ssh_host, port=ssh_port, user=ssh_user)
|
||||
fw = conn.forward_local(
|
||||
local_port=local_port, remote_port=db_port, remote_host=db_host
|
||||
)
|
||||
fw = conn.forward_local(local_port=local_port, remote_port=db_port, remote_host=db_host)
|
||||
return conn, fw, local_port
|
||||
|
||||
|
||||
def load_db_from_file(db_host, db_port, db_user, db_password, db_name, file_name):
|
||||
connstr = "host=%s port=%s user=%s password=%s sslmode=disable dbname=%s" % (
|
||||
db_host,
|
||||
db_port,
|
||||
db_user,
|
||||
db_password,
|
||||
db_name,
|
||||
)
|
||||
connstr = f"host={db_host} port={db_port} user={db_user} password={db_password} sslmode=disable dbname={db_name}"
|
||||
with psycopg.connect(connstr) as conn:
|
||||
with conn.cursor() as cur:
|
||||
print(
|
||||
f"Importing from {file_name} to {db_host}:{db_port}/{db_name}... ",
|
||||
end="",
|
||||
)
|
||||
cur.execute(open(file_name, "rt").read())
|
||||
cur.execute(open(file_name).read())
|
||||
print("DONE")
|
||||
|
||||
|
||||
@@ -60,9 +51,7 @@ if __name__ == "__main__":
|
||||
parser.add_argument("--src-dbpw", help="DB password", required=True)
|
||||
parser.add_argument("--src-dbname", help="dbname", default="keycloak")
|
||||
|
||||
parser.add_argument(
|
||||
"--dst-file", help="Destination filename", default="keycloak-mirror.sql"
|
||||
)
|
||||
parser.add_argument("--dst-file", help="Destination filename", default="keycloak-mirror.sql")
|
||||
|
||||
parser.add_argument("--live-import", help="run the import", action="store_true")
|
||||
|
||||
|
||||
Reference in new issue
Block a user