Browse Source

fixed, last review remarks

pull/636/head
archetipo 9 years ago
committed by Dave Lasley
parent
commit
593420191a
  1. 3
      auto_backup/README.rst
  2. 2
      auto_backup/__init__.py
  3. 5
      auto_backup/__openerp__.py
  4. 22
      auto_backup/model/backup_scheduler.py

3
auto_backup/README.rst

@ -1,8 +1,9 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg .. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License: AGPL-3 :alt: License: AGPL-3
=================
Automated backups Automated backups
===========
=================
A tool for all your back-ups, internal and external! A tool for all your back-ups, internal and external!

2
auto_backup/__init__.py

@ -22,4 +22,4 @@
from . import model from . import model
from . import tests from . import tests
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

5
auto_backup/__openerp__.py

@ -22,7 +22,7 @@
{ {
"name": "Database Auto-Backup", "name": "Database Auto-Backup",
"version": "1.0",
"version": "8.0.1.0.0",
"author": ( "author": (
"VanRoey.be - Yenthe Van Ginneken, Agile Business Group," "VanRoey.be - Yenthe Van Ginneken, Agile Business Group,"
" Odoo Community Association (OCA)" " Odoo Community Association (OCA)"
@ -30,7 +30,7 @@
"website": "http://www.vanroey.be/applications/bedrijfsbeheer/odoo", "website": "http://www.vanroey.be/applications/bedrijfsbeheer/odoo",
"category": "Tools", "category": "Tools",
"summary": "Backups data base", "summary": "Backups data base",
"depends": ['base', 'email_template'],
"depends": ['email_template'],
"demo": [], "demo": [],
"data": [ "data": [
"view/bkp_conf_view.xml", "view/bkp_conf_view.xml",
@ -40,4 +40,3 @@
"active": False, "active": False,
"installable": True "installable": True
} }
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

22
auto_backup/model/backup_scheduler.py

@ -25,16 +25,15 @@ import time
import datetime import datetime
import base64 import base64
import re import re
try:
import pysftp
except ImportError:
pass
from openerp import models, fields, api, _ from openerp import models, fields, api, _
from openerp.exceptions import except_orm, Warning
from openerp.exceptions import except_orm, Warning as UserError
from openerp import tools from openerp import tools
import logging import logging
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
try:
import pysftp
except ImportError:
_logger.debug('Can not import pysftp')
def execute(connector, method, *args): def execute(connector, method, *args):
@ -238,7 +237,7 @@ class db_backup(models.Model):
messageContent + "%s") % messageContent + "%s") %
tools.ustr(e)) tools.ustr(e))
else: else:
raise Warning(_(messageTitle), _(messageContent))
raise UserError(_(messageTitle), _(messageContent))
@api.model @api.model
def schedule_backup(self): def schedule_backup(self):
@ -261,13 +260,12 @@ class db_backup(models.Model):
bkp = '' bkp = ''
bkp = execute( bkp = execute(
conn, 'dump', rec.adminpassword, rec.name) conn, 'dump', rec.adminpassword, rec.name)
except:
except Exception, e:
_logger.info( _logger.info(
_( _(
"Couldn't backup database %s. "
"Bad database administrator"
"password for server running at http://%s:%s"
) % (rec.name, rec.host, rec.port))
"Autobackup Couldn't backup database %s. :" +
str(e))
)
return False return False
bkp = base64.decodestring(bkp) bkp = base64.decodestring(bkp)
fp = open(file_path, 'wb') fp = open(file_path, 'wb')

Loading…
Cancel
Save