Last active
December 3, 2024 01:06
-
-
Save opragel/59e368872303496db07061e67f0eb18f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
"""Intends to read USB SmartCard and return | |
device names, product IDs, and vendor IDs""" | |
import json | |
import subprocess | |
def main(): | |
cmd = ['/usr/sbin/system_profiler', 'SPUSBDataType', '-json'] | |
output = subprocess.check_output(cmd) | |
info = json.loads(output) | |
hardware_info = info['SPUSBDataType'] | |
items = [] | |
for dict in hardware_info: | |
if "_items" in dict: | |
for item in dict["_items"]: | |
items.append(f"{item['_name']},{item['product_id']}") | |
if not items: | |
items = "N/A" | |
print(f"<result>{items}</result>") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment