pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Python os.system module handle errors
2+ messages / 2 participants
[nested] [flat]

* Python os.system module handle errors
@ 2006-05-04 20:50 Vadim Pestovnikov <vpestovnikov@yak.ca>
  2006-05-11 09:05 ` Re: Python os.system module handle errors Volkan YAZICI <yazicivo@ttnet.net.tr>
  0 siblings, 1 reply; 2+ messages in thread

From: Vadim Pestovnikov @ 2006-05-04 20:50 UTC (permalink / raw)
  To: pgsql-admin

Hi all,

When I create a database dump in python script and if there are some errors (user_name is not correct, db_name doesn't exist or something else) I need to send e-mail notification to admin. How can I handle these errors?

Example:
----------------------------------------------------------------------------#!/usr/bin/python
import os

os.system("pg_dump -U user_name -i -F c -v db_name -f file_name.backup") 
print "%s backup complete" % ("Database XXX")
----------------------------------------------------------------------------

I tried to use, 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 complete" % ("Database XXX")
except os.error:

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

    print "Backup error %s" % error


--
Vadim



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Python os.system module handle errors
  2006-05-04 20:50 Python os.system module handle errors Vadim Pestovnikov <vpestovnikov@yak.ca>
@ 2006-05-11 09:05 ` Volkan YAZICI <yazicivo@ttnet.net.tr>
  0 siblings, 0 replies; 2+ messages in thread

From: Volkan YAZICI @ 2006-05-11 09:05 UTC (permalink / raw)
  To: Vadim Pestovnikov <vpestovnikov@yak.ca>; +Cc: pgsql-admin

On May 04 04:50, Vadim Pestovnikov wrote:
> When I create a database dump in python script and if there are some
> errors (user_name is not correct, db_name doesn't exist or something
> else) I need to send e-mail notification to admin. How can I handle
> these errors?

I don't think this has anything to do with PostgreSQL. IMHO you should
start with reading documentation of Python os module (especially
OSError exceptions part) and consult to a python related mailing list.


Regards.



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2006-05-11 09:05 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-05-04 20:50 Python os.system module handle errors Vadim Pestovnikov <vpestovnikov@yak.ca>
2006-05-11 09:05 ` Volkan YAZICI <yazicivo@ttnet.net.tr>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox