From 0a759a5c99085665905a76637dc257cb15902975 Mon Sep 17 00:00:00 2001 From: James Meyer Date: Sun, 25 Dec 2011 16:45:19 -0600 Subject: myth_mtc.py: Fix path for backup and restore jobs. All encase db calls in try/except to avoid the script failing when the bindings cannot connect refs #804 --- abs/core/LinHES-system/myth_mtc.py | 59 ++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/abs/core/LinHES-system/myth_mtc.py b/abs/core/LinHES-system/myth_mtc.py index 1ed6c88..6fd53a7 100755 --- a/abs/core/LinHES-system/myth_mtc.py +++ b/abs/core/LinHES-system/myth_mtc.py @@ -10,18 +10,22 @@ import datetime,time -#try: -from MythTV import MythBE -mythtv = MythBE() -#except: -# mythtv = None +try: + from MythTV import MythBE + mythtv = MythBE() +except: + mythtv = None #print mythtv.db.getSetting( 'Theme', socket.gethostname()) def optimize(): - cursor = mythtv.db.cursor() - cursor.execute("SHOW tables") - result = cursor.fetchall() + try: + cursor = mythtv.db.cursor() + cursor.execute("SHOW tables") + result = cursor.fetchall() + except: + print "Problem getting tables from database" + return ops=["REPAIR","OPTIMIZE","ANALYZE"] for row in result: ctable=row[0] @@ -32,7 +36,10 @@ def optimize(): def upcoming_check(): - upcoming = mythtv.getUpcomingRecordings() + try: + upcoming = mythtv.getUpcomingRecordings() + except: + return True try: show=str(upcoming[0]) show=show.strip() @@ -52,10 +59,14 @@ def upcoming_check(): def schemalock_check(): - c = mythtv.db.cursor() - c.execute("select count(*) from schemalock") - results=c.fetchone() - schemalock=results[0] + try: + c = mythtv.db.cursor() + c.execute("select count(*) from schemalock") + results=c.fetchone() + schemalock=results[0] + except: + return True + if schemalock == 0: return True else: @@ -63,9 +74,12 @@ def schemalock_check(): return False def job_check(): - c = mythtv.db.cursor() - c.execute("select count(*) from jobqueue where status = 4") - results=c.fetchone() + try: + c = mythtv.db.cursor() + c.execute("select count(*) from jobqueue where status = 4") + results=c.fetchone() + except: + return True jobs= results[0] if jobs == 0 : return True @@ -75,9 +89,12 @@ def job_check(): def in_use(): - c = mythtv.db.cursor() - c.execute("select count(*) from inuseprograms") - results=c.fetchone() + try: + c = mythtv.db.cursor() + c.execute("select count(*) from inuseprograms") + results=c.fetchone() + except: + return True prginuse=results[0] if prginuse == 0 : return True @@ -119,10 +136,10 @@ def run_stuff(): optimize() print "Running backup" - os.system('/usr/LH/bin/backup_job') + os.system('/usr/LH/bin/lh_system_backup_job') print "Running system_update" - os.system('/usr/LH/bin/update_system') + os.system('/usr/LH/bin/lh_system_host_update') continue_loop=False else: continue_loop=True -- cgit v0.12