summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-system/myth_mtc.py
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2013-12-03 22:17:25 (GMT)
committerJames Meyer <james.meyer@operamail.com>2013-12-03 22:17:25 (GMT)
commitd5370e5d6fe083e14866c5b5d1728fea4f9879bc (patch)
tree23a53195111dc6a098d17308486440899ecf0341 /abs/core/LinHES-system/myth_mtc.py
parentba4ef74d5cd87084bd5c328fbbc254208e5e84a6 (diff)
downloadlinhes_pkgbuild-d5370e5d6fe083e14866c5b5d1728fea4f9879bc.zip
linhes_pkgbuild-d5370e5d6fe083e14866c5b5d1728fea4f9879bc.tar.gz
linhes_pkgbuild-d5370e5d6fe083e14866c5b5d1728fea4f9879bc.tar.bz2
LinHES-system: systembackup
lh_system_backup_job. Fix sed problem when adjusting the meny xml . Changed > to -gt to force bash int test instead of string add timestamps to myth_mtc.py and general cleanup
Diffstat (limited to 'abs/core/LinHES-system/myth_mtc.py')
-rwxr-xr-xabs/core/LinHES-system/myth_mtc.py39
1 files changed, 28 insertions, 11 deletions
diff --git a/abs/core/LinHES-system/myth_mtc.py b/abs/core/LinHES-system/myth_mtc.py
index a5f02a0..2c1fd14 100755
--- a/abs/core/LinHES-system/myth_mtc.py
+++ b/abs/core/LinHES-system/myth_mtc.py
@@ -14,13 +14,21 @@ except:
#print mythtv.db.getSetting( 'Theme', socket.gethostname())
+def get_timestamp():
+ now = datetime.datetime.now()
+#date = "%s-%s-%s" %(now.year, now.month, now.day)
+ date = (now.strftime('%Y-%m-%d %H:%M'))
+ return date
+
+
def optimize():
+
try:
cursor = mythtv.db.cursor()
cursor.execute("SHOW tables")
result = cursor.fetchall()
except:
- print "Problem getting tables from database"
+ print " Problem getting tables from database"
return
ops=["REPAIR","OPTIMIZE","ANALYZE"]
for row in result:
@@ -32,6 +40,7 @@ def optimize():
def upcoming_check():
+ print " Checking for upcoming shows"
try:
upcoming = mythtv.getUpcomingRecordings()
except:
@@ -50,11 +59,12 @@ def upcoming_check():
if ( time_diff > 30) :
return True
else:
- print show , "is upcoming in " , time_diff
+ print " %s is upcoming in %s" %(show,time_diff)
return False
def schemalock_check():
+ print " Checking if schema is locked"
try:
c = mythtv.db.cursor()
c.execute("select count(*) from schemalock")
@@ -66,10 +76,11 @@ def schemalock_check():
if schemalock == 0:
return True
else:
- print "schema is locked"
+ print " schema is locked"
return False
def job_check():
+ print " Checking jobqueue"
try:
c = mythtv.db.cursor()
c.execute("select count(*) from jobqueue where status = 4")
@@ -80,11 +91,12 @@ def job_check():
if jobs == 0 :
return True
else:
- print " jobs are running"
+ print " jobs are running"
return False
def in_use():
+ print " Checking if programs are in use"
try:
c = mythtv.db.cursor()
c.execute("select count(*) from inuseprograms")
@@ -95,10 +107,11 @@ def in_use():
if prginuse == 0 :
return True
else:
- print "programs in use"
+ print " Programs in use"
return False
def mfd_check():
+ print " Checking is mythfilldatabase is running"
ps = subprocess.Popen("ps ax -o pid= -o args= ", shell=True, stdout=subprocess.PIPE)
ps_pid = ps.pid
output = ps.stdout.read()
@@ -110,7 +123,7 @@ def mfd_check():
if res:
pid = int(res[0][0])
if proc_name in res[0][1] and pid != os.getpid() and pid != ps_pid:
- print "mythfilldatabase is running"
+ print " mythfilldatabase is running"
return False
return True
@@ -118,23 +131,24 @@ def mfd_check():
def idle_check():
+ print "%s Checking idle" %(get_timestamp())
if ( upcoming_check() and schemalock_check() and job_check() and in_use() and mfd_check() ):
idle=True
- print "Myth is idle"
+ print "\n%s Myth is idle" %(get_timestamp())
else:
idle=False
- print "Myth is NOT idle"
+ print "\n%s Myth is NOT idle" %(get_timestamp())
return idle
def run_stuff():
if idle_check():
- print "Running optimize"
+ print "\n%sRunning optimize" %(get_timestamp())
optimize()
- print "Running backup"
+ print "\n%s Running backup" %(get_timestamp())
os.system('/usr/LH/bin/lh_system_backup_job')
- print "Running system_update"
+ print "\n%s Running system update" %(get_timestamp())
os.system('/usr/LH/bin/lh_system_host_update')
continue_loop=False
else:
@@ -146,8 +160,11 @@ starttime=time.time()
ctin=True
while ctin:
ctin=run_stuff()
+ print "\n"
if ctin:
+ print "%s Waiting 10 minutes before trying again" %(get_timestamp())
time.sleep(600)
+
current_time=time.time()
if (current_time - starttime) > 10800 :
ctin = False