Skip to content

Commit

Permalink
Fix grgsm_scanner -l
Browse files Browse the repository at this point in the history
  • Loading branch information
0xxstone committed Oct 26, 2024
1 parent 2de47e2 commit 699328d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions python/misc_utils/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,23 @@

import osmosdr
import os
from urllib.parse import parse_qsl
from ast import literal_eval

def get_devices(hint=""):
return osmosdr.device_find(osmosdr.device_t(hint))

def device_to_dict(dev):
dev_dict = {}
for k, v in parse_qsl(dev.to_string(), separator=","):
try:
dev_dict[k] = literal_eval(v)
except (ValueError, SyntaxError):
dev_dict[k] = literal_eval(f"'{v}'")
return dev_dict

def match(dev, filters):
dev = device_to_dict(dev)
for f in filters:
for k, v in f.items():
if (k not in dev or dev[k] != v):
Expand Down

0 comments on commit 699328d

Please sign in to comment.