'Logs in user'

def login(self):

    loginpage = 'http://rutracker.org/forum/login.php'
    post_params = {'login_username': headphones.CONFIG.RUTRACKER_USER, 'login_password': headphones.CONFIG.RUTRACKER_PASSWORD, 'login': '\xc2\xf5\xee\xe4'}
    logger.info('Attempting    to    log    in    to    rutracker...')
    try:
        r = self.session.post(loginpage, data=post_params, timeout=self.timeout, allow_redirects=False)
        if (not self.has_bb_session_cookie(r)):
            time.sleep(10)
            if headphones.CONFIG.RUTRACKER_COOKIE:
                logger.info('Attempting    to    log    in    using    predefined    cookie...')
                r = self.session.post(loginpage, data=post_params, timeout=self.timeout, allow_redirects=False, cookies={'bb_session': headphones.CONFIG.RUTRACKER_COOKIE})
            else:
                r = self.session.post(loginpage, data=post_params, timeout=self.timeout, allow_redirects=False)
        if self.has_bb_session_cookie(r):
            self.loggedin = True
            logger.info('Successfully    logged    in    to    rutracker')
        else:
            logger.error('Could    not    login    to    rutracker,    credentials    maybe    incorrect,    site    is    down    or    too    many    attempts.    Try    again    later')
            self.loggedin = False
        return self.loggedin
    except Exception as e:
        logger.error(('Unknown    error    logging    in    to    rutracker:    %s' % e))
        self.loggedin = False
        return self.loggedin
