Advertisement
Guest User

DLP setting finder

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