uifw update to python3X 31/274831/1 tizen_6.5
authorchen <chen89.chen@samsung.com>
Tue, 10 May 2022 08:13:39 +0000 (16:13 +0800)
committerchen <chen89.chen@samsung.com>
Tue, 10 May 2022 08:14:13 +0000 (16:14 +0800)
Change-Id: I6fe0e84e790d2a64fd20b56594f98f3d915a7127
Signed-off-by: chen <chen89.chen@samsung.com>
52 files changed:
mobile/tct-webuifw-tests01/inst.apk.py [changed mode: 0644->0755]
mobile/tct-webuifw-tests01/inst.wgt.py [changed mode: 0644->0755]
mobile/tct-webuifw-tests01/inst.xpk.py [changed mode: 0644->0755]
mobile/tct-webuifw-tests01/pack.py [changed mode: 0644->0755]
mobile/tct-webuifw-tests02/inst.apk.py [changed mode: 0644->0755]
mobile/tct-webuifw-tests02/inst.wgt.py [changed mode: 0644->0755]
mobile/tct-webuifw-tests02/inst.xpk.py [changed mode: 0644->0755]
mobile/tct-webuifw-tests02/pack.py [changed mode: 0644->0755]
mobile/tct-webuifw-tests03/inst.apk.py [changed mode: 0644->0755]
mobile/tct-webuifw-tests03/inst.wgt.py [changed mode: 0644->0755]
mobile/tct-webuifw-tests03/inst.xpk.py [changed mode: 0644->0755]
mobile/tct-webuifw-tests03/pack.py [changed mode: 0644->0755]
mobile/tct-webuifw-tests04/inst.apk.py [changed mode: 0644->0755]
mobile/tct-webuifw-tests04/inst.wgt.py [changed mode: 0644->0755]
mobile/tct-webuifw-tests04/inst.xpk.py [changed mode: 0644->0755]
mobile/tct-webuifw-tests04/pack.py [changed mode: 0644->0755]
mobile/tct-webuifw-tests05/inst.apk.py [changed mode: 0644->0755]
mobile/tct-webuifw-tests05/inst.wgt.py [changed mode: 0644->0755]
mobile/tct-webuifw-tests05/inst.xpk.py [changed mode: 0644->0755]
mobile/tct-webuifw-tests05/pack.py [changed mode: 0644->0755]
mobile/tct-webuifw-tests06/inst.apk.py [changed mode: 0644->0755]
mobile/tct-webuifw-tests06/inst.wgt.py [changed mode: 0644->0755]
mobile/tct-webuifw-tests06/inst.xpk.py [changed mode: 0644->0755]
mobile/tct-webuifw-tests06/pack.py [changed mode: 0644->0755]
mobile/tct-webuifw-tests07/inst.apk.py [changed mode: 0644->0755]
mobile/tct-webuifw-tests07/inst.wgt.py [changed mode: 0644->0755]
mobile/tct-webuifw-tests07/inst.xpk.py [changed mode: 0644->0755]
mobile/tct-webuifw-tests07/pack.py [changed mode: 0644->0755]
wearable/tct-webuifw-tests01/inst.apk.py
wearable/tct-webuifw-tests01/inst.wgt.py
wearable/tct-webuifw-tests01/inst.xpk.py
wearable/tct-webuifw-tests01/pack.py
wearable/tct-webuifw-tests02/inst.apk.py
wearable/tct-webuifw-tests02/inst.wgt.py
wearable/tct-webuifw-tests02/inst.xpk.py
wearable/tct-webuifw-tests02/pack.py
wearable/tct-webuifw-tests03/inst.apk.py
wearable/tct-webuifw-tests03/inst.wgt.py
wearable/tct-webuifw-tests03/inst.xpk.py
wearable/tct-webuifw-tests03/pack.py
wearable/tct-webuifw-tests04/inst.apk.py
wearable/tct-webuifw-tests04/inst.wgt.py
wearable/tct-webuifw-tests04/inst.xpk.py
wearable/tct-webuifw-tests04/pack.py
wearable/tct-webuifw-tests05/inst.apk.py
wearable/tct-webuifw-tests05/inst.wgt.py
wearable/tct-webuifw-tests05/inst.xpk.py
wearable/tct-webuifw-tests05/pack.py
wearable/tct-webuifw-tests06/inst.apk.py
wearable/tct-webuifw-tests06/inst.wgt.py
wearable/tct-webuifw-tests06/inst.xpk.py
wearable/tct-webuifw-tests06/pack.py

old mode 100644 (file)
new mode 100755 (executable)
index d5f9fbb..d636bee
@@ -7,7 +7,7 @@ import time
 import sys
 import subprocess
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -17,14 +17,14 @@ ADB_CMD = "adb"
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -77,8 +77,8 @@ def main():
             "-u", dest="buninstpkg", action="store_true", help="Uninstall package")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.device:
@@ -89,11 +89,11 @@ def main():
                 break
 
     if not PARAMETERS.device:
-        print "No device found"
+        print ("No device found")
         sys.exit(1)
 
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
old mode 100644 (file)
new mode 100755 (executable)
index 59ca043..454b936
@@ -8,7 +8,7 @@ import sys
 import subprocess
 import string
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR)
 PARAMETERS = None
 #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket"
 TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"
-tct_parser = ConfigParser.ConfigParser()
+tct_parser = configparser.ConfigParser()
 tct_parser.read(TCT_CONFIG_FILE)
 SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')
 PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
@@ -32,14 +32,14 @@ def userCheck():
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -190,8 +190,8 @@ def main():
             "-a", dest="user", action="store", help="User name")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.user:
@@ -215,7 +215,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     userCheck()
@@ -227,10 +227,10 @@ def main():
         userid = user_info[1][0]
         XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid)
     else:
-        print "[Error] cmd commands error : %s"%str(user_info[1])
+        print ("[Error] cmd commands error : %s" % str(user_info[1]))
         sys.exit(1)
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
old mode 100644 (file)
new mode 100755 (executable)
index f70351a..ace8cbb
@@ -8,7 +8,7 @@ import sys
 import subprocess
 import string
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR)
 PARAMETERS = None
 #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket"
 TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"
-tct_parser = ConfigParser.ConfigParser()
+tct_parser = configparser.ConfigParser()
 tct_parser.read(TCT_CONFIG_FILE)
 SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')
 PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
@@ -24,14 +24,14 @@ PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -183,8 +183,8 @@ def main():
             "-a", dest="user", action="store", help="User name")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.user:
@@ -203,7 +203,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     user_info = getUSERID()
@@ -213,10 +213,10 @@ def main():
         userid = user_info[1][0]
         XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid)
     else:
-        print "[Error] cmd commands error : %s"%str(user_info[1])
+        print ("[Error] cmd commands error : %s" % str(user_info[1]))
         sys.exit(1)
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
old mode 100644 (file)
new mode 100755 (executable)
index e29187a..f1f0cb4
@@ -40,10 +40,10 @@ import logging
 import zipfile
 import signal
 import subprocess
+import imp
 from optparse import OptionParser
 
-reload(sys)
-sys.setdefaultencoding('utf8')
+imp.reload(sys)
 
 TOOL_VERSION = "v0.1"
 VERSION_FILE = "VERSION"
@@ -363,7 +363,7 @@ def doCMDWithOutput(cmd, time_out=DEFAULT_CMD_TIMEOUT):
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         elapsed_time = time.time() - pre_time
         if cmd_return_code is None:
@@ -938,7 +938,7 @@ def main():
         sys.exit(1)
 
     if BUILD_PARAMETERS.bversion:
-        print "Version: %s" % TOOL_VERSION
+        LOG.info("Version: %s" % TOOL_VERSION)
         sys.exit(0)
 
     if not BUILD_PARAMETERS.srcdir:
old mode 100644 (file)
new mode 100755 (executable)
index d5f9fbb..d636bee
@@ -7,7 +7,7 @@ import time
 import sys
 import subprocess
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -17,14 +17,14 @@ ADB_CMD = "adb"
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -77,8 +77,8 @@ def main():
             "-u", dest="buninstpkg", action="store_true", help="Uninstall package")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.device:
@@ -89,11 +89,11 @@ def main():
                 break
 
     if not PARAMETERS.device:
-        print "No device found"
+        print ("No device found")
         sys.exit(1)
 
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
old mode 100644 (file)
new mode 100755 (executable)
index 59ca043..454b936
@@ -8,7 +8,7 @@ import sys
 import subprocess
 import string
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR)
 PARAMETERS = None
 #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket"
 TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"
-tct_parser = ConfigParser.ConfigParser()
+tct_parser = configparser.ConfigParser()
 tct_parser.read(TCT_CONFIG_FILE)
 SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')
 PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
@@ -32,14 +32,14 @@ def userCheck():
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -190,8 +190,8 @@ def main():
             "-a", dest="user", action="store", help="User name")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.user:
@@ -215,7 +215,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     userCheck()
@@ -227,10 +227,10 @@ def main():
         userid = user_info[1][0]
         XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid)
     else:
-        print "[Error] cmd commands error : %s"%str(user_info[1])
+        print ("[Error] cmd commands error : %s" % str(user_info[1]))
         sys.exit(1)
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
old mode 100644 (file)
new mode 100755 (executable)
index f70351a..ace8cbb
@@ -8,7 +8,7 @@ import sys
 import subprocess
 import string
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR)
 PARAMETERS = None
 #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket"
 TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"
-tct_parser = ConfigParser.ConfigParser()
+tct_parser = configparser.ConfigParser()
 tct_parser.read(TCT_CONFIG_FILE)
 SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')
 PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
@@ -24,14 +24,14 @@ PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -183,8 +183,8 @@ def main():
             "-a", dest="user", action="store", help="User name")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.user:
@@ -203,7 +203,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     user_info = getUSERID()
@@ -213,10 +213,10 @@ def main():
         userid = user_info[1][0]
         XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid)
     else:
-        print "[Error] cmd commands error : %s"%str(user_info[1])
+        print ("[Error] cmd commands error : %s" % str(user_info[1]))
         sys.exit(1)
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
old mode 100644 (file)
new mode 100755 (executable)
index e29187a..f1f0cb4
@@ -40,10 +40,10 @@ import logging
 import zipfile
 import signal
 import subprocess
+import imp
 from optparse import OptionParser
 
-reload(sys)
-sys.setdefaultencoding('utf8')
+imp.reload(sys)
 
 TOOL_VERSION = "v0.1"
 VERSION_FILE = "VERSION"
@@ -363,7 +363,7 @@ def doCMDWithOutput(cmd, time_out=DEFAULT_CMD_TIMEOUT):
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         elapsed_time = time.time() - pre_time
         if cmd_return_code is None:
@@ -938,7 +938,7 @@ def main():
         sys.exit(1)
 
     if BUILD_PARAMETERS.bversion:
-        print "Version: %s" % TOOL_VERSION
+        LOG.info("Version: %s" % TOOL_VERSION)
         sys.exit(0)
 
     if not BUILD_PARAMETERS.srcdir:
old mode 100644 (file)
new mode 100755 (executable)
index d5f9fbb..d636bee
@@ -7,7 +7,7 @@ import time
 import sys
 import subprocess
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -17,14 +17,14 @@ ADB_CMD = "adb"
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -77,8 +77,8 @@ def main():
             "-u", dest="buninstpkg", action="store_true", help="Uninstall package")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.device:
@@ -89,11 +89,11 @@ def main():
                 break
 
     if not PARAMETERS.device:
-        print "No device found"
+        print ("No device found")
         sys.exit(1)
 
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
old mode 100644 (file)
new mode 100755 (executable)
index 59ca043..454b936
@@ -8,7 +8,7 @@ import sys
 import subprocess
 import string
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR)
 PARAMETERS = None
 #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket"
 TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"
-tct_parser = ConfigParser.ConfigParser()
+tct_parser = configparser.ConfigParser()
 tct_parser.read(TCT_CONFIG_FILE)
 SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')
 PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
@@ -32,14 +32,14 @@ def userCheck():
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -190,8 +190,8 @@ def main():
             "-a", dest="user", action="store", help="User name")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.user:
@@ -215,7 +215,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     userCheck()
@@ -227,10 +227,10 @@ def main():
         userid = user_info[1][0]
         XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid)
     else:
-        print "[Error] cmd commands error : %s"%str(user_info[1])
+        print ("[Error] cmd commands error : %s" % str(user_info[1]))
         sys.exit(1)
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
old mode 100644 (file)
new mode 100755 (executable)
index f70351a..ace8cbb
@@ -8,7 +8,7 @@ import sys
 import subprocess
 import string
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR)
 PARAMETERS = None
 #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket"
 TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"
-tct_parser = ConfigParser.ConfigParser()
+tct_parser = configparser.ConfigParser()
 tct_parser.read(TCT_CONFIG_FILE)
 SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')
 PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
@@ -24,14 +24,14 @@ PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -183,8 +183,8 @@ def main():
             "-a", dest="user", action="store", help="User name")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.user:
@@ -203,7 +203,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     user_info = getUSERID()
@@ -213,10 +213,10 @@ def main():
         userid = user_info[1][0]
         XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid)
     else:
-        print "[Error] cmd commands error : %s"%str(user_info[1])
+        print ("[Error] cmd commands error : %s" % str(user_info[1]))
         sys.exit(1)
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
old mode 100644 (file)
new mode 100755 (executable)
index e29187a..f1f0cb4
@@ -40,10 +40,10 @@ import logging
 import zipfile
 import signal
 import subprocess
+import imp
 from optparse import OptionParser
 
-reload(sys)
-sys.setdefaultencoding('utf8')
+imp.reload(sys)
 
 TOOL_VERSION = "v0.1"
 VERSION_FILE = "VERSION"
@@ -363,7 +363,7 @@ def doCMDWithOutput(cmd, time_out=DEFAULT_CMD_TIMEOUT):
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         elapsed_time = time.time() - pre_time
         if cmd_return_code is None:
@@ -938,7 +938,7 @@ def main():
         sys.exit(1)
 
     if BUILD_PARAMETERS.bversion:
-        print "Version: %s" % TOOL_VERSION
+        LOG.info("Version: %s" % TOOL_VERSION)
         sys.exit(0)
 
     if not BUILD_PARAMETERS.srcdir:
old mode 100644 (file)
new mode 100755 (executable)
index d5f9fbb..d636bee
@@ -7,7 +7,7 @@ import time
 import sys
 import subprocess
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -17,14 +17,14 @@ ADB_CMD = "adb"
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -77,8 +77,8 @@ def main():
             "-u", dest="buninstpkg", action="store_true", help="Uninstall package")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.device:
@@ -89,11 +89,11 @@ def main():
                 break
 
     if not PARAMETERS.device:
-        print "No device found"
+        print ("No device found")
         sys.exit(1)
 
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
old mode 100644 (file)
new mode 100755 (executable)
index 59ca043..454b936
@@ -8,7 +8,7 @@ import sys
 import subprocess
 import string
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR)
 PARAMETERS = None
 #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket"
 TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"
-tct_parser = ConfigParser.ConfigParser()
+tct_parser = configparser.ConfigParser()
 tct_parser.read(TCT_CONFIG_FILE)
 SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')
 PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
@@ -32,14 +32,14 @@ def userCheck():
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -190,8 +190,8 @@ def main():
             "-a", dest="user", action="store", help="User name")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.user:
@@ -215,7 +215,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     userCheck()
@@ -227,10 +227,10 @@ def main():
         userid = user_info[1][0]
         XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid)
     else:
-        print "[Error] cmd commands error : %s"%str(user_info[1])
+        print ("[Error] cmd commands error : %s" % str(user_info[1]))
         sys.exit(1)
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
old mode 100644 (file)
new mode 100755 (executable)
index f70351a..ace8cbb
@@ -8,7 +8,7 @@ import sys
 import subprocess
 import string
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR)
 PARAMETERS = None
 #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket"
 TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"
-tct_parser = ConfigParser.ConfigParser()
+tct_parser = configparser.ConfigParser()
 tct_parser.read(TCT_CONFIG_FILE)
 SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')
 PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
@@ -24,14 +24,14 @@ PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -183,8 +183,8 @@ def main():
             "-a", dest="user", action="store", help="User name")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.user:
@@ -203,7 +203,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     user_info = getUSERID()
@@ -213,10 +213,10 @@ def main():
         userid = user_info[1][0]
         XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid)
     else:
-        print "[Error] cmd commands error : %s"%str(user_info[1])
+        print ("[Error] cmd commands error : %s" % str(user_info[1]))
         sys.exit(1)
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
old mode 100644 (file)
new mode 100755 (executable)
index e29187a..f1f0cb4
@@ -40,10 +40,10 @@ import logging
 import zipfile
 import signal
 import subprocess
+import imp
 from optparse import OptionParser
 
-reload(sys)
-sys.setdefaultencoding('utf8')
+imp.reload(sys)
 
 TOOL_VERSION = "v0.1"
 VERSION_FILE = "VERSION"
@@ -363,7 +363,7 @@ def doCMDWithOutput(cmd, time_out=DEFAULT_CMD_TIMEOUT):
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         elapsed_time = time.time() - pre_time
         if cmd_return_code is None:
@@ -938,7 +938,7 @@ def main():
         sys.exit(1)
 
     if BUILD_PARAMETERS.bversion:
-        print "Version: %s" % TOOL_VERSION
+        LOG.info("Version: %s" % TOOL_VERSION)
         sys.exit(0)
 
     if not BUILD_PARAMETERS.srcdir:
old mode 100644 (file)
new mode 100755 (executable)
index d5f9fbb..d636bee
@@ -7,7 +7,7 @@ import time
 import sys
 import subprocess
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -17,14 +17,14 @@ ADB_CMD = "adb"
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -77,8 +77,8 @@ def main():
             "-u", dest="buninstpkg", action="store_true", help="Uninstall package")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.device:
@@ -89,11 +89,11 @@ def main():
                 break
 
     if not PARAMETERS.device:
-        print "No device found"
+        print ("No device found")
         sys.exit(1)
 
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
old mode 100644 (file)
new mode 100755 (executable)
index 59ca043..454b936
@@ -8,7 +8,7 @@ import sys
 import subprocess
 import string
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR)
 PARAMETERS = None
 #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket"
 TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"
-tct_parser = ConfigParser.ConfigParser()
+tct_parser = configparser.ConfigParser()
 tct_parser.read(TCT_CONFIG_FILE)
 SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')
 PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
@@ -32,14 +32,14 @@ def userCheck():
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -190,8 +190,8 @@ def main():
             "-a", dest="user", action="store", help="User name")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.user:
@@ -215,7 +215,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     userCheck()
@@ -227,10 +227,10 @@ def main():
         userid = user_info[1][0]
         XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid)
     else:
-        print "[Error] cmd commands error : %s"%str(user_info[1])
+        print ("[Error] cmd commands error : %s" % str(user_info[1]))
         sys.exit(1)
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
old mode 100644 (file)
new mode 100755 (executable)
index f70351a..ace8cbb
@@ -8,7 +8,7 @@ import sys
 import subprocess
 import string
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR)
 PARAMETERS = None
 #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket"
 TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"
-tct_parser = ConfigParser.ConfigParser()
+tct_parser = configparser.ConfigParser()
 tct_parser.read(TCT_CONFIG_FILE)
 SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')
 PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
@@ -24,14 +24,14 @@ PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -183,8 +183,8 @@ def main():
             "-a", dest="user", action="store", help="User name")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.user:
@@ -203,7 +203,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     user_info = getUSERID()
@@ -213,10 +213,10 @@ def main():
         userid = user_info[1][0]
         XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid)
     else:
-        print "[Error] cmd commands error : %s"%str(user_info[1])
+        print ("[Error] cmd commands error : %s" % str(user_info[1]))
         sys.exit(1)
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
old mode 100644 (file)
new mode 100755 (executable)
index e29187a..f1f0cb4
@@ -40,10 +40,10 @@ import logging
 import zipfile
 import signal
 import subprocess
+import imp
 from optparse import OptionParser
 
-reload(sys)
-sys.setdefaultencoding('utf8')
+imp.reload(sys)
 
 TOOL_VERSION = "v0.1"
 VERSION_FILE = "VERSION"
@@ -363,7 +363,7 @@ def doCMDWithOutput(cmd, time_out=DEFAULT_CMD_TIMEOUT):
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         elapsed_time = time.time() - pre_time
         if cmd_return_code is None:
@@ -938,7 +938,7 @@ def main():
         sys.exit(1)
 
     if BUILD_PARAMETERS.bversion:
-        print "Version: %s" % TOOL_VERSION
+        LOG.info("Version: %s" % TOOL_VERSION)
         sys.exit(0)
 
     if not BUILD_PARAMETERS.srcdir:
old mode 100644 (file)
new mode 100755 (executable)
index d5f9fbb..d636bee
@@ -7,7 +7,7 @@ import time
 import sys
 import subprocess
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -17,14 +17,14 @@ ADB_CMD = "adb"
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -77,8 +77,8 @@ def main():
             "-u", dest="buninstpkg", action="store_true", help="Uninstall package")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.device:
@@ -89,11 +89,11 @@ def main():
                 break
 
     if not PARAMETERS.device:
-        print "No device found"
+        print ("No device found")
         sys.exit(1)
 
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
old mode 100644 (file)
new mode 100755 (executable)
index 59ca043..454b936
@@ -8,7 +8,7 @@ import sys
 import subprocess
 import string
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR)
 PARAMETERS = None
 #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket"
 TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"
-tct_parser = ConfigParser.ConfigParser()
+tct_parser = configparser.ConfigParser()
 tct_parser.read(TCT_CONFIG_FILE)
 SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')
 PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
@@ -32,14 +32,14 @@ def userCheck():
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -190,8 +190,8 @@ def main():
             "-a", dest="user", action="store", help="User name")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.user:
@@ -215,7 +215,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     userCheck()
@@ -227,10 +227,10 @@ def main():
         userid = user_info[1][0]
         XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid)
     else:
-        print "[Error] cmd commands error : %s"%str(user_info[1])
+        print ("[Error] cmd commands error : %s" % str(user_info[1]))
         sys.exit(1)
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
old mode 100644 (file)
new mode 100755 (executable)
index f70351a..ace8cbb
@@ -8,7 +8,7 @@ import sys
 import subprocess
 import string
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR)
 PARAMETERS = None
 #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket"
 TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"
-tct_parser = ConfigParser.ConfigParser()
+tct_parser = configparser.ConfigParser()
 tct_parser.read(TCT_CONFIG_FILE)
 SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')
 PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
@@ -24,14 +24,14 @@ PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -183,8 +183,8 @@ def main():
             "-a", dest="user", action="store", help="User name")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.user:
@@ -203,7 +203,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     user_info = getUSERID()
@@ -213,10 +213,10 @@ def main():
         userid = user_info[1][0]
         XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid)
     else:
-        print "[Error] cmd commands error : %s"%str(user_info[1])
+        print ("[Error] cmd commands error : %s" % str(user_info[1]))
         sys.exit(1)
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
old mode 100644 (file)
new mode 100755 (executable)
index e29187a..f1f0cb4
@@ -40,10 +40,10 @@ import logging
 import zipfile
 import signal
 import subprocess
+import imp
 from optparse import OptionParser
 
-reload(sys)
-sys.setdefaultencoding('utf8')
+imp.reload(sys)
 
 TOOL_VERSION = "v0.1"
 VERSION_FILE = "VERSION"
@@ -363,7 +363,7 @@ def doCMDWithOutput(cmd, time_out=DEFAULT_CMD_TIMEOUT):
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         elapsed_time = time.time() - pre_time
         if cmd_return_code is None:
@@ -938,7 +938,7 @@ def main():
         sys.exit(1)
 
     if BUILD_PARAMETERS.bversion:
-        print "Version: %s" % TOOL_VERSION
+        LOG.info("Version: %s" % TOOL_VERSION)
         sys.exit(0)
 
     if not BUILD_PARAMETERS.srcdir:
old mode 100644 (file)
new mode 100755 (executable)
index d5f9fbb..d636bee
@@ -7,7 +7,7 @@ import time
 import sys
 import subprocess
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -17,14 +17,14 @@ ADB_CMD = "adb"
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -77,8 +77,8 @@ def main():
             "-u", dest="buninstpkg", action="store_true", help="Uninstall package")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.device:
@@ -89,11 +89,11 @@ def main():
                 break
 
     if not PARAMETERS.device:
-        print "No device found"
+        print ("No device found")
         sys.exit(1)
 
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
old mode 100644 (file)
new mode 100755 (executable)
index 59ca043..454b936
@@ -8,7 +8,7 @@ import sys
 import subprocess
 import string
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR)
 PARAMETERS = None
 #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket"
 TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"
-tct_parser = ConfigParser.ConfigParser()
+tct_parser = configparser.ConfigParser()
 tct_parser.read(TCT_CONFIG_FILE)
 SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')
 PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
@@ -32,14 +32,14 @@ def userCheck():
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -190,8 +190,8 @@ def main():
             "-a", dest="user", action="store", help="User name")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.user:
@@ -215,7 +215,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     userCheck()
@@ -227,10 +227,10 @@ def main():
         userid = user_info[1][0]
         XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid)
     else:
-        print "[Error] cmd commands error : %s"%str(user_info[1])
+        print ("[Error] cmd commands error : %s" % str(user_info[1]))
         sys.exit(1)
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
old mode 100644 (file)
new mode 100755 (executable)
index f70351a..ace8cbb
@@ -8,7 +8,7 @@ import sys
 import subprocess
 import string
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR)
 PARAMETERS = None
 #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket"
 TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"
-tct_parser = ConfigParser.ConfigParser()
+tct_parser = configparser.ConfigParser()
 tct_parser.read(TCT_CONFIG_FILE)
 SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')
 PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
@@ -24,14 +24,14 @@ PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -183,8 +183,8 @@ def main():
             "-a", dest="user", action="store", help="User name")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.user:
@@ -203,7 +203,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     user_info = getUSERID()
@@ -213,10 +213,10 @@ def main():
         userid = user_info[1][0]
         XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid)
     else:
-        print "[Error] cmd commands error : %s"%str(user_info[1])
+        print ("[Error] cmd commands error : %s" % str(user_info[1]))
         sys.exit(1)
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
old mode 100644 (file)
new mode 100755 (executable)
index e29187a..f1f0cb4
@@ -40,10 +40,10 @@ import logging
 import zipfile
 import signal
 import subprocess
+import imp
 from optparse import OptionParser
 
-reload(sys)
-sys.setdefaultencoding('utf8')
+imp.reload(sys)
 
 TOOL_VERSION = "v0.1"
 VERSION_FILE = "VERSION"
@@ -363,7 +363,7 @@ def doCMDWithOutput(cmd, time_out=DEFAULT_CMD_TIMEOUT):
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         elapsed_time = time.time() - pre_time
         if cmd_return_code is None:
@@ -938,7 +938,7 @@ def main():
         sys.exit(1)
 
     if BUILD_PARAMETERS.bversion:
-        print "Version: %s" % TOOL_VERSION
+        LOG.info("Version: %s" % TOOL_VERSION)
         sys.exit(0)
 
     if not BUILD_PARAMETERS.srcdir:
index d5f9fbb96f7b82ebce4068b79598df34023b9b0f..d636bee034d8504fbfee33e3d6fe297f4e9bee1a 100755 (executable)
@@ -7,7 +7,7 @@ import time
 import sys
 import subprocess
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -17,14 +17,14 @@ ADB_CMD = "adb"
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -77,8 +77,8 @@ def main():
             "-u", dest="buninstpkg", action="store_true", help="Uninstall package")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.device:
@@ -89,11 +89,11 @@ def main():
                 break
 
     if not PARAMETERS.device:
-        print "No device found"
+        print ("No device found")
         sys.exit(1)
 
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
index 59ca043a9fb17c7b209c7d3f6fd79ad30f1e5423..454b936b7bcf100587116e577b5e3b0630ff68b6 100755 (executable)
@@ -8,7 +8,7 @@ import sys
 import subprocess
 import string
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR)
 PARAMETERS = None
 #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket"
 TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"
-tct_parser = ConfigParser.ConfigParser()
+tct_parser = configparser.ConfigParser()
 tct_parser.read(TCT_CONFIG_FILE)
 SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')
 PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
@@ -32,14 +32,14 @@ def userCheck():
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -190,8 +190,8 @@ def main():
             "-a", dest="user", action="store", help="User name")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.user:
