def _process(self): boaConfig = self._conf.getBOAConfig() pdfFilename = "%s - Book of abstracts.pdf" % cleanHTMLHeaderFilename( self._target.getTitle()) cacheFile = self._getCacheFileName() if os.path.isfile(cacheFile): mtime = pytz.utc.localize( datetime.utcfromtimestamp(os.path.getmtime(cacheFile))) else: mtime = None if boaConfig.isCacheEnabled( ) and not self._noCache and mtime and mtime > boaConfig.lastChanged: return send_file(pdfFilename, cacheFile, 'PDF') else: tz = timezoneUtils.DisplayTZ(self._aw, self._target).getDisplayTZ() pdf = AbstractBook(self._target, self.getAW(), tz=tz) fname = pdf.generate() with open(fname, 'rb') as f: data = f.read() with open(cacheFile, 'wb') as f: f.write(data) return send_file(pdfFilename, cacheFile, 'PDF')
def create_boa(event): """Create the book of abstracts if necessary :return: The path to the PDF file """ path = boa_settings.get(event, 'cache_path') if path and os.path.exists(path): return path pdf = AbstractBook(event) tmp_path = pdf.generate() path = os.path.join(Config.getInstance().getXMLCacheDir(), 'boa-{}.pdf'.format(event.id)) shutil.move(tmp_path, path) boa_settings.set(event, 'cache_path', path) return path
def create_boa(event): """Create the book of abstracts if necessary :return: The path to the PDF file """ path = boa_settings.get(event, 'cache_path') if path and os.path.exists(path): return path pdf = AbstractBook(event) tmp_path = pdf.generate() filename = 'boa-{}.pdf'.format(event.id) full_path = os.path.join(Config.getInstance().getXMLCacheDir(), filename) shutil.move(tmp_path, full_path) boa_settings.set(event, 'cache_path', filename) return full_path
def _process(self): boaConfig = self._conf.getBOAConfig() pdfFilename = "%s - Book of abstracts.pdf" % cleanHTMLHeaderFilename(self._target.getTitle()) cacheFile = self._getCacheFileName() if os.path.isfile(cacheFile): mtime = pytz.utc.localize(datetime.utcfromtimestamp(os.path.getmtime(cacheFile))) else: mtime = None if boaConfig.isCacheEnabled() and not self._noCache and mtime and mtime > boaConfig.lastChanged: return send_file(pdfFilename, cacheFile, 'PDF') else: tz = timezoneUtils.DisplayTZ(self._aw, self._target).getDisplayTZ() pdf = AbstractBook(self._target, self.getAW(), tz=tz) fname = pdf.generate() with open(fname, 'rb') as f: data = f.read() with open(cacheFile, 'wb') as f: f.write(data) return send_file(pdfFilename, cacheFile, 'PDF')