mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-13 06:59:53 -05:00
test
This commit is contained in:
parent
64e5dbcfd3
commit
688daaba1a
@ -27,8 +27,8 @@ class PluginValues(BASE):
|
|||||||
"""
|
"""
|
||||||
__tablename__ = 'plugin_values'
|
__tablename__ = 'plugin_values'
|
||||||
plugin = Column(String(255), primary_key=True)
|
plugin = Column(String(255), primary_key=True)
|
||||||
category = Column(String(255), primary_key=True)
|
key = Column(String(255), primary_key=True)
|
||||||
key = Column(String(255))
|
category = Column(String(255))
|
||||||
value = Column(String(255))
|
value = Column(String(255))
|
||||||
|
|
||||||
|
|
||||||
@ -217,7 +217,7 @@ class SpiceDB(object):
|
|||||||
|
|
||||||
# PLUGIN FUNCTIONS
|
# PLUGIN FUNCTIONS
|
||||||
|
|
||||||
def set_plugin_value(self, plugin, key, value, category='default'):
|
def set_plugin_value(self, plugin, key, value):
|
||||||
"""Sets the value for a given key to be associated with the plugin."""
|
"""Sets the value for a given key to be associated with the plugin."""
|
||||||
plugin = Identifier(plugin).lower()
|
plugin = Identifier(plugin).lower()
|
||||||
value = json.dumps(value, ensure_ascii=False)
|
value = json.dumps(value, ensure_ascii=False)
|
||||||
@ -225,7 +225,6 @@ class SpiceDB(object):
|
|||||||
try:
|
try:
|
||||||
result = session.query(PluginValues) \
|
result = session.query(PluginValues) \
|
||||||
.filter(PluginValues.plugin == plugin)\
|
.filter(PluginValues.plugin == plugin)\
|
||||||
.filter(PluginValues.category == category)\
|
|
||||||
.filter(PluginValues.key == key) \
|
.filter(PluginValues.key == key) \
|
||||||
.one_or_none()
|
.one_or_none()
|
||||||
# PluginValues exists, update
|
# PluginValues exists, update
|
||||||
@ -234,7 +233,7 @@ class SpiceDB(object):
|
|||||||
session.commit()
|
session.commit()
|
||||||
# DNE - Insert
|
# DNE - Insert
|
||||||
else:
|
else:
|
||||||
new_pluginvalue = PluginValues(plugin=plugin, category=category, key=key, value=value)
|
new_pluginvalue = PluginValues(plugin=plugin, key=key, value=value)
|
||||||
session.add(new_pluginvalue)
|
session.add(new_pluginvalue)
|
||||||
session.commit()
|
session.commit()
|
||||||
except SQLAlchemyError:
|
except SQLAlchemyError:
|
||||||
@ -243,14 +242,13 @@ class SpiceDB(object):
|
|||||||
finally:
|
finally:
|
||||||
session.close()
|
session.close()
|
||||||
|
|
||||||
def get_plugin_value(self, plugin, key, category='default'):
|
def get_plugin_value(self, plugin, key):
|
||||||
"""Retrieves the value for a given key associated with a plugin."""
|
"""Retrieves the value for a given key associated with a plugin."""
|
||||||
plugin = Identifier(plugin).lower()
|
plugin = Identifier(plugin).lower()
|
||||||
session = self.ssession()
|
session = self.ssession()
|
||||||
try:
|
try:
|
||||||
result = session.query(PluginValues) \
|
result = session.query(PluginValues) \
|
||||||
.filter(PluginValues.plugin == plugin)\
|
.filter(PluginValues.plugin == plugin)\
|
||||||
.filter(PluginValues.category == category)\
|
|
||||||
.filter(PluginValues.key == key) \
|
.filter(PluginValues.key == key) \
|
||||||
.one_or_none()
|
.one_or_none()
|
||||||
if result is not None:
|
if result is not None:
|
||||||
@ -262,14 +260,13 @@ class SpiceDB(object):
|
|||||||
finally:
|
finally:
|
||||||
session.close()
|
session.close()
|
||||||
|
|
||||||
def delete_plugin_value(self, plugin, key, category='default'):
|
def delete_plugin_value(self, plugin, key):
|
||||||
"""Deletes the value for a given key to be associated with the plugin."""
|
"""Deletes the value for a given key to be associated with the plugin."""
|
||||||
plugin = Identifier(plugin).lower()
|
plugin = Identifier(plugin).lower()
|
||||||
session = self.ssession()
|
session = self.ssession()
|
||||||
try:
|
try:
|
||||||
result = session.query(PluginValues) \
|
result = session.query(PluginValues) \
|
||||||
.filter(PluginValues.plugin == plugin)\
|
.filter(PluginValues.plugin == plugin)\
|
||||||
.filter(PluginValues.category == category)\
|
|
||||||
.filter(PluginValues.key == key) \
|
.filter(PluginValues.key == key) \
|
||||||
.one_or_none()
|
.one_or_none()
|
||||||
# PluginValues exists, delete
|
# PluginValues exists, delete
|
||||||
@ -282,7 +279,7 @@ class SpiceDB(object):
|
|||||||
finally:
|
finally:
|
||||||
session.close()
|
session.close()
|
||||||
|
|
||||||
def adjust_plugin_value(self, plugin, key, value, category='default'):
|
def adjust_plugin_value(self, plugin, key, value):
|
||||||
"""Sets the value for a given key to be associated with the plugin."""
|
"""Sets the value for a given key to be associated with the plugin."""
|
||||||
plugin = Identifier(plugin).lower()
|
plugin = Identifier(plugin).lower()
|
||||||
value = json.dumps(value, ensure_ascii=False)
|
value = json.dumps(value, ensure_ascii=False)
|
||||||
@ -290,7 +287,6 @@ class SpiceDB(object):
|
|||||||
try:
|
try:
|
||||||
result = session.query(PluginValues) \
|
result = session.query(PluginValues) \
|
||||||
.filter(PluginValues.plugin == plugin)\
|
.filter(PluginValues.plugin == plugin)\
|
||||||
.filter(PluginValues.category == category)\
|
|
||||||
.filter(PluginValues.key == key) \
|
.filter(PluginValues.key == key) \
|
||||||
.one_or_none()
|
.one_or_none()
|
||||||
# ChannelValue exists, update
|
# ChannelValue exists, update
|
||||||
@ -299,7 +295,7 @@ class SpiceDB(object):
|
|||||||
session.commit()
|
session.commit()
|
||||||
# DNE - Insert
|
# DNE - Insert
|
||||||
else:
|
else:
|
||||||
new_pluginvalue = PluginValues(plugin=plugin, category=category, key=key, value=float(value))
|
new_pluginvalue = PluginValues(plugin=plugin, key=key, value=float(value))
|
||||||
session.add(new_pluginvalue)
|
session.add(new_pluginvalue)
|
||||||
session.commit()
|
session.commit()
|
||||||
except SQLAlchemyError:
|
except SQLAlchemyError:
|
||||||
@ -308,7 +304,7 @@ class SpiceDB(object):
|
|||||||
finally:
|
finally:
|
||||||
session.close()
|
session.close()
|
||||||
|
|
||||||
def adjust_plugin_list(self, plugin, key, entries, adjustmentdirection, category='default'):
|
def adjust_plugin_list(self, plugin, key, entries, adjustmentdirection):
|
||||||
"""Sets the value for a given key to be associated with the plugin."""
|
"""Sets the value for a given key to be associated with the plugin."""
|
||||||
plugin = Identifier(plugin).lower()
|
plugin = Identifier(plugin).lower()
|
||||||
if not isinstance(entries, list):
|
if not isinstance(entries, list):
|
||||||
@ -318,7 +314,6 @@ class SpiceDB(object):
|
|||||||
try:
|
try:
|
||||||
result = session.query(PluginValues) \
|
result = session.query(PluginValues) \
|
||||||
.filter(PluginValues.plugin == plugin)\
|
.filter(PluginValues.plugin == plugin)\
|
||||||
.filter(PluginValues.category == category)\
|
|
||||||
.filter(PluginValues.key == key) \
|
.filter(PluginValues.key == key) \
|
||||||
.one_or_none()
|
.one_or_none()
|
||||||
# ChannelValue exists, update
|
# ChannelValue exists, update
|
||||||
@ -343,7 +338,7 @@ class SpiceDB(object):
|
|||||||
for entry in entries:
|
for entry in entries:
|
||||||
while entry in values:
|
while entry in values:
|
||||||
values.remove(entry)
|
values.remove(entry)
|
||||||
new_pluginvalue = PluginValues(plugin=plugin, category=category, key=key, value=values)
|
new_pluginvalue = PluginValues(plugin=plugin, key=key, value=values)
|
||||||
session.add(new_pluginvalue)
|
session.add(new_pluginvalue)
|
||||||
session.commit()
|
session.commit()
|
||||||
except SQLAlchemyError:
|
except SQLAlchemyError:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user