def configure(self, options, conf):
<EOL>if not options.mongoengine or options.mongodb_bin:<EOL><INDENT>return<EOL><DEDENT>if not options.mongodb_bin:<EOL><INDENT>self.mongodb_param['<STR_LIT>'] = scan_path()<EOL>if self.mongodb_param['<STR_LIT>'] is None:<EOL><INDENT>raise AssertionError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self.mongodb_param['<STR_LIT>'] = os.path.abspath(<EOL>os.path.expanduser(os.path.expandvars(options.mongodb_bin)))<EOL>if not os.path.exists(self.mongodb_param['<STR_LIT>']):<EOL><INDENT>raise AssertionError(<EOL>"<STR_LIT>" %self.mongodb_param['<STR_LIT>'])<EOL><DEDENT><DEDENT>self.enabled = True<EOL>db_log_path = os.path.expandvars(os.path.expanduser(<EOL>options.mongodb_logpath))<EOL>try:<EOL><INDENT>db_file = open(db_log_path, "<STR_LIT:w>")<EOL>db_file.close()<EOL><DEDENT>except Exception as exc:<EOL><INDENT>raise AssertionError("<STR_LIT>" % exc)<EOL><DEDENT>if not options.mongodb_port:<EOL><INDENT>self.mongodb_param['<STR_LIT>'] = get_open_port()<EOL><DEDENT>else:<EOL><INDENT>self.mongodb_param['<STR_LIT>'] = options.mongodb_port<EOL><DEDENT>db_prealloc = options.mongodb_prealloc<EOL>db_scripting = options.mongodb_scripting<EOL>self.clear_context['<STR_LIT>'] = options.mongoengine_clear_after_module<EOL>self.clear_context['<STR_LIT:class>'] = options.mongoengine_clear_after_class<EOL>self.database_name = str(uuid.uuid1())<EOL>self.mongodb_param['<STR_LIT>'] = tempfile.mkdtemp()<EOL>if not os.path.exists(self.mongodb_param['<STR_LIT>']):<EOL><INDENT>os.mkdir(self.mongodb_param['<STR_LIT>'])<EOL><DEDENT>args = [<EOL>self.mongodb_param['<STR_LIT>'],<EOL>"<STR_LIT>",<EOL>self.mongodb_param['<STR_LIT>'],<EOL>"<STR_LIT>",<EOL>str(self.mongodb_param['<STR_LIT>']),<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>db_log_path,<EOL>"<STR_LIT>"<EOL>]<EOL>if not db_prealloc:<EOL><INDENT>args.append("<STR_LIT>")<EOL><DEDENT>if not db_scripting:<EOL><INDENT>args.append("<STR_LIT>")<EOL><DEDENT>self.process = Popen(<EOL>args,<EOL>stdout=subprocess.PIPE,<EOL>stderr=subprocess.STDOUT<EOL>)<EOL>self._running = True<EOL>os.environ["<STR_LIT>"] = "<STR_LIT>" %self.mongodb_param['<STR_LIT>']<EOL>os.environ["<STR_LIT>"] = self.database_name<EOL>time.sleep(<NUM_LIT>)<EOL>self.connection = connect(self.database_name, host="<STR_LIT:localhost>",<EOL>port=self.mongodb_param['<STR_LIT>'])<EOL>
Parse the command line options and start an instance of mongodb