Remove logging for rethinkdb instance open/close
This commit is contained in:
parent
748bc4f374
commit
6de148a1c7
|
@ -2,9 +2,7 @@ import ruamel.yaml as yaml
|
|||
import asyncio
|
||||
import rethinkdb as r
|
||||
import pendulum
|
||||
import logging
|
||||
|
||||
log = logging.getLogger()
|
||||
loop = asyncio.get_event_loop()
|
||||
global_config = {}
|
||||
|
||||
|
@ -131,7 +129,6 @@ def command_prefix(bot, message):
|
|||
async def add_content(table, content):
|
||||
r.set_loop_type("asyncio")
|
||||
conn = await r.connect(**db_opts)
|
||||
log.info("RethinkDB Instance opened. Table: {}---Content: {}---Method = add_content".format(table, content))
|
||||
# First we need to make sure that this entry doesn't exist
|
||||
# For all rethinkDB cares, multiple entries can exist with the same content
|
||||
# For our purposes however, we do not want this
|
||||
|
@ -144,7 +141,6 @@ async def add_content(table, content):
|
|||
result = {}
|
||||
|
||||
await conn.close()
|
||||
log.info("RethinkDB Instance closed. Table: {}---Content: {}---Method = add_content".format(table, content))
|
||||
if table == 'prefixes' or table == 'server_settings':
|
||||
loop.create_task(cache[table].update())
|
||||
return result.get('inserted', 0) > 0
|
||||
|
@ -153,7 +149,6 @@ async def add_content(table, content):
|
|||
async def remove_content(table, key):
|
||||
r.set_loop_type("asyncio")
|
||||
conn = await r.connect(**db_opts)
|
||||
log.info("RethinkDB Instance opened. Table: {}---Key: {}---Method: remove_content".format(table, key))
|
||||
try:
|
||||
result = await r.table(table).get(key).delete().run(conn)
|
||||
except r.ReqlOpFailedError:
|
||||
|
@ -161,7 +156,6 @@ async def remove_content(table, key):
|
|||
pass
|
||||
|
||||
await conn.close()
|
||||
log.info("RethinkDB Instance closed. Table: {}---Key: {}---Method: remove_content".format(table, key))
|
||||
if table == 'prefixes' or table == 'server_settings':
|
||||
loop.create_task(cache[table].update())
|
||||
return result.get('deleted', 0) > 0
|
||||
|
@ -170,7 +164,6 @@ async def remove_content(table, key):
|
|||
async def update_content(table, content, key):
|
||||
r.set_loop_type("asyncio")
|
||||
conn = await r.connect(**db_opts)
|
||||
log.info("RethinkDB Instance opened. Table: {}---Content: {}---Key: {}---Method: update_content".format(table, content, key))
|
||||
# This method is only for updating content, so if we find that it doesn't exist, just return false
|
||||
try:
|
||||
# Update based on the content and filter passed to us
|
||||
|
@ -181,7 +174,6 @@ async def update_content(table, content, key):
|
|||
result = {}
|
||||
|
||||
await conn.close()
|
||||
log.info("RethinkDB Instance closed. Table: {}---Content: {}---Key: {}---Method: update_content".format(table, content, key))
|
||||
if table == 'prefixes' or table == 'server_settings':
|
||||
loop.create_task(cache[table].update())
|
||||
return result.get('replaced', 0) > 0 or result.get('unchanged', 0) > 0
|
||||
|
@ -191,14 +183,12 @@ async def replace_content(table, content, key):
|
|||
# This method is here because .replace and .update can have some different functionalities
|
||||
r.set_loop_type("asyncio")
|
||||
conn = await r.connect(**db_opts)
|
||||
log.info("RethinkDB Instance opened. Table: {}---Content: {}---Key: {}---Method: replace_content".format(table, content, key))
|
||||
try:
|
||||
result = await r.table(table).get(key).replace(content).run(conn)
|
||||
except r.ReqlOpFailedError:
|
||||
result = {}
|
||||
|
||||
await conn.close()
|
||||
log.info("RethinkDB Instance closed. Table: {}---Content: {}---Key: {}---Method: replace_content".format(table, content, key))
|
||||
if table == 'prefixes' or table == 'server_settings':
|
||||
loop.create_task(cache[table].update())
|
||||
return result.get('replaced', 0) > 0 or result.get('unchanged', 0) > 0
|
||||
|
@ -207,7 +197,6 @@ async def replace_content(table, content, key):
|
|||
async def get_content(table, key=None):
|
||||
r.set_loop_type("asyncio")
|
||||
conn = await r.connect(**db_opts)
|
||||
log.info("RethinkDB Instance opened. Table: {}---Key: {}---Method: get_content".format(table, key))
|
||||
|
||||
try:
|
||||
if key:
|
||||
|
@ -226,13 +215,11 @@ async def get_content(table, key=None):
|
|||
content = None
|
||||
|
||||
await conn.close()
|
||||
log.info("RethinkDB Instance closed. Table: {}---Key: {}---Method: get_content".format(table, key))
|
||||
return content
|
||||
|
||||
async def filter_content(table: str, r_filter):
|
||||
r.set_loop_type("asyncio")
|
||||
conn = await r.connect(**db_opts)
|
||||
log.info("RethinkDB Instance opened. Table: {}---Filter: {}---Method: filter_content".format(table, r_filter))
|
||||
try:
|
||||
cursor = await r.table(table).filter(r_filter).run(conn)
|
||||
content = await _convert_to_list(cursor)
|
||||
|
@ -242,7 +229,6 @@ async def filter_content(table: str, r_filter):
|
|||
content = None
|
||||
|
||||
await conn.close()
|
||||
log.info("RethinkDB Instance closed. Table: {}---Filter: {}---Method: filter_content".format(table, r_filter))
|
||||
return content
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue