From 75b7d1b496f176c454989b3a0084609d5e6bccbc Mon Sep 17 00:00:00 2001 From: archetipo Date: Mon, 2 Nov 2015 10:48:05 +0100 Subject: [PATCH] [FIX] fixed, last review remarks --- auto_backup/README.rst | 3 ++- auto_backup/__init__.py | 2 +- auto_backup/__openerp__.py | 5 ++--- auto_backup/data/backup_data.xml | 2 +- auto_backup/model/backup_scheduler.py | 22 ++++++++++------------ auto_backup/security/ir.model.access.csv | 2 +- auto_backup/view/bkp_conf_view.xml | 2 +- 7 files changed, 18 insertions(+), 20 deletions(-) diff --git a/auto_backup/README.rst b/auto_backup/README.rst index 00aaaa37c..769f80059 100644 --- a/auto_backup/README.rst +++ b/auto_backup/README.rst @@ -1,8 +1,9 @@ .. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg :alt: License: AGPL-3 +================= Automated backups -=========== +================= A tool for all your back-ups, internal and external! diff --git a/auto_backup/__init__.py b/auto_backup/__init__.py index 084d03697..511803e75 100644 --- a/auto_backup/__init__.py +++ b/auto_backup/__init__.py @@ -22,4 +22,4 @@ from . import model from . import tests -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/auto_backup/__openerp__.py b/auto_backup/__openerp__.py index f1b3a2842..e16162ff9 100644 --- a/auto_backup/__openerp__.py +++ b/auto_backup/__openerp__.py @@ -22,7 +22,7 @@ { "name": "Database Auto-Backup", - "version": "1.0", + "version": "8.0.1.0.0", "author": ( "VanRoey.be - Yenthe Van Ginneken, Agile Business Group," " Odoo Community Association (OCA)" @@ -30,7 +30,7 @@ "website": "http://www.vanroey.be/applications/bedrijfsbeheer/odoo", "category": "Tools", "summary": "Backups data base", - "depends": ['base', 'email_template'], + "depends": ['email_template'], "demo": [], "data": [ "view/bkp_conf_view.xml", @@ -40,4 +40,3 @@ "active": False, "installable": True } -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/auto_backup/data/backup_data.xml b/auto_backup/data/backup_data.xml index 4714778a5..8911a3bd6 100644 --- a/auto_backup/data/backup_data.xml +++ b/auto_backup/data/backup_data.xml @@ -15,4 +15,4 @@ - \ No newline at end of file + diff --git a/auto_backup/model/backup_scheduler.py b/auto_backup/model/backup_scheduler.py index 65e234a2b..6476131ca 100644 --- a/auto_backup/model/backup_scheduler.py +++ b/auto_backup/model/backup_scheduler.py @@ -25,16 +25,15 @@ import time import datetime import base64 import re -try: - import pysftp -except ImportError: - pass - 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 import logging _logger = logging.getLogger(__name__) +try: + import pysftp +except ImportError: + _logger.debug('Can not import pysftp') def execute(connector, method, *args): @@ -238,7 +237,7 @@ class db_backup(models.Model): messageContent + "%s") % tools.ustr(e)) else: - raise Warning(_(messageTitle), _(messageContent)) + raise UserError(_(messageTitle), _(messageContent)) @api.model def schedule_backup(self): @@ -261,13 +260,12 @@ class db_backup(models.Model): bkp = '' bkp = execute( conn, 'dump', rec.adminpassword, rec.name) - except: + except Exception, e: _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 bkp = base64.decodestring(bkp) fp = open(file_path, 'wb') diff --git a/auto_backup/security/ir.model.access.csv b/auto_backup/security/ir.model.access.csv index f5de02b31..e38dbf11b 100644 --- a/auto_backup/security/ir.model.access.csv +++ b/auto_backup/security/ir.model.access.csv @@ -1,2 +1,2 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_db_backup,access_db_backup,model_db_backup,,1,0,0,0 \ No newline at end of file +access_db_backup,access_db_backup,model_db_backup,,1,0,0,0 diff --git a/auto_backup/view/bkp_conf_view.xml b/auto_backup/view/bkp_conf_view.xml index 061bff016..7527dfd80 100644 --- a/auto_backup/view/bkp_conf_view.xml +++ b/auto_backup/view/bkp_conf_view.xml @@ -105,4 +105,4 @@ - \ No newline at end of file +