From fc6d03a08c3d7c9a704f31d2b07f4fba2f9a01bc Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Fri, 25 Nov 2011 10:45:23 +0100 Subject: Minor improvement. Ensure that the size of the string to encode is less than 4296 characters. Else the URL of the article is used. Catch all type of exceptions. --- .hgsubstate | 2 +- pyAggr3g470r.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.hgsubstate b/.hgsubstate index 4457f723..cf4d43fa 100644 --- a/.hgsubstate +++ b/.hgsubstate @@ -1 +1 @@ -1b35d194105a4025bea6fb60a467aea4b4f4be7b qrcode +95fa18e08f277df2f4d03da06e0fe8c7c8cd4e8e qrcode diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py index 41911075..13ca2310 100755 --- a/pyAggr3g470r.py +++ b/pyAggr3g470r.py @@ -445,11 +445,14 @@ class Root: pass if not os.path.isfile("./var/qrcode/" + article_id + ".png"): # QR Code generation - if len(utils.clear_string(description)) < 4296: + try: + if len(utils.clear_string(description)) > 4296: + raise Exception() f = qr.QRUrl(url = utils.clear_string(description)) - else: + f.make() + except: f = qr.QRUrl(url = article.article_link) - f.make() + f.make() f.save("./var/qrcode/"+article_id+".png") # Previous and following articles -- cgit