lint
This commit is contained in:
parent
f81ff2e1de
commit
afb98724d3
6 changed files with 10 additions and 8 deletions
|
@ -107,7 +107,6 @@ def run_job(job_cls: Type[BaseAutomation], *,
|
|||
# to be logged for investigation. Catching more specific exceptions would just mean that
|
||||
# others go unrecorded and are difficult to debug.
|
||||
except Exception as exc: # pylint: disable=broad-except
|
||||
raise exc
|
||||
trace = TracebackException.from_exception(exc)
|
||||
success = False
|
||||
logs = "\n".join(trace.format())
|
||||
|
@ -125,6 +124,7 @@ def run_job(job_cls: Type[BaseAutomation], *,
|
|||
log.updated = datetime.datetime.utcnow()
|
||||
log.logs = str(logs)
|
||||
db.session.add(log)
|
||||
db.session.commit()
|
||||
activity = Activity(
|
||||
activity_type="automation",
|
||||
text=(f"[{automation.short_name}] 🚨 Automation failure: It was not possible to handle this failure safely "
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from app.extensions import db
|
||||
|
||||
|
||||
class TerraformState(db.Model):
|
||||
class TerraformState(db.Model): # type: ignore
|
||||
key = db.Column(db.String, primary_key=True)
|
||||
state = db.Column(db.String)
|
||||
lock = db.Column(db.String)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from datetime import datetime, timedelta, timezone
|
||||
from typing import Optional
|
||||
|
||||
from flask import Blueprint, render_template, request
|
||||
from flask import Blueprint, render_template, request, url_for, redirect
|
||||
from flask.typing import ResponseReturnValue
|
||||
from jinja2.utils import markupsafe
|
||||
from sqlalchemy import desc, or_, func
|
||||
|
@ -129,6 +129,8 @@ def portal_home() -> ResponseReturnValue:
|
|||
@portal.route("/search")
|
||||
def search() -> ResponseReturnValue:
|
||||
query = request.args.get("query")
|
||||
if query is None:
|
||||
return redirect(url_for("portal.portal_home"))
|
||||
proxies = Proxy.query.filter(
|
||||
or_(func.lower(Proxy.url).contains(query.lower())), Proxy.destroyed.is_(None)).all()
|
||||
origins = Origin.query.filter(
|
||||
|
|
|
@ -26,4 +26,3 @@ class BlockBridgeGitlabAutomation(BlockBridgeReachabilityAutomation):
|
|||
)
|
||||
# Decode the base64 first, then decode the UTF-8 string
|
||||
self._lines = contents.decode().decode('utf-8').splitlines()
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ class ListGitlabAutomation(ListAutomation):
|
|||
{% endfor %}
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
if 'GITLAB_URL' in current_app.config:
|
||||
self.template_parameters.append("gitlab_url")
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import json
|
||||
|
||||
from flask import Blueprint, request, Response
|
||||
from flask.typing import ResponseReturnValue
|
||||
|
||||
from app.extensions import db
|
||||
from app.models.tfstate import TerraformState
|
||||
|
@ -9,7 +10,7 @@ tfstate = Blueprint("tfstate", __name__)
|
|||
|
||||
|
||||
@tfstate.route("/<key>", methods=['GET'])
|
||||
def handle_get(key):
|
||||
def handle_get(key: str) -> ResponseReturnValue:
|
||||
state = TerraformState.query.filter(TerraformState.key == key).first()
|
||||
if state is None or state.state is None:
|
||||
return "Not Found", 404
|
||||
|
@ -17,7 +18,7 @@ def handle_get(key):
|
|||
|
||||
|
||||
@tfstate.route("/<key>", methods=['POST', 'DELETE', 'UNLOCK'])
|
||||
def handle_update(key):
|
||||
def handle_update(key: str) -> ResponseReturnValue:
|
||||
state = TerraformState.query.filter(TerraformState.key == key).first()
|
||||
if not state:
|
||||
if request.method in ["DELETE", "UNLOCK"]:
|
||||
|
@ -38,7 +39,7 @@ def handle_update(key):
|
|||
|
||||
|
||||
@tfstate.route("/<key>", methods=['LOCK'])
|
||||
def handle_lock(key):
|
||||
def handle_lock(key: str) -> ResponseReturnValue:
|
||||
state = TerraformState.query.filter(TerraformState.key == key).with_for_update().first()
|
||||
if state is None:
|
||||
state = TerraformState(key=key)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue