python - 多次运行后,提示{"error":"no such bucket"}
问题描述
第一次转码pfop成功
第二此刷新url,成功
第三此次转码pfop , 失败,{'error':'no such bucket'}
调用的地方
qiniuUtil = QiniuUtil()qiniuUtil.transcode_low_m3u8('dz/msjt/xxx.mp4')qiniuUtil.refresh_url('http://i.haierzhongyou.com/dz/msjt/xxx.mp4_low.m3u8')qiniuUtil.transcode_low_m3u8('dz/msjt/xxx.mp4')
类:
class QiniuUtil(object): logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(name)s %(levelname)s lineno:%(lineno)d %(message)s') def __init__(self):self.logger = logging.getLogger(’qiniu’)self.access_key = setting.qiniu_access_keyself.secret_key = setting.qiniu_secret_keyself.bucket = setting.qiniu_video_bucket_nameself.pipeline = setting.pipelineself.notify_url = setting.notify_url # 视频转码 def transcode_low_m3u8(self, key):# key 要转码的文件所在的空间和文件名。default_fops = 'avthumb/m3u8/noDomain/1/segtime/10/vcodec/libx264/s/640x480/vb/500k/autoscale/1'q = Auth(self.access_key, self.secret_key)self.logger.debug(q)fops = op_save(default_fops, self.bucket, key + ’_low.m3u8’)self.logger.debug(fops)pfop = PersistentFop(q, self.bucket, self.pipeline, self.notify_url)ops = []ops.append(fops)self.logger.debug(ops)ret, info = pfop.execute(key, ops, 1)self.logger.info(info)self.logger.info(ret)return ret, info # 刷新缓存 def refresh_url(self, url):# url 要刷新的链接。q = Auth(self.access_key, self.secret_key)cdn_manager = CdnManager(q)urls = [url]ret, info = cdn_manager.refresh_urls(urls)self.logger.info(info)self.logger.info(ret)return ret, info
日志输出如下:
2017-05-11 18:32:51,045 qiniu DEBUG lineno:50 <qiniu.auth.Auth object at 0x000000000371EA90>2017-05-11 18:32:51,045 qiniu DEBUG lineno:52 avthumb/m3u8/noDomain/1/segtime/10/vcodec/libx264/s/640x480/vb/500k/autoscale/1|saveas/dmlkZW90ZXN0OmR6L21zanQvMTE1M2JmMWItOWY1My00MTJkLTk2NTQtM2FlNThjOWE3MThkLm1wNF9sb3cubTN1OA==2017-05-11 18:32:51,045 qiniu DEBUG lineno:58 [’avthumb/m3u8/noDomain/1/segtime/10/vcodec/libx264/s/640x480/vb/500k/autoscale/1|saveas/dmlkZW90ZXN0OmR6L21zanQvMTE1M2JmMWItOWY1My00MTJkLTk2NTQtM2FlNThjOWE3MThkLm1wNF9sb3cubTN1OA==’]2017-05-11 18:32:51,046 requests.packages.urllib3.util.retry DEBUG lineno:191 Converted retries value: 3 -> Retry(total=3, connect=None, read=None, redirect=None)2017-05-11 18:32:51,046 requests.packages.urllib3.connectionpool DEBUG lineno:207 Starting new HTTP connection (1): api.qiniu.com2017-05-11 18:32:51,256 requests.packages.urllib3.connectionpool DEBUG lineno:395 http://api.qiniu.com:80 'POST /pfop HTTP/1.1' 200 462017-05-11 18:32:51,278 qiniu INFO lineno:61 exception:None, status_code:200, _ResponseInfo__response:<Response [200]>, text_body:{'persistentId':'z0.59143dc545a2650c99df9f34'}, req_id:7gkAAIB_6qyzhr0U, 7gkAAIB_6qyzhr0U, 7gkAAIB_6qyzhr0U, x_log:rs33_8.sel;rwro.get;RS:1;PFOPMQ:60;STATUS;PFOP:133;ZONEPROXY:134;APIS:1352017-05-11 18:32:51,278 qiniu INFO lineno:62 {u’persistentId’: u’z0.59143dc545a2650c99df9f34’}2017-05-11 18:32:51,279 requests.packages.urllib3.connectionpool DEBUG lineno:207 Starting new HTTP connection (1): fusion.qiniuapi.com2017-05-11 18:32:51,368 requests.packages.urllib3.connectionpool DEBUG lineno:395 http://fusion.qiniuapi.com:80 'POST /v2/tune/refresh HTTP/1.1' 200 1812017-05-11 18:32:51,369 qiniu INFO lineno:73 exception:None, status_code:200, _ResponseInfo__response:<Response [200]>, text_body:{'code':200,'error':'success','requestId':'59143dc5e3ab3a25f0af784b','invalidUrls':null,'invalidDirs':null,'urlQuotaDay':500,'urlSurplusDay':481,'dirQuotaDay':10,'dirSurplusDay':10}, req_id:pT8AADMSLbuzhr0U, pT8AADMSLbuzhr0U, x_log:fusiondomain;fusionrefresh_v3:5;APIS:72017-05-11 18:32:51,369 qiniu INFO lineno:74 {u’code’: 200, u’dirSurplusDay’: 10, u’urlSurplusDay’: 481, u’invalidDirs’: None, u’invalidUrls’: None, u’requestId’: u’59143dc5e3ab3a25f0af784b’, u’error’: u’success’, u’urlQuotaDay’: 500, u’dirQuotaDay’: 10}2017-05-11 18:32:51,369 qiniu DEBUG lineno:50 <qiniu.auth.Auth object at 0x00000000037B62B0>2017-05-11 18:32:51,369 qiniu DEBUG lineno:52 avthumb/m3u8/noDomain/1/segtime/10/vcodec/libx264/s/640x480/vb/500k/autoscale/1|saveas/dmlkZW90ZXN0OmR6L21zanQvMTE1M2JmMWItOWY1My00MTJkLTk2NTQtM2FlNThjOWE3MThkLm1wNF9sb3cubTN1OA==2017-05-11 18:32:51,369 qiniu DEBUG lineno:58 [’avthumb/m3u8/noDomain/1/segtime/10/vcodec/libx264/s/640x480/vb/500k/autoscale/1|saveas/dmlkZW90ZXN0OmR6L21zanQvMTE1M2JmMWItOWY1My00MTJkLTk2NTQtM2FlNThjOWE3MThkLm1wNF9sb3cubTN1OA==’]2017-05-11 18:32:51,411 requests.packages.urllib3.connectionpool DEBUG lineno:395 http://api.qiniu.com:80 'POST /pfop HTTP/1.1' 631 262017-05-11 18:32:51,413 qiniu INFO lineno:61 exception:None, status_code:631, _ResponseInfo__response:<Response [631]>, text_body:{'error':'no such bucket'}, req_id:JlEAAMz_vL2zhr0U, JlEAAMz_vL2zhr0U, error:no such bucket, x_log:TBLMGR:1/612;UC:3/612;CFGG:7/612;ZONEPROXY:8/631;APIS:8/6312017-05-11 18:32:51,413 qiniu INFO lineno:62 None
问题解答
回答1:看来你使用的是七牛云的python的sdk,首先从这个错误可以看到你七牛云上是没有创建对应目录的,可以理解为对应url的地址的文件不存在。