コード例 #1
0
ファイル: root.py プロジェクト: Pelonza/Learn2Mine-Main
    def history( self, trans, as_xml=False, show_deleted=None, show_hidden=None, **kwd ):
        """
        Display the current history in it's own page or as xml.
        """
        if as_xml:
            return self.history_as_xml( trans,
                show_deleted=string_as_bool( show_deleted ), show_hidden=string_as_bool( show_hidden ) )

        if trans.app.config.require_login and not trans.user:
            return trans.fill_template( '/no_access.mako', message = 'Please log in to access Galaxy histories.' )

        # get all datasets server-side, client-side will get flags and render appropriately
        show_deleted = string_as_bool_or_none( show_deleted )
        show_purged  = show_deleted
        show_hidden  = string_as_bool_or_none( show_hidden )

        history_dictionary = {}
        hda_dictionaries   = []
        try:
            history_data = self._get_current_history_data( trans )
            history_dictionary = history_data[ 'history' ]
            hda_dictionaries   = history_data[ 'hdas' ]

        except Exception, exc:
            user_id = str( trans.user.id ) if trans.user else '(anonymous)'
            log.exception( 'Error bootstrapping history for user %s: %s', user_id, str( exc ) )
            history_dictionary[ 'error' ] = ( 'An error occurred getting the history data from the server. '
                                            + 'Please contact a Galaxy administrator if the problem persists.' )
コード例 #2
0
 def use_volumes(self):
     if self.attr.container_interface and not self.attr.container_interface.supports_volumes:
         return False
     elif self.attr.viz_config.has_option("docker", "use_volumes"):
         return string_as_bool_or_none(self.attr.viz_config.get("docker", "use_volumes"))
     else:
         return True
コード例 #3
0
ファイル: datasets.py プロジェクト: Pelonza/Learn2Mine-Main
    def display( self, trans, history_content_id, history_id,
                 preview=False, filename=None, to_ext=None, chunk=None, raw=False, **kwd ):
        """
        GET /api/histories/{encoded_history_id}/contents/{encoded_content_id}/display
        Displays history content (dataset).

        The query parameter 'raw' should be considered experimental and may be dropped at
        some point in the future without warning. Generally, data should be processed by its
        datatype prior to display (the defult if raw is unspecified or explicitly false.
        """
        raw = string_as_bool_or_none( raw )
        rval = ''
        try:
            hda = self.get_history_dataset_association_from_ids( trans, history_content_id, history_id )

            display_kwd = kwd.copy()
            try:
                del display_kwd["key"]
            except KeyError:
                pass
            if raw:
                if filename and filename != 'index':
                    file_path = trans.app.object_store.get_filename(hda.dataset, extra_dir='dataset_%s_files' % hda.dataset.id, alt_name=filename)
                else:
                    file_path = hda.file_name
                rval = open( file_path )

            else:
                rval = hda.datatype.display_data( trans, hda, preview, filename, to_ext, chunk, **display_kwd )

        except Exception, exception:
            log.error( "Error getting display data for dataset (%s) from history (%s): %s",
                       history_content_id, history_id, str( exception ), exc_info=True )
            trans.response.status = 500
            rval = ( "Could not get display data for dataset: " + str( exception ) )
コード例 #4
0
ファイル: lwr.py プロジェクト: Pelonza/Learn2Mine-Main
 def __init__( self, app, nworkers, transport=None, cache=None ):
     """Start the job runner """
     super( LwrJobRunner, self ).__init__( app, nworkers )
     self._init_monitor_thread()
     self._init_worker_threads()
     client_manager_kwargs = {'transport_type': transport, 'cache': string_as_bool_or_none(cache)}
     self.client_manager = ClientManager(**client_manager_kwargs)
