sync: auto-sync from HOWARD-HOME at 2026-07-06 16:41:20
Author: Howard Enos Machine: HOWARD-HOME Timestamp: 2026-07-06 16:41:20
This commit is contained in:
@@ -101,18 +101,37 @@ def _gated(action_desc: str, confirm: bool) -> bool:
|
||||
|
||||
# --- handlers ---
|
||||
def cmd_status(client, args):
|
||||
# Auth check via the fleet filter; report instance + custom-property map + counts.
|
||||
access = client.list_sessions(session_type="access")
|
||||
support = client.list_sessions(session_type="support")
|
||||
na = len(access) if isinstance(access, list) else 0
|
||||
ns = len(support) if isinstance(support, list) else 0
|
||||
# Auth check via the most basic verified method (GetSessionsByName), so status
|
||||
# confirms credentials even on an extension version without GetSessionsByFilter.
|
||||
client.get_sessions_by_name("")
|
||||
print(f"[OK] Authenticated to {SC_BASE_URL}")
|
||||
print(f" extension: {client.extension_guid}")
|
||||
print(f" custom properties: {CUSTOM_PROPERTIES}")
|
||||
print(f" fleet: {na} Access (unattended) + {ns} Support session(s)")
|
||||
# Fleet counts are a best-effort add-on: the filter method may be absent, and it
|
||||
# must never fail the auth check that status exists to perform.
|
||||
try:
|
||||
access = client.list_sessions(session_type="access")
|
||||
support = client.list_sessions(session_type="support")
|
||||
na = len(access) if isinstance(access, list) else 0
|
||||
ns = len(support) if isinstance(support, list) else 0
|
||||
print(f" fleet: {na} Access (unattended) + {ns} Support session(s)")
|
||||
except ScreenConnectError as exc:
|
||||
print(f" fleet: (listing unavailable via GetSessionsByFilter: {exc})")
|
||||
return 0
|
||||
|
||||
|
||||
def _effective_type(args) -> str:
|
||||
"""Resolve the SessionType filter for `sessions`. Explicit --type wins. Otherwise
|
||||
a bare listing defaults to the Access fleet, but a TARGETED search (by name/like/
|
||||
company/site/tag) spans all types - matching the old GetSessionsByName behavior,
|
||||
where a by-name lookup found Support sessions too."""
|
||||
if args.type is not None:
|
||||
return args.type
|
||||
if any([args.name, args.like, args.company, args.site, args.tag]):
|
||||
return "all"
|
||||
return "access"
|
||||
|
||||
|
||||
def cmd_sessions(client, args):
|
||||
# Full-fleet listing is the default (no selector -> every Access session).
|
||||
# A raw --filter wins; otherwise build a filter from the structured flags.
|
||||
@@ -120,20 +139,17 @@ def cmd_sessions(client, args):
|
||||
data = client.get_sessions_by_filter(args.filter)
|
||||
else:
|
||||
data = client.list_sessions(
|
||||
session_type=args.type,
|
||||
session_type=_effective_type(args),
|
||||
name=args.name or None,
|
||||
name_like=args.like,
|
||||
company=args.company,
|
||||
site=args.site,
|
||||
tag=args.tag,
|
||||
)
|
||||
if isinstance(data, list) and args.limit and len(data) > args.limit:
|
||||
shown = data[: args.limit]
|
||||
if args.json:
|
||||
_emit(shown, True)
|
||||
else:
|
||||
_print_sessions(shown)
|
||||
print(f" ... {len(data) - args.limit} more (raise --limit or use --json)")
|
||||
# --limit only caps the human-readable print; --json is always the full set.
|
||||
if not args.json and isinstance(data, list) and args.limit and len(data) > args.limit:
|
||||
_print_sessions(data[: args.limit])
|
||||
print(f" ... {len(data) - args.limit} more (raise --limit or use --json)")
|
||||
return 0
|
||||
_emit(data, True) if args.json else _print_sessions(data)
|
||||
return 0
|
||||
@@ -225,8 +241,9 @@ def build_parser() -> argparse.ArgumentParser:
|
||||
sp.add_argument("--company", help="Filter by CP1 = Company.")
|
||||
sp.add_argument("--site", help="Filter by CP2 = Site.")
|
||||
sp.add_argument("--tag", help="Filter by CP3 = Tag.")
|
||||
sp.add_argument("--type", default="access",
|
||||
help="access (default) | support | meeting | all.")
|
||||
sp.add_argument("--type", default=None,
|
||||
help="access | support | meeting | all. Default: access for a "
|
||||
"bare listing, all when a name/company/etc selector is given.")
|
||||
sp.add_argument("--filter", help="Raw session-filter expression (overrides the flags).")
|
||||
sp.add_argument("--limit", type=int, default=0,
|
||||
help="Cap rows printed (0 = no cap; --json is always full).")
|
||||
|
||||
Reference in New Issue
Block a user