Fix build error with scons-4.4.0 version which is based on python3
[platform/upstream/iotivity.git] / extlibs / arduino / SConscript
index 879fe2c..368fe07 100644 (file)
@@ -4,7 +4,7 @@
 ##
 
 import os, subprocess, struct
-import urllib2, urlparse
+import urllib.request, urllib.error, urllib.parse, urllib.parse
 import SCons.Errors
 import shutil
 
@@ -20,8 +20,8 @@ SConscript(src_dir + '/build_common/external_libs.scons')
 if target_os == 'arduino':
        arduino_home = env.get('ARDUINO_HOME')
        if not arduino_home:
-               print 'Creating ARDUINO_HOME for Arduino lib'
-               print '''
+               print('Creating ARDUINO_HOME for Arduino lib')
+               print('''
         *******************************************************************************
         *   Arduino root directory isn't set, you can set enviornment variable        *
         *   ARDUINO_HOME or add it in command line as follows (Only set if your       *
@@ -29,14 +29,14 @@ if target_os == 'arduino':
         *   wish to manually set ARDUINO_HOME.):                                      *
         *      # scons ARDUINO_HOME=<path to arduino root directory> ...              *
         *******************************************************************************
-        '''
+        ''')
                arduinolib_dir      = src_dir + '/extlibs/arduino/arduino-1.5.8'
 
                if not os.path.exists(arduinolib_dir):
                        from sys import platform as _platform
                        if _platform == "linux" or _platform == "linux2":
                                archType = 8 * struct.calcsize("P")
-                               print 'On %s-bit machine.' % (archType)
+                               print('On %s-bit machine.' % (archType))
                                if archType == 32:
                                        arduinolib_zip_file = src_dir + '/extlibs/arduino/arduino-1.5.8-linux32.tgz'
                                        arduinolib_url      = 'http://arduino.cc/download.php?f=/arduino-1.5.8-linux32.tgz'
@@ -57,9 +57,9 @@ if target_os == 'arduino':
                                arduinolib_zip = arduinolib_zip_file
 
                        # Unzip the lib
-                       print 'Unzipping arduino lib...'
+                       print('Unzipping arduino lib...')
                        env.UnpackAll(arduinolib_dir, arduinolib_zip)
-                       print 'Unzipping arduino lib complete'
+                       print('Unzipping arduino lib complete')
 
                        # Remove downloaded file
                        os.remove(arduinolib_zip_file)
@@ -82,12 +82,12 @@ if target_os == 'arduino':
                                timelib_zip = timelib_zip_file
 
                        # Unzip the lib
-                       print 'Unzipping Arduino Time lib...'
+                       print('Unzipping Arduino Time lib...')
                        env.UnpackAll(timelib_dir + '/Time', timelib_zip)
 
                        # Apply patches to ARDUINO_HOME directory.
                        os.chdir(arduinolib_dir)
-                       print 'Patching Arduino libraries...'
+                       print('Patching Arduino libraries...')
 
                        os.system("find ./libraries/Time/Time/DateStrings.cpp -type f -exec dos2unix {} \;")
                        os.system("patch -p1 < " + src_dir + "/resource/csdk/connectivity/lib/arduino/arduino_libraries.patch --directory=" + arduinolib_dir)
@@ -95,11 +95,11 @@ if target_os == 'arduino':
                        # Remove downloaded file
                        os.remove(timelib_zip_file)
                else:
-                       print 'Please manually install package dos2unix. The build process will end now. Your Action Required: Install package manually, then restart build process.'
-                       print 'You may likely retrieve this package as follows:'
-                       print '      sudo apt-get install dos2unix'
-                       print '               or'
-                       print '      sudo yum install dos2unix'
+                       print('Please manually install package dos2unix. The build process will end now. Your Action Required: Install package manually, then restart build process.')
+                       print('You may likely retrieve this package as follows:')
+                       print('      sudo apt-get install dos2unix')
+                       print('               or')
+                       print('      sudo yum install dos2unix')
                        exit(1)
 
        redbearlib_dir         = arduinolib_dir + '/libraries/RBL_nRF8001'
@@ -114,7 +114,7 @@ if target_os == 'arduino':
                                redbearlib_zip = redbearlib_zip_file
 
                        # Unzip the lib
-                       print 'Unzipping Red Bear lib...'
+                       print('Unzipping Red Bear lib...')
                        os.chdir(arduinolib_dir + '/libraries')
                        env.UnpackAll(redbearlib_dir, redbearlib_zip)
 
@@ -123,7 +123,7 @@ if target_os == 'arduino':
                        shutil.rmtree('nRF8001-25643e7b1b7da3740406325a471e3faa4b948747')
 
                        # Apply Red Bear patches
-                       print 'Patching Red Bear library...'
+                       print('Patching Red Bear library...')
                        os.chdir(arduinolib_dir + '/libraries/RBL_nRF8001/')
 
                        os.system("find . -type f -exec dos2unix {} \;")
@@ -132,11 +132,11 @@ if target_os == 'arduino':
                        # Remove downloaded file
                        os.remove(redbearlib_zip_file)
                else:
-                       print 'Please manually install package dos2unix. The build process will end now. Your Action Required: Install package manually, then restart build process.'
-                       print 'You may likely retrieve this package as follows:'
-                       print '      sudo apt-get install dos2unix'
-                       print '               or'
-                       print '      sudo yum install dos2unix'
+                       print('Please manually install package dos2unix. The build process will end now. Your Action Required: Install package manually, then restart build process.')
+                       print('You may likely retrieve this package as follows:')
+                       print('      sudo apt-get install dos2unix')
+                       print('               or')
+                       print('      sudo yum install dos2unix')
                        exit(1)
 
        nordiclib_dir           = arduinolib_dir + '/libraries/BLE'
@@ -151,7 +151,7 @@ if target_os == 'arduino':
                                nordiclib_zip = nordiclib_zip_file
 
                        # Unzip the lib
-                       print 'Unzipping Nordic lib...'
+                       print('Unzipping Nordic lib...')
                        os.chdir(arduinolib_dir + '/libraries')
                        env.UnpackAll(nordiclib_dir, nordiclib_zip)
 
@@ -160,7 +160,7 @@ if target_os == 'arduino':
                        shutil.rmtree('ble-sdk-arduino-0.9.5.beta')
 
                        # Apply Nordic lib patches
-                       print 'Patching Nordic library...'
+                       print('Patching Nordic library...')
                        os.chdir(arduinolib_dir + '/libraries/BLE/')
 
                        os.system("find . -type f -exec dos2unix {} \;")
@@ -169,13 +169,13 @@ if target_os == 'arduino':
                        # Remove downloaded file
                        os.remove(nordiclib_zip_file)
                else:
-                       print 'Please manually install package dos2unix. The build process will end now. Your Action Required: Install package manually, then restart build process.'
-                       print 'You may likely retrieve this package as follows:'
-                       print '      sudo apt-get install dos2unix'
-                       print '               or'
-                       print '      sudo yum install dos2unix'
+                       print('Please manually install package dos2unix. The build process will end now. Your Action Required: Install package manually, then restart build process.')
+                       print('You may likely retrieve this package as follows:')
+                       print('      sudo apt-get install dos2unix')
+                       print('               or')
+                       print('      sudo yum install dos2unix')
                        exit(1)
 
 # Set the ARDUINO_HOME
 env.Replace(ARDUINO_HOME = arduinolib_dir)
-print 'ARDUINO_HOME = ' + env.get('ARDUINO_HOME')
+print('ARDUINO_HOME = ' + env.get('ARDUINO_HOME'))