-
Notifications
You must be signed in to change notification settings - Fork 9
/
credentials.py
28 lines (26 loc) · 1.07 KB
/
credentials.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
'''
-------------------------------------------------------------------------------
This function loads the credentials from a CSV file for connecting to your
devices. Will hopefully become an *option* in the future instead of the only
one supported.
-------------------------------------------------------------------------------
'''
import csv
import os.path
import getpass
#Read in the credentials from file
def cred_csv(filename="credentials.csv"):
"""Check for existence of credentials file, read data if True, else ask for it manually"""
if os.path.isfile(filename) is True:
with open(filename, mode='r') as credfile:
reader = csv.DictReader(credfile)
for row in reader:
username = row['username']
password = row['password']
secret = row['secret']
return (username, password, secret)
else:
username = input("Username? ")
password = getpass.getpass("Password? ")
secret = getpass.getpass("Enable Password? ")
return (username, password, secret)