summaryrefslogtreecommitdiffstats
path: root/abs/core-testing/LinHES-config/mv_common.py
diff options
context:
space:
mode:
Diffstat (limited to 'abs/core-testing/LinHES-config/mv_common.py')
-rw-r--r--abs/core-testing/LinHES-config/mv_common.py101
1 files changed, 76 insertions, 25 deletions
diff --git a/abs/core-testing/LinHES-config/mv_common.py b/abs/core-testing/LinHES-config/mv_common.py
index 3ae7edb..64ff2d6 100644
--- a/abs/core-testing/LinHES-config/mv_common.py
+++ b/abs/core-testing/LinHES-config/mv_common.py
@@ -10,10 +10,9 @@ def runcmd(cmd):
else:
cmd = "echo "+cmd
logging.debug(" %s",cmd)
- cmdout = commands.getoutput(cmd)
+ cmdout = commands.getstatusoutput(cmd)
logging.debug(" %s",cmdout)
- return cmdout
-
+ return cmdout[0]
def services(systemconfig):
logging.debug("______Start of services______")
@@ -30,12 +29,34 @@ def cp_and_log(srcfile,destfile):
def add_service(daemon):
logging.info(" Adding service %s",daemon)
+ cmd = "add_service.sh %s" %daemon
+ runcmd(cmd)
def remove_service(daemon):
logging.info(" Removing service %s",daemon)
+ cmd = "remove_service.sh %s" %daemon
+ runcmd(cmd)
+
+def pkg_blacklist_check(pkg):
+ cmd = '''grep -q %s /etc/blacklist.package''' %pkg
+ rc = runcmd(cmd)
+ if rc == 0:
+ return True
+ else:
+ return False
+
+def pkg_installed_check(pkg):
+ logging.debug(" Checking if %sis installed",pkg)
+ cmd = "pacman -Q %s " %pkg
+ rc = runcmd(cmd)
+ if rc == 0:
+ return True
+ else:
+ return False
+
def pacinstall(pkg):
- logging.info(" Installing %s",pkg)
+ logging.info(" Checking %s for install",pkg)
#extra pkg check
if pkg == "xine":
pacinstall("xine-ui")
@@ -44,8 +65,18 @@ def pacinstall(pkg):
elif pkg == "webmin":
add_service("webmin")
+ if not pkg_blacklist_check(pkg):
+ if pkg_installed_check(pkg):
+ logging.info(" %s is already installed, will not install",pkg)
+ else:
+ logging.info(" Installing %s",pkg)
+ cmd ='''pacman --noconfirm -Sf %s ''' %pkg
+ runcmd(cmd)
+ else:
+ logging.info(" %s is blacklisted, will not install",pkg)
+
def pacremove(pkg):
- logging.info(" Removing %s",pkg)
+ logging.info(" Checking %s for removal",pkg)
if pkg == "xine":
pacremove("xine-ui")
elif pkg == "dvdcss":
@@ -53,32 +84,52 @@ def pacremove(pkg):
elif pkg == "webmin":
remove_service("webmin")
+ if not pkg_blacklist_check(pkg):
+ if not pkg_installed_check(pkg):
+ logging.info(" %s is not installed, will not remove",pkg)
+ else:
+ logging.info(" Removing %s",pkg)
+ cmd ='''pacman --noconfirm -R %s ''' %pkg
+ else:
+ logging.info(" %s is blacklisted, will not remove",pkg)
+
+def getpid(process):
+ return commands.getoutput('pidof %s' % process)
+
+
+def restartLCD(RESTART_LCD):
+ if RESTART_LCD :
+ logging.info(" Restarting lcd server")
+ cmd = "killall -9 mythlcdserver"
+ runcmd(cmd)
+ else:
+ logging.debug(" Not restarting MYTHLCD server")
+
-def reloadfe():
- logging.info(" Reloading frontend")
- logging.info(" LOOK Reloading frontend")
- #function reloadfe(){
- #PID=`ps -ef |grep mythfrontend|grep -v grep |awk '{print $2 }'`
- #/usr/bin/backend_control.sh clearcache behost $dbhost
- #if [ x$RESTART_LCD = xtrue ]
- #then
- #killall -9 mythlcdserver
- #fi
- #if [ x = x$PID ]
- #then
- #echo "Mythfrontend not running, will not reload"
- #else
- #kill -s USR1 $PID
- #fi
- return
-
-def restartfe():
+def reloadfe(dbhost,RESTART_LCD):
+ logging.debug("____Start of reloadfe____")
+ logging.info(" Clearing Backend cache")
+ cmd = '''/usr/bin/backend_control.sh clearcache behost %s''' %dbhost
+ runcmd(cmd)
+ restartLCD(RESTART_LCD)
+ for pid in getpid("mythfrontend"):
+ cmd = ''' kill -s USR1 %s ''' %pid
+ #runcmd(cmd)
+ logging.info(" Reloading frontend with pid of %s",pid)
+
+ logging.debug("__End of reloadfe\n")
+
+
+def restartfe(RESTART_LCD):
+ logging.debug("____Start of restartfe____")
logging.info(" Restarting frontend")
+ restartLCD(RESTART_LCD)
cmd="killall -9 mythfrontend"
runcmd(cmd)
cmd="killall -9 welcome"
runcmd(cmd)
- return
+ logging.debug("__End of restartfe\n")
+
def udev_trigger():
logging.info(" Triggering udev")