Merge pull request #1202 from anandpdoshi/hotfix-backup-manager
[fix] backup manager
This commit is contained in:
commit
56f58cfa68
@ -16,8 +16,6 @@ import webnotes
|
|||||||
from webnotes.utils import get_request_site_address, cstr
|
from webnotes.utils import get_request_site_address, cstr
|
||||||
from webnotes import _
|
from webnotes import _
|
||||||
|
|
||||||
from backup_manager import ignore_list
|
|
||||||
|
|
||||||
@webnotes.whitelist()
|
@webnotes.whitelist()
|
||||||
def get_dropbox_authorize_url():
|
def get_dropbox_authorize_url():
|
||||||
sess = get_dropbox_session()
|
sess = get_dropbox_session()
|
||||||
@ -100,9 +98,7 @@ def backup_to_dropbox():
|
|||||||
path = get_files_path()
|
path = get_files_path()
|
||||||
for filename in os.listdir(path):
|
for filename in os.listdir(path):
|
||||||
filename = cstr(filename)
|
filename = cstr(filename)
|
||||||
if filename in ignore_list:
|
|
||||||
continue
|
|
||||||
|
|
||||||
found = False
|
found = False
|
||||||
filepath = os.path.join(path, filename)
|
filepath = os.path.join(path, filename)
|
||||||
for file_metadata in response["contents"]:
|
for file_metadata in response["contents"]:
|
||||||
|
|||||||
@ -87,7 +87,7 @@ $.extend(cur_frm.cscript, {
|
|||||||
cur_frm.save();
|
cur_frm.save();
|
||||||
},
|
},
|
||||||
|
|
||||||
upload_backups_to_gdrive: function() {
|
// upload_backups_to_gdrive: function() {
|
||||||
cur_frm.save();
|
// cur_frm.save();
|
||||||
},
|
// },
|
||||||
});
|
});
|
||||||
@ -7,8 +7,6 @@ from __future__ import unicode_literals
|
|||||||
import webnotes
|
import webnotes
|
||||||
from webnotes import _
|
from webnotes import _
|
||||||
|
|
||||||
ignore_list = []
|
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self, d, dl):
|
def __init__(self, d, dl):
|
||||||
self.doc, self.doclist = d, dl
|
self.doc, self.doclist = d, dl
|
||||||
@ -39,10 +37,6 @@ def take_backups_dropbox():
|
|||||||
file_and_error = [" - ".join(f) for f in zip(did_not_upload, error_log)]
|
file_and_error = [" - ".join(f) for f in zip(did_not_upload, error_log)]
|
||||||
error_message = ("\n".join(file_and_error) + "\n" + webnotes.getTraceback())
|
error_message = ("\n".join(file_and_error) + "\n" + webnotes.getTraceback())
|
||||||
webnotes.errprint(error_message)
|
webnotes.errprint(error_message)
|
||||||
|
|
||||||
if not webnotes.conn:
|
|
||||||
webnotes.connect()
|
|
||||||
|
|
||||||
send_email(False, "Dropbox", error_message)
|
send_email(False, "Dropbox", error_message)
|
||||||
|
|
||||||
#backup to gdrive
|
#backup to gdrive
|
||||||
@ -62,6 +56,7 @@ def take_backups_gdrive():
|
|||||||
send_email(False, "Google Drive", error_message)
|
send_email(False, "Google Drive", error_message)
|
||||||
|
|
||||||
def send_email(success, service_name, error_status=None):
|
def send_email(success, service_name, error_status=None):
|
||||||
|
from webnotes.utils.email_lib import sendmail
|
||||||
if success:
|
if success:
|
||||||
subject = "Backup Upload Successful"
|
subject = "Backup Upload Successful"
|
||||||
message ="""<h3>Backup Uploaded Successfully</h3><p>Hi there, this is just to inform you
|
message ="""<h3>Backup Uploaded Successfully</h3><p>Hi there, this is just to inform you
|
||||||
@ -76,7 +71,8 @@ def send_email(success, service_name, error_status=None):
|
|||||||
<p>Please contact your system manager for more information.</p>
|
<p>Please contact your system manager for more information.</p>
|
||||||
""" % (service_name, error_status)
|
""" % (service_name, error_status)
|
||||||
|
|
||||||
# email system managers
|
if not webnotes.conn:
|
||||||
from webnotes.utils.email_lib import sendmail
|
webnotes.connect()
|
||||||
sendmail(webnotes.conn.get_value("Backup Manager", None, "send_notifications_to").split(","),
|
|
||||||
subject=subject, msg=message)
|
recipients = webnotes.conn.get_value("Backup Manager", None, "send_notifications_to").split(",")
|
||||||
|
sendmail(recipients, subject=subject, msg=message)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user