generated from root/miduo_client
107 lines
3.8 KiB
Python
107 lines
3.8 KiB
Python
# -*- coding: utf-8 -*-
|
||
# # Auther: Wang Qi
|
||
# !/usr/bin/env python
|
||
# encoding: utf-8
|
||
import os
|
||
import oss2
|
||
import sys
|
||
import base64
|
||
import hashlib
|
||
import requests
|
||
import subprocess
|
||
import urllib3
|
||
import logging
|
||
import time
|
||
import random
|
||
import argparse
|
||
from threading import Thread, current_thread
|
||
from concurrent.futures import ProcessPoolExecutor
|
||
from qcloud_cos import CosConfig
|
||
from qcloud_cos import CosS3Client
|
||
|
||
|
||
|
||
class jlrg():
|
||
basedir = "/data/public/samba/public/jieling_dl/dev/assetBundles/"
|
||
dir_name = "mht_china"
|
||
fail_list = []
|
||
|
||
logging.basicConfig(level=logging.INFO, stream=sys.stdout)
|
||
secret_id = 'AKIDRJxLRFFzwcmiNlLzqPggdplPlrpVec2A' # <20>滻Ϊ<E6BBBB>û<EFBFBD><C3BB><EFBFBD> secretId
|
||
secret_key = 'zh8JDqJZYLq42j9NL2RYOyGI9kDOIGxN' # <20>滻Ϊ<E6BBBB>û<EFBFBD><C3BB><EFBFBD> secretKey
|
||
region = 'ap-guangzhou' # <20>滻Ϊ<E6BBBB>û<EFBFBD><C3BB><EFBFBD> Region
|
||
token = None # ʹ<><CAB9><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Կ<EFBFBD><D4BF>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD> Token<65><6E>Ĭ<EFBFBD><C4AC>Ϊ<EFBFBD>գ<EFBFBD><D5A3>ɲ<EFBFBD><C9B2><EFBFBD>
|
||
scheme = 'https' # ָ<><D6B8>ʹ<EFBFBD><CAB9> http/https Э<><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> COS<4F><53>Ĭ<EFBFBD><C4AC>Ϊ https<70><73><EFBFBD>ɲ<EFBFBD><C9B2><EFBFBD>
|
||
config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key, Token=token, Scheme=scheme)
|
||
# 2. <20><>ȡ<EFBFBD>ͻ<EFBFBD><CDBB>˶<EFBFBD><CBB6><EFBFBD>
|
||
client = CosS3Client(config)
|
||
|
||
def __init__(self):
|
||
self.fileList = []
|
||
|
||
|
||
def get_all_file(self):
|
||
fo = open("/data/scripts/mht_china_test.txt", "r")
|
||
files = fo.readlines()
|
||
filelist = []
|
||
for f in files:
|
||
file = f.strip()
|
||
if not file.startswith("http") and not file.endswith("/") and not file.endswith("version.txt") and not file.endswith("files.unity3d"):
|
||
filelist.append(file)
|
||
return filelist
|
||
|
||
def flushurl(self,url):
|
||
keydict = {
|
||
'Action': 'RefreshCdnUrl',
|
||
'Timestamp': str(int(time.time())),
|
||
'Nonce': str(int(random.random() * 1000)),
|
||
'SecretId': jlrg.secret_id,
|
||
'urls.0': url
|
||
}
|
||
return keydict
|
||
|
||
def upload_file_to_txy_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)
|
||
# print(11111)
|
||
cos_object_key = local_file_path[len(jlrg.basedir):].replace("\\", "/").lstrip("/")
|
||
print(cos_object_key)
|
||
url = 'http://' + "jl.tyu89.wang" + "/" + cos_object_key
|
||
print(url)
|
||
response = jlrg.client.upload_file(
|
||
Bucket='internal-jieling-1302131159',
|
||
LocalFilePath=local_file_path,
|
||
Key=cos_object_key,
|
||
PartSize=1,
|
||
MAXThread=10,
|
||
EnableMD5=False
|
||
)
|
||
self.flushurl(url)
|
||
return (response['ETag'])
|
||
|
||
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:
|
||
# print(file)
|
||
pool.submit(self.upload_file_to_txy_cos, file)
|
||
self.upload_file_to_txy_cos("/data/public/samba/public/jieling_dl/dev/assetBundles/mht_china/test/Android/config.txt")
|
||
self.upload_file_to_txy_cos("/data/public/samba/public/jieling_dl/dev/assetBundles/mht_china/test/Android/config.txt")
|
||
self.upload_file_to_txy_cos("/data/public/samba/public/jieling_dl/dev/assetBundles/mht_china/test/Android/files.unity3d")
|
||
self.upload_file_to_txy_cos("/data/public/samba/public/jieling_dl/dev/assetBundles/mht_china/test/Android/version.txt")
|
||
|
||
|
||
|
||
#https://dcdn.aliyuncs.com/?Action=RefreshDcdnObjectCaches&ObjectPath=download.gamenew-h5.com/Japan/SW/&ObjectType=Directory&Version=2018-01-15&Timestamp=2021-05-08T03:32:45Z&SignatureNonce=15215528852396&AccessKeyId=LTAIE4jRXhLBvVLL&SignatureMethod=HMAC-SHA1
|
||
|
||
|
||
if __name__ == '__main__':
|
||
z = jlrg()
|
||
z.up()
|