예제 #1
0
    OrgOrGuess(parser)
    parser.add_argument('--genus', help='Organism Genus')
    parser.add_argument('--species', help='Organism Species')
    parser.add_argument('--public', action='store_true', help='Make organism public')
    parser.add_argument('--group', help='Give access to a user group')
    parser.add_argument('--remove_old_directory', action='store_true', help='Remove old directory')

    args = parser.parse_args()
    wa = WebApolloInstance(args.apollo, args.username, args.password)

    org_cn = GuessOrg(args, wa)
    if isinstance(org_cn, list):
        org_cn = org_cn[0]

    # User must have an account
    gx_user = AssertUser(wa.users.loadUsers(email=args.email))

    log.info("Determining if add or update required")
    try:
        org = wa.organisms.findOrganismByCn(org_cn)
    except Exception:
        org = None

    if org:
        has_perms = False
        old_directory = org['directory']
        for user_owned_organism in gx_user.organismPermissions:
            if 'WRITE' in user_owned_organism['permissions']:
                has_perms = True
                break
예제 #2
0
    parser.add_argument('email', help='User Email')
    parser.add_argument('share_with', help='Share with this user (by email)')
    parser.add_argument('--write',
                        action='store_true',
                        help='Write permission')
    parser.add_argument('--export',
                        action='store_true',
                        help='Export permission')
    parser.add_argument('--read', action='store_true', help='Read permission')

    OrgOrGuess(parser)
    args = parser.parse_args()

    wa = WebApolloInstance(args.apollo, args.username, args.password)
    # User must have an account
    gx_user = AssertUser(wa.users.loadUsers(email=args.email))

    # Get organism
    org_cn = GuessOrg(args, wa)[0]

    # Fetch all organisms
    all_orgs = wa.organisms.findAllOrganisms()
    # Figure out which are accessible to the user
    # filter out common names
    orgs = [d[0] for d in accessible_organisms(gx_user, all_orgs)]

    # This user MUST be allowed to access an organism before they can
    # modify permissions on it.
    assert org_cn in orgs

    org = wa.organisms.findOrganismByCn(org_cn)