Fix build error with scons-4.4.0 version which is based on python3
[platform/upstream/iotivity.git] / build_common / external_libs.scons
index 85550d0..b9c6947 100644 (file)
@@ -21,7 +21,7 @@
 #
 ##
 import os, subprocess
-import urllib2, urlparse
+import urllib.request, urllib.error, urllib.parse, urllib.parse
 import SCons.Errors
 
 Import('env')
@@ -79,21 +79,21 @@ def __prepare_lib(ienv, libname, lib = None, path = None, script = None):
                        SConscript(st)
                else:
                        if target_os in ['linux', 'darwin', 'tizen']:
-                               print 'Don\'t find library(%s), please intall it, exit ...' % libname
+                               print(('Don\'t find library(%s), please intall it, exit ...' % libname))
                        else:
-                               print 'Don\'t find library(%s) and don\'t find the process script (%s), exit ...' % (libname, st)
+                               print(('Don\'t find library(%s) and don\'t find the process script (%s), exit ...' % (libname, st)))
                        Exit(1)
 
        conf.Finish()
 
 # Run configure command (usually it's done before build a library)
 def __configure(env, cwd, cmd) :
-       print "Configuring using [%s/%s] ..." % (cwd, cmd)
+       print(("Configuring using [%s/%s] ..." % (cwd, cmd)))
        # build it now (we need the shell, because some programs need it)
        devnull = open(os.devnull, "wb")
        handle  = subprocess.Popen(cmd, shell=True, cwd=cwd, stdout=devnull)
 
-       if handle.wait() <> 0 :
+       if handle.wait() != 0 :
                raise SCons.Errors.BuildError( "Run configuring script [%s]" % (cmd) )
 
 # Download from URL 'url', will save as 'target'
@@ -102,15 +102,15 @@ def __download(ienv, target, url) :
                return target
 
        try :
-               print "Download %s from %s" % (target, url)
-               print "Downloading ..."
-               stream = urllib2.urlopen(url)
+               print(("Download %s from %s" % (target, url)))
+               print("Downloading ...")
+               stream = urllib.request.urlopen(url)
                file = open(target, 'wb')
                file.write(stream.read())
                file.close()
-               print "Download %s from %s complete" % (target, url)
+               print(("Download %s from %s complete" % (target, url)))
                return target
-       except Exception, e :
+       except Exception as e :
                raise SCons.Errors.StopError( '%s [%s]' % (e, url) )
 
 # Install header file(s) to <src_dir>/deps/<target_os>/include