<commit_before>#!python
# -*- coding: utf-8 -*-

#
# Copyright (c) 2011-2015 Genestack Limited
# All Rights Reserved
# THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF GENESTACK LIMITED
# The copyright notice above does not evidence any
# actual or intended publication of such source code.
#
from argparse import ArgumentParser

import os
import re
from getpass import getpass
from genestack import GenestackException, get_connection
from genestack.GenestackShell import GenestackShell, Command
from genestack.settings import DEFAULT_HOST, User, config


def ask_host():
    host = raw_input('host [%s]: ' % DEFAULT_HOST).strip()
    return host or DEFAULT_HOST


def ask_alias(existed):
    expression = re.compile('[A-z0-9_@\-]+$')

    print 'Please input alias. (Alias can contain: letters (a-Z), digit (0-9), at (@), underscore (_), minus (-))'
    while True:
        alias = raw_input('alias: ').strip()
        if not alias:
            print 'Alias cannot be empty.'
            continue
        if not expression.match(alias):
            print 'Restricted symbols message'
            continue
        if alias in existed:
            print 'Alias must be unique.'
            continue
        return alias


def ask_email_and_password(host, alias=None):
    print 'Please input your email and password for %s' % host
    user_login = None
    while True:
        if user_login:
            res = raw_input('Please specify your user login(email) [%s]: ' % user_login).strip()
            if res:
                user_login = res
        else:
            user_login = raw_input('Please specify your user login(email): ').strip()
            if not user_login:
                print 'Login cannot be empty.'
                continue
        user_password = getpass('Please specify your password for %s: ' % user_login)
        if not user_password:
            print 'Password cannot be empty'
            continue

        if not user_login or not user_password:
            print
            continue
        user = User(user_login, host=host, password=<PASSWORD>, alias=alias)
        try:
            connection = user.get_connection()
            break
        except GenestackException:
            print 'Your username or password was incorrect. Please try again.'
    return connection, user


class AddUser(Command):
    COMMAND = 'add'
    DESCRIPTION = 'Add new user.'
    OFFLINE = True

    def run(self):
        alias = ask_alias(config.users.keys())
        host = ask_host()
        _, user = ask_email_and_password(host, alias=alias)
        config.add_user(user)
        config.save()


def select_user(users, selected=None):
    user_list = users.values()<commit_msg>Add print on add user command.<commit_after>#!python
# -*- coding: utf-8 -*-

#
# Copyright (c) 2011-2015 Genestack Limited
# All Rights Reserved
# THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF GENESTACK LIMITED
# The copyright notice above does not evidence any
# actual or intended publication of such source code.
#
from argparse import ArgumentParser

import os
import re
from getpass import getpass
from genestack import GenestackException, get_connection
from genestack.GenestackShell import GenestackShell, Command
from genestack.settings import DEFAULT_HOST, User, config


def ask_host():
    host = raw_input('host [%s]: ' % DEFAULT_HOST).strip()
    return host or DEFAULT_HOST


def ask_alias(existed):
    expression = re.compile('[A-z0-9_@\-]+$')

    print 'Please input alias. (Alias can contain: letters (a-Z), digit (0-9), at (@), underscore (_), minus (-))'
    while True:
        alias = raw_input('alias: ').strip()
        if not alias:
            print 'Alias cannot be empty.'
            continue
        if not expression.match(alias):
            print 'Restricted symbols message'
            continue
        if alias in existed:
            print 'Alias must be unique.'
            continue
        return alias


def ask_email_and_password(host, alias=None):
    print 'Please input your email and password for %s' % host
    user_login = None
    while True:
        if user_login:
            res = raw_input('Please specify your user login(email) [%s]: ' % user_login).strip()
            if res:
                user_login = res
        else:
            user_login = raw_input('Please specify your user login(email): ').strip()
            if not user_login:
                print 'Login cannot be empty.'
                continue
        user_password = getpass('Please specify your password for %s: ' % user_login)
        if not user_password:
            print 'Password cannot be empty'
            continue

        if not user_login or not user_password:
            print
            continue
        user = User(user_login, host=host, password=<PASSWORD>, alias=alias)
        try:
            connection = user.get_connection()
            break
        except GenestackException:
            print 'Your username or password was incorrect. Please try again.'
    return connection, user


class AddUser(Command):
    COMMAND = 'add'
    DESCRIPTION = 'Add new user.'
    OFFLINE = True

    def run(self):
        alias = ask_alias(config.users.keys())
        host = ask_host()
        _, user = ask_email_and_password(host, alias=alias)
        config.add_user(user)
        config.save()
        print "User %s created" % user.alias


def select_user(users, selected=None):
    user_list = users.values()
{'fraction_non_alphanumeric': 0.08800880088008801, 'fraction_numerical': 0.004767143381004767, 'mean_word_length': 2.413642052565707, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1037339', 'n_tokens_mistral': 1521, 'n_tokens_neox': 1466, 'n_words': 513}