From 8bc95efda6b837471291d08cec184dc7bbd6306e Mon Sep 17 00:00:00 2001 From: Sayafdine Said Date: Sun, 25 Jun 2023 16:55:26 +0200 Subject: [PATCH] fix: convert to string when necessary --- howdy/src/cli/add.py | 4 ++-- howdy/src/cli/config.py | 1 - howdy/src/cli/disable.py | 1 - howdy/src/cli/remove.py | 2 +- howdy/src/cli/set.py | 1 - howdy/src/cli/snap.py | 1 - howdy/src/cli/test.py | 1 - howdy/src/compare.py | 4 ---- howdy/src/snapshot.py | 7 +++---- 9 files changed, 6 insertions(+), 16 deletions(-) diff --git a/howdy/src/cli/add.py b/howdy/src/cli/add.py index 0c64f2c..ab58cc7 100644 --- a/howdy/src/cli/add.py +++ b/howdy/src/cli/add.py @@ -31,7 +31,7 @@ import cv2 # Test if at lest 1 of the data files is there and abort if it's not if not os.path.isfile(paths_factory.shape_predictor_5_face_landmarks_path()): print(_("Data files have not been downloaded, please run the following commands:")) - print("\n\tcd " + paths.dlib_data_dir) + print("\n\tcd " + str(paths.dlib_data_dir)) print("\tsudo ./install.sh\n") sys.exit(1) @@ -50,7 +50,7 @@ face_encoder = dlib.face_recognition_model_v1(str(paths_factory.dlib_face_recogn user = builtins.howdy_user # The permanent file to store the encoded model in -enc_file = paths_factory.user_model_path(user) +enc_file = str(paths_factory.user_model_path(user)) # Known encodings encodings = [] diff --git a/howdy/src/cli/config.py b/howdy/src/cli/config.py index 34860e8..fae7b08 100644 --- a/howdy/src/cli/config.py +++ b/howdy/src/cli/config.py @@ -3,7 +3,6 @@ # Import required modules import os import subprocess -import paths import paths_factory from i18n import _ diff --git a/howdy/src/cli/disable.py b/howdy/src/cli/disable.py index 42b2d3c..dc87e23 100644 --- a/howdy/src/cli/disable.py +++ b/howdy/src/cli/disable.py @@ -6,7 +6,6 @@ import os import builtins import fileinput import configparser -import paths import paths_factory from i18n import _ diff --git a/howdy/src/cli/remove.py b/howdy/src/cli/remove.py index 799b629..595dfc6 100644 --- a/howdy/src/cli/remove.py +++ b/howdy/src/cli/remove.py @@ -72,7 +72,7 @@ if not found: # Remove the entire file if this encoding is the only one if len(encodings) == 1: - os.remove(paths.user_models_dir / f"{user}.dat") + os.remove(paths_factory.user_model_path(user)) print(_("Removed last model, howdy disabled for user")) else: # A place holder to contain the encodings that will remain diff --git a/howdy/src/cli/set.py b/howdy/src/cli/set.py index eddad43..ba981c2 100644 --- a/howdy/src/cli/set.py +++ b/howdy/src/cli/set.py @@ -5,7 +5,6 @@ import sys import os import builtins import fileinput -import paths import paths_factory from i18n import _ diff --git a/howdy/src/cli/snap.py b/howdy/src/cli/snap.py index ff5dfa4..4d0d2ca 100644 --- a/howdy/src/cli/snap.py +++ b/howdy/src/cli/snap.py @@ -5,7 +5,6 @@ import os import configparser import datetime import snapshot -import paths import paths_factory from recorders.video_capture import VideoCapture diff --git a/howdy/src/cli/test.py b/howdy/src/cli/test.py index fff2e91..934d535 100644 --- a/howdy/src/cli/test.py +++ b/howdy/src/cli/test.py @@ -10,7 +10,6 @@ import time import dlib import cv2 import numpy as np -import paths import paths_factory from i18n import _ diff --git a/howdy/src/compare.py b/howdy/src/compare.py index 0878ed8..c46a1ef 100644 --- a/howdy/src/compare.py +++ b/howdy/src/compare.py @@ -25,10 +25,6 @@ import numpy as np import _thread as thread import paths import paths_factory - -# Allow imports from the local howdy folder -sys.path.append('/lib/security/howdy') - from recorders.video_capture import VideoCapture from i18n import _ diff --git a/howdy/src/snapshot.py b/howdy/src/snapshot.py index 53dd7fa..c6a7abf 100644 --- a/howdy/src/snapshot.py +++ b/howdy/src/snapshot.py @@ -15,8 +15,6 @@ def generate(frames, text_lines): if len(frames) == 0: return - # Get the path to the containing folder - 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 @@ -56,8 +54,9 @@ def generate(frames, text_lines): # Generate a filename based on the current time filename = datetime.datetime.utcnow().strftime("%Y%m%dT%H%M%S.jpg") + filepath = str(paths_factory.snapshot_path(filename)) # Write the image to that file - cv2.imwrite(paths_factory.snapshot_path(filename), snap) + cv2.imwrite(filepath, snap) # Return the saved file location - return paths_factory.snapshot_path(filename) + return filepath