1
0
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:
echel0n 2014-06-07 15:35:16 -07:00
parent d00d55fdfc
commit a1da7df12e
17 changed files with 67 additions and 56 deletions

View File

@ -1,4 +1,5 @@
#import sickbeard
#import psutil
#from sickbeard import db
#import os.path
#set global $title="Configuration"
@ -14,6 +15,17 @@
<h1 class="title">$title</h1>
#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">
<table class="infoTable" cellspacing="1" border="0" cellpadding="0">
@ -25,6 +37,7 @@
#end if
<font color="red">You are using BETA software</font>
</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 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>

View File

@ -343,7 +343,7 @@ class BTNCache(tvcache.TVCache):
cl.append(ci)
if cl:
myDB = self._getDB()
with self._getDB() as myDB:
myDB.mass_action(cl)
else:

View File

@ -255,7 +255,7 @@ class HDBitsCache(tvcache.TVCache):
ql.append(ci)
if ql:
myDB = self._getDB()
with self._getDB() as myDB:
myDB.mass_action(ql)
else:

View File

@ -377,7 +377,7 @@ class HDTorrentsCache(tvcache.TVCache):
cl.append(ci)
if cl:
myDB = self._getDB()
with self._getDB() as myDB:
myDB.mass_action(cl)
def _parseItem(self, item):

View File

@ -318,7 +318,7 @@ class IPTorrentsCache(tvcache.TVCache):
cl.append(ci)
if cl:
myDB = self._getDB()
with self._getDB() as myDB:
myDB.mass_action(cl)
def _parseItem(self, item):

View File

@ -455,7 +455,7 @@ class KATCache(tvcache.TVCache):
cl.append(ci)
if cl:
myDB = self._getDB()
with self._getDB() as myDB:
myDB.mass_action(cl)
def _parseItem(self, item):

View File

@ -342,7 +342,7 @@ class NewznabCache(tvcache.TVCache):
ql.append(ci)
if ql:
myDB = self._getDB()
with self._getDB() as myDB:
myDB.mass_action(ql)
else:

View File

@ -367,7 +367,7 @@ class NextGenCache(tvcache.TVCache):
cl.append(ci)
if cl:
myDB = self._getDB()
with self._getDB() as myDB:
myDB.mass_action(cl)
def _parseItem(self, item):

View File

@ -340,7 +340,7 @@ class PublicHDCache(tvcache.TVCache):
ql.append(ci)
if ql:
myDB = self._getDB()
with self._getDB() as myDB:
myDB.mass_action(ql)
def _parseItem(self, item):

View File

@ -362,7 +362,7 @@ class SCCCache(tvcache.TVCache):
cl.append(ci)
if cl:
myDB = self._getDB()
with self._getDB() as myDB:
myDB.mass_action(cl)
def _parseItem(self, item):

View File

@ -302,7 +302,7 @@ class SpeedCDCache(tvcache.TVCache):
ql.append(ci)
if ql:
myDB = self._getDB()
with self._getDB() as myDB:
myDB.mass_action(ql)
def _parseItem(self, item):

View File

@ -435,7 +435,7 @@ class ThePirateBayCache(tvcache.TVCache):
cl.append(ci)
if cl:
myDB = self._getDB()
with self._getDB() as myDB:
myDB.mass_action(cl)
def _parseItem(self, item):

View File

@ -326,7 +326,7 @@ class TorrentDayCache(tvcache.TVCache):
cl.append(ci)
if cl:
myDB = self._getDB()
with self._getDB() as myDB:
myDB.mass_action(cl)
def _parseItem(self, item):

View File

@ -321,7 +321,7 @@ class TorrentLeechCache(tvcache.TVCache):
cl.append(ci)
if cl:
myDB = self._getDB()
with self._getDB() as myDB:
myDB.mass_action(cl)
def _parseItem(self, item):

View File

@ -693,4 +693,5 @@ def fix_xem_numbering(indexer_id, indexer):
update_scene_absolute_number = False
if ql:
with db.DBConnection() as myDB:
myDB.mass_action(ql)

View File

@ -82,10 +82,9 @@ class TVCache():
if not self.shouldClearCache():
return
myDB = self._getDB()
curDate = datetime.date.today() - datetime.timedelta(weeks=1)
with self._getDB() as myDB:
myDB.action("DELETE FROM [" + self.providerID + "] WHERE time < ?", [int(time.mktime(curDate.timetuple()))])
def _getRSSData(self):
@ -127,7 +126,7 @@ class TVCache():
cl.append(ci)
if cl:
myDB = self._getDB()
with self._getDB() as myDB:
myDB.mass_action(cl)
else:
@ -194,7 +193,7 @@ class TVCache():
def _getLastUpdate(self):
myDB = self._getDB()
with self._getDB() as myDB:
sqlResults = myDB.select("SELECT time FROM lastUpdate WHERE provider = ?", [self.providerID])
if sqlResults:
@ -207,7 +206,7 @@ class TVCache():
return datetime.datetime.fromtimestamp(lastTime)
def _getLastSearch(self):
myDB = self._getDB()
with self._getDB() as myDB:
sqlResults = myDB.select("SELECT time FROM lastSearch WHERE provider = ?", [self.providerID])
if sqlResults:
@ -224,7 +223,7 @@ class TVCache():
if not toDate:
toDate = datetime.datetime.today()
myDB = self._getDB()
with self._getDB() as myDB:
myDB.upsert("lastUpdate",
{'time': int(time.mktime(toDate.timetuple()))},
{'provider': self.providerID})
@ -233,7 +232,7 @@ class TVCache():
if not toDate:
toDate = datetime.datetime.today()
myDB = self._getDB()
with self._getDB() as myDB:
myDB.upsert("lastSearch",
{'time': int(time.mktime(toDate.timetuple()))},
{'provider': self.providerID})
@ -316,8 +315,7 @@ class TVCache():
return neededEps
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.%'"
if date != None:
@ -329,10 +327,9 @@ class TVCache():
def findNeededEpisodes(self, episodes, manualSearch=False):
neededEps = {}
cacheDB = self._getDB()
for epObj in episodes:
sqlResults = cacheDB.select(
with self._getDB() as myDB:
sqlResults = myDB.select(
"SELECT * FROM [" + self.providerID + "] WHERE indexerid = ? AND season = ? AND episodes LIKE ?",
[epObj.show.indexerid, epObj.season, "%|" + str(epObj.episode) + "|%"])