<commit_before>#!/usr/bin/env python

"""ConPaaS director: add user"""

import sys
import getpass

from cpsdirector import db, common, create_user

if __name__ == "__main__":
    db.create_all()
    try:
        email, username, password = sys.argv[1:]
        create_user(username, "", "", email, "", password, 120)

    except ValueError:
        print "\nAdd new ConPaaS user"
        email    = common.rlinput('E-mail: ')
        username = common.rlinput('Username: ')
        pprompt = lambda: (getpass.getpass(), getpass.getpass('Retype password: '))

        p1, p2 = pprompt()

        while p1 != p2:
            print('Passwords do not match. Try again')
            p1, p2 = pprompt()

        create_user(username, "", "", email, "", p1, 120)

    common.chown(common.config.get('director',
        'DATABASE_URI').replace('sqlite:///', ''), 'www-data', 'www-data')<commit_msg>conpaas-director/cpsadduser.py: do not fail if the specified user already exists<commit_after>#!/usr/bin/env python

"""ConPaaS director: add user"""

import sys
import getpass

import sqlalchemy

from cpsdirector import db, common, create_user

if __name__ == "__main__":
    db.create_all()
    try:
        email, username, password = sys.argv[1:]

    except ValueError:
        print "\nAdd new ConPaaS user"
        email    = common.rlinput('E-mail: ')
        username = common.rlinput('Username: ')
        pprompt = lambda: (getpass.getpass(), getpass.getpass('Retype password: '))

        password, p2 = pprompt()

        while password != p2:
            print('Passwords do not match. Try again')
            password, p2 = pprompt()


    try:
        create_user(username, "", "", email, "", password, 120)
    except sqlalchemy.exc.IntegrityError:
        print "User %s already present" % username

    common.chown(common.config.get('director',
        'DATABASE_URI').replace('sqlite:///', ''), 'www-data', 'www-data')
{'fraction_non_alphanumeric': 0.14618973561430793, 'fraction_numerical': 0.01088646967340591, 'mean_word_length': 2.814229249011858, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '6694044', 'n_tokens_mistral': 637, 'n_tokens_neox': 609, 'n_words': 151}