commit/galaxy-central: smcmanus: Added tool exit code to the UI. Modified stdout, stderr, and exit_code retrieval to reference same method.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/f78de6cddd0f/ changeset: f78de6cddd0f user: smcmanus date: 2012-10-03 23:07:40 summary: Added tool exit code to the UI. Modified stdout, stderr, and exit_code retrieval to reference same method. affected #: 2 files diff -r e4e1c621b025b4f0b09846e9d4410d2630394470 -r f78de6cddd0f240aede5f02911379db7102981e2 lib/galaxy/webapps/galaxy/controllers/dataset.py --- a/lib/galaxy/webapps/galaxy/controllers/dataset.py +++ b/lib/galaxy/webapps/galaxy/controllers/dataset.py @@ -154,12 +154,24 @@ stored_list_grid = HistoryDatasetAssociationListGrid() + def _get_job_for_dataset( self, trans, dataset_id ): + ''' + Return the job for the given dataset. This will throw an error if the + dataset is either nonexistent or inaccessible to the user. This looks + up the job by mapping the dataset to an HDA and then mapping the HDA + to its job. This will throw exceptions so that the caller can determine + the appropriate response. + ''' + hda = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( trans.security.decode_id( dataset_id ) ) + assert hda and trans.app.security_agent.can_access_dataset( trans.get_current_user_roles(), hda.dataset ) + return hda.creating_job_associations[0].job + @web.expose def errors( self, trans, id ): hda = trans.sa_session.query( model.HistoryDatasetAssociation ).get( id ) return trans.fill_template( "dataset/errors.mako", hda=hda ) @web.expose - def stdout( self, trans, dataset_id=None, **kwargs ): + def stdoutX( self, trans, dataset_id=None, **kwargs ): trans.response.set_content_type( 'text/plain' ) try: hda = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( trans.security.decode_id( dataset_id ) ) @@ -168,16 +180,40 @@ except: return "Invalid dataset ID or you are not allowed to access this dataset" return job.stdout + @web.expose + def stdout( self, trans, dataset_id=None, **kwargs ): + trans.response.set_content_type( 'text/plain' ) + stdout = "" + try: + job = self._get_job_for_dataset( trans, dataset_id ) + stdout = job.stdout + except: + stdout = "Invalid dataset ID or you are not allowed to access this dataset" + return stdout + + @web.expose + # TODO: Migrate stderr and stdout to use _get_job_for_dataset; it wasn't tested. def stderr( self, trans, dataset_id=None, **kwargs ): trans.response.set_content_type( 'text/plain' ) + stderr = "" try: - hda = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( trans.security.decode_id( dataset_id ) ) - assert hda and trans.app.security_agent.can_access_dataset( trans.get_current_user_roles(), hda.dataset ) - job = hda.creating_job_associations[0].job + job = self._get_job_for_dataset( trans, dataset_id ) + stderr = job.stderr except: - return "Invalid dataset ID or you are not allowed to access this dataset" - return job.stderr + stderr = "Invalid dataset ID or you are not allowed to access this dataset" + return stderr + + @web.expose + def exit_code( self, trans, dataset_id=None, **kwargs ): + trans.response.set_content_type( 'text/plain' ) + exit_code = "" + try: + job = _get_job_for_dataset( dataset_id ) + exit_code = job.exit_code + except: + exit_code = "Invalid dataset ID or you are not allowed to access this dataset" + return exit_code @web.expose def report_error( self, trans, id, email='', message="" ): smtp_server = trans.app.config.smtp_server @@ -986,7 +1022,7 @@ pass inherit_chain = source_dataset_chain(hda, []) - return trans.fill_template( "show_params.mako", inherit_chain=inherit_chain, history=trans.get_history(), hda=hda, tool=tool, params_objects=params_objects ) + return trans.fill_template( "show_params.mako", inherit_chain=inherit_chain, history=trans.get_history(), hda=hda, job=job, tool=tool, params_objects=params_objects ) @web.expose def copy_datasets( self, trans, source_history=None, source_dataset_ids="", target_history_id=None, target_history_ids="", new_history_name="", do_copy=False, **kwd ): diff -r e4e1c621b025b4f0b09846e9d4410d2630394470 -r f78de6cddd0f240aede5f02911379db7102981e2 templates/show_params.mako --- a/templates/show_params.mako +++ b/templates/show_params.mako @@ -60,6 +60,7 @@ <tr><td>Tool Version:</td><td>${hda.tool_version}</td></tr><tr><td>Tool Standard Output:</td><td><a href="${h.url_for( controller='dataset', action='stdout')}">stdout</a></td></tr><tr><td>Tool Standard Error:</td><td><a href="${h.url_for( controller='dataset', action='stderr')}">stderr</a></td></tr> + <tr><td>Tool Exit Code:</td><td>${job.exit_code}</td></tr> %if trans.user_is_admin() or trans.app.config.expose_dataset_path: <tr><td>Full Path:</td><td>${hda.file_name}</td></tr> %endif Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
Bitbucket