Fixed write perms but in QRMaker.py

This commit is contained in:
Fergal Moran
2011-01-07 18:18:49 +00:00
parent 1394ac23d8
commit d3cda3245c

View File

@@ -3,40 +3,49 @@ import logging
import re
import uuid
import shutil
import os
HEIGHT = 220
WIDTH = 220
HEIGHT = 210
WIDTH = 210
vCardTemplate = """BEGIN:VCARD
vCardTemplate = '''BEGIN:VCARD
N:{SURNAME};{FIRSTNAME}
TEL;CELL:{TELMOBILE}
TEL;HOME:{TELHOME}
EMAIL:{EMAIL}
URL:{URL}
END:VCARD"""
END:VCARD'''
class QRMaker:
def __init__(self):
self._templateData = vCardTemplate
def createVCard(self, data):
logging.debug("In createVCard")
try:
logging.debug('In createVCard')
chart = QRChart(HEIGHT, WIDTH)
templateData = ""
templateData = ''
logging.debug('Parsing form')
for k, v in data.items():
templateData = self._templateData.replace("{%s}" % k, v)
templateData = self._templateData.replace('{%s}' % k, v)
self._templateData = templateData
logging.debug('Parsed form..')
match = re.sub(r'{\w*\w}', '', templateData)
chart.add_data(match)
chart.set_ec('H', 0)
uid = uuid.uuid1()
chart.download('static/cache/%s.png' % uid)
logging.debug('Downloading image')
filePath = '%s/../static/cache/%s.png' % (os.path.dirname(__file__), uid)
logging.debug('Downloading ' + filePath)
chart.download(filePath)
return uid
except ex:
logging.debug('Unhandled exception')
logging.exception('Unhandled exception')
def generatePermalink(self, id):
shutil.copyfile(
@@ -44,3 +53,4 @@ class QRMaker:
'static/images/permalinked/%s.png' % id
)
return 'static/images/permalinked/%s.png' % id