Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess, re
- def _getDLP():
- p = subprocess.Popen(['nvidia-xconfig', '--query-gpu-info'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- out, err = p.communicate()
- if err:
- return
- out = out.split('\n')
- for l in out:
- if 'Panasonic' in l:
- i = out.index(l)
- dfpLine = out[i-1]
- findDfp = re.search('DFP-[\d]', dfpLine)
- if findDfp:
- return findDfp.group()
- # alt method:
- def getDLP():
- xorgLog = '/var/log/Xorg.0.log'
- if os.path.exists(xorgLog):
- fd = open(xorgLog, 'r')
- for line in fd:
- # the idea here is that '(connected)' is not the primary display
- # primary is '(boot, connected)',
- # so this one is the presentation display
- if '(connected)' in line:
- findDfp = re.search('DFP-[\d]', line)
- if findDfp:
- fd.close()
- return findDfp.group()
- fd.close()
- else:
- return _getDLP()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement