generated from root/miduo_client
66 lines
2.4 KiB
Python
66 lines
2.4 KiB
Python
# -*- coding: utf-8 -*-
|
||
import oss2
|
||
import os
|
||
|
||
|
||
class jlrg():
|
||
|
||
# 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。
|
||
auth = oss2.Auth('LTAIE4jRXhLBvVLL', '74hEmfGzNEYLSFP26fO6CUZ319AY61')
|
||
# yourEndpoint填写Bucket所在地域对应的Endpoint。以华东1(杭州)为例,Endpoint填写为https://oss-cn-hangzhou.aliyuncs.com。
|
||
# 填写Bucket名称。
|
||
bucket = oss2.Bucket(auth, 'https://oss-ap-northeast-1.aliyuncs.com', 'taichuxing')
|
||
|
||
|
||
basedir = "/data/public/samba/public/jieling_dl/dev/assetBundles/"
|
||
fail_list = []
|
||
|
||
|
||
def __init__(self):
|
||
self.fileList = []
|
||
|
||
def get_all_file(self):
|
||
fo = open("/data/scripts/mht_test.txt", "r")
|
||
files = fo.readlines()
|
||
filelist = []
|
||
print(filelist)
|
||
for f in files:
|
||
file = f.strip()
|
||
if file.startswith("http") and not file.endswith("/") and not file.endswith("version.txt") and not file.endswith("files.unity3d"):
|
||
filelist.append(file)
|
||
return self.fileList
|
||
|
||
|
||
|
||
def upload_file_to_aly_cos(self, local_file_path):
|
||
if local_file_path.endswith('.DS_Store') or not os.path.isfile(local_file_path):
|
||
return
|
||
if ".svn" in local_file_path:
|
||
return
|
||
print(local_file_path)
|
||
cos_object_key = local_file_path[len(jlrg.basedir):].replace("\\", "/").lstrip("/")
|
||
print(cos_object_key)
|
||
url = 'http://download.gamenew-h5.com/' + cos_object_key
|
||
print(url)
|
||
jlrg.bucket.put_object_from_file(cos_object_key, local_file_path)
|
||
|
||
|
||
|
||
def up(self):
|
||
os.system("sh /data/scripts/url_mht_china_test.sh")
|
||
|
||
filelist = self.get_all_file()
|
||
print(filelist)
|
||
pool = ProcessPoolExecutor(4)
|
||
for file in filelist:
|
||
pool.submit(self.upload_file_to_aly_cos, file)
|
||
|
||
self.upload_file_to_aly_cos("/data/public/samba/public/jieling_dl/dev/assetBundles/mht_china/test/Android/config.txt")
|
||
self.upload_file_to_aly_cos("/data/public/samba/public/jieling_dl/dev/assetBundles/mht_china/test/Android/files.unity3d")
|
||
self.upload_file_to_aly_cos("/data/public/samba/public/jieling_dl/dev/assetBundles/mht_china/test/Android/version.txt")
|
||
|
||
|
||
if __name__ == '__main__':
|
||
z = jlrg()
|
||
z.up()
|