def get_fernet():
"""
Deferred load of Fernet key.
This function could fail either because Cryptography is not installed
or because the Fernet key is invalid.
:return: Fernet object
:raises: AirflowException if there's a problem trying to load Fernet
"""
try:
from cryptography.fernet import Fernet
except:
raise AirflowException('Failed to import Fernet, it may not be installed')
try:
return Fernet(configuration.get('core', 'FERNET_KEY').encode('utf-8'))
except ValueError as ve:
raise AirflowException("Could not create Fernet object: {}".format(ve))
评论列表
文章目录