Fix build error with scons-4.4.0 version which is based on python3
[platform/upstream/iotivity.git] / build_common / arduino / SConscript
index 5dffa92..dea95b9 100644 (file)
@@ -27,7 +27,7 @@ def __parse_config(f):
 
 def __get_boards(dict):
        boards = []
-       keys = dict.keys()
+       keys = list(dict.keys())
        for key in keys:
                idx = key.find('.name')
                if idx > 0:
@@ -37,7 +37,7 @@ def __get_boards(dict):
 
 def __get_cpu(dict, board):
        cpus = []
-       keys = dict.keys()
+       keys = list(dict.keys())
        for key in keys:
                idx = key.find(board + '.menu.cpu.')
                start = len(board + '.menu.cpu.')
@@ -190,13 +190,13 @@ def __upload(env, binary):
                 port = '/dev/ttyACM0'
                 upload_cmd = arduino_home + '/hardware/tools/avr/bin/avrdude -C' + arduino_home +'/hardware/tools/avr/etc/avrdude.conf -p' \
                 + mcu + ' -c' + protocol + ' -P' + port + ' -b' + speed + ' -D -Uflash:w:' + binary + ':i'
-                print "Upload command: %s" %upload_cmd
+                print("Upload command: %s" %upload_cmd)
                 install_cmd = env.Command('install_cmd', None, upload_cmd)
                 env.Default('install_cmd')
         elif target_arch == 'arm':
                 port = 'ttyACM0'
                 upload_cmd = 'stty -F /dev/' + port + ' speed 1200 cs8 -cstopb -parenb \n' + arduino_home + '/hardware/tools/bossac -i --port=' + port + ' -U false -e -w -b ' + binary + ' -R'
-                print "Upload command: %s" %upload_cmd
+                print("Upload command: %s" %upload_cmd)
                 install_cmd = env.Command('install_cmd', None, upload_cmd)
                 env.Default('install_cmd')
 
@@ -234,7 +234,7 @@ target_arch = env.get('TARGET_ARCH')
 # installed.  If not, get them and install them.
 SConscript(os.path.join(env.get('SRC_DIR'), 'extlibs', 'arduino', 'SConscript'))
 arduino_home = env.get('ARDUINO_HOME')
-print 'ARDUINO_HOME = ' + env.get('ARDUINO_HOME')
+print('ARDUINO_HOME = ' + env.get('ARDUINO_HOME'))
 
 # Overwrite suffixes and prefixes
 if env['HOST_OS'] == 'win32':
@@ -269,12 +269,12 @@ if os.path.exists(os.path.join(arduino_home, 'lib', 'version.txt')):
        vf = open(os.path.join(arduino_home, 'lib', 'version.txt'), 'r')
        version = vf.readline().replace('.', '').strip()
 else:
-       print '''
+       print('''
 ************************************* Error ***********************************
 * Can't find version file (lib/version.txt), please check if (%s)
 * is arduino root directory.                                                  *
 *******************************************************************************
-''' % arduino_home
+''' % arduino_home)
        Exit(1)
 
 if version[0:2] == '10':
@@ -288,12 +288,12 @@ if version[0:2] == '10':
        env.Replace(LINK = 'avr-gcc')
        env.Replace(RANLIB = 'avr-ranlib')
        if target_arch != 'avr':
-               print '''
+               print('''
 ************************************* Error ***********************************
 * Arduino 1.0.x IDE only support 'avr', to support other arch at least 1.5.x  *
 * is required.
 *******************************************************************************
-'''
+''')
                Exit(1)
 else:
        is_1_0_x = False
@@ -304,11 +304,11 @@ else:
                boards_info = __parse_config(os.path.join(arduino_home, 'hardware', 'arduino', 'sam', 'boards.txt'))
                platform_info = __parse_config(os.path.join(arduino_home, 'hardware', 'arduino', 'sam', 'platform.txt'))
        else:
-               print '''
+               print('''
 ************************************* Error ***********************************
 * CPU arch %s isn't supported currently.
 *******************************************************************************
-''' % target_arch
+''' % target_arch)
 
 #Board option, let user to select the board
 boards = __get_boards(boards_info)