2012-08-20 17:19:57 +02:00
|
|
|
import os
|
|
|
|
from configobj import ConfigObj
|
|
|
|
import traceback
|
|
|
|
|
2012-08-20 18:32:16 +02:00
|
|
|
def upgrade(source, destination):
|
2012-08-20 17:19:57 +02:00
|
|
|
"""
|
|
|
|
Must be ran as sudo. will do upgrade of configuration files by filling in
|
|
|
|
missing values according to upgrade_data
|
|
|
|
"""
|
2012-08-20 18:32:16 +02:00
|
|
|
if not os.path.exists(source):
|
|
|
|
print("Cannot upgrade '%s'. Skipping this file" % source)
|
|
|
|
return
|
|
|
|
try:
|
|
|
|
cfg_source, cfg_dest = ConfigObj(source), ConfigObj(destination)
|
|
|
|
for key, val in cfg_source.iteritems():
|
|
|
|
if key not in cfg_dest: cfg_dest[key] = val
|
|
|
|
cfg_dest.write()
|
|
|
|
except Exception:
|
|
|
|
print("Error upgrading")
|
|
|
|
print( traceback.format_exc() )
|