comparison create_account.py @ 10:df0e4eb2dfa5 draft

"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 08015be1ee8a784e0619f961aaa724857debfd6f"
author gga
date Mon, 02 Dec 2019 05:44:41 -0500
parents f7e9c792047b
children
comparison
equal deleted inserted replaced
9:2adc3aa47d15 10:df0e4eb2dfa5
2 from __future__ import print_function 2 from __future__ import print_function
3 3
4 import argparse 4 import argparse
5 import time 5 import time
6 6
7 from six.moves.builtins import str 7 from arrow.apollo import get_apollo_instance
8
9 from webapollo import PasswordGenerator, WAAuth, WebApolloInstance
10 8
11 9
12 if __name__ == '__main__': 10 if __name__ == '__main__':
13 parser = argparse.ArgumentParser(description='Sample script to add an account via web services') 11 parser = argparse.ArgumentParser(description='Sample script to add an account via web services')
14 WAAuth(parser)
15
16 parser.add_argument('email', help='User Email') 12 parser.add_argument('email', help='User Email')
17 parser.add_argument('--first', help='First Name', default='Jane') 13 parser.add_argument('--first', help='First Name', default='Jane')
18 parser.add_argument('--last', help='Last Name', default='Aggie') 14 parser.add_argument('--last', help='Last Name', default='Aggie')
19 args = parser.parse_args() 15 args = parser.parse_args()
20 16
21 wa = WebApolloInstance(args.apollo, args.username, args.password) 17 wa = get_apollo_instance()
22 18
23 password = PasswordGenerator(12) 19 password = wa.users._password_generator(12)
24 time.sleep(1) 20 time.sleep(1)
25 users = wa.users.loadUsers() 21 users = wa.users.get_users()
26 user = [u for u in users 22 user = [u for u in users
27 if u.username == args.email] 23 if u['username'] == args.email]
28 24
29 if len(user) == 1: 25 if len(user) == 1:
30 # Update name, regen password if the user ran it again 26 # Update name, regen password if the user ran it again
31 userObj = user[0] 27 returnData = wa.users.update_user(args.email, args.first, args.last, password)
32 returnData = wa.users.updateUser(userObj, args.email, args.first, args.last, password)
33 print('Updated User\nUsername: %s\nPassword: %s' % (args.email, password)) 28 print('Updated User\nUsername: %s\nPassword: %s' % (args.email, password))
34 else: 29 else:
35 returnData = wa.users.createUser(args.email, args.first, args.last, password, role='user') 30 returnData = wa.users.create_user(args.email, args.first, args.last, password, role='user')
36 print('Created User\nUsername: %s\nPassword: %s' % (args.email, password)) 31 print('Created User\nUsername: %s\nPassword: %s' % (args.email, password))
37 32
38 print("Return data: " + str(returnData)) 33 print("Return data: " + str(returnData))