def compress_nw(self, electron_path):
compression = self.get_setting('electron_compression_level')
if compression.value == 0:
return
comp_dict = {'Darwin64bit': get_file('files/compressors/upx-mac'),
'Darwin32bit': get_file('files/compressors/upx-mac'),
'Linux64bit': get_file('files/compressors/upx-linux-x64'),
'Linux32bit': get_file('files/compressors/upx-linux-x32'),
'Windows64bit': get_file('files/compressors/upx-win.exe'),
'Windows32bit': get_file('files/compressors/upx-win.exe')
}
if is_installed():
comp_dict['Windows64bit'] = get_data_file_path('files/compressors/upx-win.exe')
comp_dict['Windows32bit'] = get_data_file_path('files/compressors/upx-win.exe')
plat = platform.system()+platform.architecture()[0]
upx_version = comp_dict.get(plat, None)
if upx_version is not None:
upx_bin = upx_version
os.chmod(upx_bin, 0o755)
cmd = [upx_bin, '--lzma', u'-{}'.format(compression.value), electron_path]
if platform.system() == 'Windows':
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
startupinfo.wShowWindow = subprocess.SW_HIDE
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE,
startupinfo=startupinfo)
else:
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE)
self.progress_text = '\n\n'
self.progress_text = 'Compressing files'
while proc.poll() is None:
self.progress_text += '.'
time.sleep(2)
output, err = proc.communicate()
评论列表
文章目录