summaryrefslogtreecommitdiffstats
path: root/abs/core-testing/LinHES-config/mv_install.py
diff options
context:
space:
mode:
Diffstat (limited to 'abs/core-testing/LinHES-config/mv_install.py')
-rwxr-xr-xabs/core-testing/LinHES-config/mv_install.py46
1 files changed, 37 insertions, 9 deletions
diff --git a/abs/core-testing/LinHES-config/mv_install.py b/abs/core-testing/LinHES-config/mv_install.py
index a945e34..678cf3e 100755
--- a/abs/core-testing/LinHES-config/mv_install.py
+++ b/abs/core-testing/LinHES-config/mv_install.py
@@ -15,8 +15,19 @@ def usage():
def clean_upgrade():
return False
+def update_db(value,data):
+ db = MySQLdb.connect(host="localhost", user="mythtv", passwd="mythtv", db="mythconverg")
+ try:
+ cursor = db.cursor()
+ cursor.execute("DELETE FROM settings where value=%s and hostname=%s;",(value,data_config.MVHOSTNAME))
+ cursor.execute("REPLACE INTO settings set value=%s,data=%s,hostname=%s;" ,(value,data,data_config.MVHOSTNAME))
+ logging.debug("Updated database with %s,%s",data,value)
+ except MySQLdb.Error, e:
+ logging.debug("Unable to update database with %s,%s",data,value)
+
+
def progress(pgnum):
- progressline = str(pgnum) + " complete"
+ progressline = str(pgnum) + "% complete"
logging.debug("Progress: %s" , pgnum)
f = open('/tmp/.install_percent', 'w')
f.write(progressline)
@@ -64,11 +75,11 @@ def backup_sql_check():
except:
logging.debug("Backup file var is empty")
return False
- if os.path.exists(hostoptions["backupfile"]):
- logging.debug("Backup file %s is present",hostoptions["backupfile"])
+ if os.path.exists(data_config.MOUNTPOINT+hostoptions["backupfile"]):
+ logging.debug("Backup file %s is present",data_config.MOUNTPOINT+hostoptions["backupfile"])
return True
else:
- logging.debug("Backup file %s is NOT present",hostoptions["backupfile"])
+ logging.debug("Backup file %s is NOT present",data_config.MOUNTPOINT+hostoptions["backupfile"])
return False
def mdadm_find(PREFIX):
@@ -90,7 +101,7 @@ def mdadm_assemble_all():
mdadm_contents = ''
try:
f = open(mdadmconf_file, 'r')
- mdadm_contents = f.readlines
+ mdadm_contents = f.readlines()
f.close()
except:
logging.debug(" Couldn't open mdadmconf file")
@@ -115,7 +126,23 @@ def copy_updates():
cp_and_log2(MVROOT+"/bin/",data_config.MOUNTPOINT+MVROOT+"/bin","*.py")
def timezone_to_db(timefile):
- logging.info("LOOK TIMEZONE TO DB needs to be completed")
+ logging.info("importing timezone needs")
+ try:
+ f = open(timefile)
+ timezonecontents = f.readline().strip()
+ f.close
+ except:
+ logging.debug("Couldn't open /tmp/etc/timezone, will not set the timezone")
+ return
+ tzsplit = timezonecontents.partition('/')
+ print tzsplit
+ if tzsplit[2] == '' :
+ update_db("HostTimeZoneRegion", tzsplit[0])
+ else:
+ update_db("HostTimeZoneRegion", tzsplit[0])
+ tztemp="HostTimeZoneRegion_%s" % tzsplit[0]
+ update_db(tztemp,tzsplit[2])
+
def cp_and_log(srcfile,destfile):
@@ -1008,6 +1035,7 @@ def upgrade_mount_search():
newbackupfile = "/tmp/"+data_config.BACKUPFILE
if os.path.exists(newbackupfile):
logging.debug("Setting backup file to %s",newbackupfile)
+ cp_and_log(newbackupfile,data_config.MOUNTPOINT+newbackupfile)
hostoptions["backupfile"] = newbackupfile
else:
logging.info("Couldn't find any database to restore, upgrade will continue with a new database")
@@ -1036,7 +1064,7 @@ def upgrade(hostoptions):
update_status(statusmsg)
progress(3)
mount_it()
- hostoptions["backupfile"] = data_config.MOUNTPOINT+data_config.BACKUPPATH+data_config.BACKUPFILE
+ hostoptions["backupfile"] = data_config.BACKUPPATH+data_config.BACKUPFILE
statgrab( hostoptions["rootdisk"])
msg = "Upgrading %s" %(systemconfig["hostname"])
update_status(msg)
@@ -1201,7 +1229,7 @@ logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
datefmt='%m-%d %H:%M',
filename=DEBUGLOG,
- filemode='w')
+ filemode='a')
# define a Handler which writes INFO messages or higher to the sys.stderr
console = logging.StreamHandler()
console.setLevel(logging.INFO)
@@ -1241,7 +1269,7 @@ for line in config_file:
if __name__ == "__main__":
config_file = "mv_config"
data_config = __import__(config_file, globals(), locals(), [])
-
+ logging.debug("___________START OF DEBUG_________________________")
cmdoptions = main(sys.argv[1:])
logging.debug("______cmd line options______")
for i in cmdoptions.items():