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