utf8 content.json fix, faster node.js coffeescript compiler support

This commit is contained in:
HelloZeroNet 2015-01-26 01:43:39 +01:00
parent 1468756691
commit 6cedaa8e8f
2 changed files with 8 additions and 9 deletions

View File

@ -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())

View File

@ -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 -