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
|
Return the effective |
|
Return True iff |
|
Convert |
- exlab_wizard.sync.bandwidth.effective_bandwidth_limit_kibps(cfg, *, now_local)[source]#
Return the effective
--bwlimitin KiB/s fornow_local.Decision tree per §7.1.7:
If
cfg.upload_mbpsisNone-> unlimited (None).Else if
cfg.scheduleis empty -> the cap applies always.Else if
now_localfalls inside any schedule window -> the cap applies for this transfer.Else -> unlimited (
None).
- Parameters:
cfg (
BandwidthConfig)now_local (
datetime)
- Return type:
- exlab_wizard.sync.bandwidth.is_window_active(window, now_local)[source]#
Return True iff
now_localis insidewindow.The window is defined by
days(a list of three-letter day names) andfrom/toHH: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:
window (
BandwidthWindow)now_local (
datetime)
- Return type:
- exlab_wizard.sync.bandwidth.mbps_to_kibps(upload_mbps)[source]#
Convert
upload_mbps(megabits/s) into--bwlimitKiB/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.