Fix kodidb_function.py classes
This commit is contained in:
parent
b42a9e2062
commit
5c944cd092
2 changed files with 12 additions and 6 deletions
|
@ -48,7 +48,7 @@ class Items(object):
|
||||||
self.kodiconn = kodi_sql('video')
|
self.kodiconn = kodi_sql('video')
|
||||||
self.kodicursor = self.kodiconn.cursor()
|
self.kodicursor = self.kodiconn.cursor()
|
||||||
self.plex_db = plexdb.Plex_DB_Functions(self.plexcursor)
|
self.plex_db = plexdb.Plex_DB_Functions(self.plexcursor)
|
||||||
self.kodi_db = kodidb.Kodidb_Functions(self.kodicursor)
|
self.kodi_db = kodidb.KodiDBMethods(self.kodicursor)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||||
|
@ -1250,7 +1250,7 @@ class Music(Items):
|
||||||
self.kodiconn = kodi_sql('music')
|
self.kodiconn = kodi_sql('music')
|
||||||
self.kodicursor = self.kodiconn.cursor()
|
self.kodicursor = self.kodiconn.cursor()
|
||||||
self.plex_db = plexdb.Plex_DB_Functions(self.plexcursor)
|
self.plex_db = plexdb.Plex_DB_Functions(self.plexcursor)
|
||||||
self.kodi_db = kodidb.Kodidb_Functions(self.kodicursor)
|
self.kodi_db = kodidb.KodiDBMethods(self.kodicursor)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@catch_exceptions(warnuser=True)
|
@catch_exceptions(warnuser=True)
|
||||||
|
|
|
@ -15,7 +15,7 @@ LOG = getLogger("PLEX." + __name__)
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
|
||||||
class GetKodiDB():
|
class GetKodiDB(object):
|
||||||
"""
|
"""
|
||||||
Usage: with GetKodiDB(db_type) as kodi_db:
|
Usage: with GetKodiDB(db_type) as kodi_db:
|
||||||
do stuff with kodi_db
|
do stuff with kodi_db
|
||||||
|
@ -27,19 +27,25 @@ class GetKodiDB():
|
||||||
and the db gets closed
|
and the db gets closed
|
||||||
"""
|
"""
|
||||||
def __init__(self, db_type):
|
def __init__(self, db_type):
|
||||||
|
self.kodiconn = None
|
||||||
self.db_type = db_type
|
self.db_type = db_type
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
self.kodiconn = kodi_sql(self.db_type)
|
self.kodiconn = kodi_sql(self.db_type)
|
||||||
kodi_db = Kodidb_Functions(self.kodiconn.cursor())
|
kodi_db = KodiDBMethods(self.kodiconn.cursor())
|
||||||
return kodi_db
|
return kodi_db
|
||||||
|
|
||||||
def __exit__(self, type, value, traceback):
|
def __exit__(self, typus, value, traceback):
|
||||||
self.kodiconn.commit()
|
self.kodiconn.commit()
|
||||||
self.kodiconn.close()
|
self.kodiconn.close()
|
||||||
|
|
||||||
|
|
||||||
class Kodidb_Functions():
|
class KodiDBMethods(object):
|
||||||
|
"""
|
||||||
|
Best used indirectly with another Class GetKodiDB:
|
||||||
|
with GetKodiDB(db_type) as kodi_db:
|
||||||
|
kodi_db.method()
|
||||||
|
"""
|
||||||
def __init__(self, cursor):
|
def __init__(self, cursor):
|
||||||
self.cursor = cursor
|
self.cursor = cursor
|
||||||
self.artwork = artwork.Artwork()
|
self.artwork = artwork.Artwork()
|
||||||
|
|
Loading…
Reference in a new issue