summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-system/myth_mtc.py
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2011-12-21 22:43:21 (GMT)
committerJames Meyer <james.meyer@operamail.com>2011-12-21 22:43:21 (GMT)
commit02750b0fe64c4da69ff0dfc16178f1a79cec0b18 (patch)
treedc18089e73a30a552b1291fc951e0fee96fc8a49 /abs/core/LinHES-system/myth_mtc.py
parent42cebee00a801bc7267613c4588bcefa6e60ff39 (diff)
downloadlinhes_pkgbuild-02750b0fe64c4da69ff0dfc16178f1a79cec0b18.zip
linhes_pkgbuild-02750b0fe64c4da69ff0dfc16178f1a79cec0b18.tar.gz
linhes_pkgbuild-02750b0fe64c4da69ff0dfc16178f1a79cec0b18.tar.bz2
linhes-system: myth_mtc
fix python bindings usage and replace popen2 with subprocess. refs #803
Diffstat (limited to 'abs/core/LinHES-system/myth_mtc.py')
-rwxr-xr-xabs/core/LinHES-system/myth_mtc.py35
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