From 70d5bf5170ff47cee66e4c59e5ee588193543787 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Sat, 12 Apr 2014 19:18:20 +0200 Subject: Trying the export to HTML option on Heroku (4). --- conf.py | 2 +- pyaggr3g470r/export.py | 6 +++--- pyaggr3g470r/views.py | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/conf.py b/conf.py index 01483f10..2c54ae91 100644 --- a/conf.py +++ b/conf.py @@ -45,7 +45,7 @@ if not ON_HEROKU: basedir = os.path.abspath(os.path.dirname(__file__)) PATH = os.path.abspath(".") - WEBZINE_ROOT = PATH + "/pyaggr3g470r/var/export/webzine/" + WEBZINE_ROOT = PATH + "/pyaggr3g470r/var/export/" else: HTTP_PROXY = "" diff --git a/pyaggr3g470r/export.py b/pyaggr3g470r/export.py index 530c08fd..37a55ffe 100644 --- a/pyaggr3g470r/export.py +++ b/pyaggr3g470r/export.py @@ -136,7 +136,7 @@ def export_html(user): """ Export all articles of 'user' in Web pages. """ - webzine_root = conf.WEBZINE_ROOT + webzine_root = conf.WEBZINE_ROOT + "webzine/" nb_articles = format(len(models.Article.query.filter(models.Article.user_id == user.id).all()), ",d") index = HTML_HEADER("News archive") index += "

List of feeds

\n" @@ -190,10 +190,10 @@ def export_html(user): f.write(CSS.encode("utf-8")) archive_file_name = datetime.now().strftime('%Y-%m-%d') + '.tar.gz' - with tarfile.open(conf.PATH + "/pyaggr3g470r/var/export/" + archive_file_name, "w:gz") as tar: + with tarfile.open(conf.WEBZINE_ROOT + archive_file_name, "w:gz") as tar: tar.add(webzine_root, arcname=os.path.basename(webzine_root)) shutil.rmtree(webzine_root) - with open(conf.PATH + "/pyaggr3g470r/var/export/" + archive_file_name, 'r') as export_file: + with open(conf.WEBZINE_ROOT + archive_file_name, 'r') as export_file: return export_file.read(), archive_file_name \ No newline at end of file diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index 9ce597e6..a38dffcd 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -394,7 +394,6 @@ def export_articles(): Export all articles. """ user = User.query.filter(User.id == g.user.id).first() - archive_file, archive_file_name = export.export_html(user) try: archive_file, archive_file_name = export.export_html(user) except: -- cgit