mirror of
https://github.com/frappe/bench.git
synced 2025-01-09 08:30:39 +00:00
style: chmod+x, format, space -> tabs
This commit is contained in:
parent
80b58d9999
commit
a987c1e9ae
41
easy-install.py
Normal file → Executable file
41
easy-install.py
Normal file → Executable file
@ -1,14 +1,14 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import subprocess
|
||||
import logging
|
||||
import os
|
||||
import platform
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import urllib.request
|
||||
import logging
|
||||
import platform
|
||||
from shutil import which, unpack_archive, move
|
||||
from hashlib import sha224
|
||||
from shutil import move, unpack_archive, which
|
||||
from typing import Dict
|
||||
|
||||
logging.basicConfig(
|
||||
@ -59,20 +59,21 @@ def clone_frappe_docker_repo() -> None:
|
||||
logging.error("Download and unzip failed", exc_info=True)
|
||||
cprint("\nCloning frappe_docker Failed\n\n", "[ERROR]: ", e, level=1)
|
||||
|
||||
def get_from_env(dir,file) -> Dict:
|
||||
env_vars ={}
|
||||
with open(os.path.join(dir,file)) as f:
|
||||
|
||||
def get_from_env(dir, file) -> Dict:
|
||||
env_vars = {}
|
||||
with open(os.path.join(dir, file)) as f:
|
||||
for line in f:
|
||||
if line.startswith('#') or not line.strip():
|
||||
if line.startswith("#") or not line.strip():
|
||||
continue
|
||||
key, value = line.strip().split('=', 1)
|
||||
key, value = line.strip().split("=", 1)
|
||||
env_vars[key] = value
|
||||
return env_vars
|
||||
|
||||
|
||||
def write_to_env(wd: str, site: str, db_pass: str, admin_pass: str, email: str) -> None:
|
||||
site_name = site or ""
|
||||
example_env = get_from_env(wd,"example.env")
|
||||
example_env = get_from_env(wd, "example.env")
|
||||
with open(os.path.join(wd, ".env"), "w") as f:
|
||||
f.writelines(
|
||||
[
|
||||
@ -108,9 +109,7 @@ def check_repo_exists() -> bool:
|
||||
|
||||
def setup_prod(project: str, sitename: str, email: str) -> None:
|
||||
if check_repo_exists():
|
||||
compose_file_name = os.path.join(
|
||||
os.path.expanduser("~"), f"{project}-compose.yml"
|
||||
)
|
||||
compose_file_name = os.path.join(os.path.expanduser("~"), f"{project}-compose.yml")
|
||||
docker_repo_path = os.path.join(os.getcwd(), "frappe_docker")
|
||||
cprint(
|
||||
"\nPlease refer to .example.env file in the frappe_docker folder to know which keys to set\n\n",
|
||||
@ -128,15 +127,13 @@ def setup_prod(project: str, sitename: str, email: str) -> None:
|
||||
"\nA .env file is generated with basic configs. Please edit it to fit to your needs \n",
|
||||
level=3,
|
||||
)
|
||||
with open(
|
||||
os.path.join(os.path.expanduser("~"), "passwords.txt"), "w"
|
||||
) as en:
|
||||
with open(os.path.join(os.path.expanduser("~"), "passwords.txt"), "w") as en:
|
||||
en.writelines(f"ADMINISTRATOR_PASSWORD={admin_pass}\n")
|
||||
en.writelines(f"MARIADB_ROOT_PASSWORD={db_pass}\n")
|
||||
else:
|
||||
env = get_from_env(docker_repo_path,".env")
|
||||
admin_pass = env['SITE_ADMIN_PASS']
|
||||
db_pass = env['DB_PASSWORD']
|
||||
env = get_from_env(docker_repo_path, ".env")
|
||||
admin_pass = env["SITE_ADMIN_PASS"]
|
||||
db_pass = env["DB_PASSWORD"]
|
||||
try:
|
||||
# TODO: Include flags for non-https and non-erpnext installation
|
||||
subprocess.run(
|
||||
@ -165,7 +162,7 @@ def setup_prod(project: str, sitename: str, email: str) -> None:
|
||||
check=True,
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
logging.error("Docker Compose generation failed", exc_info=True)
|
||||
cprint("\nGenerating Compose File failed\n")
|
||||
sys.exit(1)
|
||||
@ -211,7 +208,7 @@ def setup_prod(project: str, sitename: str, email: str) -> None:
|
||||
admin_pass,
|
||||
"--install-app",
|
||||
"erpnext",
|
||||
"--set-default"
|
||||
"--set-default",
|
||||
],
|
||||
check=True,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user