def add_gesture(cls, name, gesture, action): id_app = gestures._get_id_from_name(name) cmd = "DELETE FROM gestures WHERE id_app = ? AND gesture = ?" db.q(cmd, (str(id_app), gesture)) cmd = "INSERT INTO gestures (id_app, gesture, action) VALUES (?,?,?)" db.q(cmd, (str(id_app), gesture, action))
def remove_app(cls, name): app_id = gestures._get_id_from_name(name) print name, app_id cmd = "DELETE FROM apps WHERE id = ?" db.q(cmd, (app_id, )) cmd = "DELETE FROM gestures WHERE id_app = ?" db.q(cmd, (app_id, ))
def remove_app(cls, name): app_id = gestures._get_id_from_name(name) print name, app_id cmd = "DELETE FROM apps WHERE id = ?" db.q(cmd, (app_id,)) cmd = "DELETE FROM gestures WHERE id_app = ?" db.q(cmd, (app_id,))
def find_gesture(cls, name, gesture): cmd = """ SELECT action FROM apps LEFT JOIN gestures ON apps.id = gestures.id_app WHERE (apps.name = ? OR apps.name = ?) AND gesture = ? """ return db.q(cmd, (str(name[0]), str(name[1]), str(gesture))).fetchall()
def find_gesture(cls, name, gesture): cmd = """ SELECT action FROM apps LEFT JOIN gestures ON apps.id = gestures.id_app WHERE (apps.name = ? OR apps.name = ?) AND gesture = ? """ return db.q(cmd, (str(name[0]),str(name[1]),str(gesture))).fetchall()
def get_app_gestures(cls, name): id_app = gestures._get_id_from_name(name) cmd = "SELECT * FROM gestures WHERE id_app = ?" return db.q( cmd, (str(id_app)), ).fetchall()
def _get_id_from_name(cls, name): cmd = "SELECT * FROM apps WHERE name = ?" r = db.q(cmd, (name,)).fetchall() if r == []: return 0 else: return r[0]['id']
def _get_id_from_name(cls, name): cmd = "SELECT * FROM apps WHERE name = ?" r = db.q(cmd, (name, )).fetchall() if r == []: return 0 else: return r[0]['id']
def get(cls, key): cmd = "SELECT * FROM settings WHERE key = ?" r = db.q(cmd, (key,)).fetchall() if len(r) == 0: return False from types import NoneType if type(r[0]) is NoneType: return '' else: return r[0]['value']
def get(cls, key): cmd = "SELECT * FROM settings WHERE key = ?" r = db.q(cmd, (key, )).fetchall() if len(r) == 0: return False from types import NoneType if type(r[0]) is NoneType: return '' else: return r[0]['value']
def add_app(cls, name): cmd = "INSERT INTO apps (name) VALUES(?)" db.q(cmd, (name,))
def get_apps(cls): cmd = "SELECT * FROM apps" r = db.q(cmd).fetchall() return r
def set(cls, key, value): k = cls.get(key) if k or k == '': db.q("UPDATE settings SET value = ? WHERE key = ?", (value, key)) else: db.q("INSERT INTO settings VALUES(?,?)", (key, value))
def add_app(cls, name): cmd = "INSERT INTO apps (name) VALUES(?)" db.q(cmd, (name, ))
def get_app_gestures(cls, name): id_app = gestures._get_id_from_name(name) cmd = "SELECT * FROM gestures WHERE id_app = ?" return db.q(cmd, (str(id_app)),).fetchall()
def delete(cls, key): cmd = "DELETE FROM settings WHERE key = ?" db.q(cmd, (key,))
def delete(cls, key): cmd = "DELETE FROM settings WHERE key = ?" db.q(cmd, (key, ))