From 6cedaa8e8f990e34aa28b5b4951df9a252850661 Mon Sep 17 00:00:00 2001 From: HelloZeroNet Date: Mon, 26 Jan 2015 01:43:39 +0100 Subject: [PATCH] utf8 content.json fix, faster node.js coffeescript compiler support --- src/Debug/DebugMedia.py | 12 ++++++------ src/Ui/UiRequest.py | 5 ++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Debug/DebugMedia.py b/src/Debug/DebugMedia.py index e2f7cb90..69043bc9 100644 --- a/src/Debug/DebugMedia.py +++ b/src/Debug/DebugMedia.py @@ -40,14 +40,14 @@ def merge(merged_path): return False # No coffeescript compiler, skip this file command = config.coffeescript_compiler % file_path.replace("/", "\\") s = time.time() - compiler = subprocess.Popen(command, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE) + compiler = subprocess.Popen(command, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE) logging.debug("Running: %s (Done in %.2fs)" % (command, time.time()-s)) - source = compiler.stdout.read() - if source: - parts.append(source) + out = compiler.stdout.read() + if out and out.startswith("("): + parts.append(out) else: - error = compiler.stderr.read() - parts.append("alert('%s compile error: %s');" % (file_path, re.escape(error)) ) + error = out + parts.append("alert('%s compile error: %s');" % (file_path, re.escape(error).replace("\n", "\\n").replace(r"\\n", r"\n") ) ) else: # Add to parts parts.append(open(file_path).read()) diff --git a/src/Ui/UiRequest.py b/src/Ui/UiRequest.py index 5f99df52..18ccfae1 100644 --- a/src/Ui/UiRequest.py +++ b/src/Ui/UiRequest.py @@ -84,9 +84,8 @@ class UiRequest: def render(self, template_path, *args, **kwargs): #template = SimpleTemplate(open(template_path), lookup=[os.path.dirname(template_path)]) #yield str(template.render(*args, **kwargs).encode("utf8")) - ENCODING = 'utf-8' - template = unicode(open(template_path).read(), ENCODING) - yield template.format(**kwargs).encode(ENCODING) + template = open(template_path).read().decode("utf8") + yield template.format(**kwargs).encode("utf8") # - Actions -