Python os.system module handle errors
От | Vadim Pestovnikov |
---|---|
Тема | Python os.system module handle errors |
Дата | |
Msg-id | 1B6B036445BFC94490C87AF12F102AD3144DC4@tofn-svr-exc-01.yak.ca обсуждение исходный текст |
Ответы |
Re: Python os.system module handle errors
|
Список | 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 existor 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
В списке pgsql-admin по дате отправления: