]> glassweightruler.freedombox.rocks Git - waydroid.git/blobdiff - tools/helpers/props.py
clipboard: Return empty string if error
[waydroid.git] / tools / helpers / props.py
index bcc7c3465eb0e22dcf6d624b64c8f9ed64e7be4d..de3c3a8dcef4cb96b69e82c9b3f1b16c5029fc03 100644 (file)
@@ -1,6 +1,7 @@
 # Copyright 2021 Oliver Smith
 # SPDX-License-Identifier: GPL-3.0-or-later
 from shutil import which
+import subprocess
 import logging
 import os
 import tools.helpers.run
@@ -10,7 +11,7 @@ from tools.interfaces import IPlatform
 def host_get(args, prop):
     if which("getprop") is not None:
         command = ["getprop", prop]
-        return tools.helpers.run.user(args, command, output_return=True).strip()
+        return subprocess.run(command, stdout=subprocess.PIPE).stdout.decode('utf-8').strip()
     else:
         return ""
 
@@ -48,3 +49,14 @@ def set(args, prop, value):
                 session_cfg["session"]["state"]))
     else:
         logging.error("WayDroid session is stopped")
+
+def file_get(args, file, prop):
+    with open(file) as build_prop:
+        for line in build_prop:
+            line = line.strip()
+            if len(line) == 0 or line[0] == "#":
+                continue
+            k,v = line.partition("=")[::2]
+            if k == prop:
+                return v;
+    return ""