diff options
author | Britney Fransen <brfransen@gmail.com> | 2014-09-26 18:35:17 (GMT) |
---|---|---|
committer | Britney Fransen <brfransen@gmail.com> | 2014-09-26 18:35:17 (GMT) |
commit | 38f5e9792089593ffefef6155b569b302657a664 (patch) | |
tree | f47d08f042845f6b87a5255f7c15196e0c620f4f /abs/core/LinHES-system | |
parent | 1620aea86b123aec654f9f19cb0502379b441118 (diff) | |
download | linhes_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')
-rwxr-xr-x | abs/core/LinHES-system/PKGBUILD | 4 | ||||
-rwxr-xr-x | abs/core/LinHES-system/myth_mtc.py | 14 |
2 files changed, 14 insertions, 4 deletions
diff --git a/abs/core/LinHES-system/PKGBUILD b/abs/core/LinHES-system/PKGBUILD index 04d0d50..ad23218 100755 --- a/abs/core/LinHES-system/PKGBUILD +++ b/abs/core/LinHES-system/PKGBUILD @@ -1,6 +1,6 @@ pkgname=LinHES-system pkgver=8.2 -pkgrel=2 +pkgrel=3 arch=('i686' 'x86_64') install=system.install pkgdesc="Everything that makes LinHES an automated system" @@ -79,7 +79,7 @@ md5sums=('a10cb96850951ae835c46f41f92463b2' 'de32a1c50101265dd7f6ca5037f7a26a' '301884fb60521627fffd1160b2cf5181' '76b2637cac0452b3acdbeeb4e8a5474b' - '8dcdd10f5551a45d6e8681800fafe7e0' + '0149e77a12d30f1050dd3990f6f1f123' 'dc3eef2a624754e16805d72bbe488b67' '617af86b901538817ebdcaf646248dc5' '542e670e78d117657f93141e9689f54d' 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) - |