Skip to content

Commit

Permalink
add logger to creds_mng
Browse files Browse the repository at this point in the history
  • Loading branch information
liorf committed Mar 1, 2017
1 parent 1a16d61 commit 253d6a1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions nsot_sync/creds_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
import logging
__author__ = 'liorf'

logger = logging.getLogger(__name__)


class CredsManager:
"""
This class needs to get the filename of the credentials and a flag update_creds, if not set will be False.
"""
def __init__(self, **kwargs):
self.logger = logging.getLogger(__name__)
self.update_creds = False
self.creds_filename = ''
if kwargs is not None:
Expand All @@ -35,11 +36,11 @@ def load_creds(self):
if self.update_creds:
user = raw_input('Enter Username: ')
if user == "":
self.logger.info('No username given')
logger.info('No username given')
raise Exception("No username given")
password = getpass.getpass()
if password == "":
self.logger.info('No password given')
logger.info('No password given')
raise Exception("No password given")
with open(self.creds_filename, 'w') as f:
f.write(user + "\n")
Expand All @@ -54,14 +55,14 @@ def load_creds(self):
f.close()
return user, password
else:
self.logger.info('No user found in cache')
logger.info('No user found in cache')
user = raw_input('Enter Username: ')
if user == "":
logging.info('No username given')
raise Exception("Error: No username given")
password = getpass.getpass()
if password == "":
self.logger.info('No password given')
logger.info('No password given')
raise Exception("Error: No password given")
with open(self.creds_filename, 'w') as f:
f.write(user + "\n")
Expand Down

0 comments on commit 253d6a1

Please sign in to comment.