zabgrab.cli.fetch

zabgrab fetch: downloading data.

Functions

guard_text(app, target, result, query, allow)

Check before writing a lot of text to a .mat file.

report_problems(app, result)

Warn about skipped items and report failed ones.

run_plan(app, plan, query, *, dry_run, empty)

Download the data for a plan's jobs, then close its connections.

save_target(target, result, metadata, query, ...)

Write fetched data to a file.

async zabgrab.cli.fetch.run_plan(app, plan, query, *, dry_run, empty)[source]

Download the data for a plan’s jobs, then close its connections.

Parameters:
  • app (AppContext) – For the UI and the clock.

  • plan (Plan) – The items to download, and the connections to their servers.

  • query (Query) – The time range and settings.

  • dry_run (bool) – Show the items that would be downloaded instead.

  • empty (ZabgrabError) – The error to raise if there are no items.

Returns:

FetchResult or None – The data, or None for a dry run.

Return type:

FetchResult | None

zabgrab.cli.fetch.guard_text(app, target, result, query, allow)[source]

Check before writing a lot of text to a .mat file.

See zabgrab.services.output.guard_large_text().

Parameters:
  • app (AppContext) – For the UI.

  • target (Target) – Where the data is to be saved.

  • result (FetchResult) – The data.

  • query (Query) – For the mat_text_warn_entries setting.

  • allow (bool) – --allow-large-text.

Returns:

tuple of Target and FetchResult – Where to save, and what.

Return type:

tuple[Target, FetchResult]

zabgrab.cli.fetch.save_target(target, result, metadata, query, options)[source]

Write fetched data to a file.

Parameters:
  • target (Target) – Where and how to save.

  • result (FetchResult) – The data.

  • metadata (dict) – The metadata to save with it.

  • query (Query) – The query, for its time range and timezone.

  • options (SaveOptions) – --group and --in-place, for appending.

Returns:

str – A description of where the data went, for the summary.

Return type:

str

zabgrab.cli.fetch.report_problems(app, result)[source]

Warn about skipped items and report failed ones.

Parameters:
Raises:

ZabgrabError – If nothing was fetched.

Return type:

None