def get_exe_version(exe, args=[u'--version'], version_re=u'version\\s+([0-9._-a-zA-Z]+)', unrecognized=u'present'):
 try:
  (out, err) = subprocess.Popen(([exe] + args), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()
 except OSError:
  return False
 firstline = out.partition('\n')[0].decode(u'ascii', u'ignore')
 m = re.search(version_re, firstline)
 if m:
  return m.group(1)
 else:
  return unrecognized

def get_exe_version ( exe , args = [ u'--version' ] , version_re = u'version\\s+([0-9._-a-zA-Z]+)' , unrecognized = u'present' ) : try : ( out , err ) = subprocess . Popen ( ( [ exe ] + args ) , stdout = subprocess . PIPE , stderr = subprocess . STDOUT ) . communicate ( ) except OSError : return False firstline = out . partition ( '\n' ) [ 0 ] . decode ( u'ascii' , u'ignore' ) m = re . search ( version_re , firstline ) if m : return m . group ( 1 ) else : return unrecognized
returns the version of the specified executable .