Started on CLI
This commit is contained in:
parent
10563589c2
commit
590d488c34
2 changed files with 79 additions and 42 deletions
35
cli.py
Executable file
35
cli.py
Executable file
|
|
@ -0,0 +1,35 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import json
|
||||||
|
import time
|
||||||
|
|
||||||
|
path = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
cmd = sys.argv[1]
|
||||||
|
|
||||||
|
if cmd == "list":
|
||||||
|
if not os.path.exists(path + "/models"):
|
||||||
|
print("Face models have not been initialized yet, please run:")
|
||||||
|
print("\n\thowdy add\n")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
user = os.environ.get("USER")
|
||||||
|
enc_file = path + "/models/" + user + ".dat"
|
||||||
|
|
||||||
|
try:
|
||||||
|
encodings = json.load(open(enc_file))
|
||||||
|
except FileNotFoundError:
|
||||||
|
print("No face model known for the current user (" + user + "), please run:")
|
||||||
|
print("\n\thowdy add\n")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
print("Known face models for " + user + ":")
|
||||||
|
print("\n\t\033[1;29mID Date Label\033[0m")
|
||||||
|
|
||||||
|
for enc in encodings:
|
||||||
|
print("\t" + str(enc["id"]), end="")
|
||||||
|
print((4 - len(str(enc["id"]))) * " ", end="")
|
||||||
|
print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(enc["time"])), end="")
|
||||||
|
print(" " + enc["label"])
|
||||||
|
|
||||||
|
print()
|
||||||
|
|
@ -82,6 +82,8 @@ for line in fileinput.input(["/lib/security/howdy/config.ini"], inplace = 1):
|
||||||
print(line.replace("device_id = 1", "device_id = " + picked), end="")
|
print(line.replace("device_id = 1", "device_id = " + picked), end="")
|
||||||
|
|
||||||
handleStatus(subprocess.call(["chmod 600 -R /lib/security/howdy/"], shell=True))
|
handleStatus(subprocess.call(["chmod 600 -R /lib/security/howdy/"], shell=True))
|
||||||
|
handleStatus(subprocess.call(["ln -s /lib/security/howdy/cli.py /usr/bin/howdy"], shell=True))
|
||||||
|
handleStatus(subprocess.call(["chmod +x /usr/bin/howdy"], shell=True))
|
||||||
|
|
||||||
log("Adding howdy as PAM module")
|
log("Adding howdy as PAM module")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue