aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/utils.py
diff options
context:
space:
mode:
authorFrançois Schmidts <francois.schmidts@gmail.com>2014-06-09 14:04:38 +0200
committerFrançois Schmidts <francois.schmidts@gmail.com>2014-06-09 15:15:25 +0200
commit16ec162838eb8ab891f5b04351bb202d84a2b834 (patch)
tree975f0b567f48604f976adf35ba62f8a536a5ab16 /pyaggr3g470r/utils.py
parentsupporting feed without date or with ill formated date (diff)
downloadnewspipe-16ec162838eb8ab891f5b04351bb202d84a2b834.tar.gz
newspipe-16ec162838eb8ab891f5b04351bb202d84a2b834.tar.bz2
newspipe-16ec162838eb8ab891f5b04351bb202d84a2b834.zip
making pyagregator runnable by apache
* adding bootstrap module for basic import * redoing logging (config, proper use of the logging module) * making secret part of config (random wouldn't work with apache since it uses different instances of python) * making server entry point not executing application if just imported * not writing file for opml when we can read it from memory
Diffstat (limited to 'pyaggr3g470r/utils.py')
-rwxr-xr-xpyaggr3g470r/utils.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/pyaggr3g470r/utils.py b/pyaggr3g470r/utils.py
index 320c49ce..4acaafc8 100755
--- a/pyaggr3g470r/utils.py
+++ b/pyaggr3g470r/utils.py
@@ -38,6 +38,7 @@ import re
import glob
import opml
import json
+import logging
import datetime
import operator
import urllib
@@ -59,8 +60,7 @@ url_finders = [
re.compile("'\\<((mailto:)|)[-A-Za-z0-9\\.]+@[-A-Za-z0-9\\.]+") \
]
-#import log
-#pyaggr3g470r_log = log.Log()
+logger = logging.getLogger(__name__)
@contextmanager
@@ -76,15 +76,16 @@ def opened_w_error(filename, mode="r"):
f.close()
-def import_opml(email, opml_file):
+def import_opml(email, opml_content):
"""
Import new feeds from an OPML file.
"""
user = User.query.filter(User.email == email).first()
try:
- subscriptions = opml.parse(opml_file)
- except Exception as e:
- raise e
+ subscriptions = opml.from_string(opml_content)
+ except:
+ logger.exception("Parsing OPML file failed:")
+ raise
def read(subsubscription, nb=0):
"""
bgstack15