@@ -215,7 +215,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     userCheck()
@@ -227,10 +227,10 @@ def main():
         userid = user_info[1][0]
         XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid)
     else:
-        print "[Error] cmd commands error : %s"%str(user_info[1])
+        print ("[Error] cmd commands error : %s" % str(user_info[1]))
         sys.exit(1)
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
index f70351a9bca5ce6c87032da6adacd41a268563bc..ace8cbba96610eaf7e44d169716ce4fc3b921873 100755 (executable)
@@ -8,7 +8,7 @@ import sys
 import subprocess
 import string
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR)
 PARAMETERS = None
 #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket"
 TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"
-tct_parser = ConfigParser.ConfigParser()
+tct_parser = configparser.ConfigParser()
 tct_parser.read(TCT_CONFIG_FILE)
 SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')
 PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
@@ -24,14 +24,14 @@ PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -183,8 +183,8 @@ def main():
             "-a", dest="user", action="store", help="User name")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.user:
@@ -203,7 +203,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     user_info = getUSERID()
@@ -213,10 +213,10 @@ def main():
         userid = user_info[1][0]
         XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid)
     else:
-        print "[Error] cmd commands error : %s"%str(user_info[1])
+        print ("[Error] cmd commands error : %s" % str(user_info[1]))
         sys.exit(1)
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
index e29187a0bae2e2dce107adc8fe9ecb8898559397..f1f0cb470fad677077cced4db9cf44015525827c 100755 (executable)
@@ -40,10 +40,10 @@ import logging
 import zipfile
 import signal
 import subprocess
+import imp
 from optparse import OptionParser
 
-reload(sys)
-sys.setdefaultencoding('utf8')
+imp.reload(sys)
 
 TOOL_VERSION = "v0.1"
 VERSION_FILE = "VERSION"
@@ -363,7 +363,7 @@ def doCMDWithOutput(cmd, time_out=DEFAULT_CMD_TIMEOUT):
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         elapsed_time = time.time() - pre_time
         if cmd_return_code is None:
@@ -938,7 +938,7 @@ def main():
         sys.exit(1)
 
     if BUILD_PARAMETERS.bversion:
-        print "Version: %s" % TOOL_VERSION
+        LOG.info("Version: %s" % TOOL_VERSION)
         sys.exit(0)
 
     if not BUILD_PARAMETERS.srcdir:
index d5f9fbb96f7b82ebce4068b79598df34023b9b0f..d636bee034d8504fbfee33e3d6fe297f4e9bee1a 100755 (executable)
@@ -7,7 +7,7 @@ import time
 import sys
 import subprocess
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -17,14 +17,14 @@ ADB_CMD = "adb"
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -77,8 +77,8 @@ def main():
             "-u", dest="buninstpkg", action="store_true", help="Uninstall package")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.device:
@@ -89,11 +89,11 @@ def main():
                 break
 
     if not PARAMETERS.device:
-        print "No device found"
+        print ("No device found")
         sys.exit(1)
 
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
index 59ca043a9fb17c7b209c7d3f6fd79ad30f1e5423..454b936b7bcf100587116e577b5e3b0630ff68b6 100755 (executable)
@@ -8,7 +8,7 @@ import sys
 import subprocess
 import string
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR)
 PARAMETERS = None
 #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket"
 TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"
-tct_parser = ConfigParser.ConfigParser()
+tct_parser = configparser.ConfigParser()
 tct_parser.read(TCT_CONFIG_FILE)
 SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')
 PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
@@ -32,14 +32,14 @@ def userCheck():
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -190,8 +190,8 @@ def main():
             "-a", dest="user", action="store", help="User name")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.user:
@@ -215,7 +215,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     userCheck()
@@ -227,10 +227,10 @@ def main():
         userid = user_info[1][0]
         XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid)
     else:
-        print "[Error] cmd commands error : %s"%str(user_info[1])
+        print ("[Error] cmd commands error : %s" % str(user_info[1]))
         sys.exit(1)
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
index f70351a9bca5ce6c87032da6adacd41a268563bc..ace8cbba96610eaf7e44d169716ce4fc3b921873 100755 (executable)
@@ -8,7 +8,7 @@ import sys
 import subprocess
 import string
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR)
 PARAMETERS = None
 #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket"
 TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"
-tct_parser = ConfigParser.ConfigParser()
+tct_parser = configparser.ConfigParser()
 tct_parser.read(TCT_CONFIG_FILE)
 SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')
 PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
@@ -24,14 +24,14 @@ PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -183,8 +183,8 @@ def main():
             "-a", dest="user", action="store", help="User name")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.user:
@@ -203,7 +203,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     user_info = getUSERID()
@@ -213,10 +213,10 @@ def main():
         userid = user_info[1][0]
         XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid)
     else:
-        print "[Error] cmd commands error : %s"%str(user_info[1])
+        print ("[Error] cmd commands error : %s" % str(user_info[1]))
         sys.exit(1)
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
index e29187a0bae2e2dce107adc8fe9ecb8898559397..f1f0cb470fad677077cced4db9cf44015525827c 100755 (executable)
@@ -40,10 +40,10 @@ import logging
 import zipfile
 import signal
 import subprocess
+import imp
 from optparse import OptionParser
 
-reload(sys)
-sys.setdefaultencoding('utf8')
+imp.reload(sys)
 
 TOOL_VERSION = "v0.1"
 VERSION_FILE = "VERSION"
@@ -363,7 +363,7 @@ def doCMDWithOutput(cmd, time_out=DEFAULT_CMD_TIMEOUT):
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         elapsed_time = time.time() - pre_time
         if cmd_return_code is None:
@@ -938,7 +938,7 @@ def main():
         sys.exit(1)
 
     if BUILD_PARAMETERS.bversion:
-        print "Version: %s" % TOOL_VERSION
+        LOG.info("Version: %s" % TOOL_VERSION)
         sys.exit(0)
 
     if not BUILD_PARAMETERS.srcdir:
index d5f9fbb96f7b82ebce4068b79598df34023b9b0f..d636bee034d8504fbfee33e3d6fe297f4e9bee1a 100755 (executable)
@@ -7,7 +7,7 @@ import time
 import sys
 import subprocess
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -17,14 +17,14 @@ ADB_CMD = "adb"
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -77,8 +77,8 @@ def main():
             "-u", dest="buninstpkg", action="store_true", help="Uninstall package")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.device:
@@ -89,11 +89,11 @@ def main():
                 break
 
     if not PARAMETERS.device:
-        print "No device found"
+        print ("No device found")
         sys.exit(1)
 
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
index 2a667fa7218918b336951b938691caca1c58a600..54e2748ab5f56f1e80d5ae0018b503539e48a004 100755 (executable)
-#!/usr/bin/env python
-
-import os
-import shutil
-import glob
-import time
-import sys
-import subprocess
-import string
+#!/usr/bin/env python\r
+\r
+import os\r
+import shutil\r
+import glob\r
+import time\r
+import sys\r
+import subprocess\r
+import string\r
 from optparse import OptionParser, make_option\r
