|
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | """Flask App for MPContribs API""" |
3 | 3 | import os |
4 | | -import urllib |
5 | 4 | import smtplib |
6 | 5 | import logging |
7 | 6 | import requests |
|
10 | 9 | from email.message import EmailMessage |
11 | 10 | from importlib import import_module |
12 | 11 | from websocket import create_connection |
13 | | -from flask import Flask, current_app, request, g, jsonify |
| 12 | +from flask import Flask, current_app, request, jsonify |
14 | 13 | from flask_marshmallow import Marshmallow |
15 | 14 | from flask_mongoengine import MongoEngine |
16 | 15 | from flask_mongorest import register_class |
@@ -113,7 +112,7 @@ def send_email(to, subject, html): |
113 | 112 | msg["To"] = to |
114 | 113 |
|
115 | 114 | # NOTE boto3 SES client can't connect to VPC endpoint yet |
116 | | - with smtplib.SMTP(host=SMTP_HOST, port=SMTP_PORT) as ses_client: |
| 115 | + with smtplib.SMTP(host=SMTP_HOST, port=int(SMTP_PORT)) as ses_client: |
117 | 116 | ses_client.starttls() |
118 | 117 | ses_client.login(os.environ["SMTP_USERNAME"], os.environ["SMTP_PASSWORD"]) |
119 | 118 | ses_client.send_message(msg) |
@@ -163,7 +162,7 @@ def get_kernels(): |
163 | 162 |
|
164 | 163 | response = r.json() |
165 | 164 | nkernels = 3 # reserve 3 kernels for each deployment |
166 | | - idx = int(os.environ.get("DEPLOYMENT")) |
| 165 | + idx = int(os.environ.get("DEPLOYMENT", 1)) |
167 | 166 |
|
168 | 167 | if len(response) < nkernels * (idx + 1): |
169 | 168 | logger.error("NOT ENOUGH KERNELS AVAILABLE") |
|
0 commit comments