handling errors of os.error module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux