当前位置: 首页>>代码示例>>Python>>正文


Python http_utils.quoter函数代码示例

本文整理汇总了Python中turbolift.utils.http_utils.quoter函数的典型用法代码示例。如果您正苦于以下问题:Python quoter函数的具体用法?Python quoter怎么用?Python quoter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了quoter函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: container_cdn_command

    def container_cdn_command(self, url, container, sfile=None):
        """Command your CDN enabled Container.

        :param url:
        :param container:
        """
        rty_count = ARGS.get('error_retry')
        for retry in basic.retryloop(attempts=rty_count, delay=2, obj=sfile):
            # Open Connection
            conn = http.open_connection(url=url)
            with meth.operation(retry, conn):
                cheaders = self.payload['headers']
                if sfile is not None:
                    rpath = http.quoter(url=url.path,
                                        cont=container,
                                        ufile=sfile)
                    # perform CDN Object DELETE
                    conn.request('DELETE', rpath, headers=cheaders)
                    resp, read = http.response_get(conn=conn, retry=retry)
                    self.resp_exception(resp=resp, rty=retry)
                else:
                    rpath = http.quoter(url=url.path,
                                        cont=container)
                    http.cdn_toggle(headers=cheaders)
                    # perform CDN Enable POST
                    conn.request('PUT', rpath, headers=cheaders)
                    resp, read = http.response_get(conn=conn, retry=retry)
                    self.resp_exception(resp=resp, rty=retry)

                report.reporter(
                    msg=('OBJECT %s MESSAGE %s %s %s'
                         % (rpath, resp.status, resp.reason, resp.msg)),
                    prt=False,
                    lvl='debug'
                )
开发者ID:knabar,项目名称:turbolift,代码行数:35,代码来源:actions.py

示例2: container_cdn_command

    def container_cdn_command(self, url, container, sfile=None):
        """Command your CDN enabled Container.

        :param url:
        :param container:
        """

        rty_count = ARGS.get("error_retry")
        for retry in basic.retryloop(attempts=rty_count, delay=2, obj=sfile):
            cheaders = self.payload["headers"]
            if sfile is not None:
                rpath = http.quoter(url=url.path, cont=container, ufile=sfile)
                # perform CDN Object DELETE
                adddata = "%s %s" % (cheaders, container)
                with meth.operation(retry, obj=adddata):
                    resp = http.delete_request(url=url, rpath=rpath, headers=cheaders)
                    self.resp_exception(resp=resp)
            else:
                rpath = http.quoter(url=url.path, cont=container)
                http.cdn_toggle(headers=cheaders)

                # perform CDN Enable PUT
                adddata = "%s %s" % (cheaders, container)
                with meth.operation(retry, obj=adddata):
                    resp = http.put_request(url=url, rpath=rpath, headers=cheaders)
                    self.resp_exception(resp=resp)

            report.reporter(
                msg="OBJECT %s MESSAGE %s %s %s" % (rpath, resp.status_code, resp.reason, resp.request),
                prt=False,
                lvl="debug",
            )
开发者ID:remezcla,项目名称:turbolift,代码行数:32,代码来源:actions.py

示例3: detail_show

    def detail_show(self, url):
        """Return Details on an object or container."""

        rty_count = ARGS.get("error_retry")
        for retry in basic.retryloop(attempts=rty_count, delay=5, obj=ARGS.get("container")):
            if ARGS.get("object") is not None:
                rpath = http.quoter(url=url.path, cont=ARGS.get("container"), ufile=ARGS.get("object"))
            else:
                rpath = http.quoter(url=url.path, cont=ARGS.get("container"))
            fheaders = self.payload["headers"]
            with meth.operation(retry, obj="%s %s" % (fheaders, rpath)):
                return self._header_getter(url=url, rpath=rpath, fheaders=fheaders)
开发者ID:remezcla,项目名称:turbolift,代码行数:12,代码来源:actions.py

示例4: container_lister

    def container_lister(self, url, last_obj=None):
        """Builds a long list of objects found in a container.

        NOTE: This could be millions of Objects.

        :param url:
        :return None | list:
        """

        for retry in basic.retryloop(attempts=ARGS.get("error_retry"), obj="Container List"):

            fheaders = self.payload["headers"]
            fpath = http.quoter(url=url.path)
            with meth.operation(retry, obj="%s %s" % (fheaders, fpath)):
                resp = self._header_getter(url=url, rpath=fpath, fheaders=fheaders)

                head_check = resp.headers
                container_count = head_check.get("x-account-container-count")
                if container_count:
                    container_count = int(container_count)
                    if not container_count > 0:
                        return None
                else:
                    return None

                # Set the number of loops that we are going to do
                return self._list_getter(url=url, filepath=fpath, fheaders=fheaders, last_obj=last_obj)
开发者ID:remezcla,项目名称:turbolift,代码行数:27,代码来源:actions.py

示例5: container_create

    def container_create(self, url, container):
        """Create a container if it is not Found.

        :param url:
        :param container:
        """

        rty_count = ARGS.get("error_retry")
        for retry in basic.retryloop(attempts=rty_count, delay=5, obj=container):

            rpath = http.quoter(url=url.path, cont=container)

            fheaders = self.payload["headers"]
            with meth.operation(retry, obj="%s %s" % (fheaders, rpath)):
                resp = self._header_getter(url=url, rpath=rpath, fheaders=fheaders)

                # Check that the status was a good one
                if resp.status_code == 404:
                    report.reporter(msg="Creating Container => %s" % container)
                    http.put_request(url=url, rpath=rpath, headers=fheaders)
                    self.resp_exception(resp=resp)
                    report.reporter(msg='Container "%s" Created' % container)
                    return True
                else:
                    report.reporter(msg='Container "%s" Found' % container)
                    return False
开发者ID:remezcla,项目名称:turbolift,代码行数:26,代码来源:actions.py

示例6: object_lister

    def object_lister(self, url, container, object_count=None, last_obj=None):
        """Builds a long list of objects found in a container.

        NOTE: This could be millions of Objects.

        :param url:
        :param container:
        :param object_count:
        :param last_obj:
        :return None | list:
        """

        for retry in basic.retryloop(attempts=ARGS.get("error_retry"), obj="Object List"):
            fheaders = self.payload["headers"]
            fpath = http.quoter(url=url.path, cont=container)
            with meth.operation(retry, obj="%s %s" % (fheaders, fpath)):
                resp = self._header_getter(url=url, rpath=fpath, fheaders=fheaders)
                if resp.status_code == 404:
                    report.reporter(msg="Not found. %s | %s" % (resp.status_code, resp.request))
                    return None, None, None
                else:
                    if object_count is None:
                        object_count = resp.headers.get("x-container-object-count")
                        if object_count:
                            object_count = int(object_count)
                            if not object_count > 0:
                                return None, None, None
                        else:
                            return None, None, None

                    # Set the number of loops that we are going to do
                    return self._list_getter(url=url, filepath=fpath, fheaders=fheaders, last_obj=last_obj)
开发者ID:remezcla,项目名称:turbolift,代码行数:32,代码来源:actions.py

示例7: object_downloader

    def object_downloader(self, url, container, source, u_file):
        """Download an Object from a Container.

        :param url:
        :param container:
        :param u_file:
        """

        rty_count = ARGS.get('error_retry')
        for retry in basic.retryloop(attempts=rty_count, delay=2, obj=u_file):
            # Open Connection
            conn = http.open_connection(url=url)

            # Perform operation
            with meth.operation(retry, conn):
                fheaders = self.payload['headers']

                rpath = http.quoter(url=url.path,
                                    cont=container,
                                    ufile=u_file)
                # Perform Download.
                self._downloader(conn=conn,
                                 rpath=rpath,
                                 fheaders=fheaders,
                                 lfile=u_file,
                                 source=source,
                                 retry=retry)
