fix the configparser for Python 2 and 3 Compatibility 03/64103/2
authordongwenjuan <dong.wenjuan@zte.com.cn>
Sat, 27 Oct 2018 02:40:07 +0000 (10:40 +0800)
committerdongwenjuan <dong.wenjuan@zte.com.cn>
Sat, 27 Oct 2018 03:03:58 +0000 (11:03 +0800)
Change-Id: I6ea9c031a8093d7ce94b49575cb6bfe348eb6c9a
Signed-off-by: dongwenjuan <dong.wenjuan@zte.com.cn>
doctor_tests/installer/common/set_congress.py

index d275483..7961df3 100644 (file)
@@ -6,7 +6,7 @@
 # which accompanies this distribution, and is available at
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
-import configparser
+from six.moves import configparser
 import os
 import shutil
 
@@ -22,13 +22,13 @@ def set_drivers_config():
 
     config = configparser.ConfigParser()
     config.read(co_conf)
-    drivers = config['DEFAULT']['drivers']
+    drivers = config.get('DEFAULT', 'drivers')
 
     if doctor_driver not in drivers:
         config_modified = True
         drivers += ',' + doctor_driver
 
-    config['DEFAULT']['drivers'] = drivers
+    config.set('DEFAULT', 'drivers', drivers)
 
     if config_modified:
         shutil.copyfile(co_conf, co_conf_bak)