Skip to content

Commit

Permalink
fix: Show traceback on bench init failure
Browse files Browse the repository at this point in the history
Other changes:
* Invoke internal init function instead of invoking click
command. This was done to avoid handling random Exceptions that are done
in the command definition
* os.chdir after initializing new bench in get_app
  • Loading branch information
gavindsouza committed Nov 17, 2021
1 parent a192240 commit 30e3e72
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions bench/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,11 @@ def get_app(
branch = app.tag

if not is_bench_directory(bench_path):
bench_path = generate_bench_name(git_url, bench_path)
from bench.commands.make import init
from bench.utils.system import init

click.get_current_context().invoke(init, path=bench_path, frappe_branch=branch)
bench_path = get_available_folder_name(f"{app.repo}-bench", bench_path)
init(path=bench_path, frappe_branch=branch)
os.chdir(bench_path)

cloned_path = os.path.join(bench_path, "apps", repo_name)
dir_already_exists = os.path.isdir(cloned_path)
Expand Down
5 changes: 3 additions & 2 deletions bench/commands/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ def init(path, apps_path, frappe_path, frappe_branch, no_procfile, no_backups, c
except SystemExit:
raise
except Exception as e:
import os, shutil, time
import shutil, time
from bench.utils import get_traceback
# add a sleep here so that the traceback of other processes doesnt overlap with the prompts
time.sleep(1)
print(e)
print(get_traceback())
log(f"There was a problem while creating {path}", level=2)
if click.confirm("Do you want to rollback these changes?"):
print(f'Rolling back Bench "{path}"')
Expand Down

0 comments on commit 30e3e72

Please sign in to comment.