Advertisement
Guest User

DLP setting finder

a guest
Nov 24th, 2014
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.05 KB | None | 0 0
  1. import subprocess, re
  2.  
  3. def _getDLP():
  4.     p = subprocess.Popen(['nvidia-xconfig', '--query-gpu-info'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  5.     out, err = p.communicate()
  6.     if err:
  7.         return
  8.     out = out.split('\n')    
  9.     for l in out:
  10.         if 'Panasonic' in l:
  11.             i = out.index(l)
  12.             dfpLine = out[i-1]
  13.             findDfp = re.search('DFP-[\d]', dfpLine)
  14.             if findDfp:
  15.                 return findDfp.group()
  16.  
  17. # alt method:
  18. def getDLP():
  19.     xorgLog = '/var/log/Xorg.0.log'
  20.     if os.path.exists(xorgLog):
  21.         fd = open(xorgLog, 'r')
  22.         for line in fd:
  23.             # the idea here is that '(connected)' is not the primary display
  24.             # primary is '(boot, connected)',
  25.             # so this one is the presentation display
  26.             if '(connected)' in line:
  27.                 findDfp = re.search('DFP-[\d]', line)
  28.                 if findDfp:
  29.                     fd.close()
  30.                     return findDfp.group()
  31.         fd.close()
  32.     else:
  33.         return _getDLP()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement