Refactor for consistent string quoting and formatting
Some checks failed
Ansible Lint Check / check-ansible (push) Successful in 5s
Nix Format Check / check-format (push) Successful in 1m14s
Python Lint Check / check-python (push) Failing after 7s

This commit is contained in:
2025-09-23 13:53:29 +00:00
parent 2e5a06e9d5
commit 40063cfe6b
4 changed files with 59 additions and 32 deletions

View File

@@ -5,23 +5,33 @@ import sys
import subprocess
# Add the helpers directory to the path
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'helpers'))
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "helpers"))
from functions import printfe
def get_borg_passphrase():
"""Get Borg passphrase from 1Password"""
try:
result = subprocess.run(
["op", "item", "get", "Borg Backup", "--vault=Dotfiles", "--fields=password", "--reveal"],
[
"op",
"item",
"get",
"Borg Backup",
"--vault=Dotfiles",
"--fields=password",
"--reveal",
],
capture_output=True,
text=True,
check=True
check=True,
)
return result.stdout.strip()
except subprocess.CalledProcessError:
printfe("red", "Error: Failed to retrieve Borg passphrase from 1Password")
return None
def main():
"""Generate export commands for Borg environment variables"""
args = sys.argv[1:] if len(sys.argv) > 1 else []
@@ -38,7 +48,7 @@ def main():
f'export BORG_CACHE_DIR="/home/menno/.config/borg/cache"',
f'export BORG_CONFIG_DIR="/home/menno/.config/borg/config"',
f'export BORG_SECURITY_DIR="/home/menno/.config/borg/security"',
f'export BORG_KEYS_DIR="/home/menno/.config/borg/keys"'
f'export BORG_KEYS_DIR="/home/menno/.config/borg/keys"',
]
# Check if we're being eval'd (no arguments and stdout is a pipe)
@@ -77,5 +87,6 @@ def main():
return 0
if __name__ == "__main__":
sys.exit(main())