コード例 #5
0
ファイル: root.py プロジェクト: yfu/galaxy-pipelines
    def history( self, trans, as_xml=False, show_deleted=None, show_hidden=None, hda_id=None, **kwd ):
        """Display the current history, creating a new history if necessary.

        NOTE: No longer accepts "id" or "template" options for security reasons.
        """
        if as_xml:
            return self.history_as_xml( trans,
                show_deleted=string_as_bool( show_deleted ), show_hidden=string_as_bool( show_hidden ) )

        # get all datasets server-side, client-side will get flags and render appropriately
        show_deleted = string_as_bool_or_none( show_deleted )
        show_purged  = show_deleted
        show_hidden  = string_as_bool_or_none( show_hidden )
        params = Params( kwd )
        message = params.get( 'message', '' )
        #TODO: ugh...
        message = message if message != 'None' else ''
        status = params.get( 'status', 'done' )

        if trans.app.config.require_login and not trans.user:
            return trans.fill_template( '/no_access.mako', message = 'Please log in to access Galaxy histories.' )

        def err_msg( where=None ):
            where = where if where else 'getting the history data from the server'
            err_msg = ( 'An error occurred %s. '
                      + 'Please contact a Galaxy administrator if the problem persists.' ) %( where )
            return err_msg, 'error'

        history_dictionary = {}
        hda_dictionaries   = []
        try:
            history = trans.get_history( create=True )
            hdas = self.get_history_datasets( trans, history,
                show_deleted=True, show_hidden=True, show_purged=True )

            for hda in hdas:
                try:
                    hda_dictionaries.append( self.get_hda_dict( trans, hda ) )

                except Exception, exc:
                    # don't fail entire list if hda err's, record and move on
                    log.error( 'Error bootstrapping hda %d: %s', hda.id, str( exc ), exc_info=True )
                    hda_dictionaries.append( self.get_hda_dict_with_error( trans, hda, str( exc ) ) )

            # re-use the hdas above to get the history data...
            history_dictionary = self.get_history_dict( trans, history, hda_dictionaries=hda_dictionaries )
コード例 #6
0
    def history( self, trans, as_xml=False, show_deleted=None, show_hidden=None, hda_id=None, **kwd ):
        """
        Display the current history, creating a new history if necessary.
        NOTE: No longer accepts "id" or "template" options for security reasons.
        """
        params = util.Params( kwd )
        message = params.get( 'message', None )
        status = params.get( 'status', 'done' )
        if trans.app.config.require_login and not trans.user:
            return trans.fill_template( '/no_access.mako', message = 'Please log in to access Galaxy histories.' )
        history = trans.get_history( create=True )
        if as_xml:
            trans.response.set_content_type('text/xml')
            return trans.fill_template_mako( "root/history_as_xml.mako", 
                                              history=history, 
                                              show_deleted=util.string_as_bool( show_deleted ),
                                              show_hidden=util.string_as_bool( show_hidden ) )
        else:
            show_deleted = util.string_as_bool_or_none( show_deleted )
            show_purged  = show_deleted
            show_hidden  = util.string_as_bool_or_none( show_hidden )
            
            datasets = []
            history_panel_template = "root/alternate_history.mako"

            # keeping this switch here for a while - uncomment the next line to use the original mako history panel
            #USE_ORIGINAL = True
            if 'USE_ORIGINAL' in locals():
                datasets = self.get_history_datasets( trans, history, show_deleted, show_hidden, show_purged )
                history_panel_template = "root/history.mako"

            else:
                # get all datasets server-side, client-side will get flags and render appropriately
                datasets = self.get_history_datasets( trans, history,
                                                      show_deleted=True, show_hidden=True, show_purged=True )

            return trans.stream_template_mako( history_panel_template,
                                               history = history,
                                               annotation = self.get_item_annotation_str( trans.sa_session, trans.user, history ),
                                               datasets = datasets,
                                               hda_id = hda_id,
                                               show_deleted = show_deleted,
                                               show_hidden=show_hidden,
                                               over_quota=trans.app.quota_agent.get_percent( trans=trans ) >= 100,
                                               message=message,
                                               status=status )
