def query(self, command, value=1, check=True, allowable_errors=None, **kwargs):
"""?????
pymongo????????,??????
TODO:????????????"""
if not self._db:
self.recorder('CRITICAL', 'please select db first!')
shell_command = 'db.runCommand(\n{cmd}\n)'.format(cmd=dumps(command, indent=4, whole=4))
self.recorder('INFO', '{obj} command start\n{cmd}'.format(obj=self, cmd=shell_command))
try:
with tool.timing('s', 10) as t:
response = self._db.command(command=command, value=value, check=check, allowable_errors=allowable_errors, **kwargs)
except pymongo.errors.PyMongoError as e:
self.recorder('ERROR', '{obj} command error [{msg}]'.format(obj=self, msg=e))
raise MongoError
self.recorder('INFO', '{obj} command successful\n{cmd} -- {time}'.format(obj=self, cmd=shell_command, time=t))
self._response = self._parse_response(response)
return self._response
评论列表
文章目录