mirror of
https://github.com/moparisthebest/SickRage
synced 2024-12-13 19:42:20 -05:00
Fixes for DB issues
This commit is contained in:
parent
d00d55fdfc
commit
a1da7df12e
@ -1,4 +1,5 @@
|
|||||||
#import sickbeard
|
#import sickbeard
|
||||||
|
#import psutil
|
||||||
#from sickbeard import db
|
#from sickbeard import db
|
||||||
#import os.path
|
#import os.path
|
||||||
#set global $title="Configuration"
|
#set global $title="Configuration"
|
||||||
@ -14,6 +15,17 @@
|
|||||||
<h1 class="title">$title</h1>
|
<h1 class="title">$title</h1>
|
||||||
#end if
|
#end if
|
||||||
|
|
||||||
|
#set cpu_usage = $psutil.cpu_percent()
|
||||||
|
#set ram = $psutil.phymem_usage()
|
||||||
|
#set ram_total = $ram.total / 2**20
|
||||||
|
#set ram_used = $ram.used / 2**20
|
||||||
|
#set ram_free = $ram.free / 2**20
|
||||||
|
#set ram_percent_used = $ram.percent
|
||||||
|
#set disk = $psutil.disk_usage('/')
|
||||||
|
#set disk_total = $disk.total / 2**30
|
||||||
|
#set disk_used = $disk.used / 2**30
|
||||||
|
#set disk_free = $disk.free / 2**30
|
||||||
|
#set disk_percent_used = $disk.percent
|
||||||
|
|
||||||
<div id="summary" class="align-left">
|
<div id="summary" class="align-left">
|
||||||
<table class="infoTable" cellspacing="1" border="0" cellpadding="0">
|
<table class="infoTable" cellspacing="1" border="0" cellpadding="0">
|
||||||
@ -25,6 +37,7 @@
|
|||||||
#end if
|
#end if
|
||||||
<font color="red">You are using BETA software</font>
|
<font color="red">You are using BETA software</font>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
|
<tr><td class="infoTableHeader">Memory Used: </td><td class="infoTableCell">$ram_percent_used</td></tr>
|
||||||
<tr><td class="infoTableHeader">SR Config file: </td><td class="infoTableCell">$sickbeard.CONFIG_FILE</td></tr>
|
<tr><td class="infoTableHeader">SR Config file: </td><td class="infoTableCell">$sickbeard.CONFIG_FILE</td></tr>
|
||||||
<tr><td class="infoTableHeader">SR Database file: </td><td class="infoTableCell">$db.dbFilename()</td></tr>
|
<tr><td class="infoTableHeader">SR Database file: </td><td class="infoTableCell">$db.dbFilename()</td></tr>
|
||||||
<tr><td class="infoTableHeader">SR Cache Dir: </td><td class="infoTableCell">$sickbeard.CACHE_DIR</td></tr>
|
<tr><td class="infoTableHeader">SR Cache Dir: </td><td class="infoTableCell">$sickbeard.CACHE_DIR</td></tr>
|
||||||
|
@ -343,8 +343,8 @@ class BTNCache(tvcache.TVCache):
|
|||||||
cl.append(ci)
|
cl.append(ci)
|
||||||
|
|
||||||
if cl:
|
if cl:
|
||||||
myDB = self._getDB()
|
with self._getDB() as myDB:
|
||||||
myDB.mass_action(cl)
|
myDB.mass_action(cl)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise AuthException(
|
raise AuthException(
|
||||||
|
@ -255,8 +255,8 @@ class HDBitsCache(tvcache.TVCache):
|
|||||||
ql.append(ci)
|
ql.append(ci)
|
||||||
|
|
||||||
if ql:
|
if ql:
|
||||||
myDB = self._getDB()
|
with self._getDB() as myDB:
|
||||||
myDB.mass_action(ql)
|
myDB.mass_action(ql)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise exceptions.AuthException(
|
raise exceptions.AuthException(
|
||||||
|
@ -377,8 +377,8 @@ class HDTorrentsCache(tvcache.TVCache):
|
|||||||
cl.append(ci)
|
cl.append(ci)
|
||||||
|
|
||||||
if cl:
|
if cl:
|
||||||
myDB = self._getDB()
|
with self._getDB() as myDB:
|
||||||
myDB.mass_action(cl)
|
myDB.mass_action(cl)
|
||||||
|
|
||||||
def _parseItem(self, item):
|
def _parseItem(self, item):
|
||||||
|
|
||||||
|
@ -318,8 +318,8 @@ class IPTorrentsCache(tvcache.TVCache):
|
|||||||
cl.append(ci)
|
cl.append(ci)
|
||||||
|
|
||||||
if cl:
|
if cl:
|
||||||
myDB = self._getDB()
|
with self._getDB() as myDB:
|
||||||
myDB.mass_action(cl)
|
myDB.mass_action(cl)
|
||||||
|
|
||||||
def _parseItem(self, item):
|
def _parseItem(self, item):
|
||||||
|
|
||||||
|
@ -455,8 +455,8 @@ class KATCache(tvcache.TVCache):
|
|||||||
cl.append(ci)
|
cl.append(ci)
|
||||||
|
|
||||||
if cl:
|
if cl:
|
||||||
myDB = self._getDB()
|
with self._getDB() as myDB:
|
||||||
myDB.mass_action(cl)
|
myDB.mass_action(cl)
|
||||||
|
|
||||||
def _parseItem(self, item):
|
def _parseItem(self, item):
|
||||||
|
|
||||||
|
@ -342,8 +342,8 @@ class NewznabCache(tvcache.TVCache):
|
|||||||
ql.append(ci)
|
ql.append(ci)
|
||||||
|
|
||||||
if ql:
|
if ql:
|
||||||
myDB = self._getDB()
|
with self._getDB() as myDB:
|
||||||
myDB.mass_action(ql)
|
myDB.mass_action(ql)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise AuthException(
|
raise AuthException(
|
||||||
|
@ -367,8 +367,8 @@ class NextGenCache(tvcache.TVCache):
|
|||||||
cl.append(ci)
|
cl.append(ci)
|
||||||
|
|
||||||
if cl:
|
if cl:
|
||||||
myDB = self._getDB()
|
with self._getDB() as myDB:
|
||||||
myDB.mass_action(cl)
|
myDB.mass_action(cl)
|
||||||
|
|
||||||
def _parseItem(self, item):
|
def _parseItem(self, item):
|
||||||
|
|
||||||
|
@ -340,8 +340,8 @@ class PublicHDCache(tvcache.TVCache):
|
|||||||
ql.append(ci)
|
ql.append(ci)
|
||||||
|
|
||||||
if ql:
|
if ql:
|
||||||
myDB = self._getDB()
|
with self._getDB() as myDB:
|
||||||
myDB.mass_action(ql)
|
myDB.mass_action(ql)
|
||||||
|
|
||||||
def _parseItem(self, item):
|
def _parseItem(self, item):
|
||||||
|
|
||||||
|
@ -362,8 +362,8 @@ class SCCCache(tvcache.TVCache):
|
|||||||
cl.append(ci)
|
cl.append(ci)
|
||||||
|
|
||||||
if cl:
|
if cl:
|
||||||
myDB = self._getDB()
|
with self._getDB() as myDB:
|
||||||
myDB.mass_action(cl)
|
myDB.mass_action(cl)
|
||||||
|
|
||||||
def _parseItem(self, item):
|
def _parseItem(self, item):
|
||||||
|
|
||||||
|
@ -302,8 +302,8 @@ class SpeedCDCache(tvcache.TVCache):
|
|||||||
ql.append(ci)
|
ql.append(ci)
|
||||||
|
|
||||||
if ql:
|
if ql:
|
||||||
myDB = self._getDB()
|
with self._getDB() as myDB:
|
||||||
myDB.mass_action(ql)
|
myDB.mass_action(ql)
|
||||||
|
|
||||||
def _parseItem(self, item):
|
def _parseItem(self, item):
|
||||||
|
|
||||||
|
@ -435,8 +435,8 @@ class ThePirateBayCache(tvcache.TVCache):
|
|||||||
cl.append(ci)
|
cl.append(ci)
|
||||||
|
|
||||||
if cl:
|
if cl:
|
||||||
myDB = self._getDB()
|
with self._getDB() as myDB:
|
||||||
myDB.mass_action(cl)
|
myDB.mass_action(cl)
|
||||||
|
|
||||||
def _parseItem(self, item):
|
def _parseItem(self, item):
|
||||||
|
|
||||||
|
@ -326,8 +326,8 @@ class TorrentDayCache(tvcache.TVCache):
|
|||||||
cl.append(ci)
|
cl.append(ci)
|
||||||
|
|
||||||
if cl:
|
if cl:
|
||||||
myDB = self._getDB()
|
with self._getDB() as myDB:
|
||||||
myDB.mass_action(cl)
|
myDB.mass_action(cl)
|
||||||
|
|
||||||
def _parseItem(self, item):
|
def _parseItem(self, item):
|
||||||
|
|
||||||
|
@ -321,8 +321,8 @@ class TorrentLeechCache(tvcache.TVCache):
|
|||||||
cl.append(ci)
|
cl.append(ci)
|
||||||
|
|
||||||
if cl:
|
if cl:
|
||||||
myDB = self._getDB()
|
with self._getDB() as myDB:
|
||||||
myDB.mass_action(cl)
|
myDB.mass_action(cl)
|
||||||
|
|
||||||
def _parseItem(self, item):
|
def _parseItem(self, item):
|
||||||
|
|
||||||
|
@ -693,4 +693,5 @@ def fix_xem_numbering(indexer_id, indexer):
|
|||||||
update_scene_absolute_number = False
|
update_scene_absolute_number = False
|
||||||
|
|
||||||
if ql:
|
if ql:
|
||||||
myDB.mass_action(ql)
|
with db.DBConnection() as myDB:
|
||||||
|
myDB.mass_action(ql)
|
@ -203,7 +203,7 @@ class TVShow(object):
|
|||||||
if self.is_anime and absolute_number and not season and not episode:
|
if self.is_anime and absolute_number and not season and not episode:
|
||||||
with db.DBConnection() as myDB:
|
with db.DBConnection() as myDB:
|
||||||
sql = "SELECT * FROM tv_episodes WHERE showid = ? and absolute_number = ? and season != 0"
|
sql = "SELECT * FROM tv_episodes WHERE showid = ? and absolute_number = ? and season != 0"
|
||||||
sqlResults = myDB.select(sql, [self.indexerid, absolute_number])
|
sqlResults = myDB.select(sql, [self.indexerid, absolute_number])
|
||||||
|
|
||||||
if len(sqlResults) == 1:
|
if len(sqlResults) == 1:
|
||||||
episode = int(sqlResults[0]["episode"])
|
episode = int(sqlResults[0]["episode"])
|
||||||
|
@ -82,11 +82,10 @@ class TVCache():
|
|||||||
if not self.shouldClearCache():
|
if not self.shouldClearCache():
|
||||||
return
|
return
|
||||||
|
|
||||||
myDB = self._getDB()
|
|
||||||
|
|
||||||
curDate = datetime.date.today() - datetime.timedelta(weeks=1)
|
curDate = datetime.date.today() - datetime.timedelta(weeks=1)
|
||||||
|
|
||||||
myDB.action("DELETE FROM [" + self.providerID + "] WHERE time < ?", [int(time.mktime(curDate.timetuple()))])
|
with self._getDB() as myDB:
|
||||||
|
myDB.action("DELETE FROM [" + self.providerID + "] WHERE time < ?", [int(time.mktime(curDate.timetuple()))])
|
||||||
|
|
||||||
def _getRSSData(self):
|
def _getRSSData(self):
|
||||||
|
|
||||||
@ -127,8 +126,8 @@ class TVCache():
|
|||||||
cl.append(ci)
|
cl.append(ci)
|
||||||
|
|
||||||
if cl:
|
if cl:
|
||||||
myDB = self._getDB()
|
with self._getDB() as myDB:
|
||||||
myDB.mass_action(cl)
|
myDB.mass_action(cl)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise AuthException(
|
raise AuthException(
|
||||||
@ -194,8 +193,8 @@ class TVCache():
|
|||||||
|
|
||||||
|
|
||||||
def _getLastUpdate(self):
|
def _getLastUpdate(self):
|
||||||
myDB = self._getDB()
|
with self._getDB() as myDB:
|
||||||
sqlResults = myDB.select("SELECT time FROM lastUpdate WHERE provider = ?", [self.providerID])
|
sqlResults = myDB.select("SELECT time FROM lastUpdate WHERE provider = ?", [self.providerID])
|
||||||
|
|
||||||
if sqlResults:
|
if sqlResults:
|
||||||
lastTime = int(sqlResults[0]["time"])
|
lastTime = int(sqlResults[0]["time"])
|
||||||
@ -207,8 +206,8 @@ class TVCache():
|
|||||||
return datetime.datetime.fromtimestamp(lastTime)
|
return datetime.datetime.fromtimestamp(lastTime)
|
||||||
|
|
||||||
def _getLastSearch(self):
|
def _getLastSearch(self):
|
||||||
myDB = self._getDB()
|
with self._getDB() as myDB:
|
||||||
sqlResults = myDB.select("SELECT time FROM lastSearch WHERE provider = ?", [self.providerID])
|
sqlResults = myDB.select("SELECT time FROM lastSearch WHERE provider = ?", [self.providerID])
|
||||||
|
|
||||||
if sqlResults:
|
if sqlResults:
|
||||||
lastTime = int(sqlResults[0]["time"])
|
lastTime = int(sqlResults[0]["time"])
|
||||||
@ -224,19 +223,19 @@ class TVCache():
|
|||||||
if not toDate:
|
if not toDate:
|
||||||
toDate = datetime.datetime.today()
|
toDate = datetime.datetime.today()
|
||||||
|
|
||||||
myDB = self._getDB()
|
with self._getDB() as myDB:
|
||||||
myDB.upsert("lastUpdate",
|
myDB.upsert("lastUpdate",
|
||||||
{'time': int(time.mktime(toDate.timetuple()))},
|
{'time': int(time.mktime(toDate.timetuple()))},
|
||||||
{'provider': self.providerID})
|
{'provider': self.providerID})
|
||||||
|
|
||||||
def setLastSearch(self, toDate=None):
|
def setLastSearch(self, toDate=None):
|
||||||
if not toDate:
|
if not toDate:
|
||||||
toDate = datetime.datetime.today()
|
toDate = datetime.datetime.today()
|
||||||
|
|
||||||
myDB = self._getDB()
|
with self._getDB() as myDB:
|
||||||
myDB.upsert("lastSearch",
|
myDB.upsert("lastSearch",
|
||||||
{'time': int(time.mktime(toDate.timetuple()))},
|
{'time': int(time.mktime(toDate.timetuple()))},
|
||||||
{'provider': self.providerID})
|
{'provider': self.providerID})
|
||||||
|
|
||||||
lastUpdate = property(_getLastUpdate)
|
lastUpdate = property(_getLastUpdate)
|
||||||
lastSearch = property(_getLastSearch)
|
lastSearch = property(_getLastSearch)
|
||||||
@ -316,25 +315,23 @@ class TVCache():
|
|||||||
return neededEps
|
return neededEps
|
||||||
|
|
||||||
def listPropers(self, date=None, delimiter="."):
|
def listPropers(self, date=None, delimiter="."):
|
||||||
myDB = self._getDB()
|
with self._getDB() as myDB:
|
||||||
|
sql = "SELECT * FROM [" + self.providerID + "] WHERE name LIKE '%.PROPER.%' OR name LIKE '%.REPACK.%'"
|
||||||
|
|
||||||
sql = "SELECT * FROM [" + self.providerID + "] WHERE name LIKE '%.PROPER.%' OR name LIKE '%.REPACK.%'"
|
if date != None:
|
||||||
|
sql += " AND time >= " + str(int(time.mktime(date.timetuple())))
|
||||||
|
|
||||||
if date != None:
|
return filter(lambda x: x['indexerid'] != 0, myDB.select(sql))
|
||||||
sql += " AND time >= " + str(int(time.mktime(date.timetuple())))
|
|
||||||
|
|
||||||
return filter(lambda x: x['indexerid'] != 0, myDB.select(sql))
|
|
||||||
|
|
||||||
|
|
||||||
def findNeededEpisodes(self, episodes, manualSearch=False):
|
def findNeededEpisodes(self, episodes, manualSearch=False):
|
||||||
neededEps = {}
|
neededEps = {}
|
||||||
|
|
||||||
cacheDB = self._getDB()
|
|
||||||
|
|
||||||
for epObj in episodes:
|
for epObj in episodes:
|
||||||
sqlResults = cacheDB.select(
|
with self._getDB() as myDB:
|
||||||
"SELECT * FROM [" + self.providerID + "] WHERE indexerid = ? AND season = ? AND episodes LIKE ?",
|
sqlResults = myDB.select(
|
||||||
[epObj.show.indexerid, epObj.season, "%|" + str(epObj.episode) + "|%"])
|
"SELECT * FROM [" + self.providerID + "] WHERE indexerid = ? AND season = ? AND episodes LIKE ?",
|
||||||
|
[epObj.show.indexerid, epObj.season, "%|" + str(epObj.episode) + "|%"])
|
||||||
|
|
||||||
# for each cache entry
|
# for each cache entry
|
||||||
for curResult in sqlResults:
|
for curResult in sqlResults:
|
||||||
|
Loading…
Reference in New Issue
Block a user