summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-system/myth_mtc.py
diff options
context:
space:
mode:
authorBritney Fransen <brfransen@gmail.com>2014-09-26 18:35:17 (GMT)
committerBritney Fransen <brfransen@gmail.com>2014-09-26 18:35:17 (GMT)
commit38f5e9792089593ffefef6155b569b302657a664 (patch)
treef47d08f042845f6b87a5255f7c15196e0c620f4f /abs/core/LinHES-system/myth_mtc.py
parent1620aea86b123aec654f9f19cb0502379b441118 (diff)
downloadlinhes_pkgbuild-38f5e9792089593ffefef6155b569b302657a664.zip
linhes_pkgbuild-38f5e9792089593ffefef6155b569b302657a664.tar.gz
linhes_pkgbuild-38f5e9792089593ffefef6155b569b302657a664.tar.bz2
LinHES-system: myth_mtc.py: remove items from inuseprograms that are older than 4 hours
mythtv housekeeper does this daily, but sometimes that isn't often enough for the mtc script
Diffstat (limited to 'abs/core/LinHES-system/myth_mtc.py')
-rwxr-xr-xabs/core/LinHES-system/myth_mtc.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/abs/core/LinHES-system/myth_mtc.py b/abs/core/LinHES-system/myth_mtc.py
index db6b42a..b1ec75d 100755
--- a/abs/core/LinHES-system/myth_mtc.py
+++ b/abs/core/LinHES-system/myth_mtc.py
@@ -29,7 +29,7 @@ def optimize():
cursor.execute("SHOW tables")
result = cursor.fetchall()
except:
- print " Problem getting tables from database"
+ print "\n%s Problem getting tables from the database" %(get_timestamp())
return
ops=["REPAIR","OPTIMIZE","ANALYZE"]
for row in result:
@@ -39,6 +39,16 @@ def optimize():
cmd= "%s table %s" %(op,ctable)
cursor.execute(cmd)
+def cleanup_inuseprograms():
+ fourHoursAgo=datetime.datetime.today() - datetime.timedelta(hours=4)
+ cmd="DELETE FROM inuseprograms WHERE lastupdatetime < '%s';" %fourHoursAgo
+ try:
+ cursor = mythtv.db.cursor()
+ cursor.execute(cmd)
+ except:
+ print "\n%s Problem cleaning inuseprograms in database" %(get_timestamp())
+
+
def bail_if_another_is_running():
cmd = shlex.split("pgrep -u {} -f {}".format(os.getuid(), __file__))
pids = subprocess.check_output(cmd).strip().split('\n')
@@ -74,6 +84,7 @@ bail_if_another_is_running()
starttime=time.time()
ctin=True
while ctin:
+ cleanup_inuseprograms()
ctin=run_stuff()
if ctin:
print "\n%s Waiting 10 minutes before trying again." %(get_timestamp())
@@ -84,4 +95,3 @@ while ctin:
ctin = False
print "\n%s Time Exceeded 50 minutes. Quitting.)" %(get_timestamp())
exit(1)
-