Skip to content

Commit 2a3dac9

Browse files
authored
Merge pull request #2106 from vladak/projadm_base
emit errors along with guidance how to fix them
2 parents d7e4ae9 + c0d1e5b commit 2a3dac9

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

tools/sync/projadm.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,9 @@ def project_delete(doit, logger, project, messages):
237237
logger.debug("Using {} as instance base".
238238
format(args.base))
239239
else:
240-
logger.error("Not a directory: {}".format(args.base))
240+
logger.error("Not a directory: {}\n"
241+
"Set the base directory with the --base option."
242+
.format(args.base))
241243
sys.exit(1)
242244

243245
# read-only configuration file.
@@ -250,7 +252,15 @@ def project_delete(doit, logger, project, messages):
250252

251253
# XXX replace Messages with REST request after issue #1801
252254
messages_file = get_command(logger, args.messages, "Messages")
255+
if not messages_file:
256+
logger.error("Use the --messages option to specify the path to"
257+
"the Messages script")
258+
sys.exit(1)
253259
configmerge_file = get_command(logger, args.configmerge, "ConfigMerge")
260+
if not configmerge_file:
261+
logger.error("Use the --configmerge option to specify the path to"
262+
"the ConfigMerge script")
263+
sys.exit(1)
254264

255265
lock = filelock.FileLock(os.path.join(tempfile.gettempdir(),
256266
os.path.basename(sys.argv[0]) + ".lock"))

tools/sync/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def get_command(logger, path, name):
5858
if not is_exe(cmd_file):
5959
logger.error("file {} is not executable file".
6060
format(path))
61-
sys.exit(1)
61+
return None
6262
else:
6363
cmd_file = which(name)
6464
if not cmd_file:
@@ -68,7 +68,7 @@ def get_command(logger, path, name):
6868
if not cmd_file:
6969
logger.error("cannot determine path to the {} script".
7070
format(name))
71-
sys.exit(1)
71+
return None
7272
logger.debug("{} = {}".format(name, cmd_file))
7373

7474
return cmd_file

0 commit comments

Comments
 (0)