def tunnel_change_callback(new_tunnel): global tunnel_id global options drop_readyfile = None if options.readyfile: def d(): open(options.readyfile, 'wb').write("ready") connected_callback = None if options.daemonize: def daemonize(): daemon.daemonize(options.pidfile) if drop_readyfile: drop_readyfile() connected_callback = daemonize elif drop_readyfile: connected_callback = drop_readyfile tunnel_id = new_tunnel['id'] sshtunnel.connect_tunnel(tunnel_id, sauce.base_url, username, access_key, local_host, new_tunnel['Host'], ports, connected_callback, tunnel_change_callback, shutdown_callback(tunnel_id), options.diagnostic)
def tunnel_change_callback(new_tunnel, connected_callback=None): global tunnel_id tunnel_id = new_tunnel['id'] sshtunnel.connect_tunnel( tunnel_id, sauce_client.base_url, username, access_key, local_host, new_tunnel['Host'], ports, connected_callback, lambda t=tunnel_id: disconnected_callback(t), lambda t=tunnel_id: sauce_client.delete_tunnel(t), options.diagnostic)
tunnel_id = new_tunnel['id'] sshtunnel.connect_tunnel(tunnel_id, sauce.base_url, username, access_key, local_host, new_tunnel['Host'], ports, connected_callback, tunnel_change_callback, shutdown_callback(tunnel_id), options.diagnostic) sshtunnel.connect_tunnel(tunnel_id, sauce.base_url, username, access_key, local_host, tunnel['Host'], ports, connected_callback, tunnel_change_callback, shutdown_callback(tunnel_id), options.diagnostic) start_monitor() finally: print "Aborted -- shutting down tunnel machine" sauce.delete_tunnel(tunnel_id)