Providers implement API of resources. Most of the API is documented via Resources, so this document will focus on things specific to providers.
As mentioned in Sessions, access to providers is made via session’s registry:
>>> import xal >>> session = xal.LocalSession() >>> session.sh <xal.sh.local.LocalShProvider object at 0x...>
We will use this
sh provider in the examples below...
Providers are resource factories¶
One provider implements API of one resource type. As an example,
ShCommand resource. Providers are callables, and when you call
them, you create a resource:
>>> session.sh('echo "Hello"') ShCommand(echo "Hello")
Providers have system-level methods¶
Providers have some methods that don’t take a resource as argument. They are
usually shortcuts. As an example,
ShProvider.run() is a shortcut that
ShCommand instance and runs it:
>>> session.sh.run('echo "Hello"') <xal.sh.resource.ShResult object at 0x...>
System-level methods are described along with Resources, so that there is a single documentation page for each resource API.
Providers implement resources’ API¶
Most of the methods of providers are implementation of resources’ API which require interaction with the environment. Such methods take a resource as first positional argument.
But in most situations (i.e. except you are developing a provider) you don’t need to bother about such methods: just create resource instances as explained above, then use the resource instance’s API, as described in Resources.