handling errors of os.error module

From: "Vadim Pestovnikov" <vadim(dot)pestovnikov(at)gmail(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: handling errors of os.error module
Date: 2006-05-05 21:02:52
Message-ID: d1556ada0605051402m970a0aaj686b9d4af010eb48@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi all,

When I create a database dump in python script and if there are some
errors depending on database like user_name is not correct, db_name
doesn't exist or something else I need to handle this error and send
an e-mail notification to my admin. How can I do it?

I tried to use like this, but it doesn't work.

#!/usr/bin/python
import os

try:
os.system("pg_dump -U user_name -i -F c -v db_name -f file_name.backup")
print "%s backup has been completed" % ("Database XXX")

except os.error, error:

# ...
# here sending e-mail if there is an error of backing up
# ...

print "Backup error %s" % error

--
Sincerely,
Vadim Pestovnikov

Browse pgsql-admin by date

  From Date Subject
Next Message kynn 2006-05-06 01:44:08 Permission denied: LOCK TABLE test.__proc IN ACCESS SHARE MODE
Previous Message MIlos Prudek 2006-05-05 17:49:33 Re: missing chunk number 0 for toast value ...