Changeset 2683

Show
Ignore:
Timestamp:
03/27/17 03:39:34 (1 month ago)
Author:
jwoithe
Message:

support/tools/: make allowances for the movement of getstatusoutput() from the 'commands' module in Python2 to the 'subprocess' module in Python3. This patch differs from an initial implementation by Xavier Forestier's in November 2016 in that the committed code should work in both python variants.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/support/tools/ffado_diag_helpers.py

    r2680 r2683  
    2222 
    2323import os 
    24 import commands 
    2524import re 
    2625import logging 
     26 
     27# Allow for the movement of getstatusoutput from the "commands" module (in 
     28# python2) to the "subprocess" module in python3. 
     29try: 
     30    from subprocess import getstatusoutput 
     31except ImportError: 
     32    from commands import getstatusoutput 
    2733 
    2834## logging setup 
     
    6470    log.info("Checking if module '%s' is present... " % modulename) 
    6571    kver = get_kernel_version() 
    66     (exitstatus, outtext) = commands.getstatusoutput("find \"/lib/modules/%s/\" -name '%s.ko' | grep '%s'" % \ 
    67                                                      (kver, modulename, modulename) ) 
     72    (exitstatus, outtext) = getstatusoutput("find \"/lib/modules/%s/\" -name '%s.ko' | grep '%s'" % \ 
     73                                            (kver, modulename, modulename) ) 
    6874    log.debug("find outputs: %s" % outtext) 
    6975    if outtext == "": 
     
    127133 
    128134def run_command(cmd): 
    129     (exitstatus, outtext) = commands.getstatusoutput(cmd) 
     135    (exitstatus, outtext) = getstatusoutput(cmd) 
    130136    log.debug("%s outputs: %s" % (cmd, outtext)) 
    131137    return outtext 
  • trunk/libffado/support/tools/listirqinfo.py

    r2682 r2683  
    1919 
    2020import os 
    21 import commands 
    2221import re 
     22 
     23# Allow for the movement of getstatusoutput from the "commands" module (in 
     24# python2) to the "subprocess" module in python3. 
     25try: 
     26    from subprocess import getstatusoutput 
     27except ImportError: 
     28    from commands import getstatusoutput 
    2329 
    2430LISTIRQINFO_VERSION="0.3" 
     
    6369    def load(self): 
    6470        # get PID info 
    65         (exitstatus, outtext) = commands.getstatusoutput('ps -eLo pid,cmd,class,rtprio | grep IRQ') 
     71        (exitstatus, outtext) = getstatusoutput('ps -eLo pid,cmd,class,rtprio | grep IRQ') 
    6672         
    6773        rawstr = r"""([0-9]+) +\[IRQ-([0-9]+)\] +([A-Z]{2}) +([-0-9]+)""" 
     
    8288                IRQs[irq.number] = irq 
    8389         
    84         (exitstatus, outtext) = commands.getstatusoutput('ps -eLo pid,cmd,class,rtprio | grep softirq') 
     90        (exitstatus, outtext) = getstatusoutput('ps -eLo pid,cmd,class,rtprio | grep softirq') 
    8591         
    8692        rawstr = r"""([0-9]+) +\[softirq-(.*)\] +([A-Z]+) +([-0-9]+)""" 
     
    103109         
    104110        # get irq info 
    105         (exitstatus, outtext) = commands.getstatusoutput('cat /proc/interrupts') 
     111        (exitstatus, outtext) = getstatusoutput('cat /proc/interrupts') 
    106112        lines = outtext.splitlines() 
    107113        nb_cpus = len(lines[0].split())