aurum: Add sample script with util commands 36/283836/2
authorWoochanLee <wc0917.lee@samsung.com>
Fri, 14 Oct 2022 06:02:29 +0000 (15:02 +0900)
committerChun <jykeon@samsung.com>
Fri, 4 Nov 2022 07:49:54 +0000 (07:49 +0000)
utils.py supports below commands.
runCommand
checkSdb
getDeviceInfo
isAurumReady
displayStop
getStub

Change-Id: I673b7331b19222087f9be7563b718bff292546b6
(cherry picked from commit 526f53596d671ef81ba1a645145011bf1532c816)

ui_automation/python/tv/sampleWithUtils.py [new file with mode: 0644]
ui_automation/python/tv/utils.py [new file with mode: 0644]

diff --git a/ui_automation/python/tv/sampleWithUtils.py b/ui_automation/python/tv/sampleWithUtils.py
new file mode 100644 (file)
index 0000000..9e30a0c
--- /dev/null
@@ -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 (file)
index 0000000..901cf2a
--- /dev/null
@@ -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
+