diff options
Diffstat (limited to 'abs/core/LinHES-config/mv_common.py')
-rwxr-xr-x | abs/core/LinHES-config/mv_common.py | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/abs/core/LinHES-config/mv_common.py b/abs/core/LinHES-config/mv_common.py index 5257a5a..b5939f2 100755 --- a/abs/core/LinHES-config/mv_common.py +++ b/abs/core/LinHES-config/mv_common.py @@ -2,6 +2,7 @@ import logging, os, time import commands import ConfigParser +import urllib2 config_file = "mv_config" data_config = __import__(config_file, globals(), locals(), []) @@ -11,6 +12,38 @@ try: except: logging.info("couldn't read mythvantage.cfg") +class config_extra_reader(object): + def __init__(self,url): + self.url=url + self.Config = ConfigParser.ConfigParser() + req = urllib2.Request(url) + response = urllib2.urlopen(req) + self.Config.readfp(response) + + def print_url(self): + print self.url + + + def print_sections(self): + print self.Config.sections() + + + def read_config(self,data): + rvalue = True + section = "extra" + try: + rvalue = self.Config.get(section, data) + if rvalue == "False": + rvalue = False + if rvalue == "no": + rvalue = False + except: + logging.debug("Couldn't read config_file") + rvalue = True + + return rvalue + + def read_config(module_config,data): rvalue = True @@ -61,6 +94,39 @@ def cp_and_log(srcfile,destfile): cmd = ("rsync -arhp %s %s") %(srcfile,destfile) runcmd(cmd) +def link_file(srcfile,link_name): + logging.info(" Trying to link %s -> %s",srcfile,link_name) + if not os.path.exists(srcfile): + logging.info(" %s is not present, skipping...",srcfile) + elif os.path.exists(link_name): + logging.info(" %s is present, skipping...",link_name) + else: + try: + os.symlink(srcfile, link_name) + except: + logging.info(" Problem linking files occured") + + return + +def mkdir_mythhome(mythhome): + if not os.path.exists(mythhome+"/.mythtv"): + logging.debug(" Creating %s/.mythtv",mythhome) + try: + os.mkdir(mythhome+"/.mythtv") + except: + logging.debug(" Couldn't create .mythtv ") + return + try: + os.chown(mythhome+"/.mythtv", mythuid, mythgid) + logging.debug("* Couldn't chown of %s", mythhome) + except: + cmd = ''' chown -R mythtv %s/.mythtv''' %mythhome + runcmd(cmd) + cmd = ''' chgrp -R mythtv %s/.mythtv''' %mythhome + runcmd(cmd) + pass + + def add_service(daemon): logging.info(" Adding service %s",daemon) |