mirror of
https://github.com/frappe/bench.git
synced 2025-01-09 16:36:25 +00:00
fix: Raise and handle Exception class
* Instead of sys.exit, raise ValidationError * Let's not handle BaseException, just Exception * Use ValidationError instead of invalid syntax raise str
This commit is contained in:
parent
e08a12477d
commit
c4b8391716
@ -201,7 +201,7 @@ def get_sites_with_config(bench_path):
|
|||||||
"If you want this command to pass, instead of just throwing an error,",
|
"If you want this command to pass, instead of just throwing an error,",
|
||||||
"You may remove the 'strict_nginx' flag from common_site_config.json or set it to 0",
|
"You may remove the 'strict_nginx' flag from common_site_config.json or set it to 0",
|
||||||
"\n\n")
|
"\n\n")
|
||||||
raise (e)
|
raise e
|
||||||
else:
|
else:
|
||||||
print(f"\n\nWARNING: The site config for the site {site} is broken.",
|
print(f"\n\nWARNING: The site config for the site {site} is broken.",
|
||||||
"If you want this command to fail, instead of just showing a warning,",
|
"If you want this command to fail, instead of just showing a warning,",
|
||||||
|
@ -182,7 +182,7 @@ def reload_supervisor():
|
|||||||
def reload_nginx():
|
def reload_nginx():
|
||||||
try:
|
try:
|
||||||
exec_cmd(f"sudo {which('nginx')} -t")
|
exec_cmd(f"sudo {which('nginx')} -t")
|
||||||
except:
|
except Exception:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
service('nginx', 'reload')
|
service('nginx', 'reload')
|
||||||
|
@ -191,10 +191,10 @@ def get_bumped_version(version, bump_type):
|
|||||||
v.prerelease = ('beta', str(int(v.prerelease[1]) + 1))
|
v.prerelease = ('beta', str(int(v.prerelease[1]) + 1))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise ("Something wen't wrong while doing a prerelease")
|
raise ValidationError("Something wen't wrong while doing a prerelease")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise ("bump_type not amongst [major, minor, patch, prerelease]")
|
raise ValidationError("bump_type not amongst [major, minor, patch, prerelease]")
|
||||||
|
|
||||||
return str(v)
|
return str(v)
|
||||||
|
|
||||||
|
@ -239,15 +239,16 @@ def get_bench_name(bench_path):
|
|||||||
|
|
||||||
def set_git_remote_url(git_url, bench_path='.'):
|
def set_git_remote_url(git_url, bench_path='.'):
|
||||||
"Set app remote git url"
|
"Set app remote git url"
|
||||||
|
from bench.app import get_repo_dir
|
||||||
from bench.bench import Bench
|
from bench.bench import Bench
|
||||||
|
|
||||||
app = git_url.rsplit('/', 1)[1].rsplit('.', 1)[0]
|
app = git_url.rsplit('/', 1)[1].rsplit('.', 1)[0]
|
||||||
|
|
||||||
if app not in Bench(bench_path).apps:
|
if app not in Bench(bench_path).apps:
|
||||||
print(f"No app named {app}")
|
raise ValidationError(f"No app named {app}")
|
||||||
sys.exit(1)
|
|
||||||
|
app_dir = get_repo_dir(app, bench_path=bench_path)
|
||||||
|
|
||||||
app_dir = bench.app.get_repo_dir(app, bench_path=bench_path)
|
|
||||||
if os.path.exists(os.path.join(app_dir, '.git')):
|
if os.path.exists(os.path.join(app_dir, '.git')):
|
||||||
exec_cmd(f"git remote set-url upstream {git_url}", cwd=app_dir)
|
exec_cmd(f"git remote set-url upstream {git_url}", cwd=app_dir)
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ def migrate_env(python, backup=False):
|
|||||||
exec_cmd(f'{redis} FLUSHALL')
|
exec_cmd(f'{redis} FLUSHALL')
|
||||||
logger.log('Clearing Redis DataBase...')
|
logger.log('Clearing Redis DataBase...')
|
||||||
exec_cmd(f'{redis} FLUSHDB')
|
exec_cmd(f'{redis} FLUSHDB')
|
||||||
except:
|
except Exception:
|
||||||
logger.warning('Please ensure Redis Connections are running or Daemonized.')
|
logger.warning('Please ensure Redis Connections are running or Daemonized.')
|
||||||
|
|
||||||
# Backup venv: restore using `virtualenv --relocatable` if needed
|
# Backup venv: restore using `virtualenv --relocatable` if needed
|
||||||
@ -213,7 +213,7 @@ def migrate_env(python, backup=False):
|
|||||||
packages_setup = exec_cmd(f'{pvenv} -m pip install -q -U {apps}')
|
packages_setup = exec_cmd(f'{pvenv} -m pip install -q -U {apps}')
|
||||||
|
|
||||||
logger.log(f'Migration Successful to {python}')
|
logger.log(f'Migration Successful to {python}')
|
||||||
except:
|
except Exception:
|
||||||
if venv_creation or packages_setup:
|
if venv_creation or packages_setup:
|
||||||
logger.warning('Migration Error')
|
logger.warning('Migration Error')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user