Ensure get_password is accessing a file that exists.

pull/6/head
Konstantinos Tsakalozos 2017-06-30 20:24:35 +03:00
parent 17e19dfce6
commit cd34d8f80d
1 changed files with 2 additions and 2 deletions

View File

@ -920,9 +920,9 @@ def setup_tokens(token, username, user):
def get_password(csv_fname, user):
'''Get the password of user within the csv file provided.'''
root_cdk = '/root/cdk'
if not os.path.isdir(root_cdk):
return None
tokens_fname = os.path.join(root_cdk, csv_fname)
if not os.path.isfile(tokens_fname):
return None
with open(tokens_fname, 'r') as stream:
for line in stream:
record = line.split(',')