[PATCH] apps/osmocom_fft: fix compatibility with Python 3: print needs parentheses

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/osmocom-sdr@lists.osmocom.org/.

Vadim Yanitskiy axilirator at gmail.com
Tue Nov 12 12:46:35 UTC 2019


---
 apps/osmocom_fft | 42 +++++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/apps/osmocom_fft b/apps/osmocom_fft
index da38861..0110d19 100755
--- a/apps/osmocom_fft
+++ b/apps/osmocom_fft
@@ -117,7 +117,7 @@ class app_top_block(stdgui2.std_top_block, pubsub):
         try:
             self.src.get_sample_rates().start()
         except RuntimeError:
-            print "Source has no sample rates (wrong device arguments?)."
+            print("Source has no sample rates (wrong device arguments?).")
             sys.exit(1)
 
         # Set the antenna
@@ -150,18 +150,18 @@ class app_top_block(stdgui2.std_top_block, pubsub):
             gain_names = self.src.get_gain_names()
             for name in gain_names:
                 range = self.src.get_gain_range(name)
-                print "%s gain range: start %d stop %d step %d" % (name, range.start(), range.stop(), range.step())
+                print("%s gain range: start %d stop %d step %d" % (name, range.start(), range.stop(), range.step()))
 
         if options.gains:
             for tuple in options.gains.split(","):
                 name, gain = tuple.split(":")
                 gain = int(gain)
-                print "Setting gain %s to %d." % (name, gain)
+                print("Setting gain %s to %d." % (name, gain))
                 self.src.set_gain(gain, name)
 
         if self._verbose:
             rates = self.src.get_sample_rates()
-            print 'Supported sample rates %d-%d step %d.' % (rates.start(), rates.stop(), rates.step())
+            print('Supported sample rates %d-%d step %d.' % (rates.start(), rates.stop(), rates.step()))
 
         if options.center_freq is None:
             freq = self.src.get_center_freq()
@@ -221,7 +221,7 @@ class app_top_block(stdgui2.std_top_block, pubsub):
 
         #force update on pubsub keys
         #for key in (SAMP_RATE_KEY, BWIDTH_KEY, CENTER_FREQ_KEY, FREQ_CORR_KEY):
-            #print key, "=", self[key]
+            #print(key, "=", self[key])
             #self[key] = self[key]
 
         if options.fosphor:
@@ -422,7 +422,7 @@ class app_top_block(stdgui2.std_top_block, pubsub):
         try:
 
             bw_range = self[BWIDTH_RANGE_KEY]
-            #print bw_range.to_pp_string()
+            #print(bw_range.to_pp_string())
             if bw_range.start() < bw_range.stop():
                 bwidth_vbox = forms.static_box_sizer(parent=self.panel,
                                                      label="Bandwidth",
@@ -537,14 +537,14 @@ class app_top_block(stdgui2.std_top_block, pubsub):
 
                 self.rec_file_name = self.record_to_filename()
 
-                print "Recording samples to ", self.rec_file_name
+                print("Recording samples to ", self.rec_file_name)
                 self.file_sink.open(self.rec_file_name);
             else:
                 self.sample_rate_text.Enable()
                 self.record_text.Enable()
 
                 self.file_sink.close()
-                print "Finished recording to", self.rec_file_name
+                print("Finished recording to", self.rec_file_name)
 
         forms.toggle_button(
             sizer=rec_hbox,
@@ -732,9 +732,9 @@ class app_top_block(stdgui2.std_top_block, pubsub):
             self.src.set_dc_offset( correction )
 
             if self._verbose:
-                print "Set DC offset to", correction
+                print("Set DC offset to", correction)
         except RuntimeError as ex:
-            print ex
+            print(ex)
 
     def set_iq_balance_mode(self, iq_balance_mode):
         if iq_balance_mode == 1:
@@ -761,16 +761,16 @@ class app_top_block(stdgui2.std_top_block, pubsub):
             self.src.set_iq_balance( correction )
 
             if self._verbose:
-                print "Set IQ balance to", correction
+                print("Set IQ balance to", correction)
         except RuntimeError as ex:
-            print ex
+            print(ex)
 
     def set_sample_rate(self, samp_rate):
         samp_rate = self.src.set_sample_rate(samp_rate)
         if hasattr(self.scope, 'set_sample_rate'):
             self.scope.set_sample_rate(samp_rate)
         if self._verbose:
-            print "Set sample rate to:", samp_rate
+            print("Set sample rate to:", samp_rate)
 
         try:
             self[BWIDTH_KEY] = self.set_bandwidth(samp_rate)
@@ -787,13 +787,13 @@ class app_top_block(stdgui2.std_top_block, pubsub):
             g = self[GAIN_RANGE_KEY(name)]
             gain = float(g.start()+g.stop())/2
             if self._verbose:
-                print "Using auto-calculated mid-point gain"
+                print("Using auto-calculated mid-point gain")
             self[GAIN_KEY(name)] = gain
             return
 
         gain = self.src.set_gain(gain, name)
         if self._verbose:
-            print "Set " + name + " gain to:", gain
+            print("Set " + name + " gain to:", gain)
 
     def set_bandwidth(self, bw):
         clipped_bw = self[BWIDTH_RANGE_KEY].clip(bw)
@@ -801,7 +801,7 @@ class app_top_block(stdgui2.std_top_block, pubsub):
             bw = self.src.set_bandwidth(clipped_bw)
 
             if self._verbose:
-                print "Set bandwidth to:", bw
+                print("Set bandwidth to:", bw)
 
         return bw
 
@@ -814,7 +814,7 @@ class app_top_block(stdgui2.std_top_block, pubsub):
             f = self[FREQ_RANGE_KEY]
             freq = float(f.start()+f.stop())/2.0
             if self._verbose:
-                print "Using auto-calculated mid-point frequency"
+                print("Using auto-calculated mid-point frequency")
             self[CENTER_FREQ_KEY] = freq
             return
 
@@ -825,22 +825,22 @@ class app_top_block(stdgui2.std_top_block, pubsub):
 
         if freq is not None:
             if self._verbose:
-                print "Set center frequency to", freq
+                print("Set center frequency to", freq)
         elif self._verbose:
-            print "Failed to set freq."
+            print("Failed to set freq.")
         return freq
 
     def set_freq_corr(self, ppm):
         if ppm is None:
             ppm = 0.0
             if self._verbose:
-                print "Using frequency corrrection of", ppm
+                print("Using frequency corrrection of", ppm)
             self[FREQ_CORR_KEY] = ppm
             return
 
         ppm = self.src.set_freq_corr(ppm)
         if self._verbose:
-            print "Set frequency correction to:", ppm
+            print("Set frequency correction to:", ppm)
 
 def main ():
     app = stdgui2.stdapp(app_top_block, "osmocom Spectrum Browser", nstatus=1)
-- 
2.24.0




More information about the osmocom-sdr mailing list