コード例 #7
0
ファイル: datasets.py プロジェクト: usegalaxy-eu/galaxy
    def display(self,
                trans,
                history_content_id,
                history_id,
                preview=False,
                filename=None,
                to_ext=None,
                chunk=None,
                raw=False,
                **kwd):
        """
        GET /api/histories/{encoded_history_id}/contents/{encoded_content_id}/display
        Displays history content (dataset).

        The query parameter 'raw' should be considered experimental and may be dropped at
        some point in the future without warning. Generally, data should be processed by its
        datatype prior to display (the defult if raw is unspecified or explicitly false.
        """
        decoded_content_id = self.decode_id(history_content_id)
        raw = util.string_as_bool_or_none(raw)

        rval = ''
        try:
            hda = self.hda_manager.get_accessible(decoded_content_id,
                                                  trans.user)

            if raw:
                if filename and filename != 'index':
                    file_path = trans.app.object_store.get_filename(
                        hda.dataset,
                        extra_dir=('dataset_%s_files' % hda.dataset.id),
                        alt_name=filename)
                else:
                    file_path = hda.file_name
                rval = open(file_path)

            else:
                display_kwd = kwd.copy()
                if 'key' in display_kwd:
                    del display_kwd["key"]
                rval = hda.datatype.display_data(trans, hda, preview, filename,
                                                 to_ext, chunk, **display_kwd)

        except Exception as exception:
            log.error(
                "Error getting display data for dataset (%s) from history (%s): %s",
                history_content_id,
                history_id,
                str(exception),
                exc_info=True)
            trans.response.status = 500
            rval = ("Could not get display data for dataset: " +
                    str(exception))

        return rval
コード例 #8
0
ファイル: root.py プロジェクト: odoppelt/galaxy-central
    def history(self,
                trans,
                as_xml=False,
                show_deleted=None,
                show_hidden=None,
                **kwd):
        """
        Display the current history in its own page or as xml.
        """
        if as_xml:
            return self.history_as_xml(
                trans,
                show_deleted=string_as_bool(show_deleted),
                show_hidden=string_as_bool(show_hidden))

        if trans.app.config.require_login and not trans.user:
            return trans.fill_template(
                '/no_access.mako',
                message='Please log in to access Galaxy histories.')

        # get all datasets server-side, client-side will get flags and render appropriately
        show_deleted = string_as_bool_or_none(show_deleted)
        show_purged = show_deleted
        show_hidden = string_as_bool_or_none(show_hidden)

        history_dictionary = {}
        hda_dictionaries = []
        try:
            history_data = self.history_manager._get_history_data(
                trans, trans.get_history(create=True))
            history_dictionary = history_data['history']
            hda_dictionaries = history_data['contents']

        except Exception, exc:
            user_id = str(trans.user.id) if trans.user else '(anonymous)'
            log.exception('Error bootstrapping history for user %s: %s',
                          user_id, str(exc))
            history_dictionary['error'] = (
                'An error occurred getting the history data from the server. '
                +
                'Please contact a Galaxy administrator if the problem persists.'
            )
コード例 #9
0
 def load_container_interface(self):
     self.attr.container_interface = None
     key = None
     if string_as_bool_or_none(self.attr.viz_config.get("main", "container_interface")) is not None:
         key = self.attr.viz_config.get("main", "container_interface")
     elif self.attr.galaxy_config.enable_beta_containers_interface:
         # TODO: don't hardcode this, and allow for mapping
         key = '_default_'
     if key:
         try:
             self.attr.container_interface = self.trans.app.containers[key]
         except KeyError:
             log.error("Unable to load '%s' container interface: invalid key", key)
コード例 #10
0
    def __use_remote_datatypes_conf( pulsar_client ):
        """ When setting remote metadata, use integrated datatypes from this
        Galaxy instance or use the datatypes config configured via the remote
        Pulsar.

        Both options are broken in different ways for same reason - datatypes
        may not match. One can push the local datatypes config to the remote
        server - but there is no guarentee these datatypes will be defined
        there. Alternatively, one can use the remote datatype config - but
        there is no guarentee that it will contain all the datatypes available
        to this Galaxy.
        """
        use_remote_datatypes = string_as_bool_or_none( pulsar_client.destination_params.get( "use_remote_datatypes", False ) )
        return use_remote_datatypes
コード例 #11
0
ファイル: pulsar.py プロジェクト: ARTbio/galaxy
    def __use_remote_datatypes_conf( pulsar_client ):
        """ When setting remote metadata, use integrated datatypes from this
        Galaxy instance or use the datatypes config configured via the remote
        Pulsar.

        Both options are broken in different ways for same reason - datatypes
        may not match. One can push the local datatypes config to the remote
        server - but there is no guarentee these datatypes will be defined
        there. Alternatively, one can use the remote datatype config - but
        there is no guarentee that it will contain all the datatypes available
        to this Galaxy.
        """
        use_remote_datatypes = string_as_bool_or_none( pulsar_client.destination_params.get( "use_remote_datatypes", False ) )
        return use_remote_datatypes
コード例 #12
0
    def display(self,
                trans,
                history_content_id,
                history_id,
                preview=False,
                filename=None,
                to_ext=None,
                raw=False,
                **kwd):
        """
        GET /api/histories/{encoded_history_id}/contents/{encoded_content_id}/display
        Displays history content (dataset).

        The query parameter 'raw' should be considered experimental and may be dropped at
        some point in the future without warning. Generally, data should be processed by its
        datatype prior to display (the defult if raw is unspecified or explicitly false.
        """
        decoded_content_id = self.decode_id(history_content_id)
        raw = util.string_as_bool_or_none(raw)

        rval = ''
        try:
            hda = self.hda_manager.get_accessible(decoded_content_id,
                                                  trans.user)
            if raw:
                if filename and filename != 'index':
                    object_store = trans.app.object_store
                    dir_name = hda.dataset.extra_files_path_name
                    file_path = object_store.get_filename(hda.dataset,
                                                          extra_dir=dir_name,
                                                          alt_name=filename)
                else:
                    file_path = hda.file_name
                rval = open(file_path, 'rb')
            else:
                display_kwd = kwd.copy()
                if 'key' in display_kwd:
                    del display_kwd["key"]
                rval = hda.datatype.display_data(trans, hda, preview, filename,
                                                 to_ext, **display_kwd)
        except galaxy_exceptions.MessageException:
            raise
        except Exception as e:
            log.exception(
                "Server error getting display data for dataset (%s) from history (%s)",
                history_content_id, history_id)
            raise galaxy_exceptions.InternalServerError(
                f"Could not get display data for dataset: {util.unicodify(e)}")
        return rval
コード例 #13
0
ファイル: test.py プロジェクト: mvdbeek/galaxy
def _process_bool_param_value(param, param_value):
    assert isinstance(param, galaxy.tools.parameters.basic.BooleanToolParameter)
    was_list = False
    if isinstance(param_value, list):
        was_list = True
        param_value = param_value[0]
    if param.truevalue == param_value:
        processed_value = True
    elif param.falsevalue == param_value:
        processed_value = False
    else:
        if param.optional:
            processed_value = string_as_bool_or_none(param_value)
        else:
            processed_value = string_as_bool(param_value)
    return [processed_value] if was_list else processed_value
コード例 #14
0
    def index(self, trans: ProvidesUserContext, **kwd):
        """
        index( self, trans, **kwd )
        * GET /api/libraries:
            Returns a list of summary data for all libraries.

        :param  deleted: if True, show only ``deleted`` libraries, if False show only ``non-deleted``
        :type   deleted: boolean (optional)

        :returns:   list of dictionaries containing library information
        :rtype:     list

        .. seealso:: :attr:`galaxy.model.Library.dict_collection_visible_keys`

        """
        deleted = util.string_as_bool_or_none(kwd.get('deleted', None))
        return self.service.index(trans, deleted)
コード例 #15
0
ファイル: libraries.py プロジェクト: BinglanLi/galaxy
    def index( self, trans, **kwd ):
        """
        index( self, trans, **kwd )
        * GET /api/libraries:
            Returns a list of summary data for all libraries.

        :param  deleted: if True, show only ``deleted`` libraries, if False show only ``non-deleted``
        :type   deleted: boolean (optional)

        :returns:   list of dictionaries containing library information
        :rtype:     list

        .. seealso:: :attr:`galaxy.model.Library.dict_collection_visible_keys`

        """
        deleted = util.string_as_bool_or_none( kwd.get( 'deleted', None ) )
        query = self.library_manager.list( trans, deleted )
        libraries = []
        for library in query:
            libraries.append( self.library_manager.get_library_dict( trans, library ) )
        return libraries
コード例 #16
0
ファイル: libraries.py プロジェクト: gtrack/galaxy
    def index(self, trans, **kwd):
        """
        index( self, trans, **kwd )
        * GET /api/libraries:
            Returns a list of summary data for all libraries.

        :param  deleted: if True, show only ``deleted`` libraries, if False show only ``non-deleted``
        :type   deleted: boolean (optional)

        :returns:   list of dictionaries containing library information
        :rtype:     list

        .. seealso:: :attr:`galaxy.model.Library.dict_collection_visible_keys`

        """
        deleted = util.string_as_bool_or_none(kwd.get('deleted', None))
        query, prefetched_ids = self.library_manager.list(trans, deleted)
        libraries = []
        for library in query:
            libraries.append(self.library_manager.get_library_dict(trans, library, prefetched_ids))
        return libraries
コード例 #17
0
def to_bool_or_none(value):
    return util.string_as_bool_or_none(value)
コード例 #18
0
ファイル: __init__.py プロジェクト: odoppelt/galaxy-central
def _get_tri_state(d, k, o):
    if k in d:
        return string_as_bool_or_none(d[k])
    else:
        return o
コード例 #19
0
ファイル: pulsar.py プロジェクト: agrauslys/galaxy
 def __rewrite_parameters( pulsar_client ):
     return string_as_bool_or_none( pulsar_client.destination_params.get( "rewrite_parameters", False ) ) or False
コード例 #20
0
ファイル: pulsar.py プロジェクト: agrauslys/galaxy
 def __remote_metadata( pulsar_client ):
     remote_metadata = string_as_bool_or_none( pulsar_client.destination_params.get( "remote_metadata", False ) )
     return remote_metadata
コード例 #21
0
 def __remote_container_handling(pulsar_client):
     remote_container_handling = string_as_bool_or_none(pulsar_client.destination_params.get("remote_container_handling", False))
     return remote_container_handling
コード例 #22
0
ファイル: __init__.py プロジェクト: usegalaxy-eu/galaxy
def _get_tri_state(d, k, o):
    if k in d:
        return string_as_bool_or_none(d[k])
    else:
        return o
コード例 #23
0
    def index( self, trans, history_id, ids=None, **kwd ):
        """
        index( self, trans, history_id, ids=None, **kwd )
        * GET /api/histories/{history_id}/contents
            return a list of HDA data for the history with the given ``id``
        .. note:: Anonymous users are allowed to get their current history contents

        If Ids is not given, index returns a list of *summary* objects for
        every HDA associated with the given `history_id`.

        If ids is given, index returns a *more complete* json object for each
        HDA in the ids list.

        :type   history_id: str
        :param  history_id: encoded id string of the HDA's History
        :type   ids:        str
        :param  ids:        (optional) a comma separated list of encoded `HDA` ids

        :rtype:     list
        :returns:   dictionaries containing summary or detailed HDA information
        .. seealso::
            :func:`_summary_hda_dict` and
            :func:`galaxy.web.base.controller.UsesHistoryDatasetAssociationMixin.get_hda_dict`
        """
        rval = []
        try:
            # get the history, if anon user and requesting current history - allow it
            if( ( trans.user == None )
                and ( history_id == trans.security.encode_id( trans.history.id ) ) ):
                #TODO:?? is secure?
                history = trans.history
            # otherwise, check permissions for the history first
            else:
                history = self.get_history( trans, history_id, check_ownership=True, check_accessible=True )

            # if ids, return _FULL_ data (as show) for each id passed
            if ids:
                ids = ids.split( ',' )
                for index, hda in enumerate( history.datasets ):
                    encoded_hda_id = trans.security.encode_id( hda.id )
                    if encoded_hda_id in ids:
                        #TODO: share code with show
                        rval.append( self._detailed_hda_dict( trans, hda ) )

            # if no ids passed, return a _SUMMARY_ of _all_ datasets in the history
            else:
                # details param allows a mixed set of summary and detailed hdas
                #TODO: this is getting convoluted due to backwards compat
                details = kwd.get( 'details', None ) or []
                if details and details != 'all':
                    details = util.listify( details )

                # by default return all datasets - even if deleted or hidden (defaulting the next switches to None)
                #   if specified return those datasets that match the setting
                # backwards compat
                return_deleted = util.string_as_bool_or_none( kwd.get( 'deleted', None ) )
                return_visible = util.string_as_bool_or_none( kwd.get( 'visible', None ) )

                for hda in history.datasets:
                    # if either return_ setting has been requested (!= None), skip hdas that don't match the request
                    if return_deleted is not None:
                        if( ( return_deleted and not hda.deleted )
                        or  ( not return_deleted and hda.deleted ) ):
                            continue
                    if return_visible is not None:
                        if( ( return_visible and not hda.visible )
                        or  ( not return_visible and hda.visible ) ):
                            continue

                    encoded_hda_id = trans.security.encode_id( hda.id )
                    if( ( encoded_hda_id in details )
                    or  ( details == 'all' ) ):
                        rval.append( self._detailed_hda_dict( trans, hda ) )
                    else:
                        rval.append( self._summary_hda_dict( trans, history_id, hda ) )

        except Exception, e:
            # for errors that are not specific to one hda (history lookup or summary list)
            rval = "Error in history API at listing contents: " + str( e )
            log.error( rval + ": %s, %s" % ( type( e ), str( e ) ), exc_info=True )
            trans.response.status = 500
コード例 #24
0
ファイル: specs.py プロジェクト: AAFC-MBB/galaxy-1
def to_bool_or_none( value ):
    return util.string_as_bool_or_none( value )
コード例 #25
0
 def __remote_metadata(pulsar_client):
     remote_metadata = string_as_bool_or_none(
         pulsar_client.destination_params.get("remote_metadata", False))
     return remote_metadata
