コード例 #1
0
def validate_path_upload(trans):
    if not trans.app.config.allow_library_path_paste:
        raise ConfigDoesNotAllowException(
            '"allow_path_paste" is not set to True in the Galaxy configuration file'
        )

    if not trans.user_is_admin:
        raise AdminRequiredException(
            'Uploading files via filesystem paths can only be performed by administrators'
        )
コード例 #2
0
        def get_url_paste_urls_or_filename(group_incoming,
                                           override_name=None,
                                           override_info=None):
            url_paste_file = group_incoming.get('url_paste', None)
            if url_paste_file is not None:
                url_paste = open(url_paste_file, 'r').read()

                def start_of_url(content):
                    start_of_url_paste = content.lstrip()[0:8].lower()
                    looks_like_url = False
                    for url_prefix in [
                            "http://", "https://", "ftp://", "file://"
                    ]:
                        if start_of_url_paste.startswith(url_prefix):
                            looks_like_url = True
                            break

                    return looks_like_url

                if start_of_url(url_paste):
                    url_paste = url_paste.replace('\r', '').split('\n')
                    for line in url_paste:
                        line = line.strip()
                        if line:
                            if not start_of_url(line):
                                continue  # non-url line, ignore

                            if "file://" in line:
                                if not trans.user_is_admin:
                                    raise AdminRequiredException()
                                elif not trans.app.config.allow_path_paste:
                                    raise ConfigDoesNotAllowException()
                                upload_path = line[len("file://"):]
                                dataset_name = os.path.basename(upload_path)
                            else:
                                dataset_name = line

                            if override_name:
                                dataset_name = override_name
                            yield Bunch(type='url',
                                        path=line,
                                        name=dataset_name)
                else:
                    dataset_name = 'Pasted Entry'  # we need to differentiate between various url pastes here
                    if override_name:
                        dataset_name = override_name
                    yield Bunch(type='file',
                                path=url_paste_file,
                                name=dataset_name)
コード例 #3
0
ファイル: groups.py プロジェクト: davebx/toolshed
    def index(self, trans, deleted=False, **kwd):
        """
        GET /api/groups
        Return a list of dictionaries that contain information about each Group.

        :param deleted: flag used to include deleted groups

        Example: GET localhost:9009/api/groups
        """
        group_dicts = []
        deleted = util.asbool(deleted)
        if deleted and not trans.user_is_admin:
            raise AdminRequiredException('Only administrators can query deleted groups.')
        for group in self.group_manager.list(trans, deleted):
            group_dicts.append(self._populate(trans, group))
        return group_dicts
コード例 #4
0
def get_admin_user(trans: SessionRequestContext = DependsOnTrans):
    if not trans.user_is_admin:
        raise AdminRequiredException(
            require_admin_message(trans.app.config, trans.user))
    return trans.user