开发者ID:knabar,项目名称:turbolift,代码行数:27,代码来源:actions.py

示例8: object_deleter

    def object_deleter(self, url, container, u_file):
        """Deletes an objects in a container.

        :param url:
        :param container:
        :param u_file:
        """
        rty_count = ARGS.get('error_retry')
        for retry in basic.retryloop(attempts=rty_count, delay=2, obj=u_file):
            # Open Connection
            conn = http.open_connection(url=url)

            # Open connection and perform operation
            with meth.operation(retry, conn):
                rpath = http.quoter(url=url.path,
                                    cont=container,
                                    ufile=u_file)

                # Make a connection
                resp = self._header_getter(conn=conn,
                                           rpath=rpath,
                                           fheaders=self.payload['headers'],
                                           retry=retry)
                if not resp.status == 404:
                    # Perform delete.
                    self._deleter(conn=conn,
                                  rpath=rpath,
                                  fheaders=self.payload['headers'],
                                  retry=retry)
开发者ID:knabar,项目名称:turbolift,代码行数:29,代码来源:actions.py

示例9: _last_marker

        def _last_marker(f_path, l_obj):
            """Set Marker.

            :param f_path:
            :param l_obj:
            :return str:
            """

            return '%s&marker=%s' % (f_path, http.quoter(url=l_obj))
开发者ID:knabar,项目名称:turbolift,代码行数:9,代码来源:actions.py

示例10: container_deleter

    def container_deleter(self, url, container):
        """Delete all objects in a container.

        :param url:
        :param container:
        """

        for retry in basic.retryloop(attempts=ARGS.get("error_retry"), delay=2, obj=container):
            fheaders = self.payload["headers"]
            rpath = http.quoter(url=url.path, cont=container)
            with meth.operation(retry, obj="%s %s" % (fheaders, container)):
                # Perform delete.
                self._deleter(url=url, rpath=rpath, fheaders=fheaders)
开发者ID:remezcla,项目名称:turbolift,代码行数:13,代码来源:actions.py

示例11: object_putter

    def object_putter(self, url, container, source, u_file):
        """This is the Sync method which uploads files to the swift repository

        if they are not already found. If a file "name" is found locally and
        in the swift repository an MD5 comparison is done between the two
        files. If the MD5 is miss-matched the local file is uploaded to the
        repository. If custom meta data is specified, and the object exists the
        method will put the metadata onto the object.

        :param url:
        :param container:
        :param source:
        :param u_file:
        """

        for retry in basic.retryloop(attempts=ARGS.get('error_retry'),
                                     delay=2,
                                     obj=u_file):
            # Open Connection
            conn = http.open_connection(url=url)

            # Open connection and perform operation
            with meth.operation(retry, conn, obj=u_file):
                # Get the path ready for action
                sfile = basic.get_sfile(ufile=u_file, source=source)
                rpath = http.quoter(url=url.path,
                                    cont=container,
                                    ufile=sfile)

                fheaders = self.payload['headers']

                # Perform Upload.
                self._putter(conn=conn,
                             fpath=u_file,
                             rpath=rpath,
                             fheaders=fheaders,
                             retry=retry)

                # Put headers on the object if custom headers, or save perms.
                if any([ARGS.get('object_headers') is not None,
                        ARGS.get('save_perms') is not None]):

                    if ARGS.get('object_headers') is not None:
                        fheaders.update(ARGS.get('object_headers'))
                    if ARGS.get('save_perms') is not None:
                        fheaders.update(basic.stat_file(local_file=u_file))

                    self._header_poster(conn=conn,
                                        rpath=rpath,
                                        fheaders=fheaders,
                                        retry=retry)
开发者ID:knabar,项目名称:turbolift,代码行数:51,代码来源:actions.py

