Formatting fixes
This commit is contained in:
parent
f8cfde6f72
commit
f4db5ee94b
9 changed files with 38 additions and 31 deletions
|
|
@ -16,7 +16,7 @@ config = configparser.ConfigParser()
|
|||
config.read(config_path)
|
||||
|
||||
# Check if enough arguments have been passed
|
||||
if builtins.howdy_args.argument == None:
|
||||
if builtins.howdy_args.argument is None:
|
||||
print("Please add a 0 (enable) or a 1 (disable) as an argument")
|
||||
sys.exit(1)
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ path = os.path.dirname(os.path.realpath(__file__)) + "/.."
|
|||
user = builtins.howdy_user
|
||||
|
||||
# Check if enough arguments have been passed
|
||||
if builtins.howdy_args.argument == None:
|
||||
if builtins.howdy_args.argument is None:
|
||||
print("Please add the ID of the model you want to remove as an argument")
|
||||
print("You can find the IDs by running:")
|
||||
print("\n\thowdy list\n")
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ Press ctrl+C in this terminal to quit
|
|||
Click on the image to enable or disable slow mode
|
||||
""")
|
||||
|
||||
|
||||
def mouse(event, x, y, flags, param):
|
||||
"""Handle mouse events"""
|
||||
global slow_mode
|
||||
|
|
@ -53,10 +54,12 @@ def mouse(event, x, y, flags, param):
|
|||
if event == cv2.EVENT_LBUTTONDOWN:
|
||||
slow_mode = not slow_mode
|
||||
|
||||
|
||||
def print_text(line_number, text):
|
||||
"""Print the status text by line number"""
|
||||
cv2.putText(overlay, text, (10, height - 10 - (10 * line_number)), cv2.FONT_HERSHEY_SIMPLEX, .3, (0, 255, 0), 0, cv2.LINE_AA)
|
||||
|
||||
|
||||
# Open the window and attach a a mouse listener
|
||||
cv2.namedWindow("Howdy Test")
|
||||
cv2.setMouseCallback("Howdy Test", mouse)
|
||||
|
|
@ -90,7 +93,6 @@ try:
|
|||
sec = int(time.time())
|
||||
sec_frames = 0
|
||||
|
||||
|
||||
# Grab a single frame of video
|
||||
ret, frame = (video_capture.read())
|
||||
# Make a frame to put overlays in
|
||||
|
|
|
|||
|
|
@ -18,11 +18,13 @@ import configparser
|
|||
config = configparser.ConfigParser()
|
||||
config.read(os.path.dirname(os.path.abspath(__file__)) + "/config.ini")
|
||||
|
||||
|
||||
def stop(status):
|
||||
"""Stop the execution and close video stream"""
|
||||
video_capture.release()
|
||||
sys.exit(status)
|
||||
|
||||
|
||||
# Make sure we were given an username to tast against
|
||||
try:
|
||||
if not isinstance(sys.argv[1], str):
|
||||
|
|
@ -182,7 +184,7 @@ while True:
|
|||
print("Certainty of winning frame: %.3f" % (match * 10, ))
|
||||
|
||||
# Catch older 3-encoding models
|
||||
if not match_index in models:
|
||||
if match_index not in models:
|
||||
match_index = 0
|
||||
|
||||
print("Winning model: %d (\"%s\")" % (match_index, models[match_index]["label"]))
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import re
|
|||
from subprocess import Popen, PIPE
|
||||
from cv2 import CAP_PROP_FRAME_WIDTH
|
||||
from cv2 import CAP_PROP_FRAME_HEIGHT
|
||||
from cv2 import CAP_PROP_FOURCC
|
||||
|
||||
try:
|
||||
import ffmpeg
|
||||
|
|
@ -16,6 +15,7 @@ except ImportError:
|
|||
print(" pip3 install ffmpeg-python\n")
|
||||
sys.exit(12)
|
||||
|
||||
|
||||
class ffmpeg_reader:
|
||||
""" This class was created to look as similar to the openCV features used in Howdy as possible for overall code cleanliness. """
|
||||
|
||||
|
|
@ -54,16 +54,16 @@ class ffmpeg_reader:
|
|||
return_code = process.poll()
|
||||
|
||||
# Worst case scenario, err will equal en empty byte string, b'', so probe will get set to [] here.
|
||||
regex = re.compile('\s\d{3,4}x\d{3,4}')
|
||||
regex = re.compile(r"\s\d{3,4}x\d{3,4}")
|
||||
probe = regex.findall(str(err.decode("utf-8")))
|
||||
|
||||
if not return_code == 1 or len(probe) < 1:
|
||||
# Could not determine the resolution from ffmpeg call. Reverting to ffmpeg.probe()
|
||||
probe = ffmpeg.probe(self.device_path)
|
||||
height = probe['streams'][0]['height']
|
||||
width = probe['streams'][0]['width']
|
||||
height = probe["streams"][0]["height"]
|
||||
width = probe["streams"][0]["width"]
|
||||
else:
|
||||
(height, width) = [x.strip() for x in probe[0].split('x')]
|
||||
(height, width) = [x.strip() for x in probe[0].split("x")]
|
||||
|
||||
# Set height and width from probe if they haven't been set already
|
||||
if height.isdigit() and self.get(CAP_PROP_FRAME_HEIGHT) == 0:
|
||||
|
|
@ -71,7 +71,6 @@ class ffmpeg_reader:
|
|||
if width.isdigit() and self.get(CAP_PROP_FRAME_WIDTH) == 0:
|
||||
self.set(CAP_PROP_FRAME_WIDTH, int(width))
|
||||
|
||||
|
||||
def record(self, numframes):
|
||||
""" Record a video, saving it to self.video array for processing later """
|
||||
|
||||
|
|
@ -86,7 +85,7 @@ class ffmpeg_reader:
|
|||
stream, ret = (
|
||||
ffmpeg
|
||||
.input(self.device_path, format=self.device_format)
|
||||
.output('pipe:', format='rawvideo', pix_fmt='rgb24', vframes=numframes)
|
||||
.output("pipe:", format="rawvideo", pix_fmt="rgb24", vframes=numframes)
|
||||
.run(capture_stdout=True, quiet=True)
|
||||
)
|
||||
self.video = (
|
||||
|
|
@ -95,7 +94,6 @@ class ffmpeg_reader:
|
|||
.reshape([-1, self.width, self.height, 3])
|
||||
)
|
||||
|
||||
|
||||
def read(self):
|
||||
""" Read a sigle frame from the self.video array. Will record a video if array is empty. """
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import ConfigParser
|
|||
config = ConfigParser.ConfigParser()
|
||||
config.read(os.path.dirname(os.path.abspath(__file__)) + "/config.ini")
|
||||
|
||||
|
||||
def doAuth(pamh):
|
||||
"""Starts authentication in a seperate process"""
|
||||
|
||||
|
|
@ -56,18 +57,22 @@ def doAuth(pamh):
|
|||
pamh.conversation(pamh.Message(pamh.PAM_ERROR_MSG, "Unknown error: " + str(status)))
|
||||
return pamh.PAM_SYSTEM_ERR
|
||||
|
||||
|
||||
def pam_sm_authenticate(pamh, flags, args):
|
||||
"""Called by PAM when the user wants to authenticate, in sudo for example"""
|
||||
return doAuth(pamh)
|
||||
|
||||
|
||||
def pam_sm_open_session(pamh, flags, args):
|
||||
"""Called when starting a session, such as su"""
|
||||
return doAuth(pamh)
|
||||
|
||||
|
||||
def pam_sm_close_session(pamh, flags, argv):
|
||||
"""We don't need to clean anyting up at the end of a session, so returns true"""
|
||||
return pamh.PAM_SUCCESS
|
||||
|
||||
|
||||
def pam_sm_setcred(pamh, flags, argv):
|
||||
"""We don't need set any credentials, so returns true"""
|
||||
return pamh.PAM_SUCCESS
|
||||
|
|
|
|||
Loading…
Reference in a new issue