Created
July 2, 2013 15:24
-
-
Save netscruff/5910251 to your computer and use it in GitHub Desktop.
Return a JSON array of applications owned by or shared with user. These are User- and Community-mode applications
This file contains hidden or 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
| #!/usr/bin/env python | |
| import argparse | |
| import getpass | |
| import urllib | |
| import urllib2 | |
| import base64 | |
| import simplejson as json | |
| parser = argparse.ArgumentParser(description='Submit and monitor cd-hit job.') | |
| parser.add_argument('-u', dest='userid', type=str, required=True, | |
| help='Your iPlant userid') | |
| parser.add_argument('inputSeqs', type=str, | |
| help='name of input sequence file on iPlant iRODS datastore') | |
| args = parser.parse_args() | |
| userid = args.userid | |
| password = getpass.getpass() | |
| authurl = "https://foundation.iplantc.org/auth-v1" | |
| url = "https://foundation.iplantc.org/apps-v1/apps/shared/list" | |
| req = urllib2.Request(url) | |
| base64string = base64.encodestring('%s:%s' % (userid, password)).replace('\n', '') | |
| req.add_header("Authorization", "Basic %s" % base64string) | |
| print 'This will be a', req.get_method(), 'request.' | |
| opener = urllib2.build_opener() | |
| results = opener.open(req) | |
| data = json.load(results) | |
| result = data.get('result') | |
| for item in result: | |
| print item['name'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment