catching SSL errors

workspace
Brendan Howell 5 years ago
parent 92108a875a
commit 4c02405c20

@ -384,8 +384,14 @@ class Bureau(object):
pdfpath = tempfile.mkstemp(".pdf")[1]
self.log.debug("rendering to: " + pdfpath)
weasyprint.HTML(string=templ.render_unicode(**kwargs)).write_pdf(pdfpath)
subprocess.call("lpr -o sides=two-sided-long-edge -o InputSlot=Upper " + pdfpath, shell=True)
# use an URL fetcher that waits 30s instead of 10s
def slowfetch(url, timeout=30, ssl_context=None):
return weasyprint.default_url_fetcher(url, 30, ssl_context)
weasyprint.HTML(url_fetcher=slowfetch,
string=templ.render_unicode(**kwargs)).write_pdf(pdfpath)
subprocess.call("lpr -o sides=two-sided-long-edge -o InputSlot=Upper "
+ pdfpath, shell=True)
# TODO: make this asynchronous
def print_small(self, text, cut=True):

@ -10,7 +10,7 @@ import string
import imapclient
import kode256
from ssl import SSLSyscallError
from ssl import SSLSysCallError
from bureau import Bureau, add_command, add_api
@ -76,7 +76,7 @@ class MailRoom(Bureau):
"""
try:
self.imapserv.select_folder("INBOX")
except (self.imapserv.AbortError, SSLSyscallError) as err:
except (self.imapserv.AbortError, SSLSysCallError) as err:
self.log.debug("reconnecting after imap connection error: ", err)
self.imapserv.logout()
self.imapserv = imapclient.IMAPClient(self.host, use_uid=True, ssl=self.imap_ssl)

Loading…
Cancel
Save