<commit_before>import json
import storj
from PyQt4 import QtCore, QtGui
from mainUI import MainUI
from qt_interfaces.storj_login_ui import Ui_Login
from utilities.account_manager import AccountManager


# Login section
class LoginUI(QtGui.QMainWindow):

    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)

        # login UI
        self.login_ui = Ui_Login()
        self.login_ui.setupUi(self)

        # Account manager
        self.login_ui.password.setEchoMode(QtGui.QLineEdit.Password)

        QtCore.QObject.connect(self.login_ui.login_bt, QtCore.SIGNAL("clicked()"), self.login)  # take login action

    def login(self):
        # take login action
        self.email = str(self.login_ui.email.text()).strip()  # get mail
        self.password = str(self.login_ui.password.text()).strip()  # get password

        self.storj_client = storj.Client(email=self.email,
                                         password=self.password)
        success = False
        # take login action - check credentials by listing keys :D
        try:
            self.storj_client.key_list()
            success = True
        except storj.exception.StorjBridgeApiError as e:
            j = json.loads(str(e))
            if j.get("error") == "Invalid email or password":
                QtGui.QMessageBox.about(self, "Warning",
                                        "Invalid email or password - access denied. "
                                        "Please check your credentials and try again!")
            else:
                QtGui.QMessageBox.about(self, "Unhandled exception", "Exception: " + str(e))

        if success:
            self.account_manager = AccountManager(self.email, self.password)  # init account manager
            self.account_manager.save_account_credentials()  # save login credentials and state
            msgBox = QtGui.QMessageBox(QtGui.QMessageBox.Information, "Success", "Successfully loged in!",
                                       QtGui.QMessageBox.Ok)
            result = msgBox.exec_()
            if result == QtGui.QMessageBox.Ok:
                self.main_ui_window = MainUI(self)
                self.main_ui_window.show()
                self.close()
                #initial_window.hide()

                # self.account_manager.get_login_state()

        # print self.storj_client.bucket_list()
        print 1
<commit_msg>add logger to login<commit_after>import json
import storj
from PyQt4 import QtCore, QtGui
from mainUI import MainUI
from qt_interfaces.storj_login_ui import Ui_Login
from utilities.account_manager import AccountManager

from utilities.log_manager import logger


# Login section
class LoginUI(QtGui.QMainWindow):

    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)

        # login UI
        self.login_ui = Ui_Login()
        self.login_ui.setupUi(self)

        # Account manager
        self.login_ui.password.setEchoMode(QtGui.QLineEdit.Password)

        QtCore.QObject.connect(self.login_ui.login_bt, QtCore.SIGNAL("clicked()"), self.login)  # take login action

    def login(self):
        # take login action
        self.email = str(self.login_ui.email.text()).strip()  # get mail
        self.password = str(self.login_ui.password.text()).strip()  # get password

        self.storj_client = storj.Client(email=self.email,
                                         password=self.password)
        success = False
        # take login action - check credentials by listing keys :D
        try:
            self.storj_client.key_list()
            success = True
        except storj.exception.StorjBridgeApiError as e:
            j = json.loads(str(e))
            if j.get("error") == "Invalid email or password":
                QtGui.QMessageBox.about(self, "Warning",
                                        "Invalid email or password - access denied. "
                                        "Please check your credentials and try again!")
            else:
                QtGui.QMessageBox.about(self, "Unhandled exception", "Exception: " + str(e))

        if success:
            self.account_manager = AccountManager(self.email, self.password)  # init account manager
            self.account_manager.save_account_credentials()  # save login credentials and state
            msgBox = QtGui.QMessageBox(QtGui.QMessageBox.Information, "Success", "Successfully loged in!",
                                       QtGui.QMessageBox.Ok)
            result = msgBox.exec_()
            if result == QtGui.QMessageBox.Ok:
                logger.info("User {} succesfully logged in".format(self.email))
                self.main_ui_window = MainUI(self)
                self.main_ui_window.show()
                self.close()
                #initial_window.hide()
                # self.account_manager.get_login_state()

        # print self.storj_client.bucket_list()
        print 1

{'fraction_non_alphanumeric': 0.09074336641685234, 'fraction_numerical': 0.0008102086287218959, 'mean_word_length': 2.0164935858277335, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '853709', 'n_tokens_mistral': 1371, 'n_tokens_neox': 1329, 'n_words': 299}