mirror of
https://github.com/frappe/bench.git
synced 2025-01-10 00:37:51 +00:00
fix: seperate colors from log, change exception
changes: thrown if bench dir exists on bench init style: fixed whitespaces and formatting
This commit is contained in:
parent
f0c1893565
commit
7fb1484b7f
@ -17,6 +17,14 @@ logger = logging.getLogger(__name__)
|
|||||||
folders_in_bench = ('apps', 'sites', 'config', 'logs', 'config/pids')
|
folders_in_bench = ('apps', 'sites', 'config', 'logs', 'config/pids')
|
||||||
|
|
||||||
|
|
||||||
|
class color:
|
||||||
|
nc = '\033[0m'
|
||||||
|
blue = '\033[94m'
|
||||||
|
green = '\033[92m'
|
||||||
|
yellow = '\033[93m'
|
||||||
|
red = '\033[91m'
|
||||||
|
|
||||||
|
|
||||||
def is_bench_directory(directory=os.path.curdir):
|
def is_bench_directory(directory=os.path.curdir):
|
||||||
is_bench = True
|
is_bench = True
|
||||||
|
|
||||||
@ -29,12 +37,12 @@ def is_bench_directory(directory=os.path.curdir):
|
|||||||
|
|
||||||
def log(message, level=0):
|
def log(message, level=0):
|
||||||
levels = {
|
levels = {
|
||||||
0: '\033[94m', # normal
|
0: color.blue + 'LOG', # normal
|
||||||
1: '\033[92m', # success
|
1: color.green + 'SUCCESS', # success
|
||||||
2: '\033[91mERROR: ', # fail
|
2: color.red + 'ERROR', # fail
|
||||||
3: '\033[93mWARN: ' # warn/suggest
|
3: color.yellow + 'WARN' # warn/suggest
|
||||||
}
|
}
|
||||||
start = levels.get(level) or ''
|
start = levels.get(level) + ': ' if level in levels else ''
|
||||||
end = '\033[0m'
|
end = '\033[0m'
|
||||||
|
|
||||||
print(start + message + end)
|
print(start + message + end)
|
||||||
@ -57,23 +65,19 @@ def get_frappe(bench_path='.'):
|
|||||||
def get_env_cmd(cmd, bench_path='.'):
|
def get_env_cmd(cmd, bench_path='.'):
|
||||||
return os.path.abspath(os.path.join(bench_path, 'env', 'bin', cmd))
|
return os.path.abspath(os.path.join(bench_path, 'env', 'bin', cmd))
|
||||||
|
|
||||||
def init(path, apps_path=None, no_procfile=False, no_backups=False,
|
def init(path, apps_path=None, no_procfile=False, no_backups=False, no_auto_update=False,
|
||||||
no_auto_update=False, frappe_path=None, frappe_branch=None, wheel_cache_dir=None,
|
frappe_path=None, frappe_branch=None, wheel_cache_dir=None, verbose=False, clone_from=None,
|
||||||
verbose=False, clone_from=None, skip_redis_config_generation=False,
|
skip_redis_config_generation=False, clone_without_update=False, ignore_exist = False, skip_assets=False, python='python3'):
|
||||||
clone_without_update=False,
|
import os, errno
|
||||||
ignore_exist = False, skip_assets=False,
|
from bench.app import get_app, install_apps_from_path
|
||||||
python = 'python3'): # Let's change when we're ready. - <achilles@frappe.io>
|
from bench.config import redis
|
||||||
from .app import get_app, install_apps_from_path
|
from bench.config.common_site_config import make_config
|
||||||
from .config.common_site_config import make_config
|
from bench.config.procfile import setup_procfile
|
||||||
from .config import redis
|
|
||||||
from .config.procfile import setup_procfile
|
|
||||||
from bench.patches import set_all_patches_executed
|
from bench.patches import set_all_patches_executed
|
||||||
|
|
||||||
import os.path as osp
|
if os.path.exists(path) and not ignore_exist:
|
||||||
|
log('Path {path} already exists!'.format(path=path))
|
||||||
if osp.exists(path):
|
sys.exit(0)
|
||||||
if not ignore_exist:
|
|
||||||
raise ValueError('Bench Instance {path} already exists.'.format(path = path))
|
|
||||||
else:
|
else:
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
|
|
||||||
@ -81,7 +85,7 @@ def init(path, apps_path=None, no_procfile=False, no_backups=False,
|
|||||||
try:
|
try:
|
||||||
os.makedirs(os.path.join(path, dirname))
|
os.makedirs(os.path.join(path, dirname))
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
if e.errno == os.errno.EEXIST:
|
if e.errno == errno.EEXIST:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
setup_logging()
|
setup_logging()
|
||||||
|
Loading…
Reference in New Issue
Block a user