Skip to content

Commit 869b303

Browse files
committed
some lint stuff
1 parent 6e49ee9 commit 869b303

4 files changed

Lines changed: 17 additions & 15 deletions

File tree

mpcontribs-api/mpcontribs/api/__init__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# -*- coding: utf-8 -*-
22
"""Flask App for MPContribs API"""
33
import os
4-
import urllib
54
import smtplib
65
import logging
76
import requests
@@ -10,7 +9,7 @@
109
from email.message import EmailMessage
1110
from importlib import import_module
1211
from websocket import create_connection
13-
from flask import Flask, current_app, request, g, jsonify
12+
from flask import Flask, current_app, request, jsonify
1413
from flask_marshmallow import Marshmallow
1514
from flask_mongoengine import MongoEngine
1615
from flask_mongorest import register_class
@@ -113,7 +112,7 @@ def send_email(to, subject, html):
113112
msg["To"] = to
114113

115114
# 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:
117116
ses_client.starttls()
118117
ses_client.login(os.environ["SMTP_USERNAME"], os.environ["SMTP_PASSWORD"])
119118
ses_client.send_message(msg)
@@ -163,7 +162,7 @@ def get_kernels():
163162

164163
response = r.json()
165164
nkernels = 3 # reserve 3 kernels for each deployment
166-
idx = int(os.environ.get("DEPLOYMENT"))
165+
idx = int(os.environ.get("DEPLOYMENT", 1))
167166

168167
if len(response) < nkernels * (idx + 1):
169168
logger.error("NOT ENOUGH KERNELS AVAILABLE")

mpcontribs-api/mpcontribs/api/projects/views.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def has_add_permission(self, req, obj):
9999

100100
# is_approved can only be set by an admin
101101
if obj.is_approved:
102-
raise Unauthorized(f"Only admins can set `is_approved=True`")
102+
raise Unauthorized("Only admins can set `is_approved=True`")
103103

104104
# limit the number of projects a user can own (unless admin)
105105
nr_projects = Projects.objects(owner=obj.owner).count()
@@ -161,11 +161,14 @@ def search():
161161
if not term:
162162
abort(404, description="Missing search term.")
163163

164-
pipeline = [{
165-
"$search": {
166-
"index": "mpcontribs-dev-project-search",
167-
"text": {"path": {"wildcard": "*"}, "query": term}
168-
}
169-
}, {"$project": {"_id": 1}}]
164+
pipeline = [
165+
{
166+
"$search": {
167+
"index": "mpcontribs-dev-project-search",
168+
"text": {"path": {"wildcard": "*"}, "query": term},
169+
}
170+
},
171+
{"$project": {"_id": 1}},
172+
]
170173
result = [p["_id"] for p in Projects.objects().aggregate(pipeline)]
171174
return jsonify(result)

mpcontribs-api/scripts/start.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/bin/bash
22

33
set -e
4-
zzz=$(($DEPLOYMENT * 60))
4+
zzz=$((DEPLOYMENT * 60))
55
echo "$SUPERVISOR_PROCESS_NAME: waiting for $zzz seconds before start..."
66
sleep $zzz
77

8-
pmgrc=$HOME/.pmgrc.yaml
9-
[[ ! -e $pmgrc ]] && echo "PMG_DUMMY_VAR: dummy" >$pmgrc
8+
PMGRC=$HOME/.pmgrc.yaml
9+
[[ ! -e "$PMGRC" ]] && echo "PMG_DUMMY_VAR: dummy" >"$PMGRC"
1010

1111
STATS_ARG=""
1212
SERVER_APP="mpcontribs.api:create_app()"

mpcontribs-api/scripts/start_rq.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
set -e
4-
zzz=$(($DEPLOYMENT * 60))
4+
zzz=$((DEPLOYMENT * 60))
55
echo "$SUPERVISOR_PROCESS_NAME: waiting for $zzz seconds before start..."
66
sleep $zzz
77

0 commit comments

Comments
 (0)