Skip to content

Commit

Permalink
refactor: Exceptions, variables with pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
gavindsouza committed Aug 3, 2022
1 parent 2c5c28b commit 4014f73
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions bench/patches/v5/fix_user_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
def is_sudoers_set():
"""Check if bench sudoers is set"""
cmd = ["sudo", "-n", "bench"]
bench_warn = False

with open(os.devnull, "wb") as f:
return_code_check = not subprocess.call(cmd, stdout=f)
Expand Down
9 changes: 5 additions & 4 deletions bench/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ def is_valid_frappe_branch(frappe_path: str, frappe_branch: str):
:type frappe_branch: str
:raises InvalidRemoteException: branch for this repo doesn't exist
"""
import git
from git.cmd import Git
from git.exc import GitCommandError

g = git.cmd.Git()
g = Git()

if frappe_branch:
try:
Expand All @@ -74,8 +75,8 @@ def is_valid_frappe_branch(frappe_path: str, frappe_branch: str):
raise InvalidRemoteException(
f"Invalid branch or tag: {frappe_branch} for the remote {frappe_path}"
)
except git.exc.GitCommandError:
raise InvalidRemoteException(f"Invalid frappe path: {frappe_path}")
except GitCommandError as e:
raise InvalidRemoteException(f"Invalid frappe path: {frappe_path}") from e


def log(message, level=0, no_log=False):
Expand Down
2 changes: 1 addition & 1 deletion bench/utils/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def restart_supervisor_processes(bench_path=".", web_workers=False):
sudo = ""
try:
supervisor_status = get_cmd_output("supervisorctl status", cwd=bench_path)
except Exception as e:
except subprocess.CalledProcessError as e:
if e.returncode == 127:
log("restart failed: Couldn't find supervisorctl in PATH", level=3)
return
Expand Down

0 comments on commit 4014f73

Please sign in to comment.