mirror of
https://github.com/boltgolt/howdy.git
synced 2024-09-19 09:51:19 +02:00
Change snapshot location per #649
This commit is contained in:
parent
27f3a73c9f
commit
568a5734d4
2 changed files with 13 additions and 8 deletions
|
@ -94,7 +94,7 @@ rotate = 0
|
|||
|
||||
[snapshots]
|
||||
# Capture snapshots of failed login attempts and save them to disk with metadata
|
||||
# Snapshots are saved to the "snapshots" folder
|
||||
# Snapshots are saved to /var/log/howdy/snapshots
|
||||
save_failed = false
|
||||
|
||||
# Do the same as the option above but for successful attempts
|
||||
|
|
|
@ -8,14 +8,14 @@ import numpy as np
|
|||
|
||||
|
||||
def generate(frames, text_lines):
|
||||
"""Generate a shapshot from given frames"""
|
||||
"""Generate a snapshot from given frames"""
|
||||
|
||||
# Don't execute if no frames were given
|
||||
if len(frames) == 0:
|
||||
return
|
||||
|
||||
# Get the path to the containing folder
|
||||
abpath = os.path.dirname(os.path.abspath(__file__))
|
||||
core_path = os.path.dirname(os.path.abspath(__file__))
|
||||
# Get frame dimensions
|
||||
frame_height, frame_width, cc = frames[0].shape
|
||||
# Spread the given frames out horizontally
|
||||
|
@ -31,7 +31,7 @@ def generate(frames, text_lines):
|
|||
# Add the Howdy logo if there's space to do so
|
||||
if len(frames) > 1:
|
||||
# Load the logo from file
|
||||
logo = cv2.imread(abpath + "/logo.png")
|
||||
logo = cv2.imread(core_path + "/logo.png")
|
||||
# Calculate the position of the logo
|
||||
logo_y = frame_height + 20
|
||||
logo_x = frame_width * len(frames) - 210
|
||||
|
@ -49,14 +49,19 @@ def generate(frames, text_lines):
|
|||
|
||||
line_number += 1
|
||||
|
||||
# Define path to any howdy logs
|
||||
log_path = "/var/log/howdy"
|
||||
|
||||
# Made sure a snapshot folder exist
|
||||
if not os.path.exists(abpath + "/snapshots"):
|
||||
os.makedirs(abpath + "/snapshots")
|
||||
if not os.path.exists(log_path):
|
||||
os.makedirs(log_path)
|
||||
if not os.path.exists(log_path + "/snapshots"):
|
||||
os.makedirs(log_path + "/snapshots")
|
||||
|
||||
# Generate a filename based on the current time
|
||||
filename = datetime.datetime.utcnow().strftime("%Y%m%dT%H%M%S.jpg")
|
||||
# Write the image to that file
|
||||
cv2.imwrite(abpath + "/snapshots/" + filename, snap)
|
||||
cv2.imwrite(log_path + "/snapshots/" + filename, snap)
|
||||
|
||||
# Return the saved file location
|
||||
return abpath + "/snapshots/" + filename
|
||||
return log_path + "/snapshots/" + filename
|
||||
|
|
Loading…
Reference in a new issue