RemoteRF 2.13.4__tar.gz → 2.13.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. {remoterf-2.13.4/src/remoterf.egg-info → remoterf-2.13.6}/PKG-INFO +26 -1
  2. {remoterf-2.13.4 → remoterf-2.13.6}/README.md +25 -0
  3. {remoterf-2.13.4 → remoterf-2.13.6}/pyproject.toml +1 -1
  4. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/__init__.py +17 -0
  5. remoterf-2.13.6/src/remoterf/api.py +152 -0
  6. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/core/app.py +6 -6
  7. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/core/grpc_client.py +1 -1
  8. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/data/agent_guide.md +29 -1
  9. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/data/mcp_tools.json +1 -1
  10. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/mcp_server.py +1 -1
  11. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/remoterf_cli.py +32 -23
  12. {remoterf-2.13.4 → remoterf-2.13.6/src/remoterf.egg-info}/PKG-INFO +26 -1
  13. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf.egg-info/SOURCES.txt +2 -0
  14. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_agent_docs.py +1 -1
  15. remoterf-2.13.6/tests/test_api.py +140 -0
  16. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_cli_login_fresh.py +10 -9
  17. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_device_routes.py +1 -1
  18. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_homes.py +93 -1
  19. {remoterf-2.13.4 → remoterf-2.13.6}/LICENSE +0 -0
  20. {remoterf-2.13.4 → remoterf-2.13.6}/setup.cfg +0 -0
  21. {remoterf-2.13.4 → remoterf-2.13.6}/setup.py +0 -0
  22. {remoterf-2.13.4 → remoterf-2.13.6}/src/_remoterf_alias.py +0 -0
  23. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/admin.py +0 -0
  24. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/agent_cli.py +0 -0
  25. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/agent_docs.py +0 -0
  26. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/common/__init__.py +0 -0
  27. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/common/grpc/__init__.py +0 -0
  28. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/common/grpc/deployment_capabilities.proto +0 -0
  29. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/common/grpc/deployment_capabilities_pb2.py +0 -0
  30. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/common/grpc/deployment_capabilities_pb2_grpc.py +0 -0
  31. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/common/grpc/grpc.proto +0 -0
  32. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/common/grpc/grpc_pb2.py +0 -0
  33. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/common/grpc/grpc_pb2_grpc.py +0 -0
  34. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/common/grpc/v2_codec.py +0 -0
  35. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/common/tos_notice.txt +0 -0
  36. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/common/utils/__init__.py +0 -0
  37. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/common/utils/ansi_codes.py +0 -0
  38. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/common/utils/api_token.py +0 -0
  39. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/common/utils/banner.py +0 -0
  40. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/common/utils/list_string.py +0 -0
  41. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/common/utils/process_arg.py +0 -0
  42. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/config/__init__.py +0 -0
  43. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/config/cert_fetcher.py +0 -0
  44. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/config/config.py +0 -0
  45. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/core/__init__.py +0 -0
  46. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/core/acc_login.py +0 -0
  47. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/core/availability.py +0 -0
  48. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/core/banner_note.txt +0 -0
  49. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/core/direct_path.py +0 -0
  50. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/core/dynamic_v2_transport.py +0 -0
  51. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/core/grpc_acc.py +0 -0
  52. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/core/messages.py +0 -0
  53. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/core/secure_channel.py +0 -0
  54. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/core/v2_errors.py +0 -0
  55. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/deployment/__init__.py +0 -0
  56. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/deployment/backend.py +0 -0
  57. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/deployment/direct.py +0 -0
  58. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/deployment/homes.py +0 -0
  59. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/deployment/http.py +0 -0
  60. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/deployment/lanpass.py +0 -0
  61. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/deployment/state.py +0 -0
  62. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/drivers/__init__.py +0 -0
  63. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/drivers/_virtual.py +0 -0
  64. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/drivers/adalm_pluto/__init__.py +0 -0
  65. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/drivers/adalm_pluto/adalm_pluto_remote.py +0 -0
  66. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/drivers/dynamic_device.py +0 -0
  67. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/drivers/dynamic_v2.py +0 -0
  68. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/drivers/hackrf/__init__.py +0 -0
  69. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/drivers/hackrf/hackrf_remote.py +0 -0
  70. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/drivers/rtl_sdr/__init__.py +0 -0
  71. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/drivers/rtl_sdr/rtl_sdr_remote.py +0 -0
  72. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/drivers/schema_review.py +0 -0
  73. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/drivers/sim_sdr/__init__.py +0 -0
  74. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/drivers/sim_sdr/sim_sdr_remote.py +0 -0
  75. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/drivers/support/__init__.py +0 -0
  76. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/drivers/support/ti_mmwave.py +0 -0
  77. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/drivers/support/uhd.py +0 -0
  78. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/drivers/support/uhd_dsp.py +0 -0
  79. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/drivers/support/uhd_v2.py +0 -0
  80. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/drivers/ti_mmwave/__init__.py +0 -0
  81. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/drivers/ti_mmwave/ti_mmwave_remote.py +0 -0
  82. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/drivers/usrp/__init__.py +0 -0
  83. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/drivers/usrp/usrp_remote.py +0 -0
  84. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/drivers/usrp/usrp_remote.pyi +0 -0
  85. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/ops.py +0 -0
  86. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf/version.py +0 -0
  87. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf.egg-info/dependency_links.txt +0 -0
  88. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf.egg-info/entry_points.txt +0 -0
  89. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf.egg-info/requires.txt +0 -0
  90. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf.egg-info/top_level.txt +0 -0
  91. {remoterf-2.13.4 → remoterf-2.13.6}/src/remoterf.py +0 -0
  92. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_agent_cli.py +0 -0
  93. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_banner.py +0 -0
  94. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_batch.py +0 -0
  95. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_bundled_drivers.py +0 -0
  96. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_ca_pin.py +0 -0
  97. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_config_address.py +0 -0
  98. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_deployment_accounts.py +0 -0
  99. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_devices_api.py +0 -0
  100. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_direct_path_fixed.py +0 -0
  101. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_direct_path_global.py +0 -0
  102. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_direct_path_partner.py +0 -0
  103. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_direct_path_race.py +0 -0
  104. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_direct_path_relay.py +0 -0
  105. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_dynamic_device_codegen.py +0 -0
  106. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_dynamic_v2.py +0 -0
  107. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_federated_devices.py +0 -0
  108. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_fetch_idl_fallback.py +0 -0
  109. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_finish_prompt.py +0 -0
  110. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_gate_i_direct_path.py +0 -0
  111. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_grpc_client_target.py +0 -0
  112. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_lan_fallback.py +0 -0
  113. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_mcp_server.py +0 -0
  114. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_messages.py +0 -0
  115. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_native_account_credentials.py +0 -0
  116. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_native_devices.py +0 -0
  117. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_old_import_name.py +0 -0
  118. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_ops.py +0 -0
  119. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_partner_dynamic_v2.py +0 -0
  120. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_pluto_virtual.py +0 -0
  121. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_process_arg.py +0 -0
  122. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_relay_paging.py +0 -0
  123. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_remote_admin.py +0 -0
  124. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_remoterf_cli.py +0 -0
  125. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_rx_readahead.py +0 -0
  126. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_schema_review.py +0 -0
  127. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_ti_mmwave.py +0 -0
  128. {remoterf-2.13.4 → remoterf-2.13.6}/tests/test_upgrade_rescue.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: remoterf
3
- Version: 2.13.4
3
+ Version: 2.13.6
4
4
  Summary: A python API to remotely access signal centric hardware. Client-side only! Courtesy of Wireless Lab @ UCLA & Prof. Ian Roberts.
5
5
  Author-email: Ethan Ge <84103791+ethange1@users.noreply.github.com>
6
6
  License-Expression: GPL-3.0-or-later
@@ -400,6 +400,31 @@ to require a reservation first.
400
400
 
401
401
  Each account may ask once every 10 seconds; a repeat call within that reprints the last table with the remaining wait.
402
402
 
403
+ #### Python reservation API
404
+
405
+ Scripts can find slots, reserve and cancel with the saved login. These top-level functions are the stable API
406
+ (`remoterf.ops` is internal). They print nothing, return plain dicts, and raise `remoterf.RemoteRFOpsError`
407
+ (with `.code` and `.message`) on failure:
408
+
409
+ ```python
410
+ import remoterf
411
+
412
+ remoterf.use("ucla") # default deployment for handles without @ (or set REMOTERF_DEPLOYMENT)
413
+
414
+ free = remoterf.slots("Pluto_00")["slots"] # today's free slots, aligned from local midnight
415
+ r = remoterf.reserve("Pluto_00", free[0]["start"], minutes=60) # or end=...; must be whole free slots
416
+ print(r["handle"], r["start"], r["end"])
417
+
418
+ for row in remoterf.reservations()["reservations"]:
419
+ print(row["reservation_id"], row["handle"], row["start"])
420
+
421
+ remoterf.cancel(r) # the dict from reserve()/reservations(), or an id such as "10@ucla"
422
+ ```
423
+
424
+ Also: `remoterf.whoami()`, `remoterf.list_devices()` (the non-printing `devices()`) and `remoterf.reserve_now(handle)`.
425
+ Without `use()` or `REMOTERF_DEPLOYMENT`, a bare name means the deployment you logged in to directly; an explicit
426
+ `Name@lab` always wins. Driver tokens (`Pluto(token=...)`) still need the full handle.
427
+
403
428
  ## Closing
