diff options
author | Calum Lind <calumlind+deluge@gmail.com> | 2016-05-19 15:12:14 +0200 |
---|---|---|
committer | Calum Lind <calumlind+deluge@gmail.com> | 2016-05-19 16:47:15 +0200 |
commit | cea50f319d51900cc555289c6f50e2f069116b2f (patch) | |
tree | 54b6d5b5766d3823ef8a995180db867db00c3fb8 /minify_web_js.py | |
parent | [WebUI] Handle missing script files and fallback to available files (diff) | |
download | deluge-cea50f319d51900cc555289c6f50e2f069116b2f.tar.xz deluge-cea50f319d51900cc555289c6f50e2f069116b2f.zip |
[WebUI] Print error if minify script encounters error with closure
Diffstat (limited to 'minify_web_js.py')
-rwxr-xr-x | minify_web_js.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/minify_web_js.py b/minify_web_js.py index 947da3052..645241b05 100755 --- a/minify_web_js.py +++ b/minify_web_js.py @@ -35,8 +35,12 @@ def module_exists(module_name): if module_exists('closure'): def minify_closure(file_in, file_out): import subprocess - subprocess.call(['closure', '--js', file_in, '--js_output_file', file_out, - '-W', 'QUIET']) + try: + 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'): from slimit import minify elif module_exists('jsmin'): @@ -80,11 +84,12 @@ def concat_src_files(file_list, fileout_path): def minify_file(file_debug, file_minified): try: - minify_closure(file_debug, file_minified) + return minify_closure(file_debug, file_minified) except NameError: with open(file_minified, 'w') as file_out: with open(file_debug, 'r') as file_in: file_out.write(minify(file_in.read())) + return True def minify_js_dir(source_dir): @@ -99,8 +104,10 @@ def minify_js_dir(source_dir): return concat_src_files(source_files, file_debug_js) - minify_file(file_debug_js, file_minified_js) - print('Minified %s' % source_dir) + if minify_file(file_debug_js, file_minified_js): + print('Minified %s' % source_dir) + else: + print('Error minifying %s' % source_dir) if __name__ == '__main__': if len(sys.argv) != 2: |