<commit_before># -*- coding: utf-8 -*-
import getpass

import solvebio
from solvebio.client import client, SolveAPIError
from credentials import get_credentials, delete_credentials, save_credentials


def _ask_for_credentials():
    while True:
        email = raw_input('Email address: ')
        password = getpass.getpass('Password (typing will be hidden): ')
        if email and password:
            return (email, password)
        else:
            print 'Email and password are both required.'


def login(args):
    """
    Prompt user for login information (email/password).
    Email and password are used to get the user's auth_token key.
    """
    delete_credentials()

    email, password = _ask_for_credentials()
    data = {
        'email': email,
        'password': password
    }

    try:
        response = client.request('post', '/v1/auth/token', data=data)
    except SolveAPIError as e:
        e.log_field_errors(data.keys())
        response = None

    if response:
        save_credentials(email.lower(), response['token'])
        # reset the default client's auth token
        solvebio.api_key = response['token']
        # TODO: install report
        # def post_install_report(self):
        #     data = {
        #         'hostname': platform.node(),
        #         'python_version': platform.python_version(),
        #         'python_implementation': platform.python_implementation(),
        #         'platform': platform.platform(),
        #         'architecture': platform.machine(),
        #         'processor': platform.processor(),
        #         'pyexe_build': platform.architecture()[0]
        #     }
        #     self._request('POST', '/reports/install', data=data)
        print 'You are now logged-in.'
    else:
        print 'Login failed.'


def logout(args):
    if get_credentials():
        delete_credentials()
        client.auth = None
        print 'You have been logged out.'<commit_msg>send python platform data after logging in<commit_after># -*- coding: utf-8 -*-
import getpass

import solvebio
from solvebio.client import client, SolveAPIError
from credentials import get_credentials, delete_credentials, save_credentials


def _ask_for_credentials():
    while True:
        email = raw_input('Email address: ')
        password = <PASSWORD>('Password (typing will be hidden): ')
        if email and password:
            return (email, password)
        else:
            print 'Email and password are both required.'


def _send_install_report():
    import platform
    data = {
        'hostname': platform.node(),
        'python_version': platform.python_version(),
        'python_implementation': platform.python_implementation(),
        'platform': platform.platform(),
        'architecture': platform.machine(),
        'processor': platform.processor(),
        'pyexe_build': platform.architecture()[0]
    }
    try:
        client.request('post', '/v1/reports/install', data=data)
    except:
        pass


def login(args):
    """
    Prompt user for login information (email/password).
    Email and password are used to get the user's auth_token key.
    """
    delete_credentials()

    email, password = _ask_for_credentials()
    data = {
        'email': email,
        'password': password
    }

    try:
        response = client.request('post', '/v1/auth/token', data=data)
    except SolveAPIError as e:
        e.log_field_errors(data.keys())
        response = None

    if response:
        save_credentials(email.lower(), response['token'])
        # reset the default client's auth token
        solvebio.api_key = response['token']
        _send_install_report()
        print 'You are now logged-in.'
    else:
        print 'Login failed.'


def logout(args):
    if get_credentials():
        delete_credentials()
        client.auth = None
        print 'You have been logged out.'
{'fraction_non_alphanumeric': 0.10980291783977476, 'fraction_numerical': 0.0017916560020476069, 'mean_word_length': 2.452296819787986, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1508561', 'n_tokens_mistral': 1073, 'n_tokens_neox': 1043, 'n_words': 294}