-import ConfigParser
-
-
-SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
-PKG_NAME = os.path.basename(SCRIPT_DIR)
-PARAMETERS = None
-#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket"
-TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"
-tct_parser = ConfigParser.ConfigParser()
-tct_parser.read(TCT_CONFIG_FILE)
-SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')
-PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
-EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30')
-ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30')
-
-def userCheck():
-    global GLOVAL_OPT
-    if ADMIN_USER_30 == EXECUTION_MODE_30:
-        GLOVAL_OPT="--global"
-    else:
-        GLOVAL_OPT=""
-
-def doCMD(cmd):
-    # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
-    output = []
-    cmd_return_code = 1
-    cmd_proc = subprocess.Popen(
-        cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
-
-    while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
-        cmd_return_code = cmd_proc.poll()
-        if output_line == '' and cmd_return_code != None:
-            break
-        sys.stdout.write("%s\n" % output_line)
-        sys.stdout.flush()
-        output.append(output_line)
-
-    return (cmd_return_code, output)
-
-def updateCMD(cmd=None):
-    if "pkgcmd" in cmd:
-        cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd)
-    return cmd
-def getUSERID():
-    if PARAMETERS.mode == "SDB":
-        cmd = "sdb -s %s shell id -u %s" % (
-            PARAMETERS.device, PARAMETERS.user)
-    else:
-        cmd = "ssh %s \"id -u %s\"" % (
-            PARAMETERS.device, PARAMETERS.user )
-    return doCMD(cmd)
-
-
-
-
-def getPKGID(pkg_name=None):
-    if PARAMETERS.mode == "SDB":
-        cmd = "sdb -s %s shell %s" % (
-            PARAMETERS.device, updateCMD('pkgcmd -l'))
-    else:
-        cmd = "ssh %s \"%s\"" % (
-            PARAMETERS.device, updateCMD('pkgcmd -l'))
-
-    (return_code, output) = doCMD(cmd)
-    if return_code != 0:
-        return None
-
-    test_pkg_id = None
-    for line in output:
-        if line.find("[" + pkg_name + "]") != -1:
-            pkgidIndex = line.split().index("pkgid")
-            test_pkg_id = line.split()[pkgidIndex+1].strip("[]")
-            break
-    return test_pkg_id
-
-
-def doRemoteCMD(cmd=None):
-    if PARAMETERS.mode == "SDB":
-        cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd))
-    else:
-        cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd))
-
-    return doCMD(cmd)
-
-
-def doRemoteCopy(src=None, dest=None):
-    if PARAMETERS.mode == "SDB":
-        cmd_prefix = "sdb -s %s push" % PARAMETERS.device
-        cmd = "%s %s %s" % (cmd_prefix, src, dest)
-    else:
-        cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest)
-
-    (return_code, output) = doCMD(cmd)
-    doRemoteCMD("sync")
-
-    if return_code != 0:
-        return True
-    else:
-        return False
-
-
-def uninstPKGs():
-    action_status = True
-    for root, dirs, files in os.walk(SCRIPT_DIR):
-        if root.endswith("mediasrc"):
-            continue
-
-        for file in files:
-            if file.endswith(".wgt"):
-                pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0]))
-                if not pkg_id:
-                    action_status = False
-                    continue
-                (return_code, output) = doRemoteCMD(
-                    "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id))
-                for line in output:
-                    if "Failure" in line:
-                        action_status = False
-                        break
-
-    (return_code, output) = doRemoteCMD(
-        "rm -rf %s" % PKG_SRC_DIR)
-    if return_code != 0:
-        action_status = False
-
-    return action_status
-
-
-def instPKGs():
-    action_status = True
-    (return_code, output) = doRemoteCMD(
-        "mkdir -p %s" % PKG_SRC_DIR)
-    if return_code != 0:
-        action_status = False
-    for root, dirs, files in os.walk(SCRIPT_DIR):
-        if root.endswith("mediasrc"):
-            continue
-
-        for file in files:
-            if file.endswith(".wgt"):
-                if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)):
-                    action_status = False
-                (return_code, output) = doRemoteCMD(
-                    "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file))
-                doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file))
-                for line in output:
-                    if "Failure" in line:
-                        action_status = False
-                        break
-
-    # Do some special copy/delete... steps
-    '''
-    (return_code, output) = doRemoteCMD(
-        "mkdir -p %s/tests" % PKG_SRC_DIR)
-    if return_code != 0:
-        action_status = False
-
-    if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR):
-        action_status = False
-    '''
-
-    return action_status
-
-
-def main():
-    try:
-        usage = "usage: inst.py -i"
-        opts_parser = OptionParser(usage=usage)
-        opts_parser.add_option(
-            "-m", dest="mode", action="store", help="Specify mode")
-        opts_parser.add_option(
-            "-s", dest="device", action="store", help="Specify device")
-        opts_parser.add_option(
-            "-i", dest="binstpkg", action="store_true", help="Install package")
-        opts_parser.add_option(
-            "-u", dest="buninstpkg", action="store_true", help="Uninstall package")
-        opts_parser.add_option(
-            "-a", dest="user", action="store", help="User name")
-        global PARAMETERS
-        (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
-        sys.exit(1)
-
-    if not PARAMETERS.user:
-        PARAMETERS.user = EXECUTION_MODE_30
-
-    #global SRC_DIR, PKG_SRC_DIR
-    #SRC_DIR = "/home/%s/share" % PARAMETERS.user
-    #PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
-
-    if not PARAMETERS.mode:
-        PARAMETERS.mode = "SDB"
-
-    if PARAMETERS.mode == "SDB":
-        if not PARAMETERS.device:
-            (return_code, output) = doCMD("sdb devices")
-            for line in output:
-                if str.find(line, "\tdevice") != -1:
-                    PARAMETERS.device = line.split("\t")[0]
-                    break
-    else:
-        PARAMETERS.mode = "SSH"
-
-    if not PARAMETERS.device:
-        print "No device provided"
-        sys.exit(1)
-
-    userCheck()
-
-    user_info = getUSERID()
-    re_code = user_info[0]
-    if re_code == 0 :
-        global XW_ENV
-        userid = user_info[1][0]
-        XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid)
-    else:
-        print "[Error] cmd commands error : %s"%str(user_info[1])
-        sys.exit(1)
-    if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
-        sys.exit(1)
-
-    if PARAMETERS.buninstpkg:
-        if not uninstPKGs():
-            sys.exit(1)
-    else:
-        if not instPKGs():
-            sys.exit(1)
-
-if __name__ == "__main__":
-    main()
-    sys.exit(0)
+import configparser\r
+\r
+\r
+SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))\r
+PKG_NAME = os.path.basename(SCRIPT_DIR)\r
+PARAMETERS = None\r
+#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket"\r
+TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"\r
+tct_parser = configparser.ConfigParser()\r
+tct_parser.read(TCT_CONFIG_FILE)\r
+SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')\r
+PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)\r
+EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30')\r
+ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30')\r
+\r
+def userCheck():\r
+    global GLOVAL_OPT\r
+    if ADMIN_USER_30 == EXECUTION_MODE_30:\r
+        GLOVAL_OPT="--global"\r
+    else:\r
+        GLOVAL_OPT=""\r
+\r
+def doCMD(cmd):\r
+    # Do not need handle timeout in this short script, let tool do it\r
+    print ("-->> \"%s\"" % cmd)\r
+    output = []\r
+    cmd_return_code = 1\r
+    cmd_proc = subprocess.Popen(\r
+        cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)\r
+\r
+    while True:\r
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")\r
+        cmd_return_code = cmd_proc.poll()\r
+        if output_line == '' and cmd_return_code != None:\r
+            break\r
+        sys.stdout.write("%s\n" % output_line)\r
+        sys.stdout.flush()\r
+        output.append(output_line)\r
+\r
+    return (cmd_return_code, output)\r
+\r
+def updateCMD(cmd=None):\r
+    if "pkgcmd" in cmd:\r
+        cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd)\r
+    return cmd\r
+def getUSERID():\r
+    if PARAMETERS.mode == "SDB":\r
+        cmd = "sdb -s %s shell id -u %s" % (\r
+            PARAMETERS.device, PARAMETERS.user)\r
+    else:\r
+        cmd = "ssh %s \"id -u %s\"" % (\r
+            PARAMETERS.device, PARAMETERS.user )\r
+    return doCMD(cmd)\r
+\r
+\r
+\r
+\r
+def getPKGID(pkg_name=None):\r
+    if PARAMETERS.mode == "SDB":\r
+        cmd = "sdb -s %s shell %s" % (\r
+            PARAMETERS.device, updateCMD('pkgcmd -l'))\r
+    else:\r
+        cmd = "ssh %s \"%s\"" % (\r
+            PARAMETERS.device, updateCMD('pkgcmd -l'))\r
+\r
+    (return_code, output) = doCMD(cmd)\r
+    if return_code != 0:\r
+        return None\r
+\r
+    test_pkg_id = None\r
+    for line in output:\r
+        if line.find("[" + pkg_name + "]") != -1:\r
+            pkgidIndex = line.split().index("pkgid")\r
+            test_pkg_id = line.split()[pkgidIndex+1].strip("[]")\r
+            break\r
+    return test_pkg_id\r
+\r
+\r
+def doRemoteCMD(cmd=None):\r
+    if PARAMETERS.mode == "SDB":\r
+        cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd))\r
+    else:\r
+        cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd))\r
+\r
+    return doCMD(cmd)\r
+\r
+\r
+def doRemoteCopy(src=None, dest=None):\r
+    if PARAMETERS.mode == "SDB":\r
+        cmd_prefix = "sdb -s %s push" % PARAMETERS.device\r
+        cmd = "%s %s %s" % (cmd_prefix, src, dest)\r
+    else:\r
+        cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest)\r
+\r
+    (return_code, output) = doCMD(cmd)\r
+    doRemoteCMD("sync")\r
+\r
+    if return_code != 0:\r
+        return True\r
+    else:\r
+        return False\r
+\r
+\r
+def uninstPKGs():\r
+    action_status = True\r
+    for root, dirs, files in os.walk(SCRIPT_DIR):\r
+        if root.endswith("mediasrc"):\r
+            continue\r
+\r
+        for file in files:\r
+            if file.endswith(".wgt"):\r
+                pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0]))\r
+                if not pkg_id:\r
+                    action_status = False\r
+                    continue\r
+                (return_code, output) = doRemoteCMD(\r
+                    "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id))\r
+                for line in output:\r
+                    if "Failure" in line:\r
+                        action_status = False\r
+                        break\r
+\r
+    (return_code, output) = doRemoteCMD(\r
+        "rm -rf %s" % PKG_SRC_DIR)\r
+    if return_code != 0:\r
+        action_status = False\r
+\r
+    return action_status\r
+\r
+\r
+def instPKGs():\r
+    action_status = True\r
+    (return_code, output) = doRemoteCMD(\r
+        "mkdir -p %s" % PKG_SRC_DIR)\r
+    if return_code != 0:\r
+        action_status = False\r
+    for root, dirs, files in os.walk(SCRIPT_DIR):\r
+        if root.endswith("mediasrc"):\r
+            continue\r
+\r
+        for file in files:\r
+            if file.endswith(".wgt"):\r
+                if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)):\r
+                    action_status = False\r
+                (return_code, output) = doRemoteCMD(\r
+                    "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file))\r
+                doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file))\r
+                for line in output:\r
+                    if "Failure" in line:\r
+                        action_status = False\r
+                        break\r
+\r
+    # Do some special copy/delete... steps\r
+    '''\r
+    (return_code, output) = doRemoteCMD(\r
+        "mkdir -p %s/tests" % PKG_SRC_DIR)\r
+    if return_code != 0:\r
+        action_status = False\r
+\r
+    if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR):\r
+        action_status = False\r
+    '''\r
+\r
+    return action_status\r
+\r
+\r
+def main():\r
+    try:\r
+        usage = "usage: inst.py -i"\r
+        opts_parser = OptionParser(usage=usage)\r
+        opts_parser.add_option(\r
+            "-m", dest="mode", action="store", help="Specify mode")\r
+        opts_parser.add_option(\r
+            "-s", dest="device", action="store", help="Specify device")\r
+        opts_parser.add_option(\r
+            "-i", dest="binstpkg", action="store_true", help="Install package")\r
+        opts_parser.add_option(\r
+            "-u", dest="buninstpkg", action="store_true", help="Uninstall package")\r
+        opts_parser.add_option(\r
+            "-a", dest="user", action="store", help="User name")\r
+        global PARAMETERS\r
+        (PARAMETERS, args) = opts_parser.parse_args()\r
+    except Exception as e:\r
+        print ("Got wrong option: %s, exit ..." % e)\r
+        sys.exit(1)\r
+\r
+    if not PARAMETERS.user:\r
+        PARAMETERS.user = EXECUTION_MODE_30\r
+\r
+    #global SRC_DIR, PKG_SRC_DIR\r
+    #SRC_DIR = "/home/%s/share" % PARAMETERS.user\r
+    #PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)\r
+\r
+    if not PARAMETERS.mode:\r
+        PARAMETERS.mode = "SDB"\r
+\r
+    if PARAMETERS.mode == "SDB":\r
+        if not PARAMETERS.device:\r
+            (return_code, output) = doCMD("sdb devices")\r
+            for line in output:\r
+                if str.find(line, "\tdevice") != -1:\r
+                    PARAMETERS.device = line.split("\t")[0]\r
+                    break\r
+    else:\r
+        PARAMETERS.mode = "SSH"\r
+\r
+    if not PARAMETERS.device:\r
+        print ("No device provided")\r
+        sys.exit(1)\r
+\r
+    userCheck()\r
+\r
+    user_info = getUSERID()\r
+    re_code = user_info[0]\r
+    if re_code == 0 :\r
+        global XW_ENV\r
+        userid = user_info[1][0]\r
+        XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid)\r
+    else:\r
+        print ("[Error] cmd commands error : %s" % str(user_info[1]))\r
+        sys.exit(1)\r
+    if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:\r
+        print ("-i and -u are conflict")\r
+        sys.exit(1)\r
+\r
+    if PARAMETERS.buninstpkg:\r
+        if not uninstPKGs():\r
+            sys.exit(1)\r
+    else:\r
+        if not instPKGs():\r
+            sys.exit(1)\r
+\r
+if __name__ == "__main__":\r
+    main()\r
+    sys.exit(0)\r
index f70351a9bca5ce6c87032da6adacd41a268563bc..ace8cbba96610eaf7e44d169716ce4fc3b921873 100755 (executable)
@@ -8,7 +8,7 @@ import sys
 import subprocess
 import string
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR)
 PARAMETERS = None
 #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket"
 TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"
