Exemplo n.º 1
0
 def handle(self, *args, **kwargs):
     version_msg = "Current SX Console version: {}".format(version)
     try:
         resp = requests.get(
             'http://cdn.skylable.com/check/sxconsole-lite-version')
     except Exception as e:
         msg = version_msg + ".\nFailed to check for updates. Error: {}."
         logger.error(msg.format(e))
         return
     if resp.ok:
         msg = version_msg + ", latest version: {}"
         logger.info(msg.format(resp.text))
     else:
         msg = version_msg + ". Failed to check for updates ({}). "
         logger.warn(msg.format(resp.status_code))
Exemplo n.º 2
0
 def handle(self, *args, **kwargs):
     version_msg = "Current SX Console version: {}".format(version)
     try:
         resp = requests.get(
             'http://cdn.skylable.com/check/sxconsole-lite-version')
     except Exception as e:
         msg = version_msg + ".\nFailed to check for updates. Error: {}."
         logger.error(msg.format(e))
         return
     if resp.ok:
         msg = version_msg + ", latest version: {}"
         logger.info(msg.format(resp.text))
     else:
         msg = version_msg + ". Failed to check for updates ({}). "
         logger.warn(msg.format(resp.status_code))
Exemplo n.º 3
0
def send_mail(request, subject, to, template=None, context=None, content=None):
    """Useful wrapper around django's send_mail."""

    if isinstance(to, basestring):
        to = [to]  # send_mail expects a list of recipients

    if not content:
        if 'link' in context:
            context['link'] = request.build_absolute_uri(context['link'])
        content = render_to_string(template, context)
    content = content.strip()

    from_ = settings.DEFAULT_FROM_EMAIL

    try:
        dj_send_mail(subject, content, from_, to)
        return True
    except SocketError as e:
        logger.error("Failed to send e-mail: {}".format(e))
        return False