Shell and scripting

While the Clacks core is all python and you can simply script complex tasks directly in python, there’s sometimes the need to trigger calls from within the ordinary shell - maybe inside a bash script. For that reason, there’s the clacksh binary, which can assist you in this case.

Using the shell

The Clacks shell can be called in different ways.

  • Interactive mode:

    $ clacksh
    Searching service provider...
    Connected to amqps://
    Username [cajus]:
    Clacks service shell. Use Ctrl+D to exit.

    The shell will automatically try to find the service by DNS or zeroconf and will ask for your credentials. Sometimes, you may need to connect a special system or even provide your credentials in the URI like

    $ clacksh amqps://

    but keep in mind that this will expose your credentials in the history, and maybe in the history or the process list.

    Nevertheless you’re presented a python prompt which can be used to get the list of commands using the proxy object:

        Create a new distribution based on type, mirror and installation
        Get supported time zones

    The proxy object acts as a proxy for the commands, so you can i.e. start asking for the registered Clacks clients

    >>> getClients()
    {u'2daf7cbf-75c2-4ea3-bfec-606fe9f07051': {
        u'received': 1313159425.0,
        u'name': u'dyn-10'},
     u'eb5e72d4-c53f-4612-81a3-602b14a8da69': {
         u'received': 1313467229.0,
         u'name': u'ws-2'},
     u'4f0dbdaa-05de-4632-bcba-b6fe8a9e2e09': {
         u'received': 1313463859.0,
         u'name': u'dyn-85'}}

    or just do simple multi-liners:

    >>> for client, info in getClients().items():
    ...   print info['name']

    You can leave the interactive mode by pressing “Ctrl+D”.

Using the API

Almost all parts of the API are accessible thru the command proxies or the event methods. Please take a look at

for more information.