From 02750b0fe64c4da69ff0dfc16178f1a79cec0b18 Mon Sep 17 00:00:00 2001 From: James Meyer Date: Wed, 21 Dec 2011 16:43:21 -0600 Subject: linhes-system: myth_mtc fix python bindings usage and replace popen2 with subprocess. refs #803 --- abs/core/LinHES-system/PKGBUILD | 6 +++--- abs/core/LinHES-system/myth_mtc.py | 35 +++++++++++++++++++++-------------- abs/core/LinHES-system/myth_mtc.sh | 2 +- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/abs/core/LinHES-system/PKGBUILD b/abs/core/LinHES-system/PKGBUILD index 9cc0aa9..d0012c1 100755 --- a/abs/core/LinHES-system/PKGBUILD +++ b/abs/core/LinHES-system/PKGBUILD @@ -1,6 +1,6 @@ pkgname=LinHES-system pkgver=2 -pkgrel=12 +pkgrel=13 arch=('i686') MVDIR=$startdir/pkg/usr/LH BINDIR=$startdir/pkg/usr/bin @@ -41,8 +41,8 @@ md5sums=('989c22c2eae00501f5b46f215dbf5e59' '5881bdb43d578ec3a79d1f77ea58a3db' 'a875ee97f86e46f34a741c2bc455f894' '76b2637cac0452b3acdbeeb4e8a5474b' - 'c60b6c66f498809a6e5ca18a8c97d336' - 'ccae1296ef248fa52ec3a7cb820a476e' + '6a42d3799fad2ebffac2fbf2411511ed' + '2ef9f945e034119f77d9b6beb17e4fa5' 'f7ecc552a2823cae63d75f58dc7435c4' '18a884a73344ff6eb74f63b49745e0f5' 'dc3eef2a624754e16805d72bbe488b67' diff --git a/abs/core/LinHES-system/myth_mtc.py b/abs/core/LinHES-system/myth_mtc.py index 5505b0a..1ed6c88 100755 --- a/abs/core/LinHES-system/myth_mtc.py +++ b/abs/core/LinHES-system/myth_mtc.py @@ -1,7 +1,7 @@ #!/usr/bin/python -import sys,popen2 +import sys, subprocess import optparse import re import socket @@ -10,11 +10,11 @@ import datetime,time -try: - from MythTV import MythTV - mythtv = MythTV() -except: - mythtv = None +#try: +from MythTV import MythBE +mythtv = MythBE() +#except: +# mythtv = None #print mythtv.db.getSetting( 'Theme', socket.gethostname()) @@ -86,14 +86,21 @@ def in_use(): return False def mfd_check(): - ismfd=popen2.Popen3('/bin/ps cax|/bin/grep -v grep |/bin/grep mythfilldatabase') - ismfd.wait() - mfdIdle=ismfd.poll() - if mfdIdle == 0: - print "mythfilldatabase is running" - return False - else: - return True + ps = subprocess.Popen("ps ax -o pid= -o args= ", shell=True, stdout=subprocess.PIPE) + ps_pid = ps.pid + output = ps.stdout.read() + ps.stdout.close() + ps.wait() + proc_name="mythfilldatabase" + for line in output.split("\n"): + res = re.findall("(\d+) (.*)", line) + 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" + return False + + return True diff --git a/abs/core/LinHES-system/myth_mtc.sh b/abs/core/LinHES-system/myth_mtc.sh index 487513b..12486c4 100755 --- a/abs/core/LinHES-system/myth_mtc.sh +++ b/abs/core/LinHES-system/myth_mtc.sh @@ -3,7 +3,7 @@ logFile='/var/log/mythtv/myth_mtc.log' date=`date +%Y-%m-%d` -myth_mtc.py > $logFile 2>&1 +MYTHCONFDIR=/usr/share/mythtv myth_mtc.py > $logFile 2>&1 if [ $? = 0 ] then echo "Finished $date" >> $logFile -- cgit v0.12