@@ -7,6 +7,7 @@ def col(id):
77 if id == 1 : return "\033 [32m"
88 if id == 2 : return "\033 [33m"
99 if id == 3 : return "\033 [31m"
10+ if id == 4 : return "\033 [1m"
1011 return "\033 [0m"
1112
1213
@@ -38,70 +39,111 @@ if "install" not in sys.argv:
3839# The default picked video device id
3940picked = "none"
4041
41- print (col (1 ) + "Starting IR camera check...\n " + col (0 ))
4242
4343# If prompting has been disabled, skip camera check
4444if "HOWDY_NO_PROMPT" in os .environ :
4545 print (col (2 ) + "AUTOMATED INSTALL, YOU WILL NOT BE ASKED FOR INPUT AND CHECKS WILL BE SKIPPED" + col (0 ))
4646
4747 # Write the default device to disk and exit
4848 with open ("/tmp/howdy_picked_device" , "w" ) as out_file :
49- out_file .write ("none" )
49+ out_file .write ("none;3.5 " )
5050
5151 sys .exit (0 )
5252
53- # Get all devices
54- devices = os .listdir ("/dev/v4l/by-path" )
53+ fscheck = subprocess .call (["which" , "streamer" ], stdout = subprocess .PIPE )
54+
55+ if fscheck == 1 :
56+ print (col (2 ) + "\n WARNING: Could not automatically find the right webcam, manual configuration after installation required\n " + col (0 ))
57+ else :
58+ print (col (1 ) + "Starting IR camera check...\n " + col (0 ))
59+
60+ # Get all devices
61+ devices = os .listdir ("/dev/v4l/by-path" )
62+
63+ # Loop though all devices
64+ for dev in devices :
65+ time .sleep (.5 )
66+
67+ # The full path to the device is the default name
68+ device_name = "/dev/v4l/by-path/" + dev
69+ # Get the udevadm details to try to get a better name
70+ udevadm = subprocess .check_output (["udevadm info -r --query=all -n " + device_name ], shell = True ).decode ("utf-8" )
71+
72+ # Loop though udevadm to search for a better name
73+ for line in udevadm .split ("\n " ):
74+ # Match it and encase it in quotes
75+ re_name = re .search ('product.*=(.*)$' , line , re .IGNORECASE )
76+ if re_name :
77+ device_name = '"' + re_name .group (1 ) + '"'
78+
79+ # Show what device we're using
80+ print ("Trying " + device_name )
81+
82+ # Let fswebcam keep the camera open in the background
83+ sub = subprocess .Popen (
84+ ["streamer -t 1:0:0 -c /dev/v4l/by-path/" + dev + " -b 16 -f rgb24 -o /dev/null 1>/dev/null 2>/dev/null" ],
85+ shell = True ,
86+ preexec_fn = os .setsid ,
87+ stdout = subprocess .PIPE ,
88+ stdin = subprocess .PIPE )
89+
90+ try :
91+ # Ask the user if this is the right one
92+ print (col (2 ) + "One of your cameras should now be on." + col (0 ))
93+ ans = input ("Did your IR emitters turn on? [y/N]: " )
94+ except KeyboardInterrupt :
95+ # Kill fswebcam if the user aborts
96+ os .killpg (os .getpgid (sub .pid ), signal .SIGTERM )
97+ raise
98+
99+ # The user has answered, kill fswebcam
100+ os .killpg (os .getpgid (sub .pid ), signal .SIGTERM )
55101
56- # Loop though all devices
57- for dev in devices :
58- time .sleep (.5 )
102+ # Set this camera as picked if the answer was yes, go to the next one if no
103+ if ans .lower ().strip () == "y" or ans .lower ().strip () == "yes" :
104+ picked = dev
105+ break
106+ else :
107+ print ("Interpreting as a " + col (3 ) + "\" NO\" \n " + col (0 ))
59108
60- # The full path to the device is the default name
61- device_name = "/dev/v4l/by-path/" + dev
62- # Get the udevadm details to try to get a better name
63- udevadm = subprocess . check_output ([ "udevadm info -r --query=all -n " + device_name ], shell = True ). decode ( "utf-8" )
109+ # Abort if no camera was picked
110+ if picked == "none" :
111+ print ( col ( 3 ) + "No suitable IR camera found, aborting install." + col ( 0 ))
112+ sys . exit ( 23 )
64113
65- # Loop though udevadm to search for a better name
66- for line in udevadm .split ("\n " ):
67- # Match it and encase it in quotes
68- re_name = re .search ('product.*=(.*)$' , line , re .IGNORECASE )
69- if re_name :
70- device_name = '"' + re_name .group (1 ) + '"'
114+ cert = 3.5
71115
72- # Show what device we're using
73- print ( "Trying " + device_name )
116+ # Give time to read
117+ time . sleep ( .5 )
74118
75- # Let fswebcam keep the camera open in the background
76- sub = subprocess .Popen (["streamer -t 1:0:0 -c /dev/v4l/by-path/" + dev + " -b 16 -f rgb24 -o /dev/null 1>/dev/null 2>/dev/null" ], shell = True , preexec_fn = os .setsid )
119+ print (col (1 ) + "\n Starting certainty auto config..." + col (0 ))
77120
78- try :
79- # Ask the user if this is the right one
80- print (col (2 ) + "One of your cameras should now be on." + col (0 ))
81- ans = input ("Did your IR emitters turn on? [y/N]: " )
82- except KeyboardInterrupt :
83- # Kill fswebcam if the user aborts
84- os .killpg (os .getpgid (sub .pid ), signal .SIGTERM )
85- raise
121+ # Give more time to read
122+ time .sleep (.5 )
123+
124+ print ("\n \n After detection, Howdy knows how certain it is that the match is correct." )
125+ print ("How certain Howdy needs to be before authenticating you can be customized." )
86126
87- # The user has answered, kill fswebcam
88- os .killpg (os .getpgid (sub .pid ), signal .SIGTERM )
127+ print (col (4 ) + "\n F: Fast." + col (0 ))
128+ print ("Allows more fuzzy matches, but speeds up the scanning process greatly." )
129+ print (col (4 ) + "\n B: Balanced." + col (0 ))
130+ print ("Still relatively quick detection, but might not log you in when further away." )
131+ print (col (4 ) + "\n S: Secure." + col (0 ))
132+ print ("The safest option, but will take much longer to authenticate you." )
89133
90- # Set this camera as picked if the answer was yes, go to the next one if no
91- if ans .lower ().strip () == "y" or ans .lower ().strip () == "yes" :
92- picked = dev
93- break
94- else :
95- print ("Interpreting as a " + col (3 ) + "\" NO\" \n " + col (0 ))
134+ print ("\n You can always change this setting in the config." )
135+ prof = input ("What profile would you like to use? [f/b/s]: " )
96136
97- # Abort if no camera was picked
98- if picked == "none" :
99- print (col (3 ) + "No suitable IR camera found, aborting install." + col (0 ))
100- sys .exit (23 )
137+ if prof .lower ().strip () == "f" or prof .lower ().strip () == "fast" :
138+ cert = 1.5
139+ elif prof .lower ().strip () == "b" or prof .lower ().strip () == "balanced" :
140+ cert = 2.8
141+ elif prof .lower ().strip () == "s" or prof .lower ().strip () == "secure" :
142+ cert = 4
101143
102144# Write the result to disk so postinst can have a look at it
103145with open ("/tmp/howdy_picked_device" , "w" ) as out_file :
104- out_file .write ("/dev/v4l/by-path/" + picked )
146+ out_file .write ("/dev/v4l/by-path/" + picked + ";" + str ( cert ) )
105147
106148# Add a line break
107149print ("" )
0 commit comments