Reference

ONCatLogin

class pyoncatqt.login.ONCatLogin(*args: Any, **kwargs: Any)[source]

ONCatLogin widget for connecting to the ONCat service.

This widget provides a status label and a button that starts an interactive, browser-based sign-in using PyONCat’s Device Authorization Grant. When a sign-in is started, a VerificationDialog shows a link the user opens to approve the sign-in with ORNL credentials.

Params

client_idstr, optional

The client_id is an ONCat client ID. Defaults to None. client_id is required or key is required

keystr, optional

The key used to retrieve ONCat client ID from configuration. Defaults to None.

parentQWidget, optional

The parent widget.

timeoutfloat, optional

Request timeout, in seconds, for the ONCat agent. Defaults to 10.0.

kwargsDict[str, Any], optional

Additional keyword arguments. login_title overrides the sign-in dialog window title.

connection_updated

Signal emitted when the connection status is updated.

Type:

Signal

update_connection_status() → None:[source]

Update the connection status.

is_connected() → bool:

Check if connected to OnCat.

get_agent_instance() → pyoncat.ONCat:[source]

Get the OnCat agent instance.

connect_to_oncat() → None:[source]

Start an interactive sign-in to OnCat.

read_token() → dict:[source]

Read token from file.

write_token(token: dict) → None:[source]

Write token to file.

closeEvent(event: qtpy.QtGui.QCloseEvent) → None[source]

Stop any in-flight background job before the widget is torn down.

The worker thread is unparented and its succeeded/failed signals are wired to bound methods on this widget. If the widget were destroyed mid-job, a late-finishing worker could call back into a half-destroyed C++ object. Cancel the poll loop where possible, detach the outcome callbacks so nothing outlives the widget, then stop and wait for the thread.

connect_to_oncat() → None[source]

Start an interactive, browser-based sign-in to OnCat.

Sign-in runs on a worker thread while PyONCat polls the IdP; a VerificationDialog surfaces the approval link. The connection status is refreshed once sign-in resolves.

connection_updated

alias of bool

disconnect_from_oncat() → None[source]

Log out of OnCat, revoking the current session.

logout() revokes the refresh token server-side rather than only clearing it locally, so it does network I/O and must run on a worker thread. The connection status is refreshed once it resolves.

get_agent_instance() → ONCat[source]

Get OnCat agent instance.

Returns:

The OnCat agent instance.

Return type:

pyoncat.ONCat

property is_connected: bool

Check if connected to OnCat.

Returns:

True if connected, False otherwise.

Return type:

bool

read_token() → dict[source]

Read token from file.

Returns:

The token dictionary.

Return type:

dict

update_connection_status() → None[source]

Render the cached connection status.

Reads the cached connection state instead of probing ONCat, so it never does network I/O on the GUI thread. The cache is refreshed by _refresh_connection_status() and by the login/logout callbacks.

write_token(token: dict) → None[source]

Write token to file.

Params

tokendict

The token dictionary.

VerificationDialog

class pyoncatqt.login.VerificationDialog(*args: Any, **kwargs: Any)[source]

Sign-in dialog showing a clickable link, the user code, and Cancel.

The user approves the sign-in in a browser using ORNL credentials; this dialog only surfaces the verification link and one-time code produced by the Device Authorization Grant.

Params

linkstr

The verification URL to open in a browser.

user_codestr

The one-time code to enter at the verification URL, if prompted.

parentQWidget, optional

The parent widget.

cancelled

Emitted when the user dismisses the dialog before sign-in resolves.

Type:

Signal

closeEvent(event: qtpy.QtGui.QCloseEvent) → None[source]

Route the window frame to the cancel signal.

Dismissing the dialog via the window frame sets the cancel event rather than leaving the worker polling.

reject() → None[source]

Route the Cancel button and the Escape key to the cancel signal.

Qt sends both the Cancel button (wired here) and the Escape key through reject(), which dismisses the dialog via done() without firing closeEvent(). The cancel signal is emitted here so those paths do not silently leave the worker polling; the guard keeps it from re-emitting after a resolved sign-in or a later close.

resolve() → None[source]

Mark the sign-in resolved so a programmatic close is not a cancel.

The owner calls this before closing the dialog once sign-in succeeds, so the close does not read as a user cancellation.