示例12: object_lister

    def object_lister(self, url, container, object_count=None, last_obj=None):
        """Builds a long list of objects found in a container.

        NOTE: This could be millions of Objects.

        :param url:
        :param container:
        :param object_count:
        :param last_obj:
        :return None | list:
        """

        for retry in basic.retryloop(attempts=ARGS.get('error_retry'),
                                     obj='Object List'):
            # Open Connection
            conn = http.open_connection(url=url)

            # Open connection and perform operation
            with meth.operation(retry, conn):
                # Determine how many files are in the container
                fpath = http.quoter(url=url.path,
                                    cont=container)
                # Make a connection
                resp = self._header_getter(conn=conn,
                                           rpath=fpath,
                                           fheaders=self.payload['headers'],
                                           retry=retry)
                if resp.status == 404:
                    report.reporter(
                        msg='Not found. %s | %s' % (resp.status, resp.msg)
                    )
                    return None, None, None
                else:
                    if object_count is None:
                        head_check = dict(resp.getheaders())
                        object_count = head_check.get(
                            'x-container-object-count'
                        )
                        if object_count:
                            object_count = int(object_count)
                            if not object_count > 0:
                                return None, None, None
                        else:
                            return None, None, None

                    # Set the number of loops that we are going to do
                    return self._list_getter(conn=conn,
                                             count=object_count,
                                             filepath=fpath,
                                             fheaders=self.payload['headers'],
                                             last_obj=last_obj)
开发者ID:knabar,项目名称:turbolift,代码行数:51,代码来源:actions.py

示例13: object_downloader

    def object_downloader(self, url, container, source, u_file):
        """Download an Object from a Container.

        :param url:
        :param container:
        :param u_file:
        """

        rty_count = ARGS.get("error_retry")
        for retry in basic.retryloop(attempts=rty_count, delay=2, obj=u_file):
            fheaders = self.payload["headers"]
            rpath = http.quoter(url=url.path, cont=container, ufile=u_file)
            with meth.operation(retry, obj="%s %s" % (fheaders, u_file)):
                self._downloader(url=url, rpath=rpath, fheaders=fheaders, lfile=u_file, source=source)
开发者ID:remezcla,项目名称:turbolift,代码行数:14,代码来源:actions.py

示例14: detail_show

    def detail_show(self, url):
        """Return Details on an object or container."""

        rty_count = ARGS.get('error_retry')
        for retry in basic.retryloop(attempts=rty_count,
                                     delay=5,
                                     obj=ARGS.get('container')):
            conn = http.open_connection(url=url)
            if ARGS.get('object') is not None:
                rpath = http.quoter(url=url.path,
                                    cont=ARGS.get('container'),
                                    ufile=ARGS.get('object'))
            else:
                rpath = http.quoter(url=url.path,
                                    cont=ARGS.get('container'))

            resp = self._header_getter(conn=conn,
                                       rpath=rpath,
                                       fheaders=self.payload['headers'],
                                       retry=retry)
            if resp.status == 404:
                return 'Nothing found.'
            else:
                return resp.getheaders()
开发者ID:knabar,项目名称:turbolift,代码行数:24,代码来源:actions.py

示例15: object_deleter

    def object_deleter(self, url, container, u_file):
        """Deletes an objects in a container.

        :param url:
        :param container:
        :param u_file:
        """
        rty_count = ARGS.get("error_retry")
        for retry in basic.retryloop(attempts=rty_count, delay=2, obj=u_file):
            fheaders = self.payload["headers"]
            rpath = http.quoter(url=url.path, cont=container, ufile=u_file)

            # Make a connection
            with meth.operation(retry, obj="%s %s" % (fheaders, rpath)):
                resp = self._header_getter(url=url, rpath=rpath, fheaders=fheaders)
                if not resp.status_code == 404:
                    # Perform delete.
                    self._deleter(url=url, rpath=rpath, fheaders=fheaders)
开发者ID:remezcla,项目名称:turbolift,代码行数:18,代码来源:actions.py


注:本文中的turbolift.utils.http_utils.quoter函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。