From 526f53596d671ef81ba1a645145011bf1532c816 Mon Sep 17 00:00:00 2001 From: WoochanLee Date: Fri, 14 Oct 2022 15:02:29 +0900 Subject: [PATCH] aurum: Add sample script with util commands utils.py supports below commands. runCommand checkSdb getDeviceInfo isAurumReady displayStop getStub Change-Id: I673b7331b19222087f9be7563b718bff292546b6 --- ui_automation/python/tv/sampleWithUtils.py | 19 +++++++ ui_automation/python/tv/utils.py | 63 ++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 ui_automation/python/tv/sampleWithUtils.py create mode 100644 ui_automation/python/tv/utils.py diff --git a/ui_automation/python/tv/sampleWithUtils.py b/ui_automation/python/tv/sampleWithUtils.py new file mode 100644 index 0000000..9e30a0c --- /dev/null +++ b/ui_automation/python/tv/sampleWithUtils.py @@ -0,0 +1,19 @@ +from utils import * + +def run(): + #Do below command if you needed. + """ + checkSdb() + getDeviceInfo() + displayStop() + isAurumReady() + """ + + stub = getStub() + stub.enableScreenAnalyzer(ReqEnableScreenAnalyzer(enable=True)) + response = stub.findElements(ReqFindElements()) + print(response) + + +if __name__ == '__main__': + run() diff --git a/ui_automation/python/tv/utils.py b/ui_automation/python/tv/utils.py new file mode 100644 index 0000000..901cf2a --- /dev/null +++ b/ui_automation/python/tv/utils.py @@ -0,0 +1,63 @@ +from __future__ import print_function +import os +import subprocess +import re +import sys +import time +from aurum_pb2 import * +from aurum_pb2_grpc import BootstrapStub +import grpc + +def runCommand(command): + stream = os.popen(command) + output = stream.read() + print(output) + +def checkSdb(): + stream = os.popen("command -v sdb") + output = stream.read() + if len(output) > 0: + return True + else: + print("Error - Can't run sdb") + +def getDeviceInfo(): + stream = os.popen("sdb shell cat /etc/info.ini") + output = stream.read() + print(output) + +def isAurumReady(): + stream = os.popen("sdb shell 'ps -e | grep aurum-bootstrap'") + output = stream.read() + if len(output) > 0: + return True + else: + print("Error - aurum-bootstrap not launched on target") + print("Try to launch aurum-bootstrap") + stream = os.popen("sdb shell app_launcher -s org.tizen.aurum-bootstrap") + output = stream.read() + time.sleep(1) + if len(output) > 0: + print("Success to launch aurum-bootstrap") + return True + + print("Error - Can't launch aurum-bootstrap") + return False + +# display always on +def displayStop(): + runCommand("sdb shell devicectl display stop") + runCommand("stty sane") + + +# NOTE: It may not work depending on how user sets the proxy. +def getStub(): + stream = os.popen("env | grep proxy") + output = stream.read() + if len(output) > 0: + stub = BootstrapStub(grpc.insecure_channel('l27.0.0.1:50051', options=(('grpc.enable_http_proxy', 0),))) + return stub + else: + stub = BootstrapStub(grpc.insecure_channel('127.0.0.1:50051')) + return stub + -- 2.34.1