From: chen Date: Tue, 10 May 2022 07:55:13 +0000 (+0800) Subject: api update to python3X X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f347388fdf7034d9604da3e4c46370528b529f10;p=test%2Ftct%2Fweb%2Fapi.git api update to python3X Change-Id: Icbc8514554307cc69486abde9efc27050a494b0c Signed-off-by: chen --- diff --git a/common/tct-2dtransforms-css3-tests/inst.apk.py b/common/tct-2dtransforms-css3-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/common/tct-2dtransforms-css3-tests/inst.apk.py +++ b/common/tct-2dtransforms-css3-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/common/tct-2dtransforms-css3-tests/inst.wgt.py b/common/tct-2dtransforms-css3-tests/inst.wgt.py index c7f89fd44..909755af3 100755 --- a/common/tct-2dtransforms-css3-tests/inst.wgt.py +++ b/common/tct-2dtransforms-css3-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -191,8 +191,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: @@ -211,7 +211,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -223,10 +223,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: diff --git a/common/tct-2dtransforms-css3-tests/inst.xpk.py b/common/tct-2dtransforms-css3-tests/inst.xpk.py index bbc0c8558..ace8cbba9 100755 --- a/common/tct-2dtransforms-css3-tests/inst.xpk.py +++ b/common/tct-2dtransforms-css3-tests/inst.xpk.py @@ -8,6 +8,7 @@ import sys import subprocess import string from optparse import OptionParser, make_option +import configparser SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) @@ -15,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) @@ -23,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 @@ -182,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: @@ -202,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() @@ -212,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: diff --git a/common/tct-2dtransforms-css3-tests/pack.py b/common/tct-2dtransforms-css3-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-2dtransforms-css3-tests/pack.py +++ b/common/tct-2dtransforms-css3-tests/pack.py @@ -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: diff --git a/common/tct-3dtransforms-css3-tests/inst.apk.py b/common/tct-3dtransforms-css3-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-3dtransforms-css3-tests/inst.apk.py +++ b/common/tct-3dtransforms-css3-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-3dtransforms-css3-tests/inst.wgt.py b/common/tct-3dtransforms-css3-tests/inst.wgt.py index 7e3caa6c3..b88c1fccf 100755 --- a/common/tct-3dtransforms-css3-tests/inst.wgt.py +++ b/common/tct-3dtransforms-css3-tests/inst.wgt.py @@ -1,241 +1,241 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-3dtransforms-css3-tests/inst.xpk.py b/common/tct-3dtransforms-css3-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-3dtransforms-css3-tests/inst.xpk.py +++ b/common/tct-3dtransforms-css3-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-3dtransforms-css3-tests/pack.py b/common/tct-3dtransforms-css3-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-3dtransforms-css3-tests/pack.py +++ b/common/tct-3dtransforms-css3-tests/pack.py @@ -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: diff --git a/common/tct-ResponsiveImage-w3c-tests/inst.apk.py b/common/tct-ResponsiveImage-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-ResponsiveImage-w3c-tests/inst.apk.py +++ b/common/tct-ResponsiveImage-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-ResponsiveImage-w3c-tests/inst.wgt.py b/common/tct-ResponsiveImage-w3c-tests/inst.wgt.py index 93ac8ad71..66eb23daa 100755 --- a/common/tct-ResponsiveImage-w3c-tests/inst.wgt.py +++ b/common/tct-ResponsiveImage-w3c-tests/inst.wgt.py @@ -1,240 +1,240 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-ResponsiveImage-w3c-tests/inst.xpk.py b/common/tct-ResponsiveImage-w3c-tests/inst.xpk.py index a5295f0ab..a61db816d 100755 --- a/common/tct-ResponsiveImage-w3c-tests/inst.xpk.py +++ b/common/tct-ResponsiveImage-w3c-tests/inst.xpk.py @@ -1,228 +1,228 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -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" -SRC_DIR = "/home/app/content" -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "app" - 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 + + +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" +SRC_DIR = "/home/app/content" +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = "app" + 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) diff --git a/common/tct-ResponsiveImage-w3c-tests/pack.py b/common/tct-ResponsiveImage-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-ResponsiveImage-w3c-tests/pack.py +++ b/common/tct-ResponsiveImage-w3c-tests/pack.py @@ -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: diff --git a/common/tct-account-tizen-tests/inst.apk.py b/common/tct-account-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-account-tizen-tests/inst.apk.py +++ b/common/tct-account-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-account-tizen-tests/inst.wgt.py b/common/tct-account-tizen-tests/inst.wgt.py index 2316502f4..5ec20dc07 100755 --- a/common/tct-account-tizen-tests/inst.wgt.py +++ b/common/tct-account-tizen-tests/inst.wgt.py @@ -1,257 +1,257 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - -def askpolicyremoving(): - for root, dirs, files in os.walk(SCRIPT_DIR): - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - - 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)): - action_status = False - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell .%s/askpolicy.sh %s" % (PARAMETERS.device, - SRC_DIR, pkg_id) - return doCMD(cmd) - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - #askpolicyremoving() - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + +def askpolicyremoving(): + for root, dirs, files in os.walk(SCRIPT_DIR): + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + + 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)): + action_status = False + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell .%s/askpolicy.sh %s" % (PARAMETERS.device, + SRC_DIR, pkg_id) + return doCMD(cmd) + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + #askpolicyremoving() + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-account-tizen-tests/inst.xpk.py b/common/tct-account-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-account-tizen-tests/inst.xpk.py +++ b/common/tct-account-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-account-tizen-tests/pack.py b/common/tct-account-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-account-tizen-tests/pack.py +++ b/common/tct-account-tizen-tests/pack.py @@ -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: diff --git a/common/tct-alarm-tizen-tests/inst.apk.py b/common/tct-alarm-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-alarm-tizen-tests/inst.apk.py +++ b/common/tct-alarm-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-alarm-tizen-tests/inst.wgt.py b/common/tct-alarm-tizen-tests/inst.wgt.py index 7f7d2c9d3..a928420d1 100755 --- a/common/tct-alarm-tizen-tests/inst.wgt.py +++ b/common/tct-alarm-tizen-tests/inst.wgt.py @@ -1,245 +1,245 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - - for pkg_name in ["tct-alarm-tizen-tests", "alarmTestApp"]: - pkg_id = getPKGID(pkg_name) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD("pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - (return_code, output) = doRemoteCMD("rm -rf %s/Images" % SRC_DIR) - if return_code != 0: - action_status = False - - (return_code, output) = doRemoteCMD("rm -rf %s/Sounds" % 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(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD("mkdir -p %s/Images" % SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("%s/*.jpg" % SCRIPT_DIR, "%s/Images" % SRC_DIR): - action_status = False - - (return_code, output) = doRemoteCMD("mkdir -p %s/Sounds" % SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("%s/*.mp3" % SCRIPT_DIR, "%s/Sounds" % SRC_DIR): - action_status = False - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + + for pkg_name in ["tct-alarm-tizen-tests", "alarmTestApp"]: + pkg_id = getPKGID(pkg_name) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD("pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + (return_code, output) = doRemoteCMD("rm -rf %s/Images" % SRC_DIR) + if return_code != 0: + action_status = False + + (return_code, output) = doRemoteCMD("rm -rf %s/Sounds" % 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(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD("mkdir -p %s/Images" % SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("%s/*.jpg" % SCRIPT_DIR, "%s/Images" % SRC_DIR): + action_status = False + + (return_code, output) = doRemoteCMD("mkdir -p %s/Sounds" % SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("%s/*.mp3" % SCRIPT_DIR, "%s/Sounds" % 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 as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-alarm-tizen-tests/inst.xpk.py b/common/tct-alarm-tizen-tests/inst.xpk.py index c0c358ecc..34a9d92c3 100755 --- a/common/tct-alarm-tizen-tests/inst.xpk.py +++ b/common/tct-alarm-tizen-tests/inst.xpk.py @@ -1,214 +1,214 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - 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 - - 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 + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + 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 + + 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 as 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) diff --git a/common/tct-alarm-tizen-tests/pack.py b/common/tct-alarm-tizen-tests/pack.py index 08d55aafe..92866ab2e 100755 --- a/common/tct-alarm-tizen-tests/pack.py +++ b/common/tct-alarm-tizen-tests/pack.py @@ -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: diff --git a/common/tct-animations-css3-tests/inst.apk.py b/common/tct-animations-css3-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-animations-css3-tests/inst.apk.py +++ b/common/tct-animations-css3-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-animations-css3-tests/inst.wgt.py b/common/tct-animations-css3-tests/inst.wgt.py index 7e3caa6c3..b88c1fccf 100755 --- a/common/tct-animations-css3-tests/inst.wgt.py +++ b/common/tct-animations-css3-tests/inst.wgt.py @@ -1,241 +1,241 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-animations-css3-tests/inst.xpk.py b/common/tct-animations-css3-tests/inst.xpk.py index aa292c379..7dcd40d98 100755 --- a/common/tct-animations-css3-tests/inst.xpk.py +++ b/common/tct-animations-css3-tests/inst.xpk.py @@ -1,229 +1,229 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - -# for file in files: -# if file.endswith(".xpk"): -# if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): -# action_status = False -# (return_code, output) = doRemoteCMD( -# "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) -# doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) -# for line in output: -# if "Failure" in line: -# action_status = False -# break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + +# for file in files: +# if file.endswith(".xpk"): +# if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): +# action_status = False +# (return_code, output) = doRemoteCMD( +# "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) +# doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) +# for line in output: +# if "Failure" in line: +# action_status = False +# break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-animations-css3-tests/pack.py b/common/tct-animations-css3-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-animations-css3-tests/pack.py +++ b/common/tct-animations-css3-tests/pack.py @@ -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: diff --git a/common/tct-animationtiming-w3c-tests/inst.apk.py b/common/tct-animationtiming-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-animationtiming-w3c-tests/inst.apk.py +++ b/common/tct-animationtiming-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-animationtiming-w3c-tests/inst.wgt.py b/common/tct-animationtiming-w3c-tests/inst.wgt.py index 7e3caa6c3..b88c1fccf 100755 --- a/common/tct-animationtiming-w3c-tests/inst.wgt.py +++ b/common/tct-animationtiming-w3c-tests/inst.wgt.py @@ -1,241 +1,241 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-animationtiming-w3c-tests/inst.xpk.py b/common/tct-animationtiming-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-animationtiming-w3c-tests/inst.xpk.py +++ b/common/tct-animationtiming-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-animationtiming-w3c-tests/pack.py b/common/tct-animationtiming-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-animationtiming-w3c-tests/pack.py +++ b/common/tct-animationtiming-w3c-tests/pack.py @@ -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: diff --git a/common/tct-appcache-html5-tests/inst.apk.py b/common/tct-appcache-html5-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-appcache-html5-tests/inst.apk.py +++ b/common/tct-appcache-html5-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-appcache-html5-tests/inst.wgt.py b/common/tct-appcache-html5-tests/inst.wgt.py index 8ed577c13..21f138a35 100755 --- a/common/tct-appcache-html5-tests/inst.wgt.py +++ b/common/tct-appcache-html5-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -189,8 +189,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: @@ -209,7 +209,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -221,10 +221,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: diff --git a/common/tct-appcache-html5-tests/inst.xpk.py b/common/tct-appcache-html5-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-appcache-html5-tests/inst.xpk.py +++ b/common/tct-appcache-html5-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-appcache-html5-tests/pack.py b/common/tct-appcache-html5-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-appcache-html5-tests/pack.py +++ b/common/tct-appcache-html5-tests/pack.py @@ -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: diff --git a/common/tct-appcontrol-tizen-tests/inst.apk.py b/common/tct-appcontrol-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-appcontrol-tizen-tests/inst.apk.py +++ b/common/tct-appcontrol-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-appcontrol-tizen-tests/inst.wgt.py b/common/tct-appcontrol-tizen-tests/inst.wgt.py index 8b44f9c8d..b72850d63 100755 --- a/common/tct-appcontrol-tizen-tests/inst.wgt.py +++ b/common/tct-appcontrol-tizen-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -191,8 +191,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: @@ -211,7 +211,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -223,10 +223,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: diff --git a/common/tct-appcontrol-tizen-tests/inst.xpk.py b/common/tct-appcontrol-tizen-tests/inst.xpk.py index 2b5e3f2e1..e4dff9a99 100755 --- a/common/tct-appcontrol-tizen-tests/inst.xpk.py +++ b/common/tct-appcontrol-tizen-tests/inst.xpk.py @@ -1,227 +1,227 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - 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_code, output) = doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, PKG_NAME)) - 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 - - (return_code, output) = doRemoteCMD("mkdir -p %s/%s" % (SRC_DIR, PKG_NAME)) - if return_code != 0: - action_status = False - - for item in os.listdir(SCRIPT_DIR): - if item.find("webapi-tizen-appcontrol-test_") != -1: - if not doRemoteCopy("%s/%s" % (SCRIPT_DIR, item), "%s/%s/%s" % (SRC_DIR, PKG_NAME, item)): - 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 + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + 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_code, output) = doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, PKG_NAME)) + 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 + + (return_code, output) = doRemoteCMD("mkdir -p %s/%s" % (SRC_DIR, PKG_NAME)) + if return_code != 0: + action_status = False + + for item in os.listdir(SCRIPT_DIR): + if item.find("webapi-tizen-appcontrol-test_") != -1: + if not doRemoteCopy("%s/%s" % (SCRIPT_DIR, item), "%s/%s/%s" % (SRC_DIR, PKG_NAME, item)): + 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 as 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) diff --git a/common/tct-appcontrol-tizen-tests/pack.py b/common/tct-appcontrol-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-appcontrol-tizen-tests/pack.py +++ b/common/tct-appcontrol-tizen-tests/pack.py @@ -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: diff --git a/common/tct-application-tizen-tests/inst.apk.py b/common/tct-application-tizen-tests/inst.apk.py index 31210db16..997d98f37 100755 --- a/common/tct-application-tizen-tests/inst.apk.py +++ b/common/tct-application-tizen-tests/inst.apk.py @@ -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: diff --git a/common/tct-application-tizen-tests/inst.wgt.py b/common/tct-application-tizen-tests/inst.wgt.py index 9e0c931c3..4baa95007 100755 --- a/common/tct-application-tizen-tests/inst.wgt.py +++ b/common/tct-application-tizen-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -190,8 +190,8 @@ def main(): "-a", dest="user", action="store", help="User name") global PARAMETERS (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) sys.exit(1) if not PARAMETERS.user: @@ -210,7 +210,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -222,10 +222,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: diff --git a/common/tct-application-tizen-tests/inst.xpk.py b/common/tct-application-tizen-tests/inst.xpk.py index 371cc3088..9a9a8f4e3 100755 --- a/common/tct-application-tizen-tests/inst.xpk.py +++ b/common/tct-application-tizen-tests/inst.xpk.py @@ -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 @@ -181,8 +181,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: @@ -201,7 +201,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -211,10 +211,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: diff --git a/common/tct-application-tizen-tests/pack.py b/common/tct-application-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-application-tizen-tests/pack.py +++ b/common/tct-application-tizen-tests/pack.py @@ -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: diff --git a/common/tct-archive-tizen-tests/inst.apk.py b/common/tct-archive-tizen-tests/inst.apk.py index 31210db16..997d98f37 100755 --- a/common/tct-archive-tizen-tests/inst.apk.py +++ b/common/tct-archive-tizen-tests/inst.apk.py @@ -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: diff --git a/common/tct-archive-tizen-tests/inst.wgt.py b/common/tct-archive-tizen-tests/inst.wgt.py index b8776ee49..a20ec241c 100755 --- a/common/tct-archive-tizen-tests/inst.wgt.py +++ b/common/tct-archive-tizen-tests/inst.wgt.py @@ -10,7 +10,7 @@ import string import logging import Queue from optparse import OptionParser, make_option -import ConfigParser +import configparser from shellmanager import ShellManager SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) @@ -18,7 +18,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') USER_DIR = tct_parser.get('DEVICE', 'DEVICE_USER_30') @@ -53,10 +53,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() @@ -72,7 +72,7 @@ def getInternalStorage(): # PARAMETERS.device) # return doCMD(cmd) # except Exception as ex: -# print ex +# print (ex) # else: # print ("aaaaaaaaaaaaaaa") # os.system( @@ -85,14 +85,14 @@ def getInternalStorage(): 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 @@ -245,8 +245,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: @@ -265,7 +265,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -279,10 +279,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: diff --git a/common/tct-archive-tizen-tests/inst.xpk.py b/common/tct-archive-tizen-tests/inst.xpk.py index 371cc3088..9a9a8f4e3 100755 --- a/common/tct-archive-tizen-tests/inst.xpk.py +++ b/common/tct-archive-tizen-tests/inst.xpk.py @@ -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 @@ -181,8 +181,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: @@ -201,7 +201,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -211,10 +211,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: diff --git a/common/tct-archive-tizen-tests/pack.py b/common/tct-archive-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-archive-tizen-tests/pack.py +++ b/common/tct-archive-tizen-tests/pack.py @@ -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: diff --git a/common/tct-audio-html5-tests/inst.apk.py b/common/tct-audio-html5-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-audio-html5-tests/inst.apk.py +++ b/common/tct-audio-html5-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-audio-html5-tests/inst.wgt.py b/common/tct-audio-html5-tests/inst.wgt.py index a7478a061..6ae9cae4a 100755 --- a/common/tct-audio-html5-tests/inst.wgt.py +++ b/common/tct-audio-html5-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -191,8 +191,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: @@ -211,7 +211,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -223,10 +223,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: diff --git a/common/tct-audio-html5-tests/inst.xpk.py b/common/tct-audio-html5-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-audio-html5-tests/inst.xpk.py +++ b/common/tct-audio-html5-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-audio-html5-tests/pack.py b/common/tct-audio-html5-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-audio-html5-tests/pack.py +++ b/common/tct-audio-html5-tests/pack.py @@ -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: diff --git a/common/tct-backgrounds-css3-tests/inst.apk.py b/common/tct-backgrounds-css3-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-backgrounds-css3-tests/inst.apk.py +++ b/common/tct-backgrounds-css3-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-backgrounds-css3-tests/inst.wgt.py b/common/tct-backgrounds-css3-tests/inst.wgt.py index 8ed577c13..21f138a35 100755 --- a/common/tct-backgrounds-css3-tests/inst.wgt.py +++ b/common/tct-backgrounds-css3-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -189,8 +189,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: @@ -209,7 +209,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -221,10 +221,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: diff --git a/common/tct-backgrounds-css3-tests/inst.xpk.py b/common/tct-backgrounds-css3-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-backgrounds-css3-tests/inst.xpk.py +++ b/common/tct-backgrounds-css3-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-backgrounds-css3-tests/pack.py b/common/tct-backgrounds-css3-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-backgrounds-css3-tests/pack.py +++ b/common/tct-backgrounds-css3-tests/pack.py @@ -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: diff --git a/common/tct-badge-tizen-tests/inst.apk.py b/common/tct-badge-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-badge-tizen-tests/inst.apk.py +++ b/common/tct-badge-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-badge-tizen-tests/inst.wgt.py b/common/tct-badge-tizen-tests/inst.wgt.py index 18690763e..5bbb418f3 100755 --- a/common/tct-badge-tizen-tests/inst.wgt.py +++ b/common/tct-badge-tizen-tests/inst.wgt.py @@ -1,242 +1,242 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-badge-tizen-tests/inst.xpk.py b/common/tct-badge-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-badge-tizen-tests/inst.xpk.py +++ b/common/tct-badge-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-badge-tizen-tests/pack.py b/common/tct-badge-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-badge-tizen-tests/pack.py +++ b/common/tct-badge-tizen-tests/pack.py @@ -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: diff --git a/common/tct-batterystatus-w3c-tests/inst.apk.py b/common/tct-batterystatus-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-batterystatus-w3c-tests/inst.apk.py +++ b/common/tct-batterystatus-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-batterystatus-w3c-tests/inst.wgt.py b/common/tct-batterystatus-w3c-tests/inst.wgt.py index 7e3caa6c3..b88c1fccf 100755 --- a/common/tct-batterystatus-w3c-tests/inst.wgt.py +++ b/common/tct-batterystatus-w3c-tests/inst.wgt.py @@ -1,241 +1,241 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-batterystatus-w3c-tests/inst.xpk.py b/common/tct-batterystatus-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-batterystatus-w3c-tests/inst.xpk.py +++ b/common/tct-batterystatus-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-batterystatus-w3c-tests/pack.py b/common/tct-batterystatus-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-batterystatus-w3c-tests/pack.py +++ b/common/tct-batterystatus-w3c-tests/pack.py @@ -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: diff --git a/common/tct-beacon-w3c-tests/inst.apk.py b/common/tct-beacon-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-beacon-w3c-tests/inst.apk.py +++ b/common/tct-beacon-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-beacon-w3c-tests/inst.wgt.py b/common/tct-beacon-w3c-tests/inst.wgt.py index 8ed577c13..21f138a35 100755 --- a/common/tct-beacon-w3c-tests/inst.wgt.py +++ b/common/tct-beacon-w3c-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -189,8 +189,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: @@ -209,7 +209,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -221,10 +221,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: diff --git a/common/tct-beacon-w3c-tests/inst.xpk.py b/common/tct-beacon-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-beacon-w3c-tests/inst.xpk.py +++ b/common/tct-beacon-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-beacon-w3c-tests/pack.py b/common/tct-beacon-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-beacon-w3c-tests/pack.py +++ b/common/tct-beacon-w3c-tests/pack.py @@ -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: diff --git a/common/tct-bluetooth-tizen-tests/inst.apk.py b/common/tct-bluetooth-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-bluetooth-tizen-tests/inst.apk.py +++ b/common/tct-bluetooth-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-bluetooth-tizen-tests/inst.wgt.py b/common/tct-bluetooth-tizen-tests/inst.wgt.py index d7b962bfa..0f5e3baa1 100755 --- a/common/tct-bluetooth-tizen-tests/inst.wgt.py +++ b/common/tct-bluetooth-tizen-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -189,8 +189,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: @@ -209,7 +209,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -221,10 +221,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: diff --git a/common/tct-bluetooth-tizen-tests/inst.xpk.py b/common/tct-bluetooth-tizen-tests/inst.xpk.py index c0c358ecc..34a9d92c3 100755 --- a/common/tct-bluetooth-tizen-tests/inst.xpk.py +++ b/common/tct-bluetooth-tizen-tests/inst.xpk.py @@ -1,214 +1,214 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - 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 - - 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 + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + 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 + + 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 as 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) diff --git a/common/tct-bluetooth-tizen-tests/pack.py b/common/tct-bluetooth-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-bluetooth-tizen-tests/pack.py +++ b/common/tct-bluetooth-tizen-tests/pack.py @@ -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: diff --git a/common/tct-browserstate-html5-tests/inst.apk.py b/common/tct-browserstate-html5-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-browserstate-html5-tests/inst.apk.py +++ b/common/tct-browserstate-html5-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-browserstate-html5-tests/inst.wgt.py b/common/tct-browserstate-html5-tests/inst.wgt.py index 7e3caa6c3..b88c1fccf 100755 --- a/common/tct-browserstate-html5-tests/inst.wgt.py +++ b/common/tct-browserstate-html5-tests/inst.wgt.py @@ -1,241 +1,241 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-browserstate-html5-tests/inst.xpk.py b/common/tct-browserstate-html5-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-browserstate-html5-tests/inst.xpk.py +++ b/common/tct-browserstate-html5-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-browserstate-html5-tests/pack.py b/common/tct-browserstate-html5-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-browserstate-html5-tests/pack.py +++ b/common/tct-browserstate-html5-tests/pack.py @@ -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: diff --git a/common/tct-calendar-tizen-tests/inst.apk.py b/common/tct-calendar-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-calendar-tizen-tests/inst.apk.py +++ b/common/tct-calendar-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-calendar-tizen-tests/inst.wgt.py b/common/tct-calendar-tizen-tests/inst.wgt.py index ef38eb600..6e0726097 100755 --- a/common/tct-calendar-tizen-tests/inst.wgt.py +++ b/common/tct-calendar-tizen-tests/inst.wgt.py @@ -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 @@ -205,8 +205,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: @@ -225,7 +225,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -237,10 +237,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: diff --git a/common/tct-calendar-tizen-tests/inst.xpk.py b/common/tct-calendar-tizen-tests/inst.xpk.py index 36b426acb..10bb5c425 100755 --- a/common/tct-calendar-tizen-tests/inst.xpk.py +++ b/common/tct-calendar-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -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" -SRC_DIR = "" -PKG_SRC_DIR = "" - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - - global SRC_DIR, PKG_SRC_DIR - SRC_DIR = "/home/%s/content" % PARAMETERS.user - PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - 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 + + +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" +SRC_DIR = "" +PKG_SRC_DIR = "" + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = "owner" + + global SRC_DIR, PKG_SRC_DIR + SRC_DIR = "/home/%s/content" % PARAMETERS.user + PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + 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) diff --git a/common/tct-calendar-tizen-tests/pack.py b/common/tct-calendar-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-calendar-tizen-tests/pack.py +++ b/common/tct-calendar-tizen-tests/pack.py @@ -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: diff --git a/common/tct-callhistory-tizen-tests/inst.apk.py b/common/tct-callhistory-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-callhistory-tizen-tests/inst.apk.py +++ b/common/tct-callhistory-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-callhistory-tizen-tests/inst.wgt.py b/common/tct-callhistory-tizen-tests/inst.wgt.py index ef38eb600..6e0726097 100755 --- a/common/tct-callhistory-tizen-tests/inst.wgt.py +++ b/common/tct-callhistory-tizen-tests/inst.wgt.py @@ -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 @@ -205,8 +205,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: @@ -225,7 +225,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -237,10 +237,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: diff --git a/common/tct-callhistory-tizen-tests/inst.xpk.py b/common/tct-callhistory-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-callhistory-tizen-tests/inst.xpk.py +++ b/common/tct-callhistory-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-callhistory-tizen-tests/pack.py b/common/tct-callhistory-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-callhistory-tizen-tests/pack.py +++ b/common/tct-callhistory-tizen-tests/pack.py @@ -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: diff --git a/common/tct-canvas-html5-tests/inst.apk.py b/common/tct-canvas-html5-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-canvas-html5-tests/inst.apk.py +++ b/common/tct-canvas-html5-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-canvas-html5-tests/inst.wgt.py b/common/tct-canvas-html5-tests/inst.wgt.py index 84a331b62..275a9362d 100755 --- a/common/tct-canvas-html5-tests/inst.wgt.py +++ b/common/tct-canvas-html5-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -189,8 +189,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: @@ -209,7 +209,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -221,10 +221,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: diff --git a/common/tct-canvas-html5-tests/inst.xpk.py b/common/tct-canvas-html5-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-canvas-html5-tests/inst.xpk.py +++ b/common/tct-canvas-html5-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-canvas-html5-tests/pack.py b/common/tct-canvas-html5-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-canvas-html5-tests/pack.py +++ b/common/tct-canvas-html5-tests/pack.py @@ -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: diff --git a/common/tct-colors-css3-tests/inst.apk.py b/common/tct-colors-css3-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-colors-css3-tests/inst.apk.py +++ b/common/tct-colors-css3-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-colors-css3-tests/inst.wgt.py b/common/tct-colors-css3-tests/inst.wgt.py index c7f89fd44..909755af3 100755 --- a/common/tct-colors-css3-tests/inst.wgt.py +++ b/common/tct-colors-css3-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -191,8 +191,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: @@ -211,7 +211,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -223,10 +223,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: diff --git a/common/tct-colors-css3-tests/inst.xpk.py b/common/tct-colors-css3-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-colors-css3-tests/inst.xpk.py +++ b/common/tct-colors-css3-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-colors-css3-tests/pack.py b/common/tct-colors-css3-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-colors-css3-tests/pack.py +++ b/common/tct-colors-css3-tests/pack.py @@ -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: diff --git a/common/tct-contact-tizen-tests/inst.apk.py b/common/tct-contact-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-contact-tizen-tests/inst.apk.py +++ b/common/tct-contact-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-contact-tizen-tests/inst.wgt.py b/common/tct-contact-tizen-tests/inst.wgt.py index f04d84498..80b6b1ba8 100755 --- a/common/tct-contact-tizen-tests/inst.wgt.py +++ b/common/tct-contact-tizen-tests/inst.wgt.py @@ -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) @@ -36,7 +36,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,14 +48,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 @@ -199,8 +199,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: @@ -219,7 +219,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -231,10 +231,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: diff --git a/common/tct-contact-tizen-tests/inst.xpk.py b/common/tct-contact-tizen-tests/inst.xpk.py index 371cc3088..9fc4020eb 100755 --- a/common/tct-contact-tizen-tests/inst.xpk.py +++ b/common/tct-contact-tizen-tests/inst.xpk.py @@ -1,229 +1,229 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - (return_code, output) = doRemoteCMD( - "rm -rf %s/Others" % SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - if not doRemoteCopy(os.path.join(SCRIPT_DIR, "mediasrc"), "%s/Others" % 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 + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + (return_code, output) = doRemoteCMD( + "rm -rf %s/Others" % SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + if not doRemoteCopy(os.path.join(SCRIPT_DIR, "mediasrc"), "%s/Others" % 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 as 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) diff --git a/common/tct-contact-tizen-tests/pack.py b/common/tct-contact-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-contact-tizen-tests/pack.py +++ b/common/tct-contact-tizen-tests/pack.py @@ -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: diff --git a/common/tct-content-tizen-tests/Queue.pyc b/common/tct-content-tizen-tests/Queue.pyc old mode 100755 new mode 100644 index 0ad593081..9fad00e4c Binary files a/common/tct-content-tizen-tests/Queue.pyc and b/common/tct-content-tizen-tests/Queue.pyc differ diff --git a/common/tct-content-tizen-tests/inst.apk.py b/common/tct-content-tizen-tests/inst.apk.py index 31210db16..997d98f37 100755 --- a/common/tct-content-tizen-tests/inst.apk.py +++ b/common/tct-content-tizen-tests/inst.apk.py @@ -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: diff --git a/common/tct-content-tizen-tests/inst.wgt.py b/common/tct-content-tizen-tests/inst.wgt.py index 08c6d3d34..1508860d8 100755 --- a/common/tct-content-tizen-tests/inst.wgt.py +++ b/common/tct-content-tizen-tests/inst.wgt.py @@ -10,7 +10,7 @@ import string import logging import Queue from optparse import OptionParser, make_option -import ConfigParser +import configparser from shellmanager import ShellManager time.sleep(3) @@ -20,7 +20,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') #INTERNAL_STORAGE = tct_parser.get('DEVICE', 'DEVICE_STORAGE_30') @@ -72,51 +72,28 @@ 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() def askpolicyremoving(): - print "0" - print "0" - print "0" - print "0" - print "0" for root, dirs, files in os.walk(SCRIPT_DIR): for file in files: if file.endswith(".wgt"): pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - print pkg_id - print pkg_id - print pkg_id - print pkg_id + print (pkg_id) print (os.getcwd()) - print (os.getcwd()) - print (os.path.dirname(os.path.realpath(__file__)) ) print (os.path.dirname(os.path.realpath(__file__)) ) if not doRemoteCopy("%s/askpolicy.sh" % SCRIPT_DIR, "%s" % (SRC_DIR)): action_status = False - print "1" - print "1" - print "1" - print "1" - print "1" if PARAMETERS.mode == "SDB": cmd = "sdb -s %s shell .%s/askpolicy.sh %s" % (PARAMETERS.device, SRC_DIR, pkg_id) - print cmd - print cmd - print cmd - print cmd - print cmd - return doCMD(cmd) - print "2" - print "2" - print "2" + return doCMD(cmd) def recordInternalStorage(): try: @@ -130,7 +107,7 @@ def recordInternalStorage(): PARAMETERS.device) return doCMD(cmd) except Exception as ex: - print ex + print (ex) else: print ("aaaaaaaaaaaaaaa") # os.system( @@ -143,14 +120,14 @@ def recordInternalStorage(): 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 @@ -273,8 +250,6 @@ def instPKGs(): action_status = False break print(INTERNAL_STORAGE) - print(INTERNAL_STORAGE) - print(INTERNAL_STORAGE) if not doRemoteCopy("%s/media" % SCRIPT_DIR, "%s/%s" % (SRC_DIR, PKG_NAME)): action_status = False if not doRemoteCopy("%s/media" % SCRIPT_DIR, "%s/Downloads/" % (INTERNAL_STORAGE)): @@ -303,8 +278,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: @@ -323,7 +298,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -337,10 +312,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: @@ -348,11 +323,6 @@ def main(): sys.exit(1) else: if not instPKGs(): - print "inst" - print "inst" - print "inst" - print "inst" - print "inst" #askpolicyremoving() sys.exit(1) diff --git a/common/tct-content-tizen-tests/inst.xpk.py b/common/tct-content-tizen-tests/inst.xpk.py index c3b031d9a..3626cd23a 100755 --- a/common/tct-content-tizen-tests/inst.xpk.py +++ b/common/tct-content-tizen-tests/inst.xpk.py @@ -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 @@ -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: diff --git a/common/tct-content-tizen-tests/pack.py b/common/tct-content-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-content-tizen-tests/pack.py +++ b/common/tct-content-tizen-tests/pack.py @@ -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: diff --git a/common/tct-content-tizen-tests/shellmanager.pyc b/common/tct-content-tizen-tests/shellmanager.pyc old mode 100755 new mode 100644 index 12c9ac6fd..4d0e366f9 Binary files a/common/tct-content-tizen-tests/shellmanager.pyc and b/common/tct-content-tizen-tests/shellmanager.pyc differ diff --git a/common/tct-convergence-tizen-tests/inst.apk.py b/common/tct-convergence-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-convergence-tizen-tests/inst.apk.py +++ b/common/tct-convergence-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-convergence-tizen-tests/inst.wgt.py b/common/tct-convergence-tizen-tests/inst.wgt.py index 0c4e2056a..8f0296ef1 100755 --- a/common/tct-convergence-tizen-tests/inst.wgt.py +++ b/common/tct-convergence-tizen-tests/inst.wgt.py @@ -1,223 +1,223 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - - for pkg_name in ["tct-alarm-tizen-tests", "alarmTestApp"]: - pkg_id = getPKGID(pkg_name) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD("pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT,SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + + for pkg_name in ["tct-alarm-tizen-tests", "alarmTestApp"]: + pkg_id = getPKGID(pkg_name) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD("pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT,SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + 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 as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-convergence-tizen-tests/inst.xpk.py b/common/tct-convergence-tizen-tests/inst.xpk.py index c0c358ecc..34a9d92c3 100755 --- a/common/tct-convergence-tizen-tests/inst.xpk.py +++ b/common/tct-convergence-tizen-tests/inst.xpk.py @@ -1,214 +1,214 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - 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 - - 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 + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + 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 + + 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 as 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) diff --git a/common/tct-convergence-tizen-tests/pack.py b/common/tct-convergence-tizen-tests/pack.py index 08d55aafe..92866ab2e 100755 --- a/common/tct-convergence-tizen-tests/pack.py +++ b/common/tct-convergence-tizen-tests/pack.py @@ -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: diff --git a/common/tct-cors-w3c-tests/inst.apk.py b/common/tct-cors-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-cors-w3c-tests/inst.apk.py +++ b/common/tct-cors-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-cors-w3c-tests/inst.wgt.py b/common/tct-cors-w3c-tests/inst.wgt.py index 30dfea1b2..f543d1d01 100755 --- a/common/tct-cors-w3c-tests/inst.wgt.py +++ b/common/tct-cors-w3c-tests/inst.wgt.py @@ -1,239 +1,239 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - for item in glob.glob("%s/*" % SCRIPT_DIR): - if item.endswith(".wgt"): - continue - elif item.endswith("inst.py"): - continue - else: - item_name = os.path.basename(item) - if not doRemoteCopy(item, "%s/%s" % (PKG_SRC_DIR, item_name)): - #if not doRemoteCopy(item, PKG_SRC_DIR): - action_status = False - for item in glob.glob("%s/cors/support/cgi/*" % SCRIPT_DIR): - item_name = os.path.basename(item) - if not doRemoteCopy(item, "%s/cors/support/%s" % (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 = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + for item in glob.glob("%s/*" % SCRIPT_DIR): + if item.endswith(".wgt"): + continue + elif item.endswith("inst.py"): + continue + else: + item_name = os.path.basename(item) + if not doRemoteCopy(item, "%s/%s" % (PKG_SRC_DIR, item_name)): + #if not doRemoteCopy(item, PKG_SRC_DIR): + action_status = False + for item in glob.glob("%s/cors/support/cgi/*" % SCRIPT_DIR): + item_name = os.path.basename(item) + if not doRemoteCopy(item, "%s/cors/support/%s" % (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 as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-cors-w3c-tests/inst.xpk.py b/common/tct-cors-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-cors-w3c-tests/inst.xpk.py +++ b/common/tct-cors-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-cors-w3c-tests/pack.py b/common/tct-cors-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-cors-w3c-tests/pack.py +++ b/common/tct-cors-w3c-tests/pack.py @@ -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: diff --git a/common/tct-crypto-w3c-tests/inst.apk.py b/common/tct-crypto-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-crypto-w3c-tests/inst.apk.py +++ b/common/tct-crypto-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-crypto-w3c-tests/inst.wgt.py b/common/tct-crypto-w3c-tests/inst.wgt.py index d7b962bfa..0f5e3baa1 100755 --- a/common/tct-crypto-w3c-tests/inst.wgt.py +++ b/common/tct-crypto-w3c-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -189,8 +189,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: @@ -209,7 +209,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -221,10 +221,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: diff --git a/common/tct-crypto-w3c-tests/inst.xpk.py b/common/tct-crypto-w3c-tests/inst.xpk.py index a5295f0ab..a61db816d 100755 --- a/common/tct-crypto-w3c-tests/inst.xpk.py +++ b/common/tct-crypto-w3c-tests/inst.xpk.py @@ -1,228 +1,228 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -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" -SRC_DIR = "/home/app/content" -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "app" - 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 + + +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" +SRC_DIR = "/home/app/content" +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = "app" + 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) diff --git a/common/tct-crypto-w3c-tests/pack.py b/common/tct-crypto-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-crypto-w3c-tests/pack.py +++ b/common/tct-crypto-w3c-tests/pack.py @@ -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: diff --git a/common/tct-csp-w3c-tests/inst.apk.py b/common/tct-csp-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-csp-w3c-tests/inst.apk.py +++ b/common/tct-csp-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-csp-w3c-tests/inst.wgt.py b/common/tct-csp-w3c-tests/inst.wgt.py index 076b4489e..be3dfd026 100755 --- a/common/tct-csp-w3c-tests/inst.wgt.py +++ b/common/tct-csp-w3c-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -184,8 +184,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: @@ -204,7 +204,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -216,10 +216,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: diff --git a/common/tct-csp-w3c-tests/inst.xpk.py b/common/tct-csp-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-csp-w3c-tests/inst.xpk.py +++ b/common/tct-csp-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-csp-w3c-tests/pack.py b/common/tct-csp-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-csp-w3c-tests/pack.py +++ b/common/tct-csp-w3c-tests/pack.py @@ -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: diff --git a/common/tct-customelement-w3c-tests/inst.apk.py b/common/tct-customelement-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-customelement-w3c-tests/inst.apk.py +++ b/common/tct-customelement-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-customelement-w3c-tests/inst.wgt.py b/common/tct-customelement-w3c-tests/inst.wgt.py index d7b962bfa..0f5e3baa1 100755 --- a/common/tct-customelement-w3c-tests/inst.wgt.py +++ b/common/tct-customelement-w3c-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -189,8 +189,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: @@ -209,7 +209,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -221,10 +221,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: diff --git a/common/tct-customelement-w3c-tests/inst.xpk.py b/common/tct-customelement-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-customelement-w3c-tests/inst.xpk.py +++ b/common/tct-customelement-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-customelement-w3c-tests/pack.py b/common/tct-customelement-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-customelement-w3c-tests/pack.py +++ b/common/tct-customelement-w3c-tests/pack.py @@ -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: diff --git a/common/tct-datacontrol-tizen-tests/inst.apk.py b/common/tct-datacontrol-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-datacontrol-tizen-tests/inst.apk.py +++ b/common/tct-datacontrol-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-datacontrol-tizen-tests/inst.wgt.py b/common/tct-datacontrol-tizen-tests/inst.wgt.py index 919820675..c6205c048 100755 --- a/common/tct-datacontrol-tizen-tests/inst.wgt.py +++ b/common/tct-datacontrol-tizen-tests/inst.wgt.py @@ -1,222 +1,222 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + 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 as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-datacontrol-tizen-tests/inst.xpk.py b/common/tct-datacontrol-tizen-tests/inst.xpk.py index aa292c379..7dcd40d98 100755 --- a/common/tct-datacontrol-tizen-tests/inst.xpk.py +++ b/common/tct-datacontrol-tizen-tests/inst.xpk.py @@ -1,229 +1,229 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - -# for file in files: -# if file.endswith(".xpk"): -# if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): -# action_status = False -# (return_code, output) = doRemoteCMD( -# "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) -# doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) -# for line in output: -# if "Failure" in line: -# action_status = False -# break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + +# for file in files: +# if file.endswith(".xpk"): +# if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): +# action_status = False +# (return_code, output) = doRemoteCMD( +# "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) +# doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) +# for line in output: +# if "Failure" in line: +# action_status = False +# break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-datacontrol-tizen-tests/pack.py b/common/tct-datacontrol-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-datacontrol-tizen-tests/pack.py +++ b/common/tct-datacontrol-tizen-tests/pack.py @@ -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: diff --git a/common/tct-device-cordova-tests/inst.apk.py b/common/tct-device-cordova-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-device-cordova-tests/inst.apk.py +++ b/common/tct-device-cordova-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-device-cordova-tests/inst.wgt.py b/common/tct-device-cordova-tests/inst.wgt.py index 70534429f..ecdac7ff6 100755 --- a/common/tct-device-cordova-tests/inst.wgt.py +++ b/common/tct-device-cordova-tests/inst.wgt.py @@ -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 @@ -204,8 +204,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: @@ -224,7 +224,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -236,10 +236,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: diff --git a/common/tct-device-cordova-tests/inst.xpk.py b/common/tct-device-cordova-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-device-cordova-tests/inst.xpk.py +++ b/common/tct-device-cordova-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-device-cordova-tests/pack.py b/common/tct-device-cordova-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-device-cordova-tests/pack.py +++ b/common/tct-device-cordova-tests/pack.py @@ -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: diff --git a/common/tct-devicemotion-cordova-tests/inst.apk.py b/common/tct-devicemotion-cordova-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-devicemotion-cordova-tests/inst.apk.py +++ b/common/tct-devicemotion-cordova-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-devicemotion-cordova-tests/inst.wgt.py b/common/tct-devicemotion-cordova-tests/inst.wgt.py index 70534429f..ecdac7ff6 100755 --- a/common/tct-devicemotion-cordova-tests/inst.wgt.py +++ b/common/tct-devicemotion-cordova-tests/inst.wgt.py @@ -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 @@ -204,8 +204,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: @@ -224,7 +224,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -236,10 +236,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: diff --git a/common/tct-devicemotion-cordova-tests/inst.xpk.py b/common/tct-devicemotion-cordova-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-devicemotion-cordova-tests/inst.xpk.py +++ b/common/tct-devicemotion-cordova-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-devicemotion-cordova-tests/pack.py b/common/tct-devicemotion-cordova-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-devicemotion-cordova-tests/pack.py +++ b/common/tct-devicemotion-cordova-tests/pack.py @@ -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: diff --git a/common/tct-deviceorientation-w3c-tests/inst.apk.py b/common/tct-deviceorientation-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-deviceorientation-w3c-tests/inst.apk.py +++ b/common/tct-deviceorientation-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-deviceorientation-w3c-tests/inst.wgt.py b/common/tct-deviceorientation-w3c-tests/inst.wgt.py index 93ac8ad71..66eb23daa 100755 --- a/common/tct-deviceorientation-w3c-tests/inst.wgt.py +++ b/common/tct-deviceorientation-w3c-tests/inst.wgt.py @@ -1,240 +1,240 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-deviceorientation-w3c-tests/inst.xpk.py b/common/tct-deviceorientation-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-deviceorientation-w3c-tests/inst.xpk.py +++ b/common/tct-deviceorientation-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-deviceorientation-w3c-tests/pack.py b/common/tct-deviceorientation-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-deviceorientation-w3c-tests/pack.py +++ b/common/tct-deviceorientation-w3c-tests/pack.py @@ -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: diff --git a/common/tct-dialogs-cordova-tests/inst.apk.py b/common/tct-dialogs-cordova-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-dialogs-cordova-tests/inst.apk.py +++ b/common/tct-dialogs-cordova-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-dialogs-cordova-tests/inst.wgt.py b/common/tct-dialogs-cordova-tests/inst.wgt.py index 70534429f..ecdac7ff6 100755 --- a/common/tct-dialogs-cordova-tests/inst.wgt.py +++ b/common/tct-dialogs-cordova-tests/inst.wgt.py @@ -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 @@ -204,8 +204,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: @@ -224,7 +224,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -236,10 +236,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: diff --git a/common/tct-dialogs-cordova-tests/inst.xpk.py b/common/tct-dialogs-cordova-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-dialogs-cordova-tests/inst.xpk.py +++ b/common/tct-dialogs-cordova-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-dialogs-cordova-tests/pack.py b/common/tct-dialogs-cordova-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-dialogs-cordova-tests/pack.py +++ b/common/tct-dialogs-cordova-tests/pack.py @@ -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: diff --git a/common/tct-dnd-html5-tests/inst.apk.py b/common/tct-dnd-html5-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-dnd-html5-tests/inst.apk.py +++ b/common/tct-dnd-html5-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-dnd-html5-tests/inst.wgt.py b/common/tct-dnd-html5-tests/inst.wgt.py index 93ac8ad71..66eb23daa 100755 --- a/common/tct-dnd-html5-tests/inst.wgt.py +++ b/common/tct-dnd-html5-tests/inst.wgt.py @@ -1,240 +1,240 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-dnd-html5-tests/inst.xpk.py b/common/tct-dnd-html5-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-dnd-html5-tests/inst.xpk.py +++ b/common/tct-dnd-html5-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-dnd-html5-tests/pack.py b/common/tct-dnd-html5-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-dnd-html5-tests/pack.py +++ b/common/tct-dnd-html5-tests/pack.py @@ -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: diff --git a/common/tct-download-tizen-tests/Queue.pyc b/common/tct-download-tizen-tests/Queue.pyc old mode 100755 new mode 100644 index 987860d5b..f79be9619 Binary files a/common/tct-download-tizen-tests/Queue.pyc and b/common/tct-download-tizen-tests/Queue.pyc differ diff --git a/common/tct-download-tizen-tests/inst.apk.py b/common/tct-download-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-download-tizen-tests/inst.apk.py +++ b/common/tct-download-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-download-tizen-tests/inst.wgt.py b/common/tct-download-tizen-tests/inst.wgt.py index dccbfe5eb..d2daaf7c4 100755 --- a/common/tct-download-tizen-tests/inst.wgt.py +++ b/common/tct-download-tizen-tests/inst.wgt.py @@ -10,7 +10,7 @@ import string import logging import Queue from optparse import OptionParser, make_option -import ConfigParser +import configparser from shellmanager import ShellManager time.sleep(3) @@ -20,7 +20,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) @@ -43,23 +43,23 @@ 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() 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 @@ -216,8 +216,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: @@ -236,26 +236,23 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() - print "1" getInternalStorage() - print "2" - user_info = getUSERID() - print "3" + 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]) + 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: diff --git a/common/tct-download-tizen-tests/inst.xpk.py b/common/tct-download-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-download-tizen-tests/inst.xpk.py +++ b/common/tct-download-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-download-tizen-tests/pack.py b/common/tct-download-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-download-tizen-tests/pack.py +++ b/common/tct-download-tizen-tests/pack.py @@ -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: diff --git a/common/tct-download-tizen-tests/shellmanager.pyc b/common/tct-download-tizen-tests/shellmanager.pyc old mode 100755 new mode 100644 index 7fd529693..68af55f8b Binary files a/common/tct-download-tizen-tests/shellmanager.pyc and b/common/tct-download-tizen-tests/shellmanager.pyc differ diff --git a/common/tct-events-cordova-tests/inst.apk.py b/common/tct-events-cordova-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-events-cordova-tests/inst.apk.py +++ b/common/tct-events-cordova-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-events-cordova-tests/inst.wgt.py b/common/tct-events-cordova-tests/inst.wgt.py index 28b1eb42a..7db68dc05 100755 --- a/common/tct-events-cordova-tests/inst.wgt.py +++ b/common/tct-events-cordova-tests/inst.wgt.py @@ -1,224 +1,224 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t wgt -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("%s.wgt" % PKG_NAME): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t wgt -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(".wgt"): - continue - elif item.endswith("inst.py"): - continue - else: - item_name = os.path.basename(item) - if not doRemoteCopy(item, "%s/%s" % (PKG_SRC_DIR, item_name)): - 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 + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t wgt -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("%s.wgt" % PKG_NAME): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t wgt -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(".wgt"): + continue + elif item.endswith("inst.py"): + continue + else: + item_name = os.path.basename(item) + if not doRemoteCopy(item, "%s/%s" % (PKG_SRC_DIR, item_name)): + 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 as 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) diff --git a/common/tct-events-cordova-tests/inst.xpk.py b/common/tct-events-cordova-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-events-cordova-tests/inst.xpk.py +++ b/common/tct-events-cordova-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-events-cordova-tests/pack.py b/common/tct-events-cordova-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-events-cordova-tests/pack.py +++ b/common/tct-events-cordova-tests/pack.py @@ -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: diff --git a/common/tct-exif-tizen-tests/inst.apk.py b/common/tct-exif-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-exif-tizen-tests/inst.apk.py +++ b/common/tct-exif-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-exif-tizen-tests/inst.wgt.py b/common/tct-exif-tizen-tests/inst.wgt.py index d45898649..770b31307 100755 --- a/common/tct-exif-tizen-tests/inst.wgt.py +++ b/common/tct-exif-tizen-tests/inst.wgt.py @@ -1,232 +1,232 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - (return_code, output) = doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, PKG_NAME)) - 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(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - if not doRemoteCopy("%s/media" % SCRIPT_DIR, "%s/%s" % (SRC_DIR, PKG_NAME)): - action_status = False - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + (return_code, output) = doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, PKG_NAME)) + 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(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + if not doRemoteCopy("%s/media" % SCRIPT_DIR, "%s/%s" % (SRC_DIR, PKG_NAME)): + 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 as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-exif-tizen-tests/inst.xpk.py b/common/tct-exif-tizen-tests/inst.xpk.py index c3b031d9a..1d0aba4a0 100755 --- a/common/tct-exif-tizen-tests/inst.xpk.py +++ b/common/tct-exif-tizen-tests/inst.xpk.py @@ -1,221 +1,221 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - 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_code, output) = doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, PKG_NAME)) - 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 - - if not doRemoteCopy("%s/media" % SCRIPT_DIR, "%s/%s" % (SRC_DIR, PKG_NAME)): - 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 + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + 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_code, output) = doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, PKG_NAME)) + 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 + + if not doRemoteCopy("%s/media" % SCRIPT_DIR, "%s/%s" % (SRC_DIR, PKG_NAME)): + 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 as 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) diff --git a/common/tct-exif-tizen-tests/pack.py b/common/tct-exif-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-exif-tizen-tests/pack.py +++ b/common/tct-exif-tizen-tests/pack.py @@ -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: diff --git a/common/tct-extra-html5-tests/inst.apk.py b/common/tct-extra-html5-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-extra-html5-tests/inst.apk.py +++ b/common/tct-extra-html5-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-extra-html5-tests/inst.wgt.py b/common/tct-extra-html5-tests/inst.wgt.py index 8ed577c13..21f138a35 100755 --- a/common/tct-extra-html5-tests/inst.wgt.py +++ b/common/tct-extra-html5-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -189,8 +189,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: @@ -209,7 +209,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -221,10 +221,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: diff --git a/common/tct-extra-html5-tests/inst.xpk.py b/common/tct-extra-html5-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-extra-html5-tests/inst.xpk.py +++ b/common/tct-extra-html5-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-extra-html5-tests/pack.py b/common/tct-extra-html5-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-extra-html5-tests/pack.py +++ b/common/tct-extra-html5-tests/pack.py @@ -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: diff --git a/common/tct-feedback-tizen-tests/inst.apk.py b/common/tct-feedback-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-feedback-tizen-tests/inst.apk.py +++ b/common/tct-feedback-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-feedback-tizen-tests/inst.wgt.py b/common/tct-feedback-tizen-tests/inst.wgt.py index 8ed577c13..21f138a35 100755 --- a/common/tct-feedback-tizen-tests/inst.wgt.py +++ b/common/tct-feedback-tizen-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -189,8 +189,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: @@ -209,7 +209,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -221,10 +221,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: diff --git a/common/tct-feedback-tizen-tests/inst.xpk.py b/common/tct-feedback-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-feedback-tizen-tests/inst.xpk.py +++ b/common/tct-feedback-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-feedback-tizen-tests/pack.py b/common/tct-feedback-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-feedback-tizen-tests/pack.py +++ b/common/tct-feedback-tizen-tests/pack.py @@ -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: diff --git a/common/tct-file-cordova-tests/inst.apk.py b/common/tct-file-cordova-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-file-cordova-tests/inst.apk.py +++ b/common/tct-file-cordova-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-file-cordova-tests/inst.wgt.py b/common/tct-file-cordova-tests/inst.wgt.py index 70534429f..ecdac7ff6 100755 --- a/common/tct-file-cordova-tests/inst.wgt.py +++ b/common/tct-file-cordova-tests/inst.wgt.py @@ -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 @@ -204,8 +204,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: @@ -224,7 +224,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -236,10 +236,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: diff --git a/common/tct-file-cordova-tests/inst.xpk.py b/common/tct-file-cordova-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-file-cordova-tests/inst.xpk.py +++ b/common/tct-file-cordova-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-file-cordova-tests/pack.py b/common/tct-file-cordova-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-file-cordova-tests/pack.py +++ b/common/tct-file-cordova-tests/pack.py @@ -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: diff --git a/common/tct-file-transfer-cordova-tests/inst.apk.py b/common/tct-file-transfer-cordova-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-file-transfer-cordova-tests/inst.apk.py +++ b/common/tct-file-transfer-cordova-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-file-transfer-cordova-tests/inst.wgt.py b/common/tct-file-transfer-cordova-tests/inst.wgt.py index 4bcbd777f..659267fd6 100755 --- a/common/tct-file-transfer-cordova-tests/inst.wgt.py +++ b/common/tct-file-transfer-cordova-tests/inst.wgt.py @@ -1,259 +1,259 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def askpolicyremoving(): - for root, dirs, files in os.walk(SCRIPT_DIR): - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - - 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)): - action_status = False - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell .%s/askpolicy.sh %s" % (PARAMETERS.device, - SRC_DIR, pkg_id) - return doCMD(cmd) - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - (return_code, output) = doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, PKG_NAME)) - 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("%s.wgt" % PKG_NAME): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - for item in glob.glob("%s/*" % SCRIPT_DIR): - if item.endswith(".wgt"): - continue - elif item.endswith("inst.py"): - continue - else: - item_name = os.path.basename(item) - if not doRemoteCopy(item, "%s/%s" % (PKG_SRC_DIR, item_name)): - action_status = False - - if not doRemoteCopy("%s/file-transfer" % SCRIPT_DIR, "%s/%s" % (SRC_DIR, PKG_NAME)): - action_status = False - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - #askpolicyremoving() - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def askpolicyremoving(): + for root, dirs, files in os.walk(SCRIPT_DIR): + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + + 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)): + action_status = False + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell .%s/askpolicy.sh %s" % (PARAMETERS.device, + SRC_DIR, pkg_id) + return doCMD(cmd) + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + (return_code, output) = doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, PKG_NAME)) + 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("%s.wgt" % PKG_NAME): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + for item in glob.glob("%s/*" % SCRIPT_DIR): + if item.endswith(".wgt"): + continue + elif item.endswith("inst.py"): + continue + else: + item_name = os.path.basename(item) + if not doRemoteCopy(item, "%s/%s" % (PKG_SRC_DIR, item_name)): + action_status = False + + if not doRemoteCopy("%s/file-transfer" % SCRIPT_DIR, "%s/%s" % (SRC_DIR, PKG_NAME)): + 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 as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + #askpolicyremoving() + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-file-transfer-cordova-tests/inst.xpk.py b/common/tct-file-transfer-cordova-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-file-transfer-cordova-tests/inst.xpk.py +++ b/common/tct-file-transfer-cordova-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-file-transfer-cordova-tests/pack.py b/common/tct-file-transfer-cordova-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-file-transfer-cordova-tests/pack.py +++ b/common/tct-file-transfer-cordova-tests/pack.py @@ -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: diff --git a/common/tct-fileapi-w3c-tests/inst.apk.py b/common/tct-fileapi-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-fileapi-w3c-tests/inst.apk.py +++ b/common/tct-fileapi-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-fileapi-w3c-tests/inst.wgt.py b/common/tct-fileapi-w3c-tests/inst.wgt.py index 84a331b62..275a9362d 100755 --- a/common/tct-fileapi-w3c-tests/inst.wgt.py +++ b/common/tct-fileapi-w3c-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -189,8 +189,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: @@ -209,7 +209,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -221,10 +221,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: diff --git a/common/tct-fileapi-w3c-tests/inst.xpk.py b/common/tct-fileapi-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-fileapi-w3c-tests/inst.xpk.py +++ b/common/tct-fileapi-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-fileapi-w3c-tests/pack.py b/common/tct-fileapi-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-fileapi-w3c-tests/pack.py +++ b/common/tct-fileapi-w3c-tests/pack.py @@ -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: diff --git a/common/tct-filesystem-tizen-tests/inst.apk.py b/common/tct-filesystem-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-filesystem-tizen-tests/inst.apk.py +++ b/common/tct-filesystem-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-filesystem-tizen-tests/inst.wgt.py b/common/tct-filesystem-tizen-tests/inst.wgt.py index 44e57cf17..5322534da 100755 --- a/common/tct-filesystem-tizen-tests/inst.wgt.py +++ b/common/tct-filesystem-tizen-tests/inst.wgt.py @@ -1,241 +1,241 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-filesystem-tizen-tests/inst.xpk.py b/common/tct-filesystem-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-filesystem-tizen-tests/inst.xpk.py +++ b/common/tct-filesystem-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-filesystem-tizen-tests/pack.py b/common/tct-filesystem-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-filesystem-tizen-tests/pack.py +++ b/common/tct-filesystem-tizen-tests/pack.py @@ -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: diff --git a/common/tct-flexiblebox-css3-tests/inst.apk.py b/common/tct-flexiblebox-css3-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-flexiblebox-css3-tests/inst.apk.py +++ b/common/tct-flexiblebox-css3-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-flexiblebox-css3-tests/inst.wgt.py b/common/tct-flexiblebox-css3-tests/inst.wgt.py index 93ac8ad71..66eb23daa 100755 --- a/common/tct-flexiblebox-css3-tests/inst.wgt.py +++ b/common/tct-flexiblebox-css3-tests/inst.wgt.py @@ -1,240 +1,240 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-flexiblebox-css3-tests/inst.xpk.py b/common/tct-flexiblebox-css3-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-flexiblebox-css3-tests/inst.xpk.py +++ b/common/tct-flexiblebox-css3-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-flexiblebox-css3-tests/pack.py b/common/tct-flexiblebox-css3-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-flexiblebox-css3-tests/pack.py +++ b/common/tct-flexiblebox-css3-tests/pack.py @@ -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: diff --git a/common/tct-fmradio-tizen-tests/inst.apk.py b/common/tct-fmradio-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-fmradio-tizen-tests/inst.apk.py +++ b/common/tct-fmradio-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-fmradio-tizen-tests/inst.wgt.py b/common/tct-fmradio-tizen-tests/inst.wgt.py index dc5e8b8b3..8b5d2f8a8 100755 --- a/common/tct-fmradio-tizen-tests/inst.wgt.py +++ b/common/tct-fmradio-tizen-tests/inst.wgt.py @@ -1,239 +1,239 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-fmradio-tizen-tests/inst.xpk.py b/common/tct-fmradio-tizen-tests/inst.xpk.py index aa292c379..7dcd40d98 100755 --- a/common/tct-fmradio-tizen-tests/inst.xpk.py +++ b/common/tct-fmradio-tizen-tests/inst.xpk.py @@ -1,229 +1,229 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - -# for file in files: -# if file.endswith(".xpk"): -# if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): -# action_status = False -# (return_code, output) = doRemoteCMD( -# "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) -# doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) -# for line in output: -# if "Failure" in line: -# action_status = False -# break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + +# for file in files: +# if file.endswith(".xpk"): +# if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): +# action_status = False +# (return_code, output) = doRemoteCMD( +# "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) +# doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) +# for line in output: +# if "Failure" in line: +# action_status = False +# break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-fmradio-tizen-tests/pack.py b/common/tct-fmradio-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-fmradio-tizen-tests/pack.py +++ b/common/tct-fmradio-tizen-tests/pack.py @@ -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: diff --git a/common/tct-fonts-css3-tests/inst.apk.py b/common/tct-fonts-css3-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-fonts-css3-tests/inst.apk.py +++ b/common/tct-fonts-css3-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-fonts-css3-tests/inst.wgt.py b/common/tct-fonts-css3-tests/inst.wgt.py index 122ddbf63..795d087c4 100755 --- a/common/tct-fonts-css3-tests/inst.wgt.py +++ b/common/tct-fonts-css3-tests/inst.wgt.py @@ -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) @@ -34,14 +34,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -210,8 +210,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: @@ -230,7 +230,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -242,10 +242,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: diff --git a/common/tct-fonts-css3-tests/inst.xpk.py b/common/tct-fonts-css3-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-fonts-css3-tests/inst.xpk.py +++ b/common/tct-fonts-css3-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-fonts-css3-tests/pack.py b/common/tct-fonts-css3-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-fonts-css3-tests/pack.py +++ b/common/tct-fonts-css3-tests/pack.py @@ -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: diff --git a/common/tct-forms-html5-tests/inst.apk.py b/common/tct-forms-html5-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-forms-html5-tests/inst.apk.py +++ b/common/tct-forms-html5-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-forms-html5-tests/inst.wgt.py b/common/tct-forms-html5-tests/inst.wgt.py index 93ac8ad71..66eb23daa 100755 --- a/common/tct-forms-html5-tests/inst.wgt.py +++ b/common/tct-forms-html5-tests/inst.wgt.py @@ -1,240 +1,240 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-forms-html5-tests/inst.xpk.py b/common/tct-forms-html5-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-forms-html5-tests/inst.xpk.py +++ b/common/tct-forms-html5-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-forms-html5-tests/pack.py b/common/tct-forms-html5-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-forms-html5-tests/pack.py +++ b/common/tct-forms-html5-tests/pack.py @@ -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: diff --git a/common/tct-fullscreen-nonw3c-tests/inst.apk.py b/common/tct-fullscreen-nonw3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-fullscreen-nonw3c-tests/inst.apk.py +++ b/common/tct-fullscreen-nonw3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-fullscreen-nonw3c-tests/inst.wgt.py b/common/tct-fullscreen-nonw3c-tests/inst.wgt.py index d7b962bfa..0f5e3baa1 100755 --- a/common/tct-fullscreen-nonw3c-tests/inst.wgt.py +++ b/common/tct-fullscreen-nonw3c-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -189,8 +189,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: @@ -209,7 +209,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -221,10 +221,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: diff --git a/common/tct-fullscreen-nonw3c-tests/inst.xpk.py b/common/tct-fullscreen-nonw3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-fullscreen-nonw3c-tests/inst.xpk.py +++ b/common/tct-fullscreen-nonw3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-fullscreen-nonw3c-tests/pack.py b/common/tct-fullscreen-nonw3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-fullscreen-nonw3c-tests/pack.py +++ b/common/tct-fullscreen-nonw3c-tests/pack.py @@ -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: diff --git a/common/tct-geoallow-w3c-tests/inst.apk.py b/common/tct-geoallow-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-geoallow-w3c-tests/inst.apk.py +++ b/common/tct-geoallow-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-geoallow-w3c-tests/inst.wgt.py b/common/tct-geoallow-w3c-tests/inst.wgt.py index d4fcbeb70..e210b7d43 100755 --- a/common/tct-geoallow-w3c-tests/inst.wgt.py +++ b/common/tct-geoallow-w3c-tests/inst.wgt.py @@ -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 @@ -205,8 +205,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: @@ -225,7 +225,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -237,10 +237,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: diff --git a/common/tct-geoallow-w3c-tests/inst.xpk.py b/common/tct-geoallow-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-geoallow-w3c-tests/inst.xpk.py +++ b/common/tct-geoallow-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-geoallow-w3c-tests/pack.py b/common/tct-geoallow-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-geoallow-w3c-tests/pack.py +++ b/common/tct-geoallow-w3c-tests/pack.py @@ -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: diff --git a/common/tct-geodeny-w3c-tests/inst.apk.py b/common/tct-geodeny-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-geodeny-w3c-tests/inst.apk.py +++ b/common/tct-geodeny-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-geodeny-w3c-tests/inst.wgt.py b/common/tct-geodeny-w3c-tests/inst.wgt.py index d4fcbeb70..e210b7d43 100755 --- a/common/tct-geodeny-w3c-tests/inst.wgt.py +++ b/common/tct-geodeny-w3c-tests/inst.wgt.py @@ -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 @@ -205,8 +205,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: @@ -225,7 +225,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -237,10 +237,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: diff --git a/common/tct-geodeny-w3c-tests/inst.xpk.py b/common/tct-geodeny-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-geodeny-w3c-tests/inst.xpk.py +++ b/common/tct-geodeny-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-geodeny-w3c-tests/pack.py b/common/tct-geodeny-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-geodeny-w3c-tests/pack.py +++ b/common/tct-geodeny-w3c-tests/pack.py @@ -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: diff --git a/common/tct-globalization-cordova-tests/inst.apk.py b/common/tct-globalization-cordova-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-globalization-cordova-tests/inst.apk.py +++ b/common/tct-globalization-cordova-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-globalization-cordova-tests/inst.wgt.py b/common/tct-globalization-cordova-tests/inst.wgt.py index 1f51fd5ad..9604b1805 100755 --- a/common/tct-globalization-cordova-tests/inst.wgt.py +++ b/common/tct-globalization-cordova-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -182,8 +182,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: @@ -202,7 +202,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -214,10 +214,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: diff --git a/common/tct-globalization-cordova-tests/inst.xpk.py b/common/tct-globalization-cordova-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-globalization-cordova-tests/inst.xpk.py +++ b/common/tct-globalization-cordova-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-globalization-cordova-tests/pack.py b/common/tct-globalization-cordova-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-globalization-cordova-tests/pack.py +++ b/common/tct-globalization-cordova-tests/pack.py @@ -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: diff --git a/common/tct-gumallow-w3c-tests/inst.apk.py b/common/tct-gumallow-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-gumallow-w3c-tests/inst.apk.py +++ b/common/tct-gumallow-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-gumallow-w3c-tests/inst.wgt.py b/common/tct-gumallow-w3c-tests/inst.wgt.py index d4fcbeb70..e210b7d43 100755 --- a/common/tct-gumallow-w3c-tests/inst.wgt.py +++ b/common/tct-gumallow-w3c-tests/inst.wgt.py @@ -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 @@ -205,8 +205,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: @@ -225,7 +225,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -237,10 +237,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: diff --git a/common/tct-gumallow-w3c-tests/inst.xpk.py b/common/tct-gumallow-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-gumallow-w3c-tests/inst.xpk.py +++ b/common/tct-gumallow-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-gumallow-w3c-tests/pack.py b/common/tct-gumallow-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-gumallow-w3c-tests/pack.py +++ b/common/tct-gumallow-w3c-tests/pack.py @@ -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: diff --git a/common/tct-humanactivitymonitor-tizen-tests/inst.apk.py b/common/tct-humanactivitymonitor-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-humanactivitymonitor-tizen-tests/inst.apk.py +++ b/common/tct-humanactivitymonitor-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-humanactivitymonitor-tizen-tests/inst.wgt.py b/common/tct-humanactivitymonitor-tizen-tests/inst.wgt.py index 851f32dae..fd32138f1 100755 --- a/common/tct-humanactivitymonitor-tizen-tests/inst.wgt.py +++ b/common/tct-humanactivitymonitor-tizen-tests/inst.wgt.py @@ -1,259 +1,259 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def askpolicyremoving(): - for root, dirs, files in os.walk(SCRIPT_DIR): - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - - 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)): - action_status = False - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell .%s/askpolicy.sh %s" % (PARAMETERS.device, - SRC_DIR, pkg_id) - return doCMD(cmd) - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - #askpolicyremoving() - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def askpolicyremoving(): + for root, dirs, files in os.walk(SCRIPT_DIR): + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + + 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)): + action_status = False + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell .%s/askpolicy.sh %s" % (PARAMETERS.device, + SRC_DIR, pkg_id) + return doCMD(cmd) + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + #askpolicyremoving() + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-humanactivitymonitor-tizen-tests/inst.xpk.py b/common/tct-humanactivitymonitor-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-humanactivitymonitor-tizen-tests/inst.xpk.py +++ b/common/tct-humanactivitymonitor-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-humanactivitymonitor-tizen-tests/pack.py b/common/tct-humanactivitymonitor-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-humanactivitymonitor-tizen-tests/pack.py +++ b/common/tct-humanactivitymonitor-tizen-tests/pack.py @@ -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: diff --git a/common/tct-ime-tizen-tests/inst.apk.py b/common/tct-ime-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-ime-tizen-tests/inst.apk.py +++ b/common/tct-ime-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-ime-tizen-tests/inst.wgt.py b/common/tct-ime-tizen-tests/inst.wgt.py index 10347d27d..5edd24343 100755 --- a/common/tct-ime-tizen-tests/inst.wgt.py +++ b/common/tct-ime-tizen-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -186,8 +186,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: @@ -206,7 +206,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -218,10 +218,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: diff --git a/common/tct-ime-tizen-tests/inst.xpk.py b/common/tct-ime-tizen-tests/inst.xpk.py index c904d861a..bfed062d7 100755 --- a/common/tct-ime-tizen-tests/inst.xpk.py +++ b/common/tct-ime-tizen-tests/inst.xpk.py @@ -1,236 +1,236 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - 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_code, output) = doRemoteCMD("rm -rf %s/Images" % SRC_DIR) - if return_code != 0: - action_status = False - - (return_code, output) = doRemoteCMD("rm -rf %s/Sounds" % 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 - - (return_code, output) = doRemoteCMD("mkdir -p %s/Images" % SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("%s/*.jpg" % SCRIPT_DIR, "%s/Images" % SRC_DIR): - action_status = False - - (return_code, output) = doRemoteCMD("mkdir -p %s/Sounds" % SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("%s/*.mp3" % SCRIPT_DIR, "%s/Sounds" % 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 + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + 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_code, output) = doRemoteCMD("rm -rf %s/Images" % SRC_DIR) + if return_code != 0: + action_status = False + + (return_code, output) = doRemoteCMD("rm -rf %s/Sounds" % 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 + + (return_code, output) = doRemoteCMD("mkdir -p %s/Images" % SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("%s/*.jpg" % SCRIPT_DIR, "%s/Images" % SRC_DIR): + action_status = False + + (return_code, output) = doRemoteCMD("mkdir -p %s/Sounds" % SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("%s/*.mp3" % SCRIPT_DIR, "%s/Sounds" % 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 as 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) diff --git a/common/tct-ime-tizen-tests/pack.py b/common/tct-ime-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-ime-tizen-tests/pack.py +++ b/common/tct-ime-tizen-tests/pack.py @@ -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: diff --git a/common/tct-indexeddb-w3c-tests/inst.apk.py b/common/tct-indexeddb-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-indexeddb-w3c-tests/inst.apk.py +++ b/common/tct-indexeddb-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-indexeddb-w3c-tests/inst.wgt.py b/common/tct-indexeddb-w3c-tests/inst.wgt.py index 93ac8ad71..66eb23daa 100755 --- a/common/tct-indexeddb-w3c-tests/inst.wgt.py +++ b/common/tct-indexeddb-w3c-tests/inst.wgt.py @@ -1,240 +1,240 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-indexeddb-w3c-tests/inst.xpk.py b/common/tct-indexeddb-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-indexeddb-w3c-tests/inst.xpk.py +++ b/common/tct-indexeddb-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-indexeddb-w3c-tests/pack.py b/common/tct-indexeddb-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-indexeddb-w3c-tests/pack.py +++ b/common/tct-indexeddb-w3c-tests/pack.py @@ -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: diff --git a/common/tct-inputdevice-tizen-tests/inst.apk.py b/common/tct-inputdevice-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-inputdevice-tizen-tests/inst.apk.py +++ b/common/tct-inputdevice-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-inputdevice-tizen-tests/inst.wgt.py b/common/tct-inputdevice-tizen-tests/inst.wgt.py index 93ac8ad71..66eb23daa 100755 --- a/common/tct-inputdevice-tizen-tests/inst.wgt.py +++ b/common/tct-inputdevice-tizen-tests/inst.wgt.py @@ -1,240 +1,240 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-inputdevice-tizen-tests/inst.xpk.py b/common/tct-inputdevice-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-inputdevice-tizen-tests/inst.xpk.py +++ b/common/tct-inputdevice-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-inputdevice-tizen-tests/pack.py b/common/tct-inputdevice-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-inputdevice-tizen-tests/pack.py +++ b/common/tct-inputdevice-tizen-tests/pack.py @@ -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: diff --git a/common/tct-iotcon-tizen-tests/inst.apk.py b/common/tct-iotcon-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-iotcon-tizen-tests/inst.apk.py +++ b/common/tct-iotcon-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-iotcon-tizen-tests/inst.wgt.py b/common/tct-iotcon-tizen-tests/inst.wgt.py index 2a5d8ad03..76475d82b 100755 --- a/common/tct-iotcon-tizen-tests/inst.wgt.py +++ b/common/tct-iotcon-tizen-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -192,8 +192,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: @@ -212,7 +212,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -224,10 +224,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: diff --git a/common/tct-iotcon-tizen-tests/inst.xpk.py b/common/tct-iotcon-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-iotcon-tizen-tests/inst.xpk.py +++ b/common/tct-iotcon-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-iotcon-tizen-tests/pack.py b/common/tct-iotcon-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-iotcon-tizen-tests/pack.py +++ b/common/tct-iotcon-tizen-tests/pack.py @@ -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: diff --git a/common/tct-jsenhance-html5-tests/inst.apk.py b/common/tct-jsenhance-html5-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-jsenhance-html5-tests/inst.apk.py +++ b/common/tct-jsenhance-html5-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-jsenhance-html5-tests/inst.wgt.py b/common/tct-jsenhance-html5-tests/inst.wgt.py index 93ac8ad71..66eb23daa 100755 --- a/common/tct-jsenhance-html5-tests/inst.wgt.py +++ b/common/tct-jsenhance-html5-tests/inst.wgt.py @@ -1,240 +1,240 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-jsenhance-html5-tests/inst.xpk.py b/common/tct-jsenhance-html5-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-jsenhance-html5-tests/inst.xpk.py +++ b/common/tct-jsenhance-html5-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-jsenhance-html5-tests/pack.py b/common/tct-jsenhance-html5-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-jsenhance-html5-tests/pack.py +++ b/common/tct-jsenhance-html5-tests/pack.py @@ -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: diff --git a/common/tct-keymanager-tizen-tests/inst.apk.py b/common/tct-keymanager-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-keymanager-tizen-tests/inst.apk.py +++ b/common/tct-keymanager-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-keymanager-tizen-tests/inst.wgt.py b/common/tct-keymanager-tizen-tests/inst.wgt.py index dff1eedb2..4a54d50a3 100755 --- a/common/tct-keymanager-tizen-tests/inst.wgt.py +++ b/common/tct-keymanager-tizen-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -187,8 +187,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: @@ -207,7 +207,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -219,10 +219,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: diff --git a/common/tct-keymanager-tizen-tests/inst.xpk.py b/common/tct-keymanager-tizen-tests/inst.xpk.py index bfad76c33..c176aacec 100755 --- a/common/tct-keymanager-tizen-tests/inst.xpk.py +++ b/common/tct-keymanager-tizen-tests/inst.xpk.py @@ -1,226 +1,226 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -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" -SRC_DIR = "/home/app/content" -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - (return_code, output) = doRemoteCMD( - "rm -rf %s/Others" % SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - if not doRemoteCopy(os.path.join(SCRIPT_DIR, "mediasrc"), "%s/Others" % 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 = "app" - 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 + + +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" +SRC_DIR = "/home/app/content" +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + (return_code, output) = doRemoteCMD( + "rm -rf %s/Others" % SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + if not doRemoteCopy(os.path.join(SCRIPT_DIR, "mediasrc"), "%s/Others" % 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 as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = "app" + 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) diff --git a/common/tct-keymanager-tizen-tests/pack.py b/common/tct-keymanager-tizen-tests/pack.py index 08d55aafe..92866ab2e 100755 --- a/common/tct-keymanager-tizen-tests/pack.py +++ b/common/tct-keymanager-tizen-tests/pack.py @@ -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: diff --git a/common/tct-media-cordova-tests/inst.apk.py b/common/tct-media-cordova-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-media-cordova-tests/inst.apk.py +++ b/common/tct-media-cordova-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-media-cordova-tests/inst.wgt.py b/common/tct-media-cordova-tests/inst.wgt.py index 36c333276..dab477869 100755 --- a/common/tct-media-cordova-tests/inst.wgt.py +++ b/common/tct-media-cordova-tests/inst.wgt.py @@ -1,261 +1,261 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def askpolicyremoving(): - for root, dirs, files in os.walk(SCRIPT_DIR): - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - - 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)): - action_status = False - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell .%s/askpolicy.sh %s" % (PARAMETERS.device, - SRC_DIR, pkg_id) - return doCMD(cmd) - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -q -u -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - (return_code, output) = doRemoteCMD( - "rm -rf %s/Downloads" % 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("%s.wgt" % PKG_NAME): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - for item in glob.glob("%s/*" % SCRIPT_DIR): - if item.endswith(".wgt"): - continue - elif item.endswith("inst.py"): - continue - else: - item_name = os.path.basename(item) - if not doRemoteCopy(item, "%s/%s" % (PKG_SRC_DIR, item_name)): - action_status = False - - # Do some special copy/delete... steps - if not doRemoteCopy(os.path.join(SCRIPT_DIR, "/media/support/tct-media-cordova-tests_audio.mp3"), "%s/Downloads" % SRC_DIR): - action_status = False - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - #askpolicyremoving() - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def askpolicyremoving(): + for root, dirs, files in os.walk(SCRIPT_DIR): + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + + 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)): + action_status = False + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell .%s/askpolicy.sh %s" % (PARAMETERS.device, + SRC_DIR, pkg_id) + return doCMD(cmd) + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -q -u -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + (return_code, output) = doRemoteCMD( + "rm -rf %s/Downloads" % 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("%s.wgt" % PKG_NAME): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + for item in glob.glob("%s/*" % SCRIPT_DIR): + if item.endswith(".wgt"): + continue + elif item.endswith("inst.py"): + continue + else: + item_name = os.path.basename(item) + if not doRemoteCopy(item, "%s/%s" % (PKG_SRC_DIR, item_name)): + action_status = False + + # Do some special copy/delete... steps + if not doRemoteCopy(os.path.join(SCRIPT_DIR, "/media/support/tct-media-cordova-tests_audio.mp3"), "%s/Downloads" % 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 as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + #askpolicyremoving() + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-media-cordova-tests/inst.xpk.py b/common/tct-media-cordova-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-media-cordova-tests/inst.xpk.py +++ b/common/tct-media-cordova-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-media-cordova-tests/pack.py b/common/tct-media-cordova-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-media-cordova-tests/pack.py +++ b/common/tct-media-cordova-tests/pack.py @@ -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: diff --git a/common/tct-mediacapture-w3c-tests/inst.apk.py b/common/tct-mediacapture-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-mediacapture-w3c-tests/inst.apk.py +++ b/common/tct-mediacapture-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-mediacapture-w3c-tests/inst.wgt.py b/common/tct-mediacapture-w3c-tests/inst.wgt.py index 93ac8ad71..66eb23daa 100755 --- a/common/tct-mediacapture-w3c-tests/inst.wgt.py +++ b/common/tct-mediacapture-w3c-tests/inst.wgt.py @@ -1,240 +1,240 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-mediacapture-w3c-tests/inst.xpk.py b/common/tct-mediacapture-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-mediacapture-w3c-tests/inst.xpk.py +++ b/common/tct-mediacapture-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-mediacapture-w3c-tests/pack.py b/common/tct-mediacapture-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-mediacapture-w3c-tests/pack.py +++ b/common/tct-mediacapture-w3c-tests/pack.py @@ -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: diff --git a/common/tct-mediacontroller-tizen-tests/inst.apk.py b/common/tct-mediacontroller-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-mediacontroller-tizen-tests/inst.apk.py +++ b/common/tct-mediacontroller-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-mediacontroller-tizen-tests/inst.wgt.py b/common/tct-mediacontroller-tizen-tests/inst.wgt.py index f35c72947..1d9d1c8dd 100755 --- a/common/tct-mediacontroller-tizen-tests/inst.wgt.py +++ b/common/tct-mediacontroller-tizen-tests/inst.wgt.py @@ -1,233 +1,233 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - for item in glob.glob("%s/*" % SCRIPT_DIR): - if item.endswith("inst.py"): - continue - else: - item_name = os.path.basename(item) - if not doRemoteCopy(item, "%s/%s" % (PKG_SRC_DIR, item_name)): - action_status = False - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + for item in glob.glob("%s/*" % SCRIPT_DIR): + if item.endswith("inst.py"): + continue + else: + item_name = os.path.basename(item) + if not doRemoteCopy(item, "%s/%s" % (PKG_SRC_DIR, item_name)): + 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 as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-mediacontroller-tizen-tests/inst.xpk.py b/common/tct-mediacontroller-tizen-tests/inst.xpk.py index aa292c379..7dcd40d98 100755 --- a/common/tct-mediacontroller-tizen-tests/inst.xpk.py +++ b/common/tct-mediacontroller-tizen-tests/inst.xpk.py @@ -1,229 +1,229 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - -# for file in files: -# if file.endswith(".xpk"): -# if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): -# action_status = False -# (return_code, output) = doRemoteCMD( -# "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) -# doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) -# for line in output: -# if "Failure" in line: -# action_status = False -# break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + +# for file in files: +# if file.endswith(".xpk"): +# if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): +# action_status = False +# (return_code, output) = doRemoteCMD( +# "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) +# doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) +# for line in output: +# if "Failure" in line: +# action_status = False +# break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-mediacontroller-tizen-tests/pack.py b/common/tct-mediacontroller-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-mediacontroller-tizen-tests/pack.py +++ b/common/tct-mediacontroller-tizen-tests/pack.py @@ -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: diff --git a/common/tct-mediakey-tizen-tests/inst.apk.py b/common/tct-mediakey-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-mediakey-tizen-tests/inst.apk.py +++ b/common/tct-mediakey-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-mediakey-tizen-tests/inst.wgt.py b/common/tct-mediakey-tizen-tests/inst.wgt.py index 44e57cf17..5322534da 100755 --- a/common/tct-mediakey-tizen-tests/inst.wgt.py +++ b/common/tct-mediakey-tizen-tests/inst.wgt.py @@ -1,241 +1,241 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-mediakey-tizen-tests/inst.xpk.py b/common/tct-mediakey-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-mediakey-tizen-tests/inst.xpk.py +++ b/common/tct-mediakey-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-mediakey-tizen-tests/pack.py b/common/tct-mediakey-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-mediakey-tizen-tests/pack.py +++ b/common/tct-mediakey-tizen-tests/pack.py @@ -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: diff --git a/common/tct-mediaqueries-css3-tests/inst.apk.py b/common/tct-mediaqueries-css3-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-mediaqueries-css3-tests/inst.apk.py +++ b/common/tct-mediaqueries-css3-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-mediaqueries-css3-tests/inst.wgt.py b/common/tct-mediaqueries-css3-tests/inst.wgt.py index 93ac8ad71..66eb23daa 100755 --- a/common/tct-mediaqueries-css3-tests/inst.wgt.py +++ b/common/tct-mediaqueries-css3-tests/inst.wgt.py @@ -1,240 +1,240 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-mediaqueries-css3-tests/inst.xpk.py b/common/tct-mediaqueries-css3-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-mediaqueries-css3-tests/inst.xpk.py +++ b/common/tct-mediaqueries-css3-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-mediaqueries-css3-tests/pack.py b/common/tct-mediaqueries-css3-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-mediaqueries-css3-tests/pack.py +++ b/common/tct-mediaqueries-css3-tests/pack.py @@ -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: diff --git a/common/tct-messageport-tizen-tests/inst.apk.py b/common/tct-messageport-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-messageport-tizen-tests/inst.apk.py +++ b/common/tct-messageport-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-messageport-tizen-tests/inst.wgt.py b/common/tct-messageport-tizen-tests/inst.wgt.py index 244c4552d..21c27d4ed 100755 --- a/common/tct-messageport-tizen-tests/inst.wgt.py +++ b/common/tct-messageport-tizen-tests/inst.wgt.py @@ -1,234 +1,234 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -q -u -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - (return_code, output) = doRemoteCMD( - "app_launcher -s bd2Z8dYMp1.MessagePortHelper") - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -q -u -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + (return_code, output) = doRemoteCMD( + "app_launcher -s bd2Z8dYMp1.MessagePortHelper") + + 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 as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-messageport-tizen-tests/inst.xpk.py b/common/tct-messageport-tizen-tests/inst.xpk.py index a5295f0ab..a61db816d 100755 --- a/common/tct-messageport-tizen-tests/inst.xpk.py +++ b/common/tct-messageport-tizen-tests/inst.xpk.py @@ -1,228 +1,228 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -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" -SRC_DIR = "/home/app/content" -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "app" - 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 + + +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" +SRC_DIR = "/home/app/content" +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = "app" + 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) diff --git a/common/tct-messageport-tizen-tests/pack.py b/common/tct-messageport-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-messageport-tizen-tests/pack.py +++ b/common/tct-messageport-tizen-tests/pack.py @@ -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: diff --git a/common/tct-messaging-email-tizen-tests/inst.apk.py b/common/tct-messaging-email-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-messaging-email-tizen-tests/inst.apk.py +++ b/common/tct-messaging-email-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-messaging-email-tizen-tests/inst.wgt.py b/common/tct-messaging-email-tizen-tests/inst.wgt.py index ea1c0dfa3..ec51f5207 100755 --- a/common/tct-messaging-email-tizen-tests/inst.wgt.py +++ b/common/tct-messaging-email-tizen-tests/inst.wgt.py @@ -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 @@ -207,8 +207,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: @@ -227,7 +227,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -239,10 +239,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: diff --git a/common/tct-messaging-email-tizen-tests/inst.xpk.py b/common/tct-messaging-email-tizen-tests/inst.xpk.py index 2b5e3f2e1..e4dff9a99 100755 --- a/common/tct-messaging-email-tizen-tests/inst.xpk.py +++ b/common/tct-messaging-email-tizen-tests/inst.xpk.py @@ -1,227 +1,227 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - 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_code, output) = doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, PKG_NAME)) - 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 - - (return_code, output) = doRemoteCMD("mkdir -p %s/%s" % (SRC_DIR, PKG_NAME)) - if return_code != 0: - action_status = False - - for item in os.listdir(SCRIPT_DIR): - if item.find("webapi-tizen-appcontrol-test_") != -1: - if not doRemoteCopy("%s/%s" % (SCRIPT_DIR, item), "%s/%s/%s" % (SRC_DIR, PKG_NAME, item)): - 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 + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + 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_code, output) = doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, PKG_NAME)) + 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 + + (return_code, output) = doRemoteCMD("mkdir -p %s/%s" % (SRC_DIR, PKG_NAME)) + if return_code != 0: + action_status = False + + for item in os.listdir(SCRIPT_DIR): + if item.find("webapi-tizen-appcontrol-test_") != -1: + if not doRemoteCopy("%s/%s" % (SCRIPT_DIR, item), "%s/%s/%s" % (SRC_DIR, PKG_NAME, item)): + 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 as 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) diff --git a/common/tct-messaging-email-tizen-tests/pack.py b/common/tct-messaging-email-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-messaging-email-tizen-tests/pack.py +++ b/common/tct-messaging-email-tizen-tests/pack.py @@ -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: diff --git a/common/tct-messaging-mms-tizen-tests/inst.apk.py b/common/tct-messaging-mms-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-messaging-mms-tizen-tests/inst.apk.py +++ b/common/tct-messaging-mms-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-messaging-mms-tizen-tests/inst.wgt.py b/common/tct-messaging-mms-tizen-tests/inst.wgt.py index 71805b47f..fd2e87dda 100755 --- a/common/tct-messaging-mms-tizen-tests/inst.wgt.py +++ b/common/tct-messaging-mms-tizen-tests/inst.wgt.py @@ -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 @@ -204,8 +204,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: @@ -224,7 +224,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -236,10 +236,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: diff --git a/common/tct-messaging-mms-tizen-tests/inst.xpk.py b/common/tct-messaging-mms-tizen-tests/inst.xpk.py index 2b5e3f2e1..e4dff9a99 100755 --- a/common/tct-messaging-mms-tizen-tests/inst.xpk.py +++ b/common/tct-messaging-mms-tizen-tests/inst.xpk.py @@ -1,227 +1,227 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - 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_code, output) = doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, PKG_NAME)) - 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 - - (return_code, output) = doRemoteCMD("mkdir -p %s/%s" % (SRC_DIR, PKG_NAME)) - if return_code != 0: - action_status = False - - for item in os.listdir(SCRIPT_DIR): - if item.find("webapi-tizen-appcontrol-test_") != -1: - if not doRemoteCopy("%s/%s" % (SCRIPT_DIR, item), "%s/%s/%s" % (SRC_DIR, PKG_NAME, item)): - 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 + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + 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_code, output) = doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, PKG_NAME)) + 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 + + (return_code, output) = doRemoteCMD("mkdir -p %s/%s" % (SRC_DIR, PKG_NAME)) + if return_code != 0: + action_status = False + + for item in os.listdir(SCRIPT_DIR): + if item.find("webapi-tizen-appcontrol-test_") != -1: + if not doRemoteCopy("%s/%s" % (SCRIPT_DIR, item), "%s/%s/%s" % (SRC_DIR, PKG_NAME, item)): + 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 as 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) diff --git a/common/tct-messaging-mms-tizen-tests/pack.py b/common/tct-messaging-mms-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-messaging-mms-tizen-tests/pack.py +++ b/common/tct-messaging-mms-tizen-tests/pack.py @@ -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: diff --git a/common/tct-messaging-sms-tizen-tests/inst.apk.py b/common/tct-messaging-sms-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-messaging-sms-tizen-tests/inst.apk.py +++ b/common/tct-messaging-sms-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-messaging-sms-tizen-tests/inst.wgt.py b/common/tct-messaging-sms-tizen-tests/inst.wgt.py index ef38eb600..6e0726097 100755 --- a/common/tct-messaging-sms-tizen-tests/inst.wgt.py +++ b/common/tct-messaging-sms-tizen-tests/inst.wgt.py @@ -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 @@ -205,8 +205,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: @@ -225,7 +225,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -237,10 +237,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: diff --git a/common/tct-messaging-sms-tizen-tests/inst.xpk.py b/common/tct-messaging-sms-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-messaging-sms-tizen-tests/inst.xpk.py +++ b/common/tct-messaging-sms-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-messaging-sms-tizen-tests/pack.py b/common/tct-messaging-sms-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-messaging-sms-tizen-tests/pack.py +++ b/common/tct-messaging-sms-tizen-tests/pack.py @@ -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: diff --git a/common/tct-metadata-tizen-tests/inst.apk.py b/common/tct-metadata-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-metadata-tizen-tests/inst.apk.py +++ b/common/tct-metadata-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-metadata-tizen-tests/inst.wgt.py b/common/tct-metadata-tizen-tests/inst.wgt.py index 70534429f..ecdac7ff6 100755 --- a/common/tct-metadata-tizen-tests/inst.wgt.py +++ b/common/tct-metadata-tizen-tests/inst.wgt.py @@ -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 @@ -204,8 +204,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: @@ -224,7 +224,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -236,10 +236,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: diff --git a/common/tct-metadata-tizen-tests/inst.xpk.py b/common/tct-metadata-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-metadata-tizen-tests/inst.xpk.py +++ b/common/tct-metadata-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-metadata-tizen-tests/pack.py b/common/tct-metadata-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-metadata-tizen-tests/pack.py +++ b/common/tct-metadata-tizen-tests/pack.py @@ -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: diff --git a/common/tct-ml-tizen-tests/inst.apk.py b/common/tct-ml-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-ml-tizen-tests/inst.apk.py +++ b/common/tct-ml-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-ml-tizen-tests/inst.wgt.py b/common/tct-ml-tizen-tests/inst.wgt.py index 70534429f..ecdac7ff6 100755 --- a/common/tct-ml-tizen-tests/inst.wgt.py +++ b/common/tct-ml-tizen-tests/inst.wgt.py @@ -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 @@ -204,8 +204,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: @@ -224,7 +224,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -236,10 +236,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: diff --git a/common/tct-ml-tizen-tests/inst.xpk.py b/common/tct-ml-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-ml-tizen-tests/inst.xpk.py +++ b/common/tct-ml-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-ml-tizen-tests/pack.py b/common/tct-ml-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-ml-tizen-tests/pack.py +++ b/common/tct-ml-tizen-tests/pack.py @@ -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: diff --git a/common/tct-mlpipeline-tizen-tests/inst.apk.py b/common/tct-mlpipeline-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-mlpipeline-tizen-tests/inst.apk.py +++ b/common/tct-mlpipeline-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-mlpipeline-tizen-tests/inst.wgt.py b/common/tct-mlpipeline-tizen-tests/inst.wgt.py index 70534429f..ecdac7ff6 100755 --- a/common/tct-mlpipeline-tizen-tests/inst.wgt.py +++ b/common/tct-mlpipeline-tizen-tests/inst.wgt.py @@ -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 @@ -204,8 +204,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: @@ -224,7 +224,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -236,10 +236,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: diff --git a/common/tct-mlpipeline-tizen-tests/inst.xpk.py b/common/tct-mlpipeline-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-mlpipeline-tizen-tests/inst.xpk.py +++ b/common/tct-mlpipeline-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-mlpipeline-tizen-tests/pack.py b/common/tct-mlpipeline-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-mlpipeline-tizen-tests/pack.py +++ b/common/tct-mlpipeline-tizen-tests/pack.py @@ -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: diff --git a/common/tct-mlsingleshot-tizen-tests/inst.apk.py b/common/tct-mlsingleshot-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-mlsingleshot-tizen-tests/inst.apk.py +++ b/common/tct-mlsingleshot-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-mlsingleshot-tizen-tests/inst.wgt.py b/common/tct-mlsingleshot-tizen-tests/inst.wgt.py index 39ee7a0c0..1459d2c88 100755 --- a/common/tct-mlsingleshot-tizen-tests/inst.wgt.py +++ b/common/tct-mlsingleshot-tizen-tests/inst.wgt.py @@ -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 @@ -219,8 +219,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: @@ -239,7 +239,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -251,10 +251,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: diff --git a/common/tct-mlsingleshot-tizen-tests/inst.xpk.py b/common/tct-mlsingleshot-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-mlsingleshot-tizen-tests/inst.xpk.py +++ b/common/tct-mlsingleshot-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-mlsingleshot-tizen-tests/pack.py b/common/tct-mlsingleshot-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-mlsingleshot-tizen-tests/pack.py +++ b/common/tct-mlsingleshot-tizen-tests/pack.py @@ -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: diff --git a/common/tct-mse-w3c-tests/inst.apk.py b/common/tct-mse-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-mse-w3c-tests/inst.apk.py +++ b/common/tct-mse-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-mse-w3c-tests/inst.wgt.py b/common/tct-mse-w3c-tests/inst.wgt.py index 93ac8ad71..66eb23daa 100755 --- a/common/tct-mse-w3c-tests/inst.wgt.py +++ b/common/tct-mse-w3c-tests/inst.wgt.py @@ -1,240 +1,240 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-mse-w3c-tests/inst.xpk.py b/common/tct-mse-w3c-tests/inst.xpk.py index a5295f0ab..a61db816d 100755 --- a/common/tct-mse-w3c-tests/inst.xpk.py +++ b/common/tct-mse-w3c-tests/inst.xpk.py @@ -1,228 +1,228 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -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" -SRC_DIR = "/home/app/content" -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "app" - 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 + + +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" +SRC_DIR = "/home/app/content" +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = "app" + 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) diff --git a/common/tct-mse-w3c-tests/pack.py b/common/tct-mse-w3c-tests/pack.py index d2ee57294..134a17a07 100755 --- a/common/tct-mse-w3c-tests/pack.py +++ b/common/tct-mse-w3c-tests/pack.py @@ -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: diff --git a/common/tct-multicolumn-css3-tests/inst.apk.py b/common/tct-multicolumn-css3-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-multicolumn-css3-tests/inst.apk.py +++ b/common/tct-multicolumn-css3-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-multicolumn-css3-tests/inst.wgt.py b/common/tct-multicolumn-css3-tests/inst.wgt.py index c7f89fd44..909755af3 100755 --- a/common/tct-multicolumn-css3-tests/inst.wgt.py +++ b/common/tct-multicolumn-css3-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -191,8 +191,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: @@ -211,7 +211,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -223,10 +223,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: diff --git a/common/tct-multicolumn-css3-tests/inst.xpk.py b/common/tct-multicolumn-css3-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-multicolumn-css3-tests/inst.xpk.py +++ b/common/tct-multicolumn-css3-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-multicolumn-css3-tests/pack.py b/common/tct-multicolumn-css3-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-multicolumn-css3-tests/pack.py +++ b/common/tct-multicolumn-css3-tests/pack.py @@ -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: diff --git a/common/tct-namespace-tizen-tests/inst.apk.py b/common/tct-namespace-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-namespace-tizen-tests/inst.apk.py +++ b/common/tct-namespace-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-namespace-tizen-tests/inst.wgt.py b/common/tct-namespace-tizen-tests/inst.wgt.py index 44e57cf17..5322534da 100755 --- a/common/tct-namespace-tizen-tests/inst.wgt.py +++ b/common/tct-namespace-tizen-tests/inst.wgt.py @@ -1,241 +1,241 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-namespace-tizen-tests/inst.xpk.py b/common/tct-namespace-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-namespace-tizen-tests/inst.xpk.py +++ b/common/tct-namespace-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-namespace-tizen-tests/pack.py b/common/tct-namespace-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-namespace-tizen-tests/pack.py +++ b/common/tct-namespace-tizen-tests/pack.py @@ -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: diff --git a/common/tct-navigationtiming-w3c-tests/inst.apk.py b/common/tct-navigationtiming-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-navigationtiming-w3c-tests/inst.apk.py +++ b/common/tct-navigationtiming-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-navigationtiming-w3c-tests/inst.wgt.py b/common/tct-navigationtiming-w3c-tests/inst.wgt.py index dd614f265..b30f310f4 100755 --- a/common/tct-navigationtiming-w3c-tests/inst.wgt.py +++ b/common/tct-navigationtiming-w3c-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -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) userCheck() @@ -215,10 +215,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: diff --git a/common/tct-navigationtiming-w3c-tests/inst.xpk.py b/common/tct-navigationtiming-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-navigationtiming-w3c-tests/inst.xpk.py +++ b/common/tct-navigationtiming-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-navigationtiming-w3c-tests/pack.py b/common/tct-navigationtiming-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-navigationtiming-w3c-tests/pack.py +++ b/common/tct-navigationtiming-w3c-tests/pack.py @@ -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: diff --git a/common/tct-network-information-cordova-tests/inst.apk.py b/common/tct-network-information-cordova-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-network-information-cordova-tests/inst.apk.py +++ b/common/tct-network-information-cordova-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-network-information-cordova-tests/inst.wgt.py b/common/tct-network-information-cordova-tests/inst.wgt.py index 128023f51..76e09e518 100755 --- a/common/tct-network-information-cordova-tests/inst.wgt.py +++ b/common/tct-network-information-cordova-tests/inst.wgt.py @@ -1,252 +1,252 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def askpolicyremoving(): - for root, dirs, files in os.walk(SCRIPT_DIR): - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - - 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)): - action_status = False - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell .%s/askpolicy.sh %s" % (PARAMETERS.device, - SRC_DIR, pkg_id) - return doCMD(cmd) - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - for file in files: - if file.endswith("%s.wgt" % PKG_NAME): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - for item in glob.glob("%s/*" % SCRIPT_DIR): - if item.endswith(".wgt"): - continue - elif item.endswith("inst.py"): - continue - else: - item_name = os.path.basename(item) - if not doRemoteCopy(item, "%s/%s" % (PKG_SRC_DIR, item_name)): - action_status = False - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - #askpolicyremoving() - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def askpolicyremoving(): + for root, dirs, files in os.walk(SCRIPT_DIR): + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + + 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)): + action_status = False + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell .%s/askpolicy.sh %s" % (PARAMETERS.device, + SRC_DIR, pkg_id) + return doCMD(cmd) + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + for file in files: + if file.endswith("%s.wgt" % PKG_NAME): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + for item in glob.glob("%s/*" % SCRIPT_DIR): + if item.endswith(".wgt"): + continue + elif item.endswith("inst.py"): + continue + else: + item_name = os.path.basename(item) + if not doRemoteCopy(item, "%s/%s" % (PKG_SRC_DIR, item_name)): + 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 as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + #askpolicyremoving() + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-network-information-cordova-tests/inst.xpk.py b/common/tct-network-information-cordova-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-network-information-cordova-tests/inst.xpk.py +++ b/common/tct-network-information-cordova-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-network-information-cordova-tests/pack.py b/common/tct-network-information-cordova-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-network-information-cordova-tests/pack.py +++ b/common/tct-network-information-cordova-tests/pack.py @@ -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: diff --git a/common/tct-networkbearerselection-tizen-tests/inst.apk.py b/common/tct-networkbearerselection-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-networkbearerselection-tizen-tests/inst.apk.py +++ b/common/tct-networkbearerselection-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-networkbearerselection-tizen-tests/inst.wgt.py b/common/tct-networkbearerselection-tizen-tests/inst.wgt.py index dc5e8b8b3..8b5d2f8a8 100755 --- a/common/tct-networkbearerselection-tizen-tests/inst.wgt.py +++ b/common/tct-networkbearerselection-tizen-tests/inst.wgt.py @@ -1,239 +1,239 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-networkbearerselection-tizen-tests/inst.xpk.py b/common/tct-networkbearerselection-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-networkbearerselection-tizen-tests/inst.xpk.py +++ b/common/tct-networkbearerselection-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-networkbearerselection-tizen-tests/pack.py b/common/tct-networkbearerselection-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-networkbearerselection-tizen-tests/pack.py +++ b/common/tct-networkbearerselection-tizen-tests/pack.py @@ -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: diff --git a/common/tct-nfc-tizen-tests/inst.apk.py b/common/tct-nfc-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-nfc-tizen-tests/inst.apk.py +++ b/common/tct-nfc-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-nfc-tizen-tests/inst.wgt.py b/common/tct-nfc-tizen-tests/inst.wgt.py index 2dd4ce674..bce7972e2 100755 --- a/common/tct-nfc-tizen-tests/inst.wgt.py +++ b/common/tct-nfc-tizen-tests/inst.wgt.py @@ -1,249 +1,249 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt") or file.endswith(".tpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -q -u -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - #(return_code, output) = doRemoteCMD( - # "rm /home/owner/share/org.tizen.tbt_hcetestappa-1.0.0-arm.tpk") - # (return_code, output) = doRemoteCMD( - # "rm /home/owner/share/nfcTest.wgt") - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - for file in files: - if file.endswith(".tpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t tpk -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - #if not doRemoteCopy(os.path.join(SCRIPT_DIR, "nfcTest"), "/home/owner/share"): - # action_status = False - #(return_code, output) = doRemoteCMD( - # "su - %s -c '%s;app_launcher -s cM2gZdtzOg.nfcTest'" % (PARAMETERS.user, XW_ENV)) - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt") or file.endswith(".tpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -q -u -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + #(return_code, output) = doRemoteCMD( + # "rm /home/owner/share/org.tizen.tbt_hcetestappa-1.0.0-arm.tpk") + # (return_code, output) = doRemoteCMD( + # "rm /home/owner/share/nfcTest.wgt") + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + for file in files: + if file.endswith(".tpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t tpk -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + #if not doRemoteCopy(os.path.join(SCRIPT_DIR, "nfcTest"), "/home/owner/share"): + # action_status = False + #(return_code, output) = doRemoteCMD( + # "su - %s -c '%s;app_launcher -s cM2gZdtzOg.nfcTest'" % (PARAMETERS.user, XW_ENV)) + 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 as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-nfc-tizen-tests/inst.xpk.py b/common/tct-nfc-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-nfc-tizen-tests/inst.xpk.py +++ b/common/tct-nfc-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-nfc-tizen-tests/pack.py b/common/tct-nfc-tizen-tests/pack.py index 0ba04d037..ed803130a 100755 --- a/common/tct-nfc-tizen-tests/pack.py +++ b/common/tct-nfc-tizen-tests/pack.py @@ -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: @@ -940,7 +940,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: diff --git a/common/tct-notification-tizen-tests/inst.apk.py b/common/tct-notification-tizen-tests/inst.apk.py index 31210db16..997d98f37 100755 --- a/common/tct-notification-tizen-tests/inst.apk.py +++ b/common/tct-notification-tizen-tests/inst.apk.py @@ -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: diff --git a/common/tct-notification-tizen-tests/inst.wgt.py b/common/tct-notification-tizen-tests/inst.wgt.py index 802b9e785..d40f6c0d4 100755 --- a/common/tct-notification-tizen-tests/inst.wgt.py +++ b/common/tct-notification-tizen-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -197,8 +197,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: @@ -217,7 +217,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -229,10 +229,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: diff --git a/common/tct-notification-tizen-tests/inst.xpk.py b/common/tct-notification-tizen-tests/inst.xpk.py index c904d861a..7e0d91324 100755 --- a/common/tct-notification-tizen-tests/inst.xpk.py +++ b/common/tct-notification-tizen-tests/inst.xpk.py @@ -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 @@ -188,8 +188,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: @@ -208,7 +208,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -218,10 +218,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: diff --git a/common/tct-notification-tizen-tests/pack.py b/common/tct-notification-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-notification-tizen-tests/pack.py +++ b/common/tct-notification-tizen-tests/pack.py @@ -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: diff --git a/common/tct-notification-w3c-tests/inst.apk.py b/common/tct-notification-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-notification-w3c-tests/inst.apk.py +++ b/common/tct-notification-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-notification-w3c-tests/inst.wgt.py b/common/tct-notification-w3c-tests/inst.wgt.py index d7b962bfa..0f5e3baa1 100755 --- a/common/tct-notification-w3c-tests/inst.wgt.py +++ b/common/tct-notification-w3c-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -189,8 +189,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: @@ -209,7 +209,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -221,10 +221,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: diff --git a/common/tct-notification-w3c-tests/inst.xpk.py b/common/tct-notification-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-notification-w3c-tests/inst.xpk.py +++ b/common/tct-notification-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-notification-w3c-tests/pack.py b/common/tct-notification-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-notification-w3c-tests/pack.py +++ b/common/tct-notification-w3c-tests/pack.py @@ -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: diff --git a/common/tct-package-tizen-tests/inst.apk.py b/common/tct-package-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-package-tizen-tests/inst.apk.py +++ b/common/tct-package-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-package-tizen-tests/inst.wgt.py b/common/tct-package-tizen-tests/inst.wgt.py index 26774c69d..8f8ca1b7c 100755 --- a/common/tct-package-tizen-tests/inst.wgt.py +++ b/common/tct-package-tizen-tests/inst.wgt.py @@ -1,239 +1,239 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - (return_code, output) = doRemoteCMD( - "rm -rf %s/Others" % SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - if not doRemoteCopy("%s/mediasrc" % SCRIPT_DIR, "%s/Others" % SRC_DIR): - action_status = False - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + (return_code, output) = doRemoteCMD( + "rm -rf %s/Others" % SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + if not doRemoteCopy("%s/mediasrc" % SCRIPT_DIR, "%s/Others" % 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 as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-package-tizen-tests/inst.xpk.py b/common/tct-package-tizen-tests/inst.xpk.py index 22a25cec5..911e9eb78 100755 --- a/common/tct-package-tizen-tests/inst.xpk.py +++ b/common/tct-package-tizen-tests/inst.xpk.py @@ -1,228 +1,228 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - (return_code, output) = doRemoteCMD( - "rm -rf %s/Others" % SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - if not doRemoteCopy("%s/mediasrc" % SCRIPT_DIR, "%s/Others" % 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 + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + (return_code, output) = doRemoteCMD( + "rm -rf %s/Others" % SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + if not doRemoteCopy("%s/mediasrc" % SCRIPT_DIR, "%s/Others" % 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 as 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) diff --git a/common/tct-package-tizen-tests/pack.py b/common/tct-package-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-package-tizen-tests/pack.py +++ b/common/tct-package-tizen-tests/pack.py @@ -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: diff --git a/common/tct-pagevisibility-w3c-tests/inst.apk.py b/common/tct-pagevisibility-w3c-tests/inst.apk.py index 31210db16..997d98f37 100755 --- a/common/tct-pagevisibility-w3c-tests/inst.apk.py +++ b/common/tct-pagevisibility-w3c-tests/inst.apk.py @@ -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: diff --git a/common/tct-pagevisibility-w3c-tests/inst.wgt.py b/common/tct-pagevisibility-w3c-tests/inst.wgt.py index 93ac8ad71..670f31e95 100755 --- a/common/tct-pagevisibility-w3c-tests/inst.wgt.py +++ b/common/tct-pagevisibility-w3c-tests/inst.wgt.py @@ -8,7 +8,7 @@ import sys import subprocess import string from optparse import OptionParser, make_option -import ConfigParser +import configparser SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) @@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR) PARAMETERS = None #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() +tct_parser = configparser.ConfigParser() tct_parser.read(TCT_CONFIG_FILE) SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) @@ -32,14 +32,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -190,8 +190,8 @@ def main(): "-a", dest="user", action="store", help="User name") global PARAMETERS (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) sys.exit(1) if not PARAMETERS.user: @@ -210,7 +210,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -222,10 +222,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: diff --git a/common/tct-pagevisibility-w3c-tests/inst.xpk.py b/common/tct-pagevisibility-w3c-tests/inst.xpk.py index 211d24c73..dccbae7e9 100755 --- a/common/tct-pagevisibility-w3c-tests/inst.xpk.py +++ b/common/tct-pagevisibility-w3c-tests/inst.xpk.py @@ -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: diff --git a/common/tct-pagevisibility-w3c-tests/pack.py b/common/tct-pagevisibility-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-pagevisibility-w3c-tests/pack.py +++ b/common/tct-pagevisibility-w3c-tests/pack.py @@ -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: diff --git a/common/tct-playerutil-tizen-tests/inst.apk.py b/common/tct-playerutil-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-playerutil-tizen-tests/inst.apk.py +++ b/common/tct-playerutil-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-playerutil-tizen-tests/inst.wgt.py b/common/tct-playerutil-tizen-tests/inst.wgt.py index c7f89fd44..909755af3 100755 --- a/common/tct-playerutil-tizen-tests/inst.wgt.py +++ b/common/tct-playerutil-tizen-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -191,8 +191,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: @@ -211,7 +211,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -223,10 +223,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: diff --git a/common/tct-playerutil-tizen-tests/inst.xpk.py b/common/tct-playerutil-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-playerutil-tizen-tests/inst.xpk.py +++ b/common/tct-playerutil-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-playerutil-tizen-tests/pack.py b/common/tct-playerutil-tizen-tests/pack.py index 08d55aafe..92866ab2e 100755 --- a/common/tct-playerutil-tizen-tests/pack.py +++ b/common/tct-playerutil-tizen-tests/pack.py @@ -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: diff --git a/common/tct-power-tizen-tests/inst.apk.py b/common/tct-power-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-power-tizen-tests/inst.apk.py +++ b/common/tct-power-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-power-tizen-tests/inst.wgt.py b/common/tct-power-tizen-tests/inst.wgt.py index ca95382d7..eb549d398 100755 --- a/common/tct-power-tizen-tests/inst.wgt.py +++ b/common/tct-power-tizen-tests/inst.wgt.py @@ -1,245 +1,245 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - (return_code, output) = doRemoteCMD( - "vconftool set -t int db/setting/lcd_backlight_normal 0 -f") - (return_code, output) = doRemoteCMD( - "vconftool set -t int db/setting/screen_lock_type 0 -f") - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + (return_code, output) = doRemoteCMD( + "vconftool set -t int db/setting/lcd_backlight_normal 0 -f") + (return_code, output) = doRemoteCMD( + "vconftool set -t int db/setting/screen_lock_type 0 -f") + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-power-tizen-tests/inst.xpk.py b/common/tct-power-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-power-tizen-tests/inst.xpk.py +++ b/common/tct-power-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-power-tizen-tests/pack.py b/common/tct-power-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-power-tizen-tests/pack.py +++ b/common/tct-power-tizen-tests/pack.py @@ -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: diff --git a/common/tct-preference-tizen-tests/inst.apk.py b/common/tct-preference-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-preference-tizen-tests/inst.apk.py +++ b/common/tct-preference-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-preference-tizen-tests/inst.wgt.py b/common/tct-preference-tizen-tests/inst.wgt.py index 93ac8ad71..66eb23daa 100755 --- a/common/tct-preference-tizen-tests/inst.wgt.py +++ b/common/tct-preference-tizen-tests/inst.wgt.py @@ -1,240 +1,240 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-preference-tizen-tests/inst.xpk.py b/common/tct-preference-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-preference-tizen-tests/inst.xpk.py +++ b/common/tct-preference-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-preference-tizen-tests/pack.py b/common/tct-preference-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-preference-tizen-tests/pack.py +++ b/common/tct-preference-tizen-tests/pack.py @@ -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: diff --git a/common/tct-privacyprivilege-tizen-tests/inst.apk.py b/common/tct-privacyprivilege-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-privacyprivilege-tizen-tests/inst.apk.py +++ b/common/tct-privacyprivilege-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-privacyprivilege-tizen-tests/inst.wgt.py b/common/tct-privacyprivilege-tizen-tests/inst.wgt.py index ef38eb600..6e0726097 100755 --- a/common/tct-privacyprivilege-tizen-tests/inst.wgt.py +++ b/common/tct-privacyprivilege-tizen-tests/inst.wgt.py @@ -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 @@ -205,8 +205,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: @@ -225,7 +225,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -237,10 +237,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: diff --git a/common/tct-privacyprivilege-tizen-tests/inst.xpk.py b/common/tct-privacyprivilege-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-privacyprivilege-tizen-tests/inst.xpk.py +++ b/common/tct-privacyprivilege-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-privacyprivilege-tizen-tests/pack.py b/common/tct-privacyprivilege-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-privacyprivilege-tizen-tests/pack.py +++ b/common/tct-privacyprivilege-tizen-tests/pack.py @@ -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: diff --git a/common/tct-privilege-tizen-tests/inst.apk.py b/common/tct-privilege-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-privilege-tizen-tests/inst.apk.py +++ b/common/tct-privilege-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-privilege-tizen-tests/inst.wgt.py b/common/tct-privilege-tizen-tests/inst.wgt.py index 44e57cf17..5322534da 100755 --- a/common/tct-privilege-tizen-tests/inst.wgt.py +++ b/common/tct-privilege-tizen-tests/inst.wgt.py @@ -1,241 +1,241 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-privilege-tizen-tests/inst.xpk.py b/common/tct-privilege-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-privilege-tizen-tests/inst.xpk.py +++ b/common/tct-privilege-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-privilege-tizen-tests/pack.py b/common/tct-privilege-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-privilege-tizen-tests/pack.py +++ b/common/tct-privilege-tizen-tests/pack.py @@ -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: diff --git a/common/tct-push-tizen-tests/inst.apk.py b/common/tct-push-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-push-tizen-tests/inst.apk.py +++ b/common/tct-push-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-push-tizen-tests/inst.wgt.py b/common/tct-push-tizen-tests/inst.wgt.py index e32732b34..8e0d9ef1a 100755 --- a/common/tct-push-tizen-tests/inst.wgt.py +++ b/common/tct-push-tizen-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -188,8 +188,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: @@ -208,7 +208,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -220,10 +220,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: diff --git a/common/tct-push-tizen-tests/inst.xpk.py b/common/tct-push-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-push-tizen-tests/inst.xpk.py +++ b/common/tct-push-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-push-tizen-tests/pack.py b/common/tct-push-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-push-tizen-tests/pack.py +++ b/common/tct-push-tizen-tests/pack.py @@ -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: diff --git a/common/tct-push-w3c-tests/inst.apk.py b/common/tct-push-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/common/tct-push-w3c-tests/inst.apk.py +++ b/common/tct-push-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/common/tct-push-w3c-tests/inst.wgt.py b/common/tct-push-w3c-tests/inst.wgt.py index 145211488..36be2eb51 100755 --- a/common/tct-push-w3c-tests/inst.wgt.py +++ b/common/tct-push-w3c-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -189,8 +189,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: @@ -209,7 +209,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -221,10 +221,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: diff --git a/common/tct-push-w3c-tests/inst.xpk.py b/common/tct-push-w3c-tests/inst.xpk.py index 85b97b93f..3c5075e3e 100755 --- a/common/tct-push-w3c-tests/inst.xpk.py +++ b/common/tct-push-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/common/tct-push-w3c-tests/pack.py b/common/tct-push-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-push-w3c-tests/pack.py +++ b/common/tct-push-w3c-tests/pack.py @@ -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: diff --git a/common/tct-sandbox-html5-tests/inst.apk.py b/common/tct-sandbox-html5-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-sandbox-html5-tests/inst.apk.py +++ b/common/tct-sandbox-html5-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-sandbox-html5-tests/inst.wgt.py b/common/tct-sandbox-html5-tests/inst.wgt.py index 9c17c1ad7..d442317ad 100755 --- a/common/tct-sandbox-html5-tests/inst.wgt.py +++ b/common/tct-sandbox-html5-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -185,8 +185,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: @@ -205,7 +205,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -217,10 +217,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: diff --git a/common/tct-sandbox-html5-tests/inst.xpk.py b/common/tct-sandbox-html5-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-sandbox-html5-tests/inst.xpk.py +++ b/common/tct-sandbox-html5-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-sandbox-html5-tests/pack.py b/common/tct-sandbox-html5-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-sandbox-html5-tests/pack.py +++ b/common/tct-sandbox-html5-tests/pack.py @@ -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: diff --git a/common/tct-screenorientation-w3c-tests/inst.apk.py b/common/tct-screenorientation-w3c-tests/inst.apk.py index 31210db16..997d98f37 100755 --- a/common/tct-screenorientation-w3c-tests/inst.apk.py +++ b/common/tct-screenorientation-w3c-tests/inst.apk.py @@ -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: diff --git a/common/tct-screenorientation-w3c-tests/inst.wgt.py b/common/tct-screenorientation-w3c-tests/inst.wgt.py index 93ac8ad71..670f31e95 100755 --- a/common/tct-screenorientation-w3c-tests/inst.wgt.py +++ b/common/tct-screenorientation-w3c-tests/inst.wgt.py @@ -8,7 +8,7 @@ import sys import subprocess import string from optparse import OptionParser, make_option -import ConfigParser +import configparser SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) @@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR) PARAMETERS = None #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() +tct_parser = configparser.ConfigParser() tct_parser.read(TCT_CONFIG_FILE) SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) @@ -32,14 +32,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -190,8 +190,8 @@ def main(): "-a", dest="user", action="store", help="User name") global PARAMETERS (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) sys.exit(1) if not PARAMETERS.user: @@ -210,7 +210,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -222,10 +222,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: diff --git a/common/tct-screenorientation-w3c-tests/inst.xpk.py b/common/tct-screenorientation-w3c-tests/inst.xpk.py index 211d24c73..dccbae7e9 100755 --- a/common/tct-screenorientation-w3c-tests/inst.xpk.py +++ b/common/tct-screenorientation-w3c-tests/inst.xpk.py @@ -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: diff --git a/common/tct-screenorientation-w3c-tests/pack.py b/common/tct-screenorientation-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-screenorientation-w3c-tests/pack.py +++ b/common/tct-screenorientation-w3c-tests/pack.py @@ -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: diff --git a/common/tct-secureelement-tizen-tests/inst.apk.py b/common/tct-secureelement-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-secureelement-tizen-tests/inst.apk.py +++ b/common/tct-secureelement-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-secureelement-tizen-tests/inst.wgt.py b/common/tct-secureelement-tizen-tests/inst.wgt.py index d4d5dc5df..d88ca1890 100755 --- a/common/tct-secureelement-tizen-tests/inst.wgt.py +++ b/common/tct-secureelement-tizen-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -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: diff --git a/common/tct-secureelement-tizen-tests/inst.xpk.py b/common/tct-secureelement-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-secureelement-tizen-tests/inst.xpk.py +++ b/common/tct-secureelement-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-secureelement-tizen-tests/pack.py b/common/tct-secureelement-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-secureelement-tizen-tests/pack.py +++ b/common/tct-secureelement-tizen-tests/pack.py @@ -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: diff --git a/common/tct-security-tcs-tests/inst.apk.py b/common/tct-security-tcs-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-security-tcs-tests/inst.apk.py +++ b/common/tct-security-tcs-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-security-tcs-tests/inst.wgt.py b/common/tct-security-tcs-tests/inst.wgt.py index d7b962bfa..0f5e3baa1 100755 --- a/common/tct-security-tcs-tests/inst.wgt.py +++ b/common/tct-security-tcs-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -189,8 +189,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: @@ -209,7 +209,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -221,10 +221,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: diff --git a/common/tct-security-tcs-tests/inst.xpk.py b/common/tct-security-tcs-tests/inst.xpk.py index c0c358ecc..34a9d92c3 100755 --- a/common/tct-security-tcs-tests/inst.xpk.py +++ b/common/tct-security-tcs-tests/inst.xpk.py @@ -1,214 +1,214 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - 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 - - 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 + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + 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 + + 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 as 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) diff --git a/common/tct-security-tcs-tests/pack.py b/common/tct-security-tcs-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-security-tcs-tests/pack.py +++ b/common/tct-security-tcs-tests/pack.py @@ -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: diff --git a/common/tct-selectorslevel1-w3c-tests/inst.apk.py b/common/tct-selectorslevel1-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-selectorslevel1-w3c-tests/inst.apk.py +++ b/common/tct-selectorslevel1-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-selectorslevel1-w3c-tests/inst.wgt.py b/common/tct-selectorslevel1-w3c-tests/inst.wgt.py index 93ac8ad71..66eb23daa 100755 --- a/common/tct-selectorslevel1-w3c-tests/inst.wgt.py +++ b/common/tct-selectorslevel1-w3c-tests/inst.wgt.py @@ -1,240 +1,240 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-selectorslevel1-w3c-tests/inst.xpk.py b/common/tct-selectorslevel1-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-selectorslevel1-w3c-tests/inst.xpk.py +++ b/common/tct-selectorslevel1-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-selectorslevel1-w3c-tests/pack.py b/common/tct-selectorslevel1-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-selectorslevel1-w3c-tests/pack.py +++ b/common/tct-selectorslevel1-w3c-tests/pack.py @@ -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: diff --git a/common/tct-selectorslevel2-w3c-tests/inst.apk.py b/common/tct-selectorslevel2-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-selectorslevel2-w3c-tests/inst.apk.py +++ b/common/tct-selectorslevel2-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-selectorslevel2-w3c-tests/inst.wgt.py b/common/tct-selectorslevel2-w3c-tests/inst.wgt.py index 93ac8ad71..66eb23daa 100755 --- a/common/tct-selectorslevel2-w3c-tests/inst.wgt.py +++ b/common/tct-selectorslevel2-w3c-tests/inst.wgt.py @@ -1,240 +1,240 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-selectorslevel2-w3c-tests/inst.xpk.py b/common/tct-selectorslevel2-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-selectorslevel2-w3c-tests/inst.xpk.py +++ b/common/tct-selectorslevel2-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-selectorslevel2-w3c-tests/pack.py b/common/tct-selectorslevel2-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-selectorslevel2-w3c-tests/pack.py +++ b/common/tct-selectorslevel2-w3c-tests/pack.py @@ -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: diff --git a/common/tct-sensor-tizen-tests/inst.apk.py b/common/tct-sensor-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-sensor-tizen-tests/inst.apk.py +++ b/common/tct-sensor-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-sensor-tizen-tests/inst.wgt.py b/common/tct-sensor-tizen-tests/inst.wgt.py index 3ef2cf1df..73deb8f0c 100755 --- a/common/tct-sensor-tizen-tests/inst.wgt.py +++ b/common/tct-sensor-tizen-tests/inst.wgt.py @@ -1,258 +1,258 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def askpolicyremoving(): - for root, dirs, files in os.walk(SCRIPT_DIR): - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - - 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)): - action_status = False - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell .%s/askpolicy.sh %s" % (PARAMETERS.device, - SRC_DIR, pkg_id) - return doCMD(cmd) - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - #askpolicyremoving() - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def askpolicyremoving(): + for root, dirs, files in os.walk(SCRIPT_DIR): + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + + 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)): + action_status = False + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell .%s/askpolicy.sh %s" % (PARAMETERS.device, + SRC_DIR, pkg_id) + return doCMD(cmd) + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + #askpolicyremoving() + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-sensor-tizen-tests/inst.xpk.py b/common/tct-sensor-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-sensor-tizen-tests/inst.xpk.py +++ b/common/tct-sensor-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-sensor-tizen-tests/pack.py b/common/tct-sensor-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-sensor-tizen-tests/pack.py +++ b/common/tct-sensor-tizen-tests/pack.py @@ -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: diff --git a/common/tct-serviceworkers-w3c-tests/inst.apk.py b/common/tct-serviceworkers-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-serviceworkers-w3c-tests/inst.apk.py +++ b/common/tct-serviceworkers-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-serviceworkers-w3c-tests/inst.wgt.py b/common/tct-serviceworkers-w3c-tests/inst.wgt.py index f0baddaf5..4047f19c8 100755 --- a/common/tct-serviceworkers-w3c-tests/inst.wgt.py +++ b/common/tct-serviceworkers-w3c-tests/inst.wgt.py @@ -1,235 +1,235 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - for item in glob.glob("%s/*" % SCRIPT_DIR): - if item.endswith(".wgt"): - continue - elif item.endswith("inst.py"): - continue - else: - item_name = os.path.basename(item) - if not doRemoteCopy(item, "%s/%s" % (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 = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + for item in glob.glob("%s/*" % SCRIPT_DIR): + if item.endswith(".wgt"): + continue + elif item.endswith("inst.py"): + continue + else: + item_name = os.path.basename(item) + if not doRemoteCopy(item, "%s/%s" % (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 as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-serviceworkers-w3c-tests/inst.xpk.py b/common/tct-serviceworkers-w3c-tests/inst.xpk.py index a5295f0ab..a61db816d 100755 --- a/common/tct-serviceworkers-w3c-tests/inst.xpk.py +++ b/common/tct-serviceworkers-w3c-tests/inst.xpk.py @@ -1,228 +1,228 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -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" -SRC_DIR = "/home/app/content" -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "app" - 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 + + +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" +SRC_DIR = "/home/app/content" +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = "app" + 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) diff --git a/common/tct-serviceworkers-w3c-tests/pack.py b/common/tct-serviceworkers-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-serviceworkers-w3c-tests/pack.py +++ b/common/tct-serviceworkers-w3c-tests/pack.py @@ -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: diff --git a/common/tct-sessionhistory-html5-tests/inst.apk.py b/common/tct-sessionhistory-html5-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-sessionhistory-html5-tests/inst.apk.py +++ b/common/tct-sessionhistory-html5-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-sessionhistory-html5-tests/inst.wgt.py b/common/tct-sessionhistory-html5-tests/inst.wgt.py index 7a271b8be..6926e5a0a 100755 --- a/common/tct-sessionhistory-html5-tests/inst.wgt.py +++ b/common/tct-sessionhistory-html5-tests/inst.wgt.py @@ -1,239 +1,239 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - for item in glob.glob("%s/*" % SCRIPT_DIR): - if item.endswith(".wgt"): - continue - elif item.endswith("inst.py"): - continue - else: - item_name = os.path.basename(item) - if not doRemoteCopy(item, "%s/%s" % (PKG_SRC_DIR, item_name)): - #if not doRemoteCopy(item, PKG_SRC_DIR): - action_status = False - for item in glob.glob("%s/sessionhistory/w3c/cgi/*" % SCRIPT_DIR): - item_name = os.path.basename(item) - if not doRemoteCopy(item, "%s/sessionhistory/w3c/%s" % (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 = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + for item in glob.glob("%s/*" % SCRIPT_DIR): + if item.endswith(".wgt"): + continue + elif item.endswith("inst.py"): + continue + else: + item_name = os.path.basename(item) + if not doRemoteCopy(item, "%s/%s" % (PKG_SRC_DIR, item_name)): + #if not doRemoteCopy(item, PKG_SRC_DIR): + action_status = False + for item in glob.glob("%s/sessionhistory/w3c/cgi/*" % SCRIPT_DIR): + item_name = os.path.basename(item) + if not doRemoteCopy(item, "%s/sessionhistory/w3c/%s" % (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 as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-sessionhistory-html5-tests/inst.xpk.py b/common/tct-sessionhistory-html5-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-sessionhistory-html5-tests/inst.xpk.py +++ b/common/tct-sessionhistory-html5-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-sessionhistory-html5-tests/pack.py b/common/tct-sessionhistory-html5-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-sessionhistory-html5-tests/pack.py +++ b/common/tct-sessionhistory-html5-tests/pack.py @@ -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: diff --git a/common/tct-sound-tizen-tests/inst.apk.py b/common/tct-sound-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-sound-tizen-tests/inst.apk.py +++ b/common/tct-sound-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-sound-tizen-tests/inst.wgt.py b/common/tct-sound-tizen-tests/inst.wgt.py index 18690763e..5bbb418f3 100755 --- a/common/tct-sound-tizen-tests/inst.wgt.py +++ b/common/tct-sound-tizen-tests/inst.wgt.py @@ -1,242 +1,242 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-sound-tizen-tests/inst.xpk.py b/common/tct-sound-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-sound-tizen-tests/inst.xpk.py +++ b/common/tct-sound-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-sound-tizen-tests/pack.py b/common/tct-sound-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-sound-tizen-tests/pack.py +++ b/common/tct-sound-tizen-tests/pack.py @@ -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: diff --git a/common/tct-speech-w3c-tests/inst.apk.py b/common/tct-speech-w3c-tests/inst.apk.py index 31210db16..997d98f37 100755 --- a/common/tct-speech-w3c-tests/inst.apk.py +++ b/common/tct-speech-w3c-tests/inst.apk.py @@ -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: diff --git a/common/tct-speech-w3c-tests/inst.wgt.py b/common/tct-speech-w3c-tests/inst.wgt.py index ef38eb600..6e0726097 100755 --- a/common/tct-speech-w3c-tests/inst.wgt.py +++ b/common/tct-speech-w3c-tests/inst.wgt.py @@ -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 @@ -205,8 +205,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: @@ -225,7 +225,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -237,10 +237,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: diff --git a/common/tct-speech-w3c-tests/inst.xpk.py b/common/tct-speech-w3c-tests/inst.xpk.py index 211d24c73..dccbae7e9 100755 --- a/common/tct-speech-w3c-tests/inst.xpk.py +++ b/common/tct-speech-w3c-tests/inst.xpk.py @@ -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: diff --git a/common/tct-speech-w3c-tests/pack.py b/common/tct-speech-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-speech-w3c-tests/pack.py +++ b/common/tct-speech-w3c-tests/pack.py @@ -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: diff --git a/common/tct-sse-w3c-tests/inst.apk.py b/common/tct-sse-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-sse-w3c-tests/inst.apk.py +++ b/common/tct-sse-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-sse-w3c-tests/inst.wgt.py b/common/tct-sse-w3c-tests/inst.wgt.py index f0b99779f..938613773 100755 --- a/common/tct-sse-w3c-tests/inst.wgt.py +++ b/common/tct-sse-w3c-tests/inst.wgt.py @@ -1,242 +1,242 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - for item in glob.glob("%s/*" % SCRIPT_DIR): - if item.endswith(".wgt"): - continue - elif item.endswith("inst.py"): - continue - else: - item_name = os.path.basename(item) - if not doRemoteCopy(item, "%s/%s" % (PKG_SRC_DIR, item_name)): - #if not doRemoteCopy(item, PKG_SRC_DIR): - action_status = False - for item in glob.glob("%s/sse/support/cgi/*" % SCRIPT_DIR): - item_name = os.path.basename(item) - if not doRemoteCopy(item, "%s/sse/support/%s" % (PKG_SRC_DIR, item_name)): - action_status = False - for item in glob.glob("%s/sse/w3c/resources/cgi/*" % SCRIPT_DIR): - item_name = os.path.basename(item) - if not doRemoteCopy(item, "%s/sse/w3c/resources/%s" % (PKG_SRC_DIR, item_name)): - action_status = False - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + for item in glob.glob("%s/*" % SCRIPT_DIR): + if item.endswith(".wgt"): + continue + elif item.endswith("inst.py"): + continue + else: + item_name = os.path.basename(item) + if not doRemoteCopy(item, "%s/%s" % (PKG_SRC_DIR, item_name)): + #if not doRemoteCopy(item, PKG_SRC_DIR): + action_status = False + for item in glob.glob("%s/sse/support/cgi/*" % SCRIPT_DIR): + item_name = os.path.basename(item) + if not doRemoteCopy(item, "%s/sse/support/%s" % (PKG_SRC_DIR, item_name)): + action_status = False + for item in glob.glob("%s/sse/w3c/resources/cgi/*" % SCRIPT_DIR): + item_name = os.path.basename(item) + if not doRemoteCopy(item, "%s/sse/w3c/resources/%s" % (PKG_SRC_DIR, item_name)): + 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 as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-sse-w3c-tests/inst.xpk.py b/common/tct-sse-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-sse-w3c-tests/inst.xpk.py +++ b/common/tct-sse-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-sse-w3c-tests/pack.py b/common/tct-sse-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-sse-w3c-tests/pack.py +++ b/common/tct-sse-w3c-tests/pack.py @@ -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: diff --git a/common/tct-svg-html5-tests/inst.apk.py b/common/tct-svg-html5-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-svg-html5-tests/inst.apk.py +++ b/common/tct-svg-html5-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-svg-html5-tests/inst.wgt.py b/common/tct-svg-html5-tests/inst.wgt.py index 5b1718da1..ab3c36308 100755 --- a/common/tct-svg-html5-tests/inst.wgt.py +++ b/common/tct-svg-html5-tests/inst.wgt.py @@ -1,230 +1,230 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t wgt -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t wgt -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t wgt -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t wgt -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-svg-html5-tests/inst.xpk.py b/common/tct-svg-html5-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-svg-html5-tests/inst.xpk.py +++ b/common/tct-svg-html5-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-svg-html5-tests/pack.py b/common/tct-svg-html5-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-svg-html5-tests/pack.py +++ b/common/tct-svg-html5-tests/pack.py @@ -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: diff --git a/common/tct-systeminfo-tizen-tests/inst.apk.py b/common/tct-systeminfo-tizen-tests/inst.apk.py index 31210db16..997d98f37 100755 --- a/common/tct-systeminfo-tizen-tests/inst.apk.py +++ b/common/tct-systeminfo-tizen-tests/inst.apk.py @@ -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: diff --git a/common/tct-systeminfo-tizen-tests/inst.wgt.py b/common/tct-systeminfo-tizen-tests/inst.wgt.py index 93ac8ad71..670f31e95 100755 --- a/common/tct-systeminfo-tizen-tests/inst.wgt.py +++ b/common/tct-systeminfo-tizen-tests/inst.wgt.py @@ -8,7 +8,7 @@ import sys import subprocess import string from optparse import OptionParser, make_option -import ConfigParser +import configparser SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) @@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR) PARAMETERS = None #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() +tct_parser = configparser.ConfigParser() tct_parser.read(TCT_CONFIG_FILE) SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) @@ -32,14 +32,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -190,8 +190,8 @@ def main(): "-a", dest="user", action="store", help="User name") global PARAMETERS (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) sys.exit(1) if not PARAMETERS.user: @@ -210,7 +210,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -222,10 +222,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: diff --git a/common/tct-systeminfo-tizen-tests/inst.xpk.py b/common/tct-systeminfo-tizen-tests/inst.xpk.py index 211d24c73..dccbae7e9 100755 --- a/common/tct-systeminfo-tizen-tests/inst.xpk.py +++ b/common/tct-systeminfo-tizen-tests/inst.xpk.py @@ -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: diff --git a/common/tct-systeminfo-tizen-tests/pack.py b/common/tct-systeminfo-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-systeminfo-tizen-tests/pack.py +++ b/common/tct-systeminfo-tizen-tests/pack.py @@ -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: diff --git a/common/tct-systemsetting-tizen-tests/inst.apk.py b/common/tct-systemsetting-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-systemsetting-tizen-tests/inst.apk.py +++ b/common/tct-systemsetting-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-systemsetting-tizen-tests/inst.wgt.py b/common/tct-systemsetting-tizen-tests/inst.wgt.py index f09fdf912..0089f81b2 100755 --- a/common/tct-systemsetting-tizen-tests/inst.wgt.py +++ b/common/tct-systemsetting-tizen-tests/inst.wgt.py @@ -1,238 +1,238 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - (return_code, output) = doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, PKG_NAME)) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - if not doRemoteCopy(os.path.join(SCRIPT_DIR, "mediasrc"), "%s/%s" % (SRC_DIR, PKG_NAME)): - action_status = False - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + (return_code, output) = doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, PKG_NAME)) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + if not doRemoteCopy(os.path.join(SCRIPT_DIR, "mediasrc"), "%s/%s" % (SRC_DIR, PKG_NAME)): + 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 as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-systemsetting-tizen-tests/inst.xpk.py b/common/tct-systemsetting-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-systemsetting-tizen-tests/inst.xpk.py +++ b/common/tct-systemsetting-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-systemsetting-tizen-tests/pack.py b/common/tct-systemsetting-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-systemsetting-tizen-tests/pack.py +++ b/common/tct-systemsetting-tizen-tests/pack.py @@ -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: diff --git a/common/tct-template-w3c-tests/inst.apk.py b/common/tct-template-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-template-w3c-tests/inst.apk.py +++ b/common/tct-template-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-template-w3c-tests/inst.wgt.py b/common/tct-template-w3c-tests/inst.wgt.py index d7b962bfa..0f5e3baa1 100755 --- a/common/tct-template-w3c-tests/inst.wgt.py +++ b/common/tct-template-w3c-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -189,8 +189,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: @@ -209,7 +209,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -221,10 +221,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: diff --git a/common/tct-template-w3c-tests/inst.xpk.py b/common/tct-template-w3c-tests/inst.xpk.py index a5295f0ab..a61db816d 100755 --- a/common/tct-template-w3c-tests/inst.xpk.py +++ b/common/tct-template-w3c-tests/inst.xpk.py @@ -1,228 +1,228 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -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" -SRC_DIR = "/home/app/content" -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "app" - 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 + + +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" +SRC_DIR = "/home/app/content" +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = "app" + 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) diff --git a/common/tct-template-w3c-tests/pack.py b/common/tct-template-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-template-w3c-tests/pack.py +++ b/common/tct-template-w3c-tests/pack.py @@ -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: diff --git a/common/tct-text-css3-tests/inst.apk.py b/common/tct-text-css3-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-text-css3-tests/inst.apk.py +++ b/common/tct-text-css3-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-text-css3-tests/inst.wgt.py b/common/tct-text-css3-tests/inst.wgt.py index 93ac8ad71..66eb23daa 100755 --- a/common/tct-text-css3-tests/inst.wgt.py +++ b/common/tct-text-css3-tests/inst.wgt.py @@ -1,240 +1,240 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-text-css3-tests/inst.xpk.py b/common/tct-text-css3-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-text-css3-tests/inst.xpk.py +++ b/common/tct-text-css3-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-text-css3-tests/pack.py b/common/tct-text-css3-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-text-css3-tests/pack.py +++ b/common/tct-text-css3-tests/pack.py @@ -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: diff --git a/common/tct-time-tizen-tests/inst.apk.py b/common/tct-time-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-time-tizen-tests/inst.apk.py +++ b/common/tct-time-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-time-tizen-tests/inst.wgt.py b/common/tct-time-tizen-tests/inst.wgt.py index 44e57cf17..5322534da 100755 --- a/common/tct-time-tizen-tests/inst.wgt.py +++ b/common/tct-time-tizen-tests/inst.wgt.py @@ -1,241 +1,241 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-time-tizen-tests/inst.xpk.py b/common/tct-time-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-time-tizen-tests/inst.xpk.py +++ b/common/tct-time-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-time-tizen-tests/pack.py b/common/tct-time-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-time-tizen-tests/pack.py +++ b/common/tct-time-tizen-tests/pack.py @@ -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: diff --git a/common/tct-tizen-tizen-tests/inst.apk.py b/common/tct-tizen-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-tizen-tizen-tests/inst.apk.py +++ b/common/tct-tizen-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-tizen-tizen-tests/inst.wgt.py b/common/tct-tizen-tizen-tests/inst.wgt.py index 93ac8ad71..66eb23daa 100755 --- a/common/tct-tizen-tizen-tests/inst.wgt.py +++ b/common/tct-tizen-tizen-tests/inst.wgt.py @@ -1,240 +1,240 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-tizen-tizen-tests/inst.xpk.py b/common/tct-tizen-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-tizen-tizen-tests/inst.xpk.py +++ b/common/tct-tizen-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-tizen-tizen-tests/pack.py b/common/tct-tizen-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-tizen-tizen-tests/pack.py +++ b/common/tct-tizen-tizen-tests/pack.py @@ -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: diff --git a/common/tct-touchevent-w3c-tests/inst.apk.py b/common/tct-touchevent-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-touchevent-w3c-tests/inst.apk.py +++ b/common/tct-touchevent-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-touchevent-w3c-tests/inst.wgt.py b/common/tct-touchevent-w3c-tests/inst.wgt.py index 93ac8ad71..66eb23daa 100755 --- a/common/tct-touchevent-w3c-tests/inst.wgt.py +++ b/common/tct-touchevent-w3c-tests/inst.wgt.py @@ -1,240 +1,240 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-touchevent-w3c-tests/inst.xpk.py b/common/tct-touchevent-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-touchevent-w3c-tests/inst.xpk.py +++ b/common/tct-touchevent-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-touchevent-w3c-tests/pack.py b/common/tct-touchevent-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-touchevent-w3c-tests/pack.py +++ b/common/tct-touchevent-w3c-tests/pack.py @@ -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: diff --git a/common/tct-transitions-css3-tests/inst.apk.py b/common/tct-transitions-css3-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-transitions-css3-tests/inst.apk.py +++ b/common/tct-transitions-css3-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-transitions-css3-tests/inst.wgt.py b/common/tct-transitions-css3-tests/inst.wgt.py index 8ed577c13..21f138a35 100755 --- a/common/tct-transitions-css3-tests/inst.wgt.py +++ b/common/tct-transitions-css3-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -189,8 +189,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: @@ -209,7 +209,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -221,10 +221,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: diff --git a/common/tct-transitions-css3-tests/inst.xpk.py b/common/tct-transitions-css3-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-transitions-css3-tests/inst.xpk.py +++ b/common/tct-transitions-css3-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-transitions-css3-tests/pack.py b/common/tct-transitions-css3-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-transitions-css3-tests/pack.py +++ b/common/tct-transitions-css3-tests/pack.py @@ -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: diff --git a/common/tct-tv-audiocontrol-tizen-tests/inst.apk.py b/common/tct-tv-audiocontrol-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-tv-audiocontrol-tizen-tests/inst.apk.py +++ b/common/tct-tv-audiocontrol-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-tv-audiocontrol-tizen-tests/inst.wgt.py b/common/tct-tv-audiocontrol-tizen-tests/inst.wgt.py index 54b678a51..54f3b9117 100755 --- a/common/tct-tv-audiocontrol-tizen-tests/inst.wgt.py +++ b/common/tct-tv-audiocontrol-tizen-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -188,8 +188,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: @@ -208,7 +208,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -220,10 +220,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: diff --git a/common/tct-tv-audiocontrol-tizen-tests/inst.xpk.py b/common/tct-tv-audiocontrol-tizen-tests/inst.xpk.py index 1835f7b99..9daf93e5b 100755 --- a/common/tct-tv-audiocontrol-tizen-tests/inst.xpk.py +++ b/common/tct-tv-audiocontrol-tizen-tests/inst.xpk.py @@ -1,226 +1,226 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -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" -SRC_DIR = "/home/app/content" -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - -# for file in files: -# if file.endswith(".xpk"): -# if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): -# action_status = False -# (return_code, output) = doRemoteCMD( -# "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) -# doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) -# for line in output: -# if "Failure" in line: -# action_status = False -# break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "app" - 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 + + +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" +SRC_DIR = "/home/app/content" +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + +# for file in files: +# if file.endswith(".xpk"): +# if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): +# action_status = False +# (return_code, output) = doRemoteCMD( +# "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) +# doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) +# for line in output: +# if "Failure" in line: +# action_status = False +# break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = "app" + 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) diff --git a/common/tct-tv-audiocontrol-tizen-tests/pack.py b/common/tct-tv-audiocontrol-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-tv-audiocontrol-tizen-tests/pack.py +++ b/common/tct-tv-audiocontrol-tizen-tests/pack.py @@ -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: diff --git a/common/tct-tv-channel-tizen-tests/inst.apk.py b/common/tct-tv-channel-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-tv-channel-tizen-tests/inst.apk.py +++ b/common/tct-tv-channel-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-tv-channel-tizen-tests/inst.wgt.py b/common/tct-tv-channel-tizen-tests/inst.wgt.py index 145211488..36be2eb51 100755 --- a/common/tct-tv-channel-tizen-tests/inst.wgt.py +++ b/common/tct-tv-channel-tizen-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -189,8 +189,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: @@ -209,7 +209,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -221,10 +221,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: diff --git a/common/tct-tv-channel-tizen-tests/inst.xpk.py b/common/tct-tv-channel-tizen-tests/inst.xpk.py index a5295f0ab..a61db816d 100755 --- a/common/tct-tv-channel-tizen-tests/inst.xpk.py +++ b/common/tct-tv-channel-tizen-tests/inst.xpk.py @@ -1,228 +1,228 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -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" -SRC_DIR = "/home/app/content" -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "app" - 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 + + +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" +SRC_DIR = "/home/app/content" +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = "app" + 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) diff --git a/common/tct-tv-channel-tizen-tests/pack.py b/common/tct-tv-channel-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-tv-channel-tizen-tests/pack.py +++ b/common/tct-tv-channel-tizen-tests/pack.py @@ -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: diff --git a/common/tct-tv-displaycontrol-tizen-tests/inst.apk.py b/common/tct-tv-displaycontrol-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-tv-displaycontrol-tizen-tests/inst.apk.py +++ b/common/tct-tv-displaycontrol-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-tv-displaycontrol-tizen-tests/inst.wgt.py b/common/tct-tv-displaycontrol-tizen-tests/inst.wgt.py index 145211488..36be2eb51 100755 --- a/common/tct-tv-displaycontrol-tizen-tests/inst.wgt.py +++ b/common/tct-tv-displaycontrol-tizen-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -189,8 +189,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: @@ -209,7 +209,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -221,10 +221,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: diff --git a/common/tct-tv-displaycontrol-tizen-tests/inst.xpk.py b/common/tct-tv-displaycontrol-tizen-tests/inst.xpk.py index d9ea2dfa9..8d40c52c3 100755 --- a/common/tct-tv-displaycontrol-tizen-tests/inst.xpk.py +++ b/common/tct-tv-displaycontrol-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -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" -SRC_DIR = "" -PKG_SRC_DIR = "" - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "app" - - global SRC_DIR, PKG_SRC_DIR - SRC_DIR = "/home/%s/content" % PARAMETERS.user - PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - 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 + + +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" +SRC_DIR = "" +PKG_SRC_DIR = "" + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = "app" + + global SRC_DIR, PKG_SRC_DIR + SRC_DIR = "/home/%s/content" % PARAMETERS.user + PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + 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) diff --git a/common/tct-tv-displaycontrol-tizen-tests/pack.py b/common/tct-tv-displaycontrol-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-tv-displaycontrol-tizen-tests/pack.py +++ b/common/tct-tv-displaycontrol-tizen-tests/pack.py @@ -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: diff --git a/common/tct-tv-info-tizen-tests/inst.apk.py b/common/tct-tv-info-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-tv-info-tizen-tests/inst.apk.py +++ b/common/tct-tv-info-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-tv-info-tizen-tests/inst.wgt.py b/common/tct-tv-info-tizen-tests/inst.wgt.py index a4eb99140..bb8ad4b67 100755 --- a/common/tct-tv-info-tizen-tests/inst.wgt.py +++ b/common/tct-tv-info-tizen-tests/inst.wgt.py @@ -8,7 +8,7 @@ import sys import subprocess import string from optparse import OptionParser, make_option -import ConfigParser +import configparser SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) @@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR) PARAMETERS = None #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() +tct_parser = configparser.ConfigParser() tct_parser.read(TCT_CONFIG_FILE) SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) @@ -32,14 +32,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -185,8 +185,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: @@ -205,7 +205,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -217,10 +217,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: diff --git a/common/tct-tv-info-tizen-tests/inst.xpk.py b/common/tct-tv-info-tizen-tests/inst.xpk.py index d9ea2dfa9..8d40c52c3 100755 --- a/common/tct-tv-info-tizen-tests/inst.xpk.py +++ b/common/tct-tv-info-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -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" -SRC_DIR = "" -PKG_SRC_DIR = "" - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "app" - - global SRC_DIR, PKG_SRC_DIR - SRC_DIR = "/home/%s/content" % PARAMETERS.user - PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - 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 + + +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" +SRC_DIR = "" +PKG_SRC_DIR = "" + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = "app" + + global SRC_DIR, PKG_SRC_DIR + SRC_DIR = "/home/%s/content" % PARAMETERS.user + PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + 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) diff --git a/common/tct-tv-info-tizen-tests/pack.py b/common/tct-tv-info-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-tv-info-tizen-tests/pack.py +++ b/common/tct-tv-info-tizen-tests/pack.py @@ -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: diff --git a/common/tct-tv-window-tizen-tests/inst.apk.py b/common/tct-tv-window-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-tv-window-tizen-tests/inst.apk.py +++ b/common/tct-tv-window-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-tv-window-tizen-tests/inst.wgt.py b/common/tct-tv-window-tizen-tests/inst.wgt.py index 2c16cb57b..d4f6ce479 100755 --- a/common/tct-tv-window-tizen-tests/inst.wgt.py +++ b/common/tct-tv-window-tizen-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -186,8 +186,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: @@ -206,7 +206,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -218,10 +218,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: diff --git a/common/tct-tv-window-tizen-tests/inst.xpk.py b/common/tct-tv-window-tizen-tests/inst.xpk.py index 1835f7b99..9daf93e5b 100755 --- a/common/tct-tv-window-tizen-tests/inst.xpk.py +++ b/common/tct-tv-window-tizen-tests/inst.xpk.py @@ -1,226 +1,226 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -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" -SRC_DIR = "/home/app/content" -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - -# for file in files: -# if file.endswith(".xpk"): -# if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): -# action_status = False -# (return_code, output) = doRemoteCMD( -# "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) -# doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) -# for line in output: -# if "Failure" in line: -# action_status = False -# break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "app" - 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 + + +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" +SRC_DIR = "/home/app/content" +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + +# for file in files: +# if file.endswith(".xpk"): +# if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): +# action_status = False +# (return_code, output) = doRemoteCMD( +# "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) +# doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) +# for line in output: +# if "Failure" in line: +# action_status = False +# break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = "app" + 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) diff --git a/common/tct-tv-window-tizen-tests/pack.py b/common/tct-tv-window-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-tv-window-tizen-tests/pack.py +++ b/common/tct-tv-window-tizen-tests/pack.py @@ -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: diff --git a/common/tct-typedarrays-nonw3c-tests/inst.apk.py b/common/tct-typedarrays-nonw3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-typedarrays-nonw3c-tests/inst.apk.py +++ b/common/tct-typedarrays-nonw3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-typedarrays-nonw3c-tests/inst.wgt.py b/common/tct-typedarrays-nonw3c-tests/inst.wgt.py index d7b962bfa..0f5e3baa1 100755 --- a/common/tct-typedarrays-nonw3c-tests/inst.wgt.py +++ b/common/tct-typedarrays-nonw3c-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -189,8 +189,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: @@ -209,7 +209,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -221,10 +221,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: diff --git a/common/tct-typedarrays-nonw3c-tests/inst.xpk.py b/common/tct-typedarrays-nonw3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-typedarrays-nonw3c-tests/inst.xpk.py +++ b/common/tct-typedarrays-nonw3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-typedarrays-nonw3c-tests/pack.py b/common/tct-typedarrays-nonw3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-typedarrays-nonw3c-tests/pack.py +++ b/common/tct-typedarrays-nonw3c-tests/pack.py @@ -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: diff --git a/common/tct-ui-css3-tests/inst.apk.py b/common/tct-ui-css3-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-ui-css3-tests/inst.apk.py +++ b/common/tct-ui-css3-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-ui-css3-tests/inst.wgt.py b/common/tct-ui-css3-tests/inst.wgt.py index 93ac8ad71..66eb23daa 100755 --- a/common/tct-ui-css3-tests/inst.wgt.py +++ b/common/tct-ui-css3-tests/inst.wgt.py @@ -1,240 +1,240 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-ui-css3-tests/inst.xpk.py b/common/tct-ui-css3-tests/inst.xpk.py index aa292c379..7dcd40d98 100755 --- a/common/tct-ui-css3-tests/inst.xpk.py +++ b/common/tct-ui-css3-tests/inst.xpk.py @@ -1,229 +1,229 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - -# for file in files: -# if file.endswith(".xpk"): -# if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): -# action_status = False -# (return_code, output) = doRemoteCMD( -# "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) -# doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) -# for line in output: -# if "Failure" in line: -# action_status = False -# break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + +# for file in files: +# if file.endswith(".xpk"): +# if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): +# action_status = False +# (return_code, output) = doRemoteCMD( +# "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) +# doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) +# for line in output: +# if "Failure" in line: +# action_status = False +# break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-ui-css3-tests/pack.py b/common/tct-ui-css3-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-ui-css3-tests/pack.py +++ b/common/tct-ui-css3-tests/pack.py @@ -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: diff --git a/common/tct-vibration-w3c-tests/inst.apk.py b/common/tct-vibration-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-vibration-w3c-tests/inst.apk.py +++ b/common/tct-vibration-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-vibration-w3c-tests/inst.wgt.py b/common/tct-vibration-w3c-tests/inst.wgt.py index 8ed577c13..21f138a35 100755 --- a/common/tct-vibration-w3c-tests/inst.wgt.py +++ b/common/tct-vibration-w3c-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -189,8 +189,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: @@ -209,7 +209,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -221,10 +221,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: diff --git a/common/tct-vibration-w3c-tests/inst.xpk.py b/common/tct-vibration-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-vibration-w3c-tests/inst.xpk.py +++ b/common/tct-vibration-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-vibration-w3c-tests/pack.py b/common/tct-vibration-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-vibration-w3c-tests/pack.py +++ b/common/tct-vibration-w3c-tests/pack.py @@ -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: diff --git a/common/tct-video-html5-tests/inst.apk.py b/common/tct-video-html5-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-video-html5-tests/inst.apk.py +++ b/common/tct-video-html5-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-video-html5-tests/inst.wgt.py b/common/tct-video-html5-tests/inst.wgt.py index d7b962bfa..0f5e3baa1 100755 --- a/common/tct-video-html5-tests/inst.wgt.py +++ b/common/tct-video-html5-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -189,8 +189,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: @@ -209,7 +209,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -221,10 +221,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: diff --git a/common/tct-video-html5-tests/inst.xpk.py b/common/tct-video-html5-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-video-html5-tests/inst.xpk.py +++ b/common/tct-video-html5-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-video-html5-tests/pack.py b/common/tct-video-html5-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-video-html5-tests/pack.py +++ b/common/tct-video-html5-tests/pack.py @@ -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: diff --git a/common/tct-voicecontrol-tizen-tests/inst.apk.py b/common/tct-voicecontrol-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-voicecontrol-tizen-tests/inst.apk.py +++ b/common/tct-voicecontrol-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-voicecontrol-tizen-tests/inst.wgt.py b/common/tct-voicecontrol-tizen-tests/inst.wgt.py index 257e5c264..bac23c006 100755 --- a/common/tct-voicecontrol-tizen-tests/inst.wgt.py +++ b/common/tct-voicecontrol-tizen-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -182,8 +182,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: @@ -202,7 +202,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -214,10 +214,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: diff --git a/common/tct-voicecontrol-tizen-tests/inst.xpk.py b/common/tct-voicecontrol-tizen-tests/inst.xpk.py index c0c358ecc..34a9d92c3 100755 --- a/common/tct-voicecontrol-tizen-tests/inst.xpk.py +++ b/common/tct-voicecontrol-tizen-tests/inst.xpk.py @@ -1,214 +1,214 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - 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 - - 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 + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + 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 + + 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 as 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) diff --git a/common/tct-voicecontrol-tizen-tests/pack.py b/common/tct-voicecontrol-tizen-tests/pack.py index 08d55aafe..92866ab2e 100755 --- a/common/tct-voicecontrol-tizen-tests/pack.py +++ b/common/tct-voicecontrol-tizen-tests/pack.py @@ -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: diff --git a/common/tct-webaudio-w3c-tests/inst.apk.py b/common/tct-webaudio-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-webaudio-w3c-tests/inst.apk.py +++ b/common/tct-webaudio-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-webaudio-w3c-tests/inst.wgt.py b/common/tct-webaudio-w3c-tests/inst.wgt.py index 93ac8ad71..66eb23daa 100755 --- a/common/tct-webaudio-w3c-tests/inst.wgt.py +++ b/common/tct-webaudio-w3c-tests/inst.wgt.py @@ -1,240 +1,240 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-webaudio-w3c-tests/inst.xpk.py b/common/tct-webaudio-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-webaudio-w3c-tests/inst.xpk.py +++ b/common/tct-webaudio-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-webaudio-w3c-tests/pack.py b/common/tct-webaudio-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-webaudio-w3c-tests/pack.py +++ b/common/tct-webaudio-w3c-tests/pack.py @@ -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: diff --git a/common/tct-webgl-nonw3c-tests/inst.apk.py b/common/tct-webgl-nonw3c-tests/inst.apk.py index 31210db16..997d98f37 100755 --- a/common/tct-webgl-nonw3c-tests/inst.apk.py +++ b/common/tct-webgl-nonw3c-tests/inst.apk.py @@ -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: diff --git a/common/tct-webgl-nonw3c-tests/inst.wgt.py b/common/tct-webgl-nonw3c-tests/inst.wgt.py index dd614f265..b30f310f4 100755 --- a/common/tct-webgl-nonw3c-tests/inst.wgt.py +++ b/common/tct-webgl-nonw3c-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -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) userCheck() @@ -215,10 +215,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: diff --git a/common/tct-webgl-nonw3c-tests/inst.xpk.py b/common/tct-webgl-nonw3c-tests/inst.xpk.py index 211d24c73..dccbae7e9 100755 --- a/common/tct-webgl-nonw3c-tests/inst.xpk.py +++ b/common/tct-webgl-nonw3c-tests/inst.xpk.py @@ -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: diff --git a/common/tct-webgl-nonw3c-tests/pack.py b/common/tct-webgl-nonw3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-webgl-nonw3c-tests/pack.py +++ b/common/tct-webgl-nonw3c-tests/pack.py @@ -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: diff --git a/common/tct-webmessaging-w3c-tests/inst.apk.py b/common/tct-webmessaging-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-webmessaging-w3c-tests/inst.apk.py +++ b/common/tct-webmessaging-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-webmessaging-w3c-tests/inst.wgt.py b/common/tct-webmessaging-w3c-tests/inst.wgt.py index 46b3b4aa3..44c1b3fec 100755 --- a/common/tct-webmessaging-w3c-tests/inst.wgt.py +++ b/common/tct-webmessaging-w3c-tests/inst.wgt.py @@ -1,234 +1,234 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - for item in glob.glob("%s/*" % SCRIPT_DIR): - if item.endswith(".wgt"): - continue - elif item.endswith("inst.py"): - continue - else: - item_name = os.path.basename(item) - if not doRemoteCopy(item, "%s/%s" % (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 = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + for item in glob.glob("%s/*" % SCRIPT_DIR): + if item.endswith(".wgt"): + continue + elif item.endswith("inst.py"): + continue + else: + item_name = os.path.basename(item) + if not doRemoteCopy(item, "%s/%s" % (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 as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-webmessaging-w3c-tests/inst.xpk.py b/common/tct-webmessaging-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-webmessaging-w3c-tests/inst.xpk.py +++ b/common/tct-webmessaging-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-webmessaging-w3c-tests/pack.py b/common/tct-webmessaging-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-webmessaging-w3c-tests/pack.py +++ b/common/tct-webmessaging-w3c-tests/pack.py @@ -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: diff --git a/common/tct-websetting-tizen-tests/inst.apk.py b/common/tct-websetting-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-websetting-tizen-tests/inst.apk.py +++ b/common/tct-websetting-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-websetting-tizen-tests/inst.wgt.py b/common/tct-websetting-tizen-tests/inst.wgt.py index 5b1718da1..ab3c36308 100755 --- a/common/tct-websetting-tizen-tests/inst.wgt.py +++ b/common/tct-websetting-tizen-tests/inst.wgt.py @@ -1,230 +1,230 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t wgt -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t wgt -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t wgt -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t wgt -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-websetting-tizen-tests/inst.xpk.py b/common/tct-websetting-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-websetting-tizen-tests/inst.xpk.py +++ b/common/tct-websetting-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-websetting-tizen-tests/pack.py b/common/tct-websetting-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-websetting-tizen-tests/pack.py +++ b/common/tct-websetting-tizen-tests/pack.py @@ -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: diff --git a/common/tct-websocket-w3c-tests/inst.apk.py b/common/tct-websocket-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-websocket-w3c-tests/inst.apk.py +++ b/common/tct-websocket-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-websocket-w3c-tests/inst.wgt.py b/common/tct-websocket-w3c-tests/inst.wgt.py index 9c17c1ad7..d442317ad 100755 --- a/common/tct-websocket-w3c-tests/inst.wgt.py +++ b/common/tct-websocket-w3c-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -185,8 +185,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: @@ -205,7 +205,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -217,10 +217,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: diff --git a/common/tct-websocket-w3c-tests/inst.xpk.py b/common/tct-websocket-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-websocket-w3c-tests/inst.xpk.py +++ b/common/tct-websocket-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-websocket-w3c-tests/pack.py b/common/tct-websocket-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-websocket-w3c-tests/pack.py +++ b/common/tct-websocket-w3c-tests/pack.py @@ -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: diff --git a/common/tct-webstorage-w3c-tests/inst.apk.py b/common/tct-webstorage-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-webstorage-w3c-tests/inst.apk.py +++ b/common/tct-webstorage-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-webstorage-w3c-tests/inst.wgt.py b/common/tct-webstorage-w3c-tests/inst.wgt.py index c7f89fd44..909755af3 100755 --- a/common/tct-webstorage-w3c-tests/inst.wgt.py +++ b/common/tct-webstorage-w3c-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -191,8 +191,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: @@ -211,7 +211,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -223,10 +223,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: diff --git a/common/tct-webstorage-w3c-tests/inst.xpk.py b/common/tct-webstorage-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-webstorage-w3c-tests/inst.xpk.py +++ b/common/tct-webstorage-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-webstorage-w3c-tests/pack.py b/common/tct-webstorage-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-webstorage-w3c-tests/pack.py +++ b/common/tct-webstorage-w3c-tests/pack.py @@ -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: diff --git a/common/tct-webwidget-w3c-tests/inst.apk.py b/common/tct-webwidget-w3c-tests/inst.apk.py index d5f9fbb96..d636bee03 100755 --- a/common/tct-webwidget-w3c-tests/inst.apk.py +++ b/common/tct-webwidget-w3c-tests/inst.apk.py @@ -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: diff --git a/common/tct-webwidget-w3c-tests/inst.wgt.py b/common/tct-webwidget-w3c-tests/inst.wgt.py index 31bd49daf..1c685e357 100755 --- a/common/tct-webwidget-w3c-tests/inst.wgt.py +++ b/common/tct-webwidget-w3c-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -195,8 +195,8 @@ def main(): "-a", dest="user", action="store", help="User name") global PARAMETERS (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) sys.exit(1) if not PARAMETERS.user: @@ -215,7 +215,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -227,10 +227,10 @@ def main(): userid = user_info[1][0] XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) else: - print "[Error] cmd commands error : %s"%str(user_info[1]) + print ("[Error] cmd commands error : %s" % str(user_info[1])) sys.exit(1) if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" + print ("-i and -u are conflict") sys.exit(1) if PARAMETERS.buninstpkg: diff --git a/common/tct-webwidget-w3c-tests/inst.xpk.py b/common/tct-webwidget-w3c-tests/inst.xpk.py index f70351a9b..ace8cbba9 100755 --- a/common/tct-webwidget-w3c-tests/inst.xpk.py +++ b/common/tct-webwidget-w3c-tests/inst.xpk.py @@ -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: diff --git a/common/tct-webwidget-w3c-tests/pack.py b/common/tct-webwidget-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-webwidget-w3c-tests/pack.py +++ b/common/tct-webwidget-w3c-tests/pack.py @@ -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: diff --git a/common/tct-wgtapi01-w3c-tests/inst.apk.py b/common/tct-wgtapi01-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-wgtapi01-w3c-tests/inst.apk.py +++ b/common/tct-wgtapi01-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-wgtapi01-w3c-tests/inst.wgt.py b/common/tct-wgtapi01-w3c-tests/inst.wgt.py index 9dff63be5..302423c2a 100755 --- a/common/tct-wgtapi01-w3c-tests/inst.wgt.py +++ b/common/tct-wgtapi01-w3c-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -187,8 +187,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: @@ -207,7 +207,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -219,10 +219,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: diff --git a/common/tct-wgtapi01-w3c-tests/inst.xpk.py b/common/tct-wgtapi01-w3c-tests/inst.xpk.py index 453aef60b..0f490f94c 100755 --- a/common/tct-wgtapi01-w3c-tests/inst.xpk.py +++ b/common/tct-wgtapi01-w3c-tests/inst.xpk.py @@ -1,222 +1,222 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - 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(PKG_NAME + ".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("inst.py"): - continue - else: - item_name = os.path.basename(item) - if not doRemoteCopy(item, "%s/%s" % (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 + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + 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(PKG_NAME + ".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("inst.py"): + continue + else: + item_name = os.path.basename(item) + if not doRemoteCopy(item, "%s/%s" % (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 as 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) diff --git a/common/tct-wgtapi01-w3c-tests/pack.py b/common/tct-wgtapi01-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-wgtapi01-w3c-tests/pack.py +++ b/common/tct-wgtapi01-w3c-tests/pack.py @@ -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: diff --git a/common/tct-wgtapi02-w3c-tests/inst.apk.py b/common/tct-wgtapi02-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-wgtapi02-w3c-tests/inst.apk.py +++ b/common/tct-wgtapi02-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-wgtapi02-w3c-tests/inst.wgt.py b/common/tct-wgtapi02-w3c-tests/inst.wgt.py index 145211488..36be2eb51 100755 --- a/common/tct-wgtapi02-w3c-tests/inst.wgt.py +++ b/common/tct-wgtapi02-w3c-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -189,8 +189,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: @@ -209,7 +209,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -221,10 +221,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: diff --git a/common/tct-wgtapi02-w3c-tests/inst.xpk.py b/common/tct-wgtapi02-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-wgtapi02-w3c-tests/inst.xpk.py +++ b/common/tct-wgtapi02-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-wgtapi02-w3c-tests/pack.py b/common/tct-wgtapi02-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-wgtapi02-w3c-tests/pack.py +++ b/common/tct-wgtapi02-w3c-tests/pack.py @@ -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: diff --git a/common/tct-widget01-w3c-tests/inst.apk.py b/common/tct-widget01-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-widget01-w3c-tests/inst.apk.py +++ b/common/tct-widget01-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-widget01-w3c-tests/inst.wgt.py b/common/tct-widget01-w3c-tests/inst.wgt.py index 9dff63be5..302423c2a 100755 --- a/common/tct-widget01-w3c-tests/inst.wgt.py +++ b/common/tct-widget01-w3c-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -187,8 +187,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: @@ -207,7 +207,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -219,10 +219,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: diff --git a/common/tct-widget01-w3c-tests/inst.xpk.py b/common/tct-widget01-w3c-tests/inst.xpk.py index 453aef60b..0f490f94c 100755 --- a/common/tct-widget01-w3c-tests/inst.xpk.py +++ b/common/tct-widget01-w3c-tests/inst.xpk.py @@ -1,222 +1,222 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - 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(PKG_NAME + ".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("inst.py"): - continue - else: - item_name = os.path.basename(item) - if not doRemoteCopy(item, "%s/%s" % (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 + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + 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(PKG_NAME + ".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("inst.py"): + continue + else: + item_name = os.path.basename(item) + if not doRemoteCopy(item, "%s/%s" % (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 as 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) diff --git a/common/tct-widget01-w3c-tests/pack.py b/common/tct-widget01-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-widget01-w3c-tests/pack.py +++ b/common/tct-widget01-w3c-tests/pack.py @@ -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: diff --git a/common/tct-widget02-w3c-tests/inst.apk.py b/common/tct-widget02-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-widget02-w3c-tests/inst.apk.py +++ b/common/tct-widget02-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-widget02-w3c-tests/inst.wgt.py b/common/tct-widget02-w3c-tests/inst.wgt.py index 31bd49daf..1c685e357 100755 --- a/common/tct-widget02-w3c-tests/inst.wgt.py +++ b/common/tct-widget02-w3c-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -195,8 +195,8 @@ def main(): "-a", dest="user", action="store", help="User name") global PARAMETERS (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) sys.exit(1) if not PARAMETERS.user: @@ -215,7 +215,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -227,10 +227,10 @@ def main(): userid = user_info[1][0] XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) else: - print "[Error] cmd commands error : %s"%str(user_info[1]) + print ("[Error] cmd commands error : %s" % str(user_info[1])) sys.exit(1) if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" + print ("-i and -u are conflict") sys.exit(1) if PARAMETERS.buninstpkg: diff --git a/common/tct-widget02-w3c-tests/inst.xpk.py b/common/tct-widget02-w3c-tests/inst.xpk.py index aa292c379..7dcd40d98 100755 --- a/common/tct-widget02-w3c-tests/inst.xpk.py +++ b/common/tct-widget02-w3c-tests/inst.xpk.py @@ -1,229 +1,229 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - -# for file in files: -# if file.endswith(".xpk"): -# if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): -# action_status = False -# (return_code, output) = doRemoteCMD( -# "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) -# doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) -# for line in output: -# if "Failure" in line: -# action_status = False -# break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + +# for file in files: +# if file.endswith(".xpk"): +# if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): +# action_status = False +# (return_code, output) = doRemoteCMD( +# "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) +# doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) +# for line in output: +# if "Failure" in line: +# action_status = False +# break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-widget02-w3c-tests/pack.py b/common/tct-widget02-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-widget02-w3c-tests/pack.py +++ b/common/tct-widget02-w3c-tests/pack.py @@ -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: diff --git a/common/tct-widgetpolicy-w3c-tests/inst.apk.py b/common/tct-widgetpolicy-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-widgetpolicy-w3c-tests/inst.apk.py +++ b/common/tct-widgetpolicy-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-widgetpolicy-w3c-tests/inst.wgt.py b/common/tct-widgetpolicy-w3c-tests/inst.wgt.py index 6d00172cd..138a08bfe 100755 --- a/common/tct-widgetpolicy-w3c-tests/inst.wgt.py +++ b/common/tct-widgetpolicy-w3c-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -188,8 +188,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: @@ -208,7 +208,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -220,10 +220,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: diff --git a/common/tct-widgetpolicy-w3c-tests/inst.xpk.py b/common/tct-widgetpolicy-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-widgetpolicy-w3c-tests/inst.xpk.py +++ b/common/tct-widgetpolicy-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-widgetpolicy-w3c-tests/pack.py b/common/tct-widgetpolicy-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-widgetpolicy-w3c-tests/pack.py +++ b/common/tct-widgetpolicy-w3c-tests/pack.py @@ -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: diff --git a/common/tct-widgetservice-tizen-tests/inst.apk.py b/common/tct-widgetservice-tizen-tests/inst.apk.py index d5f9fbb96..d636bee03 100755 --- a/common/tct-widgetservice-tizen-tests/inst.apk.py +++ b/common/tct-widgetservice-tizen-tests/inst.apk.py @@ -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: diff --git a/common/tct-widgetservice-tizen-tests/inst.wgt.py b/common/tct-widgetservice-tizen-tests/inst.wgt.py index 5e4c91713..3bcf73639 100755 --- a/common/tct-widgetservice-tizen-tests/inst.wgt.py +++ b/common/tct-widgetservice-tizen-tests/inst.wgt.py @@ -8,7 +8,7 @@ import sys import subprocess import string from optparse import OptionParser, make_option -import ConfigParser +import configparser SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) @@ -16,7 +16,7 @@ PKG_NAME = os.path.basename(SCRIPT_DIR) PARAMETERS = None #XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() +tct_parser = configparser.ConfigParser() tct_parser.read(TCT_CONFIG_FILE) SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) @@ -32,14 +32,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -190,8 +190,8 @@ def main(): "-a", dest="user", action="store", help="User name") global PARAMETERS (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) sys.exit(1) if not PARAMETERS.user: @@ -210,7 +210,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -222,10 +222,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: diff --git a/common/tct-widgetservice-tizen-tests/inst.xpk.py b/common/tct-widgetservice-tizen-tests/inst.xpk.py index f70351a9b..ace8cbba9 100755 --- a/common/tct-widgetservice-tizen-tests/inst.xpk.py +++ b/common/tct-widgetservice-tizen-tests/inst.xpk.py @@ -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: diff --git a/common/tct-widgetservice-tizen-tests/pack.py b/common/tct-widgetservice-tizen-tests/pack.py index c20c9326d..d725d5685 100755 --- a/common/tct-widgetservice-tizen-tests/pack.py +++ b/common/tct-widgetservice-tizen-tests/pack.py @@ -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: @@ -957,7 +957,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: diff --git a/common/tct-woff-w3c-tests/inst.apk.py b/common/tct-woff-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-woff-w3c-tests/inst.apk.py +++ b/common/tct-woff-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-woff-w3c-tests/inst.wgt.py b/common/tct-woff-w3c-tests/inst.wgt.py index d7b962bfa..0f5e3baa1 100755 --- a/common/tct-woff-w3c-tests/inst.wgt.py +++ b/common/tct-woff-w3c-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -189,8 +189,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: @@ -209,7 +209,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -221,10 +221,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: diff --git a/common/tct-woff-w3c-tests/inst.xpk.py b/common/tct-woff-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-woff-w3c-tests/inst.xpk.py +++ b/common/tct-woff-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-woff-w3c-tests/pack.py b/common/tct-woff-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-woff-w3c-tests/pack.py +++ b/common/tct-woff-w3c-tests/pack.py @@ -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: diff --git a/common/tct-workers-w3c-tests/inst.apk.py b/common/tct-workers-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-workers-w3c-tests/inst.apk.py +++ b/common/tct-workers-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-workers-w3c-tests/inst.wgt.py b/common/tct-workers-w3c-tests/inst.wgt.py index 225affe5a..b50fcca5d 100755 --- a/common/tct-workers-w3c-tests/inst.wgt.py +++ b/common/tct-workers-w3c-tests/inst.wgt.py @@ -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) @@ -29,18 +29,18 @@ def userCheck(): GLOVAL_OPT="--global" else: GLOVAL_OPT="" - + def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + 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 @@ -64,8 +64,6 @@ def getUSERID(): return doCMD(cmd) - - def getPKGID(pkg_name=None): if PARAMETERS.mode == "SDB": cmd = "sdb -s %s shell %s" % ( @@ -191,8 +189,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: @@ -211,7 +209,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -223,10 +221,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: diff --git a/common/tct-workers-w3c-tests/inst.xpk.py b/common/tct-workers-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-workers-w3c-tests/inst.xpk.py +++ b/common/tct-workers-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-workers-w3c-tests/pack.py b/common/tct-workers-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-workers-w3c-tests/pack.py +++ b/common/tct-workers-w3c-tests/pack.py @@ -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: diff --git a/common/tct-xmlhttprequest-w3c-tests/inst.apk.py b/common/tct-xmlhttprequest-w3c-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/common/tct-xmlhttprequest-w3c-tests/inst.apk.py +++ b/common/tct-xmlhttprequest-w3c-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/common/tct-xmlhttprequest-w3c-tests/inst.wgt.py b/common/tct-xmlhttprequest-w3c-tests/inst.wgt.py index 88104a59d..432dcbb17 100755 --- a/common/tct-xmlhttprequest-w3c-tests/inst.wgt.py +++ b/common/tct-xmlhttprequest-w3c-tests/inst.wgt.py @@ -1,239 +1,238 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) -EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') -ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') - -def userCheck(): - global GLOVAL_OPT - if ADMIN_USER_30 == EXECUTION_MODE_30: - GLOVAL_OPT="--global" - else: - GLOVAL_OPT="" - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - for file in files: - if file.endswith(".wgt"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - for file in files: - if file.endswith(".wgt"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - for item in glob.glob("%s/*" % SCRIPT_DIR): - if item.endswith(".wgt"): - continue - elif item.endswith("inst.py"): - continue - else: - item_name = os.path.basename(item) - if not doRemoteCopy(item, "%s/%s" % (PKG_SRC_DIR, item_name)): - #if not doRemoteCopy(item, PKG_SRC_DIR): - action_status = False - for item in glob.glob("%s/xmlhttprequest/w3c/resources/cgi/*" % SCRIPT_DIR): - item_name = os.path.basename(item) - if not doRemoteCopy(item, "%s/xmlhttprequest/w3c/resources/%s" % (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 = EXECUTION_MODE_30 - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - userCheck() - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) +EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') +ADMIN_USER_30 = tct_parser.get('DEVICE', 'DEVICE_ADMIN_USER_30') + +def userCheck(): + global GLOVAL_OPT + if ADMIN_USER_30 == EXECUTION_MODE_30: + GLOVAL_OPT="--global" + else: + GLOVAL_OPT="" + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + for file in files: + if file.endswith(".wgt"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd %s -u -t wgt -q -n %s" % (GLOVAL_OPT, pkg_id)) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + for file in files: + if file.endswith(".wgt"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd %s -i -t wgt -q -p %s/%s" % (GLOVAL_OPT, SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + for item in glob.glob("%s/*" % SCRIPT_DIR): + if item.endswith(".wgt"): + continue + elif item.endswith("inst.py"): + continue + else: + item_name = os.path.basename(item) + if not doRemoteCopy(item, "%s/%s" % (PKG_SRC_DIR, item_name)): + #if not doRemoteCopy(item, PKG_SRC_DIR): + action_status = False + for item in glob.glob("%s/xmlhttprequest/w3c/resources/cgi/*" % SCRIPT_DIR): + item_name = os.path.basename(item) + if not doRemoteCopy(item, "%s/xmlhttprequest/w3c/resources/%s" % (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 as e: + print ("Got wrong option: %s, exit ..." % e) + sys.exit(1) + + if not PARAMETERS.user: + PARAMETERS.user = EXECUTION_MODE_30 + if not PARAMETERS.mode: + PARAMETERS.mode = "SDB" + + if PARAMETERS.mode == "SDB": + if not PARAMETERS.device: + (return_code, output) = doCMD("sdb devices") + for line in output: + if str.find(line, "\tdevice") != -1: + PARAMETERS.device = line.split("\t")[0] + break + else: + PARAMETERS.mode = "SSH" + + if not PARAMETERS.device: + print ("No device provided") + sys.exit(1) + + userCheck() + + user_info = getUSERID() + re_code = user_info[0] + if re_code == 0 : + global XW_ENV + userid = user_info[1][0] + XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) + else: + print ("[Error] cmd commands error : %s" % str(user_info[1])) + sys.exit(1) + if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: + print ("-i and -u are conflict") + sys.exit(1) + + if PARAMETERS.buninstpkg: + if not uninstPKGs(): + sys.exit(1) + else: + if not instPKGs(): + sys.exit(1) + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/common/tct-xmlhttprequest-w3c-tests/inst.xpk.py b/common/tct-xmlhttprequest-w3c-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/common/tct-xmlhttprequest-w3c-tests/inst.xpk.py +++ b/common/tct-xmlhttprequest-w3c-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/common/tct-xmlhttprequest-w3c-tests/pack.py b/common/tct-xmlhttprequest-w3c-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/common/tct-xmlhttprequest-w3c-tests/pack.py +++ b/common/tct-xmlhttprequest-w3c-tests/pack.py @@ -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: diff --git a/iot/tct-capability-tests/inst.apk.py b/iot/tct-capability-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/iot/tct-capability-tests/inst.apk.py +++ b/iot/tct-capability-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/iot/tct-capability-tests/inst.wgt.py b/iot/tct-capability-tests/inst.wgt.py index ef38eb600..6e0726097 100755 --- a/iot/tct-capability-tests/inst.wgt.py +++ b/iot/tct-capability-tests/inst.wgt.py @@ -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 @@ -205,8 +205,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: @@ -225,7 +225,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -237,10 +237,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: diff --git a/iot/tct-capability-tests/inst.xpk.py b/iot/tct-capability-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/iot/tct-capability-tests/inst.xpk.py +++ b/iot/tct-capability-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/iot/tct-capability-tests/pack.py b/iot/tct-capability-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/iot/tct-capability-tests/pack.py +++ b/iot/tct-capability-tests/pack.py @@ -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: diff --git a/iot/tct-deprecatedapi-tizen-tests/inst.apk.py b/iot/tct-deprecatedapi-tizen-tests/inst.apk.py index 31210db16..d8019edc1 100755 --- a/iot/tct-deprecatedapi-tizen-tests/inst.apk.py +++ b/iot/tct-deprecatedapi-tizen-tests/inst.apk.py @@ -1,108 +1,108 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess from optparse import OptionParser, make_option -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, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def 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 + + +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, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def 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 as 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) diff --git a/iot/tct-deprecatedapi-tizen-tests/inst.wgt.py b/iot/tct-deprecatedapi-tizen-tests/inst.wgt.py index e32732b34..8e0d9ef1a 100755 --- a/iot/tct-deprecatedapi-tizen-tests/inst.wgt.py +++ b/iot/tct-deprecatedapi-tizen-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -188,8 +188,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: @@ -208,7 +208,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -220,10 +220,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: diff --git a/iot/tct-deprecatedapi-tizen-tests/inst.xpk.py b/iot/tct-deprecatedapi-tizen-tests/inst.xpk.py index 211d24c73..454919c67 100755 --- a/iot/tct-deprecatedapi-tizen-tests/inst.xpk.py +++ b/iot/tct-deprecatedapi-tizen-tests/inst.xpk.py @@ -1,231 +1,231 @@ -#!/usr/bin/env python - -import os -import shutil -import glob -import time -import sys -import subprocess -import string +#!/usr/bin/env python + +import os +import shutil +import glob +import time +import sys +import subprocess +import string from optparse import OptionParser, make_option -import ConfigParser - - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -PKG_NAME = os.path.basename(SCRIPT_DIR) -PARAMETERS = None -#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) -SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) - - -def doCMD(cmd): - # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd - output = [] - cmd_return_code = 1 - cmd_proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - - while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") - cmd_return_code = cmd_proc.poll() - if output_line == '' and cmd_return_code != None: - break - sys.stdout.write("%s\n" % output_line) - sys.stdout.flush() - output.append(output_line) - - return (cmd_return_code, output) - - -def updateCMD(cmd=None): - if "pkgcmd" in cmd: - cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) - return cmd -def getUSERID(): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell id -u %s" % ( - PARAMETERS.device, PARAMETERS.user) - else: - cmd = "ssh %s \"id -u %s\"" % ( - PARAMETERS.device, PARAMETERS.user ) - return doCMD(cmd) - - - - -def getPKGID(pkg_name=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - else: - cmd = "ssh %s \"%s\"" % ( - PARAMETERS.device, updateCMD('pkgcmd -l')) - - (return_code, output) = doCMD(cmd) - if return_code != 0: - return None - - test_pkg_id = None - for line in output: - if line.find("[" + pkg_name + "]") != -1: - pkgidIndex = line.split().index("pkgid") - test_pkg_id = line.split()[pkgidIndex+1].strip("[]") - break - return test_pkg_id - - -def doRemoteCMD(cmd=None): - if PARAMETERS.mode == "SDB": - cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) - else: - cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) - - return doCMD(cmd) - - -def doRemoteCopy(src=None, dest=None): - if PARAMETERS.mode == "SDB": - cmd_prefix = "sdb -s %s push" % PARAMETERS.device - cmd = "%s %s %s" % (cmd_prefix, src, dest) - else: - cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) - - (return_code, output) = doCMD(cmd) - doRemoteCMD("sync") - - if return_code != 0: - return True - else: - return False - - -def uninstPKGs(): - action_status = True - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) - if not pkg_id: - action_status = False - continue - (return_code, output) = doRemoteCMD( - "pkgcmd -u -t xpk -q -n %s" % pkg_id) - for line in output: - if "Failure" in line: - action_status = False - break - - (return_code, output) = doRemoteCMD( - "rm -rf %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - return action_status - - -def instPKGs(): - action_status = True - (return_code, output) = doRemoteCMD( - "mkdir -p %s" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - for root, dirs, files in os.walk(SCRIPT_DIR): - if root.endswith("mediasrc"): - continue - - for file in files: - if file.endswith(".xpk"): - if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): - action_status = False - (return_code, output) = doRemoteCMD( - "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) - doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) - for line in output: - if "Failure" in line: - action_status = False - break - - # Do some special copy/delete... steps - ''' - (return_code, output) = doRemoteCMD( - "mkdir -p %s/tests" % PKG_SRC_DIR) - if return_code != 0: - action_status = False - - if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): - action_status = False - ''' - - return action_status - - -def main(): - try: - usage = "usage: inst.py -i" - opts_parser = OptionParser(usage=usage) - opts_parser.add_option( - "-m", dest="mode", action="store", help="Specify mode") - opts_parser.add_option( - "-s", dest="device", action="store", help="Specify device") - opts_parser.add_option( - "-i", dest="binstpkg", action="store_true", help="Install package") - opts_parser.add_option( - "-u", dest="buninstpkg", action="store_true", help="Uninstall package") - opts_parser.add_option( - "-a", dest="user", action="store", help="User name") - global PARAMETERS - (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e - sys.exit(1) - - if not PARAMETERS.user: - PARAMETERS.user = "owner" - if not PARAMETERS.mode: - PARAMETERS.mode = "SDB" - - if PARAMETERS.mode == "SDB": - if not PARAMETERS.device: - (return_code, output) = doCMD("sdb devices") - for line in output: - if str.find(line, "\tdevice") != -1: - PARAMETERS.device = line.split("\t")[0] - break - else: - PARAMETERS.mode = "SSH" - - if not PARAMETERS.device: - print "No device provided" - sys.exit(1) - - user_info = getUSERID() - re_code = user_info[0] - if re_code == 0 : - global XW_ENV - userid = user_info[1][0] - XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) - else: - print "[Error] cmd commands error : %s"%str(user_info[1]) - sys.exit(1) - if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" - sys.exit(1) - - if PARAMETERS.buninstpkg: - if not uninstPKGs(): - sys.exit(1) - else: - if not instPKGs(): - sys.exit(1) - -if __name__ == "__main__": - main() - sys.exit(0) +import configparser + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +PKG_NAME = os.path.basename(SCRIPT_DIR) +PARAMETERS = None +#XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5000/dbus/user_bus_socket" +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) +SRC_DIR = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +PKG_SRC_DIR = "%s/tct/opt/%s" % (SRC_DIR, PKG_NAME) + + +def doCMD(cmd): + # Do not need handle timeout in this short script, let tool do it + print ("-->> \"%s\"" % cmd) + output = [] + cmd_return_code = 1 + cmd_proc = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + while True: + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") + cmd_return_code = cmd_proc.poll() + if output_line == '' and cmd_return_code != None: + break + sys.stdout.write("%s\n" % output_line) + sys.stdout.flush() + output.append(output_line) + + return (cmd_return_code, output) + + +def updateCMD(cmd=None): + if "pkgcmd" in cmd: + cmd = "su - %s -c '%s;%s'" % (PARAMETERS.user, XW_ENV, cmd) + return cmd +def getUSERID(): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell id -u %s" % ( + PARAMETERS.device, PARAMETERS.user) + else: + cmd = "ssh %s \"id -u %s\"" % ( + PARAMETERS.device, PARAMETERS.user ) + return doCMD(cmd) + + + + +def getPKGID(pkg_name=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + else: + cmd = "ssh %s \"%s\"" % ( + PARAMETERS.device, updateCMD('pkgcmd -l')) + + (return_code, output) = doCMD(cmd) + if return_code != 0: + return None + + test_pkg_id = None + for line in output: + if line.find("[" + pkg_name + "]") != -1: + pkgidIndex = line.split().index("pkgid") + test_pkg_id = line.split()[pkgidIndex+1].strip("[]") + break + return test_pkg_id + + +def doRemoteCMD(cmd=None): + if PARAMETERS.mode == "SDB": + cmd = "sdb -s %s shell %s" % (PARAMETERS.device, updateCMD(cmd)) + else: + cmd = "ssh %s \"%s\"" % (PARAMETERS.device, updateCMD(cmd)) + + return doCMD(cmd) + + +def doRemoteCopy(src=None, dest=None): + if PARAMETERS.mode == "SDB": + cmd_prefix = "sdb -s %s push" % PARAMETERS.device + cmd = "%s %s %s" % (cmd_prefix, src, dest) + else: + cmd = "scp -r %s %s:/%s" % (src, PARAMETERS.device, dest) + + (return_code, output) = doCMD(cmd) + doRemoteCMD("sync") + + if return_code != 0: + return True + else: + return False + + +def uninstPKGs(): + action_status = True + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + pkg_id = getPKGID(os.path.basename(os.path.splitext(file)[0])) + if not pkg_id: + action_status = False + continue + (return_code, output) = doRemoteCMD( + "pkgcmd -u -t xpk -q -n %s" % pkg_id) + for line in output: + if "Failure" in line: + action_status = False + break + + (return_code, output) = doRemoteCMD( + "rm -rf %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + return action_status + + +def instPKGs(): + action_status = True + (return_code, output) = doRemoteCMD( + "mkdir -p %s" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + for root, dirs, files in os.walk(SCRIPT_DIR): + if root.endswith("mediasrc"): + continue + + for file in files: + if file.endswith(".xpk"): + if not doRemoteCopy(os.path.join(root, file), "%s/%s" % (SRC_DIR, file)): + action_status = False + (return_code, output) = doRemoteCMD( + "pkgcmd -i -t xpk -q -p %s/%s" % (SRC_DIR, file)) + doRemoteCMD("rm -rf %s/%s" % (SRC_DIR, file)) + for line in output: + if "Failure" in line: + action_status = False + break + + # Do some special copy/delete... steps + ''' + (return_code, output) = doRemoteCMD( + "mkdir -p %s/tests" % PKG_SRC_DIR) + if return_code != 0: + action_status = False + + if not doRemoteCopy("specname/tests", "%s/tests" % PKG_SRC_DIR): + action_status = False + ''' + + return action_status + + +def main(): + try: + usage = "usage: inst.py -i" + opts_parser = OptionParser(usage=usage) + opts_parser.add_option( + "-m", dest="mode", action="store", help="Specify mode") + opts_parser.add_option( + "-s", dest="device", action="store", help="Specify device") + opts_parser.add_option( + "-i", dest="binstpkg", action="store_true", help="Install package") + opts_parser.add_option( + "-u", dest="buninstpkg", action="store_true", help="Uninstall package") + opts_parser.add_option( + "-a", dest="user", action="store", help="User name") + global PARAMETERS + (PARAMETERS, args) = opts_parser.parse_args() + except Exception as 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) diff --git a/iot/tct-deprecatedapi-tizen-tests/pack.py b/iot/tct-deprecatedapi-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/iot/tct-deprecatedapi-tizen-tests/pack.py +++ b/iot/tct-deprecatedapi-tizen-tests/pack.py @@ -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: diff --git a/ivi/tct-2dtransforms-css3-tests/inst.apk.py b/ivi/tct-2dtransforms-css3-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-2dtransforms-css3-tests/inst.apk.py +++ b/ivi/tct-2dtransforms-css3-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-2dtransforms-css3-tests/inst.wgt.py b/ivi/tct-2dtransforms-css3-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-2dtransforms-css3-tests/inst.wgt.py +++ b/ivi/tct-2dtransforms-css3-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-2dtransforms-css3-tests/inst.xpk.py b/ivi/tct-2dtransforms-css3-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-2dtransforms-css3-tests/inst.xpk.py +++ b/ivi/tct-2dtransforms-css3-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-3dtransforms-css3-tests/inst.apk.py b/ivi/tct-3dtransforms-css3-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-3dtransforms-css3-tests/inst.apk.py +++ b/ivi/tct-3dtransforms-css3-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-3dtransforms-css3-tests/inst.wgt.py b/ivi/tct-3dtransforms-css3-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-3dtransforms-css3-tests/inst.wgt.py +++ b/ivi/tct-3dtransforms-css3-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-3dtransforms-css3-tests/inst.xpk.py b/ivi/tct-3dtransforms-css3-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-3dtransforms-css3-tests/inst.xpk.py +++ b/ivi/tct-3dtransforms-css3-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-alarm-tizen-tests/inst.apk.py b/ivi/tct-alarm-tizen-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-alarm-tizen-tests/inst.apk.py +++ b/ivi/tct-alarm-tizen-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-alarm-tizen-tests/inst.wgt.py b/ivi/tct-alarm-tizen-tests/inst.wgt.py index 9b50ab82d..905410740 100755 --- a/ivi/tct-alarm-tizen-tests/inst.wgt.py +++ b/ivi/tct-alarm-tizen-tests/inst.wgt.py @@ -20,14 +20,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 @@ -160,8 +160,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: @@ -180,7 +180,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -190,10 +190,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: diff --git a/ivi/tct-alarm-tizen-tests/inst.xpk.py b/ivi/tct-alarm-tizen-tests/inst.xpk.py index 2b58ff607..635947096 100755 --- a/ivi/tct-alarm-tizen-tests/inst.xpk.py +++ b/ivi/tct-alarm-tizen-tests/inst.xpk.py @@ -20,14 +20,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 @@ -162,8 +162,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: @@ -182,7 +182,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -192,10 +192,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: diff --git a/ivi/tct-animations-css3-tests/inst.apk.py b/ivi/tct-animations-css3-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-animations-css3-tests/inst.apk.py +++ b/ivi/tct-animations-css3-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-animations-css3-tests/inst.wgt.py b/ivi/tct-animations-css3-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-animations-css3-tests/inst.wgt.py +++ b/ivi/tct-animations-css3-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-animations-css3-tests/inst.xpk.py b/ivi/tct-animations-css3-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-animations-css3-tests/inst.xpk.py +++ b/ivi/tct-animations-css3-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-animationtiming-w3c-tests/inst.apk.py b/ivi/tct-animationtiming-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-animationtiming-w3c-tests/inst.apk.py +++ b/ivi/tct-animationtiming-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-animationtiming-w3c-tests/inst.wgt.py b/ivi/tct-animationtiming-w3c-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-animationtiming-w3c-tests/inst.wgt.py +++ b/ivi/tct-animationtiming-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-animationtiming-w3c-tests/inst.xpk.py b/ivi/tct-animationtiming-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-animationtiming-w3c-tests/inst.xpk.py +++ b/ivi/tct-animationtiming-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-appcache-html5-tests/inst.apk.py b/ivi/tct-appcache-html5-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-appcache-html5-tests/inst.apk.py +++ b/ivi/tct-appcache-html5-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-appcache-html5-tests/inst.wgt.py b/ivi/tct-appcache-html5-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-appcache-html5-tests/inst.wgt.py +++ b/ivi/tct-appcache-html5-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-appcache-html5-tests/inst.xpk.py b/ivi/tct-appcache-html5-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-appcache-html5-tests/inst.xpk.py +++ b/ivi/tct-appcache-html5-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-appcontrol-tizen-tests/inst.apk.py b/ivi/tct-appcontrol-tizen-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-appcontrol-tizen-tests/inst.apk.py +++ b/ivi/tct-appcontrol-tizen-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-appcontrol-tizen-tests/inst.wgt.py b/ivi/tct-appcontrol-tizen-tests/inst.wgt.py index f328736e3..3a6af9945 100755 --- a/ivi/tct-appcontrol-tizen-tests/inst.wgt.py +++ b/ivi/tct-appcontrol-tizen-tests/inst.wgt.py @@ -20,14 +20,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 @@ -175,8 +175,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: @@ -195,7 +195,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -205,10 +205,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: diff --git a/ivi/tct-appcontrol-tizen-tests/inst.xpk.py b/ivi/tct-appcontrol-tizen-tests/inst.xpk.py index 7fd565644..68a7a7cb4 100755 --- a/ivi/tct-appcontrol-tizen-tests/inst.xpk.py +++ b/ivi/tct-appcontrol-tizen-tests/inst.xpk.py @@ -20,14 +20,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 @@ -175,8 +175,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: @@ -195,7 +195,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -205,10 +205,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: diff --git a/ivi/tct-application-tizen-tests/inst.apk.py b/ivi/tct-application-tizen-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-application-tizen-tests/inst.apk.py +++ b/ivi/tct-application-tizen-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-application-tizen-tests/inst.wgt.py b/ivi/tct-application-tizen-tests/inst.wgt.py index 24141f7f4..ec7da2954 100755 --- a/ivi/tct-application-tizen-tests/inst.wgt.py +++ b/ivi/tct-application-tizen-tests/inst.wgt.py @@ -20,14 +20,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 @@ -177,8 +177,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: @@ -197,7 +197,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -207,10 +207,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: diff --git a/ivi/tct-application-tizen-tests/inst.xpk.py b/ivi/tct-application-tizen-tests/inst.xpk.py index ccd694af4..fbe31c492 100755 --- a/ivi/tct-application-tizen-tests/inst.xpk.py +++ b/ivi/tct-application-tizen-tests/inst.xpk.py @@ -20,14 +20,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 @@ -177,8 +177,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: @@ -197,7 +197,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -207,10 +207,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: diff --git a/ivi/tct-audio-html5-tests/inst.apk.py b/ivi/tct-audio-html5-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-audio-html5-tests/inst.apk.py +++ b/ivi/tct-audio-html5-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-audio-html5-tests/inst.wgt.py b/ivi/tct-audio-html5-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-audio-html5-tests/inst.wgt.py +++ b/ivi/tct-audio-html5-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-audio-html5-tests/inst.xpk.py b/ivi/tct-audio-html5-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-audio-html5-tests/inst.xpk.py +++ b/ivi/tct-audio-html5-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-backgrounds-css3-tests/inst.apk.py b/ivi/tct-backgrounds-css3-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-backgrounds-css3-tests/inst.apk.py +++ b/ivi/tct-backgrounds-css3-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-backgrounds-css3-tests/inst.wgt.py b/ivi/tct-backgrounds-css3-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-backgrounds-css3-tests/inst.wgt.py +++ b/ivi/tct-backgrounds-css3-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-backgrounds-css3-tests/inst.xpk.py b/ivi/tct-backgrounds-css3-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-backgrounds-css3-tests/inst.xpk.py +++ b/ivi/tct-backgrounds-css3-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-bluetooth-tizen-tests/inst.apk.py b/ivi/tct-bluetooth-tizen-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-bluetooth-tizen-tests/inst.apk.py +++ b/ivi/tct-bluetooth-tizen-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-bluetooth-tizen-tests/inst.wgt.py b/ivi/tct-bluetooth-tizen-tests/inst.wgt.py index d26375e71..59454337a 100755 --- a/ivi/tct-bluetooth-tizen-tests/inst.wgt.py +++ b/ivi/tct-bluetooth-tizen-tests/inst.wgt.py @@ -20,14 +20,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 @@ -162,8 +162,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: @@ -182,7 +182,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -192,10 +192,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: diff --git a/ivi/tct-bluetooth-tizen-tests/inst.xpk.py b/ivi/tct-bluetooth-tizen-tests/inst.xpk.py index 2b58ff607..635947096 100755 --- a/ivi/tct-bluetooth-tizen-tests/inst.xpk.py +++ b/ivi/tct-bluetooth-tizen-tests/inst.xpk.py @@ -20,14 +20,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 @@ -162,8 +162,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: @@ -182,7 +182,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -192,10 +192,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: diff --git a/ivi/tct-bookmark-tizen-tests/inst.apk.py b/ivi/tct-bookmark-tizen-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-bookmark-tizen-tests/inst.apk.py +++ b/ivi/tct-bookmark-tizen-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-bookmark-tizen-tests/inst.wgt.py b/ivi/tct-bookmark-tizen-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-bookmark-tizen-tests/inst.wgt.py +++ b/ivi/tct-bookmark-tizen-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-bookmark-tizen-tests/inst.xpk.py b/ivi/tct-bookmark-tizen-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-bookmark-tizen-tests/inst.xpk.py +++ b/ivi/tct-bookmark-tizen-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-browserstate-html5-tests/inst.apk.py b/ivi/tct-browserstate-html5-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-browserstate-html5-tests/inst.apk.py +++ b/ivi/tct-browserstate-html5-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-browserstate-html5-tests/inst.wgt.py b/ivi/tct-browserstate-html5-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-browserstate-html5-tests/inst.wgt.py +++ b/ivi/tct-browserstate-html5-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-browserstate-html5-tests/inst.xpk.py b/ivi/tct-browserstate-html5-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-browserstate-html5-tests/inst.xpk.py +++ b/ivi/tct-browserstate-html5-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-canvas-html5-tests/inst.apk.py b/ivi/tct-canvas-html5-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-canvas-html5-tests/inst.apk.py +++ b/ivi/tct-canvas-html5-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-canvas-html5-tests/inst.wgt.py b/ivi/tct-canvas-html5-tests/inst.wgt.py index 43f110bce..617c1f44c 100755 --- a/ivi/tct-canvas-html5-tests/inst.wgt.py +++ b/ivi/tct-canvas-html5-tests/inst.wgt.py @@ -20,14 +20,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 @@ -172,8 +172,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: @@ -192,7 +192,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -202,10 +202,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: diff --git a/ivi/tct-canvas-html5-tests/inst.xpk.py b/ivi/tct-canvas-html5-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-canvas-html5-tests/inst.xpk.py +++ b/ivi/tct-canvas-html5-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-capability-tests/inst.apk.py b/ivi/tct-capability-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-capability-tests/inst.apk.py +++ b/ivi/tct-capability-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-capability-tests/inst.wgt.py b/ivi/tct-capability-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-capability-tests/inst.wgt.py +++ b/ivi/tct-capability-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-capability-tests/inst.xpk.py b/ivi/tct-capability-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-capability-tests/inst.xpk.py +++ b/ivi/tct-capability-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-clipboard-w3c-tests/inst.apk.py b/ivi/tct-clipboard-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-clipboard-w3c-tests/inst.apk.py +++ b/ivi/tct-clipboard-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-clipboard-w3c-tests/inst.wgt.py b/ivi/tct-clipboard-w3c-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-clipboard-w3c-tests/inst.wgt.py +++ b/ivi/tct-clipboard-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-clipboard-w3c-tests/inst.xpk.py b/ivi/tct-clipboard-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-clipboard-w3c-tests/inst.xpk.py +++ b/ivi/tct-clipboard-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-colors-css3-tests/inst.apk.py b/ivi/tct-colors-css3-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-colors-css3-tests/inst.apk.py +++ b/ivi/tct-colors-css3-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-colors-css3-tests/inst.wgt.py b/ivi/tct-colors-css3-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-colors-css3-tests/inst.wgt.py +++ b/ivi/tct-colors-css3-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-colors-css3-tests/inst.xpk.py b/ivi/tct-colors-css3-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-colors-css3-tests/inst.xpk.py +++ b/ivi/tct-colors-css3-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-content-tizen-tests/inst.apk.py b/ivi/tct-content-tizen-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-content-tizen-tests/inst.apk.py +++ b/ivi/tct-content-tizen-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-content-tizen-tests/inst.wgt.py b/ivi/tct-content-tizen-tests/inst.wgt.py index 9cf8713a3..99d1a488c 100755 --- a/ivi/tct-content-tizen-tests/inst.wgt.py +++ b/ivi/tct-content-tizen-tests/inst.wgt.py @@ -20,14 +20,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 @@ -169,8 +169,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: @@ -189,7 +189,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -199,10 +199,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: diff --git a/ivi/tct-content-tizen-tests/inst.xpk.py b/ivi/tct-content-tizen-tests/inst.xpk.py index 489c5efc9..9604d7898 100755 --- a/ivi/tct-content-tizen-tests/inst.xpk.py +++ b/ivi/tct-content-tizen-tests/inst.xpk.py @@ -20,14 +20,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 @@ -169,8 +169,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: @@ -189,7 +189,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -199,10 +199,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: diff --git a/ivi/tct-cors-w3c-tests/inst.apk.py b/ivi/tct-cors-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-cors-w3c-tests/inst.apk.py +++ b/ivi/tct-cors-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-cors-w3c-tests/inst.wgt.py b/ivi/tct-cors-w3c-tests/inst.wgt.py index e4ea5495f..89d4de707 100755 --- a/ivi/tct-cors-w3c-tests/inst.wgt.py +++ b/ivi/tct-cors-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -177,8 +177,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: @@ -197,7 +197,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -207,10 +207,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: diff --git a/ivi/tct-cors-w3c-tests/inst.xpk.py b/ivi/tct-cors-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-cors-w3c-tests/inst.xpk.py +++ b/ivi/tct-cors-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-csp-w3c-tests/inst.apk.py b/ivi/tct-csp-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-csp-w3c-tests/inst.apk.py +++ b/ivi/tct-csp-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-csp-w3c-tests/inst.wgt.py b/ivi/tct-csp-w3c-tests/inst.wgt.py index a7ea7b578..109ff4430 100755 --- a/ivi/tct-csp-w3c-tests/inst.wgt.py +++ b/ivi/tct-csp-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -172,8 +172,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: @@ -192,7 +192,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -202,10 +202,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: diff --git a/ivi/tct-csp-w3c-tests/inst.xpk.py b/ivi/tct-csp-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-csp-w3c-tests/inst.xpk.py +++ b/ivi/tct-csp-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-dnd-html5-tests/inst.apk.py b/ivi/tct-dnd-html5-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-dnd-html5-tests/inst.apk.py +++ b/ivi/tct-dnd-html5-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-dnd-html5-tests/inst.wgt.py b/ivi/tct-dnd-html5-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-dnd-html5-tests/inst.wgt.py +++ b/ivi/tct-dnd-html5-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-dnd-html5-tests/inst.xpk.py b/ivi/tct-dnd-html5-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-dnd-html5-tests/inst.xpk.py +++ b/ivi/tct-dnd-html5-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-download-tizen-tests/inst.apk.py b/ivi/tct-download-tizen-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-download-tizen-tests/inst.apk.py +++ b/ivi/tct-download-tizen-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-download-tizen-tests/inst.wgt.py b/ivi/tct-download-tizen-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-download-tizen-tests/inst.wgt.py +++ b/ivi/tct-download-tizen-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-download-tizen-tests/inst.xpk.py b/ivi/tct-download-tizen-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-download-tizen-tests/inst.xpk.py +++ b/ivi/tct-download-tizen-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-extra-html5-tests/inst.apk.py b/ivi/tct-extra-html5-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-extra-html5-tests/inst.apk.py +++ b/ivi/tct-extra-html5-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-extra-html5-tests/inst.wgt.py b/ivi/tct-extra-html5-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-extra-html5-tests/inst.wgt.py +++ b/ivi/tct-extra-html5-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-extra-html5-tests/inst.xpk.py b/ivi/tct-extra-html5-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-extra-html5-tests/inst.xpk.py +++ b/ivi/tct-extra-html5-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-fileapi-w3c-tests/inst.apk.py b/ivi/tct-fileapi-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-fileapi-w3c-tests/inst.apk.py +++ b/ivi/tct-fileapi-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-fileapi-w3c-tests/inst.wgt.py b/ivi/tct-fileapi-w3c-tests/inst.wgt.py index 43f110bce..617c1f44c 100755 --- a/ivi/tct-fileapi-w3c-tests/inst.wgt.py +++ b/ivi/tct-fileapi-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -172,8 +172,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: @@ -192,7 +192,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -202,10 +202,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: diff --git a/ivi/tct-fileapi-w3c-tests/inst.xpk.py b/ivi/tct-fileapi-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-fileapi-w3c-tests/inst.xpk.py +++ b/ivi/tct-fileapi-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-filesystem-tizen-tests/inst.apk.py b/ivi/tct-filesystem-tizen-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-filesystem-tizen-tests/inst.apk.py +++ b/ivi/tct-filesystem-tizen-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-filesystem-tizen-tests/inst.wgt.py b/ivi/tct-filesystem-tizen-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-filesystem-tizen-tests/inst.wgt.py +++ b/ivi/tct-filesystem-tizen-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-filesystem-tizen-tests/inst.xpk.py b/ivi/tct-filesystem-tizen-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-filesystem-tizen-tests/inst.xpk.py +++ b/ivi/tct-filesystem-tizen-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-filesystemapi-w3c-tests/inst.apk.py b/ivi/tct-filesystemapi-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-filesystemapi-w3c-tests/inst.apk.py +++ b/ivi/tct-filesystemapi-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-filesystemapi-w3c-tests/inst.wgt.py b/ivi/tct-filesystemapi-w3c-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-filesystemapi-w3c-tests/inst.wgt.py +++ b/ivi/tct-filesystemapi-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-filesystemapi-w3c-tests/inst.xpk.py b/ivi/tct-filesystemapi-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-filesystemapi-w3c-tests/inst.xpk.py +++ b/ivi/tct-filesystemapi-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-filewriterapi-w3c-tests/inst.apk.py b/ivi/tct-filewriterapi-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-filewriterapi-w3c-tests/inst.apk.py +++ b/ivi/tct-filewriterapi-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-filewriterapi-w3c-tests/inst.wgt.py b/ivi/tct-filewriterapi-w3c-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-filewriterapi-w3c-tests/inst.wgt.py +++ b/ivi/tct-filewriterapi-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-filewriterapi-w3c-tests/inst.xpk.py b/ivi/tct-filewriterapi-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-filewriterapi-w3c-tests/inst.xpk.py +++ b/ivi/tct-filewriterapi-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-flexiblebox-css3-tests/inst.apk.py b/ivi/tct-flexiblebox-css3-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-flexiblebox-css3-tests/inst.apk.py +++ b/ivi/tct-flexiblebox-css3-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-flexiblebox-css3-tests/inst.wgt.py b/ivi/tct-flexiblebox-css3-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-flexiblebox-css3-tests/inst.wgt.py +++ b/ivi/tct-flexiblebox-css3-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-flexiblebox-css3-tests/inst.xpk.py b/ivi/tct-flexiblebox-css3-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-flexiblebox-css3-tests/inst.xpk.py +++ b/ivi/tct-flexiblebox-css3-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-fonts-css3-tests/inst.apk.py b/ivi/tct-fonts-css3-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-fonts-css3-tests/inst.apk.py +++ b/ivi/tct-fonts-css3-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-fonts-css3-tests/inst.wgt.py b/ivi/tct-fonts-css3-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-fonts-css3-tests/inst.wgt.py +++ b/ivi/tct-fonts-css3-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-fonts-css3-tests/inst.xpk.py b/ivi/tct-fonts-css3-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-fonts-css3-tests/inst.xpk.py +++ b/ivi/tct-fonts-css3-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-forms-html5-tests/inst.apk.py b/ivi/tct-forms-html5-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-forms-html5-tests/inst.apk.py +++ b/ivi/tct-forms-html5-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-forms-html5-tests/inst.wgt.py b/ivi/tct-forms-html5-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-forms-html5-tests/inst.wgt.py +++ b/ivi/tct-forms-html5-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-forms-html5-tests/inst.xpk.py b/ivi/tct-forms-html5-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-forms-html5-tests/inst.xpk.py +++ b/ivi/tct-forms-html5-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-fullscreen-nonw3c-tests/inst.apk.py b/ivi/tct-fullscreen-nonw3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-fullscreen-nonw3c-tests/inst.apk.py +++ b/ivi/tct-fullscreen-nonw3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-fullscreen-nonw3c-tests/inst.wgt.py b/ivi/tct-fullscreen-nonw3c-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-fullscreen-nonw3c-tests/inst.wgt.py +++ b/ivi/tct-fullscreen-nonw3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-fullscreen-nonw3c-tests/inst.xpk.py b/ivi/tct-fullscreen-nonw3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-fullscreen-nonw3c-tests/inst.xpk.py +++ b/ivi/tct-fullscreen-nonw3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-geoallow-w3c-tests/inst.apk.py b/ivi/tct-geoallow-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-geoallow-w3c-tests/inst.apk.py +++ b/ivi/tct-geoallow-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-geoallow-w3c-tests/inst.wgt.py b/ivi/tct-geoallow-w3c-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-geoallow-w3c-tests/inst.wgt.py +++ b/ivi/tct-geoallow-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-geoallow-w3c-tests/inst.xpk.py b/ivi/tct-geoallow-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-geoallow-w3c-tests/inst.xpk.py +++ b/ivi/tct-geoallow-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-geodeny-w3c-tests/inst.apk.py b/ivi/tct-geodeny-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-geodeny-w3c-tests/inst.apk.py +++ b/ivi/tct-geodeny-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-geodeny-w3c-tests/inst.wgt.py b/ivi/tct-geodeny-w3c-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-geodeny-w3c-tests/inst.wgt.py +++ b/ivi/tct-geodeny-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-geodeny-w3c-tests/inst.xpk.py b/ivi/tct-geodeny-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-geodeny-w3c-tests/inst.xpk.py +++ b/ivi/tct-geodeny-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-getcapabilities/inst.apk.py b/ivi/tct-getcapabilities/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-getcapabilities/inst.apk.py +++ b/ivi/tct-getcapabilities/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-getcapabilities/inst.wgt.py b/ivi/tct-getcapabilities/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-getcapabilities/inst.wgt.py +++ b/ivi/tct-getcapabilities/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-getcapabilities/inst.xpk.py b/ivi/tct-getcapabilities/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-getcapabilities/inst.xpk.py +++ b/ivi/tct-getcapabilities/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-gumallow-w3c-tests/inst.apk.py b/ivi/tct-gumallow-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-gumallow-w3c-tests/inst.apk.py +++ b/ivi/tct-gumallow-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-gumallow-w3c-tests/inst.wgt.py b/ivi/tct-gumallow-w3c-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-gumallow-w3c-tests/inst.wgt.py +++ b/ivi/tct-gumallow-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-gumallow-w3c-tests/inst.xpk.py b/ivi/tct-gumallow-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-gumallow-w3c-tests/inst.xpk.py +++ b/ivi/tct-gumallow-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-indexeddb-w3c-tests/inst.apk.py b/ivi/tct-indexeddb-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-indexeddb-w3c-tests/inst.apk.py +++ b/ivi/tct-indexeddb-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-indexeddb-w3c-tests/inst.wgt.py b/ivi/tct-indexeddb-w3c-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-indexeddb-w3c-tests/inst.wgt.py +++ b/ivi/tct-indexeddb-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-indexeddb-w3c-tests/inst.xpk.py b/ivi/tct-indexeddb-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-indexeddb-w3c-tests/inst.xpk.py +++ b/ivi/tct-indexeddb-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-jsenhance-html5-tests/inst.apk.py b/ivi/tct-jsenhance-html5-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-jsenhance-html5-tests/inst.apk.py +++ b/ivi/tct-jsenhance-html5-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-jsenhance-html5-tests/inst.wgt.py b/ivi/tct-jsenhance-html5-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-jsenhance-html5-tests/inst.wgt.py +++ b/ivi/tct-jsenhance-html5-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-jsenhance-html5-tests/inst.xpk.py b/ivi/tct-jsenhance-html5-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-jsenhance-html5-tests/inst.xpk.py +++ b/ivi/tct-jsenhance-html5-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-mediaqueries-css3-tests/inst.apk.py b/ivi/tct-mediaqueries-css3-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-mediaqueries-css3-tests/inst.apk.py +++ b/ivi/tct-mediaqueries-css3-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-mediaqueries-css3-tests/inst.wgt.py b/ivi/tct-mediaqueries-css3-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-mediaqueries-css3-tests/inst.wgt.py +++ b/ivi/tct-mediaqueries-css3-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-mediaqueries-css3-tests/inst.xpk.py b/ivi/tct-mediaqueries-css3-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-mediaqueries-css3-tests/inst.xpk.py +++ b/ivi/tct-mediaqueries-css3-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-messageport-tizen-tests/inst.apk.py b/ivi/tct-messageport-tizen-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-messageport-tizen-tests/inst.apk.py +++ b/ivi/tct-messageport-tizen-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-messageport-tizen-tests/inst.wgt.py b/ivi/tct-messageport-tizen-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-messageport-tizen-tests/inst.wgt.py +++ b/ivi/tct-messageport-tizen-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-messageport-tizen-tests/inst.xpk.py b/ivi/tct-messageport-tizen-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-messageport-tizen-tests/inst.xpk.py +++ b/ivi/tct-messageport-tizen-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-multicolumn-css3-tests/inst.apk.py b/ivi/tct-multicolumn-css3-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-multicolumn-css3-tests/inst.apk.py +++ b/ivi/tct-multicolumn-css3-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-multicolumn-css3-tests/inst.wgt.py b/ivi/tct-multicolumn-css3-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-multicolumn-css3-tests/inst.wgt.py +++ b/ivi/tct-multicolumn-css3-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-multicolumn-css3-tests/inst.xpk.py b/ivi/tct-multicolumn-css3-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-multicolumn-css3-tests/inst.xpk.py +++ b/ivi/tct-multicolumn-css3-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-namespace-tizen-tests/inst.apk.py b/ivi/tct-namespace-tizen-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-namespace-tizen-tests/inst.apk.py +++ b/ivi/tct-namespace-tizen-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-namespace-tizen-tests/inst.wgt.py b/ivi/tct-namespace-tizen-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-namespace-tizen-tests/inst.wgt.py +++ b/ivi/tct-namespace-tizen-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-namespace-tizen-tests/inst.xpk.py b/ivi/tct-namespace-tizen-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-namespace-tizen-tests/inst.xpk.py +++ b/ivi/tct-namespace-tizen-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-navigationtiming-w3c-tests/inst.apk.py b/ivi/tct-navigationtiming-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-navigationtiming-w3c-tests/inst.apk.py +++ b/ivi/tct-navigationtiming-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-navigationtiming-w3c-tests/inst.wgt.py b/ivi/tct-navigationtiming-w3c-tests/inst.wgt.py index 43f110bce..617c1f44c 100755 --- a/ivi/tct-navigationtiming-w3c-tests/inst.wgt.py +++ b/ivi/tct-navigationtiming-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -172,8 +172,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: @@ -192,7 +192,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -202,10 +202,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: diff --git a/ivi/tct-navigationtiming-w3c-tests/inst.xpk.py b/ivi/tct-navigationtiming-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-navigationtiming-w3c-tests/inst.xpk.py +++ b/ivi/tct-navigationtiming-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-notification-tizen-tests/inst.apk.py b/ivi/tct-notification-tizen-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-notification-tizen-tests/inst.apk.py +++ b/ivi/tct-notification-tizen-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-notification-tizen-tests/inst.wgt.py b/ivi/tct-notification-tizen-tests/inst.wgt.py index 58fa04cbf..ceefce39d 100755 --- a/ivi/tct-notification-tizen-tests/inst.wgt.py +++ b/ivi/tct-notification-tizen-tests/inst.wgt.py @@ -20,14 +20,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 @@ -184,8 +184,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: @@ -204,7 +204,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -214,10 +214,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: diff --git a/ivi/tct-notification-tizen-tests/inst.xpk.py b/ivi/tct-notification-tizen-tests/inst.xpk.py index 24c306935..1d56a7d91 100755 --- a/ivi/tct-notification-tizen-tests/inst.xpk.py +++ b/ivi/tct-notification-tizen-tests/inst.xpk.py @@ -20,14 +20,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 @@ -184,8 +184,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: @@ -204,7 +204,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -214,10 +214,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: diff --git a/ivi/tct-notification-w3c-tests/inst.apk.py b/ivi/tct-notification-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-notification-w3c-tests/inst.apk.py +++ b/ivi/tct-notification-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-notification-w3c-tests/inst.wgt.py b/ivi/tct-notification-w3c-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-notification-w3c-tests/inst.wgt.py +++ b/ivi/tct-notification-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-notification-w3c-tests/inst.xpk.py b/ivi/tct-notification-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-notification-w3c-tests/inst.xpk.py +++ b/ivi/tct-notification-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-package-tizen-tests/inst.apk.py b/ivi/tct-package-tizen-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-package-tizen-tests/inst.apk.py +++ b/ivi/tct-package-tizen-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-package-tizen-tests/inst.wgt.py b/ivi/tct-package-tizen-tests/inst.wgt.py index 6fce2fba5..3f6a9265e 100755 --- a/ivi/tct-package-tizen-tests/inst.wgt.py +++ b/ivi/tct-package-tizen-tests/inst.wgt.py @@ -20,14 +20,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 @@ -176,8 +176,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: @@ -196,7 +196,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -206,10 +206,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: diff --git a/ivi/tct-package-tizen-tests/inst.xpk.py b/ivi/tct-package-tizen-tests/inst.xpk.py index 25ce6831d..3ec8311ff 100755 --- a/ivi/tct-package-tizen-tests/inst.xpk.py +++ b/ivi/tct-package-tizen-tests/inst.xpk.py @@ -20,14 +20,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 @@ -176,8 +176,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: @@ -196,7 +196,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -206,10 +206,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: diff --git a/ivi/tct-pagevisibility-w3c-tests/inst.apk.py b/ivi/tct-pagevisibility-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-pagevisibility-w3c-tests/inst.apk.py +++ b/ivi/tct-pagevisibility-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-pagevisibility-w3c-tests/inst.wgt.py b/ivi/tct-pagevisibility-w3c-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-pagevisibility-w3c-tests/inst.wgt.py +++ b/ivi/tct-pagevisibility-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-pagevisibility-w3c-tests/inst.xpk.py b/ivi/tct-pagevisibility-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-pagevisibility-w3c-tests/inst.xpk.py +++ b/ivi/tct-pagevisibility-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-power-tizen-tests/inst.apk.py b/ivi/tct-power-tizen-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-power-tizen-tests/inst.apk.py +++ b/ivi/tct-power-tizen-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-power-tizen-tests/inst.wgt.py b/ivi/tct-power-tizen-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-power-tizen-tests/inst.wgt.py +++ b/ivi/tct-power-tizen-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-power-tizen-tests/inst.xpk.py b/ivi/tct-power-tizen-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-power-tizen-tests/inst.xpk.py +++ b/ivi/tct-power-tizen-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-privilege-tizen-tests/inst.apk.py b/ivi/tct-privilege-tizen-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-privilege-tizen-tests/inst.apk.py +++ b/ivi/tct-privilege-tizen-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-privilege-tizen-tests/inst.wgt.py b/ivi/tct-privilege-tizen-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-privilege-tizen-tests/inst.wgt.py +++ b/ivi/tct-privilege-tizen-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-privilege-tizen-tests/inst.xpk.py b/ivi/tct-privilege-tizen-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-privilege-tizen-tests/inst.xpk.py +++ b/ivi/tct-privilege-tizen-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-sandbox-html5-tests/inst.apk.py b/ivi/tct-sandbox-html5-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-sandbox-html5-tests/inst.apk.py +++ b/ivi/tct-sandbox-html5-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-sandbox-html5-tests/inst.wgt.py b/ivi/tct-sandbox-html5-tests/inst.wgt.py index 43f110bce..617c1f44c 100755 --- a/ivi/tct-sandbox-html5-tests/inst.wgt.py +++ b/ivi/tct-sandbox-html5-tests/inst.wgt.py @@ -20,14 +20,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 @@ -172,8 +172,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: @@ -192,7 +192,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -202,10 +202,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: diff --git a/ivi/tct-sandbox-html5-tests/inst.xpk.py b/ivi/tct-sandbox-html5-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-sandbox-html5-tests/inst.xpk.py +++ b/ivi/tct-sandbox-html5-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-screenorientation-w3c-tests/inst.apk.py b/ivi/tct-screenorientation-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-screenorientation-w3c-tests/inst.apk.py +++ b/ivi/tct-screenorientation-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-screenorientation-w3c-tests/inst.wgt.py b/ivi/tct-screenorientation-w3c-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-screenorientation-w3c-tests/inst.wgt.py +++ b/ivi/tct-screenorientation-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-screenorientation-w3c-tests/inst.xpk.py b/ivi/tct-screenorientation-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-screenorientation-w3c-tests/inst.xpk.py +++ b/ivi/tct-screenorientation-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-security-tcs-tests/inst.apk.py b/ivi/tct-security-tcs-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-security-tcs-tests/inst.apk.py +++ b/ivi/tct-security-tcs-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-security-tcs-tests/inst.wgt.py b/ivi/tct-security-tcs-tests/inst.wgt.py index d26375e71..59454337a 100755 --- a/ivi/tct-security-tcs-tests/inst.wgt.py +++ b/ivi/tct-security-tcs-tests/inst.wgt.py @@ -20,14 +20,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 @@ -162,8 +162,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: @@ -182,7 +182,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -192,10 +192,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: diff --git a/ivi/tct-security-tcs-tests/inst.xpk.py b/ivi/tct-security-tcs-tests/inst.xpk.py index 2b58ff607..635947096 100755 --- a/ivi/tct-security-tcs-tests/inst.xpk.py +++ b/ivi/tct-security-tcs-tests/inst.xpk.py @@ -20,14 +20,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 @@ -162,8 +162,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: @@ -182,7 +182,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -192,10 +192,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: diff --git a/ivi/tct-selectorslevel1-w3c-tests/inst.apk.py b/ivi/tct-selectorslevel1-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-selectorslevel1-w3c-tests/inst.apk.py +++ b/ivi/tct-selectorslevel1-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-selectorslevel1-w3c-tests/inst.wgt.py b/ivi/tct-selectorslevel1-w3c-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-selectorslevel1-w3c-tests/inst.wgt.py +++ b/ivi/tct-selectorslevel1-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-selectorslevel1-w3c-tests/inst.xpk.py b/ivi/tct-selectorslevel1-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-selectorslevel1-w3c-tests/inst.xpk.py +++ b/ivi/tct-selectorslevel1-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-selectorslevel2-w3c-tests/inst.apk.py b/ivi/tct-selectorslevel2-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-selectorslevel2-w3c-tests/inst.apk.py +++ b/ivi/tct-selectorslevel2-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-selectorslevel2-w3c-tests/inst.wgt.py b/ivi/tct-selectorslevel2-w3c-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-selectorslevel2-w3c-tests/inst.wgt.py +++ b/ivi/tct-selectorslevel2-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-selectorslevel2-w3c-tests/inst.xpk.py b/ivi/tct-selectorslevel2-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-selectorslevel2-w3c-tests/inst.xpk.py +++ b/ivi/tct-selectorslevel2-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-sessionhistory-html5-tests/inst.apk.py b/ivi/tct-sessionhistory-html5-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-sessionhistory-html5-tests/inst.apk.py +++ b/ivi/tct-sessionhistory-html5-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-sessionhistory-html5-tests/inst.wgt.py b/ivi/tct-sessionhistory-html5-tests/inst.wgt.py index c21cdecda..f11e570b7 100755 --- a/ivi/tct-sessionhistory-html5-tests/inst.wgt.py +++ b/ivi/tct-sessionhistory-html5-tests/inst.wgt.py @@ -20,14 +20,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 @@ -177,8 +177,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: @@ -197,7 +197,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -207,10 +207,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: diff --git a/ivi/tct-sessionhistory-html5-tests/inst.xpk.py b/ivi/tct-sessionhistory-html5-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-sessionhistory-html5-tests/inst.xpk.py +++ b/ivi/tct-sessionhistory-html5-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-sse-w3c-tests/inst.apk.py b/ivi/tct-sse-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-sse-w3c-tests/inst.apk.py +++ b/ivi/tct-sse-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-sse-w3c-tests/inst.wgt.py b/ivi/tct-sse-w3c-tests/inst.wgt.py index afef62e72..ebb8353d1 100755 --- a/ivi/tct-sse-w3c-tests/inst.wgt.py +++ b/ivi/tct-sse-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -180,8 +180,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: @@ -200,7 +200,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -210,10 +210,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: diff --git a/ivi/tct-sse-w3c-tests/inst.xpk.py b/ivi/tct-sse-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-sse-w3c-tests/inst.xpk.py +++ b/ivi/tct-sse-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-svg-html5-tests/inst.apk.py b/ivi/tct-svg-html5-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-svg-html5-tests/inst.apk.py +++ b/ivi/tct-svg-html5-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-svg-html5-tests/inst.wgt.py b/ivi/tct-svg-html5-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-svg-html5-tests/inst.wgt.py +++ b/ivi/tct-svg-html5-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-svg-html5-tests/inst.xpk.py b/ivi/tct-svg-html5-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-svg-html5-tests/inst.xpk.py +++ b/ivi/tct-svg-html5-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-systeminfo-tizen-tests/inst.apk.py b/ivi/tct-systeminfo-tizen-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-systeminfo-tizen-tests/inst.apk.py +++ b/ivi/tct-systeminfo-tizen-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-systeminfo-tizen-tests/inst.wgt.py b/ivi/tct-systeminfo-tizen-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-systeminfo-tizen-tests/inst.wgt.py +++ b/ivi/tct-systeminfo-tizen-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-systeminfo-tizen-tests/inst.xpk.py b/ivi/tct-systeminfo-tizen-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-systeminfo-tizen-tests/inst.xpk.py +++ b/ivi/tct-systeminfo-tizen-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-systemsetting-tizen-tests/inst.apk.py b/ivi/tct-systemsetting-tizen-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-systemsetting-tizen-tests/inst.apk.py +++ b/ivi/tct-systemsetting-tizen-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-systemsetting-tizen-tests/inst.wgt.py b/ivi/tct-systemsetting-tizen-tests/inst.wgt.py index e7aeac9ec..f2417bdad 100755 --- a/ivi/tct-systemsetting-tizen-tests/inst.wgt.py +++ b/ivi/tct-systemsetting-tizen-tests/inst.wgt.py @@ -20,14 +20,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 @@ -169,8 +169,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: @@ -189,7 +189,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -199,10 +199,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: diff --git a/ivi/tct-systemsetting-tizen-tests/inst.xpk.py b/ivi/tct-systemsetting-tizen-tests/inst.xpk.py index 8a8ed798d..cadbfcc44 100755 --- a/ivi/tct-systemsetting-tizen-tests/inst.xpk.py +++ b/ivi/tct-systemsetting-tizen-tests/inst.xpk.py @@ -20,14 +20,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 @@ -169,8 +169,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: @@ -189,7 +189,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -199,10 +199,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: diff --git a/ivi/tct-testconfig/inst.apk.py b/ivi/tct-testconfig/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-testconfig/inst.apk.py +++ b/ivi/tct-testconfig/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-testconfig/inst.wgt.py b/ivi/tct-testconfig/inst.wgt.py index 183d9078e..87ca4d612 100755 --- a/ivi/tct-testconfig/inst.wgt.py +++ b/ivi/tct-testconfig/inst.wgt.py @@ -20,14 +20,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 @@ -139,8 +139,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: @@ -159,7 +159,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -169,10 +169,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: diff --git a/ivi/tct-testconfig/inst.xpk.py b/ivi/tct-testconfig/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-testconfig/inst.xpk.py +++ b/ivi/tct-testconfig/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-time-tizen-tests/inst.apk.py b/ivi/tct-time-tizen-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-time-tizen-tests/inst.apk.py +++ b/ivi/tct-time-tizen-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-time-tizen-tests/inst.wgt.py b/ivi/tct-time-tizen-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-time-tizen-tests/inst.wgt.py +++ b/ivi/tct-time-tizen-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-time-tizen-tests/inst.xpk.py b/ivi/tct-time-tizen-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-time-tizen-tests/inst.xpk.py +++ b/ivi/tct-time-tizen-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-tizen-tizen-tests/inst.apk.py b/ivi/tct-tizen-tizen-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-tizen-tizen-tests/inst.apk.py +++ b/ivi/tct-tizen-tizen-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-tizen-tizen-tests/inst.wgt.py b/ivi/tct-tizen-tizen-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-tizen-tizen-tests/inst.wgt.py +++ b/ivi/tct-tizen-tizen-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-tizen-tizen-tests/inst.xpk.py b/ivi/tct-tizen-tizen-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-tizen-tizen-tests/inst.xpk.py +++ b/ivi/tct-tizen-tizen-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-touchevent-w3c-tests/inst.apk.py b/ivi/tct-touchevent-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-touchevent-w3c-tests/inst.apk.py +++ b/ivi/tct-touchevent-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-touchevent-w3c-tests/inst.wgt.py b/ivi/tct-touchevent-w3c-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-touchevent-w3c-tests/inst.wgt.py +++ b/ivi/tct-touchevent-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-touchevent-w3c-tests/inst.xpk.py b/ivi/tct-touchevent-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-touchevent-w3c-tests/inst.xpk.py +++ b/ivi/tct-touchevent-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-transitions-css3-tests/inst.apk.py b/ivi/tct-transitions-css3-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-transitions-css3-tests/inst.apk.py +++ b/ivi/tct-transitions-css3-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-transitions-css3-tests/inst.wgt.py b/ivi/tct-transitions-css3-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-transitions-css3-tests/inst.wgt.py +++ b/ivi/tct-transitions-css3-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-transitions-css3-tests/inst.xpk.py b/ivi/tct-transitions-css3-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-transitions-css3-tests/inst.xpk.py +++ b/ivi/tct-transitions-css3-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-typedarrays-nonw3c-tests/inst.apk.py b/ivi/tct-typedarrays-nonw3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-typedarrays-nonw3c-tests/inst.apk.py +++ b/ivi/tct-typedarrays-nonw3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-typedarrays-nonw3c-tests/inst.wgt.py b/ivi/tct-typedarrays-nonw3c-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-typedarrays-nonw3c-tests/inst.wgt.py +++ b/ivi/tct-typedarrays-nonw3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-typedarrays-nonw3c-tests/inst.xpk.py b/ivi/tct-typedarrays-nonw3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-typedarrays-nonw3c-tests/inst.xpk.py +++ b/ivi/tct-typedarrays-nonw3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-ui-css3-tests/inst.apk.py b/ivi/tct-ui-css3-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-ui-css3-tests/inst.apk.py +++ b/ivi/tct-ui-css3-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-ui-css3-tests/inst.wgt.py b/ivi/tct-ui-css3-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-ui-css3-tests/inst.wgt.py +++ b/ivi/tct-ui-css3-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-ui-css3-tests/inst.xpk.py b/ivi/tct-ui-css3-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-ui-css3-tests/inst.xpk.py +++ b/ivi/tct-ui-css3-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-video-html5-tests/inst.apk.py b/ivi/tct-video-html5-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-video-html5-tests/inst.apk.py +++ b/ivi/tct-video-html5-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-video-html5-tests/inst.wgt.py b/ivi/tct-video-html5-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-video-html5-tests/inst.wgt.py +++ b/ivi/tct-video-html5-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-video-html5-tests/inst.xpk.py b/ivi/tct-video-html5-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-video-html5-tests/inst.xpk.py +++ b/ivi/tct-video-html5-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-webaudio-w3c-tests/inst.apk.py b/ivi/tct-webaudio-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-webaudio-w3c-tests/inst.apk.py +++ b/ivi/tct-webaudio-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-webaudio-w3c-tests/inst.wgt.py b/ivi/tct-webaudio-w3c-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-webaudio-w3c-tests/inst.wgt.py +++ b/ivi/tct-webaudio-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-webaudio-w3c-tests/inst.xpk.py b/ivi/tct-webaudio-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-webaudio-w3c-tests/inst.xpk.py +++ b/ivi/tct-webaudio-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-webdatabase-w3c-tests/inst.apk.py b/ivi/tct-webdatabase-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-webdatabase-w3c-tests/inst.apk.py +++ b/ivi/tct-webdatabase-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-webdatabase-w3c-tests/inst.wgt.py b/ivi/tct-webdatabase-w3c-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-webdatabase-w3c-tests/inst.wgt.py +++ b/ivi/tct-webdatabase-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-webdatabase-w3c-tests/inst.xpk.py b/ivi/tct-webdatabase-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-webdatabase-w3c-tests/inst.xpk.py +++ b/ivi/tct-webdatabase-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-webgl-nonw3c-tests/inst.apk.py b/ivi/tct-webgl-nonw3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-webgl-nonw3c-tests/inst.apk.py +++ b/ivi/tct-webgl-nonw3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-webgl-nonw3c-tests/inst.wgt.py b/ivi/tct-webgl-nonw3c-tests/inst.wgt.py index 43f110bce..617c1f44c 100755 --- a/ivi/tct-webgl-nonw3c-tests/inst.wgt.py +++ b/ivi/tct-webgl-nonw3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -172,8 +172,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: @@ -192,7 +192,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -202,10 +202,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: diff --git a/ivi/tct-webgl-nonw3c-tests/inst.xpk.py b/ivi/tct-webgl-nonw3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-webgl-nonw3c-tests/inst.xpk.py +++ b/ivi/tct-webgl-nonw3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-webmessaging-w3c-tests/inst.apk.py b/ivi/tct-webmessaging-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-webmessaging-w3c-tests/inst.apk.py +++ b/ivi/tct-webmessaging-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-webmessaging-w3c-tests/inst.wgt.py b/ivi/tct-webmessaging-w3c-tests/inst.wgt.py index 43f110bce..617c1f44c 100755 --- a/ivi/tct-webmessaging-w3c-tests/inst.wgt.py +++ b/ivi/tct-webmessaging-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -172,8 +172,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: @@ -192,7 +192,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -202,10 +202,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: diff --git a/ivi/tct-webmessaging-w3c-tests/inst.xpk.py b/ivi/tct-webmessaging-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-webmessaging-w3c-tests/inst.xpk.py +++ b/ivi/tct-webmessaging-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-websetting-tizen-tests/inst.apk.py b/ivi/tct-websetting-tizen-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-websetting-tizen-tests/inst.apk.py +++ b/ivi/tct-websetting-tizen-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-websetting-tizen-tests/inst.wgt.py b/ivi/tct-websetting-tizen-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-websetting-tizen-tests/inst.wgt.py +++ b/ivi/tct-websetting-tizen-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-websetting-tizen-tests/inst.xpk.py b/ivi/tct-websetting-tizen-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-websetting-tizen-tests/inst.xpk.py +++ b/ivi/tct-websetting-tizen-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-websocket-w3c-tests/inst.apk.py b/ivi/tct-websocket-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-websocket-w3c-tests/inst.apk.py +++ b/ivi/tct-websocket-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-websocket-w3c-tests/inst.wgt.py b/ivi/tct-websocket-w3c-tests/inst.wgt.py index 43f110bce..617c1f44c 100755 --- a/ivi/tct-websocket-w3c-tests/inst.wgt.py +++ b/ivi/tct-websocket-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -172,8 +172,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: @@ -192,7 +192,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -202,10 +202,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: diff --git a/ivi/tct-websocket-w3c-tests/inst.xpk.py b/ivi/tct-websocket-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-websocket-w3c-tests/inst.xpk.py +++ b/ivi/tct-websocket-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-webstorage-w3c-tests/inst.apk.py b/ivi/tct-webstorage-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-webstorage-w3c-tests/inst.apk.py +++ b/ivi/tct-webstorage-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-webstorage-w3c-tests/inst.wgt.py b/ivi/tct-webstorage-w3c-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-webstorage-w3c-tests/inst.wgt.py +++ b/ivi/tct-webstorage-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-webstorage-w3c-tests/inst.xpk.py b/ivi/tct-webstorage-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-webstorage-w3c-tests/inst.xpk.py +++ b/ivi/tct-webstorage-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-wgtapi01-w3c-tests/inst.apk.py b/ivi/tct-wgtapi01-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-wgtapi01-w3c-tests/inst.apk.py +++ b/ivi/tct-wgtapi01-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-wgtapi01-w3c-tests/inst.wgt.py b/ivi/tct-wgtapi01-w3c-tests/inst.wgt.py index fedb04beb..5b9572769 100755 --- a/ivi/tct-wgtapi01-w3c-tests/inst.wgt.py +++ b/ivi/tct-wgtapi01-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -170,8 +170,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: @@ -190,7 +190,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -200,10 +200,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: diff --git a/ivi/tct-wgtapi01-w3c-tests/inst.xpk.py b/ivi/tct-wgtapi01-w3c-tests/inst.xpk.py index 8e14d7da5..60a188baa 100755 --- a/ivi/tct-wgtapi01-w3c-tests/inst.xpk.py +++ b/ivi/tct-wgtapi01-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -170,8 +170,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: @@ -190,7 +190,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -200,10 +200,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: diff --git a/ivi/tct-wgtapi02-w3c-tests/inst.apk.py b/ivi/tct-wgtapi02-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-wgtapi02-w3c-tests/inst.apk.py +++ b/ivi/tct-wgtapi02-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-wgtapi02-w3c-tests/inst.wgt.py b/ivi/tct-wgtapi02-w3c-tests/inst.wgt.py index 43f110bce..617c1f44c 100755 --- a/ivi/tct-wgtapi02-w3c-tests/inst.wgt.py +++ b/ivi/tct-wgtapi02-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -172,8 +172,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: @@ -192,7 +192,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -202,10 +202,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: diff --git a/ivi/tct-wgtapi02-w3c-tests/inst.xpk.py b/ivi/tct-wgtapi02-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-wgtapi02-w3c-tests/inst.xpk.py +++ b/ivi/tct-wgtapi02-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-widget01-w3c-tests/inst.apk.py b/ivi/tct-widget01-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-widget01-w3c-tests/inst.apk.py +++ b/ivi/tct-widget01-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-widget01-w3c-tests/inst.wgt.py b/ivi/tct-widget01-w3c-tests/inst.wgt.py index fedb04beb..5b9572769 100755 --- a/ivi/tct-widget01-w3c-tests/inst.wgt.py +++ b/ivi/tct-widget01-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -170,8 +170,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: @@ -190,7 +190,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -200,10 +200,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: diff --git a/ivi/tct-widget01-w3c-tests/inst.xpk.py b/ivi/tct-widget01-w3c-tests/inst.xpk.py index 8e14d7da5..60a188baa 100755 --- a/ivi/tct-widget01-w3c-tests/inst.xpk.py +++ b/ivi/tct-widget01-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -170,8 +170,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: @@ -190,7 +190,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -200,10 +200,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: diff --git a/ivi/tct-widget02-w3c-tests/inst.apk.py b/ivi/tct-widget02-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-widget02-w3c-tests/inst.apk.py +++ b/ivi/tct-widget02-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-widget02-w3c-tests/inst.wgt.py b/ivi/tct-widget02-w3c-tests/inst.wgt.py index 7574ae1d7..773707bb2 100755 --- a/ivi/tct-widget02-w3c-tests/inst.wgt.py +++ b/ivi/tct-widget02-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -172,8 +172,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: @@ -192,7 +192,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -202,10 +202,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: diff --git a/ivi/tct-widget02-w3c-tests/inst.xpk.py b/ivi/tct-widget02-w3c-tests/inst.xpk.py index 6bc5749c3..88d4d47ed 100755 --- a/ivi/tct-widget02-w3c-tests/inst.xpk.py +++ b/ivi/tct-widget02-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-widgetpolicy-w3c-tests/inst.apk.py b/ivi/tct-widgetpolicy-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-widgetpolicy-w3c-tests/inst.apk.py +++ b/ivi/tct-widgetpolicy-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-widgetpolicy-w3c-tests/inst.wgt.py b/ivi/tct-widgetpolicy-w3c-tests/inst.wgt.py index dc5c11750..b7ded0857 100755 --- a/ivi/tct-widgetpolicy-w3c-tests/inst.wgt.py +++ b/ivi/tct-widgetpolicy-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -172,8 +172,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: @@ -192,7 +192,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -202,10 +202,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: diff --git a/ivi/tct-widgetpolicy-w3c-tests/inst.xpk.py b/ivi/tct-widgetpolicy-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-widgetpolicy-w3c-tests/inst.xpk.py +++ b/ivi/tct-widgetpolicy-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-woff-w3c-tests/inst.apk.py b/ivi/tct-woff-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-woff-w3c-tests/inst.apk.py +++ b/ivi/tct-woff-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-woff-w3c-tests/inst.wgt.py b/ivi/tct-woff-w3c-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-woff-w3c-tests/inst.wgt.py +++ b/ivi/tct-woff-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-woff-w3c-tests/inst.xpk.py b/ivi/tct-woff-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-woff-w3c-tests/inst.xpk.py +++ b/ivi/tct-woff-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-workers-w3c-tests/inst.apk.py b/ivi/tct-workers-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-workers-w3c-tests/inst.apk.py +++ b/ivi/tct-workers-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-workers-w3c-tests/inst.wgt.py b/ivi/tct-workers-w3c-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/tct-workers-w3c-tests/inst.wgt.py +++ b/ivi/tct-workers-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/tct-workers-w3c-tests/inst.xpk.py b/ivi/tct-workers-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-workers-w3c-tests/inst.xpk.py +++ b/ivi/tct-workers-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/tct-xmlhttprequest-w3c-tests/inst.apk.py b/ivi/tct-xmlhttprequest-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/tct-xmlhttprequest-w3c-tests/inst.apk.py +++ b/ivi/tct-xmlhttprequest-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/tct-xmlhttprequest-w3c-tests/inst.wgt.py b/ivi/tct-xmlhttprequest-w3c-tests/inst.wgt.py index db5440cb7..8515a88b8 100755 --- a/ivi/tct-xmlhttprequest-w3c-tests/inst.wgt.py +++ b/ivi/tct-xmlhttprequest-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -177,8 +177,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: @@ -197,7 +197,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -207,10 +207,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: diff --git a/ivi/tct-xmlhttprequest-w3c-tests/inst.xpk.py b/ivi/tct-xmlhttprequest-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/tct-xmlhttprequest-w3c-tests/inst.xpk.py +++ b/ivi/tct-xmlhttprequest-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/webapi-hrtime-w3c-tests/inst.apk.py b/ivi/webapi-hrtime-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/webapi-hrtime-w3c-tests/inst.apk.py +++ b/ivi/webapi-hrtime-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/webapi-hrtime-w3c-tests/inst.wgt.py b/ivi/webapi-hrtime-w3c-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/webapi-hrtime-w3c-tests/inst.wgt.py +++ b/ivi/webapi-hrtime-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/webapi-hrtime-w3c-tests/inst.xpk.py b/ivi/webapi-hrtime-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/webapi-hrtime-w3c-tests/inst.xpk.py +++ b/ivi/webapi-hrtime-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/webapi-nfc-w3c-tests/inst.apk.py b/ivi/webapi-nfc-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/webapi-nfc-w3c-tests/inst.apk.py +++ b/ivi/webapi-nfc-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/webapi-nfc-w3c-tests/inst.wgt.py b/ivi/webapi-nfc-w3c-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/webapi-nfc-w3c-tests/inst.wgt.py +++ b/ivi/webapi-nfc-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/webapi-nfc-w3c-tests/inst.xpk.py b/ivi/webapi-nfc-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/webapi-nfc-w3c-tests/inst.xpk.py +++ b/ivi/webapi-nfc-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/webapi-performancetimeline-w3c-tests/inst.apk.py b/ivi/webapi-performancetimeline-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/webapi-performancetimeline-w3c-tests/inst.apk.py +++ b/ivi/webapi-performancetimeline-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/webapi-performancetimeline-w3c-tests/inst.wgt.py b/ivi/webapi-performancetimeline-w3c-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/webapi-performancetimeline-w3c-tests/inst.wgt.py +++ b/ivi/webapi-performancetimeline-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/webapi-performancetimeline-w3c-tests/inst.xpk.py b/ivi/webapi-performancetimeline-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/webapi-performancetimeline-w3c-tests/inst.xpk.py +++ b/ivi/webapi-performancetimeline-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/webapi-resourcetiming-w3c-tests/inst.apk.py b/ivi/webapi-resourcetiming-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/webapi-resourcetiming-w3c-tests/inst.apk.py +++ b/ivi/webapi-resourcetiming-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/webapi-resourcetiming-w3c-tests/inst.wgt.py b/ivi/webapi-resourcetiming-w3c-tests/inst.wgt.py index eedbf8845..929bf5c3f 100755 --- a/ivi/webapi-resourcetiming-w3c-tests/inst.wgt.py +++ b/ivi/webapi-resourcetiming-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -177,8 +177,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: @@ -197,7 +197,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -207,10 +207,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: diff --git a/ivi/webapi-resourcetiming-w3c-tests/inst.xpk.py b/ivi/webapi-resourcetiming-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/webapi-resourcetiming-w3c-tests/inst.xpk.py +++ b/ivi/webapi-resourcetiming-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/webapi-speechapi-tizen-tests/inst.apk.py b/ivi/webapi-speechapi-tizen-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/webapi-speechapi-tizen-tests/inst.apk.py +++ b/ivi/webapi-speechapi-tizen-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/webapi-speechapi-tizen-tests/inst.wgt.py b/ivi/webapi-speechapi-tizen-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/webapi-speechapi-tizen-tests/inst.wgt.py +++ b/ivi/webapi-speechapi-tizen-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/webapi-speechapi-tizen-tests/inst.xpk.py b/ivi/webapi-speechapi-tizen-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/webapi-speechapi-tizen-tests/inst.xpk.py +++ b/ivi/webapi-speechapi-tizen-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/webapi-usertiming-w3c-tests/inst.apk.py b/ivi/webapi-usertiming-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/webapi-usertiming-w3c-tests/inst.apk.py +++ b/ivi/webapi-usertiming-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/webapi-usertiming-w3c-tests/inst.wgt.py b/ivi/webapi-usertiming-w3c-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/webapi-usertiming-w3c-tests/inst.wgt.py +++ b/ivi/webapi-usertiming-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/webapi-usertiming-w3c-tests/inst.xpk.py b/ivi/webapi-usertiming-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/webapi-usertiming-w3c-tests/inst.xpk.py +++ b/ivi/webapi-usertiming-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/webapi-vehicleinfo-ivi-tests/inst.apk.py b/ivi/webapi-vehicleinfo-ivi-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/webapi-vehicleinfo-ivi-tests/inst.apk.py +++ b/ivi/webapi-vehicleinfo-ivi-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/webapi-vehicleinfo-ivi-tests/inst.wgt.py b/ivi/webapi-vehicleinfo-ivi-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/webapi-vehicleinfo-ivi-tests/inst.wgt.py +++ b/ivi/webapi-vehicleinfo-ivi-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/webapi-vehicleinfo-ivi-tests/inst.xpk.py b/ivi/webapi-vehicleinfo-ivi-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/webapi-vehicleinfo-ivi-tests/inst.xpk.py +++ b/ivi/webapi-vehicleinfo-ivi-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/ivi/webapi-webrtc-w3c-tests/inst.apk.py b/ivi/webapi-webrtc-w3c-tests/inst.apk.py index a13f660a9..5fcedb9d9 100755 --- a/ivi/webapi-webrtc-w3c-tests/inst.apk.py +++ b/ivi/webapi-webrtc-w3c-tests/inst.apk.py @@ -16,14 +16,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 @@ -76,8 +76,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: @@ -88,11 +88,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: diff --git a/ivi/webapi-webrtc-w3c-tests/inst.wgt.py b/ivi/webapi-webrtc-w3c-tests/inst.wgt.py index 918e9561d..44eca3371 100755 --- a/ivi/webapi-webrtc-w3c-tests/inst.wgt.py +++ b/ivi/webapi-webrtc-w3c-tests/inst.wgt.py @@ -20,14 +20,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 @@ -178,8 +178,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: @@ -198,7 +198,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -208,10 +208,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: diff --git a/ivi/webapi-webrtc-w3c-tests/inst.xpk.py b/ivi/webapi-webrtc-w3c-tests/inst.xpk.py index 62f961bb9..11cdd8e23 100755 --- a/ivi/webapi-webrtc-w3c-tests/inst.xpk.py +++ b/ivi/webapi-webrtc-w3c-tests/inst.xpk.py @@ -20,14 +20,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 @@ -179,8 +179,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: @@ -199,7 +199,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -209,10 +209,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: diff --git a/mobile/tct-capability-tests/inst.apk.py b/mobile/tct-capability-tests/inst.apk.py index 31210db16..997d98f37 100755 --- a/mobile/tct-capability-tests/inst.apk.py +++ b/mobile/tct-capability-tests/inst.apk.py @@ -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: diff --git a/mobile/tct-capability-tests/inst.wgt.py b/mobile/tct-capability-tests/inst.wgt.py index ef38eb600..6e0726097 100755 --- a/mobile/tct-capability-tests/inst.wgt.py +++ b/mobile/tct-capability-tests/inst.wgt.py @@ -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 @@ -205,8 +205,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: @@ -225,7 +225,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -237,10 +237,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: diff --git a/mobile/tct-capability-tests/inst.xpk.py b/mobile/tct-capability-tests/inst.xpk.py index 211d24c73..dccbae7e9 100755 --- a/mobile/tct-capability-tests/inst.xpk.py +++ b/mobile/tct-capability-tests/inst.xpk.py @@ -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: diff --git a/mobile/tct-capability-tests/pack.py b/mobile/tct-capability-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/mobile/tct-capability-tests/pack.py +++ b/mobile/tct-capability-tests/pack.py @@ -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: diff --git a/mobile/tct-deprecatedapi-tizen-tests/inst.apk.py b/mobile/tct-deprecatedapi-tizen-tests/inst.apk.py index 31210db16..997d98f37 100755 --- a/mobile/tct-deprecatedapi-tizen-tests/inst.apk.py +++ b/mobile/tct-deprecatedapi-tizen-tests/inst.apk.py @@ -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: diff --git a/mobile/tct-deprecatedapi-tizen-tests/inst.wgt.py b/mobile/tct-deprecatedapi-tizen-tests/inst.wgt.py index e32732b34..8e0d9ef1a 100755 --- a/mobile/tct-deprecatedapi-tizen-tests/inst.wgt.py +++ b/mobile/tct-deprecatedapi-tizen-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -188,8 +188,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: @@ -208,7 +208,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -220,10 +220,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: diff --git a/mobile/tct-deprecatedapi-tizen-tests/inst.xpk.py b/mobile/tct-deprecatedapi-tizen-tests/inst.xpk.py index 211d24c73..dccbae7e9 100755 --- a/mobile/tct-deprecatedapi-tizen-tests/inst.xpk.py +++ b/mobile/tct-deprecatedapi-tizen-tests/inst.xpk.py @@ -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: diff --git a/mobile/tct-deprecatedapi-tizen-tests/pack.py b/mobile/tct-deprecatedapi-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/mobile/tct-deprecatedapi-tizen-tests/pack.py +++ b/mobile/tct-deprecatedapi-tizen-tests/pack.py @@ -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: diff --git a/tools/build/pack.py b/tools/build/pack.py index e48cdc174..22bf5e2a1 100755 --- a/tools/build/pack.py +++ b/tools/build/pack.py @@ -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: diff --git a/tools/coverage/stats.py b/tools/coverage/stats.py index e10865f47..10a22ab09 100755 --- a/tools/coverage/stats.py +++ b/tools/coverage/stats.py @@ -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() diff --git a/tools/xml/csv2xml.py b/tools/xml/csv2xml.py index 4447e4d65..bdfdb207d 100755 --- a/tools/xml/csv2xml.py +++ b/tools/xml/csv2xml.py @@ -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 | 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]]() diff --git a/tools/xml/xml2csv.py b/tools/xml/xml2csv.py index 07de9c35a..5a6d3ba2c 100755 --- a/tools/xml/xml2csv.py +++ b/tools/xml/xml2csv.py @@ -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 | 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: { diff --git a/tools/xml/xmlverifier.py b/tools/xml/xmlverifier.py index 4165ec9d6..9794b2c8b 100755 --- a/tools/xml/xmlverifier.py +++ b/tools/xml/xmlverifier.py @@ -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 | 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]]() diff --git a/tv/tct-capability-tests/inst.apk.py b/tv/tct-capability-tests/inst.apk.py index 31210db16..997d98f37 100755 --- a/tv/tct-capability-tests/inst.apk.py +++ b/tv/tct-capability-tests/inst.apk.py @@ -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: diff --git a/tv/tct-capability-tests/inst.wgt.py b/tv/tct-capability-tests/inst.wgt.py index ef38eb600..6e0726097 100755 --- a/tv/tct-capability-tests/inst.wgt.py +++ b/tv/tct-capability-tests/inst.wgt.py @@ -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 @@ -205,8 +205,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: @@ -225,7 +225,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -237,10 +237,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: diff --git a/tv/tct-capability-tests/inst.xpk.py b/tv/tct-capability-tests/inst.xpk.py index 211d24c73..dccbae7e9 100755 --- a/tv/tct-capability-tests/inst.xpk.py +++ b/tv/tct-capability-tests/inst.xpk.py @@ -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: diff --git a/tv/tct-capability-tests/pack.py b/tv/tct-capability-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/tv/tct-capability-tests/pack.py +++ b/tv/tct-capability-tests/pack.py @@ -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: diff --git a/tv/tct-deprecatedapi-tizen-tests/inst.apk.py b/tv/tct-deprecatedapi-tizen-tests/inst.apk.py index 31210db16..d636bee03 100755 --- a/tv/tct-deprecatedapi-tizen-tests/inst.apk.py +++ b/tv/tct-deprecatedapi-tizen-tests/inst.apk.py @@ -6,8 +6,8 @@ import glob import time import sys import subprocess -from optparse import OptionParser, make_option -import ConfigParser +from optparse import OptionParser, make_option +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: diff --git a/tv/tct-deprecatedapi-tizen-tests/inst.wgt.py b/tv/tct-deprecatedapi-tizen-tests/inst.wgt.py index e32732b34..8e0d9ef1a 100755 --- a/tv/tct-deprecatedapi-tizen-tests/inst.wgt.py +++ b/tv/tct-deprecatedapi-tizen-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -188,8 +188,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: @@ -208,7 +208,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -220,10 +220,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: diff --git a/tv/tct-deprecatedapi-tizen-tests/inst.xpk.py b/tv/tct-deprecatedapi-tizen-tests/inst.xpk.py index 211d24c73..dccbae7e9 100755 --- a/tv/tct-deprecatedapi-tizen-tests/inst.xpk.py +++ b/tv/tct-deprecatedapi-tizen-tests/inst.xpk.py @@ -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: diff --git a/tv/tct-deprecatedapi-tizen-tests/pack.py b/tv/tct-deprecatedapi-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/tv/tct-deprecatedapi-tizen-tests/pack.py +++ b/tv/tct-deprecatedapi-tizen-tests/pack.py @@ -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: diff --git a/wearable/tct-capability-tests/inst.apk.py b/wearable/tct-capability-tests/inst.apk.py index 31210db16..997d98f37 100755 --- a/wearable/tct-capability-tests/inst.apk.py +++ b/wearable/tct-capability-tests/inst.apk.py @@ -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: diff --git a/wearable/tct-capability-tests/inst.wgt.py b/wearable/tct-capability-tests/inst.wgt.py index ef38eb600..6e0726097 100755 --- a/wearable/tct-capability-tests/inst.wgt.py +++ b/wearable/tct-capability-tests/inst.wgt.py @@ -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 @@ -205,8 +205,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: @@ -225,7 +225,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -237,10 +237,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: diff --git a/wearable/tct-capability-tests/inst.xpk.py b/wearable/tct-capability-tests/inst.xpk.py index 211d24c73..dccbae7e9 100755 --- a/wearable/tct-capability-tests/inst.xpk.py +++ b/wearable/tct-capability-tests/inst.xpk.py @@ -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: diff --git a/wearable/tct-capability-tests/pack.py b/wearable/tct-capability-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/wearable/tct-capability-tests/pack.py +++ b/wearable/tct-capability-tests/pack.py @@ -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: diff --git a/wearable/tct-deprecatedapi-tizen-tests/inst.apk.py b/wearable/tct-deprecatedapi-tizen-tests/inst.apk.py index 31210db16..997d98f37 100755 --- a/wearable/tct-deprecatedapi-tizen-tests/inst.apk.py +++ b/wearable/tct-deprecatedapi-tizen-tests/inst.apk.py @@ -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: diff --git a/wearable/tct-deprecatedapi-tizen-tests/inst.wgt.py b/wearable/tct-deprecatedapi-tizen-tests/inst.wgt.py index e32732b34..8e0d9ef1a 100755 --- a/wearable/tct-deprecatedapi-tizen-tests/inst.wgt.py +++ b/wearable/tct-deprecatedapi-tizen-tests/inst.wgt.py @@ -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) @@ -33,14 +33,14 @@ def userCheck(): def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode("UTF-8").strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -188,8 +188,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: @@ -208,7 +208,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) userCheck() @@ -220,10 +220,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: diff --git a/wearable/tct-deprecatedapi-tizen-tests/inst.xpk.py b/wearable/tct-deprecatedapi-tizen-tests/inst.xpk.py index 211d24c73..dccbae7e9 100755 --- a/wearable/tct-deprecatedapi-tizen-tests/inst.xpk.py +++ b/wearable/tct-deprecatedapi-tizen-tests/inst.xpk.py @@ -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: diff --git a/wearable/tct-deprecatedapi-tizen-tests/pack.py b/wearable/tct-deprecatedapi-tizen-tests/pack.py index e29187a0b..f1f0cb470 100755 --- a/wearable/tct-deprecatedapi-tizen-tests/pack.py +++ b/wearable/tct-deprecatedapi-tizen-tests/pack.py @@ -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: