4. Using Debugpanel as a Library
You can use Debugpanel as a Python library. See the Debugpanel API Reference for details.
The lockss.debugpanel.Node class can create a node object from a node reference (a string like host:8081, http://host:8081, http://host:8081/, https://host:8081, https://host:8081/; no protocol defaults to http://), a username, and a password.
Note
The lockss.debugpanel.node() function is deprecated and will be removed in a future release.
This node object can be used as the argument to lockss.debugpanel.crawl_plugins() or lockss.debugpanel.reload_config().
It can also be used as the first argument to lockss.debugpanel.check_substance(), lockss.debugpanel.crawl(), lockss.debugpanel.deep_crawl(), lockss.debugpanel.disable_indexing(), lockss.debugpanel.poll(), lockss.debugpanel.reindex_metadata(), or lockss.debugpanel.validate_files(), together with an AUID string as the second argument.
The lockss.debugpanel.deep_crawl() function has an optional third argument, depth, for the crawl depth (which defaults to lockss.debugpanel.DEFAULT_DEPTH).
All operations return the modified http.client.HTTPResponse object from urllib.request.urlopen() (see https://docs.python.org/3.9/library/urllib.request.html#urllib.request.urlopen). A status code of 200 indicates that the request to the node was made successfully (but not much else; for example if there is no such AUID for an AUID operation, nothing happens).
Use of the module is illustrated in this example:
from getpass import getpass
from lockss.debugpanel import Node, poll
hostport: str = '...'
username: str = input('Username: ')
password: str = getpass('Password: ')
node: Node = Node(hostport, username, password)
auid: str = '...'
try:
resp = poll(node, auid)
if resp.status == 200:
print('Poll requested (200)')
else:
print(f'{resp.reason} ({resp.status})')
except Exception as exc:
print(f'Error: {exc!s}')