Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions nesc/whip6/apps/test_wnesc_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ def get_status_str(value):
f.write('{},{},{},{}\n'.format(app, data['time'], data['size'], data['overflow']))

print('----------------------------------------------------------')
print(colored('good apps:', 'green'), ','.join(apps_good))
print(colored('bad apps:', 'red'), ','.join(apps_bad))
print('result: {}/{}'.format(len(apps_good), len(apps_good) + len(apps_bad)))
print((colored('good apps:', 'green'), ','.join(apps_good)))
print((colored('bad apps:', 'red'), ','.join(apps_bad)))
print(('result: {}/{}'.format(len(apps_good), len(apps_good) + len(apps_bad))))
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# whip6: Warsaw High-performance IPv6.
#
Expand All @@ -24,7 +24,7 @@
'list of symbol (output of nm -t posix) with files of the sizes '
'corresponding to the symbols. They can then be visualized with tools '
'like Baobab.')
parser.add_argument('--kinds', '-k', choices=KINDS.keys(), default='flash',
parser.add_argument('--kinds', '-k', choices=list(KINDS.keys()), default='flash',
help='kinds of symbols to choose')
parser.add_argument('output_dir',
help='output directory')
Expand All @@ -47,8 +47,8 @@
filename = os.path.join(args.output_dir, *parts)
try:
os.makedirs(os.path.dirname(filename))
except OSError, e:
except OSError as e:
if e.errno != errno.EEXIST:
raise
with open(filename, 'wb') as f:
f.write('X' * size)
f.write(b'X' * size)
22 changes: 11 additions & 11 deletions nesc/whip6/platforms/tools/compiler/make/makebuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def _gen_makefile(self, f):
include_paths.extend(self.collect_config_list(INCL_PATHS))
defines = self.collect_config_list(DEFINITIONS)
cflags = self.collect_config_list(C_FLAGS)
cflags.extend(map(lambda p: '-I' + p, include_paths))
cflags.extend(map(lambda d: '-D' + d, defines))
cflags.extend(['-I' + p for p in include_paths])
cflags.extend(['-D' + d for d in defines])

ldflags = self.collect_config_list(LD_FLAGS)

Expand All @@ -50,15 +50,15 @@ def _gen_makefile(self, f):
makefile = self.find_config_value(MAKEFILE)
if not makefile:
raise RuntimeError('no "%s" specified' % (MAKEFILE,))
print >>f, 'APP_NAME :=', app_name
print >>f, 'BOARD_NAME :=', self.board
print >>f, 'PROJECT_ROOT :=', self.project_root
print >>f, 'ALT_PROJECT_ROOT :=', self.alt_project_root
print >>f, 'BUILD_DIR :=', self.build_dir
print >>f, 'LDFLAGS += ', ' '.join(ldflags)
print >>f, 'CFLAGS += ', ' '.join(cflags)
print >>f, 'OBJS :=', ' '.join(objects)
print >>f, 'include ', makefile
print('APP_NAME :=', app_name, file=f)
print('BOARD_NAME :=', self.board, file=f)
print('PROJECT_ROOT :=', self.project_root, file=f)
print('ALT_PROJECT_ROOT :=', self.alt_project_root, file=f)
print('BUILD_DIR :=', self.build_dir, file=f)
print('LDFLAGS += ', ' '.join(ldflags), file=f)
print('CFLAGS += ', ' '.join(cflags), file=f)
print('OBJS :=', ' '.join(objects), file=f)
print('include ', makefile, file=f)

def run_step(self):
makeopts = self.collect_config_list(MAKE_OPTS)
Expand Down
4 changes: 2 additions & 2 deletions nesc/whip6/platforms/tools/compiler/nescc/nesccompile.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ def _find_native_gcc(self):
if 'LLVM' in version:
continue
if c != 'gcc-4.6':
print 'WARNING: gcc-4.6 not found. Note that this is the recommended'
print 'compiler version for NesC.'
print('WARNING: gcc-4.6 not found. Note that this is the recommended')
print('compiler version for NesC.')
return c
except Exception:
pass
Expand Down
2 changes: 1 addition & 1 deletion nesc/whip6/platforms/tools/other/gengdbinit.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def _gen_gdbinit(self, f):
paths.append(config[CONF_PATH])
paths.extend(self.collect_config_list(INCL_PATHS))
for path in paths:
print >>f, 'directory ', path
print('directory ', path, file=f)

def run_step(self):
with open(os.path.join(self.build_dir, 'gdbinit'), 'w') as f:
Expand Down
2 changes: 1 addition & 1 deletion nesc/whip6/platforms/tools/other/make_ext_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def run_step(self):
if RUN_MAKE_IN in config:
for l in config[RUN_MAKE_IN]:
relative_l = l[(len(self.project_root) + 1):]
print colored('Running make in %s ...' % (relative_l,), 'cyan')
print(colored('Running make in %s ...' % (relative_l,), 'cyan'))
self.call('make', '-j', str(num_threads), '-C', l, *makeopts)

# Exports the BuildStep to make it visible for smake
Expand Down
8 changes: 4 additions & 4 deletions nesc/whip6/platforms/tools/other/makeapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ def __init__(self, project_root, configs, flags):
BuildStep.__init__(self, project_root, configs, flags)

def run_step(self):
coreName = raw_input("What will be the core name of the "
coreName = input("What will be the core name of the "
"app (fe. ButtonRadio, Blink)?\n> ").strip()

if not re.match(ur'^[A-Z]\w+$', coreName):
if not re.match(r'^[A-Z]\w+$', coreName):
raise BuildError("Error: Name must match regex ^[A-Z]\w+$")

newAppPath = join(self.project_root, APPS, coreName)

if os.path.exists(newAppPath):
raise BuildError("Error: path %s already exists" % newAppPath)

srcAppName = raw_input("What will be the base app? This must be"
srcAppName = input("What will be the base app? This must be"
" an existing app folder name\n"
"[Blink] > ").strip()

Expand All @@ -48,7 +48,7 @@ def run_step(self):
if not os.path.exists(srcAppPath):
raise BuildError("Error: Path %s does not exist" % srcAppPath)

repName = raw_input("What will be the replace word? This word will be"
repName = input("What will be the replace word? This word will be"
" replaced in all files with %s\n"
"[%s] > " % (coreName, srcAppName)).strip()

Expand Down
16 changes: 8 additions & 8 deletions nesc/whip6/platforms/tools/other/setuniqueids.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#
import glob
import time
import cStringIO
import io
from os.path import join

from build_step import BuildStep
Expand Down Expand Up @@ -37,21 +37,21 @@ def _replaceWithNumbers(self, cFile, bestIdsList, firstId):
contents = f.read()
contents = contents.replace(REMOVE_LINE, '')
parts = contents.split(SYMBOL)
io = cStringIO.StringIO()
io.write(parts[0])
stream = io.StringIO()
stream.write(parts[0])
for p in parts[1:]:
io.write(str(bestIdsList[firstId]))
io.write(p)
stream.write(str(bestIdsList[firstId]))
stream.write(p)
firstId += 1
with open(cFile, 'w') as f:
f.write(io.getvalue())
f.write(stream.getvalue())
return firstId

def _findEfficientNumbers(self, maxNumber):
"""Efficient numbers are thouse which have no 0s (101 - bad),
are short and have a small digit sum"""
candidates = []
for i in xrange(1, maxNumber + 1):
for i in range(1, maxNumber + 1):
hasZero, cost = self._evaluateNumber(i)
if not hasZero:
candidates.append((cost, i))
Expand All @@ -66,7 +66,7 @@ def _evaluateNumber(self, n):
digSum += d
if d == 0:
return True, -1
n /= 10
n //= 10
digCnt += 1

return (False, (digCnt + digSum))
Expand Down
4 changes: 2 additions & 2 deletions nesc/whip6/platforms/tools/other/warn_about_printfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from build_step import BuildStep

PRINTF_PATTERN = re.compile(ur'printf\s*\(\s*"')
PRINTF_PATTERN = re.compile(r'printf\s*\(\s*"')
WARNING_MSG = '''
+-------------------------------------------------------------------+
| |
Expand All @@ -35,7 +35,7 @@ def run_step(self):
for cFile in c_files:
with open(cFile, 'r') as f:
if PRINTF_PATTERN.search(f.read()):
print colored(WARNING_MSG, 'yellow')
print(colored(WARNING_MSG, 'yellow'))
return

BuildStepImpl = WarnAboutPrintfs
Expand Down
Loading