From ca136b65a3d17756c530f1afe903220a7d637bd2 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Sun, 30 Aug 2020 02:30:52 +0200 Subject: [PATCH] add Failed column to Messages table --- respodns/__main__.py | 4 +--- respodns/db.py | 5 ++++- respodns/sql.py | 1 + respodns/tables.py | 1 + 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/respodns/__main__.py b/respodns/__main__.py index 7aaa6f3..8e3816c 100644 --- a/respodns/__main__.py +++ b/respodns/__main__.py @@ -1,11 +1,9 @@ -#!/usr/bin/env python3 - if __name__ == "__main__": from sys import argv, stderr from .ui import ui if len(argv) == 0: - print("You've met with a terrible fate.", file=stderr) + print("malformed arguments", file=stderr) ret = 2 else: ret = ui(argv[0], argv[1:]) diff --git a/respodns/db.py b/respodns/db.py index 9b474b8..0ddbb4c 100644 --- a/respodns/db.py +++ b/respodns/db.py @@ -252,8 +252,11 @@ class RespoDB: else: exception = None + failed = not entry.success + message = self.new_message( execution=entry.execution, server=server, domain=domain, - record_id=record_id, exception=exception) + record_id=record_id, exception=exception, + failed=failed) self.flush() diff --git a/respodns/sql.py b/respodns/sql.py index 438117c..5ffd709 100644 --- a/respodns/sql.py +++ b/respodns/sql.py @@ -67,6 +67,7 @@ CREATE TABLE IF NOT EXISTS Messages ( DomainId INTEGER NOT NULL, RecordId INTEGER, ExceptionId INTEGER, + Failed BOOLEAN DEFAULT 0 NOT NULL, FOREIGN KEY(ServerId) REFERENCES Ips(IpId), FOREIGN KEY(ExecutionId) REFERENCES Executions(ExecutionId), FOREIGN KEY(DomainId) REFERENCES Domains(DomainId), diff --git a/respodns/tables.py b/respodns/tables.py index b8fab3d..f8b06cc 100644 --- a/respodns/tables.py +++ b/respodns/tables.py @@ -61,6 +61,7 @@ class TMessage(rain.Storm, AttrCheck): domain_id = rain.Int("DomainId") record_id = rain.Int("RecordId") exception_id = rain.Int("ExceptionId") + failed = rain.Bool("Failed") execution = rain.Reference(execution_id, "TExecution.execution_id") server = rain.Reference(server_id, "TAddress.address_id") domain = rain.Reference(domain_id, "TDomain.domain_id")