-tct_parser = ConfigParser.ConfigParser()
+tct_parser = configparser.ConfigParser()
 tct_parser.read(TCT_CONFIG_FILE)
 SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')
 PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
@@ -24,14 +24,14 @@ PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -183,8 +183,8 @@ def main():
             "-a", dest="user", action="store", help="User name")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.user:
@@ -203,7 +203,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     user_info = getUSERID()
@@ -213,10 +213,10 @@ def main():
         userid = user_info[1][0]
         XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid)
     else:
-        print "[Error] cmd commands error : %s"%str(user_info[1])
+        print ("[Error] cmd commands error : %s" % str(user_info[1]))
         sys.exit(1)
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
index e29187a0bae2e2dce107adc8fe9ecb8898559397..f1f0cb470fad677077cced4db9cf44015525827c 100755 (executable)
@@ -40,10 +40,10 @@ import logging
 import zipfile
 import signal
 import subprocess
+import imp
 from optparse import OptionParser
 
-reload(sys)
-sys.setdefaultencoding('utf8')
+imp.reload(sys)
 
 TOOL_VERSION = "v0.1"
 VERSION_FILE = "VERSION"
@@ -363,7 +363,7 @@ def doCMDWithOutput(cmd, time_out=DEFAULT_CMD_TIMEOUT):
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         elapsed_time = time.time() - pre_time
         if cmd_return_code is None:
@@ -938,7 +938,7 @@ def main():
         sys.exit(1)
 
     if BUILD_PARAMETERS.bversion:
-        print "Version: %s" % TOOL_VERSION
+        LOG.info("Version: %s" % TOOL_VERSION)
         sys.exit(0)
 
     if not BUILD_PARAMETERS.srcdir:
index d5f9fbb96f7b82ebce4068b79598df34023b9b0f..d636bee034d8504fbfee33e3d6fe297f4e9bee1a 100755 (executable)
@@ -7,7 +7,7 @@ import time
 import sys
 import subprocess
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -17,14 +17,14 @@ ADB_CMD = "adb"
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -77,8 +77,8 @@ def main():
             "-u", dest="buninstpkg", action="store_true", help="Uninstall package")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.device:
@@ -89,11 +89,11 @@ def main():
                 break
 
     if not PARAMETERS.device:
-        print "No device found"
+        print ("No device found")
         sys.exit(1)
 
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
index 59ca043a9fb17c7b209c7d3f6fd79ad30f1e5423..454b936b7bcf100587116e577b5e3b0630ff68b6 100755 (executable)
@@ -8,7 +8,7 @@ import sys
 import subprocess
 import string
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR)
 PARAMETERS = None
 #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket"
 TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"
-tct_parser = ConfigParser.ConfigParser()
+tct_parser = configparser.ConfigParser()
 tct_parser.read(TCT_CONFIG_FILE)
 SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')
 PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
@@ -32,14 +32,14 @@ def userCheck():
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -190,8 +190,8 @@ def main():
             "-a", dest="user", action="store", help="User name")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.user:
@@ -215,7 +215,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     userCheck()
@@ -227,10 +227,10 @@ def main():
         userid = user_info[1][0]
         XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid)
     else:
-        print "[Error] cmd commands error : %s"%str(user_info[1])
+        print ("[Error] cmd commands error : %s" % str(user_info[1]))
         sys.exit(1)
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
index f70351a9bca5ce6c87032da6adacd41a268563bc..ace8cbba96610eaf7e44d169716ce4fc3b921873 100755 (executable)
@@ -8,7 +8,7 @@ import sys
 import subprocess
 import string
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR)
 PARAMETERS = None
 #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket"
 TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"
-tct_parser = ConfigParser.ConfigParser()
+tct_parser = configparser.ConfigParser()
 tct_parser.read(TCT_CONFIG_FILE)
 SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')
 PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
@@ -24,14 +24,14 @@ PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -183,8 +183,8 @@ def main():
             "-a", dest="user", action="store", help="User name")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.user:
@@ -203,7 +203,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     user_info = getUSERID()
@@ -213,10 +213,10 @@ def main():
         userid = user_info[1][0]
         XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid)
     else:
-        print "[Error] cmd commands error : %s"%str(user_info[1])
+        print ("[Error] cmd commands error : %s" % str(user_info[1]))
         sys.exit(1)
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
index e29187a0bae2e2dce107adc8fe9ecb8898559397..f1f0cb470fad677077cced4db9cf44015525827c 100755 (executable)
@@ -40,10 +40,10 @@ import logging
 import zipfile
 import signal
 import subprocess
+import imp
 from optparse import OptionParser
 
-reload(sys)
-sys.setdefaultencoding('utf8')
+imp.reload(sys)
 
 TOOL_VERSION = "v0.1"
 VERSION_FILE = "VERSION"
@@ -363,7 +363,7 @@ def doCMDWithOutput(cmd, time_out=DEFAULT_CMD_TIMEOUT):
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         elapsed_time = time.time() - pre_time
         if cmd_return_code is None:
@@ -938,7 +938,7 @@ def main():
         sys.exit(1)
 
     if BUILD_PARAMETERS.bversion:
-        print "Version: %s" % TOOL_VERSION
+        LOG.info("Version: %s" % TOOL_VERSION)
         sys.exit(0)
 
     if not BUILD_PARAMETERS.srcdir:
index d5f9fbb96f7b82ebce4068b79598df34023b9b0f..d636bee034d8504fbfee33e3d6fe297f4e9bee1a 100755 (executable)
@@ -7,7 +7,7 @@ import time
 import sys
 import subprocess
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -17,14 +17,14 @@ ADB_CMD = "adb"
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -77,8 +77,8 @@ def main():
             "-u", dest="buninstpkg", action="store_true", help="Uninstall package")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.device:
@@ -89,11 +89,11 @@ def main():
                 break
 
     if not PARAMETERS.device:
-        print "No device found"
+        print ("No device found")
         sys.exit(1)
 
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
index 59ca043a9fb17c7b209c7d3f6fd79ad30f1e5423..454b936b7bcf100587116e577b5e3b0630ff68b6 100755 (executable)
@@ -8,7 +8,7 @@ import sys
 import subprocess
 import string
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR)
 PARAMETERS = None
 #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket"
 TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"
-tct_parser = ConfigParser.ConfigParser()
+tct_parser = configparser.ConfigParser()
 tct_parser.read(TCT_CONFIG_FILE)
 SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')
 PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
@@ -32,14 +32,14 @@ def userCheck():
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -190,8 +190,8 @@ def main():
             "-a", dest="user", action="store", help="User name")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.user:
@@ -215,7 +215,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     userCheck()
@@ -227,10 +227,10 @@ def main():
         userid = user_info[1][0]
         XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid)
     else:
-        print "[Error] cmd commands error : %s"%str(user_info[1])
+        print ("[Error] cmd commands error : %s" % str(user_info[1]))
         sys.exit(1)
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
index f70351a9bca5ce6c87032da6adacd41a268563bc..ace8cbba96610eaf7e44d169716ce4fc3b921873 100755 (executable)
@@ -8,7 +8,7 @@ import sys
 import subprocess
 import string
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR)
 PARAMETERS = None
 #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket"
 TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"
-tct_parser = ConfigParser.ConfigParser()
+tct_parser = configparser.ConfigParser()
 tct_parser.read(TCT_CONFIG_FILE)
 SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')
 PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
@@ -24,14 +24,14 @@ PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -183,8 +183,8 @@ def main():
             "-a", dest="user", action="store", help="User name")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.user:
@@ -203,7 +203,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     user_info = getUSERID()
@@ -213,10 +213,10 @@ def main():
         userid = user_info[1][0]
         XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid)
     else:
-        print "[Error] cmd commands error : %s"%str(user_info[1])
+        print ("[Error] cmd commands error : %s" % str(user_info[1]))
         sys.exit(1)
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
index e29187a0bae2e2dce107adc8fe9ecb8898559397..f1f0cb470fad677077cced4db9cf44015525827c 100755 (executable)
@@ -40,10 +40,10 @@ import logging
 import zipfile
 import signal
 import subprocess
+import imp
 from optparse import OptionParser
 
-reload(sys)
-sys.setdefaultencoding('utf8')
+imp.reload(sys)
 
 TOOL_VERSION = "v0.1"
 VERSION_FILE = "VERSION"
@@ -363,7 +363,7 @@ def doCMDWithOutput(cmd, time_out=DEFAULT_CMD_TIMEOUT):
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         elapsed_time = time.time() - pre_time
         if cmd_return_code is None:
@@ -938,7 +938,7 @@ def main():
         sys.exit(1)
 
     if BUILD_PARAMETERS.bversion:
-        print "Version: %s" % TOOL_VERSION
+        LOG.info("Version: %s" % TOOL_VERSION)
         sys.exit(0)
 
     if not BUILD_PARAMETERS.srcdir:
index d5f9fbb96f7b82ebce4068b79598df34023b9b0f..d636bee034d8504fbfee33e3d6fe297f4e9bee1a 100755 (executable)
@@ -7,7 +7,7 @@ import time
 import sys
 import subprocess
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -17,14 +17,14 @@ ADB_CMD = "adb"
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -77,8 +77,8 @@ def main():
             "-u", dest="buninstpkg", action="store_true", help="Uninstall package")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.device:
@@ -89,11 +89,11 @@ def main():
                 break
 
     if not PARAMETERS.device:
-        print "No device found"
+        print ("No device found")
         sys.exit(1)
 
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
index 59ca043a9fb17c7b209c7d3f6fd79ad30f1e5423..454b936b7bcf100587116e577b5e3b0630ff68b6 100755 (executable)
@@ -8,7 +8,7 @@ import sys
 import subprocess
 import string
 from optparse import OptionParser, make_option
-import ConfigParser
+import configparser
 
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR)
 PARAMETERS = None
 #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket"
 TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"
-tct_parser = ConfigParser.ConfigParser()
+tct_parser = configparser.ConfigParser()
 tct_parser.read(TCT_CONFIG_FILE)
 SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')
 PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
@@ -32,14 +32,14 @@ def userCheck():
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_return_code = 1
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         if output_line == '' and cmd_return_code != None:
             break
@@ -190,8 +190,8 @@ def main():
             "-a", dest="user", action="store", help="User name")
         global PARAMETERS
         (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
+    except Exception as e:
+        print ("Got wrong option: %s, exit ..." % e)
         sys.exit(1)
 
     if not PARAMETERS.user:
@@ -215,7 +215,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     userCheck()
@@ -227,10 +227,10 @@ def main():
         userid = user_info[1][0]
         XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid)
     else:
-        print "[Error] cmd commands error : %s"%str(user_info[1])
+        print ("[Error] cmd commands error : %s" % str(user_info[1]))
         sys.exit(1)
     if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
+        print ("-i and -u are conflict")
         sys.exit(1)
 
     if PARAMETERS.buninstpkg:
index 211d24c73b20b5b3e5025847a9233ca625463653..454919c67ddb6e1a63505419ba26a2d7a29b7497 100755 (executable)
-#!/usr/bin/env python
-
-import os
-import shutil
-import glob
-import time
-import sys
-import subprocess
-import string
+#!/usr/bin/env python\r
+\r
+import os\r
+import shutil\r
+import glob\r
+import time\r
+import sys\r
+import subprocess\r
+import string\r
 from optparse import OptionParser, make_option\r
-import ConfigParser
-
-
-SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
-PKG_NAME = os.path.basename(SCRIPT_DIR)
-PARAMETERS = None
-#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket"
-TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"
-tct_parser = ConfigParser.ConfigParser()
-tct_parser.read(TCT_CONFIG_FILE)
-SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')
-PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)
-
-
-def doCMD(cmd):
-    # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
-    output = []
-    cmd_return_code = 1
-    cmd_proc = subprocess.Popen(
-        cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
-
-    while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
-        cmd_return_code = cmd_proc.poll()
-        if output_line == '' and cmd_return_code != None:
-            break
-        sys.stdout.write("%s\n" % output_line)
-        sys.stdout.flush()
-        output.append(output_line)
-
-    return (cmd_return_code, output)
-
-
-def updateCMD(cmd=None):
-    if "pkgcmd" in cmd:
-        cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd)
-    return cmd
-def getUSERID():
-    if PARAMETERS.mode == "SDB":
-        cmd = "sdb -s %s shell id -u %s" % (
-            PARAMETERS.device, PARAMETERS.user)
-    else:
-        cmd = "ssh %s \"id -u %s\"" % (
-            PARAMETERS.device, PARAMETERS.user )
-    return doCMD(cmd)
-
-
-
-
-def getPKGID(pkg_name=None):
-    if PARAMETERS.mode == "SDB":
-        cmd = "sdb -s %s shell %s" % (
-            PARAMETERS.device, updateCMD('pkgcmd -l'))
-    else:
-        cmd = "ssh %s \"%s\"" % (
-            PARAMETERS.device, updateCMD('pkgcmd -l'))
-
-    (return_code, output) = doCMD(cmd)
-    if return_code != 0:
-        return None
-
-    test_pkg_id = None
-    for line in output:
-        if line.find("[" + pkg_name + "]") != -1:
-            pkgidIndex = line.split().index("pkgid")
-            test_pkg_id = line.split()[pkgidIndex+1].strip("[]")
-            break
-    return test_pkg_id
-
-
-def doRemoteCMD(cmd=None):
-    if PARAMETERS.mode == "SDB":
-        cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd))
-    else:
-        cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd))
-
-    return doCMD(cmd)
-
-
-def doRemoteCopy(src=None, dest=None):
-    if PARAMETERS.mode == "SDB":
-        cmd_prefix = "sdb -s %s push" % PARAMETERS.device
-        cmd = "%s %s %s" % (cmd_prefix, src, dest)
-    else:
-        cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest)
-
-    (return_code, output) = doCMD(cmd)
-    doRemoteCMD("sync")
-
-    if return_code != 0:
-        return True
-    else:
-        return False
-
-
-def uninstPKGs():
-    action_status = True
-    for root, dirs, files in os.walk(SCRIPT_DIR):
-        if root.endswith("mediasrc"):
-            continue
-
-        for file in files:
-            if file.endswith(".xpk"):
-                pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0]))
-                if not pkg_id:
-                    action_status = False
-                    continue
-                (return_code, output) = doRemoteCMD(
-                    "pkgcmd -u -t xpk -q -n %s" % pkg_id)
-                for line in output:
-                    if "Failure" in line:
-                        action_status = False
-                        break
-
-    (return_code, output) = doRemoteCMD(
-        "rm -rf %s" % PKG_SRC_DIR)
-    if return_code != 0:
-        action_status = False
-
-    return action_status
-
-
-def instPKGs():
-    action_status = True
-    (return_code, output) = doRemoteCMD(
-        "mkdir -p %s" % PKG_SRC_DIR)
-    if return_code != 0:
-        action_status = False
-    for root, dirs, files in os.walk(SCRIPT_DIR):
-        if root.endswith("mediasrc"):
-            continue
-
-        for file in files:
-            if file.endswith(".xpk"):
-                if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)):
-                    action_status = False
-                (return_code, output) = doRemoteCMD(
-                    "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file))
-                doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file))
-                for line in output:
-                    if "Failure" in line:
-                        action_status = False
-                        break
-
-    # Do some special copy/delete... steps
-    '''
-    (return_code, output) = doRemoteCMD(
-        "mkdir -p %s/tests" % PKG_SRC_DIR)
-    if return_code != 0:
-        action_status = False
-
-    if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR):
-        action_status = False
-    '''
-
-    return action_status
-
-
-def main():
-    try:
-        usage = "usage: inst.py -i"
-        opts_parser = OptionParser(usage=usage)
-        opts_parser.add_option(
-            "-m", dest="mode", action="store", help="Specify mode")
-        opts_parser.add_option(
-            "-s", dest="device", action="store", help="Specify device")
-        opts_parser.add_option(
-            "-i", dest="binstpkg", action="store_true", help="Install package")
-        opts_parser.add_option(
-            "-u", dest="buninstpkg", action="store_true", help="Uninstall package")
-        opts_parser.add_option(
-            "-a", dest="user", action="store", help="User name")
-        global PARAMETERS
-        (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
-        sys.exit(1)
-
-    if not PARAMETERS.user:
-        PARAMETERS.user = "owner"
-    if not PARAMETERS.mode:
-        PARAMETERS.mode = "SDB"
-
-    if PARAMETERS.mode == "SDB":
-        if not PARAMETERS.device:
-            (return_code, output) = doCMD("sdb devices")
-            for line in output:
-                if str.find(line, "\tdevice") != -1:
-                    PARAMETERS.device = line.split("\t")[0]
-                    break
-    else:
-        PARAMETERS.mode = "SSH"
-
-    if not PARAMETERS.device:
-        print "No device provided"
-        sys.exit(1)
-
-    user_info = getUSERID()
-    re_code = user_info[0]
-    if re_code == 0 :
-        global XW_ENV
-        userid = user_info[1][0]
-        XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid)
-    else:
-        print "[Error] cmd commands error : %s"%str(user_info[1])
-        sys.exit(1)
-    if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:
-        print "-i and -u are conflict"
-        sys.exit(1)
-
-    if PARAMETERS.buninstpkg:
-        if not uninstPKGs():
-            sys.exit(1)
-    else:
-        if not instPKGs():
-            sys.exit(1)
-
-if __name__ == "__main__":
-    main()
-    sys.exit(0)
+import configparser\r
+\r
+\r
+SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))\r
+PKG_NAME = os.path.basename(SCRIPT_DIR)\r
+PARAMETERS = None\r
+#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket"\r
+TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"\r
+tct_parser = configparser.ConfigParser()\r
+tct_parser.read(TCT_CONFIG_FILE)\r
+SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')\r
+PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME)\r
+\r
+\r
+def doCMD(cmd):\r
+    # Do not need handle timeout in this short script, let tool do it\r
+    print ("-->> \"%s\"" % cmd)\r
+    output = []\r
+    cmd_return_code = 1\r
+    cmd_proc = subprocess.Popen(\r
+        cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)\r
+\r
+    while True:\r
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")\r
+        cmd_return_code = cmd_proc.poll()\r
+        if output_line == '' and cmd_return_code != None:\r
+            break\r
+        sys.stdout.write("%s\n" % output_line)\r
+        sys.stdout.flush()\r
+        output.append(output_line)\r
+\r
+    return (cmd_return_code, output)\r
+\r
+\r
+def updateCMD(cmd=None):\r
+    if "pkgcmd" in cmd:\r
+        cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd)\r
+    return cmd\r
+def getUSERID():\r
+    if PARAMETERS.mode == "SDB":\r
+        cmd = "sdb -s %s shell id -u %s" % (\r
+            PARAMETERS.device, PARAMETERS.user)\r
+    else:\r
+        cmd = "ssh %s \"id -u %s\"" % (\r
+            PARAMETERS.device, PARAMETERS.user )\r
+    return doCMD(cmd)\r
+\r
+\r
+\r
+\r
+def getPKGID(pkg_name=None):\r
+    if PARAMETERS.mode == "SDB":\r
+        cmd = "sdb -s %s shell %s" % (\r
+            PARAMETERS.device, updateCMD('pkgcmd -l'))\r
+    else:\r
+        cmd = "ssh %s \"%s\"" % (\r
+            PARAMETERS.device, updateCMD('pkgcmd -l'))\r
+\r
+    (return_code, output) = doCMD(cmd)\r
+    if return_code != 0:\r
+        return None\r
+\r
+    test_pkg_id = None\r
+    for line in output:\r
+        if line.find("[" + pkg_name + "]") != -1:\r
+            pkgidIndex = line.split().index("pkgid")\r
+            test_pkg_id = line.split()[pkgidIndex+1].strip("[]")\r
+            break\r
+    return test_pkg_id\r
+\r
+\r
+def doRemoteCMD(cmd=None):\r
+    if PARAMETERS.mode == "SDB":\r
+        cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd))\r
+    else:\r
+        cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd))\r
+\r
+    return doCMD(cmd)\r
+\r
+\r
+def doRemoteCopy(src=None, dest=None):\r
+    if PARAMETERS.mode == "SDB":\r
+        cmd_prefix = "sdb -s %s push" % PARAMETERS.device\r
+        cmd = "%s %s %s" % (cmd_prefix, src, dest)\r
+    else:\r
+        cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest)\r
+\r
+    (return_code, output) = doCMD(cmd)\r
+    doRemoteCMD("sync")\r
+\r
+    if return_code != 0:\r
+        return True\r
+    else:\r
+        return False\r
+\r
+\r
+def uninstPKGs():\r
+    action_status = True\r
+    for root, dirs, files in os.walk(SCRIPT_DIR):\r
+        if root.endswith("mediasrc"):\r
+            continue\r
+\r
+        for file in files:\r
+            if file.endswith(".xpk"):\r
+                pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0]))\r
+                if not pkg_id:\r
+                    action_status = False\r
+                    continue\r
+                (return_code, output) = doRemoteCMD(\r
+                    "pkgcmd -u -t xpk -q -n %s" % pkg_id)\r
+                for line in output:\r
+                    if "Failure" in line:\r
+                        action_status = False\r
+                        break\r
+\r
+    (return_code, output) = doRemoteCMD(\r
+        "rm -rf %s" % PKG_SRC_DIR)\r
+    if return_code != 0:\r
+        action_status = False\r
+\r
+    return action_status\r
+\r
+\r
+def instPKGs():\r
+    action_status = True\r
+    (return_code, output) = doRemoteCMD(\r
+        "mkdir -p %s" % PKG_SRC_DIR)\r
+    if return_code != 0:\r
+        action_status = False\r
+    for root, dirs, files in os.walk(SCRIPT_DIR):\r
+        if root.endswith("mediasrc"):\r
+            continue\r
+\r
+        for file in files:\r
+            if file.endswith(".xpk"):\r
+                if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)):\r
+                    action_status = False\r
+                (return_code, output) = doRemoteCMD(\r
+                    "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file))\r
+                doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file))\r
+                for line in output:\r
+                    if "Failure" in line:\r
+                        action_status = False\r
+                        break\r
+\r
+    # Do some special copy/delete... steps\r
+    '''\r
+    (return_code, output) = doRemoteCMD(\r
+        "mkdir -p %s/tests" % PKG_SRC_DIR)\r
+    if return_code != 0:\r
+        action_status = False\r
+\r
+    if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR):\r
+        action_status = False\r
+    '''\r
+\r
+    return action_status\r
+\r
+\r
+def main():\r
+    try:\r
+        usage = "usage: inst.py -i"\r
+        opts_parser = OptionParser(usage=usage)\r
+        opts_parser.add_option(\r
+            "-m", dest="mode", action="store", help="Specify mode")\r
+        opts_parser.add_option(\r
+            "-s", dest="device", action="store", help="Specify device")\r
+        opts_parser.add_option(\r
+            "-i", dest="binstpkg", action="store_true", help="Install package")\r
+        opts_parser.add_option(\r
+            "-u", dest="buninstpkg", action="store_true", help="Uninstall package")\r
+        opts_parser.add_option(\r
+            "-a", dest="user", action="store", help="User name")\r
+        global PARAMETERS\r
+        (PARAMETERS, args) = opts_parser.parse_args()\r
+    except Exception as e:\r
+        print ("Got wrong option: %s, exit ..." % e)\r
+        sys.exit(1)\r
+\r
+    if not PARAMETERS.user:\r
+        PARAMETERS.user = "owner"\r
+    if not PARAMETERS.mode:\r
+        PARAMETERS.mode = "SDB"\r
+\r
+    if PARAMETERS.mode == "SDB":\r
+        if not PARAMETERS.device:\r
+            (return_code, output) = doCMD("sdb devices")\r
+            for line in output:\r
+                if str.find(line, "\tdevice") != -1:\r
+                    PARAMETERS.device = line.split("\t")[0]\r
+                    break\r
+    else:\r
+        PARAMETERS.mode = "SSH"\r
+\r
+    if not PARAMETERS.device:\r
+        print ("No device provided")\r
+        sys.exit(1)\r
+\r
+    user_info = getUSERID()\r
+    re_code = user_info[0]\r
+    if re_code == 0 :\r
+        global XW_ENV\r
+        userid = user_info[1][0]\r
+        XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid)\r
+    else:\r
+        print ("[Error] cmd commands error : %s" % str(user_info[1]))\r
+        sys.exit(1)\r
+    if PARAMETERS.binstpkg and PARAMETERS.buninstpkg:\r
+        print ("-i and -u are conflict")\r
+        sys.exit(1)\r
+\r
+    if PARAMETERS.buninstpkg:\r
+        if not uninstPKGs():\r
+            sys.exit(1)\r
+    else:\r
+        if not instPKGs():\r
+            sys.exit(1)\r
+\r
+if __name__ == "__main__":\r
+    main()\r
+    sys.exit(0)\r
index e29187a0bae2e2dce107adc8fe9ecb8898559397..f1f0cb470fad677077cced4db9cf44015525827c 100755 (executable)
@@ -40,10 +40,10 @@ import logging
 import zipfile
 import signal
 import subprocess
+import imp
 from optparse import OptionParser
 
-reload(sys)
-sys.setdefaultencoding('utf8')
+imp.reload(sys)
 
 TOOL_VERSION = "v0.1"
 VERSION_FILE = "VERSION"
@@ -363,7 +363,7 @@ def doCMDWithOutput(cmd, time_out=DEFAULT_CMD_TIMEOUT):
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
     while True:
-        output_line = cmd_proc.stdout.readline().strip("\r\n")
+        output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
         cmd_return_code = cmd_proc.poll()
         elapsed_time = time.time() - pre_time
         if cmd_return_code is None:
@@ -938,7 +938,7 @@ def main():
         sys.exit(1)
 
     if BUILD_PARAMETERS.bversion:
-        print "Version: %s" % TOOL_VERSION
+        LOG.info("Version: %s" % TOOL_VERSION)
         sys.exit(0)
 
     if not BUILD_PARAMETERS.srcdir: