summaryrefslogtreecommitdiff
path: root/yaksh/file_utils.py
diff options
context:
space:
mode:
authoradityacp2018-06-26 16:03:10 +0530
committeradityacp2018-06-26 16:03:10 +0530
commitddd2981529798b8c59dec33e50ccf6e808f3bc19 (patch)
tree946b2bf9b4eee1c82188cd438e3342e2fb2cc900 /yaksh/file_utils.py
parenta200623e1739cb85c5125b0c5115663489e51633 (diff)
downloadonline_test-ddd2981529798b8c59dec33e50ccf6e808f3bc19.tar.gz
online_test-ddd2981529798b8c59dec33e50ccf6e808f3bc19.tar.bz2
online_test-ddd2981529798b8c59dec33e50ccf6e808f3bc19.zip
Fix course download to support Python 2 and 3
Diffstat (limited to 'yaksh/file_utils.py')
-rw-r--r--yaksh/file_utils.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/yaksh/file_utils.py b/yaksh/file_utils.py
index 6b0340f..af0ee1e 100644
--- a/yaksh/file_utils.py
+++ b/yaksh/file_utils.py
@@ -80,8 +80,11 @@ def write_static_files_to_zip(zipfile, course_name, current_dir):
folder_path = os.sep.join((current_dir, "static", "yaksh", folder))
for file in static_files[folder]:
file_path = os.sep.join((folder_path, file))
- zipfile.write(file_path, os.sep.join((course_name, "static",
- folder, file)))
+ with open(file_path, "rb") as f:
+ zipfile.writestr(
+ os.sep.join((course_name, "static", folder, file)),
+ f.read()
+ )
def write_templates_to_zip(zipfile, template_path, data, filename, filepath):
@@ -91,4 +94,4 @@ def write_templates_to_zip(zipfile, template_path, data, filename, filepath):
context = Context(data)
render = template.render(context)
zipfile.writestr(os.sep.join((filepath, "{0}.html".format(filename))),
- render)
+ str(render))