404
429
 
405
430
  This is fundamentally a experimental platform, and there will be many unknown bugs and issues. Some devices do not have universal support for all its functions at the moment, I am working on that aspect.
@@ -373,6 +373,31 @@ to require a reservation first.
373
373
 
374
374
  Each account may ask once every 10 seconds; a repeat call within that reprints the last table with the remaining wait.
375
375
 
376
+ #### Python reservation API
377
+
378
+ Scripts can find slots, reserve and cancel with the saved login. These top-level functions are the stable API
379
+ (`remoterf.ops` is internal). They print nothing, return plain dicts, and raise `remoterf.RemoteRFOpsError`
380
+ (with `.code` and `.message`) on failure:
381
+
382
+ ```python
383
+ import remoterf
384
+
385
+ remoterf.use("ucla") # default deployment for handles without @ (or set REMOTERF_DEPLOYMENT)
386
+
387
+ free = remoterf.slots("Pluto_00")["slots"] # today's free slots, aligned from local midnight
388
+ r = remoterf.reserve("Pluto_00", free[0]["start"], minutes=60) # or end=...; must be whole free slots
389
+ print(r["handle"], r["start"], r["end"])
390
+
391
+ for row in remoterf.reservations()["reservations"]:
392
+ print(row["reservation_id"], row["handle"], row["start"])
393
+
394
+ remoterf.cancel(r) # the dict from reserve()/reservations(), or an id such as "10@ucla"
395
+ ```
396
+
397
+ Also: `remoterf.whoami()`, `remoterf.list_devices()` (the non-printing `devices()`) and `remoterf.reserve_now(handle)`.
398
+ Without `use()` or `REMOTERF_DEPLOYMENT`, a bare name means the deployment you logged in to directly; an explicit
399
+ `Name@lab` always wins. Driver tokens (`Pluto(token=...)`) still need the full handle.
400
+
376
401
  ## Closing
377
402
 
378
403
  This is fundamentally a experimental platform, and there will be many unknown bugs and issues. Some devices do not have universal support for all its functions at the moment, I am working on that aspect.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "remoterf"
7
- version = "2.13.4"
7
+ version = "2.13.6"
8
8
  description = "A python API to remotely access signal centric hardware. Client-side only! Courtesy of Wireless Lab @ UCLA & Prof. Ian Roberts."
9
9
  readme = "README.md"
10
10
  license = "GPL-3.0-or-later"
@@ -20,3 +20,20 @@ def devices():
20
20
  from .core.availability import devices as _devices
21
21
 
22
22
  return _devices()
