2
0
mirror of https://github.com/frappe/frappe_docker.git synced 2025-01-11 09:35:12 +00:00

chore(lint): Run pyupgrade

This commit is contained in:
Lev Vereshchagin 2021-12-10 11:51:47 +03:00
parent 3e4e66769b
commit c4772bc5b5
4 changed files with 13 additions and 13 deletions

View File

@ -29,7 +29,7 @@ def check_host(ip, port, retry=10, delay=3, print_attempt=True):
ipup = False
for i in range(retry):
if print_attempt:
print("Attempt {i} to connect to {ip}:{port}".format(ip=ip, port=port, i=i+1))
print(f"Attempt {i+1} to connect to {ip}:{port}")
if is_open(ip, port):
ipup = True
break

View File

@ -51,7 +51,7 @@ def main():
service_name=service_name,
service_port=service_port,
)
print("{0}:{1} Connected".format(service_name, service_port))
print(f"{service_name}:{service_port} Connected")
print("Health check successful")
exit(0)

View File

@ -34,7 +34,7 @@ def get_backup_dir():
def decompress_db(database_file, site):
command = ["gunzip", "-c", database_file]
with open(database_file.replace(".gz", ""), "w") as db_file:
print('Extract Database GZip for site {}'.format(site))
print(f'Extract Database GZip for site {site}')
run_command(command, stdout=db_file)
@ -80,14 +80,14 @@ def restore_files(files_base):
public_files = files_base + '-files.tar'
# extract tar
public_tar = tarfile.open(public_files)
print('Extracting {}'.format(public_files))
print(f'Extracting {public_files}')
public_tar.extractall()
def restore_private_files(files_base):
private_files = files_base + '-private-files.tar'
private_tar = tarfile.open(private_files)
print('Extracting {}'.format(private_files))
print(f'Extracting {private_files}')
private_tar.extractall()
@ -143,7 +143,7 @@ def pull_backup_from_s3():
if backup in backup_file:
if not os.path.exists(os.path.dirname(backup_file)):
os.makedirs(os.path.dirname(backup_file))
print('Downloading {}'.format(backup_file))
print(f'Downloading {backup_file}')
bucket.download_file(bucket_dir + '/' + backup_file, backup_file)
os.chdir(os.path.join(os.path.expanduser('~'), 'frappe-bench', 'sites'))
@ -196,7 +196,7 @@ def restore_postgres(config, site_config, database_file):
run_command(psql_command + [psql_uri, "-c", f"CREATE DATABASE \"{db_name}\""])
run_command(psql_command + [psql_uri, "-c", f"CREATE user {db_name} password '{db_password}'"])
run_command(psql_command + [psql_uri, "-c", f"GRANT ALL PRIVILEGES ON DATABASE \"{db_name}\" TO {db_name}"])
with open(database_file.replace('.gz', ''), 'r') as db_file:
with open(database_file.replace('.gz', '')) as db_file:
run_command(psql_command + [f"{psql_uri}/{db_name}", "<"], stdin=db_file)
@ -240,7 +240,7 @@ def restore_mariadb(config, site_config, database_file):
run_command(grant_privileges_command)
print('Restoring MariaDB')
with open(database_file.replace('.gz', ''), 'r') as db_file:
with open(database_file.replace('.gz', '')) as db_file:
run_command(mysql_command + [f"{db_name}"], stdin=db_file)
@ -260,7 +260,7 @@ def main():
if not os.path.exists(site_config_path):
site_config_path = os.path.join(backup_dir, site, 'site_config.json')
if site in get_sites():
print('Overwrite site {}'.format(site))
print(f'Overwrite site {site}')
restore_database(files_base, site_config_path, site)
restore_private_files(files_base)
restore_files(files_base)
@ -279,7 +279,7 @@ def main():
)
make_site_dirs()
print('Create site {}'.format(site))
print(f'Create site {site}')
restore_database(files_base, site_config_path, site)
restore_private_files(files_base)
restore_files(files_base)

View File

@ -94,7 +94,7 @@ def get_config():
def get_site_config(site_name):
site_config = None
with open('{site_name}/site_config.json'.format(site_name=site_name)) as site_config_file:
with open(f'{site_name}/site_config.json') as site_config_file:
site_config = json.load(site_config_file)
return site_config
@ -164,7 +164,7 @@ def list_directories(path):
def get_site_config_from_path(site_config_path):
site_config = dict()
if os.path.exists(site_config_path):
with open(site_config_path, 'r') as sc:
with open(site_config_path) as sc:
site_config = json.load(sc)
return site_config
@ -173,7 +173,7 @@ def set_key_in_site_config(key, site, site_config_path):
site_config = get_site_config_from_path(site_config_path)
value = site_config.get(key)
if value:
print('Set {key} in site config for site: {site}'.format(key=key, site=site))
print(f'Set {key} in site config for site: {site}')
update_site_config(key, value,
site_config_path=os.path.join(os.getcwd(), site, "site_config.json"))