aboutsummaryrefslogtreecommitdiff
path: root/pyAggr3g470r.py
diff options
context:
space:
mode:
authorcedricbonhomme <devnull@localhost>2011-11-23 22:00:43 +0100
committercedricbonhomme <devnull@localhost>2011-11-23 22:00:43 +0100
commitb457e5d66552c08dcc645a3db900dd1097897148 (patch)
treec95d57742d4caaaf628bc7befdb1b1c0c0c2e846 /pyAggr3g470r.py
parentSystematic generation of QR Code in article's page. If the article is too lon... (diff)
downloadnewspipe-b457e5d66552c08dcc645a3db900dd1097897148.tar.gz
newspipe-b457e5d66552c08dcc645a3db900dd1097897148.tar.bz2
newspipe-b457e5d66552c08dcc645a3db900dd1097897148.zip
Removed PyQRNative module in favor of qrcode module.
Diffstat (limited to 'pyAggr3g470r.py')
-rwxr-xr-xpyAggr3g470r.py24
1 files changed, 9 insertions, 15 deletions
diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py
index 7e9e4f06..44fe3331 100755
--- a/pyAggr3g470r.py
+++ b/pyAggr3g470r.py
@@ -52,7 +52,8 @@ import datetime
import utils
import export
import feedgetter
-import PyQRNative
+from qrcode.pyqrnative.PyQRNative import QRCode, QRErrorCorrectLevel, CodeOverflowException
+from qrcode import qr
def error_page_404(status, message, traceback, version):
@@ -444,19 +445,12 @@ class Root:
pass
if not os.path.isfile("./var/qrcode/" + article_id + ".png"):
# QR Code generation
- try:
- qr = PyQRNative.QRCode(40, PyQRNative.QRErrorCorrectLevel.L)
- if len(description) <= 4296:
- print article.article_description
- qr.addData(article.article_description)
- else:
- qr.addData(article.article_link)
- qr.make()
- im = qr.makeImage()
- im.save("./var/qrcode/"+article_id+".png", format='png')
- except Exception, e:
- # Code length overflow
- print e
+ if len(description) < 4296:
+ f = qr.QRUrl(url = description)
+ else:
+ f = qr.QRUrl(url = article.article_link)
+ f.make()
+ f.save("./var/qrcode/"+article_id+".png")
# Previous and following articles
try:
@@ -533,7 +527,7 @@ class Root:
# QRCode (for smartphone)
- html += """<br />\n<img src="/var/qrcode/%s.png" title="Share with your smartphone" />""" % (article_id,)
+ html += """<br />\n<a href="/var/qrcode/%s.png"><img src="/var/qrcode/%s.png" title="Share with your smartphone" width="500" height="500" /></a>""" % (article_id, article_id)
html += "<hr />\n" + htmlfooter
return html
bgstack15