23
+
24
+
25
+ # The stable reservation API (remoterf.api), imported on first use: `ops` is internal.
26
+ _API = ("use", "whoami", "list_devices", "slots", "reservations", "reserve", "reserve_now", "cancel",
27
+ "RemoteRFOpsError")
28
+
29
+
30
+ def __getattr__(name):
31
+ if name in _API:
32
+ from . import api
33
+
34
+ return getattr(api, name)
35
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
36
+
37
+
38
+ def __dir__():
39
+ return sorted({*globals(), *_API})
@@ -0,0 +1,152 @@
1
+ # Copyright (C) 2026 RemoteRF
2
+ #
3
+ # This program is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
15
+
16
+ """The stable Python reservation API, re-exported as `remoterf.<name>`.
17
+ It only adapts arguments; `ops` (internal) does the work. Plain dicts out,
18
+ RemoteRFOpsError on failure; nothing prints or prompts."""
19
+
20
+ import os
21
+ import threading
22
+ from datetime import datetime, timezone
23
+
24
+ from . import ops
25
+ from .ops import RemoteRFOpsError
26
+
27
+ _session = None
28
+ _lock = threading.Lock()
29
+ _default = None
30
+
31
+
32
+ def _call(fn, *args, **kwargs):
33
+ """fn(session, ...) with the saved login, loaded once; reloaded and
34
+ retried once when the deployment says it expired. Safe across threads."""
35
+ global _session
36
+ with _lock:
37
+ if _session is None:
38
+ _session = ops.saved_session()
39
+ s = _session
40
+ try:
41
+ return fn(s, *args, **kwargs)
42
+ except RemoteRFOpsError as exc:
43
+ if exc.code != "session_expired":
44
+ raise
45
+ with _lock:
46
+ if _session is s: # another thread may have reloaded already
47
+ _session = ops.saved_session()
48
+ s = _session
49
+ return fn(s, *args, **kwargs)
50
+
51
+
52
+ def use(deployment):
53
+ """Set the deployment a handle with no `@lab` means, for this process; None clears it."""
54
+ global _default
55
+ _default = str(deployment or "").strip().lower() or None
56
+
57
+
58
+ def _lab(s):
59
+ """use(), then REMOTERF_DEPLOYMENT, then the lab this login is at."""
60
+ return (_default or os.environ.get("REMOTERF_DEPLOYMENT", "").strip().lower()
61
+ or (s.home if s.home_kind == "deployment" else None))
62
+
63
+
64
+ def _handle(s, handle):
65
+ handle = str(handle or "").strip()
66
+ if "@" in handle or not handle:
67
+ return handle
68
+ lab = _lab(s)
69
+ if not lab:
70
+ raise RemoteRFOpsError("invalid_argument", "A handle is Name@deployment, for example Pluto_00@ucla. "
71
+ 'Or set a default deployment: remoterf.use("ucla").')
72
+ return f"{handle}@{lab}"
73
+
74
+
75
+ def whoami() -> dict:
76
+ return _call(ops.whoami)
77
+
78
+
79
+ def list_devices(deployment=None, online_only=True, type=None) -> dict:
80
+ """Like remoterf.devices(), as a dict and without printing."""
81
+ return _call(ops.list_devices, deployment=deployment, online_only=online_only, type=type)
82
+
83
+
84
+ def slots(handle, start_day=None, days=1, tz=None) -> dict:
85
+ return _call(lambda s: ops.find_slots(s, _handle(s, handle), start_day=start_day, days=days, tz=tz))
86
+
87
+
88
+ def reservations(mine_only=True) -> dict:
89
+ return _call(ops.list_reservations, mine_only=mine_only)
90
+
91
+
92
+ def _check_window(s, handle, start_ts, end_ts):
93
+ """Refuse a window that isn't consecutive free blocks of the device's grid, before asking the lab."""
94
+ first, last = datetime.fromtimestamp(start_ts), datetime.fromtimestamp(end_ts - 1)
95
+ out = ops.find_slots(s, handle, start_day=first.date(), days=(last.date() - first.date()).days + 1)
96
+ block = out["slot_minutes"] * 60
97
+ free = {slot["start_ts"]: slot["end_ts"] for slot in out["slots"]}
98
+ after = [slot["start"] for slot in out["slots"] if slot["start_ts"] >= start_ts]
99
+ nxt = f"the next free one starts {after[0]}" if after else "none is free later on those days"
100
+ minute = first.hour * 60 + first.minute
101
+ if first.second or minute % (block // 60) or (end_ts - start_ts) % block:
102
+ raise RemoteRFOpsError("invalid_argument", f"{out['handle']} is reserved in {block // 60}-minute slots "
103
+ f"from midnight; {nxt}.")
104
+ ts = start_ts
105
+ while ts < end_ts:
106
+ if ts not in free:
107
+ raise RemoteRFOpsError("slot_unavailable", f"The {block // 60}-minute slot at "
108
+ f"{ops._instant('t', ts)['t']} on {out['handle']} isn't free; {nxt}.")
109
+ ts = free[ts]
110
+
111
+
112
+ def reserve(handle, start, end=None, *, minutes=None, reveal_token=False) -> dict:
113
+ """Reserve `handle` from `start` (datetime or RFC 3339; naive is local time)
114
+ to `end`, or for `minutes`: one or more consecutive free slots."""
115
+ if (end is None) == (minutes is None):
116
+ raise RemoteRFOpsError("invalid_argument", "Give exactly one of end or minutes.")
117
+ start_ts = ops._epoch(start)
118
+ if minutes is not None:
119
+ if isinstance(minutes, bool) or not isinstance(minutes, int) or minutes <= 0:
120
+ raise RemoteRFOpsError("invalid_argument", "minutes must be a positive whole number.")
121
+ end_ts = start_ts + minutes * 60
122
+ else:
123
+ end_ts = ops._epoch(end)
124
+ if end_ts <= start_ts:
125
+ raise RemoteRFOpsError("invalid_argument", "end must be after start.")
126
+
127
+ def book(s):
128
+ h = _handle(s, handle)
129
+ _check_window(s, h, start_ts, end_ts)
130
+ return ops.reserve(s, h, datetime.fromtimestamp(start_ts, timezone.utc),
131
+ datetime.fromtimestamp(end_ts, timezone.utc), reveal_token=reveal_token)
132
+
133
+ return _call(book)
134
+
135
+
136
+ def reserve_now(handle) -> dict:
137
+ """Reserve the free slot running now."""
138
+ return _call(lambda s: ops.auto_reserve(s, _handle(s, handle)))
139
+
140
+
141
+ def cancel(reservation) -> dict:
142
+ """Cancel a reservation: a dict from reserve() or reservations(), or its id ('10@ucla')."""
143
+ rid = reservation.get("reservation_id") if isinstance(reservation, dict) else reservation
144
+ if not rid:
145
+ raise RemoteRFOpsError("invalid_argument", "No reservation_id: find it with remoterf.reservations().")
146
+
147
+ def drop(s):
148
+ num, at, lab = str(rid).rpartition("@")
149
+ # A lab login knows its own ids without the '@lab' Global adds.
150
+ return ops.cancel(s, num if at and s.home_kind == "deployment" and lab.lower() == s.home else rid)
151
+
152
+ return _call(drop)
@@ -114,7 +114,7 @@ def _password_confirmation(*, enforce_policy=False):
114
114
 
115
115
  # The code typed at `remoterf -r`, used once for this registration.
116
116
  pending_enrollment_code = None
117
- # A username already given (`name@lab` at `-l`): the login asks only the password.
117
+ # A username already given (`name@global` or an email at `-l`): the login asks only the password.
118
118
  pending_username = None
119
119
  # The saved home this shell is attached to (None on a bare direct profile).
120
120
  home_name = None
@@ -165,9 +165,9 @@ def _print_reserved(where, when, token, handle, logged_in_to, install, no_handle
165
165
  rows.append(("Handle ", Sty.BOLD, handle, (Sty.BOLD, Sty.GREEN)))
166
166
  rows.append(())
167
167
  if handle:
168
- rows += [("Token works anywhere, no login needed.", Sty.DEFAULT),
168
+ rows += [("Token Works anywhere, no login needed.", Sty.DEFAULT),
169
169
  (" Keep it safe: it can't be shown again.", Sty.DEFAULT),
170
- (f"Handle works while you're logged in to {logged_in_to}", Sty.DEFAULT),
170
+ (f"Handle Works while you're logged in to {logged_in_to}", Sty.DEFAULT),
171
171
  (" and this reservation is active.", Sty.DEFAULT)]
172
172
  else:
173
173
  rows += [("Works anywhere, no login needed.", Sty.DEFAULT),
@@ -481,7 +481,7 @@ def welcome(*, show_banner: bool = True, initial=(), route=None):
481
481
  except Exception as exc: # noqa: BLE001 - same rule for the HTTPS session
482
482
  if not getattr(exc, 'sent', True):
483
483
  # Global did not answer: the session is fine, so keep it.
484
- printf('RemoteRF Global is not answering. Try again, or open a lab directly: remoterf -l <you>@<lab>', Sty.WARNING)
484
+ printf('RemoteRF Global is not answering. Try again, or open a lab directly: remoterf -l <lab>', Sty.WARNING)
485
485
  return False
486
486
  account.backend.credentials = None
487
487
  try:
@@ -1453,7 +1453,7 @@ def interactive_reserve_next_days(block_minutes=60):
1453
1453
 
1454
1454
  # --- Display the available slots, using 0-based index ---
1455
1455
  print()
1456
- printf("Available time slots for device ", Sty.BOLD, f"{chosen_device_id}", Sty.MAGENTA, f" over the next {num_days} days:", Sty.DEFAULT)
1456
+ printf("Available time slots for device ", Sty.BOLD, f"{chosen_device_id}", Sty.MAGENTA, f" over the next {num_days} days (your time, {available_slots[0][1][0].astimezone():%Z}):", Sty.DEFAULT)
1457
1457
  last_day = None
1458
1458
  for idx, (day, slot) in enumerate(available_slots):
1459
1459
  slot_start_str = slot[0].strftime('%I:%M %p')
@@ -1540,7 +1540,7 @@ def _pick_slot_and_reserve(chosen_device_id, chosen_device_name, block_minutes,
1540
1540
 
1541
1541
  print()
1542
1542
  index_width = len(str(len(available_slots) - 1))
1543
- rows = [(f"{device_label}", Sty.MAGENTA, f" {block_minutes} min blocks, next {num_days} days", Sty.GRAY)]
1543
+ rows = [(f"{device_label}", Sty.MAGENTA, f" {block_minutes} min blocks, next {num_days} days (your time, {available_slots[0][1][0].astimezone():%Z})", Sty.GRAY)]
1544
1544
  last_day = None
1545
1545
  for idx, (day, slot) in enumerate(available_slots):
1546
1546
  slot_start_str = slot[0].strftime("%I:%M %p")
@@ -349,7 +349,7 @@ _auto_tried: set = set() # x@lab handles auto-reservation already tried for in
349
349
 
350
350
  def _unreachable(dep):
351
351
  return RuntimeError(
352
- f"can't reach {dep}: log in with remoterf --login username@{dep} or use a token from {dep}"
352
+ f"can't reach {dep}: log in with remoterf --login {dep} or use a token from {dep}"
353
353
  )
354
354
 
355
355
 
@@ -3,7 +3,7 @@
3
3
  RemoteRF gives remote access to real radios (ADALM-Pluto, USRP, RTL-SDR, HackRF and deployment-defined devices) at
4
4
  RemoteRF deployments, by reservation. Experiments are ordinary Python on the user's machine; the `remoterf` drivers carry each call to the radio.
5
5
  This guide ships with the installed `remoterf` package, so it matches that version. `remoterf guide TOPIC` prints one
6
- section: workflow, tokens, cli, mcp, safety, errors.
6
+ section: workflow, tokens, cli, python, mcp, safety, errors.
7
7
 
8
8
  ## workflow
9
9
 
@@ -87,6 +87,34 @@ looks: `~/.claude/skills/remoterf/SKILL.md`, `~/.codex/AGENTS.md`, `~/.gemini/GE
87
87
  `auth apps` lists the apps connected to a Global account; connected apps arrive with the RemoteRF Global connector,
88
88
  which isn't available yet.
89
89
 
90
+ ## python
91
+
92
+ Scripts can find slots, reserve and cancel without the CLI. These top-level names are the stable Python API;
93
+ `remoterf.ops` is internal and may change. They use the saved login (loaded once, reloaded once if it expired), never
94
+ print or prompt, return plain dicts like the `--json` output, and raise `remoterf.RemoteRFOpsError` (`code`, `message`,
95
+ `retryable`, `retry_after`; the codes are those under errors).
96
+
97
+ ```python
98
+ import remoterf
99
+
100
+ remoterf.use("ucla") # default deployment for handles without @; use(None) clears it
101
+ remoterf.whoami()
102
+ remoterf.list_devices() # deployment=None, online_only=True, type=None
103
+ free = remoterf.slots("Pluto_00", days=1) # start_day=None, tz=None
104
+ r = remoterf.reserve("Pluto_00", free["slots"][0]["start"], minutes=60) # or end=...; reveal_token=False
105
+ remoterf.reservations() # mine_only=True
106
+ remoterf.cancel(r) # the dict, or its id such as "10@ucla"
107
+ remoterf.reserve_now("Pluto_00") # the free slot running now
108
+ ```
109
+
110
+ - A handle without `@` gets the default deployment: `remoterf.use()`, else `REMOTERF_DEPLOYMENT`, else the deployment
111
+ this login is at (a Global login has none). An explicit `@lab` always wins. Returned handles are always full.
112
+ - `start` is a datetime or RFC 3339 string; naive means this machine's local time. Give exactly one of `end` or
113
+ `minutes`. The window must be one or more consecutive free slots: a misaligned one raises `invalid_argument` and a
114
+ taken one `slot_unavailable`, both before anything is sent, naming the slot length and the next free slot.
115
+ - `remoterf.devices()` still prints its table; `list_devices()` is the quiet form.
116
+ - The safety rules apply: reserve and cancel only with the user's approval, and never retry them automatically.
117
+
90
118
  ## mcp
91
119
 
92
120
  Local server (Claude Code, Claude Desktop, Codex CLI, Gemini CLI, Cursor): `remoterf mcp`, over stdio, using the saved
@@ -117,7 +117,7 @@
117
117
  "input_schema": {
118
118
  "type": "object",
119
119
  "properties": {
120
- "topic": {"type": "string", "description": "One section: workflow, tokens, cli, mcp, safety, errors. Default: the whole guide."}
120
+ "topic": {"type": "string", "description": "One section: workflow, tokens, cli, python, mcp, safety, errors. Default: the whole guide."}
121
121
  },
122
122
  "required": []
123
123
  }
@@ -151,7 +151,7 @@ def build_server(*, allow_reserve: bool, session_factory=ops.saved_session):
151
151
  return read(lambda: _docs().guide()["text"], session=False)
152
152
 
153
153
  @server.resource("remoterf://docs/{page}", name="docs", title="RemoteRF guide section", mime_type="text/markdown",
154
- description="One section of the agent guide: workflow, tokens, cli, mcp, safety, errors.")
154
+ description="One section of the agent guide: workflow, tokens, cli, python, mcp, safety, errors.")
155
155
  def docs_resource(page: str):
156
156
  return read(lambda: _docs().guide(page)["text"], session=False)
157
157
 
@@ -151,7 +151,7 @@ def print_help() -> None:
151
151
  printf(" remoterf -h | --help", Sty.CYAN, " Show this help", Sty.DEFAULT)
152
152
  print()
153
153
  printf("Commands:", (Sty.BOLD, Sty.MAGENTA))
154
- printf(" remoterf -l | --login [target]", Sty.CYAN, " Login: last used, 'global', a home name, or an account (username@deployment)", Sty.DEFAULT)
154
+ printf(" remoterf -l | --login [target]", Sty.CYAN, " Login: last used, 'global', or a deployment name", Sty.DEFAULT)
155
155
  printf(" remoterf -r | --register", Sty.CYAN, " Create a RemoteRF Global account", Sty.DEFAULT)
156
156
  printf(" remoterf -r --local-only", Sty.CYAN, " Register at a deployment with an enrollment code", Sty.DEFAULT)
157
157
  printf(" remoterf --reset-password", Sty.CYAN, " Reset a RemoteRF Global password by email", Sty.DEFAULT)
@@ -179,7 +179,7 @@ def print_help() -> None:
179
179
  printf(" remoterf --reset-password", Sty.GREEN)
180
180
  printf(" remoterf --login ucla", Sty.GREEN)
181
181
  printf(" remoterf --login global", Sty.GREEN)
182
- printf(" remoterf --login jdoe@ucla", Sty.GREEN)
182
+ printf(" remoterf --login ucla", Sty.GREEN)
183
183
  printf(" remoterf homes", Sty.GREEN)
184
184
  printf(" remoterf --config --addr 203.0.113.10:12321", Sty.GREEN)
185
185
  printf(" remoterf --config --wipe", Sty.GREEN)
@@ -493,49 +493,58 @@ def _login(target: str | None) -> int:
493
493
  if not _ensure_config_present()[0]:
494
494
  return _login_by_username()
495
495
  return _account_shell(register=False)
496
+ if target.lower() in homes.homes() or target.lower() == 'global':
497
+ target = target.lower()
496
498
  if target == 'global':
497
499
  # Global's address is built in, so a fresh install can log in to an
498
500
  # existing Global account without registering again.
499
501
  return _use_global(register=False)
500
- if target not in homes.homes():
502
+ if target in homes.homes():
503
+ return _use_home(target, register=False)
504
+ target = target.lower()
505
+ if not homes.NAME_RE.match(target):
501
506
  printf(f'No saved home named {target!r}.', Sty.WARNING)
502
507
  return _print_pick_a_target()
503
- return _use_home(target, register=False)
508
+ # Not saved here yet: look the lab up by name; the shell asks the username.
509
+ host = f'{target}.{homes.GLOBAL_DOMAIN}'
510
+ try:
511
+ with _working(f"Looking up {host}…"):
512
+ lab, home, route = homes.register_home(host)
513
+ except (RuntimeError, ValueError) as exc:
514
+ printf(f'Could not reach {host}: {_reason(exc)}', Sty.WARNING)
515
+ printf('For a RemoteRF Global account, use: remoterf -l global', Sty.GRAY)
516
+ return _print_pick_a_target()
517
+ return _account_shell(
518
+ register=False, server_label=f'{lab} ({_route_label(route)})',
519
+ home=lab, route={**route, 'home': home},
520
+ )
504
521
 
505
522
 
506
523
  def _login_by_username() -> int:
507
- """A fresh install: an account says where it lives (`alice@ucla`), so
508
- asking for it is enough. Enter registers, as `-l` here always did."""
524
+ """A fresh install: ask where to log in. Enter registers, as `-l` here
525
+ always did."""
509
526
  try:
510
- name = input('Account (username@deployment, Enter to register): ').strip()
527
+ target = input("Deployment (lab name, 'global', or Enter to register): ").strip()
511
528
  except (EOFError, KeyboardInterrupt):
512
529
  print()
513
530
  return 1
514
- if not name:
531
+ if not target:
515
532
  return _register()
516
- return _login_as(name)
533
+ if target == 'global':
534
+ return _use_global(register=False)
535
+ return _login(target)
517
536
 
518
537
 
519
538
  def _login_as(account: str) -> int:
520
- """Log in to `name@lab` at that lab; a bare name or an email is Global."""
539
+ """Log in to Global as `name@global` or an email. A lab is
540
+ reached with `remoterf --login <lab>`, which asks the username."""
521
541
  from remoterf.deployment import homes
522
542
 
523
543
  name, lab = homes.split_account(account)
524
544
  if lab is None or lab == homes.GLOBAL_ACCOUNTS:
525
545
  return _use_global(register=False, username=name)
526
- if lab in homes.homes():
527
- return _use_home(lab, register=False, username=name)
528
- host = f'{lab}.{homes.GLOBAL_DOMAIN}'
529
- try:
530
- with _working(f"Looking up {host}…"):
531
- lab, home, route = homes.register_home(host)
532
- except (RuntimeError, ValueError) as exc:
533
- printf(f'Could not reach {host}: {_reason(exc)}', Sty.WARNING)
534
- return 2
535
- return _account_shell(
536
- register=False, server_label=f'{lab} ({_route_label(route)})',
537
- home=lab, route={**route, 'home': home}, username=name,
538
- )
546
+ print(f'remoterf: to log in at {lab}, run: remoterf --login {lab}', file=sys.stderr)
547
+ return 2
539
548
 
540
549
 
541
550
  def _print_pick_a_target() -> int:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: remoterf
3
- Version: 2.13.4
3
+ Version: 2.13.6
4
4
  Summary: A python API to remotely access signal centric hardware. Client-side only! Courtesy of Wireless Lab @ UCLA & Prof. Ian Roberts.
5
5
  Author-email: Ethan Ge <84103791+ethange1@users.noreply.github.com>
6
6
  License-Expression: GPL-3.0-or-later
@@ -400,6 +400,31 @@ to require a reservation first.
400
400
 
401
401
  Each account may ask once every 10 seconds; a repeat call within that reprints the last table with the remaining wait.
402
402
 
403
+ #### Python reservation API
404
+
405
+ Scripts can find slots, reserve and cancel with the saved login. These top-level functions are the stable API
406
+ (`remoterf.ops` is internal). They print nothing, return plain dicts, and raise `remoterf.RemoteRFOpsError`
407
+ (with `.code` and `.message`) on failure:
408
+
409
+ ```python
410
+ import remoterf
411
+
412
+ remoterf.use("ucla") # default deployment for handles without @ (or set REMOTERF_DEPLOYMENT)
413
+
414
+ free = remoterf.slots("Pluto_00")["slots"] # today's free slots, aligned from local midnight
415
+ r = remoterf.reserve("Pluto_00", free[0]["start"], minutes=60) # or end=...; must be whole free slots
416
+ print(r["handle"], r["start"], r["end"])
417
+
418
+ for row in remoterf.reservations()["reservations"]:
419
+ print(row["reservation_id"], row["handle"], row["start"])
420
+
421
+ remoterf.cancel(r) # the dict from reserve()/reservations(), or an id such as "10@ucla"
422
+ ```
423
+
424
+ Also: `remoterf.whoami()`, `remoterf.list_devices()` (the non-printing `devices()`) and `remoterf.reserve_now(handle)`.
425
+ Without `use()` or `REMOTERF_DEPLOYMENT`, a bare name means the deployment you logged in to directly; an explicit
426
+ `Name@lab` always wins. Driver tokens (`Pluto(token=...)`) still need the full handle.
427
+
403
428
  ## Closing
404
429
 
405
430
  This is fundamentally a experimental platform, and there will be many unknown bugs and issues. Some devices do not have universal support for all its functions at the moment, I am working on that aspect.
@@ -8,6 +8,7 @@ src/remoterf/__init__.py
8
8
  src/remoterf/admin.py
9
9
  src/remoterf/agent_cli.py
10
10
  src/remoterf/agent_docs.py
11
+ src/remoterf/api.py
11
12
  src/remoterf/mcp_server.py
12
13
  src/remoterf/ops.py
13
14
  src/remoterf/remoterf_cli.py
@@ -83,6 +84,7 @@ src/remoterf/drivers/usrp/usrp_remote.py
83
84
  src/remoterf/drivers/usrp/usrp_remote.pyi
84
85
  tests/test_agent_cli.py
85
86
  tests/test_agent_docs.py
87
+ tests/test_api.py
86
88
  tests/test_banner.py
87
89
  tests/test_batch.py
88
90
  tests/test_bundled_drivers.py
@@ -13,7 +13,7 @@ _TX = re.compile(r"\btx\b|tx_|_tx|transmit|send_waveform|dds")
13
13
 
14
14
  def test_guide_topics_and_sections():
15
15
  whole = guide()
16
- assert whole["topic"] is None and whole["topics"] == ["workflow", "tokens", "cli", "mcp", "safety", "errors"]
16
+ assert whole["topic"] is None and whole["topics"] == ["workflow", "tokens", "cli", "python", "mcp", "safety", "errors"]
17
17
  for topic in whole["topics"]:
18
18
  part = guide(topic.upper())
19
19
  assert part["topic"] == topic and part["text"].startswith(f"## {topic}\n") and part["text"] in whole["text"]