diff options
author | PMR <pmr@pmr-lander> | 2020-08-20 08:41:13 +0000 |
---|---|---|
committer | PMR <pmr@pmr-lander> | 2020-08-20 08:41:13 +0000 |
commit | 1c93355aa1fb8e03488bd6975b73fde6c0254ef2 (patch) | |
tree | 1b7aef7967fd390e51740e5da44b94a3501e849b /bin | |
parent | 5d3d61b56f3f62ac399d551899412bd34b37ff04 (diff) | |
parent | 5efd1c4d223080bd3020f2e97c25073d5fd3e8a0 (diff) |
Merge #386796 from ~williamhsu/plainbox-provider-checkbox/+git/plainbox-provide-checkbox:bug/lp-1884235/exchanged-the-sequence-of-graphics-log-parsing
Exchanged the sequence of graphics log parsing
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/graphics_driver.py | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/bin/graphics_driver.py b/bin/graphics_driver.py index f9bdff3..52ca157 100755 --- a/bin/graphics_driver.py +++ b/bin/graphics_driver.py @@ -37,6 +37,7 @@ import re import sys import os +import glob from subprocess import Popen, PIPE, check_output, CalledProcessError @@ -362,10 +363,30 @@ def hybrid_graphics_check(xlog): def main(): - if os.path.isfile("/var/log/Xorg.0.log"): - xlog = XorgLog("/var/log/Xorg.0.log") + usr_xorg_dir = os.path.expanduser("~/.local/share/xorg/") + root_xorg_dir = "/var/log/" + xlog = None + xorg_owner = [] + tgt_dir = "" + + # Output the Xorg owner + xorg_owner = check_output("ps -o user= -p $(pidof Xorg)", + shell=True, + universal_newlines=True).split() + + # Check the Xorg owner and then judge the Xorg log location + if "root" in xorg_owner: + tgt_dir = root_xorg_dir + elif xorg_owner: + tgt_dir = usr_xorg_dir else: - xlog = XorgLog(os.path.expanduser("~/.local/share/xorg/Xorg.0.log")) + print("ERROR: No Xorg process found!", file=sys.stderr) + + if tgt_dir: + xorg_file_paths = list(glob.iglob(tgt_dir + 'Xorg.*.log')) + target_file = xorg_file_paths[0] + xlog = XorgLog(target_file) + results = [] results.append(get_driver_info(xlog)) |