behavior update to python3X 33/274833/1
authorchen <chen89.chen@samsung.com>
Tue, 10 May 2022 08:18:57 +0000 (16:18 +0800)
committerchen <chen89.chen@samsung.com>
Tue, 10 May 2022 08:19:19 +0000 (16:19 +0800)
Change-Id: Id5ed142db662dd9cb065081143a139cea451bcb1
Signed-off-by: chen <chen89.chen@samsung.com>
20 files changed:
ivi/inst.apk.py
ivi/inst.wgt.py
ivi/inst.xpk.py
mobile/tct-behavior-tests/inst.apk.py
mobile/tct-behavior-tests/inst.wgt.py
mobile/tct-behavior-tests/inst.xpk.py
mobile/tct-behavior-tests/pack.py
tools/build/pack.py
tools/coverage/stats.py
tools/xml/csv2xml.py
tools/xml/xml2csv.py
tools/xml/xmlverifier.py
tv/tct-behavior-tests/inst.apk.py
tv/tct-behavior-tests/inst.wgt.py
tv/tct-behavior-tests/inst.xpk.py
tv/tct-behavior-tests/pack.py
wearable/tct-behavior-tests/inst.apk.py
wearable/tct-behavior-tests/inst.wgt.py
wearable/tct-behavior-tests/inst.xpk.py
wearable/tct-behavior-tests/pack.py

index 472790c79f88d6876dd6398ec6eba4a9ccc3cfc8..7d549d5f49028deb2b9cf2fba45d3d1dc06ce233 100755 (executable)
@@ -16,7 +16,7 @@ ADB_CMD = "adb"
 
 def doCMD(cmd):
     # Do not need handle timeout in this short script
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
@@ -27,8 +27,8 @@ def doCMD(cmd):
 
     if not cmd.endswith("&"):
         while True:
-            line = cmd_proc.stdout.readline().strip('\n')
-            print line
+            line = cmd_proc.stdout.readline().decode("UTF-8").strip('\n')
+            print (line)
             if not line or line.find("daemon started") >= 0:
                 break
             output.append(line)
@@ -78,8 +78,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:
@@ -90,11 +90,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 989b152d9ca4034a7e500220ff657588a09f18f8..8dc8654f7eb0e38880013bb441febdd0f2964fb2 100755 (executable)
@@ -20,7 +20,7 @@ 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_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
@@ -31,8 +31,8 @@ def doCMD(cmd):
 
     if not cmd.endswith("&"):
         while True:
-            line = cmd_proc.stdout.readline().strip("\r\n")
-            print line
+            line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
+            print (line)
             if not line or line.find("daemon started") >= 0:
                 break
             output.append(line)
@@ -173,8 +173,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:
@@ -193,7 +193,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     user_info = getUSERID()
@@ -203,10 +203,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 e030f80afb7479bf254858d9c939928537abd36c..a43f0d09e785d90cd2c9daf39f442beb7ccb5b43 100755 (executable)
@@ -20,7 +20,7 @@ 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_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
@@ -31,8 +31,8 @@ def doCMD(cmd):
 
     if not cmd.endswith("&"):
         while True:
-            line = cmd_proc.stdout.readline().strip("\r\n")
-            print line
+            line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
+            print (line)
             if not line or line.find("daemon started") >= 0:
                 break
             output.append(line)
@@ -173,8 +173,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:
@@ -193,7 +193,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     user_info = getUSERID()
@@ -203,10 +203,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 56e4343699f3b268bb2339b439ca65cae420f54e..b166f10d8dbceae2d801223f6b95f25ba8946165 100755 (executable)
-#!/usr/bin/env python
-
-import os
-import shutil
-import glob
-import time
-import sys
-import subprocess
+#!/usr/bin/env python\r
+\r
+import os\r
+import shutil\r
+import glob\r
+import time\r
+import sys\r
+import subprocess\r
 from optparse import OptionParser, make_option\r
