Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
eljeffeg committed Mar 12, 2023
1 parent 052889a commit 31ecf59
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
15 changes: 11 additions & 4 deletions alembic/versions/ffe623ae412_delete_snapshot_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
history = {}
flag_count = {}


def _table_has_column(table, column):
has_column = False
for col in inspector.get_columns(table):
Expand All @@ -37,9 +38,13 @@ def _has_table(table_name):
tables = inspector.get_table_names()
return table_name in tables


def add_history(created, team_id, reason, value):
conn = op.get_bind()
conn.execute(f"INSERT INTO game_history (created, team_id, _type, _value) VALUES ('{created}', {team_id}, '{reason}', {value});")
conn.execute(
f"INSERT INTO game_history (created, team_id, _type, _value) VALUES ('{created}', {team_id}, '{reason}', {value});"
)


def check_flag(item):
team_id = item[0]
Expand All @@ -51,6 +56,7 @@ def check_flag(item):
flag_count[str(team_id)] = 1
add_history(created, team_id, "flag_count", flag_count[str(team_id)])


def check_history(item):
created = item[1]
team_id = item[2]
Expand All @@ -74,6 +80,7 @@ def check_history(item):
add_history(created, team_id, "score", money)
history[str(team_id)] = {"money": money, "bots": bots}


def upgrade():
try:
conn = op.get_bind()
Expand All @@ -84,8 +91,8 @@ def upgrade():
check_history(item)
i += 1
if i > 0:
conn.execute("COMMIT;")
conn.execute("COMMIT;")

except Exception as e:
print("Failed to import prior snapshot data into game history: %s" % str(e))
print("Continuing...")
Expand All @@ -97,7 +104,7 @@ def upgrade():
check_flag(item)
i += 1
if i > 0:
conn.execute("COMMIT;")
conn.execute("COMMIT;")
except Exception as e:
print("Failed to import prior flag count into game history: %s" % str(e))
print("Continuing...")
Expand Down
12 changes: 10 additions & 2 deletions libs/SecurityDecorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,16 @@ def wrapper(self, *args, **kwargs):
if self.request.remote_ip not in self.application.settings["blacklisted_ips"]:
return method(self, *args, **kwargs)
else:
self.render("public/login.html", info=None, errors=["Your IP address is currently banned - Contact Admin"])
logging.warning("[BAN HAMMER] Login attempt from blacklisted IP %s" % self.request.remote_ip)
self.render(
"public/login.html",
info=None,
errors=["Your IP address is currently banned - Contact Admin"],
)
logging.warning(
"[BAN HAMMER] Login attempt from blacklisted IP %s"
% self.request.remote_ip
)

return wrapper


Expand Down

0 comments on commit 31ecf59

Please sign in to comment.