You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.4 KiB
43 lines
1.4 KiB
#!/usr/bin/python |
|
import oss2, os, sys, shutil |
|
from threading import Thread |
|
import time |
|
|
|
def down(path, pid, action): |
|
if not os.path.exists(path): os.mkdir(path) |
|
|
|
# 根据前缀获取文件列表 |
|
prefix = f'objs/{action}/{pid}/' |
|
filelist = oss2.ObjectIteratorV2(oss_client, prefix=prefix) |
|
print('正在下载:', prefix) |
|
for file in filelist: |
|
filename = file.key.split('/')[-1] |
|
if filename.endswith('.obj'): obj_filename = filename |
|
print('正在下载:', file.key) |
|
localfile = os.path.join(path, filename) |
|
oss_client.get_object_to_file(file.key, localfile) |
|
|
|
if __name__ == '__main__': |
|
workdir = 'd:\\' |
|
AccessKeyId = 'LTAI5tSReWm8hz7dSYxxth8f' |
|
AccessKeySecret = '8ywTDF9upPAtvgXtLKALY2iMYHIxdS' |
|
Endpoint = 'oss-cn-shanghai.aliyuncs.com' |
|
Bucket = 'suwa3d-securedata' |
|
oss_client = oss2.Bucket(oss2.Auth(AccessKeyId, AccessKeySecret), Endpoint, Bucket) |
|
|
|
if len(sys.argv) == 2: |
|
pids = sys.argv[1].split(',') |
|
action = 'print' |
|
elif len(sys.argv) == 3: |
|
pids = sys.argv[1].split(',') |
|
action = sys.argv[2] |
|
else: |
|
print('用法:python downobjfromoss.py <pids> [print|auto]') |
|
|
|
workdir = os.path.join(workdir, action) |
|
if not os.path.exists(workdir): os.mkdir(workdir) |
|
for pid in pids: |
|
path = os.path.join(workdir, pid) |
|
down(path, pid, action) |
|
|
|
print('下载完成') |