File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -2,3 +2,5 @@ yapf==0.23.0
22twine==1.11.0
33bumpversion==0.5.3
44pytest==3.7.4
5+ oss2==2.5.0
6+ pycryptodome==3.6.6
Original file line number Diff line number Diff line change 1+ import os
2+ import sys
3+ import ntpath
4+ import glob
5+ import configparser
6+
7+ import oss2
8+
9+ endpoint = 'http://{region}.aliyuncs.com' .format (region = 'oss-cn-shanghai' )
10+
11+ bucket_name = 'lc-frontend'
12+
13+ if __name__ == '__main__' :
14+ if len (sys .argv ) >= 2 :
15+ files = sys .argv [1 :]
16+ else :
17+ files = glob .glob ('build/lib/py_sourcemap/*.so' )
18+
19+ config = configparser .ConfigParser ()
20+ config .read ('.bumpversion.cfg' )
21+ package_version = config ['bumpversion' ]['current_version' ]
22+
23+ access_key = os .environ .get ('ALIYUN_ACCESS_KEY' )
24+ access_token = os .environ .get ('ALIYUN_ACCESS_TOKEN' )
25+
26+ auth = oss2 .Auth (access_key , access_token )
27+ bucket = oss2 .Bucket (auth , endpoint , bucket_name )
28+
29+ for file_path in files :
30+ basename = ntpath .basename (file_path )
31+ fp = open (file_path , 'rb' )
32+ target_key = 'packages/py_sourcemap/{version}/{name}' .format (
33+ version = package_version , name = basename )
34+ print ('Uploading {}...' .format (target_key ))
35+ bucket .put_object (target_key , fp .read ())
36+ fp .close ()
37+ print ('Uploaded all.' )
You can’t perform that action at this time.
0 commit comments