[common][mltrain][upgrade mltrain to python3x] 40/275540/1
authorchen <chen89.chen@samsung.com>
Thu, 26 May 2022 06:35:48 +0000 (14:35 +0800)
committerchen <chen89.chen@samsung.com>
Thu, 26 May 2022 06:35:55 +0000 (14:35 +0800)
Change-Id: Ia747b345e46a5b4e26f07ca56485c2d38da63858
Signed-off-by: chen <chen89.chen@samsung.com>
common/tct-mltrain-tizen-tests/inst.apk.py
common/tct-mltrain-tizen-tests/inst.wgt.py
common/tct-mltrain-tizen-tests/inst.xpk.py
common/tct-mltrain-tizen-tests/pack.py

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 aa684ed0c5d1d6019bedc7a05a5291dad460a176..7a5f5ec09b0b60be5bcf0ddc641d32150668bf59 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)
@@ -37,7 +37,7 @@ def askpolicyremoving():
             if file.endswith(".wgt"):
                 pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0]))
    
-    print pkg_id
+    print (pkg_id)
     print (os.getcwd())
     print (os.path.dirname(os.path.realpath(__file__)) )
     if not doRemoteCopy("%s/askpolicy.sh" % SCRIPT_DIR, "%s" % (SRC_DIR)):
@@ -49,14 +49,14 @@ def askpolicyremoving():
        
 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,7 +183,7 @@ def instPKGs():
         action_status = False
 
     if not doRemoteCopy("%s/media/*" % SCRIPT_DIR, "%s/Documents" % SRC_DIR):
-               action_status = False
+        action_status = False
     for item in glob.glob("%s/*" % SCRIPT_DIR):
         if item.endswith(".wgt"):
             continue
@@ -213,8 +213,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:
@@ -233,7 +233,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     userCheck()
@@ -245,10 +245,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: