[Tutor] basic python question/getting values
Joe M
moray at sdf.lonestar.org
Tue Jan 2 20:53:01 CET 2007
Thanks. I appreciate the quick response. I am going to kick myself for
this one ;)
On Tue, 2 Jan 2007, Asrarahmed Kadri wrote:
> Date: Tue, 2 Jan 2007 19:38:04 +0000
> From: Asrarahmed Kadri <ajkadri at googlemail.com>
> To: Joe M <moray at sdf.lonestar.org>
> Subject: Re: [Tutor] basic python question/getting values
>
> Hey, the call should be:
> dbping.db_alive()
> and not dbping.db_run()
>
> HTH,
> Regards,
> Asrarahmed
>
>
> On 1/2/07, Joe M <moray at sdf.lonestar.org> wrote:
>>
>> I apologize in advanced as I know this is basic information, but I cannot
>> seem to figure it.
>>
>> I have a few scripts that will return a value ie here I am testing to see
>> if a database is alive (script is called dbping.py):
>>
>> def db_alive():
>> dbRunning = '0'
>> try:
>> con = pg.connect(dbname='xxx', host='localhost', user
>> ='xxx',port = xxx)
>> pass
>> except pg.InternalError:
>> dbRunning = '1'
>> return dbRunning
>>
>> This should return a value of 1 if the db is not running else it will
>> return a value of 0.
>>
>> Ok, now I want to call this from another script and have it write
>> to a file with the return value (and other values to be added later, but
>> right now all I am interested in in getting the return values)
>>
>> I tried this sort of thing but it doesn't work (I will be writing to a
>> file later, but right now getting it to print the value of dbRunning would
>> be nice)
>>
>> import dbping
>> l = dbping.db_run(db_run.dbRunning)
>> print l
>>
>> NameError: name 'db_run' is not defined
>>
>> Thanks for any pointers
>>
>> moray at sdf.lonestar.org
>> SDF Public Access UNIX System - http://sdf.lonestar.org
>> _______________________________________________
>> Tutor maillist - Tutor at python.org
>> http://mail.python.org/mailman/listinfo/tutor
>>
>
>
>
> --
> To HIM you shall return.
>
moray at sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org
More information about the Tutor
mailing list