mirror of https://github.com/axmolengine/axmol.git
Merge pull request #6563 from dumganhar/v3
Updates download-deps.py, write file with permission information while unziping.
This commit is contained in:
commit
6bc0550c70
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/env python
|
||||||
#coding=utf-8
|
#coding=utf-8
|
||||||
#
|
#
|
||||||
# ./download-deps.py
|
# ./download-deps.py
|
||||||
|
@ -13,6 +13,7 @@ import urllib2
|
||||||
import os.path,zipfile
|
import os.path,zipfile
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
|
import traceback
|
||||||
from sys import stdout
|
from sys import stdout
|
||||||
|
|
||||||
prefix = 'https://codeload.github.com/minggo/cocos2d-x-resources/zip/'
|
prefix = 'https://codeload.github.com/minggo/cocos2d-x-resources/zip/'
|
||||||
|
@ -41,21 +42,21 @@ def download_file(url, file_name):
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
def unzip(src,dst):
|
def unzip(src,dst):
|
||||||
zfile = zipfile.ZipFile(src)
|
zf = zipfile.ZipFile(src)
|
||||||
for name in zfile.namelist():
|
for file in zf.filelist:
|
||||||
(dirname, filename) = os.path.split(name)
|
name = file.filename
|
||||||
if filename == '':
|
perm = ((file.external_attr >> 16L) & 0777)
|
||||||
# directory
|
|
||||||
if not os.path.exists(dirname):
|
if name.endswith('/'):
|
||||||
path = os.path.join(dst,dirname)
|
outfile = os.path.join(dst, name)
|
||||||
os.mkdir(dirname)
|
if not os.path.exists(outfile):
|
||||||
|
os.mkdir(outfile, perm)
|
||||||
else:
|
else:
|
||||||
# file
|
outfile = os.path.join(dst, name)
|
||||||
path = os.path.join(dst, name)
|
fh = os.open(outfile, os.O_CREAT | os.O_WRONLY, perm)
|
||||||
fd = open(path, 'w')
|
os.write(fh, zf.read(name))
|
||||||
fd.write(zfile.read(name))
|
os.close(fh)
|
||||||
fd.close()
|
zf.close()
|
||||||
zfile.close()
|
|
||||||
|
|
||||||
def copy_files(src, dst):
|
def copy_files(src, dst):
|
||||||
for item in os.listdir(src):
|
for item in os.listdir(src):
|
||||||
|
@ -86,5 +87,5 @@ if __name__ == '__main__':
|
||||||
try:
|
try:
|
||||||
main()
|
main()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
traceback.print_exc()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
Loading…
Reference in New Issue