Permalink
Browse files

catch exceptions with bad encoding

  • Loading branch information...
1 parent 8656213 commit 7db2fbeacdb8d6696079281f585c28cecf1eee22 @domoritz domoritz committed Dec 4, 2011
Showing with 9 additions and 6 deletions.
  1. +7 −5 www/validitychecker/helpers/IsiHandler.py
  2. +2 −1 www/validitychecker/views.py
@@ -155,11 +155,13 @@ def calcISIScore(authorname):
def refreshArticles(article):
"""fetch number of cites for articles and add missing information (like source, datatype...)"""
- #TODO implement
- isidata = IsiHandler('',article.title).getISIData()
- article.source = isidata['source']
- article.times_cited_on_isi = isidata['timescited']
- article.save()
+ try:
+ isidata = IsiHandler('',article.title).getISIData()
+ article.source = isidata['source']
+ article.times_cited_on_isi = isidata['timescited']
+ article.save()
+ except Exception, e:
+ print "well, that didn't work <(','<) <(',')> (>',')>", e
def convertScholarNameToISIName(name):
print('Name', ' '.join(name.split(' ')[::-1]))
@@ -94,7 +94,8 @@ def get_authors_and_articles_from_db(titles):
for author in authors:
tmp = (author, Article.objects.filter(title__in=titles, author__name=author.name).order_by('-publish_date'))
#calculate score
- print("score", tmp[0].isi_cites, tmp[0].isi_score)
+ if not tmp[0].isi_cites:
+ tmp[0].isi_cites = 0
tmp[0].score = int(math.log(tmp[0].isi_cites+1) + 2*tmp[0].isi_score)
ret.append(tmp)
ret = sorted(ret, key=lambda elem: -elem[0].score)

0 comments on commit 7db2fbe

Please sign in to comment.