2
0
mirror of https://github.com/frappe/bench.git synced 2025-01-23 15:08:24 +00:00

fix(easy_install): log files saved with timestamp

This commit is contained in:
Gavin D'souza 2020-01-07 15:34:34 +05:30
parent bb7310f218
commit b80cecc917

View File

@ -1,10 +1,16 @@
#!/usr/bin/env python3
import os, sys, subprocess, getpass, json, multiprocessing, shutil, platform, warnings
import os, sys, subprocess, getpass, json, multiprocessing, shutil, platform, warnings, datetime
tmp_bench_repo = os.path.join('/', 'tmp', '.bench')
tmp_log_folder = os.path.join('/', 'tmp', 'logs')
log_path = os.path.join(tmp_log_folder, 'install_bench.log')
execution_day = "{:%Y-%m-%d}".format(datetime.datetime.utcnow())
execution_time = "{:%H-%M}".format(datetime.datetime.utcnow())
execution_ts = "{0}__{1}".format(execution_day, execution_time)
log_file_name = "easy-install__{}.log".format(execution_ts)
log_path = os.path.join(tmp_log_folder, log_file_name)
log_stream = sys.stdout
@ -29,6 +35,7 @@ def setup_log_stream(args):
os.makedirs(tmp_log_folder)
log_stream = open(log_path, 'w')
log("Logs are saved under {0}".format(log_path), level=3)
print("Install script run at {}\n\n".format(execution_ts), file=log_stream)
def check_environment():
@ -73,6 +80,7 @@ def check_distribution_compatibility():
if float(dist_version) in supported_dists[dist_name]:
log("{0} {1} is compatible!".format(dist_name, dist_version), level=1)
else:
log("{0} {1} is detected".format(dist_name, dist_version), level=1)
log("Install on {0} {1} instead".format(dist_name, supported_dists[dist_name][-1]), level=3)
else:
log("Sorry, the installer doesn't support {0}. Aborting installation!".format(dist_name), level=2)
@ -277,12 +285,16 @@ def clone_bench_repo(args):
return success
def passwords_didnt_match(context=''):
log("{} passwords did not match!".format(context), level=3)
def get_passwords(args):
"""
Returns a dict of passwords for further use
and creates passwords.txt in the bench user's home directory
"""
log("Input mySQL and Frappe Administrator passwords:")
log("Input MySQL and Frappe Administrator passwords:")
ignore_prompt = args.run_travis or args.without_bench_setup
mysql_root_password, admin_password = '', ''
passwords_file_path = os.path.join(os.path.expanduser('~' + args.user), 'passwords.txt')
@ -309,6 +321,7 @@ def get_passwords(args):
conf_mysql_passwd = getpass.unix_getpass(prompt='Re-enter mysql root password: ')
if mysql_root_password != conf_mysql_passwd or mysql_root_password == '':
passwords_didnt_match("MySQL")
mysql_root_password = ''
continue
@ -318,6 +331,7 @@ def get_passwords(args):
conf_admin_passswd = getpass.unix_getpass(prompt='Re-enter Administrator password: ')
if admin_password != conf_admin_passswd or admin_password == '':
passwords_didnt_match("Administrator")
admin_password = ''
continue