zabgrab.cli.fetch¶
zabgrab fetch: downloading data.
Functions
|
Find the items and download their data, reporting any problems. |
|
Describe what was fetched, e.g. |
|
Check before writing a lot of text to a .mat file. |
|
Warn about skipped items and report failed ones. |
|
Work out what to fetch from the command line, the template and the config. |
|
Download the data for a plan's jobs, then close its connections. |
|
Write fetched data to a file. |
|
Check fetch settings given on the command line. |
|
Show the command that repeats this command without its questions. |
- zabgrab.cli.fetch.settings_values(given)[source]¶
Check fetch settings given on the command line.
- Parameters:
given (dict) – The options’ values, by setting name (
Nonewhere not given).- Returns:
dict – The settings given.
- Raises:
click.UsageError – If a value isn’t valid.
- Return type:
- zabgrab.cli.fetch.resolve_request(app, *, templates, items, servers, values, now)[source]¶
Work out what to fetch from the command line, the template and the config.
- Parameters:
app (AppContext) – For the config and the UI (anything missing is asked for).
templates (tuple) –
--template,--itemand--server.items (tuple) –
--template,--itemand--server.servers (tuple) –
--template,--itemand--server.values (dict) – The other settings given (see
settings_values()).now (datetime) – The start of the command, for relative times.
- Returns:
CliRequest – The command line’s request.
Query – What to fetch, and where each setting came from.
- Return type:
- zabgrab.cli.fetch.show_equivalent(app, query, *, templates=True)[source]¶
Show the command that repeats this command without its questions.
- Parameters:
app (AppContext) – For the UI.
query (Query) – The query, with the answers given to questions.
templates (bool, optional) – Whether the command can save templates (
--save-template).
- Return type:
None
- zabgrab.cli.fetch.fetch_summary(result, query)[source]¶
Describe what was fetched, e.g.
Fetched 2 items (4 points) from ....- Parameters:
result (FetchResult) – The data (with at least one series).
query (Query) – The query, for the time range and time zone.
- Returns:
str – The description, without a full stop.
- Return type:
- zabgrab.cli.fetch.download(app, query, *, yes)[source]¶
Find the items and download their data, reporting any problems.
- Parameters:
app (AppContext) – For the UI and the connections.
query (Query) – What to fetch.
yes (bool) –
--yes: fetch however many items match.
- Returns:
FetchResult – The data, with at least one series.
- Raises:
ZabgrabError – If there are no items, or nothing could be fetched.
- Return type:
- 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
Nonefor 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_entriessetting.allow (bool) –
--allow-large-text.
- Returns:
tuple of Target and FetchResult – Where to save, and what.
- Return type:
- 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) –
--groupand--in-place, for appending.
- Returns:
str – A description of where the data went, for the summary.
- Return type:
- zabgrab.cli.fetch.report_problems(app, result)[source]¶
Warn about skipped items and report failed ones.
- Parameters:
app (AppContext) – For the UI.
result (FetchResult) – The fetched data.
- Raises:
ZabgrabError – If nothing was fetched.
- Return type:
None