Skip to content

Commit 85df6c9

Browse files
author
Dominik Neise
authored
Merge pull request #30 from fact-project/environ_password
Read password from env if there
2 parents 98b7018 + 5580273 commit 85df6c9

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

fact/credentials/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
from functools import lru_cache
2-
try:
3-
from configparser import SafeConfigParser
4-
except ImportError:
5-
from ConfigParser import SafeConfigParser
2+
from configparser import SafeConfigParser
63
from getpass import getpass
74
from simplecrypt import decrypt
85
from io import StringIO
96
from pkg_resources import resource_stream
107
from sqlalchemy import create_engine
118
import socket
9+
import os
1210

1311

1412
__all__ = ['get_credentials', 'create_factdb_engine']
@@ -37,9 +35,12 @@ def get_credentials():
3735
3836
use get_credentials().get(group, element) to retrieve elements
3937
'''
38+
if 'FACT_PASSWORD' in os.environ:
39+
passwd = os.environ['FACT_PASSWORD']
40+
else:
41+
passwd = getpass('Please enter the current, universal FACT password: ')
42+
4043
with resource_stream('fact', 'credentials/credentials.encrypted') as f:
41-
print('Please enter the current, universal FACT password')
42-
passwd = getpass()
4344
decrypted = decrypt(passwd, f.read()).decode('utf-8')
4445

4546
config = SafeConfigParser()

0 commit comments

Comments
 (0)