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')
-rwxr-xr-xabs/core-testing/LinHES-config/mv_common.py232
1 files changed, 0 insertions, 232 deletions
diff --git a/abs/core-testing/LinHES-config/mv_common.py b/abs/core-testing/LinHES-config/mv_common.py
deleted file mode 100755
index 0272809..0000000
--- a/abs/core-testing/LinHES-config/mv_common.py
+++ /dev/null
@@ -1,232 +0,0 @@
-# -*- coding: utf-8 -*-
-import logging, os, time
-import commands
-import ConfigParser
-config_file = "mv_config"
-data_config = __import__(config_file, globals(), locals(), [])
-
-module_config = ConfigParser.RawConfigParser()
-try:
- module_config.read('/etc/mythvantage.cfg')
-except:
- logging.info("couldn't read mythvantage.cfg")
-
-
-def read_config(module_config,data):
- rvalue = True
- section = "mythvantage"
- try:
- rvalue = module_config.get(section, data)
- if rvalue == "False":
- rvalue = False
- if rvalue == "no":
- rvalue = False
-
-
- except:
- logging.debug("Couldn't read mythvantage.cfg")
- rvalue = True
-
- return rvalue
-
-def runcmd(cmd):
- if data_config.NOOPDEBUG=="FALSE":
- pass
- else:
- cmd = "echo "+cmd
- logging.debug(" %s",cmd)
- cmdout = commands.getstatusoutput(cmd)
- logging.debug(" %s",cmdout)
- return cmdout[0]
-
-def runcmd_output(cmd):
- if data_config.NOOPDEBUG=="FALSE":
- pass
- else:
- cmd = "echo "+cmd
- logging.debug(" %s",cmd)
- cmdout = commands.getstatusoutput(cmd)
- logging.debug(" %s",cmdout)
- return cmdout[1]
-
-def services(systemconfig):
- logging.debug("______Start of services______")
- logging.debug("__End services")
-
-def cp_and_log(srcfile,destfile):
- #return
- if not os.path.exists(srcfile):
- logging.info("%s is not present, skipping...",srcfile)
- else:
- cmd = ("rsync -arhp %s %s") %(srcfile,destfile)
- runcmd(cmd)
-
-
-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)
- stop_service(daemon)
- cmd = "remove_service.sh %s" %daemon
- runcmd(cmd)
-
-def start_service(daemon):
- logging.info(" start service %s",daemon)
- cmd = "sv start %s" %daemon
- runcmd(cmd)
-
-def stop_service(daemon):
- logging.info(" stop service %s",daemon)
- cmd = "sv stop %s" %daemon
- runcmd(cmd)
-
-def restart_service(daemon):
- logging.info(" Restarting service %s",daemon)
- if daemon == "lcdd":
- stop_service(daemon)
- logging.debug(" killing all lcdd")
- cmd = "killall -9 LCDd"
- runcmd(cmd)
- time.sleep(2)
- start_service(daemon)
- else:
- cmd = "sv restart %s" %daemon
- runcmd(cmd)
-
-def hup_service(daemon):
- logging.info(" hup service %s",daemon)
- cmd = "sv hup %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(" Checking %s for install",pkg)
- #extra pkg check
- if pkg == "xine":
- pacinstall("xine-ui")
- elif pkg == "dvdcss":
- pacinstall("libdvdcss")
- elif pkg == "webmin":
- add_service("webmin")
- elif pkg == "fuppes":
- pacinstall("fuppes-svn")
- elif pkg == "mupen64":
- pacinstall("mupen64plus-svn")
-
- 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(" Checking %s for removal",pkg)
- if pkg == "xine":
- pacremove("xine-ui")
- elif pkg == "dvdcss":
- pacremove("libdvdcss")
- elif pkg == "webmin":
- remove_service("webmin")
- elif pkg == "fuppes":
- pacremove("fuppes-svn")
- elif pkg == "mupen64":
- pacremove("mupen64plus-svn")
-
- 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
- runcmd(cmd)
- else:
- logging.info(" %s is blacklisted, will not remove",pkg)
-
-def getpid(process):
- return commands.getoutput('pidof %s' % process)
-
-def remove_file(filename):
- logging.debug(" Removing %s", filename)
- try:
- os.remove(filename)
- except:
- logging.debug("* Could not remove %s", filename)
-
-
-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(dbhost,RESTART_LCD):
- logging.debug("____Start of reloadfe____")
- if data_config.SYSTEMTYPE == "MythVantage":
- 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____")
- if data_config.SYSTEMTYPE=="LinHES":
- logging.debug(" LinHES seems to be running will not restartfe")
- return
- logging.info(" Restarting frontend")
- restartLCD(RESTART_LCD)
- cmd="killall -9 mythfrontend"
- runcmd(cmd)
- cmd="killall -9 welcome"
- runcmd(cmd)
- logging.debug("__End of restartfe\n")
-
-
-def udev_trigger():
- logging.info(" Triggering udev")
- cmd = "udevadm settle"
- runcmd(cmd)
- cmd = "udevadm trigger"
- runcmd(cmd)
- cmd = "udevadm settle"
- runcmd(cmd)
- cmd = "udevadm trigger"
- runcmd(cmd)
-
-