aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2014-11-09 08:37:53 +0100
committerCédric Bonhomme <cedric@cedricbonhomme.org>2014-11-09 08:37:53 +0100
commit2ea470dfc61e054f477d08698b00f0a911b68cd5 (patch)
tree21f9442fb1346293cf69abda47aa685babd77c2e
parentClass btn-default for the 'Log In' button. (diff)
downloadnewspipe-2ea470dfc61e054f477d08698b00f0a911b68cd5.tar.gz
newspipe-2ea470dfc61e054f477d08698b00f0a911b68cd5.tar.bz2
newspipe-2ea470dfc61e054f477d08698b00f0a911b68cd5.zip
More robust fetch.py script.
-rwxr-xr-xfetch.py13
-rwxr-xr-xpyaggr3g470r/utils.py4
-rw-r--r--pyaggr3g470r/views.py2
3 files changed, 11 insertions, 8 deletions
diff --git a/fetch.py b/fetch.py
index 49315d38..7203fe33 100755
--- a/fetch.py
+++ b/fetch.py
@@ -13,16 +13,19 @@ from pyaggr3g470r.models import User
if __name__ == "__main__":
# Point of entry in execution mode
+ users, feed_id = [], None
try:
- feed_id = int(sys.argv[2])
+ users = User.query.filter(User.id == int(sys.argv[1])).all()
except:
- feed_id = None
+ users = User.query.all()
+ finally:
+ if users == []:
+ users = User.query.all()
- users = []
try:
- users = User.query.filter(User.email == sys.argv[1]).all()
+ feed_id = int(sys.argv[2])
except:
- users = User.query.all()
+ feed_id = None
for user in users:
if user.activation_key == "":
diff --git a/pyaggr3g470r/utils.py b/pyaggr3g470r/utils.py
index d0419362..9fb26702 100755
--- a/pyaggr3g470r/utils.py
+++ b/pyaggr3g470r/utils.py
@@ -78,8 +78,8 @@ def opened_w_error(filename, mode="r"):
finally:
f.close()
-def fetch(email, feed_id=None):
- cmd = ['python', conf.basedir+'/fetch.py', email, str(feed_id)]
+def fetch(id, feed_id=None):
+ cmd = ['python', conf.basedir+'/fetch.py', str(id), str(feed_id)]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
def import_opml(email, opml_content):
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py
index ffc7a53b..712f1da3 100644
--- a/pyaggr3g470r/views.py
+++ b/pyaggr3g470r/views.py
@@ -267,7 +267,7 @@ def fetch(feed_id=None):
Triggers the download of news.
News are downloaded in a separated process, mandatory for Heroku.
"""
- utils.fetch(g.user.email, feed_id)
+ utils.fetch(g.user.id, feed_id)
flash(gettext("Downloading articles..."), 'info')
return redirect(redirect_url())
bgstack15