[Tutor] basic python question/getting values
Joe M
moray at sdf.lonestar.org
Tue Jan 2 20:16:33 CET 2007
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
More information about the Tutor
mailing list