www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | LICENSE

MyX11Utils.py (1034B)


      1 import FreeCAD
      2 import FreeCADGui as Gui
      3 import subprocess
      4 import PySide
      5 import re
      6 from PySide import QtGui
      7 from PySide import QtCore
      8 
      9 import ExternalAppsList
     10 
     11 def x11stillAlive(windowId):
     12     try:
     13         subprocess.check_output(['xprop', '-id', str(windowId), '_NET_WM_PID'])
     14         return True
     15     except:
     16         return False
     17 
     18 def x11prop(windowId, prop, type):
     19     try:
     20         process_output = subprocess.check_output(['xprop', '-id', str(windowId), prop])
     21         # use decode('utf-8', 'ignore') to use strings instead of
     22         # byte strings and discard ill-formed unicode in case this
     23         # tool doesn't sanitize their output
     24         output = process_output.decode('utf-8', 'ignore').split('\n')
     25     except subprocess.CalledProcessError as e:
     26         output = []
     27     xprop_re = re.compile(r'^' + re.escape(prop) + r'\(' + re.escape(type) + r'\)((:)| =(.*))$')
     28     for line in output:
     29         trymatch = xprop_re.match(line)
     30         if trymatch:
     31             return trymatch.group(2) or trymatch.group(3)
     32     return None