mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-11 03:55:43 +00:00
[WebUI] Print error if minify script encounters error with closure
This commit is contained in:
parent
6ce9f77e17
commit
cea50f319d
@ -35,8 +35,12 @@ def module_exists(module_name):
|
|||||||
if module_exists('closure'):
|
if module_exists('closure'):
|
||||||
def minify_closure(file_in, file_out):
|
def minify_closure(file_in, file_out):
|
||||||
import subprocess
|
import subprocess
|
||||||
subprocess.call(['closure', '--js', file_in, '--js_output_file', file_out,
|
try:
|
||||||
'-W', 'QUIET'])
|
subprocess.check_call(['closure', '-W', 'QUIET',
|
||||||
|
'--js', file_in, '--js_output_file', file_out])
|
||||||
|
return True
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
return False
|
||||||
elif module_exists('slimit'):
|
elif module_exists('slimit'):
|
||||||
from slimit import minify
|
from slimit import minify
|
||||||
elif module_exists('jsmin'):
|
elif module_exists('jsmin'):
|
||||||
@ -80,11 +84,12 @@ def concat_src_files(file_list, fileout_path):
|
|||||||
|
|
||||||
def minify_file(file_debug, file_minified):
|
def minify_file(file_debug, file_minified):
|
||||||
try:
|
try:
|
||||||
minify_closure(file_debug, file_minified)
|
return minify_closure(file_debug, file_minified)
|
||||||
except NameError:
|
except NameError:
|
||||||
with open(file_minified, 'w') as file_out:
|
with open(file_minified, 'w') as file_out:
|
||||||
with open(file_debug, 'r') as file_in:
|
with open(file_debug, 'r') as file_in:
|
||||||
file_out.write(minify(file_in.read()))
|
file_out.write(minify(file_in.read()))
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def minify_js_dir(source_dir):
|
def minify_js_dir(source_dir):
|
||||||
@ -99,8 +104,10 @@ def minify_js_dir(source_dir):
|
|||||||
return
|
return
|
||||||
|
|
||||||
concat_src_files(source_files, file_debug_js)
|
concat_src_files(source_files, file_debug_js)
|
||||||
minify_file(file_debug_js, file_minified_js)
|
if minify_file(file_debug_js, file_minified_js):
|
||||||
print('Minified %s' % source_dir)
|
print('Minified %s' % source_dir)
|
||||||
|
else:
|
||||||
|
print('Error minifying %s' % source_dir)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if len(sys.argv) != 2:
|
if len(sys.argv) != 2:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user