diff --git a/radio/util/add-issue-links.py b/radio/util/add-issue-links.py
index e66ad56a7..d2682bce3 100755
--- a/radio/util/add-issue-links.py
+++ b/radio/util/add-issue-links.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
+from __future__ import print_function
import sys
import os
@@ -43,7 +44,7 @@ while True:
links = "(" + ", ".join(issue_links) + ")"
line = "
" + line + " " + links + ""
- print line
+ print(line)
inp.close()
diff --git a/radio/util/addtr.py b/radio/util/addtr.py
index 3a3b30e52..4794b8905 100755
--- a/radio/util/addtr.py
+++ b/radio/util/addtr.py
@@ -1,9 +1,11 @@
#!/bin/env python
+from __future__ import print_function
+
import sys, glob
def addLine(filename, newline, after):
- print filename, newline
+ print(filename, newline)
lines = file(filename, 'r').readlines()
for i, line in enumerate(lines):
if after in line:
@@ -14,7 +16,7 @@ def addLine(filename, newline, after):
def modifyTranslations(constant, translation, after):
for filename in glob.glob('translations/*.h.txt'):
newline = "#define " + constant + " "*max(1, 23-len(constant)) + '"' + translation + '"'
- addLine(filename, newline, after+" ")
+ addLine(filename, newline, after+" ")
def modifyDeclaration(constant, after):
newline = "extern const pm_char S" + constant + "[];"
diff --git a/radio/util/codecs.py b/radio/util/codecs.py
index 4c75a6ed6..55698b81a 100755
--- a/radio/util/codecs.py
+++ b/radio/util/codecs.py
@@ -1,5 +1,7 @@
#!/bin/env python
+from __future__ import print_function
+
SIGN_BIT = (0x80) # Sign bit for a A-law byte.
QUANT_MASK = (0xf) # Quantization field mask.
SEG_SHIFT = (4) # Left shift for segment number.
@@ -47,5 +49,5 @@ def tableToString(name, table):
result += ' };'
return result
-print tableToString('alawTable', pcmTable(alaw2linear))
-print tableToString('ulawTable', pcmTable(ulaw2linear))
+print(tableToString('alawTable', pcmTable(alaw2linear)))
+print(tableToString('ulawTable', pcmTable(ulaw2linear)))
diff --git a/radio/util/copyright.py b/radio/util/copyright.py
index 9a12c285d..3e075d08f 100755
--- a/radio/util/copyright.py
+++ b/radio/util/copyright.py
@@ -1,5 +1,7 @@
#!/usr/bin/env python
+from __future__ import print_function
+
import os
import re
import sys
@@ -38,9 +40,9 @@ def writeheader(filename,header):
f = open(filename,'w')
f.writelines(output)
f.close()
- print "added header to %s" %filename
- except IOError,err:
- print "something went wrong trying to add header to %s: %s" % (filename,err)
+ print("added header to %s" %filename)
+ except IOError as err:
+ print("something went wrong trying to add header to %s: %s" % (filename,err))
def main(args=sys.argv):
headerfile = open(args[1])
diff --git a/radio/util/dsm2.py b/radio/util/dsm2.py
index 1d1d77006..7c5e4097a 100755
--- a/radio/util/dsm2.py
+++ b/radio/util/dsm2.py
@@ -1,7 +1,9 @@
+from __future__ import print_function
+
BITLEN_DSM2 = 16
def sendByteDsm2(b):
- print "%02x:" % b,
+ print("%02x:" % b, end=' ')
lev = 0
len = BITLEN_DSM2
for i in range(9):
@@ -9,13 +11,13 @@ def sendByteDsm2(b):
if (lev == nlev):
len += BITLEN_DSM2
else:
- print len,
+ print(len, end=' ')
# _send_1(nlev ? len-5 : len+3);
len = BITLEN_DSM2
lev = nlev
b = (b>>1) | 0x80
# _send_1(len+BITLEN_DSM2+3); // 2 stop bits
- print len+BITLEN_DSM2
+ print(len+BITLEN_DSM2)
sendByteDsm2(24)
sendByteDsm2(17)
diff --git a/radio/util/fat12.py b/radio/util/fat12.py
index 13889f3c7..fdc81d235 100755
--- a/radio/util/fat12.py
+++ b/radio/util/fat12.py
@@ -1,5 +1,7 @@
#!/bin/env python
+from __future__ import division, print_function
+
curr = 0
idx = 0
byte = 0
@@ -10,12 +12,12 @@ def push4bits(val):
curr += val << idx
idx += 4
if idx == 8:
- print "0x%02X," % curr,
+ print("0x%02X," % curr, end=' ')
idx = 0
curr = 0
byte += 1
if byte % 16 == 0:
- print
+ print()
cluster = 0
@@ -27,8 +29,8 @@ def pushCluster(val):
cluster += 1
def pushFile(size):
- sectors = size / 512
- count = sectors / 8
+ sectors = size // 512
+ count = sectors // 8
for i in range(count-1):
pushCluster(cluster+1)
pushCluster(0xFFF)
@@ -36,14 +38,14 @@ def pushFile(size):
def pushDisk(eeprom, flash):
global curr, idx, byte, cluster
curr = idx = byte = cluster = 0
- print "Disk with %dk EEPROM and %dk FLASH:" % (eeprom, flash)
+ print("Disk with %dk EEPROM and %dk FLASH:" % (eeprom, flash))
pushCluster(0xFF8)
pushCluster(0xFFF)
pushFile(eeprom*1024)
pushFile(flash*1024)
while byte < 512:
push4bits(0)
- print
+ print()
pushDisk(32, 512)
pushDisk(64, 512)
diff --git a/radio/util/img2lbm.py b/radio/util/img2lbm.py
index e02ac7a25..58e12e32c 100755
--- a/radio/util/img2lbm.py
+++ b/radio/util/img2lbm.py
@@ -1,5 +1,7 @@
#!/usr/bin/env python
+from __future__ import division, print_function
+
import sys
from PyQt4 import Qt, QtGui
@@ -19,7 +21,7 @@ else:
def writeSize(f, width, height):
if lcdwidth > 255:
- f.write("%d,%d,%d,%d,\n" % (width%256, width/256, height%256, height/256))
+ f.write("%d,%d,%d,%d,\n" % (width%256, width//256, height%256, height//256))
else:
f.write("%d,%d,\n" % (width, height))
@@ -27,7 +29,7 @@ if what == "1bit":
rows = 1
if len(sys.argv) > 5:
rows = int(sys.argv[5])
- writeSize(f, width, height/rows)
+ writeSize(f, width, height//rows)
for y in range(0, height, 8):
for x in range(width):
value = 0
@@ -42,7 +44,7 @@ elif what == "4/4/4/4":
for y in range(height):
for x in range(width):
pixel = image.pixel(x, y)
- f.write("0x%1x%1x%1x%1x," % (Qt.qAlpha(pixel)/16, Qt.qRed(pixel)/16, Qt.qGreen(pixel)/16, Qt.qBlue(pixel)/16))
+ f.write("0x%1x%1x%1x%1x," % (Qt.qAlpha(pixel)//16, Qt.qRed(pixel)//16, Qt.qGreen(pixel)//16, Qt.qBlue(pixel)//16))
f.write("\n")
elif what == "5/6/5/8":
colors = []
@@ -148,4 +150,3 @@ elif what == "22x38":
f.write("\n")
else:
print("wrong argument", sys.argv[4])
-
diff --git a/radio/util/include-guard.py b/radio/util/include-guard.py
index 53d3bdb9e..77e80bed0 100755
--- a/radio/util/include-guard.py
+++ b/radio/util/include-guard.py
@@ -1,5 +1,7 @@
#!/usr/bin/env python
+from __future__ import print_function
+
import sys, os
for filename in sys.argv[1:]:
@@ -14,7 +16,7 @@ for filename in sys.argv[1:]:
if line.startswith("#ifndef "):
guard = line[8:]
if lines[i+1].strip() == "#define %s" % guard:
- print filename, ":", guard, "=>", newguard
+ print(filename, ":", guard, "=>", newguard)
lines[i] = "#ifndef %s\n" % newguard
lines[i+1] = "#define %s\n" % newguard
end = -1
diff --git a/radio/util/luaexport.py b/radio/util/luaexport.py
index 5b785e8bb..e000454ec 100755
--- a/radio/util/luaexport.py
+++ b/radio/util/luaexport.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
+from __future__ import print_function
import sys
import os
@@ -24,11 +25,11 @@ error = None
def checkName(name):
global warning
if name in dups_name:
- print "WARNING: Duplicate name %s found for constant %s" % (name, CONSTANT_VALUE)
+ print("WARNING: Duplicate name %s found for constant %s" % (name, CONSTANT_VALUE))
warning = True
dups_name.append(name)
if name != name.lower():
- print "WARNING: Name not in lower case %s found for constant %s" % (name, CONSTANT_VALUE)
+ print("WARNING: Name not in lower case %s found for constant %s" % (name, CONSTANT_VALUE))
warning = True
@@ -46,9 +47,9 @@ def LEXP_MULTIPLE(nameFormat, descriptionFormat, valuesCount):
exports_multiple.append( (CONSTANT_VALUE, nameFormat, descriptionFormat, valuesCount) )
if len(sys.argv) < 3:
- print "Error: not enough arguments!"
- print "Usage:"
- print " luaexport.py