예제 #1
0
def send_confirmation(user):
    if _cfg("smtp-host") == "":
        return
    smtp = smtplib.SMTP(_cfg("smtp-host"), _cfgi("smtp-port"))
    smtp.login(_cfg("smtp-user"), _cfg("smtp-password"))
    with open("emails/confirm-account") as f:
        message = MIMEText(html.parser.HTMLParser().unescape(\
            pystache.render(f.read(), { 'user': user, "domain": _cfg("domain"), 'confirmation': user.confirmation })))
    message['X-MC-Important'] = "true"
    message['X-MC-PreserveRecipients'] = "false"
    message['Subject'] = "Confirm your account on the KnightOS Package Index"
    message['From'] = "*****@*****.**"
    message['To'] = user.email
    smtp.sendmail("*****@*****.**", [ user.email ], message.as_string())
    smtp.quit()
예제 #2
0
def send_reset(user):
    if _cfg("smtp-host") == "":
        return
    smtp = smtplib.SMTP(_cfg("smtp-host"), _cfgi("smtp-port"))
    smtp.ehlo()
    smtp.starttls()
    smtp.login(_cfg("smtp-user"), _cfg("smtp-password"))
    with open("emails/password-reset") as f:
        message = MIMEText(html.parser.HTMLParser().unescape(\
            pystache.render(f.read(), { 'user': user, "domain": _cfg("domain"), 'confirmation': user.passwordReset })))
    message['Subject'] = "Reset your password for the KnightOS Package Index"
    message['From'] = _cfg("smtp-user")
    message['To'] = user.email
    smtp.sendmail(_cfg("smtp-user"), [user.email], message.as_string())
    smtp.quit()
예제 #3
0
def send_reset(user):
    if _cfg("smtp-host") == "":
        return
    smtp = smtplib.SMTP(_cfg("smtp-host"), _cfgi("smtp-port"))
    smtp.ehlo()
    smtp.starttls()
    smtp.login(_cfg("smtp-user"), _cfg("smtp-password"))
    with open("emails/password-reset") as f:
        message = MIMEText(html.parser.HTMLParser().unescape(\
            pystache.render(f.read(), { 'user': user, "domain": _cfg("domain"), 'confirmation': user.passwordReset })))
    message['Subject'] = "Reset your password for the KnightOS Package Index"
    message['From'] = _cfg("smtp-user")
    message['To'] = user.email
    smtp.sendmail(_cfg("smtp-user"), [ user.email ], message.as_string())
    smtp.quit()
예제 #4
0
def send_new_pacakge_email(package):
    if _cfg("smtp-host") == "":
        return
    smtp = smtplib.SMTP(_cfg("smtp-host"), _cfgi("smtp-port"))
    smtp.login(_cfg("smtp-user"), _cfg("smtp-password"))
    with open("emails/new-package") as f:
        message = MIMEText(html.parser.HTMLParser().unescape(\
                pystache.render(f.read(), { 'url': _cfg("protocol") + "://" + _cfg("domain") + url_for("html.package", name=package.name, repo=package.repo) })))
    targets = [u.email for u in User.query.filter(User.admin == True)]
    message['X-MC-Important'] = "true"
    message['X-MC-PreserveRecipients'] = "false"
    message['Subject'] = "New package pending approval"
    message['From'] = "*****@*****.**"
    message['To'] = ';'.join(targets)
    smtp.sendmail("*****@*****.**", targets, message.as_string())
    smtp.quit()
예제 #5
0
def send_new_pacakge_email(package):
    if _cfg("smtp-host") == "":
        return
    smtp = smtplib.SMTP(_cfg("smtp-host"), _cfgi("smtp-port"))
    smtp.ehlo()
    smtp.starttls()
    smtp.login(_cfg("smtp-user"), _cfg("smtp-password"))
    with open("emails/new-package") as f:
        message = MIMEText(html.parser.HTMLParser().unescape(\
                pystache.render(f.read(), { 'url': _cfg("protocol") + "://" + _cfg("domain") + url_for("html.package", name=package.name, repo=package.repo) })))
    targets = [u.email for u in User.query.filter(User.admin == True)]
    message['Subject'] = "New package pending approval"
    message['From'] = _cfg("smtp-user")
    message['To'] = ';'.join(targets)
    smtp.sendmail(_cfg("smtp-user"), targets, message.as_string())
    smtp.quit()
예제 #6
0
                # TODO: Bug the slimit guys to support python 3
                #if not app.debug:
                #    javascript = minify(javascript)

                with open(os.path.join(app.static_folder, output), "w") as w:
                    w.write(javascript)
                    w.flush()
    except:
        pass

    try:
        d = os.walk('images')
        for f in list(d)[0][2]:
            outputpath = os.path.join(app.static_folder, os.path.basename(f))
            inputpath = os.path.join('images', f)
            copyfile(inputpath, outputpath)
    except:
        pass

@app.before_first_request
def compile_first():
    prepare()

@app.before_request
def compile_if_debug():
    if app.debug and _cfg("debug-static-recompile").lower() in ['true','yes']:
        prepare()

if __name__ == '__main__':
    app.run(host=_cfg("debug-host"), port=_cfgi('debug-port'), debug=True)
예제 #7
0
                with open(os.path.join(app.static_folder, output), "w") as w:
                    w.write(javascript)
                    w.flush()
    except:
        pass

    try:
        d = os.walk('images')
        for f in list(d)[0][2]:
            outputpath = os.path.join(app.static_folder, os.path.basename(f))
            inputpath = os.path.join('images', f)
            copyfile(inputpath, outputpath)
    except:
        pass


@app.before_first_request
def compile_first():
    prepare()


@app.before_request
def compile_if_debug():
    if app.debug and _cfg("debug-static-recompile").lower() in ['true', 'yes']:
        prepare()


if __name__ == '__main__':
    app.run(host=_cfg("debug-host"), port=_cfgi('debug-port'), debug=True)