Skip to content

Commit

Permalink
Fix #846: mlaunch should handle missing MongoDB binaries more gracefu…
Browse files Browse the repository at this point in the history
…lly (#847)
  • Loading branch information
stennie authored Feb 24, 2022
1 parent b96568c commit 0f403e0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions mtools/mlaunch/mlaunch.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,11 @@ def getMongoDVersion(self):
if self.args and self.args.get('binarypath'):
binary = os.path.join(self.args['binarypath'], binary)

out = check_mongo_server_output(binary, '--version')
try:
out = check_mongo_server_output(binary, '--version')
except Exception:
return "0.0"

buf = BytesIO(out)
current_version = buf.readline().strip().decode('utf-8')
# remove prefix "db version v"
Expand Down Expand Up @@ -1577,7 +1581,13 @@ def _filter_valid_arguments(self, arguments, binary="mongod",
# get the help list of the binary
if self.args and self.args['binarypath']:
binary = os.path.join(self.args['binarypath'], binary)
out = check_mongo_server_output(binary, '--help')

try:
out = check_mongo_server_output(binary, '--help')
except Exception:
raise SystemExit("Fatal error trying get output from `%s`."
"Is the binary in your path?" % binary)

accepted_arguments = []
# extract all arguments starting with a '-'
for line in [option for option in out.decode('utf-8').split('\n')]:
Expand Down

0 comments on commit 0f403e0

Please sign in to comment.