[Tutor] URL test function.
bgailer at gmail.com
Fri Oct 22 18:53:45 CEST 2010
On 10/22/2010 10:54 AM, Jeff Honey wrote:
> I am trying to create a function to plug into a restart script I'm creating. I can't seem to successfully loop through making an http connection, if it fails to retry, if it succeeds, to end and continue with its parent function.
> I'm using the Fabric project's module and including my functions in fabfile.py.
> the most rudimentary I've got right now is this:
> def is_ready():
> with settings(
> except urllib2.URLError:
> I am trying to get the 'host_string' environment variable to plug in here but not sure if the parent function will pass along that information nor if I can call it like this.
I don't understand this part. Please clarify or show us the parent function.
> Additionally, I have never used try/except so I don't know if this will just try twice and quit. As it is now, it raises URLError and bombs out.
Whenever you want to repeat something you need either a loop or
recursion. A loop is appropriate here.
Chapel Hill NC
More information about the Tutor