-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed error with group users addition
- Loading branch information
root
committed
Sep 13, 2023
1 parent
2f8e01d
commit 3d4edad
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import psycopg2 | ||
import bioblend.galaxy | ||
import sys | ||
|
||
conn = psycopg2.connect(database="galaxy", user="postgres") | ||
cursor = conn.cursor() | ||
cursor.execute("SELECT * FROM galaxy_user") | ||
users = cursor.fetchall() | ||
user_dict = dict() | ||
|
||
for user in users: | ||
user_dict[user[0]] = user[3] # id is key, email is value | ||
|
||
cursor.execute("SELECT * FROM custos_authnz_token") | ||
einfra_users = cursor.fetchall() | ||
|
||
einfra_emails = [] | ||
for einfra_user in einfra_users: | ||
einfra_emails.append(user_dict[einfra_user[1]]) | ||
|
||
server = 'https://' + sys.argv[1] | ||
api_key = sys.argv[2] | ||
gi = bioblend.galaxy.GalaxyInstance(url=server, key=api_key) | ||
|
||
api_users = gi.users.get_users() | ||
id_dict = dict() | ||
for user in api_users: | ||
id_dict[user['email']] = user['id'] | ||
|
||
groups = gi.groups.get_groups() | ||
for group in groups: | ||
if group['name'] == 'E-infra': | ||
group_id = group['id'] | ||
|
||
for mail in einfra_emails: | ||
gi.groups.add_group_user(group_id=group_id, user_id=id_dict[mail]) |