python - Catching exceptions on fabric -


i trying create script using fabric api (not fab files) , can't exceptions work. idea is, once host has failed, perhaps run rollback() function , write log file failed host. thing system exits. code:

class fabricexception(exception):     pass  class main(object):    def __init__(self):     env.password = 'password'     env.user = 'whatever'     command = 'sudo ls -la'     failed = []     env.warn_only = true     env.abort_exeption = fabricexception      def runcommand(command):         try:             result = run(command)         except fabricexeption:             print env.host + "failed"             failed.append = env.host      execute(runcommand, command=command, hosts=hosts)     disconnect_all()  if __name__ =="__main__":     main = main() 

if you're doing logging failure, why not use context manager, , have block of code warn. using either/both of these settings: env.warn_only , env.skip_bad_hosts.

refs:


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -