Пример #1
0
	def resolveForever(self):
		consumer = Consumer(self.db)
		consumer.register_callback(self.resolve)
		while True:
			try:
				consumer.wait(heartbeat=True, filter="sessiondoc/scanconflicts")
				self.logger.info('Changes feed closed connection. Restarting.')
			except Exception as e:
				self.logger.info('Error connecting to CouchDB for changes:')
				self.logger.info('%s' % e)
				time.sleep(1)
Пример #2
0
            pdfname = pl_name
            jobname = uuid.uuid4().hex
            f = open('/tmp/%s.tex' % jobname, 'w+')
            f.write(data)
            f.close()
            try:
                for i in range(2):
                    p = subprocess.Popen([
                        'pdflatex',
                        '-output-directory', '/tmp',
                        '-interaction', 'nonstopmode',
                        '-jobname', jobname,
                        '/tmp/%s.tex' % jobname,
                    ], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
                    p.communicate()
                filename = '/tmp/%s.pdf' % jobname
                data = open(filename).read()
                db.put_attachment(doc, data, name=pdfname, content_type='application/pdf')
            except IOError:
                pass
    return f

if __name__ == '__main__':
    while True:
        db = Database(sys.argv[1])
        c = Consumer(db)
        last_seq = c.wait_once()['last_seq']
        c.register_callback(generate_pdf(db))
        c.wait(filter='aimpl/pl', since=last_seq, heartbeat=True)
        time.sleep(5)