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