Merge pull request #5009 from achillesrasquinha/restore-progress

Show Progress of Database Restore
This commit is contained in:
Achilles Rasquinha 2018-02-20 11:33:11 +05:30 committed by GitHub
commit ec3aedf358
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -551,8 +551,31 @@ class DbManager:
def restore_database(self,target,source,user,password):
from frappe.utils import make_esc
esc = make_esc('$ ')
os.system("mysql -u %s -p%s -h%s %s < %s" % \
(esc(user), esc(password), esc(frappe.db.host), esc(target), source))
from distutils.spawn import find_executable
pipe = find_executable('pv')
if pipe:
pipe = '{pipe} {source} |'.format(
pipe = pipe,
source = source
)
source = ''
else:
pipe = ''
source = '< {source}'.format(source = source)
if pipe:
print('Creating Database...')
command = '{pipe} mysql -u {user} -p{password} -h{host} {target} {source}'.format(
pipe = pipe,
user = esc(user),
password = esc(password),
host = esc(frappe.db.host),
target = esc(target),
source = source
)
os.system(command)
def drop_table(self,table_name):
"""drop table if exists"""