From 93fff98d5ba071c478daf046c6c3efac5a0dea50 Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Tue, 1 May 2012 13:13:16 +0200 Subject: Export tp webzine nearly OK. --- source/export.py | 40 ++++++++++++++++++---------------------- source/pyAggr3g470r.py | 4 +++- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/source/export.py b/source/export.py index a14d47c0..97b185a4 100644 --- a/source/export.py +++ b/source/export.py @@ -37,9 +37,9 @@ __license__ = "GPLv3" import os import hashlib +import conf import utils - htmlheader = '\n' + \ '' + \ '\n\tpyAggr3g470r - News aggregator\n' + \ @@ -52,60 +52,56 @@ htmlfooter = '

This software is under GPLv3 license. You are welcome to copy, ' GPLv3 license.

\n' + \ '\n' - - -def export_html(feeds): +def export_html(mongo_db): """ Export the articles given in parameter in a simple Webzine. """ + feeds = mongo_db.get_all_feeds() index = htmlheader index += "
\n\n
" index += htmlfooter - with open(utils.path + "/var/export/webzine/" + "index.html", "w") as f: - f.write(index) + with open(conf.path + "/var/export/webzine/" + "index.html", "w") as f: + f.write(index.encode('utf-8')) def export_txt(feeds): """ diff --git a/source/pyAggr3g470r.py b/source/pyAggr3g470r.py index 577b3451..a135debd 100755 --- a/source/pyAggr3g470r.py +++ b/source/pyAggr3g470r.py @@ -1171,9 +1171,11 @@ class Root: Export articles currently loaded from the MongoDB database with the appropriate function of the 'export' module. """ + getattr(export, export_method)(self.mongo) try: - getattr(export, export_method)(self.mongo.get_all_articles()) + getattr(export, export_method)(self.mongo) except Exception, e: + print e return self.error_page(e) return self.management() -- cgit