向七牛上传zip包

# -*- coding: utf-8 -*-
# flake8: noqa
from qiniu import Auth
from qiniu import BucketManager
import mysql.connector
sumr = 0
count = 0
real_count = 0
access_key = ‘WR5JtPxdsdYOgladSBDXZl3idmqjBzqkX5E-UDfG’
secret_key = ‘QOsocxMR2BN9eNZek3gjKeP2j_KznEl-H0JOg5g9’
# 初始化Auth状态
q = Auth(access_key, secret_key)
# 初始化BucketManager
bucket = BucketManager(q)
# 你要测试的空间, 并且这个key在你空间中存在
bucket_name = ‘axx-homework’

conn = mysql.connector.connect(user=’aixuexidball’, password=’aixuexi_2016dball’,host=’rm-2zefci7s9f4bpy9gt.mysql.rds.aliyuncs.com’, database=’managesystemv1.0′)
cursor = conn.cursor()
cursor.execute(
“SELECT correct_result FROM c_student_homework_answer_record WHERE correct_result LIKE ‘%http://image1.aixuexi.com%'”)

values = cursor.fetchall()
cursor.close()
conn.close()
values_set = set()
for value in values:
count+=1
values_set.add(value)

for value in values_set:
real_value = value[0].split(‘/’)[-1]
real_count+=1
# print(real_value)
# real_value = value[0].replace(‘http://image1.aixuexi.com/’, ”)
try:
ret, info = bucket.stat(bucket_name, real_value)
if info.status_code == 612:
sumr+=1
print(real_value)
f=open(‘goods.txt’, ‘a’)
f.write(str(real_value+’\n’))
f.close()
except BaseException as e:
print(“111”)
continue
f=open(‘goods.txt’, ‘a’)
f.write(“共计:”+str(count)+’\n’+”真实共计:”+str(real_count)+’\n’+”不存在共计:”+str(sumr))
f.close()
print(“共计:”+str(count))
print(“真实共计:”+str(real_count))
print(“不存在共计:”+str(sumr))

发表评论

电子邮件地址不会被公开。 必填项已用*标注