Fixed some crashes in assetManager
Copy in the rest of the web assets
This commit is contained in:
@@ -27,6 +27,7 @@ from cStringIO import StringIO
|
||||
import ctypes
|
||||
import platform
|
||||
from itertools import cycle, islice, product
|
||||
import shutil
|
||||
|
||||
def get_program_path():
|
||||
if hasattr(sys, "frozen") or imp.is_frozen("__main__"):
|
||||
@@ -358,3 +359,37 @@ class ANSIColorFormatter(HighlightingFormatter):
|
||||
else:
|
||||
# No coloring if it's not to be highlighted or colored
|
||||
return logging.Formatter.format(self, record)
|
||||
|
||||
|
||||
def mirror_dir(src, dst, entities=None):
|
||||
'''copies all of the entities from src to dst'''
|
||||
if not os.path.exists(dst):
|
||||
os.mkdir(dst)
|
||||
if entities and type(entities) != list: raise Exception("Expected a list, got a %r instead" % type(entities))
|
||||
|
||||
# files which are problematic and should not be copied
|
||||
# usually, generated by the OS
|
||||
skip_files = ['Thumbs.db', '.DS_Store']
|
||||
|
||||
for entry in os.listdir(src):
|
||||
if entry in skip_files:
|
||||
continue
|
||||
if entities and entry not in entities:
|
||||
continue
|
||||
|
||||
if os.path.isdir(os.path.join(src,entry)):
|
||||
mirror_dir(os.path.join(src, entry), os.path.join(dst, entry))
|
||||
elif os.path.isfile(os.path.join(src,entry)):
|
||||
try:
|
||||
shutil.copy(os.path.join(src, entry), os.path.join(dst, entry))
|
||||
except IOError as outer:
|
||||
try:
|
||||
# maybe permission problems?
|
||||
src_stat = os.stat(os.path.join(src, entry))
|
||||
os.chmod(os.path.join(src, entry), src_stat.st_mode | stat.S_IRUSR)
|
||||
dst_stat = os.stat(os.path.join(dst, entry))
|
||||
os.chmod(os.path.join(dst, entry), dst_stat.st_mode | stat.S_IWUSR)
|
||||
except OSError: # we don't care if this fails
|
||||
pass
|
||||
shutil.copy(os.path.join(src, entry), os.path.join(dst, entry))
|
||||
# if this stills throws an error, let it propagate up
|
||||
|
||||
Reference in New Issue
Block a user