Catching timed out connections (Commando)

21 views
Skip to first unread message

Lamisk

unread,
Dec 7, 2014, 2:36:32 AM12/7/14
to trigge...@googlegroups.com
Hi

I am new to trigger and haven't used python for a long while.... Enjoying it so far though :)

Just hopefully quick question - how am I meant to get feed back on which devices are un-connectable?

I am just getting a return at the top, before the results list:
Unhandled Error
Traceback (most recent call last):
Failure: twisted.internet.error.TimeoutError: User timeout caused connection failure.

Basic code I am trialing:
from trigger.cmds import Commando
from trigger.netdevices import NetDevices
import simplejson as json

class RunCommands(Commando):
    """Execute 'show clock' on a list of Cisco devices."""
#   vendors = ['cisco']
    commands = ['write']

if __name__ == '__main__':

    nd = NetDevices()
    device_list = nd.search('xxx')

    print device_list

    setupcommands = RunCommands(timeout=2,devices=device_list)
    setupcommands.run() # Commando exposes this to start the event loop

    print setupcommands.store_error(nd,TimeoutError)

    print '\nResults:'
    print json.dumps(setupcommands.results, indent=4)


Any help would be great - I am getting stuck here and I think I need to continue reading up about exceptions.

Jathan McCollum

unread,
Dec 8, 2014, 12:55:15 PM12/8/14
to trigge...@googlegroups.com
Hello! I'm happy you're using Trigger!

What do you mean when you say you want to "get feed back on which devices are un-connectable"? Do you want to see the errors at the end? If so, once the event loop returns, you have 2 attributes):

- .results = A dict of results from the commands that succeed, keyed by device name
- .errors = A dict of the errors, keyed by device name

Maybe that's what you were looking for?

--
You received this message because you are subscribed to the Google Groups "Trigger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trigger-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Jathan.
--
Reply all
Reply to author
Forward
0 new messages