Fixed long paths with windows (finally)
This commit is contained in:
parent
d393987117
commit
d7beb8d860
3 changed files with 58 additions and 22 deletions
|
|
@ -197,7 +197,7 @@ class Setting(object):
|
||||||
|
|
||||||
def extract(self, ex_path, version):
|
def extract(self, ex_path, version):
|
||||||
if os.path.exists(ex_path):
|
if os.path.exists(ex_path):
|
||||||
shutil.rmtree(ex_path, ignore_errors=True)
|
utils.rmtree(ex_path, ignore_errors=True)
|
||||||
|
|
||||||
path = self.save_file_path(version)
|
path = self.save_file_path(version)
|
||||||
|
|
||||||
|
|
@ -225,8 +225,8 @@ class Setting(object):
|
||||||
if os.path.exists(dir_name):
|
if os.path.exists(dir_name):
|
||||||
for p in os.listdir(dir_name):
|
for p in os.listdir(dir_name):
|
||||||
abs_file = utils.path_join(dir_name, p)
|
abs_file = utils.path_join(dir_name, p)
|
||||||
shutil.move(abs_file, ex_path)
|
utils.move(abs_file, ex_path)
|
||||||
shutil.rmtree(dir_name, ignore_errors=True)
|
utils.rmtree(dir_name, ignore_errors=True)
|
||||||
|
|
||||||
def get_file_bytes(self, version):
|
def get_file_bytes(self, version):
|
||||||
fbytes = []
|
fbytes = []
|
||||||
|
|
@ -637,7 +637,7 @@ class CommandBase(object):
|
||||||
if not icon_path.endswith('.icns'):
|
if not icon_path.endswith('.icns'):
|
||||||
save_icns(icon_path, icns_path)
|
save_icns(icon_path, icns_path)
|
||||||
else:
|
else:
|
||||||
shutil.copy(icon_path, icns_path)
|
utils.copy(icon_path, icns_path)
|
||||||
|
|
||||||
def replace_icon_in_exe(self, exe_path):
|
def replace_icon_in_exe(self, exe_path):
|
||||||
icon_setting = self.get_setting('icon')
|
icon_setting = self.get_setting('icon')
|
||||||
|
|
@ -658,11 +658,11 @@ class CommandBase(object):
|
||||||
|
|
||||||
output_dir = utils.path_join(self.output_dir(), self.project_name())
|
output_dir = utils.path_join(self.output_dir(), self.project_name())
|
||||||
if os.path.exists(output_dir):
|
if os.path.exists(output_dir):
|
||||||
shutil.rmtree(output_dir, ignore_errors=True)
|
utils.rmtree(output_dir, ignore_errors=True)
|
||||||
|
|
||||||
temp_dir = utils.path_join(TEMP_DIR, 'webexectemp')
|
temp_dir = utils.path_join(TEMP_DIR, 'webexectemp')
|
||||||
if os.path.exists(temp_dir):
|
if os.path.exists(temp_dir):
|
||||||
shutil.rmtree(temp_dir, ignore_errors=True)
|
utils.rmtree(temp_dir, ignore_errors=True)
|
||||||
|
|
||||||
self.progress_text = 'Making new directories...\n'
|
self.progress_text = 'Making new directories...\n'
|
||||||
|
|
||||||
|
|
@ -689,7 +689,7 @@ class CommandBase(object):
|
||||||
|
|
||||||
app_nw_folder = utils.path_join(temp_dir, self.project_name()+'.nwf')
|
app_nw_folder = utils.path_join(temp_dir, self.project_name()+'.nwf')
|
||||||
|
|
||||||
shutil.copytree(self.project_dir(), app_nw_folder,
|
utils.copytree(self.project_dir(), app_nw_folder,
|
||||||
ignore=shutil.ignore_patterns(output_dir))
|
ignore=shutil.ignore_patterns(output_dir))
|
||||||
|
|
||||||
zip_files(zip_file, self.project_dir(), exclude_paths=[output_dir])
|
zip_files(zip_file, self.project_dir(), exclude_paths=[output_dir])
|
||||||
|
|
@ -706,13 +706,13 @@ class CommandBase(object):
|
||||||
export_dest = export_dest.replace('node-webkit', 'nwjs')
|
export_dest = export_dest.replace('node-webkit', 'nwjs')
|
||||||
|
|
||||||
if os.path.exists(export_dest):
|
if os.path.exists(export_dest):
|
||||||
shutil.rmtree(export_dest, ignore_errors=True)
|
utils.rmtree(export_dest, ignore_errors=True)
|
||||||
|
|
||||||
# shutil will make the directory for us
|
# shutil will make the directory for us
|
||||||
shutil.copytree(get_data_path('files/'+ex_setting.name),
|
utils.copytree(get_data_path('files/'+ex_setting.name),
|
||||||
export_dest,
|
export_dest,
|
||||||
ignore=shutil.ignore_patterns('place_holder.txt'))
|
ignore=shutil.ignore_patterns('place_holder.txt'))
|
||||||
shutil.rmtree(get_data_path('files/'+ex_setting.name), ignore_errors=True)
|
utils.rmtree(get_data_path('files/'+ex_setting.name), ignore_errors=True)
|
||||||
self.progress_text += '.'
|
self.progress_text += '.'
|
||||||
|
|
||||||
if 'mac' in ex_setting.name:
|
if 'mac' in ex_setting.name:
|
||||||
|
|
@ -722,11 +722,11 @@ class CommandBase(object):
|
||||||
self.project_name()+'.app')
|
self.project_name()+'.app')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
shutil.move(utils.path_join(export_dest,
|
utils.move(utils.path_join(export_dest,
|
||||||
'nwjs.app'),
|
'nwjs.app'),
|
||||||
app_path)
|
app_path)
|
||||||
except IOError:
|
except IOError:
|
||||||
shutil.move(utils.path_join(export_dest,
|
utils.move(utils.path_join(export_dest,
|
||||||
'node-webkit.app'),
|
'node-webkit.app'),
|
||||||
app_path)
|
app_path)
|
||||||
|
|
||||||
|
|
@ -751,9 +751,9 @@ class CommandBase(object):
|
||||||
'app.nw')
|
'app.nw')
|
||||||
|
|
||||||
if uncompressed:
|
if uncompressed:
|
||||||
shutil.copytree(app_nw_folder, app_nw_res)
|
utils.copytree(app_nw_folder, app_nw_res)
|
||||||
else:
|
else:
|
||||||
shutil.copy(zip_file, app_nw_res)
|
utils.copy(zip_file, app_nw_res)
|
||||||
self.create_icns_for_app(utils.path_join(app_path,
|
self.create_icns_for_app(utils.path_join(app_path,
|
||||||
'Contents',
|
'Contents',
|
||||||
'Resources',
|
'Resources',
|
||||||
|
|
@ -802,13 +802,13 @@ class CommandBase(object):
|
||||||
self.logger.error(error)
|
self.logger.error(error)
|
||||||
self.output_err += error
|
self.output_err += error
|
||||||
finally:
|
finally:
|
||||||
shutil.rmtree(temp_dir, ignore_errors=True)
|
utils.rmtree(temp_dir, ignore_errors=True)
|
||||||
|
|
||||||
def make_desktop_file(self, nw_path, export_dest):
|
def make_desktop_file(self, nw_path, export_dest):
|
||||||
icon_set = self.get_setting('icon')
|
icon_set = self.get_setting('icon')
|
||||||
icon_path = utils.path_join(self.project_dir(), icon_set.value)
|
icon_path = utils.path_join(self.project_dir(), icon_set.value)
|
||||||
if os.path.exists(icon_path) and icon_set.value:
|
if os.path.exists(icon_path) and icon_set.value:
|
||||||
shutil.copy(icon_path, export_dest)
|
utils.copy(icon_path, export_dest)
|
||||||
icon_path = utils.path_join(export_dest, os.path.basename(icon_path))
|
icon_path = utils.path_join(export_dest, os.path.basename(icon_path))
|
||||||
else:
|
else:
|
||||||
icon_path = ''
|
icon_path = ''
|
||||||
|
|
@ -886,7 +886,7 @@ class CommandBase(object):
|
||||||
f_path = setting.value.replace(self.project_dir(), '')
|
f_path = setting.value.replace(self.project_dir(), '')
|
||||||
if os.path.isabs(f_path):
|
if os.path.isabs(f_path):
|
||||||
try:
|
try:
|
||||||
shutil.copy(setting.value, self.project_dir())
|
utils.copy(setting.value, self.project_dir())
|
||||||
self.logger.info(u'Copying file {} to {}'.format(setting.value, self.project_dir()))
|
self.logger.info(u'Copying file {} to {}'.format(setting.value, self.project_dir()))
|
||||||
except shutil.Error as e: # same file warning
|
except shutil.Error as e: # same file warning
|
||||||
self.logger.warning(u'Warning: {}'.format(e))
|
self.logger.warning(u'Warning: {}'.format(e))
|
||||||
|
|
|
||||||
1
main.py
1
main.py
|
|
@ -1037,7 +1037,6 @@ class MainWindow(QtGui.QMainWindow, CommandBase):
|
||||||
script_label.setMinimumWidth(150)
|
script_label.setMinimumWidth(150)
|
||||||
|
|
||||||
self.script_line = QtGui.QLineEdit()
|
self.script_line = QtGui.QLineEdit()
|
||||||
self.script_line.setReadOnly(True)
|
|
||||||
|
|
||||||
script_setting = self.get_setting('custom_script')
|
script_setting = self.get_setting('custom_script')
|
||||||
self.script_line.setObjectName(script_setting.name)
|
self.script_line.setObjectName(script_setting.name)
|
||||||
|
|
|
||||||
37
utils.py
37
utils.py
|
|
@ -3,6 +3,7 @@ import os, zipfile, io, platform
|
||||||
import sys, tempfile
|
import sys, tempfile
|
||||||
import subprocess
|
import subprocess
|
||||||
from appdirs import AppDirs
|
from appdirs import AppDirs
|
||||||
|
import shutil
|
||||||
|
|
||||||
#try:
|
#try:
|
||||||
# import zlib
|
# import zlib
|
||||||
|
|
@ -29,7 +30,9 @@ def path_join(base, *rest):
|
||||||
new_rest.append(rest[i].decode('utf-8'))
|
new_rest.append(rest[i].decode('utf-8'))
|
||||||
except UnicodeEncodeError:
|
except UnicodeEncodeError:
|
||||||
new_rest.append(unicode(rest[i]))
|
new_rest.append(unicode(rest[i]))
|
||||||
|
|
||||||
rpath = u'/'.join(new_rest)
|
rpath = u'/'.join(new_rest)
|
||||||
|
|
||||||
if os.path.isabs(rpath):
|
if os.path.isabs(rpath):
|
||||||
return rpath
|
return rpath
|
||||||
else:
|
else:
|
||||||
|
|
@ -40,6 +43,9 @@ def get_data_path(dir_path):
|
||||||
dirs = AppDirs('Web2Executable', 'Web2Executable')
|
dirs = AppDirs('Web2Executable', 'Web2Executable')
|
||||||
data_path = path_join(dirs.user_data_dir, *parts)
|
data_path = path_join(dirs.user_data_dir, *parts)
|
||||||
|
|
||||||
|
if is_windows():
|
||||||
|
data_path = data_path.replace(u'\\', u'/')
|
||||||
|
|
||||||
if not os.path.exists(data_path):
|
if not os.path.exists(data_path):
|
||||||
os.makedirs(data_path)
|
os.makedirs(data_path)
|
||||||
|
|
||||||
|
|
@ -50,6 +56,37 @@ def get_data_file_path(file_path):
|
||||||
data_path = get_data_path('/'.join(parts[:-1]))
|
data_path = get_data_path('/'.join(parts[:-1]))
|
||||||
return path_join(data_path, parts[-1])
|
return path_join(data_path, parts[-1])
|
||||||
|
|
||||||
|
def rmtree(path, **kwargs):
|
||||||
|
if is_windows():
|
||||||
|
if os.path.isabs(path):
|
||||||
|
path = u'//?/'+path
|
||||||
|
shutil.rmtree(path, **kwargs)
|
||||||
|
|
||||||
|
def copy(src, dest, **kwargs):
|
||||||
|
if is_windows():
|
||||||
|
if os.path.isabs(src):
|
||||||
|
src = u'//?/'+src
|
||||||
|
if os.path.isabs(dest):
|
||||||
|
dest = u'//?/'+dest
|
||||||
|
shutil.copy(src, dest, **kwargs)
|
||||||
|
|
||||||
|
def move(src, dest, **kwargs):
|
||||||
|
if is_windows():
|
||||||
|
if os.path.isabs(src):
|
||||||
|
src = u'//?/'+src
|
||||||
|
if os.path.isabs(dest):
|
||||||
|
dest = u'//?/'+dest
|
||||||
|
shutil.move(src, dest, **kwargs)
|
||||||
|
|
||||||
|
def copytree(src, dest, **kwargs):
|
||||||
|
if is_windows():
|
||||||
|
if os.path.isabs(src):
|
||||||
|
src = u'//?/'+src
|
||||||
|
if os.path.isabs(dest):
|
||||||
|
dest = u'//?/'+dest
|
||||||
|
shutil.copytree(src, dest, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def log(*args):
|
def log(*args):
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print(*args)
|
print(*args)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue