Changeset 2748
- Timestamp:
- 01/31/18 02:45:59 (6 years ago)
- Files:
-
- trunk/libffado/support/tools/ffado-diag.in (modified) (4 diffs)
- trunk/libffado/support/tools/ffado_diag_helpers.py (modified) (4 diffs)
- trunk/libffado/support/tools/listirqinfo.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/support/tools/ffado-diag.in
r2746 r2748 23 23 # 24 24 25 from __future__ import print_function 25 26 import sys 26 27 … … 108 109 with open( "$PYTHONDIR/static_info.txt", "r" ) as f: 109 110 for line in f: 110 line = line[:-1] 111 if line is not "\n" and line.startswith(" "): 112 print (line) 111 if line.startswith(" "): 112 print (line, end='') 113 113 except: 114 114 print ("Failed to read $PYTHONDIR/static_info.txt.") … … 117 117 118 118 print (" uname -a...") 119 print (" " + run_command (('uname', '-a')))119 print (" " + run_command_string (('uname', '-a'))) 120 120 121 121 print (" Hardware...") … … 124 124 list_host_controllers() 125 125 print (" CPU info:") 126 if get_command_path('lscpu'): 127 print (run_command(('lscpu',))) 128 else: 126 try: 127 lscpu_path = run_command (('which', 'lscpu')).rstrip () 128 print (run_command_string ((lscpu_path,))) 129 except subprocess.CalledProcessError: 129 130 with open ('/proc/cpuinfo') as f: 130 131 for l in f: 131 print (l .rstrip ())132 print (l, end='') 132 133 133 134 print (" Configuration...") trunk/libffado/support/tools/ffado_diag_helpers.py
r2746 r2748 19 19 # 20 20 21 from __future__ import print_function 21 22 import glob 22 23 import sys 23 24 import os 25 import errno 24 26 import logging 25 27 import subprocess … … 112 114 return False 113 115 114 def run_command(cmd): 115 try: 116 outtext = subprocess.check_output (cmd).decode () 117 except: 118 return "" 116 # Raise an exception for any problem. 117 def run_command (cmd): 118 outtext = subprocess.check_output (cmd) 119 outtext = outtext.decode ('utf8') 119 120 log.debug("%s outputs: %s" % (str (cmd), outtext)) 120 121 return outtext 121 122 123 # Wrapper intercepting common exceptions and returning a string nevertheless. 124 def run_command_string (cmd): 125 try: 126 return run_command (cmd) 127 except OSError, ( errorcode, emsg ): 128 if (errorcode == errno.ENOENT): 129 msg = "Not found" 130 else: 131 msg = "Failed to execute %s" % str (cmd) 132 log.warning (msg) 133 return msg 134 # Other errors are raised. 135 except subprocess.CalledProcessError: 136 msg = "Command %s returned a non-zero exit status" % str (cmd) 137 log.warning (msg) 138 return msg 139 122 140 # package versions 123 141 def get_package_version(name): 124 cmd = ('pkg-config', '--modversion', name) 125 return run_command(cmd) 142 return run_command_string (('pkg-config', '--modversion', name)) 126 143 127 144 def get_package_flags(name): 128 cmd = ('pkg-config', '--cflags', '--libs', name) 129 return run_command(cmd) 130 131 def get_command_path(name): 132 cmd = ('which', name) 133 return run_command(cmd) 145 return run_command_string (('pkg-config', '--cflags', '--libs', name)) 134 146 135 147 def get_version_first_line(cmd): 136 ver = run_command(cmd).split("\n")137 i f len(ver) == 0:138 ver = ["None"]139 if "sh: " in ver[0]:140 ver = ["Not found"]141 return ver[0]148 outtext = run_command_string (cmd) 149 i = outtext.find ("\n") 150 if i == -1: 151 return outtext 152 else: 153 return outtext [:i] 142 154 143 155 def list_host_controllers(): 144 lspci_cmd = get_command_path("lspci") 145 if lspci_cmd == "": 156 try: 157 lspci_cmd = run_command (('which', 'lspci')).rstrip () 158 except subprocess.CalledProcessError: 146 159 lspci_cmd = "/sbin/lspci" 147 160 outtext = run_command ((lspci_cmd,)) … … 154 167 155 168 def get_juju_permissions(): 156 return run_command (('ls', '-lh') + tuple(glob.glob ('/dev/fw*')))169 return run_command_string (['ls', '-lh'] + glob.glob ('/dev/fw*')) 157 170 158 171 def get_user_ids(): 159 return run_command (('id',));172 return run_command_string (('id',)); 160 173 161 174 def usage (): … … 183 196 print(" PyQt5 (by pyuic5) . %s" % get_version_first_line(('pyuic5', '--version'))) 184 197 print(" jackd ............. %s" % get_version_first_line(('jackd', '--version'))) 185 print(" path ............ %s" % get_command_path('jackd'))198 print(" path ............ %s" % run_command_string (('which', 'jackd')), end='') 186 199 print(" flags ........... %s" % get_package_flags("jack")) 187 200 print(" libraw1394 ........ %s" % get_package_version("libraw1394")) trunk/libffado/support/tools/listirqinfo.py
r2743 r2748 55 55 def load(self): 56 56 # get PID info 57 outtext = subprocess.check_output (('ps', '-eLo', 'pid,cmd,class,rtprio')).decode ( )57 outtext = subprocess.check_output (('ps', '-eLo', 'pid,cmd,class,rtprio')).decode ('utf8') 58 58 rawstr = r"""([0-9]+) +\[IRQ-([0-9]+)\] +([A-Z]{2}) +([-0-9]+)""" 59 59 compile_obj = re.compile(rawstr) … … 72 72 IRQs[irq.number] = irq 73 73 74 outtext = subprocess.check_output (('ps', '-eLo', 'pid,cmd,class,rtprio')).decode ( )74 outtext = subprocess.check_output (('ps', '-eLo', 'pid,cmd,class,rtprio')).decode ('utf8') 75 75 rawstr = r"""([0-9]+) +\[softirq-(.*)\] +([A-Z]+) +([-0-9]+)""" 76 76 compile_obj = re.compile(rawstr)