[2] | 1 | import os |
---|
| 2 | from __init__ import ToolAction |
---|
| 3 | from galaxy.tools.actions import upload_common |
---|
| 4 | |
---|
| 5 | import logging |
---|
| 6 | log = logging.getLogger( __name__ ) |
---|
| 7 | |
---|
| 8 | class UploadToolAction( ToolAction ): |
---|
| 9 | def execute( self, tool, trans, incoming={}, set_output_hid = True ): |
---|
| 10 | dataset_upload_inputs = [] |
---|
| 11 | for input_name, input in tool.inputs.iteritems(): |
---|
| 12 | if input.type == "upload_dataset": |
---|
| 13 | dataset_upload_inputs.append( input ) |
---|
| 14 | assert dataset_upload_inputs, Exception( "No dataset upload groups were found." ) |
---|
| 15 | |
---|
| 16 | precreated_datasets = upload_common.get_precreated_datasets( trans, incoming, trans.app.model.HistoryDatasetAssociation ) |
---|
| 17 | incoming = upload_common.persist_uploads( incoming ) |
---|
| 18 | # We can pass an empty string as the cntrller here since it is used to check whether we |
---|
| 19 | # are in an admin view, and this tool is currently not used there. |
---|
| 20 | uploaded_datasets = upload_common.get_uploaded_datasets( trans, '', incoming, precreated_datasets, dataset_upload_inputs ) |
---|
| 21 | upload_common.cleanup_unused_precreated_datasets( precreated_datasets ) |
---|
| 22 | |
---|
| 23 | if not uploaded_datasets: |
---|
| 24 | return 'No data was entered in the upload form, please go back and choose data to upload.' |
---|
| 25 | |
---|
| 26 | json_file_path = upload_common.create_paramfile( trans, uploaded_datasets ) |
---|
| 27 | data_list = [ ud.data for ud in uploaded_datasets ] |
---|
| 28 | return upload_common.create_job( trans, incoming, tool, json_file_path, data_list, return_job=True ) |
---|