diff options
Diffstat (limited to 'abs/core/LinHES-system/myth_mtc.py')
-rwxr-xr-x | abs/core/LinHES-system/myth_mtc.py | 35 |
1 files changed, 21 insertions, 14 deletions
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 |