nixos/home/emacs/doom/snippets/python-mode/salclient

22 lines
505 B
Plaintext
Raw Normal View History

# -*- mode: snippet -*-
# name: sal = SALClient(...)
# key: salclient
# --
from socket import getfqdn
from sal.client import SALClient
from sal.core.exception import AuthenticationFailed
SAL_HOST = getfqdn("sal")
SAL_BACKUP_HOST = "sal.jet.uk"
try:
sal = SALClient("https://{}".format(SAL_HOST if SAL_HOST != "sal" else SAL_BACKUP_HOST))
except ConnectionError:
sal = SALClient("https://{}".format(SAL_BACKUP_HOST))
try:
sal.list("/")
except AuthenticationFailed:
sal.authenticate()
$0