Skip to content

Commit 6158215

Browse files
stenniep
authored andcommitted
Fix #846: mlaunch should handle missing MongoDB binaries more gracefully (#847)
1 parent 3bc22ef commit 6158215

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

mtools/mlaunch/mlaunch.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,11 @@ def getMongoDVersion(self):
850850
if self.args and self.args.get('binarypath'):
851851
binary = os.path.join(self.args['binarypath'], binary)
852852

853-
out = check_mongo_server_output(binary, '--version')
853+
try:
854+
out = check_mongo_server_output(binary, '--version')
855+
except Exception:
856+
return "0.0"
857+
854858
buf = BytesIO(out)
855859
current_version = buf.readline().strip().decode('utf-8')
856860
# remove prefix "db version v"
@@ -1519,7 +1523,13 @@ def _filter_valid_arguments(self, arguments, binary="mongod",
15191523
# get the help list of the binary
15201524
if self.args and self.args['binarypath']:
15211525
binary = os.path.join(self.args['binarypath'], binary)
1522-
out = check_mongo_server_output(binary, '--help')
1526+
1527+
try:
1528+
out = check_mongo_server_output(binary, '--help')
1529+
except Exception:
1530+
raise SystemExit("Fatal error trying get output from `%s`."
1531+
"Is the binary in your path?" % binary)
1532+
15231533
accepted_arguments = []
15241534
# extract all arguments starting with a '-'
15251535
for line in [option for option in out.decode('utf-8').split('\n')]:

0 commit comments

Comments
 (0)