mirror of
https://github.com/frappe/bench.git
synced 2025-01-09 08:30:39 +00:00
feat: added bench.utils.log and updated is_bench_directory api
This commit is contained in:
parent
ef1a624556
commit
e32281557f
@ -17,17 +17,29 @@ logger = logging.getLogger(__name__)
|
|||||||
folders_in_bench = ('apps', 'sites', 'config', 'logs', 'config/pids')
|
folders_in_bench = ('apps', 'sites', 'config', 'logs', 'config/pids')
|
||||||
|
|
||||||
|
|
||||||
def is_bench_directory():
|
def is_bench_directory(directory=os.path.curdir):
|
||||||
cur_dir = os.path.curdir
|
|
||||||
is_bench = True
|
is_bench = True
|
||||||
|
|
||||||
for folder in folders_in_bench:
|
for folder in folders_in_bench:
|
||||||
path = os.path.join(cur_dir, folder)
|
path = os.path.abspath(os.path.join(directory, folder))
|
||||||
is_bench = is_bench and os.path.exists(path)
|
is_bench = is_bench and os.path.exists(path)
|
||||||
|
|
||||||
return is_bench
|
return is_bench
|
||||||
|
|
||||||
|
|
||||||
|
def log(message, level=0):
|
||||||
|
levels = {
|
||||||
|
0: '\033[94m', # normal
|
||||||
|
1: '\033[92m', # success
|
||||||
|
2: '\033[91m', # fail
|
||||||
|
3: '\033[93m' # warn/suggest
|
||||||
|
}
|
||||||
|
start = levels.get(level) or ''
|
||||||
|
end = '\033[0m'
|
||||||
|
|
||||||
|
print(start + message + end)
|
||||||
|
|
||||||
|
|
||||||
def safe_decode(string, encoding = 'utf-8'):
|
def safe_decode(string, encoding = 'utf-8'):
|
||||||
try:
|
try:
|
||||||
string = string.decode(encoding)
|
string = string.decode(encoding)
|
||||||
|
Loading…
Reference in New Issue
Block a user