Browse Source

[FIX] fixed, last review remarks

pull/203/head
archetipo 9 years ago
parent
commit
75b7d1b496
  1. 3
      auto_backup/README.rst
  2. 2
      auto_backup/__init__.py
  3. 5
      auto_backup/__openerp__.py
  4. 2
      auto_backup/data/backup_data.xml
  5. 22
      auto_backup/model/backup_scheduler.py
  6. 2
      auto_backup/security/ir.model.access.csv
  7. 2
      auto_backup/view/bkp_conf_view.xml

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:

2
auto_backup/data/backup_data.xml

@ -15,4 +15,4 @@
<field eval="&quot;&quot;&quot;db.backup&quot;&quot;&quot;" name="model"/> <field eval="&quot;&quot;&quot;db.backup&quot;&quot;&quot;" name="model"/>
</record> </record>
</data> </data>
</openerp>
</openerp>

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')

2
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 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
access_db_backup,access_db_backup,model_db_backup,,1,0,0,0

2
auto_backup/view/bkp_conf_view.xml

@ -105,4 +105,4 @@
<menuitem parent="base.menu_config" action="action_backup_conf_form" id="backup_conf_menu"/> <menuitem parent="base.menu_config" action="action_backup_conf_form" id="backup_conf_menu"/>
</data> </data>
</openerp>
</openerp>
Loading…
Cancel
Save