Fix embydb

This commit is contained in:
tomkat83 2016-02-10 11:00:32 +01:00
parent 75644de696
commit 97b8083562
4 changed files with 24 additions and 26 deletions

View file

@ -2,12 +2,30 @@
#################################################################################################
import utils
from utils import logging, kodiSQL
#################################################################################################
@utils.logging
class GetEmbyDB():
"""
Usage: with GetEmbyDB() as emby_db:
do stuff with emby_db
On exiting "with" (no matter what), commits get automatically committed
and the db gets closed
"""
def __enter__(self):
self.embyconn = kodiSQL('emby')
self.emby_db = Embydb_Functions(self.embyconn.cursor())
return self.emby_db
def __exit__(self, type, value, traceback):
self.embyconn.commit()
self.embyconn.close()
@logging
class Embydb_Functions():
def __init__(self, embycursor):

View file

@ -386,7 +386,7 @@ def getThemeMedia():
return
# Get every user view Id
with utils.GetEmbyDB() as emby_db:
with embydb.GetEmbyDB() as emby_db:
viewids = emby_db.getViews()
# Get Ids with Theme Videos

View file

@ -276,7 +276,7 @@ class LibrarySync(threading.Thread):
# Get all PMS items already saved in Kodi
# Also get checksums of every Plex items already saved in Kodi
allKodiElementsId = {}
with utils.GetEmbyDB() as emby_db:
with embydb.GetEmbyDB() as emby_db:
for itemtype in PlexFunctions.EmbyItemtypes():
try:
allKodiElementsId.update(
@ -733,7 +733,7 @@ class LibrarySync(threading.Thread):
self.allKodiElementsId = {}
if self.compare:
with utils.GetEmbyDB() as emby_db:
with embydb.GetEmbyDB() as emby_db:
# Get movies from Plex server
# Pull the list of movies and boxsets in Kodi
try:
@ -850,7 +850,7 @@ class LibrarySync(threading.Thread):
self.allKodiElementsId = {}
if self.compare:
with utils.GetEmbyDB() as emby_db:
with embydb.GetEmbyDB() as emby_db:
# Get movies from Plex server
# Pull the list of TV shows already in Kodi
try:

View file

@ -19,32 +19,12 @@ import xbmcaddon
import xbmcgui
import xbmcvfs
import embydb_functions as embydb
#################################################################################################
addonName = xbmcaddon.Addon().getAddonInfo('name')
class GetEmbyDB():
"""
Usage: with GetEmbyDB() as emby_db:
do stuff with emby_db
On exiting "with" (no matter what), commits get automatically committed
and the db gets closed
"""
def __enter__(self):
self.embyconn = kodiSQL('emby')
self.emby_db = embydb.Embydb_Functions(self.embyconn.cursor())
return self.emby_db
def __exit__(self, type, value, traceback):
self.embyconn.commit()
self.embyconn.close()
def LogTime(func):
"""
Decorator for functions and methods to log the time it took to run the code