view @ 14:a31493bc7952 draft

"planemo upload for repository commit 7f274d9deece87f6837ffb0a22d9231671be4542"
author gga
date Wed, 19 Aug 2020 06:57:08 -0400
parents bc2b80fc7e30
line wrap: on
line source

#!/usr/bin/env python
from __future__ import print_function

import argparse
import time

from arrow.apollo import get_apollo_instance

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Sample script to add an account via web services')
    parser.add_argument('email', help='User Email')
    parser.add_argument('--first', help='First Name', default='Jane')
    parser.add_argument('--last', help='Last Name', default='Aggie')
    args = parser.parse_args()

    wa = get_apollo_instance()

    password = wa.users._password_generator(12)
    users = wa.users.get_users()
    user = [u for u in users
            if u['username'] ==]

    if len(user) == 1:
        # Update name, regen password if the user ran it again
        returnData = wa.users.update_user(, args.first, args.last, password)
        print('Updated User\nUsername: %s\nPassword: %s' % (, password))
        returnData = wa.users.create_user(, args.first, args.last, password, role='user')
        print('Created User\nUsername: %s\nPassword: %s' % (, password))

    print("Return data: " + str(returnData))