Fix build error with scons-4.4.0 version which is based on python3
[platform/upstream/iotivity.git] / resource / csdk / connectivity / build / arduino / SConscript
index d97d596..df062e0 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.')
@@ -176,14 +176,14 @@ def __upload(env, binary):
                 upload_cmd = arduino_home + '/hardware/tools/avr/bin/avrdude -C' + arduino_home +'/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -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')
         else:
                uu = __get_board_info(board, '.upload.native_usb')
                 port = 'ttyACM0'
                upload_cmd = 'stty -F /dev/' + port + ' speed 1200 cs8 -cstopb -parenb \n' + arduino_home + '/hardware/tools/bossac -i -d --port=' + port + ' -U ' + uu + ' -e -w -v -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')
 
@@ -218,13 +218,13 @@ Help(help_vars.GenerateHelpText(env))
 target_arch = env.get('TARGET_ARCH')
 arduino_home = env.get('ARDUINO_HOME')
 if not arduino_home:
-       print '''
+       print('''
 ************************************* Error ***********************************
 *   Arduino root directory isn't set, you can set enviornment variable        *
 * ARDUINO_HOME or add it in command line as:                                  *
 *      # scons ARDUINO_HOME=<path to arduino root directory> ...              *
 *******************************************************************************
-'''
+''')
        Exit(1)
 
 # Overwrite suffixes and prefixes
@@ -257,12 +257,12 @@ if os.path.exists(arduino_home + '/lib/version.txt'):
        vf = open(arduino_home + '/lib/version.txt', 'r')
        version = vf.readline().replace('.', '')
 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':
@@ -276,12 +276,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
@@ -292,11 +292,11 @@ else:
                boards_info = __parse_config(arduino_home + '/hardware/arduino/sam/boards.txt')
                platform_info = __parse_config(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)