|
7 | 7 |
|
8 | 8 | from argparse import ArgumentParser |
9 | 9 | import json |
| 10 | +from time import sleep |
10 | 11 | from api import fetch_devices, send_reports |
11 | 12 | from cryptic import b64_ascii, get_hashed_public_key, bytes_to_int |
12 | 13 | from apple_fetch import apple_fetch |
| 14 | +from helpers import chunks |
13 | 15 | from report import create_reports |
14 | 16 |
|
15 | 17 |
|
@@ -59,15 +61,15 @@ def get_args(): |
59 | 61 | publicHashBase64 = b64_ascii(get_hashed_public_key(privateKeyBytes)) |
60 | 62 | device_mapping[publicHashBase64] = device |
61 | 63 |
|
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) |
| 64 | + for devices_chunk in chunks(device_mapping, 10): |
| 65 | + apple_result = apple_fetch(command_args.key, list(devices_chunk.keys())) |
| 66 | + if command_args.verbose: |
| 67 | + print("Results:", len(apple_result["results"])) |
| 68 | + report_list = create_reports(apple_result, device_mapping) |
| 69 | + for report in report_list: |
| 70 | + if "privateKeyNumeric" in report: |
| 71 | + del report["privateKeyNumeric"] |
| 72 | + send_reports(command_args.endpoint, report_list, headers=command_args.headers) |
| 73 | + if command_args.verbose: |
| 74 | + print(report_list) |
| 75 | + sleep(0.1) |
0 commit comments