コード例 #26
0
    def __init__(self, trans, plugin):
        self.trans = trans
        self.log = log

        self.attr = Bunch()
        self.attr.viz_id = plugin.name
        self.attr.history_id = trans.security.encode_id( trans.history.id )
        self.attr.galaxy_config = trans.app.config
        self.attr.galaxy_root_dir = os.path.abspath(self.attr.galaxy_config.root)
        self.attr.root = web.url_for("/")
        self.attr.app_root = self.attr.root + "plugins/interactive_environments/" + self.attr.viz_id + "/static/"
        self.attr.import_volume = True

        plugin_path = os.path.abspath( plugin.path )

        # Store our template and configuration path
        self.attr.our_config_dir = os.path.join(plugin_path, "config")
        self.attr.our_template_dir = os.path.join(plugin_path, "templates")
        self.attr.HOST = trans.request.host.rsplit(':', 1)[0]

        self.load_deploy_config()
        self.load_allowed_images()
        self.attr.docker_hostname = self.attr.viz_config.get("docker", "docker_hostname")
        self.attr.docker_connect_port = self.attr.viz_config.get("docker", "docker_connect_port") or None

        if string_as_bool_or_none(self.attr.viz_config.get("docker", "swarm_mode")) is not None:
            self.attr.swarm_mode = string_as_bool_or_none(self.attr.viz_config.get("docker", "swarm_mode"))
        else:
            self.attr.swarm_mode = trans.app.config.gie_swarm_mode

        # Generate per-request passwords the IE plugin can use to configure
        # the destination container.
        self.notebook_pw_salt = self.generate_password(length=12)
        self.notebook_pw = self.generate_password(length=24)

        ie_parent_temp_dir = self.attr.viz_config.get("docker", "docker_galaxy_temp_dir") or None
        self.temp_dir = os.path.abspath( tempfile.mkdtemp( dir=ie_parent_temp_dir ) )

        if self.attr.viz_config.getboolean("docker", "wx_tempdir"):
            # Ensure permissions are set
            try:
                os.chmod( self.temp_dir, os.stat(self.temp_dir).st_mode | stat.S_IXOTH )
            except Exception:
                log.error( "Could not change permissions of tmpdir %s" % self.temp_dir )
                # continue anyway

        # This duplicates the logic in the proxy manager
        if self.attr.galaxy_config.dynamic_proxy_external_proxy:
            self.attr.proxy_prefix = '/'.join(
                (
                    '',
                    self.attr.galaxy_config.cookie_path.strip('/'),
                    self.attr.galaxy_config.dynamic_proxy_prefix.strip('/'),
                    self.attr.viz_id,
                )
            )
        else:
            self.attr.proxy_prefix = ''
        # If cookie_path is unset (thus '/'), the proxy prefix ends up with
        # multiple leading '/' characters, which will cause the client to
        # request resources from http://dynamic_proxy_prefix
        if self.attr.proxy_prefix.startswith('/'):
            self.attr.proxy_prefix = '/' + self.attr.proxy_prefix.lstrip('/')

        assert not self.attr.swarm_mode or (self.attr.swarm_mode and
                                            self.attr.docker_connect_port is not None), \
            "Error: Docker swarm mode enabled but docker_connect_port is not set"
コード例 #27
0
 def __rewrite_parameters(pulsar_client):
     return string_as_bool_or_none(
         pulsar_client.destination_params.get("rewrite_parameters",
                                              False)) or False
コード例 #28
0
    def history(self,
                trans,
                as_xml=False,
                show_deleted=None,
                show_hidden=None,
                hda_id=None,
                **kwd):
        """Display the current history, creating a new history if necessary.

        NOTE: No longer accepts "id" or "template" options for security reasons.
        """
        if as_xml:
            return self.history_as_xml(
                trans,
                show_deleted=string_as_bool(show_deleted),
                show_hidden=string_as_bool(show_hidden))

        # get all datasets server-side, client-side will get flags and render appropriately
        show_deleted = string_as_bool_or_none(show_deleted)
        show_purged = show_deleted
        show_hidden = string_as_bool_or_none(show_hidden)
        params = Params(kwd)
        message = params.get('message', '')
        #TODO: ugh...
        message = message if message != 'None' else ''
        status = params.get('status', 'done')

        if trans.app.config.require_login and not trans.user:
            return trans.fill_template(
                '/no_access.mako',
                message='Please log in to access Galaxy histories.')

        def err_msg(where=None):
            where = where if where else 'getting the history data from the server'
            err_msg = (
                'An error occurred %s. ' +
                'Please contact a Galaxy administrator if the problem persists.'
            ) % (where)
            return err_msg, 'error'

        history_dictionary = {}
        hda_dictionaries = []
        try:
            history = trans.get_history(create=True)
            hdas = self.get_history_datasets(trans,
                                             history,
                                             show_deleted=True,
                                             show_hidden=True,
                                             show_purged=True)

            for hda in hdas:
                try:
                    hda_dictionaries.append(self.get_hda_dict(trans, hda))

                except Exception, exc:
                    # don't fail entire list if hda err's, record and move on
                    log.error('Error bootstrapping hda %d: %s',
                              hda.id,
                              str(exc),
                              exc_info=True)
                    hda_dictionaries.append(
                        self.get_hda_dict_with_error(trans, hda, str(exc)))

            # re-use the hdas above to get the history data...
            history_dictionary = self.get_history_dict(
                trans, history, hda_dictionaries=hda_dictionaries)