Mercurial > repos > gga > apollo_iframe
comparison create_or_update_organism.py @ 5:207c1c281360 draft
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 85194fa009ead2c34720faab61a4143fc29d17c2
author | gga |
---|---|
date | Fri, 31 Aug 2018 09:33:49 -0400 |
parents | 951ef9b7bafc |
children | 9305e1881519 |
comparison
equal
deleted
inserted
replaced
4:a10003dc6c85 | 5:207c1c281360 |
---|---|
6 import logging | 6 import logging |
7 import shutil | 7 import shutil |
8 import sys | 8 import sys |
9 import time | 9 import time |
10 | 10 |
11 from webapollo import AssertUser, GuessOrg, OrgOrGuess, WAAuth, WebApolloInstance | 11 from webapollo import GuessOrg, OrgOrGuess, PermissionCheck, WAAuth, WebApolloInstance |
12 logging.basicConfig(level=logging.INFO) | 12 logging.basicConfig(level=logging.INFO) |
13 log = logging.getLogger(__name__) | 13 log = logging.getLogger(__name__) |
14 | |
15 | 14 |
16 if __name__ == '__main__': | 15 if __name__ == '__main__': |
17 parser = argparse.ArgumentParser(description='Create or update an organism in an Apollo instance') | 16 parser = argparse.ArgumentParser(description='Create or update an organism in an Apollo instance') |
18 WAAuth(parser) | 17 WAAuth(parser) |
19 | 18 |
31 | 30 |
32 org_cn = GuessOrg(args, wa) | 31 org_cn = GuessOrg(args, wa) |
33 if isinstance(org_cn, list): | 32 if isinstance(org_cn, list): |
34 org_cn = org_cn[0] | 33 org_cn = org_cn[0] |
35 | 34 |
36 # User must have an account | 35 # User must have an account, if not, create it |
37 gx_user = AssertUser(wa.users.loadUsers(email=args.email)) | 36 gx_user = wa.users.assertOrCreateUser(args.email) |
38 | 37 |
39 log.info("Determining if add or update required") | 38 log.info("Determining if add or update required") |
40 try: | 39 try: |
41 org = wa.organisms.findOrganismByCn(org_cn) | 40 org = wa.organisms.findOrganismByCn(org_cn) |
42 except Exception: | 41 except Exception: |
43 org = None | 42 org = None |
44 | 43 |
45 if org: | 44 if org: |
46 has_perms = False | |
47 old_directory = org['directory'] | 45 old_directory = org['directory'] |
48 for user_owned_organism in gx_user.organismPermissions: | |
49 if 'WRITE' in user_owned_organism['permissions']: | |
50 has_perms = True | |
51 break | |
52 | 46 |
53 if not has_perms: | 47 if not PermissionCheck(gx_user, org_cn, "WRITE"): |
54 print("Naming Conflict. You do not have permissions to access this organism. Either request permission from the owner, or choose a different name for your organism.") | 48 print("Naming Conflict. You do not have permissions to access this organism. Either request permission from the owner, or choose a different name for your organism.") |
55 sys.exit(2) | 49 sys.exit(2) |
56 | 50 |
57 log.info("\tUpdating Organism") | 51 log.info("\tUpdating Organism") |
58 data = wa.organisms.updateOrganismInfo( | 52 data = wa.organisms.updateOrganismInfo( |