From: anh.vn Date: Fri, 27 May 2022 07:16:58 +0000 (+0700) Subject: [Non-ACR] Update tct CSharp from python 2x to python 3x X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=23082b0f78750ad8e0029052974837f61133ac78;p=test%2Ftct%2Fcsharp%2Fapi.git [Non-ACR] Update tct CSharp from python 2x to python 3x Change-Id: I41c5639904bcbfe095a43b054c76b7a8d709e788 --- diff --git a/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/resource/buildinfo.xml b/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/resource/buildinfo.xml index 533afd5..807065a 100644 --- a/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/resource/buildinfo.xml +++ b/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/resource/buildinfo.xml @@ -1,13 +1,13 @@ - - - - SM-Z130H - - - samsung - - - Z130HDDE0ANL7 - + + + + SM-Z130H + + + samsung + + + Z130HDDE0ANL7 + \ No newline at end of file diff --git a/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/resource/capability.xml b/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/resource/capability.xml index 23216c3..50f4951 100644 --- a/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/resource/capability.xml +++ b/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/resource/capability.xml @@ -1,179 +1,179 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/resource/precondition.txt b/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/resource/precondition.txt index efccadb..f456346 100644 --- a/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/resource/precondition.txt +++ b/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/resource/precondition.txt @@ -1,22 +1,22 @@ -Reference : http://168.219.209.56/confluence/display/Tizen3/Running+Web+TCT+for+Tizen+3.0 - ---------------------------------------------------------------------------------------- - -1. Please push the below attached 2 files in the below location(target) before the test start. - -file name : - -capability.xml -buildinfo.xml - - -location : - -/home/owner/content/Documents/tct/ - - -ex) sdb push capability.xml /home/owner/content/Documents/tct/ -ex) sdb push buildinfo.xml /home/owner/content/Documents/tct/ - - ---------------------------------------------------------------------------------------- +Reference : http://168.219.209.56/confluence/display/Tizen3/Running+Web+TCT+for+Tizen+3.0 + +--------------------------------------------------------------------------------------- + +1. Please push the below attached 2 files in the below location(target) before the test start. + +file name : + +capability.xml +buildinfo.xml + + +location : + +/home/owner/content/Documents/tct/ + + +ex) sdb push capability.xml /home/owner/content/Documents/tct/ +ex) sdb push buildinfo.xml /home/owner/content/Documents/tct/ + + +--------------------------------------------------------------------------------------- diff --git a/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/resource/tct-testconfig/inst.py b/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/resource/tct-testconfig/inst.py index b1bb50b..25be415 100644 --- a/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/resource/tct-testconfig/inst.py +++ b/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/resource/tct-testconfig/inst.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import os import shutil @@ -27,14 +27,14 @@ PKG_SRC_DIR = SRC_DIR + "/tct/opt/%s" % 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 @@ -148,8 +148,8 @@ def main(): "-a", dest="user", action="store", help="User name") global PARAMETERS (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) sys.exit(1) if not PARAMETERS.user: @@ -168,7 +168,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -178,10 +178,10 @@ def main(): userid = user_info[1][0] XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) else: - print "[Error] cmd commands error : %s"%str(user_info[1]) + print ("[Error] cmd commands error : %s"%str(user_info[1])) sys.exit(1) if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" + print ("-i and -u are conflict") sys.exit(1) if PARAMETERS.buninstpkg: diff --git a/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/tools/devicemanager.py b/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/tools/devicemanager.py index 7ca7e7d..4390a00 100644 --- a/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/tools/devicemanager.py +++ b/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/tools/devicemanager.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 from sdbmanager import SdbManager @@ -50,7 +50,7 @@ class DeviceManager(object): if dev.getDeviceId() == deviceId: return dev - print "#ERROR#: The '%s' device Id exists error" % deviceId + print("#ERROR#: The '%s' device Id exists error" % deviceId) return None def loadDeviceList(self): @@ -71,8 +71,8 @@ class DeviceManager(object): if len(connDevices) > 0: self._updateConnDevice(connDevices) - print "Connected Devices = %s" \ - % str([dev.devId for dev in self.devices]) + print("Connected Devices = %s" \ + % str([dev.devId for dev in self.devices])) return True else: self._resetDevices() @@ -85,11 +85,11 @@ class SdbDevice: self.devType = devType def _printDevInfo(self): - print "===== Device Infomation =====" - print " Name : " + self.devName - print " Id : " + self.devId - print " Type : " + self.devType - print "=============================" + print("===== Device Infomation =====") + print(" Name : " + self.devName) + print(" Id : " + self.devId) + print(" Type : " + self.devType) + print("=============================") def getDeviceId(self): return self.devId diff --git a/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/tools/sdbmanager.py b/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/tools/sdbmanager.py index 71b823e..d1fb915 100644 --- a/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/tools/sdbmanager.py +++ b/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/tools/sdbmanager.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 import subprocess import time @@ -24,7 +24,7 @@ class SdbManager: @staticmethod def hostCommand(command): - print command + print(command) proc = subprocess.Popen(command, shell=True, \ stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -33,19 +33,19 @@ class SdbManager: if exit_code is not None: break - output = proc.stdout.read() + output = proc.stdout.read().decode('utf-8') if output: - print output + print(output) - errlog = proc.stderr.read() + errlog = proc.stderr.read().decode('utf-8') if errlog: - print errlog + print(errlog) return True @staticmethod def hostCommandwithResult(command): - print command + print(command) proc = subprocess.Popen(command, shell=True, \ stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -54,11 +54,11 @@ class SdbManager: if exit_code is not None: break - return proc.stdout.read() + return proc.stdout.read().decode('utf-8') @staticmethod def sdbCommand(command, timeout=90): - print command + print(command) proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, @@ -79,7 +79,7 @@ class SdbManager: @staticmethod def _checkDevIdExists(_devid): if len(_devid) < 0: - print "#ERROR#: The '%s' device Id exists error" % _devid + print("#ERROR#: The '%s' device Id exists error" % _devid) return False return True @@ -93,7 +93,7 @@ class SdbManager: @staticmethod def sdbPush(_devid, local, remote): if SdbManager._checkFileExists(local) is False: - print '#WARNING#: The %s file exists error' % local + print('#WARNING#: The %s file exists error' % local) return False FAIL_LOG = "#ERROR#: sdb push failed" @@ -102,12 +102,12 @@ class SdbManager: exit_code, re_stdout, re_stderr = SdbManager.sdbCommand(push_cmd) if exit_code is None: - print FAIL_LOG - errLog = re_stderr.read() - if errLog: print errLog + print(FAIL_LOG) + errLog = re_stderr.read().decode('utf-8') + if errLog: print(errLog) return False else: - print re_stdout.read() + print(re_stdout.read().decode('utf-8')) return True @staticmethod @@ -118,19 +118,19 @@ class SdbManager: exit_code, re_stdout, re_stderr = SdbManager.sdbCommand(shell_cmd, timeout) if exit_code is None: - print FAIL_LOG - errLog = re_stderr.read() - if errLog : print errLog + print(FAIL_LOG) + errLog = re_stderr.read().decode('utf-8') + if errLog : print(errLog) return None else: - outLog = re_stdout.read() - errLog = re_stderr.read() + outLog = re_stdout.read().decode('utf-8') + errLog = re_stderr.read().decode('utf-8') if errLog: - print FAIL_LOG - print errLog + print(FAIL_LOG) + print(errLog) return None if outLog: - print outLog + print(outLog) return outLog @staticmethod @@ -142,17 +142,17 @@ class SdbManager: exit_code, re_stdout, re_stderr = SdbManager.sdbCommand(root_cmd, 20) if exit_code is None: - print FAIL_LOG - errLog = re_stderr.read() - if errLog: print (str(errLog)) + print(FAIL_LOG) + errLog = re_stderr.read().decode('utf-8') + if errLog: print((str(errLog))) checkLog = SdbManager.sdbShell(deviceId, 'whoami') if checkLog and checkLog.find('root') != -1: - print 'SDB ROOT ON' + print('SDB ROOT ON') is_pass = True else: - print FAIL_LOG - print str(checkLog) + print(FAIL_LOG) + print(str(checkLog)) return is_pass @@ -163,14 +163,14 @@ class SdbManager: SdbManager.sdbCommand(start_server_cmd, 8) exit_code, re_stdout, re_stderr = SdbManager.sdbCommand(dev_cmd, 20) if exit_code is None: - print "#ERROR#: %s" % re_stderr.read() + print("#ERROR#: %s" % re_stderr.read().decode('utf-8')) return None - return re_stdout.read() + return re_stdout.read().decode('utf-8') @staticmethod def sdbSetDate(devid): - print "set device date" + print("set device date") HDATE = '`date "+%Y-%m-%d %H:%M:%S %Z"`' date_cmd = '"date -s \''+ HDATE + '\'"' SdbManager.sdbShell(devid, date_cmd) @@ -201,21 +201,21 @@ class SdbManager: pid = pidgrp.pop() try: os.kill(int(pid), signal.SIGKILL) - except OSError, error: + except OSError as error: pattern = re.compile('No such process') match = pattern.search(str(error)) if not match: - print "[ Error: fail to kill pid: %s," \ - " error: %s ]\n" % (int(pid), error) + print("[ Error: fail to kill pid: %s," \ + " error: %s ]\n" % (int(pid), error)) # kill for windows platform else: kernel32 = ctypes.windll.kernel32 handle = kernel32.OpenProcess(1, 0, int(ppid)) kernel32.TerminateProcess(handle, 0) - except OSError, error: + except OSError as error: pattern = re.compile('No such process') match = pattern.search(str(error)) if not match: - print "[ Error: fail to kill pid: %s, error: %s ]\n" \ - % (int(ppid), error) + print("[ Error: fail to kill pid: %s, error: %s ]\n" \ + % (int(ppid), error)) return None diff --git a/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/tools/tct-config-device.py b/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/tools/tct-config-device.py index d114829..8e94f84 100644 --- a/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/tools/tct-config-device.py +++ b/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/tools/tct-config-device.py @@ -1,582 +1,582 @@ -#!/usr/bin/python - -"""Usage: - tct-config-device.py [--install [--deviceid ]] - tct-config-device.py --purge [--deviceid ] - tct-config-device.py --check [--deviceid ][--procid ] - tct-config-device.py --bhtest - -Options: - -h, --help show this help message and exit - --install Install tct resources to TIZEN device,it can be omitted - --purge Clean up tct resources from TIZEN device - --check Check test resource on device - --bhtest Install tct behavior test - --deviceid Set the device serial number - --procid Set the check process name - -""" -import os -import sys -import time -import ConfigParser -import threading -import subprocess - - -from optparse import OptionParser -from devicemanager import DeviceManager -from sdbmanager import SdbManager - -JOIN = os.path.join -EXISTS = os.path.exists -DIRNAME = os.path.dirname -BASENAME = os.path.basename -ABSPATH = os.path.abspath -SPLIT = os.path.split - -CURENT_DIR = SPLIT(DIRNAME(ABSPATH(__file__)))[0] - -TOOLS_DIR = JOIN(CURENT_DIR, "tools") -RESRC_DIR = JOIN(CURENT_DIR, "resource") -PKGS_DIR = JOIN(CURENT_DIR, "package") - -DEVID = "" - -TIZENV = "tizen_6.5" - -DLOG_CLEAR = "dlogutil -c" -DLOG_UTIL = "sdb -s %s shell dlogutil -v time" - -TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() -tct_parser.read(TCT_CONFIG_FILE) - -DEVICE_SUITE_TARGET_24 = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_24') -DEVICE_SUITE_TARGET_30 = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') -DEVICE_EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') - -if TIZENV.find('tizen_6.5') > -1: - DEVICE_SUITE_TARGET = DEVICE_SUITE_TARGET_30 -else: - DEVICE_SUITE_TARGET = DEVICE_SUITE_TARGET_24 - -def LS(root, file_name, extension=None): - import glob - - file_path = "" - if extension: - file_path = JOIN(root, file_name) + "*." + extension - else: - file_path = JOIN(root, file_name) + "*" - files = glob.iglob(r'' + file_path + '') - for f in files: - return BASENAME(f) - -def get_device_arch(): - global DEV_ARCH - #ARCHCMD = SDB_SERNO + " shell \"cat /etc/products.d/tizen.prod |grep \armv7 - result = SdbManager.sdbShell(DEVID, arch_cmd) - if result and len(result) > 0: - arch_str = result.split('\n')[0] - if arch_str and arch_str.find('armv') > -1: - DEV_ARCH = "arm" - print "info: [* Arch Type : arm *]" - elif arch_str and arch_str.find("aarch64") > -1: - DEV_ARCH = "aarch64" - print "info: [* Arch Type : aarch64 *]" - elif arch_str and arch_str.find('x86_64') > -1: - DEV_ARCH = "ia64" - print "info: [* Arch Type : ia64 *]" - elif arch_str and (arch_str.find("i686") > -1 or arch_str.find("x86") > -1 or arch_str.find("i386") > -1): - DEV_ARCH = "ia" - print "info: [* Arch Type : ia *]" - else: - print "info: [* Arch Type : None *]" - return False - return True - else: - print "#ERROR#: Failed to get device cpu_arch type" - return False - - -def kill_process(process_name): - proc_cmd = "ps aux | grep " + process_name + " | grep -v grep | awk '{print $2}'" - result = SdbManager.sdbShell(DEVID, proc_cmd) - if result and len(result) > 0: - kill_cmd = "kill -9 " + str(result).strip() + " > /dev/null 2>&1" - SdbManager.sdbShell(DEVID, kill_cmd) - print "info: %s process has been killed" % process_name - else: - print "info: No process of %s activated" % process_name - -def remove_tinyweb(): - SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/server.pem > /dev/null 2>&1") - SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/tinyweb > /dev/null 2>&1") - SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/cgi-getcookie > /dev/null 2>&1") - SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/cgi-getfield > /dev/null 2>&1") - SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/libmongoose.so > /dev/null 2>&1") - SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/echo.so > /dev/null 2>&1") - SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/libssl.so > /dev/null 2>&1") - SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/libcrypto.so > /dev/null 2>&1") - -def remove_stub(): - SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/testkit-stub") - - -def uninstall_testconfig(): - if TIZENV.find('tizen_6.5') > -1: - inst_path = RESRC_DIR + os.sep + 'tct-testconfig' + os.sep + 'inst.py' - SdbManager.hostCommand("python %s -s %s -u" % (inst_path, DEVID)) - else: - RPMPKG = LS(RESRC_DIR, "tct-testconfig") - if not RPMPKG: - sys.exit("#ERROR#: cannot found tct-testconfig.zip file in resource dir") - uninst_cmd = JOIN(DEVICE_SUITE_TARGET, 'tct/opt/tct-testconfig/inst.sh') + ' -u' - SdbManager.sdbShell(DEVID, uninst_cmd) - rm_cmd = 'rm -f ' + JOIN(DEVICE_SUITE_TARGET, 'tct/', RPMPKG) - SdbManager.sdbShell(DEVID, rm_cmd) - - -def uninstall_behavior(): - print "info: Uninstall behavior tool." - if TIZENV.find('tizen_6.5') > -1: - pass - else: - uninst_cmd = JOIN(DEVICE_SUITE_TARGET, 'tct/opt/tct-behavior-tests/inst.sh') + ' -u' - SdbManager.sdbShell(DEVID, uninst_cmd) - - -def check_resource_dir(): - print "info: check resource directory." - if os.path.exists(RESRC_DIR): - SdbManager.sdbShell(DEVID, 'mkdir -p ' + JOIN(DEVICE_SUITE_TARGET, 'tct/')) - SdbManager.sdbShell(DEVID, 'mkdir -p ' + JOIN(DEVICE_SUITE_TARGET, 'Documents/')) - return True - else: - print "#WARNING#: The directory resource does not exists. Please copy test resources to %s " % RESRC_DIR - return False - -def check_tinyweb(): - print "info: Check tinyweb." - result = SdbManager.sdbShell(DEVID, "ls /opt/home/developer/ | grep tinyweb") - if result and result.find('tinyweb'): - remove_tinyweb() - install_tinyweb() - launch_tinyweb() - else: - install_tinyweb() - launch_tinyweb() - - -def port_manager(): - print "info: Check the tinyweb port" - result = SdbManager.sdbShell('fuser -n tcp 80 8080 8081 8082 8083 8443') - if result and len(result) > 0: - check_port = SdbManager.sdbShell('su "netstat -nap |grep tinyweb"') - if len(check_port) > 0: - print "info: tinyweb on" - else: - print "info: Port is available" - - -def launch_tinyweb(): - dpath_cmd = "printenv PATH" - dpath = SdbManager.sdbShell(DEVID, dpath_cmd) - - launch_cmd = 'sdb -s ' + DEVID + ' shell ' + '"env LD_LIBRARY_PATH=/opt/home/developer PATH=' + dpath.strip() + \ - ':/opt/home/developer/ tinyweb -ssl_certificate /opt/home/developer/server.pem -document_root ' + \ - JOIN(DEVICE_SUITE_TARGET, 'tct') + ' -listening_ports 80,8080,8081,8082,8083,8443s; sleep 3s" 0> /dev/null' - - SdbManager.sdbCommand(launch_cmd, 10) - - check_tinyweb_cmd = '\"ps aux | grep tinyweb | grep -v grep\"' - result = SdbManager.sdbShell(DEVID, check_tinyweb_cmd) - if result and result.find('tinyweb') > -1: - print "info: Active process tinyweb successfully." - return True - else: - print "#ERROR#: Active process tinyweb failed." - return False - -def install_tinyweb(): - print "info: Install tinyweb" - SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, 'tinyweb', DEV_ARCH, 'tinyweb'), '/opt/home/developer/') - SdbManager.sdbShell(DEVID, "chmod 777 /opt/home/developer/tinyweb") - - SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, 'tinyweb', DEV_ARCH, 'cgi-getcookie'), '/opt/home/developer/') - SdbManager.sdbShell(DEVID, "chmod 777 /opt/home/developer/cgi-getcookie") - - SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, 'tinyweb', DEV_ARCH, 'cgi-getfield'), '/opt/home/developer/') - SdbManager.sdbShell(DEVID, "chmod 777 /opt/home/developer/cgi-getfield") - - SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, 'tinyweb', DEV_ARCH, 'libmongoose.so'), '/opt/home/developer/') - SdbManager.sdbShell(DEVID, "chmod 777 /opt/home/developer/libmongoose.so") - - SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, 'tinyweb', DEV_ARCH, 'echo.so'), '/opt/home/developer/') - SdbManager.sdbShell(DEVID, "chmod 777 /opt/home/developer/echo.so") - - SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, 'tinyweb', DEV_ARCH, 'server.pem'), '/opt/home/developer/') - SdbManager.sdbShell(DEVID, "chmod 777 /opt/home/developer/server.pem") - if DEV_ARCH == "arm": - SdbManager.sdbShell(DEVID, "ln -s /usr/lib/libssl.so.1.0.0 /opt/home/developer/libssl.so") - SdbManager.sdbShell(DEVID, "ln -s /usr/lib/libcrypto.so.1.0.0 /opt/home/developer/libcrypto.so") - elif DEV_ARCH == "ia": - SdbManager.sdbShell(DEVID, "ln -s /usr/lib/libssl.so.1.0.0 /opt/home/developer/libssl.so") - SdbManager.sdbShell(DEVID, "ln -s /usr/lib/libcrypto.so.1.0.0 /opt/home/developer/libcrypto.so") - elif DEV_ARCH == "aarch64": - SdbManager.sdbShell(DEVID, "ln -s /usr/lib64/libssl.so.1.0.0 /opt/home/developer/libssl.so") - SdbManager.sdbShell(DEVID, "ln -s /usr/lib64/libcrypto.so.1.0.0 /opt/home/developer/libcrypto.so") - elif DEV_ARCH == "ia64": - SdbManager.sdbShell(DEVID, "ln -s /usr/lib64/libssl.so.1.0.0 /opt/home/developer/libssl.so") - SdbManager.sdbShell(DEVID, "ln -s /usr/lib64/libcrypto.so.1.0.0 /opt/home/developer/libcrypto.so") - - -def check_stub(): - print "info: Check testkit-stub." - result = SdbManager.sdbShell(DEVID, "ls /opt/home/developer/ | grep testkit-stub") - if result and len(result) > 0: - print "info: testkit-stub has been installed on device." - kill_process("testkit-stub") - install_stub() - - -def install_stub(): - print "info: Install testkit-stub." - SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, 'testkit-stub', DEV_ARCH, 'testkit-stub'), '/opt/home/developer/testkit-stub') - SdbManager.sdbShell(DEVID, "chmod a+x /opt/home/developer/testkit-stub") - SdbManager.sdbShell(DEVID, "chsmack -e \"User\" /opt/home/developer/testkit-stub") - - -def check_testconfig(): - result = SdbManager.sdbShell(DEVID, '"cat ' + JOIN(DEVICE_SUITE_TARGET, 'tct/opt/tct-testconfig/tct-testconfig.ini') + ' | grep tct"') - if result and len(result) > 0 and result.find('No such file or directory') == -1: - print "info: testconfig has already been installed on device." - else: - install_testconfig() - - -def install_testconfig(): - print "info: Install testconfig." - if TIZENV.find('tizen_6.5') > -1: - instPath = RESRC_DIR + os.sep + 'tct-testconfig' + os.sep + 'inst.py' - SdbManager.hostCommand("python %s -s %s" % (instPath, DEVID)) - else: - conf_pkg = LS(RESRC_DIR, "tct-testconfig") - SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, conf_pkg), JOIN(DEVICE_SUITE_TARGET, 'tct/')) - SdbManager.sdbShell(DEVID, 'unzip -uo ' + JOIN(DEVICE_SUITE_TARGET, 'tct/') + conf_pkg + ' -d ' + JOIN(DEVICE_SUITE_TARGET, 'tct/')) - SdbManager.sdbShell(DEVID, JOIN(DEVICE_SUITE_TARGET, 'tct/opt/tct-testconfig/inst.sh')) - - result = SdbManager.sdbShell(DEVID, 'cat ' + JOIN(DEVICE_SUITE_TARGET, 'tct/opt/tct-testconfig/tct-testconfig.ini') + ' | grep tct') - - if result and len(result) > 0: - print "info: Install testconfig successfully." - else: - print "#ERROR#: Failed to install testconfig, please check %s" % RESRC_DIR - return False - - return True - -def install_behavior(profile_name): - print "info: Install behavior tool." - - if not profile_name in ['wearable', 'mobile', 'tv', 'ivi']: - print "#WARNING#: Invalid device profile value %s" % profile_name - return False - - if TIZENV.find('tizen_6.5') > -1: - RPMPKG = "tct-behavior-tests-6.5.zip" - opt_rpm_path = PKGS_DIR + "s" + os.sep + profile_name + os.sep + RPMPKG - local_rpm_path = PKGS_DIR + os.sep + profile_name + os.sep + RPMPKG - - install_rpm = None - install_dest = None - install_cmd = None - if os.path.exists(opt_rpm_path): - install_rpm = opt_rpm_path - install_dest = PKGS_DIR + "s" + os.sep + profile_name + os.sep - install_cmd = PKGS_DIR + "s" + os.sep + profile_name + os.sep + \ - 'opt' + os.sep + "tct-behavior-tests" + os.sep + "inst.py" - elif os.path.exists(local_rpm_path): - install_rpm = local_rpm_path - install_dest = PKGS_DIR + os.sep + profile_name + os.sep - install_cmd = PKGS_DIR + os.sep + profile_name + os.sep + \ - 'opt' + os.sep + "tct-behavior-tests" + os.sep + "inst.py" - - SdbManager.hostCommand("rm -rf %s" % install_dest + "opt/tct-behavior-tests") - SdbManager.hostCommand("unzip -uo %s -d %s" % (install_rpm, install_dest)) - SdbManager.hostCommand("python %s -s %s" % (install_cmd, DEVID)) - - print "info: Check tizen-web-ui-fw. Please wait..." - check_uifw = SdbManager.sdbShell(DEVID, "ls /usr/share/ | grep tizen-web-ui-fw") - if check_uifw and len(check_uifw) > 0: - print "info: tizen-web-ui-fw has been installed on device." - else: - SdbManager.sdbShell(DEVID, '"mkdir -p /usr/share/tizen-web-ui-fw/"') - SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, "tizen-web-ui-fw"), '/usr/share/tizen-web-ui-fw/') - else: - pass - - return True - - - -def update_tctconf_file(): - print "Updating TCT_CONFIG file" - tct_config_old = "/opt/tools/TCT_CONFIG" - tct_config_new = "/opt/tools/shell/tmp/%s/TCT_CONFIG"%DEVID - - if os.path.exists(tct_config_new): - os.remove(tct_config_new) - - config_content = "" - with open(tct_config_old, 'r') as f: - config_content = f.readlines() - f_new = open(tct_config_new, 'w') - - tmp = "" - for line in config_content: - if line.find("DEVICE_PHYSICAL_STORAGE_30")!=-1: - tmp = getDevPhysicalStorage() - if tmp is None: - f_new.write(line) - else: - f_new.write("DEVICE_PHYSICAL_STORAGE_30="+tmp.strip()+"\n") - elif line.find("DEVICE_ADMIN_USER_APPS_ROOT_30")!=-1: - tmp = getDevAdminUserAppsRoot() - if tmp is None: - f_new.write(line) - else: - f_new.write("DEVICE_ADMIN_USER_APPS_ROOT_30="+tmp.strip()+"\n") +#!/usr/bin/env python3 + +"""Usage: + tct-config-device.py [--install [--deviceid ]] + tct-config-device.py --purge [--deviceid ] + tct-config-device.py --check [--deviceid ][--procid ] + tct-config-device.py --bhtest + +Options: + -h, --help show this help message and exit + --install Install tct resources to TIZEN device,it can be omitted + --purge Clean up tct resources from TIZEN device + --check Check test resource on device + --bhtest Install tct behavior test + --deviceid Set the device serial number + --procid Set the check process name + +""" +import os +import sys +import time +import configparser +import threading +import subprocess + + +from optparse import OptionParser +from devicemanager import DeviceManager +from sdbmanager import SdbManager + +JOIN = os.path.join +EXISTS = os.path.exists +DIRNAME = os.path.dirname +BASENAME = os.path.basename +ABSPATH = os.path.abspath +SPLIT = os.path.split + +CURENT_DIR = SPLIT(DIRNAME(ABSPATH(__file__)))[0] + +TOOLS_DIR = JOIN(CURENT_DIR, "tools") +RESRC_DIR = JOIN(CURENT_DIR, "resource") +PKGS_DIR = JOIN(CURENT_DIR, "package") + +DEVID = "" + +TIZENV = "tizen_7.0" + +DLOG_CLEAR = "dlogutil -c" +DLOG_UTIL = "sdb -s %s shell dlogutil -v time" + +TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" +tct_parser = configparser.ConfigParser() +tct_parser.read(TCT_CONFIG_FILE) + +DEVICE_SUITE_TARGET_24 = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_24') +DEVICE_SUITE_TARGET_30 = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') +DEVICE_EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30') + +if TIZENV.find('tizen_7.0') > -1: + DEVICE_SUITE_TARGET = DEVICE_SUITE_TARGET_30 +else: + DEVICE_SUITE_TARGET = DEVICE_SUITE_TARGET_24 + +def LS(root, file_name, extension=None): + import glob + + file_path = "" + if extension: + file_path = JOIN(root, file_name) + "*." + extension + else: + file_path = JOIN(root, file_name) + "*" + files = glob.iglob(r'' + file_path + '') + for f in files: + return BASENAME(f) + +def get_device_arch(): + global DEV_ARCH + #ARCHCMD = SDB_SERNO + " shell \"cat /etc/products.d/tizen.prod |grep \armv7 + result = SdbManager.sdbShell(DEVID, arch_cmd) + if result and len(result) > 0: + arch_str = result.split('\n')[0] + if arch_str and arch_str.find('armv') > -1: + DEV_ARCH = "arm" + print("info: [* Arch Type : arm *]") + elif arch_str and arch_str.find("aarch64") > -1: + DEV_ARCH = "aarch64" + print("info: [* Arch Type : aarch64 *]") + elif arch_str and arch_str.find('x86_64') > -1: + DEV_ARCH = "ia64" + print("info: [* Arch Type : ia64 *]") + elif arch_str and (arch_str.find("i686") > -1 or arch_str.find("x86") > -1 or arch_str.find("i386") > -1): + DEV_ARCH = "ia" + print("info: [* Arch Type : ia *]") + else: + print("info: [* Arch Type : None *]") + return False + return True + else: + print("#ERROR#: Failed to get device cpu_arch type") + return False + + +def kill_process(process_name): + proc_cmd = "ps aux | grep " + process_name + " | grep -v grep | awk '{print $2}'" + result = SdbManager.sdbShell(DEVID, proc_cmd) + if result and len(result) > 0: + kill_cmd = "kill -9 " + str(result).strip() + " > /dev/null 2>&1" + SdbManager.sdbShell(DEVID, kill_cmd) + print("info: %s process has been killed" % process_name) + else: + print("info: No process of %s activated" % process_name) + +def remove_tinyweb(): + SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/server.pem > /dev/null 2>&1") + SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/tinyweb > /dev/null 2>&1") + SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/cgi-getcookie > /dev/null 2>&1") + SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/cgi-getfield > /dev/null 2>&1") + SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/libmongoose.so > /dev/null 2>&1") + SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/echo.so > /dev/null 2>&1") + SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/libssl.so > /dev/null 2>&1") + SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/libcrypto.so > /dev/null 2>&1") + +def remove_stub(): + SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/testkit-stub") + + +def uninstall_testconfig(): + if TIZENV.find('tizen_7.0') > -1: + inst_path = RESRC_DIR + os.sep + 'tct-testconfig' + os.sep + 'inst.py' + SdbManager.hostCommand("python %s -s %s -u" % (inst_path, DEVID)) + else: + RPMPKG = LS(RESRC_DIR, "tct-testconfig") + if not RPMPKG: + sys.exit("#ERROR#: cannot found tct-testconfig.zip file in resource dir") + uninst_cmd = JOIN(DEVICE_SUITE_TARGET, 'tct/opt/tct-testconfig/inst.sh') + ' -u' + SdbManager.sdbShell(DEVID, uninst_cmd) + rm_cmd = 'rm -f ' + JOIN(DEVICE_SUITE_TARGET, 'tct/', RPMPKG) + SdbManager.sdbShell(DEVID, rm_cmd) + + +def uninstall_behavior(): + print("info: Uninstall behavior tool.") + if TIZENV.find('tizen_7.0') > -1: + pass + else: + uninst_cmd = JOIN(DEVICE_SUITE_TARGET, 'tct/opt/tct-behavior-tests/inst.sh') + ' -u' + SdbManager.sdbShell(DEVID, uninst_cmd) + + +def check_resource_dir(): + print("info: check resource directory.") + if os.path.exists(RESRC_DIR): + SdbManager.sdbShell(DEVID, 'mkdir -p ' + JOIN(DEVICE_SUITE_TARGET, 'tct/')) + SdbManager.sdbShell(DEVID, 'mkdir -p ' + JOIN(DEVICE_SUITE_TARGET, 'Documents/')) + return True + else: + print("#WARNING#: The directory resource does not exists. Please copy test resources to %s " % RESRC_DIR) + return False + +def check_tinyweb(): + print("info: Check tinyweb.") + result = SdbManager.sdbShell(DEVID, "ls /opt/home/developer/ | grep tinyweb") + if result and result.find('tinyweb'): + remove_tinyweb() + install_tinyweb() + launch_tinyweb() + else: + install_tinyweb() + launch_tinyweb() + + +def port_manager(): + print("info: Check the tinyweb port") + result = SdbManager.sdbShell('fuser -n tcp 80 8080 8081 8082 8083 8443') + if result and len(result) > 0: + check_port = SdbManager.sdbShell('su "netstat -nap |grep tinyweb"') + if len(check_port) > 0: + print("info: tinyweb on") + else: + print("info: Port is available") + + +def launch_tinyweb(): + dpath_cmd = "printenv PATH" + dpath = SdbManager.sdbShell(DEVID, dpath_cmd) + + launch_cmd = 'sdb -s ' + DEVID + ' shell ' + '"env LD_LIBRARY_PATH=/opt/home/developer PATH=' + dpath.strip() + \ + ':/opt/home/developer/ tinyweb -ssl_certificate /opt/home/developer/server.pem -document_root ' + \ + JOIN(DEVICE_SUITE_TARGET, 'tct') + ' -listening_ports 80,8080,8081,8082,8083,8443s; sleep 3s" 0> /dev/null' + + SdbManager.sdbCommand(launch_cmd, 10) + + check_tinyweb_cmd = '\"ps aux | grep tinyweb | grep -v grep\"' + result = SdbManager.sdbShell(DEVID, check_tinyweb_cmd) + if result and result.find('tinyweb') > -1: + print("info: Active process tinyweb successfully.") + return True + else: + print("#ERROR#: Active process tinyweb failed.") + return False + +def install_tinyweb(): + print("info: Install tinyweb") + SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, 'tinyweb', DEV_ARCH, 'tinyweb'), '/opt/home/developer/') + SdbManager.sdbShell(DEVID, "chmod 777 /opt/home/developer/tinyweb") + + SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, 'tinyweb', DEV_ARCH, 'cgi-getcookie'), '/opt/home/developer/') + SdbManager.sdbShell(DEVID, "chmod 777 /opt/home/developer/cgi-getcookie") + + SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, 'tinyweb', DEV_ARCH, 'cgi-getfield'), '/opt/home/developer/') + SdbManager.sdbShell(DEVID, "chmod 777 /opt/home/developer/cgi-getfield") + + SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, 'tinyweb', DEV_ARCH, 'libmongoose.so'), '/opt/home/developer/') + SdbManager.sdbShell(DEVID, "chmod 777 /opt/home/developer/libmongoose.so") + + SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, 'tinyweb', DEV_ARCH, 'echo.so'), '/opt/home/developer/') + SdbManager.sdbShell(DEVID, "chmod 777 /opt/home/developer/echo.so") + + SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, 'tinyweb', DEV_ARCH, 'server.pem'), '/opt/home/developer/') + SdbManager.sdbShell(DEVID, "chmod 777 /opt/home/developer/server.pem") + if DEV_ARCH == "arm": + SdbManager.sdbShell(DEVID, "ln -s /usr/lib/libssl.so.1.0.0 /opt/home/developer/libssl.so") + SdbManager.sdbShell(DEVID, "ln -s /usr/lib/libcrypto.so.1.0.0 /opt/home/developer/libcrypto.so") + elif DEV_ARCH == "ia": + SdbManager.sdbShell(DEVID, "ln -s /usr/lib/libssl.so.1.0.0 /opt/home/developer/libssl.so") + SdbManager.sdbShell(DEVID, "ln -s /usr/lib/libcrypto.so.1.0.0 /opt/home/developer/libcrypto.so") + elif DEV_ARCH == "aarch64": + SdbManager.sdbShell(DEVID, "ln -s /usr/lib64/libssl.so.1.0.0 /opt/home/developer/libssl.so") + SdbManager.sdbShell(DEVID, "ln -s /usr/lib64/libcrypto.so.1.0.0 /opt/home/developer/libcrypto.so") + elif DEV_ARCH == "ia64": + SdbManager.sdbShell(DEVID, "ln -s /usr/lib64/libssl.so.1.0.0 /opt/home/developer/libssl.so") + SdbManager.sdbShell(DEVID, "ln -s /usr/lib64/libcrypto.so.1.0.0 /opt/home/developer/libcrypto.so") + + +def check_stub(): + print("info: Check testkit-stub.") + result = SdbManager.sdbShell(DEVID, "ls /opt/home/developer/ | grep testkit-stub") + if result and len(result) > 0: + print("info: testkit-stub has been installed on device.") + kill_process("testkit-stub") + install_stub() + + +def install_stub(): + print("info: Install testkit-stub.") + SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, 'testkit-stub', DEV_ARCH, 'testkit-stub'), '/opt/home/developer/testkit-stub') + SdbManager.sdbShell(DEVID, "chmod a+x /opt/home/developer/testkit-stub") + SdbManager.sdbShell(DEVID, "chsmack -e \"User\" /opt/home/developer/testkit-stub") + + +def check_testconfig(): + result = SdbManager.sdbShell(DEVID, '"cat ' + JOIN(DEVICE_SUITE_TARGET, 'tct/opt/tct-testconfig/tct-testconfig.ini') + ' | grep tct"') + if result and len(result) > 0 and result.find('No such file or directory') == -1: + print("info: testconfig has already been installed on device.") + else: + install_testconfig() + + +def install_testconfig(): + print("info: Install testconfig.") + if TIZENV.find('tizen_7.0') > -1: + instPath = RESRC_DIR + os.sep + 'tct-testconfig' + os.sep + 'inst.py' + SdbManager.hostCommand("python %s -s %s" % (instPath, DEVID)) + else: + conf_pkg = LS(RESRC_DIR, "tct-testconfig") + SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, conf_pkg), JOIN(DEVICE_SUITE_TARGET, 'tct/')) + SdbManager.sdbShell(DEVID, 'unzip -uo ' + JOIN(DEVICE_SUITE_TARGET, 'tct/') + conf_pkg + ' -d ' + JOIN(DEVICE_SUITE_TARGET, 'tct/')) + SdbManager.sdbShell(DEVID, JOIN(DEVICE_SUITE_TARGET, 'tct/opt/tct-testconfig/inst.sh')) + + result = SdbManager.sdbShell(DEVID, 'cat ' + JOIN(DEVICE_SUITE_TARGET, 'tct/opt/tct-testconfig/tct-testconfig.ini') + ' | grep tct') + + if result and len(result) > 0: + print("info: Install testconfig successfully.") + else: + print("#ERROR#: Failed to install testconfig, please check %s" % RESRC_DIR) + return False + + return True + +def install_behavior(profile_name): + print("info: Install behavior tool.") + + if not profile_name in ['wearable', 'mobile', 'tv', 'ivi']: + print("#WARNING#: Invalid device profile value %s" % profile_name) + return False + + if TIZENV.find('tizen_7.0') > -1: + RPMPKG = "tct-behavior-tests-7.0.zip" + opt_rpm_path = PKGS_DIR + "s" + os.sep + profile_name + os.sep + RPMPKG + local_rpm_path = PKGS_DIR + os.sep + profile_name + os.sep + RPMPKG + + install_rpm = None + install_dest = None + install_cmd = None + if os.path.exists(opt_rpm_path): + install_rpm = opt_rpm_path + install_dest = PKGS_DIR + "s" + os.sep + profile_name + os.sep + install_cmd = PKGS_DIR + "s" + os.sep + profile_name + os.sep + \ + 'opt' + os.sep + "tct-behavior-tests" + os.sep + "inst.py" + elif os.path.exists(local_rpm_path): + install_rpm = local_rpm_path + install_dest = PKGS_DIR + os.sep + profile_name + os.sep + install_cmd = PKGS_DIR + os.sep + profile_name + os.sep + \ + 'opt' + os.sep + "tct-behavior-tests" + os.sep + "inst.py" + + SdbManager.hostCommand("rm -rf %s" % install_dest + "opt/tct-behavior-tests") + SdbManager.hostCommand("unzip -uo %s -d %s" % (install_rpm, install_dest)) + SdbManager.hostCommand("python %s -s %s" % (install_cmd, DEVID)) + + print("info: Check tizen-web-ui-fw. Please wait...") + check_uifw = SdbManager.sdbShell(DEVID, "ls /usr/share/ | grep tizen-web-ui-fw") + if check_uifw and len(check_uifw) > 0: + print("info: tizen-web-ui-fw has been installed on device.") + else: + SdbManager.sdbShell(DEVID, '"mkdir -p /usr/share/tizen-web-ui-fw/"') + SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, "tizen-web-ui-fw"), '/usr/share/tizen-web-ui-fw/') + else: + pass + + return True + + + +def update_tctconf_file(): + print("Updating TCT_CONFIG file") + tct_config_old = "/opt/tools/TCT_CONFIG" + tct_config_new = "/opt/tools/shell/tmp/%s/TCT_CONFIG"%DEVID + + if os.path.exists(tct_config_new): + os.remove(tct_config_new) + + config_content = "" + with open(tct_config_old, 'r') as f: + config_content = f.readlines() + f_new = open(tct_config_new, 'w') + + tmp = "" + for line in config_content: + if line.find("DEVICE_PHYSICAL_STORAGE_30")!=-1: + tmp = getDevPhysicalStorage() + if tmp is None: + f_new.write(line) + else: + f_new.write("DEVICE_PHYSICAL_STORAGE_30="+tmp.strip()+"\n") + elif line.find("DEVICE_ADMIN_USER_APPS_ROOT_30")!=-1: + tmp = getDevAdminUserAppsRoot() + if tmp is None: + f_new.write(line) + else: + f_new.write("DEVICE_ADMIN_USER_APPS_ROOT_30="+tmp.strip()+"\n") elif line.find("DEVICE_STORAGE_30")!=-1: tmp = getDevStorage() if tmp is None: f_new.write(line) else: f_new.write("DEVICE_STORAGE_30="+tmp.strip()+"\n") - else: - f_new.write(line) - f_new.close() - -def getDevPhysicalStorage(): - devphysicalstorage_cmd = "tzplatform-get -u owner TZ_USER_CONTENT" - print devphysicalstorage_cmd - ret = SdbManager.sdbShell(DEVID, devphysicalstorage_cmd) - print ret - if ret is None: - print "Cannot get info from cmd : %s" %devphysicalstorage_cmd - return None - else: - ret = ret.replace('/opt/usr/','/') - print "DEVICE_PHYSICAL_STORAGE_30 : %s" %(ret.split('=')[1]) - return ret.split('=')[1] - -def getDevAdminUserAppsRoot(): - devadminuserappsroot_cmd = "tzplatform-get TZ_SYS_RW_APP" - ret = SdbManager.sdbShell(DEVID, devadminuserappsroot_cmd) - if ret is None: - print "Cannot get info from cmd : %s" %devadminuserappsroot_cmd - return None - else: - print "DEVCIE_ADMIN_USER_APPS_ROOT_30 : %s" %(ret.split('=')[1]) - return ret.split('=')[1] - + else: + f_new.write(line) + f_new.close() + +def getDevPhysicalStorage(): + devphysicalstorage_cmd = "tzplatform-get -u owner TZ_USER_CONTENT" + print(devphysicalstorage_cmd) + ret = SdbManager.sdbShell(DEVID, devphysicalstorage_cmd) + print(ret) + if ret is None: + print("Cannot get info from cmd : %s" %devphysicalstorage_cmd) + return None + else: + ret = ret.replace('/opt/usr/','/') + print("DEVICE_PHYSICAL_STORAGE_30 : %s" %(ret.split('=')[1])) + return ret.split('=')[1] + +def getDevAdminUserAppsRoot(): + devadminuserappsroot_cmd = "tzplatform-get TZ_SYS_RW_APP" + ret = SdbManager.sdbShell(DEVID, devadminuserappsroot_cmd) + if ret is None: + print("Cannot get info from cmd : %s" %devadminuserappsroot_cmd) + return None + else: + print("DEVCIE_ADMIN_USER_APPS_ROOT_30 : %s" %(ret.split('=')[1])) + return ret.split('=')[1] + def getDevStorage(): devstorage_cmd = "tzplatform-get -u owner TZ_USER_CONTENT" - print devstorage_cmd + print(devstorage_cmd) ret = SdbManager.sdbShell(DEVID, devstorage_cmd) - print ret + print(ret) if ret is None: - print "Cannot get info from cmd : %s" %devstorage_cmd + print("Cannot get info from cmd : %s" %devstorage_cmd) return None else: - print "DEVICE_STORAGE_30 : %s" %(ret.split('=')[1]) + print("DEVICE_STORAGE_30 : %s" %(ret.split('=')[1])) return ret.split('=')[1] -def push_tctconf_file(): - updated_tct_conf_local = "/opt/tools/shell/tmp/%s/TCT_CONFIG"%DEVID - remote = DEVICE_SUITE_TARGET_30 - if not SdbManager.sdbPush(DEVID, updated_tct_conf_local, remote): - print "#ERROR#: TCT_CONFIG file push failed" - return False - return True - - -def debug_trace(cmd, logfile): - global debug_flag, metux - - wbuffile = file(logfile, "a+") - exit_code = None - proc = subprocess.Popen(args=cmd, - shell=True, - stdout=wbuffile, - stderr=None) - while True: - exit_code = proc.poll() - if exit_code is not None: - break - time.sleep(0.6) - metux.acquire() - proc_flag = debug_flag - metux.release() - if not proc_flag: - break - wbuffile.close() - SdbManager.killall(proc.pid) - - -def start_debug(dlog_file): - global debug_flag, metux, dlog_thread - debug_flag = True - metux = threading.Lock() - clear_cmd = DLOG_CLEAR - SdbManager.sdbShell(DEVID, clear_cmd) - - dlog_cmd = DLOG_UTIL % DEVID - dlog_thread = threading.Thread(target=debug_trace, args=(dlog_cmd, dlog_file)) - dlog_thread.setDaemon(True) - dlog_thread.start() - - -def stop_debug(): - global debug_flag, metux - metux.acquire() - debug_flag = False - metux.release() - dlog_thread.join() - - -def runProcess(): - if options.purge: - print "[ Uninstall test resource on device. Please wait...]" - uninstall_testconfig() - uninstall_behavior() - remove_tinyweb() - kill_process("tinyweb") - kill_process("testkit-stub") - remove_stub() - print "Clean the tct packages in device successfully." - - elif options.check: - check_resource_dir() - print "[ Check test resource on device. Please wait...]" - if options.process == 'tinyweb': - check_tinyweb() - elif options.process == 'testkit-stub': - check_stub() - elif options.process == 'testconfig': - check_testconfig() - else: - check_tinyweb() - check_stub() - check_testconfig() - - print "Check finished." - - elif options.bhtest: - check_resource_dir() - - uninstall_behavior() - print "[ Install tct behavior tool on device. Please wait...]" - install_behavior(options.bhtest) - print "Installation of tct behavior on device completed." - - else: - check_resource_dir() - print "[ Clean old test resource on device. Please wait...]" - if options.process == 'tinyweb': - kill_process("tinyweb") - remove_tinyweb() - elif options.process == 'testkit-stub': - kill_process("testkit-stub") - remove_stub() - elif options.process == 'testconfig': - uninstall_testconfig() - else: - remove_tinyweb() - kill_process("testkit-stub") - remove_stub() - uninstall_testconfig() - - print "Clean the tct packages in device successfully." - print "[ Install test resource on device. Please wait...]" - if options.process == 'tinyweb': - install_tinyweb() - launch_tinyweb() - elif options.process == 'testkit-stub': - install_stub() - elif options.process == 'testconfig': - install_testconfig() - else: - install_testconfig() - install_stub() - install_tinyweb() - launch_tinyweb() - - - print "All of installation process on device completed." - - -if __name__ == "__main__": - - parser = OptionParser() - parser.add_option( - "--install", dest="install", action="store_true", default=False, - help="Install tct resources to TIZEN device,it can be omitted") - parser.add_option( - "--purge", dest="purge", action="store_true", default=False, - help="Clean up tct resources from TIZEN device") - parser.add_option( - "--check", dest="check", action="store_true", default=False, - help="Check test resource on device") - parser.add_option( - "--deviceid", dest="deviceid", action="store", - help="Set the device serial number") - parser.add_option( - "--procid", dest="process", action="store", - help="Set the process id for checking") - parser.add_option( - "--bhtest", dest="bhtest", action="store", - help="Install behavior test tool to device") - - (options, args) = parser.parse_args() - - devinst = DeviceManager.getInstance() - if options.deviceid: - if devinst.isDeviceAvailable(options.deviceid): - DEVID = options.deviceid - else: - sys.exit("#ERROR#: The '%s' device Id exists error" % options.deviceid) - else: - if devinst.getDeviceSize() > 1 or devinst.getDeviceSize() == 0: - sys.exit("#ERROR#: %s devices connected or device not connected" % str(devinst.getDeviceSize())) - else: - DEVID = devinst.getSdbDeviceList()[0].getDeviceId() - - print "[========== start tct-config-device : %s ==========]" % DEVID - dev_temp_dir = '/opt/tools/shell/tmp/%s/' % DEVID - if not os.path.isdir(dev_temp_dir): +def push_tctconf_file(): + updated_tct_conf_local = "/opt/tools/shell/tmp/%s/TCT_CONFIG"%DEVID + remote = DEVICE_SUITE_TARGET_30 + if not SdbManager.sdbPush(DEVID, updated_tct_conf_local, remote): + print("#ERROR#: TCT_CONFIG file push failed") + return False + return True + + +def debug_trace(cmd, logfile): + global debug_flag, metux + + wbuffile = file(logfile, "a+") + exit_code = None + proc = subprocess.Popen(args=cmd, + shell=True, + stdout=wbuffile, + stderr=None) + while True: + exit_code = proc.poll() + if exit_code is not None: + break + time.sleep(0.6) + metux.acquire() + proc_flag = debug_flag + metux.release() + if not proc_flag: + break + wbuffile.close() + SdbManager.killall(proc.pid) + + +def start_debug(dlog_file): + global debug_flag, metux, dlog_thread + debug_flag = True + metux = threading.Lock() + clear_cmd = DLOG_CLEAR + SdbManager.sdbShell(DEVID, clear_cmd) + + dlog_cmd = DLOG_UTIL % DEVID + dlog_thread = threading.Thread(target=debug_trace, args=(dlog_cmd, dlog_file)) + dlog_thread.setDaemon(True) + dlog_thread.start() + + +def stop_debug(): + global debug_flag, metux + metux.acquire() + debug_flag = False + metux.release() + dlog_thread.join() + + +def runProcess(): + if options.purge: + print("[ Uninstall test resource on device. Please wait...]") + uninstall_testconfig() + uninstall_behavior() + remove_tinyweb() + kill_process("tinyweb") + kill_process("testkit-stub") + remove_stub() + print("Clean the tct packages in device successfully.") + + elif options.check: + check_resource_dir() + print("[ Check test resource on device. Please wait...]") + if options.process == 'tinyweb': + check_tinyweb() + elif options.process == 'testkit-stub': + check_stub() + elif options.process == 'testconfig': + check_testconfig() + else: + check_tinyweb() + check_stub() + check_testconfig() + + print("Check finished.") + + elif options.bhtest: + check_resource_dir() + + uninstall_behavior() + print("[ Install tct behavior tool on device. Please wait...]") + install_behavior(options.bhtest) + print("Installation of tct behavior on device completed.") + + else: + check_resource_dir() + print("[ Clean old test resource on device. Please wait...]") + if options.process == 'tinyweb': + kill_process("tinyweb") + remove_tinyweb() + elif options.process == 'testkit-stub': + kill_process("testkit-stub") + remove_stub() + elif options.process == 'testconfig': + uninstall_testconfig() + else: + remove_tinyweb() + kill_process("testkit-stub") + remove_stub() + uninstall_testconfig() + + print("Clean the tct packages in device successfully.") + print("[ Install test resource on device. Please wait...]") + if options.process == 'tinyweb': + install_tinyweb() + launch_tinyweb() + elif options.process == 'testkit-stub': + install_stub() + elif options.process == 'testconfig': + install_testconfig() + else: + install_testconfig() + install_stub() + install_tinyweb() + launch_tinyweb() + + + print("All of installation process on device completed.") + + +if __name__ == "__main__": + + parser = OptionParser() + parser.add_option( + "--install", dest="install", action="store_true", default=False, + help="Install tct resources to TIZEN device,it can be omitted") + parser.add_option( + "--purge", dest="purge", action="store_true", default=False, + help="Clean up tct resources from TIZEN device") + parser.add_option( + "--check", dest="check", action="store_true", default=False, + help="Check test resource on device") + parser.add_option( + "--deviceid", dest="deviceid", action="store", + help="Set the device serial number") + parser.add_option( + "--procid", dest="process", action="store", + help="Set the process id for checking") + parser.add_option( + "--bhtest", dest="bhtest", action="store", + help="Install behavior test tool to device") + + (options, args) = parser.parse_args() + + devinst = DeviceManager.getInstance() + if options.deviceid: + if devinst.isDeviceAvailable(options.deviceid): + DEVID = options.deviceid + else: + sys.exit("#ERROR#: The '%s' device Id exists error" % options.deviceid) + else: + if devinst.getDeviceSize() > 1 or devinst.getDeviceSize() == 0: + sys.exit("#ERROR#: %s devices connected or device not connected" % str(devinst.getDeviceSize())) + else: + DEVID = devinst.getSdbDeviceList()[0].getDeviceId() + + print("[========== start tct-config-device : %s ==========]" % DEVID) + dev_temp_dir = '/opt/tools/shell/tmp/%s/' % DEVID + if not os.path.isdir(dev_temp_dir): os.makedirs(dev_temp_dir) - DLOG_SAVE_PATH = '/opt/tools/shell/tmp/%s/conf_dev_%s.dlog' - if options.process is None: - DLOG_SAVE_PATH = DLOG_SAVE_PATH % (DEVID, 'all') - else: - DLOG_SAVE_PATH = DLOG_SAVE_PATH % (DEVID, options.process) - - #start_debug(DLOG_SAVE_PATH) - - if not SdbManager.sdbRootOn(DEVID): - sys.exit(-1) - - SdbManager.sdbSetDate(DEVID) - - update_tctconf_file() - if not get_device_arch() or not push_tctconf_file(): - sys.exit(0) - - runProcess() - #stop_debug() - print "[========== end tct-config-device : %s ==========]" % DEVID - + DLOG_SAVE_PATH = '/opt/tools/shell/tmp/%s/conf_dev_%s.dlog' + if options.process is None: + DLOG_SAVE_PATH = DLOG_SAVE_PATH % (DEVID, 'all') + else: + DLOG_SAVE_PATH = DLOG_SAVE_PATH % (DEVID, options.process) + + #start_debug(DLOG_SAVE_PATH) + + if not SdbManager.sdbRootOn(DEVID): + sys.exit(-1) + + SdbManager.sdbSetDate(DEVID) + + update_tctconf_file() + if not get_device_arch() or not push_tctconf_file(): + sys.exit(0) + + runProcess() + #stop_debug() + print("[========== end tct-config-device : %s ==========]" % DEVID) + diff --git a/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/tools/tct-config-host.py b/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/tools/tct-config-host.py index bfa213c..553e83d 100644 --- a/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/tools/tct-config-host.py +++ b/release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/tools/tct-config-host.py @@ -1,4 +1,4 @@ -# -*- coding:utf-8 -*- +#!/usr/bin/env python3 import os import sys import platform @@ -45,8 +45,8 @@ class CpFile: def setCurrentPath(self): self.CURRENT_SOURCE_BASE_PATH = os.getcwd() + self.sep self.CURRENT_TARGET_BASE_PATH = self.TARGET_BASE_PATH - print("current source base path =" + self.CURRENT_SOURCE_BASE_PATH) - print("current target base path =" + self.CURRENT_TARGET_BASE_PATH) + print(("current source base path =" + self.CURRENT_SOURCE_BASE_PATH)) + print(("current target base path =" + self.CURRENT_TARGET_BASE_PATH)) def cpDoc(self): self.cpDir(self.CURRENT_SOURCE_BASE_PATH + self.SOURCE_DOC_PATH, @@ -100,7 +100,7 @@ class CpFile: def cpFile(self, src, target): if (not os.path.isfile(src)): - print(src + " is not a file") + print((src + " is not a file")) return path = os.path.dirname(target) if (not os.path.isdir(path)): @@ -114,39 +114,46 @@ class CpFile: def cpDir(self, src, target, name): if (os.path.isdir(src) and not os.path.exists(target)): - print("copy " + name + " dir start") + print(("copy " + name + " dir start")) shutil.copytree(src, target) - print("copy " + name + " dir finish") + print(("copy " + name + " dir finish")) else: if (not os.path.isdir(src)): - print("source " + name + " path is not a dir") + print(("source " + name + " path is not a dir")) if (os.path.exists(target)): - print ("target " + name + " path is exists") + print(("target " + name + " path is exists")) try: shutil.rmtree(target, onerror=self.del_rw) - except Exception, data: - print Exception, ":", data + except Exception as data: + print(Exception, ":", data) - print ("target " + name + " dir destroyed") + print(("target " + name + " dir destroyed")) try: shutil.copytree(src, target) - except Exception, data: - print Exception, ":", data - print("copy " + name + " dir finish") + except Exception as data: + print(Exception, ":", data) + print(("copy " + name + " dir finish")) def clear(self): self.setCurrentPath() try: shutil.rmtree(self.CURRENT_TARGET_BASE_PATH, onerror=self.del_rw) - except Exception, data: - print Exception, ":", data + except Exception as data: + print(Exception, ":", data) def makeResult(self): + mgr_folder = os.path.join(self.CURRENT_TARGET_BASE_PATH, \ + self.tizenV + "/manager") mgr_result_folder = os.path.join(self.CURRENT_TARGET_BASE_PATH, \ self.tizenV + "/manager/result") shell_result_folder = os.path.join(self.CURRENT_TARGET_BASE_PATH, \ self.tizenV + "/shell/result") + if not os.path.isdir(mgr_folder): + os.makedirs(mgr_folder) + if (platform.system() != "Windows"): + os.chmod(mgr_folder, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) + if not os.path.isdir(mgr_result_folder): os.makedirs(mgr_result_folder) else: @@ -186,7 +193,7 @@ parser.add_option("-u", "--upgrade", dest="upgrade", action="store_true", \ (options, args) = parser.parse_args() if options.tizenV is None: - print "[ Error : input your tizen version ]" + print("[ Error : input your tizen version ]") sys.exit(1) if (options.install): diff --git a/release/csharp-tct_7.0_dotnet/tct-setup.py b/release/csharp-tct_7.0_dotnet/tct-setup.py index f526c87..7223127 100644 --- a/release/csharp-tct_7.0_dotnet/tct-setup.py +++ b/release/csharp-tct_7.0_dotnet/tct-setup.py @@ -1,4 +1,4 @@ -# -*- coding:utf-8 -*- +#!/usr/bin/env python3 import os import sys import shutil @@ -88,7 +88,7 @@ def unpack_release_file(afile): msg += "a directory." else: msg += "something else." - print msg + print (msg) tar.extractall() tar.close() diff --git a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tct-shell b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tct-shell index 86d6d0c..4db5e9d 100644 --- a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tct-shell +++ b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tct-shell @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # # Copyright (C) 2012 Intel Corporation # diff --git a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/constants.py b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/constants.py index 30e7c60..b593ae1 100644 --- a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/constants.py +++ b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/constants.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # # Copyright (C) 2012 Intel Corporation # diff --git a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/devicemanager.py b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/devicemanager.py index 33469dc..40ac48a 100644 --- a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/devicemanager.py +++ b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/devicemanager.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 import queue from multiprocessing.managers import BaseManager diff --git a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/dumpmonitor.py b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/dumpmonitor.py index ba595f0..94a4449 100644 --- a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/dumpmonitor.py +++ b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/dumpmonitor.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 import time from multiprocessing import Process diff --git a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/environment_manager.py b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/environment_manager.py index 5e2526c..e74c2b6 100644 --- a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/environment_manager.py +++ b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/environment_manager.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 from multiprocessing import Queue from .shellguider import Guider diff --git a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/intention_generator.py b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/intention_generator.py index 74f77b0..8a49674 100644 --- a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/intention_generator.py +++ b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/intention_generator.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 import os import re from .constants import Constants @@ -109,12 +109,12 @@ def _read_xml_suiteInfo(test_file, tc_name): autocnt = manualcnt = 0 test_xml_temp = etree.parse(test_file) tc_exist = False - for test_xml_temp_suite in test_xml_temp.getiterator('suite'): + for test_xml_temp_suite in test_xml_temp.iter('suite'): suite_name = test_xml_temp_suite.get('name') suite_launcher = test_xml_temp_suite.get('launcher') suite_category = test_xml_temp_suite.get('category') autocnt = manualcnt = 0 - for tset in test_xml_temp_suite.getiterator('set'): + for tset in test_xml_temp_suite.iter('set'): set_autocnt, set_manualcnt, tcCheck = \ _read_xml_tcInfo(tset, tc_name) autocnt += set_autocnt @@ -134,7 +134,7 @@ def _read_xml_suiteInfo(test_file, tc_name): def _read_xml_tcInfo(tset, tc_name): set_autocnt = set_manualcnt = 0 tcCheck = False - for tcase in tset.getiterator('testcase'): + for tcase in tset.iter('testcase'): tcId = tcase.get('id') exetype = tcase.get('execution_type') if exetype == "auto": diff --git a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/netstatmonitor.py b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/netstatmonitor.py index 74feb07..0f3bb35 100644 --- a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/netstatmonitor.py +++ b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/netstatmonitor.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 import time diff --git a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/plan_options.py b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/plan_options.py index 399a67b..88969f1 100644 --- a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/plan_options.py +++ b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/plan_options.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # # Copyright (C) 2012 Intel Corporation # @@ -31,10 +31,10 @@ from logmanager import LOGGER #show all available suites def _show_available_suites(option, opt_str, value, parser): - print "Test Suites:...\n" + print("Test Suites:...\n") os.chdir("/opt/tct/") for t_version in glob.glob("tizen*"): - print "Tizen Version : %s" % t_version + print("Tizen Version : %s" % t_version) package_dir = os.path.join(os.path.abspath(t_version), 'packages') if not os.path.isdir(package_dir): continue @@ -42,17 +42,17 @@ def _show_available_suites(option, opt_str, value, parser): for profile in glob.glob("*"): if profile == 'pkg_infos': continue - print " profile : %s" % profile + print(" profile : %s" % profile) os.chdir(os.path.abspath(profile)) for files in glob.glob("*.zip"): - print " " + files[:-4] + print(" " + files[:-4]) os.chdir('../') os.chdir('../../') sys.exit(1) def _print_planfolder(option, opt_str, value, parser): - print "Plan folder: %s" % Constants.TCT_PLAN_FOLDER + print("Plan folder: %s" % Constants.TCT_PLAN_FOLDER) os.system("tree %s" % Constants.TCT_PLAN_FOLDER) sys.exit(1) @@ -107,7 +107,7 @@ Note: \n\ 1) run command 'tct-plan-generator', it might not be able to locate related module, run command 'export PYTHONPATH=/usr/lib/python2.7/site-packages' to resolve this issue" def print_usage(self): - print self.USAGE + print(self.USAGE) def parse_options(self, argv): option_list = [ @@ -208,7 +208,7 @@ Note: \n\ (self.options.tizenversion[0] is not None): return self.options.tizenversion[0] else: - print "Error: Please specify Tizen version with [--tizen-version] option" + print("Error: Please specify Tizen version with [--tizen-version] option") sys.exit(1) def get_output(self): diff --git a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/plan_runner.py b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/plan_runner.py index 28553c1..f7f048e 100644 --- a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/plan_runner.py +++ b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/plan_runner.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # # Copyright (C) 2012 Intel Corporation # This program is free software; you can redistribute it and/or @@ -92,11 +92,11 @@ class PlanRunner: os.chdir(repo) for files in glob.glob("*" + match + "*"): - print "Matched File name: %s" % str(os.path.abspath(files)) + print("Matched File name: %s" % str(os.path.abspath(files))) if (unmatch is not None) and (re.search(unmatch, \ str(files))): - print "File %s is skipped with unmatch regex %s" \ - % (str(files), unmatch) + print("File %s is skipped with unmatch regex %s" \ + % (str(files), unmatch)) else: raw_paths.append(os.path.join(repo, str(files))) @@ -114,9 +114,9 @@ class PlanRunner: launcher, category, auto, manual) self.suites[suite.name] = suite Constants.clean_unzip_file() - except Exception, e: - print "[ Error happen when reading the local repository," + \ - " error: %s ]\n" % e + except Exception as e: + print("[ Error happen when reading the local repository," + \ + " error: %s ]\n" % e) def _chooseProfile(self, path_suites): suite_profiles = {} @@ -136,12 +136,12 @@ class PlanRunner: suite_profiles[suiteName] = suiteProfile[0] continue - print "\nMultiple profiles for [%s] \ + print("\nMultiple profiles for [%s] \ :\n----------------------------------------------" \ - % suite_name + % suite_name) for profile_i in suiteProfile: - print " - %s" % profile_i + print(" - %s" % profile_i) suite_profile = None while not suite_profile in suiteProfile: @@ -184,11 +184,11 @@ class PlanRunner: autocnt = manualcnt = 0 test_xml_temp = etree.parse(test_file) - for test_xml_temp_suite in test_xml_temp.getiterator('suite'): + for test_xml_temp_suite in test_xml_temp.iter('suite'): suite_launcher = test_xml_temp_suite.get('launcher') suite_category = test_xml_temp_suite.get('category') autocnt = manualcnt = 0 - for tset in test_xml_temp_suite.getiterator('set'): + for tset in test_xml_temp_suite.iter('set'): set_autocnt, set_manualcnt = self.__get_set_casecnt(tset) autocnt += set_autocnt manualcnt += set_manualcnt @@ -197,7 +197,7 @@ class PlanRunner: def __get_set_casecnt(self, tset): set_autocnt = set_manualcnt = 0 - for tcase in tset.getiterator('testcase'): + for tcase in tset.iter('testcase'): exetype = tcase.get('execution_type') if exetype == "auto": set_autocnt += 1 diff --git a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/result_manager.py b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/result_manager.py index d6462de..9c8262d 100644 --- a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/result_manager.py +++ b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/result_manager.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 import os import threading diff --git a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/result_summary.py b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/result_summary.py index 2a6450b..f5a8c97 100644 --- a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/result_summary.py +++ b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/result_summary.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 from xml.etree import ElementTree import os diff --git a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/sdbmanager.py b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/sdbmanager.py index 0a10c1f..2044795 100644 --- a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/sdbmanager.py +++ b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/sdbmanager.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 import subprocess import time @@ -290,9 +290,9 @@ class SdbManager: @staticmethod def recoveryDevice(_tizenV, _deviceid): if _tizenV: - tinycmd = "python " + Constants.DEVICE_HEALTH_CMD % _tizenV + \ + tinycmd = "python3 " + Constants.DEVICE_HEALTH_CMD % _tizenV + \ " --check --proc=tinyweb --deviceid=" + _deviceid - stubcmd = "python " + Constants.DEVICE_HEALTH_CMD % _tizenV + \ + stubcmd = "python3 " + Constants.DEVICE_HEALTH_CMD % _tizenV + \ " --check --proc=testkit-stub --deviceid=" + _deviceid outLog, errLog = SdbManager.sdbCommand(tinycmd) if errLog: LOGGER.error(str(errLog)) diff --git a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/shellguider.py b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/shellguider.py index 7d1f4dc..10500cf 100644 --- a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/shellguider.py +++ b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/shellguider.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 import os import configparser diff --git a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/shellplanner.py b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/shellplanner.py index 3e75dcc..0009adf 100644 --- a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/shellplanner.py +++ b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/shellplanner.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 import shutil import os diff --git a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/shellworker.py b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/shellworker.py index 5869802..9e82b80 100644 --- a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/shellworker.py +++ b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/shellworker.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 import threading import time diff --git a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/shellwrapper.py b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/shellwrapper.py index 9a7b88b..202f865 100644 --- a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/shellwrapper.py +++ b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/shellwrapper.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 import os import sys diff --git a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/testenvironment.py b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/testenvironment.py index fb5b84c..0869de8 100644 --- a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/testenvironment.py +++ b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/testenvironment.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 import os import configparser from multiprocessing import Process diff --git a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/usbmonitor.py b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/usbmonitor.py index a75b204..e8af1db 100644 --- a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/usbmonitor.py +++ b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/shell/tctshell/usbmonitor.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 import threading import subprocess diff --git a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/tct-config-tools.py b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/tct-config-tools.py index 6a05f3c..dcd4bc7 100644 --- a/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/tct-config-tools.py +++ b/release/csharp-tct_7.0_dotnet/tct-tools_r4_rc1/tct-config-tools.py @@ -1,4 +1,4 @@ -# -*- coding:utf-8 -*- +#!/usr/bin/env python3 import os import platform import shutil @@ -288,25 +288,25 @@ class CpFile: if (not os.path.isdir(src)): print("source " + name + " path is not a dir") if (os.path.exists(target)): - print ("target " + name + " path is exists") + print("target " + name + " path is exists") try: shutil.rmtree(target, onerror=self.del_rw) - except Exception, data: - print Exception, ":", data + except Exception as data: + print(Exception, ":", data) - print ("target " + name + " dir destroyed") + print("target " + name + " dir destroyed") try: shutil.copytree(src, target) - except Exception, data: - print Exception, ":", data + except Exception as data: + print(Exception, ":", data) print("copy " + name + " dir finish") def clear(self): self.setCurrentPath() try: shutil.rmtree(self.CURRENT_TARGET_BASE_PATH, onerror=self.del_rw) - except Exception, data: - print Exception, ":", data + except Exception as data: + print(Exception, ":", data) def cp(self): self.setCurrentPath() diff --git a/tct-suite-vs/Tizen.Mediacontent.Manual.Tests/res/copy_res.sh b/tct-suite-vs/Tizen.Mediacontent.Manual.Tests/res/copy_res.sh index 040f490..fefcb86 100755 --- a/tct-suite-vs/Tizen.Mediacontent.Manual.Tests/res/copy_res.sh +++ b/tct-suite-vs/Tizen.Mediacontent.Manual.Tests/res/copy_res.sh @@ -1,5 +1,6 @@ LOCATION='/home/owner/share' # Change the destination of the resource folder(absolute path). +# Update for syntax issue(2022.06.02). DESTINATION_MOBILE='/home/owner/media' DESTINATION_TV='/home/owner/content' @@ -23,15 +24,15 @@ DIR_LIST=( if [ "$1" == "-i" ] then - for value in "${FILE_LIST[@]}";do + for value in "${FILE_LIST[@]}";do cp $LOCATION/$value $DESTINATION done - for value in "${DIR_LIST[@]}";do + for value in "${DIR_LIST[@]}";do cp -R $LOCATION/$value $DESTINATION done elif [ "$1" == "-u" ] then - for value in "${FILE_LIST[@]}";do + for value in "${FILE_LIST[@]}";do rm $DESTINATION/$value done for value in "${DIR_LIST[@]}";do diff --git a/tct-suite-vs/Tizen.Mediacontent.Tests/res/copy_res.sh b/tct-suite-vs/Tizen.Mediacontent.Tests/res/copy_res.sh index 79f4cbd..43f0385 100755 --- a/tct-suite-vs/Tizen.Mediacontent.Tests/res/copy_res.sh +++ b/tct-suite-vs/Tizen.Mediacontent.Tests/res/copy_res.sh @@ -1,5 +1,6 @@ LOCATION='/home/owner/share' # Change the destination of the resource folder(absolute path). +# Update for syntax issue(2022.06.02). DESTINATION_MOBILE='/home/owner/media' DESTINATION_TV='/home/owner/content' @@ -21,15 +22,15 @@ DIR_LIST=( if [ "$1" == "-i" ] then - for value in "${FILE_LIST[@]}";do + for value in "${FILE_LIST[@]}";do cp $LOCATION/$value $DESTINATION done - for value in "${DIR_LIST[@]}";do + for value in "${DIR_LIST[@]}";do cp -R $LOCATION/$value $DESTINATION done elif [ "$1" == "-u" ] then - for value in "${FILE_LIST[@]}";do + for value in "${FILE_LIST[@]}";do rm $DESTINATION/$value done for value in "${DIR_LIST[@]}";do diff --git a/tool/script/artik_template/inst.py b/tool/script/artik_template/inst.py index ad6202d..d6bc952 100755 --- a/tool/script/artik_template/inst.py +++ b/tool/script/artik_template/inst.py @@ -7,11 +7,11 @@ import time import sys import subprocess import string -import ConfigParser +import configparser from optparse import OptionParser, make_option TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG" -tct_parser = ConfigParser.ConfigParser() +tct_parser = configparser.ConfigParser() tct_parser.read(TCT_CONFIG_FILE) DEVICE_SUITE_TARGET_30 = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30') @@ -32,14 +32,14 @@ RES_SRC_DIR = SRC_DIR + "/Documents/tct/" def doCMD(cmd): # Do not need handle timeout in this short script, let tool do it - print "-->> \"%s\"" % cmd + print ("-->> \"%s\"" % cmd) output = [] cmd_return_code = 1 cmd_proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) while True: - output_line = cmd_proc.stdout.readline().strip("\r\n") + output_line = cmd_proc.stdout.readline().decode('utf-8').strip("\r\n") cmd_return_code = cmd_proc.poll() if output_line == '' and cmd_return_code != None: break @@ -134,7 +134,7 @@ def instPKGs(): for file in ['preconfigure.json', 'tests.xml', 'tct-testconfig.ini', 'portconfigure.json', 'TC_Config.txt']: if not doRemoteCopy(SCRIPT_DIR + '/' + file, "%s/%s" % (PKG_SRC_DIR, file)): action_status = False - print "#############################################################################################################################################" + print ("#############################################################################################################################################") doRemoteCopy(RES_DIR_PATH + '/' + 'capability.xml', "%s/%s" % (RES_SRC_DIR, 'capability.xml')) doRemoteCopy(RES_DIR_PATH + '/' + 'buildinfo.xml', "%s/%s" % (RES_SRC_DIR, 'buildinfo.xml')) #(return_code, output) = doRemoteCMD("touch %s/%s" % (RES_SRC_DIR, 'buildinfo.xml')) @@ -158,8 +158,8 @@ def main(): "-a", dest="user", action="store", help="User name") global PARAMETERS (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e + except Exception as e: + print ("Got wrong option: %s, exit ...") % e sys.exit(1) if not PARAMETERS.user: @@ -178,7 +178,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -188,10 +188,10 @@ def main(): userid = user_info[1][0] XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) else: - print "[Error] cmd commands error : %s"%str(user_info[1]) + print ("[Error] cmd commands error : %s"%str(user_info[1])) sys.exit(1) if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" + print ("-i and -u are conflict") sys.exit(1) if PARAMETERS.buninstpkg: diff --git a/tool/script/auto_binary.py b/tool/script/auto_binary.py index 74aebe2..0fdfbc6 100755 --- a/tool/script/auto_binary.py +++ b/tool/script/auto_binary.py @@ -11,7 +11,7 @@ from sys import platform def is_binary(filename): with open(filename, 'rb') as f: for block in f: - if '\0' in block: + if b'\0' in block: return True return False @@ -35,8 +35,8 @@ if __name__ == "__main__": # pack tv package - os.system(LINUX_PERMISSION+' python pack.py '+'all') - os.system(LINUX_PERMISSION+' python pack.py '+'manual NUI') + os.system(LINUX_PERMISSION+' python3 pack.py '+'all') + os.system(LINUX_PERMISSION+' python3 pack.py '+'manual NUI') # Copy mobile package folder to tv package. # set tv_pkg_info.xml @@ -48,12 +48,12 @@ if __name__ == "__main__": # pack wearable package - os.system(LINUX_PERMISSION+' python pack.py '+'all') - os.system(LINUX_PERMISSION+' python pack.py '+'auto ElmSharpWearable') - os.system(LINUX_PERMISSION+' python pack.py '+'manual ElmSharpWearable') - os.system(LINUX_PERMISSION+' python pack.py '+'auto NUI.Wearable') - os.system(LINUX_PERMISSION+' python pack.py '+'manual NUI.Wearable') - os.system(LINUX_PERMISSION+' python pack.py '+'auto WatchfaceComplication') + os.system(LINUX_PERMISSION+' python3 pack.py '+'all') + os.system(LINUX_PERMISSION+' python3 pack.py '+'auto ElmSharpWearable') + os.system(LINUX_PERMISSION+' python3 pack.py '+'manual ElmSharpWearable') + os.system(LINUX_PERMISSION+' python3 pack.py '+'auto NUI.Wearable') + os.system(LINUX_PERMISSION+' python3 pack.py '+'manual NUI.Wearable') + os.system(LINUX_PERMISSION+' python3 pack.py '+'auto WatchfaceComplication') # Copy mobile package folder to wearable package. # set wearable_pkg_info.xml @@ -64,8 +64,8 @@ if __name__ == "__main__": os.rename('../../release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/package/mobile','../../release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/package/wearable') # pack tizeniot package - os.system(LINUX_PERMISSION + ' python pack.py ' + 'all') - os.system(LINUX_PERMISSION+' python pack.py '+'manual NUI') + os.system(LINUX_PERMISSION + ' python3 pack.py ' + 'all') + os.system(LINUX_PERMISSION+' python3 pack.py '+'manual NUI') # Copy mobile package folder to tizeniot package. # set tizeniot_pkg_info.xml @@ -81,8 +81,8 @@ if __name__ == "__main__": # pack mobile package create_folder('../../release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/package/mobile') - os.system(LINUX_PERMISSION+' python pack.py '+'all') - os.system(LINUX_PERMISSION+' python pack.py '+'manual NUI') + os.system(LINUX_PERMISSION+' python3 pack.py '+'all') + os.system(LINUX_PERMISSION+' python3 pack.py '+'manual NUI') @@ -115,7 +115,10 @@ if __name__ == "__main__": s = os.path.join(src, item) d = os.path.join(dst, item) if os.path.isdir(s): - shutil.copytree(s, d, symlinks=False, ignore=None) + try: + shutil.copytree(s, d, symlinks=False, ignore=None) + except OSError as e: + print("Error: %s - %s." % (e.filename, e.strerror)) else: shutil.copy2(s, d) @@ -135,12 +138,12 @@ if __name__ == "__main__": os.system('sudo chmod -R 777 '+ '../../release/csharp-tct_7.0_' + date_time) #changing file format - for root, dirs, files in os.walk(dst): - for file in files: - p=os.path.join(root,file) - if not(is_binary(os.path.abspath(p))): - text = open(os.path.abspath(p), 'rb').read().replace('\r\n','\n') - open(os.path.abspath(p), 'wb').write(text) + #for root, dirs, files in os.walk(dst): + # for file in files: + # p=os.path.join(root,file) + # if not(is_binary(os.path.abspath(p))): + # text = open(os.path.abspath(p), 'rb').read().replace('\r\n','\n') + # open(os.path.abspath(p), 'wb').write(text) with tarfile.open('../../release/csharp-tct_7.0_'+date_time+'.tar.gz', "w:gz") as tar: tar.add(dst, arcname=os.path.basename(dst)) diff --git a/tool/script/cli_pack.py b/tool/script/cli_pack.py index 0435d33..a5f44ea 100755 --- a/tool/script/cli_pack.py +++ b/tool/script/cli_pack.py @@ -98,7 +98,8 @@ def folder_list(path): def create_folder(path): if not os.path.isdir(path): - os.mkdir(path,0777) + #os.mkdir(path,0777) + os.makedirs(path, exist_ok = True) def remove_folder(path): if os.path.isdir(path): @@ -180,8 +181,10 @@ def pack(module , cnt): # Create bin/opt and package folder. - os.mkdir('bin/opt',0777) - os.mkdir('bin/opt/'+PACKAGE_NAME,0777) + #os.mkdir('bin/opt',0777) + #os.mkdir('bin/opt/'+PACKAGE_NAME,0777) + os.makedirs('bin/opt', exist_ok = True) + os.makedirs('bin/opt/'+PACKAGE_NAME, exist_ok = True) # create new test.xml file file_list = read_all_testfiles(PROJECT_PATH+PACKAGE_NAME+'/testcase/') diff --git a/tool/script/creating_auto_binary.sh b/tool/script/creating_auto_binary.sh index 0282da3..4065194 100755 --- a/tool/script/creating_auto_binary.sh +++ b/tool/script/creating_auto_binary.sh @@ -4,19 +4,19 @@ TCT_VERSION='7.0' # tct-common path # {repository_path}/tct-common -TCT_COMMON='/home/tizen/ReleaseIOT/TCT/tct-common' +TCT_COMMON='/home/tizen/ShareFolder/tct-tool/tct-common/tct-common' # tct-mgr path # {repository_path}/tct-mgr -TCT_MGR='/home/tizen/ReleaseIOT/TCT/tct-mgr' +TCT_MGR='/home/tizen/ShareFolder/tct-tool/tct-mgr/tct-mgr' # tct-shell path # {repository_path}/tct-shell -TCT_SHELL='/home/tizen/ReleaseIOT/TCT/tct-shell' +TCT_SHELL='/home/tizen/ShareFolder/tct-tool/tct-shell/tct-shell' # tct path # {repository_path}/api/release/chsarp-tct_7.0_dotnet -TCT_PATH='/home/tizen/ReleaseIOT/TCT/TCT_7.0/api/release/csharp-tct_7.0_dotnet' +TCT_PATH='/home/tizen/ShareFolder/4.Fx_Win/TCT_7.0/api/release/csharp-tct_7.0_dotnet' echo "Getting latest tct-common, tct-mgr & tct-shell in spin repository." cd $TCT_COMMON @@ -32,7 +32,7 @@ git reset --hard git pull echo "Updating resource folder" -rsync -avz --exclude=tct-testconfig --exclude=tct-testconfig-3.0.zip $TCT_COMMON/tools/tct_"$TCT_VERSION"/resource/ $TCT_PATH/csharp-tct_"$TCT_VERSION"_dotnet/resource/ +rsync -avz --exclude=tct-testconfig-3.0.zip $TCT_COMMON/tools/tct_"$TCT_VERSION"/resource/ $TCT_PATH/csharp-tct_"$TCT_VERSION"_dotnet/resource/ # remove tizen-web-ui-fw and tinyweb folder rm -rf $TCT_PATH/csharp-tct_"$TCT_VERSION"_dotnet/resource/tizen-web-ui-fw/ @@ -61,4 +61,4 @@ sudo chmod -R 777 $TCT_PATH/tct-tools_r4_rc1/ cd $TCT_PATH cd ../../tool/script -sudo python auto_binary.py +sudo python3 auto_binary.py \ No newline at end of file diff --git a/tool/script/pack.py b/tool/script/pack.py index d96fd5f..744abf4 100755 --- a/tool/script/pack.py +++ b/tool/script/pack.py @@ -9,6 +9,7 @@ import zipfile from xml.etree.ElementTree import Element, SubElement, dump, parse, ElementTree from pkginfo_gen import PKGInfoGenerator from tcxml import read_tc_list, read_all_testfiles, indent, write_xml +from pathlib import Path PREFIX = 'Tizen.' SUFFIX = '.Tests' @@ -110,11 +111,22 @@ def folder_list(path): def create_folder(path): if not os.path.isdir(path): - os.mkdir(path,0777) + os.makedirs(path, exist_ok = True) + #os.mkdir(path,0o777) def remove_folder(path): + #print("Path:"+path) if os.path.isdir(path): - shutil.rmtree(path) + #print("Vao day khong 1") + for sub in Path(path).iterdir(): + #print("Vao day khong 2") + if not sub.is_dir(): + #print("AAAAAAAAAAAAAAAAAA:"+str(sub)) + sub.unlink() + else: + #print("Vao day khong 3") + remove_folder(str(sub)) + Path(path).rmdir() def copy_helper_application(folder_path , dest): create_folder(dest) @@ -195,8 +207,10 @@ def pack(module , cnt): # Create bin/opt and package folder. - os.mkdir('bin/opt',0777) - os.mkdir('bin/opt/'+PACKAGE_NAME,0777) + os.makedirs('bin/opt', exist_ok = True) + os.makedirs('bin/opt/'+PACKAGE_NAME, exist_ok = True) + #Path("bin/opt").mkdir(parents=True, exist_ok=True) + #Path('bin/opt/'+PACKAGE_NAME).mkdir(parents=True, exist_ok=True) # create new test.xml file file_list = read_all_testfiles(PROJECT_PATH+PACKAGE_NAME+'/testcase/') diff --git a/tool/script/pkginfo_gen.py b/tool/script/pkginfo_gen.py index c67e90d..e7d9ce7 100755 --- a/tool/script/pkginfo_gen.py +++ b/tool/script/pkginfo_gen.py @@ -4,12 +4,28 @@ import sys import zipfile import shutil import platform +import pathlib +import shutil +from pathlib import Path FILE_PATH = '../../release/csharp-tct_7.0_dotnet/csharp-tct_7.0_dotnet/package/pkg_infos/mobile_pkg_info.xml' OKGREEN = '\033[92m' ENDC = '\033[0m' + +def del_folder(path): + for sub in Path(path).iterdir(): + if sub.is_dir(): + # Delete folder if it is a folder + del_folder(sub) + else: + # Delete file if it is a file: + sub.unlink() + + # This removes the top-level folder: + Path(path).rmdir() + class PKGInfoGenerator: # If option is 'all', all package generate. module = '' @@ -17,7 +33,7 @@ class PKGInfoGenerator: self.module = module def print_log(self, string): - print OKGREEN + string + ENDC + print (OKGREEN + string + ENDC) def generate_pkg_info(self): self.init_file() @@ -90,7 +106,8 @@ class PKGInfoGenerator: self.set_testsuite_tag(project_name, tc_number, auto_manual) # Remove Unzip folder - shutil.rmtree(dest) + #shutil.rmtree(dest) + del_folder(dest) def set_testsuite_tag(self, project_name, tc_number, auto_manual): if self.module == 'all' : diff --git a/tool/script/tct-testconfig/inst.apk.py b/tool/script/tct-testconfig/inst.apk.py index 31210db..36bc382 100755 --- a/tool/script/tct-testconfig/inst.apk.py +++ b/tool/script/tct-testconfig/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/tool/script/tct-testconfig/inst.wgt.py b/tool/script/tct-testconfig/inst.wgt.py index fc1b497..4c0388a 100755 --- a/tool/script/tct-testconfig/inst.wgt.py +++ b/tool/script/tct-testconfig/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) @@ -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 @@ -145,8 +145,8 @@ def main(): "-a", dest="user", action="store", help="User name") global PARAMETERS (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) sys.exit(1) if not PARAMETERS.user: @@ -165,7 +165,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -175,10 +175,10 @@ def main(): userid = user_info[1][0] XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) else: - print "[Error] cmd commands error : %s"%str(user_info[1]) + print ("[Error] cmd commands error : %s"%str(user_info[1])) sys.exit(1) if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" + print ("-i and -u are conflict") sys.exit(1) if PARAMETERS.buninstpkg: diff --git a/tool/script/tct-testconfig/inst.xpk.py b/tool/script/tct-testconfig/inst.xpk.py index 211d24c..c3cb4b5 100755 --- a/tool/script/tct-testconfig/inst.xpk.py +++ b/tool/script/tct-testconfig/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/tool/script/tct-testconfig/pack.py b/tool/script/tct-testconfig/pack.py index e67cd36..c9e7a20 100755 --- a/tool/script/tct-testconfig/pack.py +++ b/tool/script/tct-testconfig/pack.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (c) 2014 Intel Corporation. # @@ -405,10 +405,10 @@ def packXPK(build_json=None, app_src=None, app_dest=None, app_name=None): os.chdir(orig_dir) return False if key_file: - pack_cmd = "python make_xpk.py %s %s -o %s" % ( + pack_cmd = "python3 make_xpk.py %s %s -o %s" % ( app_src, key_file, os.path.join(app_dest, "%s.xpk" % app_name)) else: - pack_cmd = "python make_xpk.py %s key.file -o %s" % ( + pack_cmd = "python3 make_xpk.py %s key.file -o %s" % ( app_src, os.path.join(app_dest, "%s.xpk" % app_name)) if not doCMD(pack_cmd, DEFAULT_CMD_TIMEOUT): os.chdir(orig_dir) @@ -504,7 +504,7 @@ def packAPK(build_json=None, app_src=None, app_dest=None, app_name=None): icon_opt = "--icon=%s/icon.png" % app_src if safelyGetValue(build_json, "apk-type") == "MANIFEST": - pack_cmd = "python make_apk.py --package=org.xwalk.%s " \ + pack_cmd = "python3 make_apk.py --package=org.xwalk.%s " \ "--manifest=%s/manifest.json %s %s %s %s %s" % ( app_name, app_src, mode_opt, arch_opt, ext_opt, cmd_opt, common_opts) @@ -513,12 +513,12 @@ def packAPK(build_json=None, app_src=None, app_dest=None, app_name=None): LOG.error( "Fail to find the key \"apk-url-opt\" for hosted APP packing") return False - pack_cmd = "python make_apk.py --package=org.xwalk.%s --name=%s %s " \ + pack_cmd = "python3 make_apk.py --package=org.xwalk.%s --name=%s %s " \ "%s %s %s %s %s" % ( app_name, app_name, mode_opt, arch_opt, ext_opt, cmd_opt, url_opt, common_opts) else: - pack_cmd = "python make_apk.py --package=org.xwalk.%s --name=%s " \ + pack_cmd = "python3 make_apk.py --package=org.xwalk.%s --name=%s " \ "--app-root=%s --app-local-path=index.html %s %s " \ "%s %s %s %s" % ( app_name, app_name, app_src, icon_opt, mode_opt, @@ -938,7 +938,7 @@ def main(): sys.exit(1) if BUILD_PARAMETERS.bversion: - print "Version: %s" % TOOL_VERSION + print ("Version: %s" % TOOL_VERSION) sys.exit(0) if not BUILD_PARAMETERS.srcdir: diff --git a/tool/script/template/inst.py b/tool/script/template/inst.py index 593f6d6..c6be0d8 100755 --- a/tool/script/template/inst.py +++ b/tool/script/template/inst.py @@ -7,7 +7,7 @@ import sys import subprocess import string from optparse import OptionParser, make_option -import ConfigParser +import configparser PKG_NAMES = ["REPLACE"] SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) @@ -15,7 +15,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 +23,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 @@ -121,7 +121,7 @@ def uninstPKGs(): doRemoteCMD("rm -rf /home/owner/share/res") for root, dirs, files in os.walk(SCRIPT_DIR): - print "uninstPKGs ################################" + print ("uninstPKGs ################################") for file in files: print ("file : %s" % (file)) if file.endswith(".wgt"): @@ -358,8 +358,8 @@ def main(): "-a", dest="user", action="store", help="User name") global PARAMETERS (PARAMETERS, args) = opts_parser.parse_args() - except Exception, e: - print "Got wrong option: %s, exit ..." % e + except Exception as e: + print ("Got wrong option: %s, exit ..." % e) sys.exit(1) if not PARAMETERS.user: @@ -378,7 +378,7 @@ def main(): PARAMETERS.mode = "SSH" if not PARAMETERS.device: - print "No device provided" + print ("No device provided") sys.exit(1) user_info = getUSERID() @@ -388,10 +388,10 @@ def main(): userid = user_info[1][0] XW_ENV = "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%s/dbus/user_bus_socket"%str(userid) else: - print "[Error] cmd commands error : %s"%str(user_info[1]) + print ("[Error] cmd commands error : %s"%str(user_info[1])) sys.exit(1) if PARAMETERS.binstpkg and PARAMETERS.buninstpkg: - print "-i and -u are conflict" + print ("-i and -u are conflict") sys.exit(1) if PARAMETERS.buninstpkg: