Locked History Actions

attachment:histories_2.py of Events/GCC2013/TrainingDay/API

Attachment 'histories_2.py'

Download

   1 #!/usr/bin/env python
   2 
   3 """
   4 Access a Galaxy instance and get data for histories.
   5 
   6 Now with a way to get details on a specific history.
   7 """
   8 import os
   9 import sys
  10 import pprint
  11 
  12 import setup
  13 import common
  14 
  15 # the REST URL for the user resource
  16 RESOURCE_URL = '/api/histories'
  17 
  18 # ----------------------------------------------------------------------------- functions
  19 def get_histories():
  20     """
  21     Return a list of dictionaries that describe the current user's histories.
  22     """
  23     apikey = setup.get_apikey()
  24     full_url = setup.get_base_url() + RESOURCE_URL
  25     return common.get( apikey, full_url )
  26 
  27 
  28 def get_history( history_id ):
  29     """
  30     Return a dictionary that the gives details of a
  31     specific current user's history.
  32     """
  33     # same as get_histories here...
  34     apikey = setup.get_apikey()
  35     resource_url = setup.get_base_url() + RESOURCE_URL
  36     # ...but now, we'll add the id of a specific history to the url
  37     # this will tell galaxy that we want to do a 'show' and get more information than an 'index' will provide
  38     full_url = resource_url + '/' + history_id
  39     return common.get( apikey, full_url )
  40 
  41 
  42 # ----------------------------------------------------------------------------- main
  43 if __name__ == '__main__':
  44     # here - we'll alter the main function to accept an argument (the module sys is useful here)
  45     #   BUT! we need to make sure the user sent in the argument on the command line - so, we'll check that first
  46     # (sys.argv is a list of the arguments the user sent in)
  47     if len( sys.argv ) <= 1:
  48         # if they didn't send an argument, we'll print some help
  49         print 'USAGE: histories_2.py <a history id>'
  50         # and exit from this script (the 1 indicates to most OS's that there was an error)
  51         sys.exit( 1 )
  52 
  53     # if we're here, the system didn't exit and we've got an argument, so...
  54     history_id = sys.argv[1]
  55     # get the resource data using the function we defined above
  56     returned = get_history( history_id )
  57     # pretty print the list of dictionaries that Galaxy sent us in response
  58     pprint.pprint( returned, indent=2 )

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2013-06-24 16:01:09, 8.2 KB) [[attachment:Galaxy-Workflow-Joined_Solexa_QC.ga]]
  • [get | view] (2013-06-24 16:46:36, 14.0 KB) [[attachment:all-scripts.tar.gz]]
  • [get | view] (2013-06-24 16:01:23, 5.2 KB) [[attachment:common.py]]
  • [get | view] (2013-06-24 16:04:07, 0.9 KB) [[attachment:datasets_1.py]]
  • [get | view] (2013-06-24 16:04:15, 1.2 KB) [[attachment:datasets_2.py]]
  • [get | view] (2013-06-24 16:04:22, 3.4 KB) [[attachment:datasets_3.py]]
  • [get | view] (2013-06-24 16:04:33, 1.5 KB) [[attachment:hdas_1.py]]
  • [get | view] (2013-06-24 16:04:50, 1.7 KB) [[attachment:hdas_2.py]]
  • [get | view] (2013-06-24 16:05:07, 2.2 KB) [[attachment:hdas_3.py]]
  • [get | view] (2013-06-24 16:03:38, 0.9 KB) [[attachment:histories_1.py]]
  • [get | view] (2013-06-24 16:03:52, 2.1 KB) [[attachment:histories_2.py]]
  • [get | view] (2013-06-24 16:05:25, 2.2 KB) [[attachment:histories_3.py]]
  • [get | view] (2013-06-24 16:05:34, 3.3 KB) [[attachment:lddas_1.py]]
  • [get | view] (2013-06-24 16:05:41, 1.3 KB) [[attachment:libraries_1.py]]
  • [get | view] (2013-06-24 16:01:36, 0.8 KB) [[attachment:setup.py]]
  • [get | view] (2013-06-24 16:02:45, 1.1 KB) [[attachment:step_1.py]]
  • [get | view] (2013-06-24 16:07:15, 9.9 KB) [[attachment:step_10.py]]
  • [get | view] (2013-06-24 16:03:28, 1.4 KB) [[attachment:step_2.py]]
  • [get | view] (2013-06-24 16:06:01, 1.6 KB) [[attachment:step_3.py]]
  • [get | view] (2013-06-24 16:06:11, 1.1 KB) [[attachment:step_4.py]]
  • [get | view] (2013-06-24 16:06:20, 1.9 KB) [[attachment:step_5.py]]
  • [get | view] (2013-06-24 16:06:44, 2.5 KB) [[attachment:step_6.py]]
  • [get | view] (2013-06-24 16:06:53, 4.9 KB) [[attachment:step_7.py]]
  • [get | view] (2013-06-24 16:07:05, 5.9 KB) [[attachment:step_8.py]]
  • [get | view] (2013-06-30 13:51:46, 8.0 KB) [[attachment:step_9.py]]
  • [get | view] (2013-06-24 16:41:51, 1.8 KB) [[attachment:tools_1.py]]
  • [get | view] (2013-06-24 16:44:32, 2.0 KB) [[attachment:upload_to_history.py]]
  • [get | view] (2013-06-24 16:03:03, 1.3 KB) [[attachment:users_1.py]]
  • [get | view] (2013-06-24 16:44:44, 2.9 KB) [[attachment:workflows_1.py]]
 All files | Selected Files: delete move to page

You are not allowed to attach a file to this page.