root/trunk/libffado/support/mixer-qt4/ffado/mixer/generic_dice_eap.py

Revision 2680, 5.4 kB (checked in by jwoithe, 7 years ago)

python: replace all "print ..." statements with "print( ... )", which is
compatible with current versions of python2 and python3. The replacement
was done with a straight-forward shell command:

for i in $(find . -name \*.py) ; do

sed -i.bak 's/print \(.*\)/print( \1 )/' $i ;

done

This will fail if any of the print statements extend beyond a single line.
Inspection suggests there are none of these, but there is always a chance
that one or two have been missed. If so they can obviously be fixed up
later.

The move to the new "print" syntax was included in Xavier Forestier's
November 2016 patch set. The majority of the changes needed to make FFADO
run under python3 involved fixing the "print" syntax. Other issues
identified in that patch set will be dealt with in future patches.

  • Property svn:mergeinfo set to
Line 
1 #
2 # Copyright (C) 2009-2010 by Arnold Krille
3 #               2013 by Philippe Carriere
4 #
5 # This file is part of FFADO
6 # FFADO = Free Firewire (pro-)audio drivers for linux
7 #
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 2 of the License, or
11 # (at your option) version 3 of the License.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 #
21
22 from PyQt4 import QtGui, QtCore, Qt
23 from PyQt4.QtGui import QWidget, QGridLayout, QTabWidget, QScrollArea
24 import dbus
25
26 from ffado.widgets.matrixmixer import MatrixMixer
27 from ffado.widgets.crossbarrouter import *
28
29 from ffado.config import *
30
31 class Generic_Dice_EAP(QWidget):
32     def __init__(self, parent=None):
33         QWidget.__init__(self, parent)
34         self.layout = QGridLayout(self)
35         self.setLayout(self.layout)
36         self.tabs = QTabWidget(self)
37         self.tabs.setTabPosition(QTabWidget.West)
38         self.layout.addWidget(self.tabs)
39
40     def buildMixer(self):
41         #print( self.hw )
42         #print( self.hw.getText("/Generic/Nickname") )
43         self.mixer = MatrixMixer(self.hw.servername, self.hw.basepath+"/EAP/MatrixMixer", self, "Columns_are_outputs", -1, None, None, False, QTabWidget.North, QTabWidget.Rounded)
44         self.tabs.addTab(self.mixer, "Mixer")
45
46         self.router_scrollarea = self.buildRouter(self.hw.servername, self.hw.basepath+"/EAP/Router")
47         self.tabs.addTab(self.router_scrollarea, "Crossbar Router")
48
49     def buildRouter(self, servername, path):
50         self.router = CrossbarRouter(servername, path, self)
51         self.router.MixerRoutingChanged.connect(self.mixer.updateRouting)
52         scrollarea = QScrollArea(self.tabs)
53         scrollarea.setWidgetResizable(True)
54         scrollarea.setWidget(self.router)
55         return scrollarea
56
57     def onSamplerateChange(self):
58         # Router configuration is samplerate dependent for DICE EAP devices
59         # Destroy and redraw the crossbar router view when called
60         n = self.tabs.indexOf(self.router_scrollarea)
61         self.tabs.removeTab(n)
62         self.router.destroy()
63         self.router_scrollarea.destroy()
64
65         self.router_scrollarea = self.buildRouter(self.hw.servername, self.hw.basepath+"/EAP/Router")
66         self.tabs.insertTab(n, self.router_scrollarea, "Crossbar Router")
67         self.tabs.setCurrentWidget(self.router_scrollarea)
68
69         self.mixer.updateRouting()
70
71     def saveSettings(self, indent):
72         saveString = []
73         idt = indent + "  "
74         saveString.append('%s<mixer>\n' % indent)
75         saveString.extend(self.mixer.saveSettings(idt))
76         # Do not forget to mention the adopted rule for matrix columns mixer
77         #  This might be useful for future import function
78         saveString.append("%s  <col_rule>\n" % indent)
79         saveString.append("%s    Columns_are_outputs\n" % indent)
80         saveString.append("%s  </col_rule>\n" % indent)
81         saveString.append('%s</mixer>\n' % indent)
82         saveString.append('%s<router>\n' % indent)
83         saveString.extend(self.router.saveSettings(idt))
84         saveString.append('%s</router>\n' % indent)
85         return saveString
86
87     def readSettings(self, readString):
88         try:
89             idxb = readString.index('<mixer>')
90             idxe = readString.index('</mixer>')
91         except Exception:
92             log.debug("No mixer settings found")
93             idxb = -1
94             idxe = -1
95         if idxb >= 0:
96             if idxe > idxb + 1:
97                 stringMixer = []
98                 for s in readString[idxb+1:idxe]:
99                     stringMixer.append(s)
100                 # When trying to import from a different device, the rule for column interpretation is
101                 # not necessarily the same
102                 try:
103                     idx = stringMixer.index('<col_rule>')
104                 except Exception:
105                     log.debug('Do not know how to handle column versus input/output')
106                     idx = -1
107                 transpose_coeff = False
108                 if idx >=0:
109                     if stringMixer[idx+1].find("Columns_are_outputs") == -1:
110                         log.debug('Transposing the matrix coefficient; you are importing, are not you ?')
111                         transpose_coeff = True
112                 if self.mixer.readSettings(stringMixer, transpose_coeff):
113                     log.debug("Mixer settings modified")
114                 del stringMixer
115         try:
116             idxb = readString.index('<router>')
117             idxe = readString.index('</router>')
118         except Exception:
119             log.debug("No router settings found")
120             idxb = -1
121             idxe = -1
122         if idxb >= 0:
123             if idxe > idxb + 1:
124                 stringRouter = []
125                 for s in readString[idxb+1:idxe]:
126                     stringRouter.append(s)
127                 if self.router.readSettings(stringRouter):
128                     log.debug("Router settings modified")
129                 del stringRouter
130
131     #def getDisplayTitle(self):
132     #    return "Saffire PRO40/PRO24 Mixer"
133
134 #
135 # vim: et ts=4 sw=4
Note: See TracBrowser for help on using the browser.