exlab_wizard.sync.bandwidth#

Bandwidth schedule evaluator. Backend Spec §7.1.7.

The §7.1.7 bandwidth limiter is per-equipment and per-window: an operator declares an upload_mbps cap and an optional list of schedule windows. The cap applies inside any active window; outside the windows the transport runs unthrottled.

This module is the pure evaluator: given a BandwidthConfig and a local-time datetime, return the effective bandwidth limit in KiB/s (--bwlimit units) or None for unlimited. The conversion is upload_mbps * 1024 / 8 per §7.1.7; the spec uses megabits, rclone expects kibibytes/s, and the helper rounds to the nearest integer.

Functions

effective_bandwidth_limit_kibps(cfg, *, ...)

Return the effective --bwlimit in KiB/s for now_local.

is_window_active(window, now_local)

Return True iff now_local is inside window.

mbps_to_kibps(upload_mbps)

Convert upload_mbps (megabits/s) into --bwlimit KiB/s.

exlab_wizard.sync.bandwidth.effective_bandwidth_limit_kibps(cfg, *, now_local)[source]#

Return the effective --bwlimit in KiB/s for now_local.

Decision tree per §7.1.7:

  1. If cfg.upload_mbps is None -> unlimited (None).

  2. Else if cfg.schedule is empty -> the cap applies always.

  3. Else if now_local falls inside any schedule window -> the cap applies for this transfer.

  4. Else -> unlimited (None).

Parameters:
Return type:

int | None

exlab_wizard.sync.bandwidth.is_window_active(window, now_local)[source]#

Return True iff now_local is inside window.

The window is defined by days (a list of three-letter day names) and from/to HH:MM strings (interpreted as workstation-local time). The window is half-open: from <= t < to. Cross-midnight windows are not supported by §9 (validated at config load).

Parameters:
Return type:

bool

exlab_wizard.sync.bandwidth.mbps_to_kibps(upload_mbps)[source]#

Convert upload_mbps (megabits/s) into --bwlimit KiB/s.

Per §7.1.7: K = upload_mbps * 1024 / 8. Rounded to the nearest integer. Returns 1 KiB/s as the floor when the input is positive but rounds to zero so a configured limit always throttles something.

Parameters:

upload_mbps (float)

Return type:

int