Skip to content

Commit 3e026ee

Browse files
committed
[Collector] Add --ignore-toolfilter option for downloading/refreshing crashes
1 parent a1c90b6 commit 3e026ee

1 file changed

Lines changed: 24 additions & 6 deletions

File tree

Collector/Collector.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -347,16 +347,18 @@ def download_all(self, query_params):
347347
yield local_filename
348348

349349
@remote_checks
350-
def get_by_query(self, rest_endpoint, query_params={}):
350+
def get_by_query(self, rest_endpoint, query_params={}, _ignore_toolfilter=None):
351351
"""
352352
Get request for the specified REST endpoint and query params.
353353
354354
@type rest_endpoint: str
355355
@param rest_endpoint: for crashmanager/rest/{rest_endpoint}.
356356
357-
@type params: dict
358-
@param params: dictionary of params to query with; empty default.
357+
@type query_params: dict
358+
@param query_params: dictionary of params to query with; empty default.
359359
360+
@type _ignore_toolfilter: int
361+
@param _ignore_toolfilter: integer 0 or 1 to ignore your set toolfilter
360362
@rtype: generator
361363
@return: generator of JSON responses for the specified query.
362364
"""
@@ -366,7 +368,14 @@ def get_by_query(self, rest_endpoint, query_params={}):
366368
self.serverPort,
367369
)
368370
next_url = url_rest + rest_endpoint
369-
params = {"query": json.dumps({"op": "AND", **query_params})}
371+
global ignore_toolfilter
372+
ignore = (
373+
_ignore_toolfilter if _ignore_toolfilter is not None else ignore_toolfilter
374+
)
375+
params = {
376+
"query": json.dumps({"op": "AND", **query_params}),
377+
"ignore_toolfilter": ignore,
378+
}
370379

371380
while next_url:
372381
resp_json = self.get(next_url, params=params).json()
@@ -585,6 +594,11 @@ def main(args=None):
585594
action="store_true",
586595
help="Refresh only the best entry crashes for buckets found by --query-params",
587596
)
597+
parser.add_argument(
598+
"--ignore-toolfilter",
599+
action="store_true",
600+
help="Ignore your (supposedly) set toolfilter for queries.",
601+
)
588602
parser.add_argument(
589603
"--metadata",
590604
nargs="+",
@@ -771,6 +785,8 @@ def main(args=None):
771785
collector.serverHost,
772786
collector.serverPort,
773787
)
788+
global ignore_toolfilter
789+
ignore_toolfilter = 1 if opts.ignore_toolfilter else 0
774790

775791
if opts.refresh:
776792
collector.refresh()
@@ -881,7 +897,6 @@ def main(args=None):
881897
print("No buckets found", file=sys.stderr)
882898
return 1
883899
all_params = [{"bucket": bucket} for bucket in buckets]
884-
# TODO: some check if no toolfilter is set?
885900
elif opts.query_params:
886901
if opts.best_entry_only:
887902
buckets = set()
@@ -894,7 +909,10 @@ def main(args=None):
894909
if opts.best_entry_only:
895910
all_params = []
896911
for bucket in buckets:
897-
resp_bucket = collector.get(url_rest + f"buckets/{bucket}").json()
912+
resp_bucket = collector.get(
913+
url_rest + f"buckets/{bucket}",
914+
params={"ignore_toolfilter": ignore_toolfilter},
915+
).json()
898916
all_params.append({"bucket": bucket, "id": resp_bucket["best_entry"]})
899917

900918
if opts.download_by_params:

0 commit comments

Comments
 (0)