mirror of
https://github.com/ChristianLight/tutor.git
synced 2024-12-12 14:17:46 +00:00
Fix pip install tutor-openedx
Installing from pip was broken because, for some reason, the templates/apps/xqueue/settings/ folder contained a __pycache__ folder with compiled *.pyc files. Rendering the binary files was failing miserably.
This commit is contained in:
parent
e2b0f3bfde
commit
a034f95f83
@ -1,5 +1,9 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## Latest
|
||||||
|
|
||||||
|
- [Bugfix] Fix `pip install tutor-openedx`
|
||||||
|
|
||||||
## v3.3.3 (2019-03-27)
|
## v3.3.3 (2019-03-27)
|
||||||
|
|
||||||
- [Bugfix] Fix login from localhost
|
- [Bugfix] Fix login from localhost
|
||||||
|
19
tutor/env.py
19
tutor/env.py
@ -28,7 +28,6 @@ def render_target(root, config, target):
|
|||||||
hierarchy at `root`.
|
hierarchy at `root`.
|
||||||
"""
|
"""
|
||||||
for src, dst in walk_templates(root, target):
|
for src, dst in walk_templates(root, target):
|
||||||
if is_part_of_env(src):
|
|
||||||
rendered = render_file(config, src)
|
rendered = render_file(config, src)
|
||||||
with open(dst, "w") as of:
|
with open(dst, "w") as of:
|
||||||
of.write(rendered)
|
of.write(rendered)
|
||||||
@ -40,6 +39,9 @@ def render_file(config, path):
|
|||||||
except jinja2.exceptions.TemplateError:
|
except jinja2.exceptions.TemplateError:
|
||||||
print("Error rendering template", path)
|
print("Error rendering template", path)
|
||||||
raise
|
raise
|
||||||
|
except Exception:
|
||||||
|
print("Unknown error rendering template", path)
|
||||||
|
raise
|
||||||
|
|
||||||
def render_dict(config):
|
def render_dict(config):
|
||||||
"""
|
"""
|
||||||
@ -84,12 +86,8 @@ def copy_target(root, target):
|
|||||||
at `root`.
|
at `root`.
|
||||||
"""
|
"""
|
||||||
for src, dst in walk_templates(root, target):
|
for src, dst in walk_templates(root, target):
|
||||||
if is_part_of_env(src):
|
|
||||||
shutil.copy(src, dst)
|
shutil.copy(src, dst)
|
||||||
|
|
||||||
def is_part_of_env(path):
|
|
||||||
return not os.path.basename(path).startswith(".")
|
|
||||||
|
|
||||||
def is_up_to_date(root):
|
def is_up_to_date(root):
|
||||||
return version(root) == __version__
|
return version(root) == __version__
|
||||||
|
|
||||||
@ -120,6 +118,8 @@ def walk_templates(root, target):
|
|||||||
"""
|
"""
|
||||||
target_root = template_path(target)
|
target_root = template_path(target)
|
||||||
for dirpath, _, filenames in os.walk(target_root):
|
for dirpath, _, filenames in os.walk(target_root):
|
||||||
|
if not is_part_of_env(dirpath):
|
||||||
|
continue
|
||||||
dst_dir = pathjoin(
|
dst_dir = pathjoin(
|
||||||
root, target,
|
root, target,
|
||||||
os.path.relpath(dirpath, target_root)
|
os.path.relpath(dirpath, target_root)
|
||||||
@ -129,8 +129,17 @@ def walk_templates(root, target):
|
|||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
src = os.path.join(dirpath, filename)
|
src = os.path.join(dirpath, filename)
|
||||||
dst = os.path.join(dst_dir, filename)
|
dst = os.path.join(dst_dir, filename)
|
||||||
|
if is_part_of_env(src):
|
||||||
yield src, dst
|
yield src, dst
|
||||||
|
|
||||||
|
def is_part_of_env(path):
|
||||||
|
basename = os.path.basename(path)
|
||||||
|
return not (
|
||||||
|
basename.startswith(".") or
|
||||||
|
basename.endswith(".pyc") or
|
||||||
|
basename == "__pycache__"
|
||||||
|
)
|
||||||
|
|
||||||
def template_path(*path):
|
def template_path(*path):
|
||||||
return os.path.join(TEMPLATES_ROOT, *path)
|
return os.path.join(TEMPLATES_ROOT, *path)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user