Exemple #1
0
    def execute(self, key, fops, force=None):
        ops = ';'.join(fops)
        data = {'bucket': self.bucket, 'key': key, 'fops': ops}
        if self.pipeline:
            data['pipeline'] = self.pipeline
        if self.notify_url:
            data['notifyURL'] = self.notify_url
        if force == 1:
            data['force'] = 1

        url = 'http://{0}/pfop'.format(config.API_HOST)
        return http._post_with_auth(url, data, self.auth)
Exemple #2
0
    def execute(self, key, fops, force=None):
        ops = ';'.join(fops)
        data = {'bucket': self.bucket, 'key': key, 'fops': ops}
        if self.pipeline:
            data['pipeline'] = self.pipeline
        if self.notify_url:
            data['notifyURL'] = self.notify_url
        if force == 1:
            data['force'] = 1

        url = 'http://{0}/pfop'.format(config.API_HOST)
        return http._post_with_auth(url, data, self.auth)
Exemple #3
0
    def execute(self, key, fops, force=None):
        """执行持久化处理:

        Args:
            key:    待处理的源文件
            fops:   处理详细操作,规格详见 http://developer.qiniu.com/docs/v6/api/reference/fop/
            force:  强制执行持久化处理开关

        Returns:
            一个dict变量,返回持久化处理的persistentId,类似{"persistentId": 5476bedf7823de4068253bae};
            一个ResponseInfo对象
        """
        ops = ';'.join(fops)
        data = {'bucket': self.bucket, 'key': key, 'fops': ops}
        if self.pipeline:
            data['pipeline'] = self.pipeline
        if self.notify_url:
            data['notifyURL'] = self.notify_url
        if force == 1:
            data['force'] = 1

        url = 'http://{0}/pfop'.format(config.get_default('default_api_host'))
        return http._post_with_auth(url, data, self.auth)
Exemple #4
0
    def execute(self, key, fops, force=None):
        """执行持久化处理:

        Args:
            key:    待处理的源文件
            fops:   处理详细操作,规格详见 http://developer.qiniu.com/docs/v6/api/reference/fop/
            force:  强制执行持久化处理开关

        Returns:
            一个dict变量,返回持久化处理的persistentId,类似{"persistentId": 5476bedf7823de4068253bae};
            一个ResponseInfo对象
        """
        ops = ";".join(fops)
        data = {"bucket": self.bucket, "key": key, "fops": ops}
        if self.pipeline:
            data["pipeline"] = self.pipeline
        if self.notify_url:
            data["notifyURL"] = self.notify_url
        if force == 1:
            data["force"] = 1

        url = "http://{0}/pfop".format(config.get_default("default_api_host"))
        return http._post_with_auth(url, data, self.auth)
Exemple #5
0
    def execute(self, key, fops, force=None):
        """执行持久化处理:

        Args:
            key:    待处理的源文件
            fops:   处理详细操作,规格详见 http://developer.qiniu.com/docs/v6/api/reference/fop/
            force:  强制执行持久化处理开关

        Returns:
            一个dict变量,返回持久化处理的persistentId,类似{"persistentId": 5476bedf7823de4068253bae};
            一个ResponseInfo对象
        """
        ops = ';'.join(fops)
        data = {'bucket': self.bucket, 'key': key, 'fops': ops}
        if self.pipeline:
            data['pipeline'] = self.pipeline
        if self.notify_url:
            data['notifyURL'] = self.notify_url
        if force == 1:
            data['force'] = 1

        url = '{0}/pfop'.format(config.get_default('default_api_host'))
        return http._post_with_auth(url, data, self.auth)
Exemple #6
0
 def __post(self, url, data=None):
     return http._post_with_auth(url, data, self.auth)
Exemple #7
0
 def __post(self, url, data=None):
     return http._post_with_auth(url, data, self.auth)
Exemple #8
0
# -*- coding: utf-8 -*-

import os

from qiniu import Auth, http, urlsafe_base64_encode

access_key = os.getenv('QINIU_ACCESS_KEY')
secret_key = os.getenv('QINIU_SECRET_KEY')

q = Auth(access_key, secret_key)

bucket_name = 'tmp-1811282'
region = 'z0'
url = 'http://rs.qiniu.com/mkbucketv2/' + urlsafe_base64_encode(bucket_name) + '/region/' + region
data = ''
req = http._post_with_auth(url, data, q)
print (req[1])
Exemple #9
0
if err.status_code is not 200:
    print err
    sys.exit(-1)

# 通过 Zepplin 的单选框来选择日志源空间
bucket_options = []
for bucket in sorted(buckets):
    bucket_options.append((bucket, bucket))
bucket_selected = z.select('bucket_selected', bucket_options)
bucket_custom = z.input("bucket_custom", "")
bucket = bucket_selected
if bucket_custom != "":
    bucket = bucket_custom

# get domain 使用空间域名的列举接口拿到一个域名
domains, err = http._post_with_auth(
    'http://api.qiniu.com/v6/domain/list?tbl=' + bucket, None, auth)
if err.status_code is not 200:
    print err
    sys.exit(-1)
if len(domains) is 0:
    print 'no domain in bucket'
    sys.exit(-1)

# 通过 Zepplin 初始化对象设置 hadoop 的参数配置(用来从空间中下载文件)
sc._jsc.hadoopConfiguration().set("fs.qiniu.access.key", access_key)
sc._jsc.hadoopConfiguration().set("fs.qiniu.secret.key", secret_key)
sc._jsc.hadoopConfiguration().set("fs.qiniu.bucket.domain",
                                  "http://" + domains[0])
sc._jsc.hadoopConfiguration().set("fs.qiniu.file.retention", "55")

# 输入框拿到起止日期和小时的值