Changeset 2727

Show
Ignore:
Timestamp:
01/11/18 17:12:33 (6 months ago)
Author:
jwoithe
Message:

Additional Python 3 fixes

Apply additional Python 3 fixes from Hector Martin via the FFADO-devel
mailing list. The exec() based approach in panelmanager.py no longer works
(it is replaced with importlib). Fix what looks like a typo in
crossbarrouter.py which just happened to work in Python 2.7 (Hector
understands the intent is to avoid negative values, not "negative" keys
which are actually strings). Clarify float/truncating division.

Tested on Python 2.7, 3.4, 3.5 with Qt5, and Python 2.7 with Qt4.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/support/mixer-qt4/ffado/panelmanager.py

    r2726 r2727  
    3939import sys 
    4040import time 
     41import importlib 
    4142 
    4243import logging 
     
    303304        # Specific (or dummy) mixer widgets get loaded in the following 
    304305        # 
     306        found = False 
    305307        if 'mixer' in dev and dev['mixer'] != None: 
    306308            mixerapp = dev['mixer'] 
    307             global mixerwidget 
    308             exec( """ 
    309 try: 
    310     import ffado.mixer.%s 
    311     globals()["mixerwidget"] = ffado.mixer.%s.%s( w ) 
    312     found = True 
    313 except ImportError: 
    314     log.debug("bypassdbus set, %s module not available: ignored") 
    315     found = False 
    316 """ % (mixerapp.lower(), mixerapp.lower(), mixerapp, mixerapp.lower()) ) 
    317         else: 
    318             found = False 
     309            try: 
     310                mixer_module = importlib.import_module("ffado.mixer.%s" % mixerapp.lower()) 
     311                mixerwidget = getattr(mixer_module, mixerapp)(w) 
     312                found = True 
     313            except ImportError: 
     314                log.debug("bypassdbus set, %s module not available: ignored" % mixerapp.lower()) 
    319315 
    320316        if not found: 
  • trunk/libffado/support/mixer-qt4/ffado/widgets/crossbarrouter.py

    r2726 r2727  
    195195        for peak in peakvalues: 
    196196            #log.debug("peak = [%s,%s]" % (str(peak[0]),str(peak[1]))) 
    197             if peak[0] >= 0: 
     197            if peak[1] >= 0: 
    198198                self.switchers[peak[0]].peakValue(peak[1]) 
    199199 
  • trunk/libffado/support/mixer-qt4/ffado/widgets/matrixmixer.py

    r2726 r2727  
    513513 
    514514    def updateValues(self, n): 
    515         nbitems = len(n)/
     515        nbitems = len(n) //
    516516        for i in range(nbitems): 
    517517            n_0 = n[3*i]     
     
    952952 
    953953    def updateValues(self, n): 
    954         nbitems = len(n)/
     954        nbitems = len(n) //
    955955        for j in range(nbitems): 
    956956            n_0 = n[3*j]     
     
    14071407        # Update value needed for "per Out" view 
    14081408        #log.debug("Update per Output( %s )" % str(n)) 
    1409         nbitems = len(n)/
     1409        nbitems = len(n) //
    14101410        if (self.rule == "Columns_are_inputs"): 
    14111411           n_t = n 
     
    14211421        # Update value needed for matrix view 
    14221422        #log.debug("Update Matrix( %s )" % str(n)) 
    1423         nbitems = len(n)/
     1423        nbitems = len(n) //
    14241424        if (((self.rule == "Columns_are_inputs") and not self.transpose) or ((self.rule != "Columns_are_inputs") and self.transpose)): 
    14251425            n_t = () 
     
    15131513                return False 
    15141514            n = int(readMixerString[idx+2]) 
    1515             if n > self.perOut.nbOut/2: 
     1515            if n > self.perOut.nbOut // 2: 
    15161516                log.debug("Incoherent number of stereo channels") 
    15171517                return False