diff options
Diffstat (limited to 'abs/core/LinHES-system/myth_mtc.py')
-rwxr-xr-x | abs/core/LinHES-system/myth_mtc.py | 14 |
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) - |