-import ConfigParser
-
-
-SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
-PARAMETERS = None
-ADB_CMD = "adb"
-
-
-def doCMD(cmd):
-    # Do not need handle timeout in this short script
-    print "-->> \"%s\"" % cmd
-    output = []
-    cmd_proc = subprocess.Popen(
-        cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
-    while True:
-        cmd_return_code = cmd_proc.poll()
-        if cmd_return_code != None:
-            break
-
-    if not cmd.endswith("&"):
-        while True:
-            line = cmd_proc.stdout.readline().strip('\n')
-            print line
-            if not line or line.find("daemon started") >= 0:
-                break
-            output.append(line)
-
-    return (cmd_return_code, output)
-
-
-def uninstPKGs():
-    action_status = True
-    for root, dirs, files in os.walk(SCRIPT_DIR):
-        for file in files:
-            if file.endswith(".apk"):
-                cmd = "%s -s %s uninstall org.xwalk.%s" % (
-                    ADB_CMD, PARAMETERS.device, os.path.basename(os.path.splitext(file)[0]))
-                (return_code, output) = doCMD(cmd)
-                for line in output:
-                    if "Failure" in line:
-                        action_status = False
-                        break
-    return action_status
-
-
-def instPKGs():
-    action_status = True
-    for root, dirs, files in os.walk(SCRIPT_DIR):
-        for file in files:
-            if file.endswith(".apk"):
-                cmd = "%s -s %s install %s" % (ADB_CMD,
-                                               PARAMETERS.device, os.path.join(root, file))
-                (return_code, output) = doCMD(cmd)
-                for line in output:
-                    if "Failure" in line:
-                        action_status = False
-                        break
-    return action_status
-
-
-def main():
-    try:
-        usage = "usage: inst.py -i"
-        opts_parser = OptionParser(usage=usage)
-        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")
-        global PARAMETERS
-        (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
-        sys.exit(1)
-
-    if not PARAMETERS.device:
-        (return_code, output) = doCMD("adb devices")
-        for line in output:
-            if str.find(line, "\tdevice") != -1:
-                PARAMETERS.device = line.split("\t")[0]
-                break
-
-    if not PARAMETERS.device:
-        print "No device found"
-        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
+PARAMETERS = None\r
+ADB_CMD = "adb"\r
+\r
+\r
+def doCMD(cmd):\r
+    # Do not need handle timeout in this short script\r
+    print ("-->> \"%s\"" % cmd)\r
+    output = []\r
+    cmd_proc = subprocess.Popen(\r
+        cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
+    while True:\r
+        cmd_return_code = cmd_proc.poll()\r
+        if cmd_return_code != None:\r
+            break\r
+\r
+    if not cmd.endswith("&"):\r
+        while True:\r
+            line = cmd_proc.stdout.readline().decode("UTF-8").strip('\n')\r
+            print (line)\r
+            if not line or line.find("daemon started") >= 0:\r
+                break\r
+            output.append(line)\r
+\r
+    return (cmd_return_code, output)\r
+\r
+\r
+def uninstPKGs():\r
+    action_status = True\r
+    for root, dirs, files in os.walk(SCRIPT_DIR):\r
+        for file in files:\r
+            if file.endswith(".apk"):\r
+                cmd = "%s -s %s uninstall org.xwalk.%s" % (\r
+                    ADB_CMD, PARAMETERS.device, os.path.basename(os.path.splitext(file)[0]))\r
+                (return_code, output) = doCMD(cmd)\r
+                for line in output:\r
+                    if "Failure" in line:\r
+                        action_status = False\r
+                        break\r
+    return action_status\r
+\r
+\r
+def instPKGs():\r
+    action_status = True\r
+    for root, dirs, files in os.walk(SCRIPT_DIR):\r
+        for file in files:\r
+            if file.endswith(".apk"):\r
+                cmd = "%s -s %s install %s" % (ADB_CMD,\r
+                                               PARAMETERS.device, os.path.join(root, file))\r
+                (return_code, output) = doCMD(cmd)\r
+                for line in output:\r
+                    if "Failure" in line:\r
+                        action_status = False\r
+                        break\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
+            "-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
+        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.device:\r
+        (return_code, output) = doCMD("adb devices")\r
+        for line in output:\r
+            if str.find(line, "\tdevice") != -1:\r
+                PARAMETERS.device = line.split("\t")[0]\r
+                break\r
+\r
+    if not PARAMETERS.device:\r
+        print ("No device found")\r
+        sys.exit(1)\r
+\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 16446abf2f956670c2ffbf1b0ca22c9d4937d377..d83b611eca9412eaff3fa3803ff6d74162af062e 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)
@@ -40,10 +40,10 @@ def getInternalStorage():
         shell_mgr.write_cmd('export `tzplatform-get --user ' +PARAMETERS.user+' TZ_USER_CONTENT`', '', None)
         INTERNAL_STORAGE=shell_mgr.write_cmd('echo $TZ_USER_CONTENT','', None)
         INTERNAL_STORAGE=str(INTERNAL_STORAGE[len(INTERNAL_STORAGE)-1])
-        print str(INTERNAL_STORAGE)
+        print (str(INTERNAL_STORAGE))
         
     except Exception as ex:
-        print ex
+        print (ex)
     finally:
         shell_mgr.close_shellpipe()
 
@@ -53,7 +53,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)):
@@ -65,7 +65,7 @@ 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_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
@@ -76,8 +76,8 @@ def doCMD(cmd):
 
     if not cmd.endswith("&"):
         while True:
-            line = cmd_proc.stdout.readline().strip("\r\n")
-            print line
+            line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
+            print (line)
             if not line or line.find("daemon started") >= 0:
                 break
             output.append(line)
@@ -218,8 +218,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:
@@ -238,7 +238,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     userCheck()
@@ -250,10 +250,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 1c47cca9562fab04a999b7416d483e8c10868d2a..5ae8883f60ca077471f4e6cbef4e2a37ff87a908 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_proc = subprocess.Popen(
-        cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
-    while True:
-        cmd_return_code = cmd_proc.poll()
-        if cmd_return_code != None:
-            break
-
-    if not cmd.endswith("&"):
-        while True:
-            line = cmd_proc.stdout.readline().strip("\r\n")
-            print line
-            if not line or line.find("daemon started") >= 0:
-                break
-            output.append(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):
-        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):
-        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
-
-    for item in glob.glob("%s/*" % SCRIPT_DIR):
-        if item.endswith(".xpk"):
-            continue
-        elif item.endswith("inst.py"):
-            continue
-        else:
-            item_name = os.path.basename(item)
-            if not doRemoteCopy(item, PKG_SRC_DIR+"/"+item_name):
-            #if not doRemoteCopy(item, 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_proc = subprocess.Popen(\r
+        cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
+    while True:\r
+        cmd_return_code = cmd_proc.poll()\r
+        if cmd_return_code != None:\r
+            break\r
+\r
+    if not cmd.endswith("&"):\r
+        while True:\r
+            line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")\r
+            print (line)\r
+            if not line or line.find("daemon started") >= 0:\r
+                break\r
+            output.append(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
+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
+        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
+        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
+    for item in glob.glob("%s/*" % SCRIPT_DIR):\r
+        if item.endswith(".xpk"):\r
+            continue\r
+        elif item.endswith("inst.py"):\r
+            continue\r
+        else:\r
+            item_name = os.path.basename(item)\r
+            if not doRemoteCopy(item, PKG_SRC_DIR+"/"+item_name):\r
+            #if not doRemoteCopy(item, PKG_SRC_DIR):\r
+                action_status = False\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:
index e48cdc1748839ecd1b864814a8f96db9b166898c..22bf5e2a1c4f3f5593f9cc18f1af5ea2c927d073 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 e10865f470ba1f7cfcafcabfaaf5515f49fa6852..10a22ab09119901cdc3a6fe8d2977d7ccdd2d59f 100755 (executable)
@@ -4,7 +4,7 @@
 import os
 import sys
 import re
-import commands
+import subprocess
 import glob
 import fnmatch
 import string
@@ -14,8 +14,8 @@ from optparse import OptionParser
 
 def iterfindfiles (path, fnexp):
     for root, dirs, files in os.walk(path):
-           for filename in fnmatch.filter(files, fnexp):
-                   yield os.path.join(root, filename)
+        for filename in fnmatch.filter(files, fnexp):
+            yield os.path.join(root, filename)
 
 def count_upstream (string = None, str_entry=None ):
     if string.find('/%s/' % str_entry) >= 0:
@@ -94,9 +94,9 @@ def analy_test_file(file_path = None):
                      p3_auto_webdriver += 1*subcase
                  else:
                    p3_manual += 1*subcase
-    except Exception, e:
-         print "Got error when analy test files: %s" % e
-         print file_path
+    except Exception as e:
+         print ("Got error when analy test files: %s" % e)
+         print (file_path)
 
     p0_number = p0_auto + p0_manual
     p1_number = p1_auto + p1_manual
@@ -125,8 +125,8 @@ def get_upstream(file_path):
                     n_upstream += 1
                     if element not in exist_upstream :
                        exist_upstream.append(element)
-    except Exception, e:
-        print e
+    except Exception as e:
+        print (e)
 
     upstream = ""
     for element in exist_upstream:
@@ -151,8 +151,8 @@ def get_case_status(file_path):
         fp.write(content)
         fp.write("\n")
         fp.close()
-    except Exception, e:
-        print "Got error when get case status: %s" % e
+    except Exception as e:
+        print ("Got error when get case status: %s" % e)
 
 def init_result_file():
     title = "Suite_name,Total,Total_auto,Total_auto_webdriver,Total_manual,P0,P0_auto,P0_auto_webdriver,P0_manual,P1,P1_auto,\
@@ -166,8 +166,8 @@ Integrated_Upstream_TCs,Upstream_Resource"
         fp.write(title)
         fp.write("\n")
         fp.close()
-    except Exception, e:
-        print "Got error when init analy file : %s" % e
+    except Exception as e:
+        print ("Got error when init analy file : %s" % e)
 
 def main():
     try:
@@ -184,7 +184,7 @@ def main():
         
         init_result_file()
         if len(sys.argv) == 1:
-                   sys.argv.append("-h")
+            sys.argv.append("-h")
         (PARAMETERS, args) = opts_parser.parse_args()
         if PARAMETERS.suitesdir:
             for filename in iterfindfiles("%s" % PARAMETERS.suitesdir, "tests.full.xml"):
@@ -193,8 +193,8 @@ def main():
         if PARAMETERS.xmlfile:
             get_case_status(PARAMETERS.xmlfile)   
     except Exception as e:
-        print "Got error: %s, exit" % e
+        print ("Got error: %s, exit" % e)
 
 if __name__ == '__main__':
-       main()
+    main()
 
index 4447e4d65a1c8aad0bdcd5ad43cef5e355f01198..bdfdb207da941214883b6589d44165ec1c074c58 100755 (executable)
@@ -65,11 +65,11 @@ class ColorFormatter(logging.Formatter):
 
 def csv2full(csv_path, split_sign):
     if not os.path.isfile(csv_path):
-        print '%s is not a file' % csv_path
+        print ('%s is not a file' % csv_path)
         return
     name, ext = os.path.splitext(csv_path)
     if not ext == '.csv':
-        print '%s is not a csv' % csv_path
+        print ('%s is not a csv' % csv_path)
         return
     LOG.info("+Convert csv to xml start ...")
     csv_file = file(csv_path, 'rb')
@@ -139,7 +139,7 @@ def echo_about():
     This function will print the user guide and stop toolkit.
     """
     about = 'csv2xml V1.0\n-c <path>  |  Convert csv file to tests.full.xml and tests.xml\n'
-    print about
+    print (about)
     sys.exit()
 
 def main():
@@ -161,7 +161,7 @@ def main():
     elif sys_name == 'Linux':
         split_sign = '/'
     if len(sys.argv) != 3:
-        print 'Error: No enough argv!'
+        print ('Error: No enough argv!')
         echo_about()
     else:
         {'-c': lambda : csv2full(sys.argv[2], split_sign)}[sys.argv[1]]()
index 07de9c35a9f99b2a33bb37a7717b195a1a43c866..5a6d3ba2c28df90f33a7d062a8f3a93db6bcd993 100755 (executable)
@@ -65,16 +65,16 @@ class ColorFormatter(logging.Formatter):
 
 def xml2csv(xml_path, split_sign):
     if not os.path.isfile(xml_path):
-        print '%s is not a file' % xml_path
+        print ('%s is not a file' % xml_path)
         return
     name, ext = os.path.splitext(xml_path)
 
     if not ext == '.xml':
-        print '%s is not a xml' % xml_path
+        print ('%s is not a xml' % xml_path)
         return
     if not name.split(split_sign)[-1] == 'tests.full':
-        print name
-        print '%s is not tests.full.xml' % xml_path
+        print (name)
+        print ('%s is not tests.full.xml' % xml_path)
         return
     LOG.info("+Convert xml to csv start ...")
     folder = os.path.dirname(xml_path)
@@ -152,7 +152,7 @@ def echo_about():
     This function will print the user guide and stop toolkit.
     """
     about = 'xml2csv V1.0\n-c <path>  |  Convert tests.full.xml to csv file\n'
-    print about
+    print (about)
     sys.exit()
 
 def main():
@@ -174,7 +174,7 @@ def main():
     elif sys_name == 'Linux':
         split_sign = '/'
     if len(sys.argv) != 3:
-        print 'Error: No enough argv!'
+        print ('Error: No enough argv!')
         echo_about()
     else:
         {
index 4165ec9d6951df855f42197c477363fc8089a2ec..9794b2c8b1725646a07c9452a38811a926ac327b 100755 (executable)
@@ -72,7 +72,7 @@ def verify_xml(xml_dir, split_sign):
         else:
             name, ext = os.path.splitext(xml_dir)
             if not ext == '.xml':
-                print '%s is not a xml' % xml_path
+                print ('%s is not a xml' % xml_path)
                 return
             else:
                 verify_path(xml_dir, split_sign)
@@ -143,7 +143,7 @@ def echo_about():
     This function will print the user guide and stop toolkit.
     """
     about = 'xmlverifier V1.0\n-v <path>  |  Verify case path, id, purpose and set type are right\n'
-    print about
+    print (about)
     sys.exit()
 
 def main():
@@ -165,7 +165,7 @@ def main():
     elif sys_name == 'Linux':
         split_sign = '/'
     if len(sys.argv) != 3:
-        print 'Error: No enough argv!'
+        print ('Error: No enough argv!')
         echo_about()
     else:
         {'-v': lambda : verify_xml(sys.argv[2], split_sign)}[sys.argv[1]]()
index 56e4343699f3b268bb2339b439ca65cae420f54e..b166f10d8dbceae2d801223f6b95f25ba8946165 100755 (executable)
-#!/usr/bin/env python
-
-import os
-import shutil
-import glob
-import time
-import sys
-import subprocess
+#!/usr/bin/env python\r
+\r
+import os\r
+import shutil\r
+import glob\r
+import time\r
+import sys\r
+import subprocess\r
 from optparse import OptionParser, make_option\r
-import ConfigParser
-
-
-SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
-PARAMETERS = None
-ADB_CMD = "adb"
-
-
-def doCMD(cmd):
-    # Do not need handle timeout in this short script
-    print "-->> \"%s\"" % cmd
-    output = []
-    cmd_proc = subprocess.Popen(
-        cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
-    while True:
-        cmd_return_code = cmd_proc.poll()
-        if cmd_return_code != None:
-            break
-
-    if not cmd.endswith("&"):
-        while True:
-            line = cmd_proc.stdout.readline().strip('\n')
-            print line
-            if not line or line.find("daemon started") >= 0:
-                break
-            output.append(line)
-
-    return (cmd_return_code, output)
-
-
-def uninstPKGs():
-    action_status = True
-    for root, dirs, files in os.walk(SCRIPT_DIR):
-        for file in files:
-            if file.endswith(".apk"):
-                cmd = "%s -s %s uninstall org.xwalk.%s" % (
-                    ADB_CMD, PARAMETERS.device, os.path.basename(os.path.splitext(file)[0]))
-                (return_code, output) = doCMD(cmd)
-                for line in output:
-                    if "Failure" in line:
-                        action_status = False
-                        break
-    return action_status
-
-
-def instPKGs():
-    action_status = True
-    for root, dirs, files in os.walk(SCRIPT_DIR):
-        for file in files:
-            if file.endswith(".apk"):
-                cmd = "%s -s %s install %s" % (ADB_CMD,
-                                               PARAMETERS.device, os.path.join(root, file))
-                (return_code, output) = doCMD(cmd)
-                for line in output:
-                    if "Failure" in line:
-                        action_status = False
-                        break
-    return action_status
-
-
-def main():
-    try:
-        usage = "usage: inst.py -i"
-        opts_parser = OptionParser(usage=usage)
-        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")
-        global PARAMETERS
-        (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
-        sys.exit(1)
-
-    if not PARAMETERS.device:
-        (return_code, output) = doCMD("adb devices")
-        for line in output:
-            if str.find(line, "\tdevice") != -1:
-                PARAMETERS.device = line.split("\t")[0]
-                break
-
-    if not PARAMETERS.device:
-        print "No device found"
-        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
+PARAMETERS = None\r
+ADB_CMD = "adb"\r
+\r
+\r
+def doCMD(cmd):\r
+    # Do not need handle timeout in this short script\r
+    print ("-->> \"%s\"" % cmd)\r
+    output = []\r
+    cmd_proc = subprocess.Popen(\r
+        cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
+    while True:\r
+        cmd_return_code = cmd_proc.poll()\r
+        if cmd_return_code != None:\r
+            break\r
+\r
+    if not cmd.endswith("&"):\r
+        while True:\r
+            line = cmd_proc.stdout.readline().decode("UTF-8").strip('\n')\r
+            print (line)\r
+            if not line or line.find("daemon started") >= 0:\r
+                break\r
+            output.append(line)\r
+\r
+    return (cmd_return_code, output)\r
+\r
+\r
+def uninstPKGs():\r
+    action_status = True\r
+    for root, dirs, files in os.walk(SCRIPT_DIR):\r
+        for file in files:\r
+            if file.endswith(".apk"):\r
+                cmd = "%s -s %s uninstall org.xwalk.%s" % (\r
+                    ADB_CMD, PARAMETERS.device, os.path.basename(os.path.splitext(file)[0]))\r
+                (return_code, output) = doCMD(cmd)\r
+                for line in output:\r
+                    if "Failure" in line:\r
+                        action_status = False\r
+                        break\r
+    return action_status\r
+\r
+\r
+def instPKGs():\r
+    action_status = True\r
+    for root, dirs, files in os.walk(SCRIPT_DIR):\r
+        for file in files:\r
+            if file.endswith(".apk"):\r
+                cmd = "%s -s %s install %s" % (ADB_CMD,\r
+                                               PARAMETERS.device, os.path.join(root, file))\r
+                (return_code, output) = doCMD(cmd)\r
+                for line in output:\r
+                    if "Failure" in line:\r
+                        action_status = False\r
+                        break\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
+            "-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
+        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.device:\r
+        (return_code, output) = doCMD("adb devices")\r
+        for line in output:\r
+            if str.find(line, "\tdevice") != -1:\r
+                PARAMETERS.device = line.split("\t")[0]\r
+                break\r
+\r
+    if not PARAMETERS.device:\r
+        print ("No device found")\r
+        sys.exit(1)\r
+\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 2b1ecaaa798958fc1d4e33727a4ae9869d1b1611..5e3a0aaf5b2662d8f265f7d7c39d21bd09b77bad 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)):
@@ -48,7 +48,7 @@ def askpolicyremoving():
     return doCMD(cmd)
 def doCMD(cmd):
     # Do not need handle timeout in this short script, let tool do it
-    print "-->> \"%s\"" % cmd
+    print ("-->> \"%s\"" % cmd)
     output = []
     cmd_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
@@ -59,8 +59,8 @@ def doCMD(cmd):
 
     if not cmd.endswith("&"):
         while True:
-            line = cmd_proc.stdout.readline().strip("\r\n")
-            print line
+            line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
+            print (line)
             if not line or line.find("daemon started") >= 0:
                 break
             output.append(line)
@@ -201,8 +201,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:
@@ -221,7 +221,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     userCheck()
@@ -233,10 +233,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 1c47cca9562fab04a999b7416d483e8c10868d2a..5ae8883f60ca077471f4e6cbef4e2a37ff87a908 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_proc = subprocess.Popen(
-        cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
-    while True:
-        cmd_return_code = cmd_proc.poll()
-        if cmd_return_code != None:
-            break
-
-    if not cmd.endswith("&"):
-        while True:
-            line = cmd_proc.stdout.readline().strip("\r\n")
-            print line
-            if not line or line.find("daemon started") >= 0:
-                break
-            output.append(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):
-        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):
-        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
-
-    for item in glob.glob("%s/*" % SCRIPT_DIR):
-        if item.endswith(".xpk"):
-            continue
-        elif item.endswith("inst.py"):
-            continue
-        else:
-            item_name = os.path.basename(item)
-            if not doRemoteCopy(item, PKG_SRC_DIR+"/"+item_name):
-            #if not doRemoteCopy(item, 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_proc = subprocess.Popen(\r
+        cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
+    while True:\r
+        cmd_return_code = cmd_proc.poll()\r
+        if cmd_return_code != None:\r
+            break\r
+\r
+    if not cmd.endswith("&"):\r
+        while True:\r
+            line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")\r
+            print (line)\r
+            if not line or line.find("daemon started") >= 0:\r
+                break\r
+            output.append(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
+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
+        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
+        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
+    for item in glob.glob("%s/*" % SCRIPT_DIR):\r
+        if item.endswith(".xpk"):\r
+            continue\r
+        elif item.endswith("inst.py"):\r
+            continue\r
+        else:\r
+            item_name = os.path.basename(item)\r
+            if not doRemoteCopy(item, PKG_SRC_DIR+"/"+item_name):\r
+            #if not doRemoteCopy(item, PKG_SRC_DIR):\r
+                action_status = False\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:
index 56e4343699f3b268bb2339b439ca65cae420f54e..b166f10d8dbceae2d801223f6b95f25ba8946165 100755 (executable)
-#!/usr/bin/env python
-
-import os
-import shutil
-import glob
-import time
-import sys
-import subprocess
+#!/usr/bin/env python\r
+\r
+import os\r
+import shutil\r
+import glob\r
+import time\r
+import sys\r
+import subprocess\r
 from optparse import OptionParser, make_option\r
-import ConfigParser
-
-
-SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
-PARAMETERS = None
-ADB_CMD = "adb"
-
-
-def doCMD(cmd):
-    # Do not need handle timeout in this short script
-    print "-->> \"%s\"" % cmd
-    output = []
-    cmd_proc = subprocess.Popen(
-        cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
-    while True:
-        cmd_return_code = cmd_proc.poll()
-        if cmd_return_code != None:
-            break
-
-    if not cmd.endswith("&"):
-        while True:
-            line = cmd_proc.stdout.readline().strip('\n')
-            print line
-            if not line or line.find("daemon started") >= 0:
-                break
-            output.append(line)
-
-    return (cmd_return_code, output)
-
-
-def uninstPKGs():
-    action_status = True
-    for root, dirs, files in os.walk(SCRIPT_DIR):
-        for file in files:
-            if file.endswith(".apk"):
-                cmd = "%s -s %s uninstall org.xwalk.%s" % (
-                    ADB_CMD, PARAMETERS.device, os.path.basename(os.path.splitext(file)[0]))
-                (return_code, output) = doCMD(cmd)
-                for line in output:
-                    if "Failure" in line:
-                        action_status = False
-                        break
-    return action_status
-
-
-def instPKGs():
-    action_status = True
-    for root, dirs, files in os.walk(SCRIPT_DIR):
-        for file in files:
-            if file.endswith(".apk"):
-                cmd = "%s -s %s install %s" % (ADB_CMD,
-                                               PARAMETERS.device, os.path.join(root, file))
-                (return_code, output) = doCMD(cmd)
-                for line in output:
-                    if "Failure" in line:
-                        action_status = False
-                        break
-    return action_status
-
-
-def main():
-    try:
-        usage = "usage: inst.py -i"
-        opts_parser = OptionParser(usage=usage)
-        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")
-        global PARAMETERS
-        (PARAMETERS, args) = opts_parser.parse_args()
-    except Exception, e:
-        print "Got wrong option: %s, exit ..." % e
-        sys.exit(1)
-
-    if not PARAMETERS.device:
-        (return_code, output) = doCMD("adb devices")
-        for line in output:
-            if str.find(line, "\tdevice") != -1:
-                PARAMETERS.device = line.split("\t")[0]
-                break
-
-    if not PARAMETERS.device:
-        print "No device found"
-        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
+PARAMETERS = None\r
+ADB_CMD = "adb"\r
+\r
+\r
+def doCMD(cmd):\r
+    # Do not need handle timeout in this short script\r
+    print ("-->> \"%s\"" % cmd)\r
+    output = []\r
+    cmd_proc = subprocess.Popen(\r
+        cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
+    while True:\r
+        cmd_return_code = cmd_proc.poll()\r
+        if cmd_return_code != None:\r
+            break\r
+\r
+    if not cmd.endswith("&"):\r
+        while True:\r
+            line = cmd_proc.stdout.readline().decode("UTF-8").strip('\n')\r
+            print (line)\r
+            if not line or line.find("daemon started") >= 0:\r
+                break\r
+            output.append(line)\r
+\r
+    return (cmd_return_code, output)\r
+\r
+\r
+def uninstPKGs():\r
+    action_status = True\r
+    for root, dirs, files in os.walk(SCRIPT_DIR):\r
+        for file in files:\r
+            if file.endswith(".apk"):\r
+                cmd = "%s -s %s uninstall org.xwalk.%s" % (\r
+                    ADB_CMD, PARAMETERS.device, os.path.basename(os.path.splitext(file)[0]))\r
+                (return_code, output) = doCMD(cmd)\r
+                for line in output:\r
+                    if "Failure" in line:\r
+                        action_status = False\r
+                        break\r
+    return action_status\r
+\r
+\r
+def instPKGs():\r
+    action_status = True\r
+    for root, dirs, files in os.walk(SCRIPT_DIR):\r
+        for file in files:\r
+            if file.endswith(".apk"):\r
+                cmd = "%s -s %s install %s" % (ADB_CMD,\r
+                                               PARAMETERS.device, os.path.join(root, file))\r
+                (return_code, output) = doCMD(cmd)\r
+                for line in output:\r
+                    if "Failure" in line:\r
+                        action_status = False\r
+                        break\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
+            "-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
+        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.device:\r
+        (return_code, output) = doCMD("adb devices")\r
+        for line in output:\r
+            if str.find(line, "\tdevice") != -1:\r
+                PARAMETERS.device = line.split("\t")[0]\r
+                break\r
+\r
+    if not PARAMETERS.device:\r
+        print ("No device found")\r
+        sys.exit(1)\r
+\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 1e80823763f7ff8d60422617e62196ad5b8150cd..da2a425b2fbdecc2f52e44c26347b6efaf23b722 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,7 +49,7 @@ 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_proc = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
@@ -60,8 +60,8 @@ def doCMD(cmd):
 
     if not cmd.endswith("&"):
         while True:
-            line = cmd_proc.stdout.readline().strip("\r\n")
-            print line
+            line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")
+            print (line)
             if not line or line.find("daemon started") >= 0:
                 break
             output.append(line)
@@ -202,8 +202,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:
@@ -222,7 +222,7 @@ def main():
         PARAMETERS.mode = "SSH"
 
     if not PARAMETERS.device:
-        print "No device provided"
+        print ("No device provided")
         sys.exit(1)
 
     userCheck()
@@ -234,10 +234,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 1c47cca9562fab04a999b7416d483e8c10868d2a..5ae8883f60ca077471f4e6cbef4e2a37ff87a908 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_proc = subprocess.Popen(
-        cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
-    while True:
-        cmd_return_code = cmd_proc.poll()
-        if cmd_return_code != None:
-            break
-
-    if not cmd.endswith("&"):
-        while True:
-            line = cmd_proc.stdout.readline().strip("\r\n")
-            print line
-            if not line or line.find("daemon started") >= 0:
-                break
-            output.append(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):
-        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):
-        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
-
-    for item in glob.glob("%s/*" % SCRIPT_DIR):
-        if item.endswith(".xpk"):
-            continue
-        elif item.endswith("inst.py"):
-            continue
-        else:
-            item_name = os.path.basename(item)
-            if not doRemoteCopy(item, PKG_SRC_DIR+"/"+item_name):
-            #if not doRemoteCopy(item, 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_proc = subprocess.Popen(\r
+        cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
+    while True:\r
+        cmd_return_code = cmd_proc.poll()\r
+        if cmd_return_code != None:\r
+            break\r
+\r
+    if not cmd.endswith("&"):\r
+        while True:\r
+            line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n")\r
+            print (line)\r
+            if not line or line.find("daemon started") >= 0:\r
+                break\r
+            output.append(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
+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
+        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
+        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
+    for item in glob.glob("%s/*" % SCRIPT_DIR):\r
+        if item.endswith(".xpk"):\r
+            continue\r
+        elif item.endswith("inst.py"):\r
+            continue\r
+        else:\r
+            item_name = os.path.basename(item)\r
+            if not doRemoteCopy(item, PKG_SRC_DIR+"/"+item_name):\r
+            #if not doRemoteCopy(item, PKG_SRC_DIR):\r
+                action_status = False\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: