@@ -43,24 +43,31 @@ def get_args():
4343
4444
4545if __name__ == "__main__" :
46- args = get_args ()
47- beamers = fetch_devices (args .startpoint , headers = args .headers )
48- if args .verbose :
49- print ("Beamers:" , len (beamers ))
50- devices = {}
51- for device in beamers :
52- private_key_bytes = bytes (device ["privateKey" ]["data" ])
46+ command_args = get_args ()
47+
48+ beamer_devices = fetch_devices (
49+ command_args .startpoint , headers = command_args .headers
50+ )
51+ if command_args .verbose :
52+ print ("Beamers:" , len (beamer_devices ))
53+
54+ device_mapping = {}
55+ for device in beamer_devices :
56+ privateKeyBytes = bytes (device ["privateKey" ]["data" ])
5357 del device ["privateKey" ]
54- device ["privateKeyInt" ] = bytes_to_int (private_key_bytes )
55- public_hash_b64 = b64_ascii (get_hashed_public_key (private_key_bytes ))
56- devices [public_hash_b64 ] = device
57- result = apple_fetch (args .key , list (devices .keys ()))
58- if args .verbose :
59- print ("Results:" , len (result ["results" ]))
60- reports = create_reports (result , devices )
61- for device in reports :
62- if "privateKeyInt" in device :
63- del device ["privateKeyInt" ]
64- send_reports (args .endpoint , reports , headers = args .headers )
65- if args .verbose :
66- print (reports )
58+ device ["privateKeyNumeric" ] = bytes_to_int (privateKeyBytes )
59+ publicHashBase64 = b64_ascii (get_hashed_public_key (privateKeyBytes ))
60+ device_mapping [publicHashBase64 ] = device
61+
62+ apple_result = apple_fetch (command_args .key , list (device_mapping .keys ()))
63+ if command_args .verbose :
64+ print ("Results:" , len (apple_result ["results" ]))
65+
66+ report_list = create_reports (apple_result , device_mapping )
67+ for report in report_list :
68+ if "privateKeyNumeric" in report :
69+ del report ["privateKeyNumeric" ]
70+
71+ send_reports (command_args .endpoint , report_list , headers = command_args .headers )
72+ if command_args .verbose :
73+ print (report_list )
0 commit comments