Skip to content

Commit

Permalink
Fixes for styling issues reported by Codacy (#1196)
Browse files Browse the repository at this point in the history
* Fixing python related issues reported by Codacy.
* Fixed docker related issues.
  • Loading branch information
slaff authored Jul 21, 2017
1 parent 4389a0a commit 08143b5
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Sming/Libraries/RF24/tests/pingpair_blocking/runtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys,serial

def read_until(token):
while 1:
while 1:
line = ser.readline(None)
sys.stdout.write(line)

Expand Down
2 changes: 1 addition & 1 deletion Sming/Libraries/RF24/tests/pingpair_test/runtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys,serial

def read_until(token):
while 1:
while 1:
line = ser.readline(None,"\r")
sys.stdout.write(line)

Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ MAINTAINER Slavey Karadzhov <[email protected]>
COPY assets/welcome.html /cloud9/plugins/c9.ide.welcome/welcome.html
COPY assets/welcome.js /cloud9/plugins/c9.ide.welcome/welcome.js

RUN cd /workspace && git clone https://github.com/SmingHub/Sming.git
RUN git clone https://github.com/SmingHub/Sming.git /workspace/Sming

ENV SMING_HOME /workspace/Sming/Sming

Expand Down
23 changes: 11 additions & 12 deletions tools/decode-stacktrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,32 @@
#
########################################################
import shlex
import select
import subprocess
import sys
import re

def usage():
print("Usage: \n\t%s <file.elf> [<error-stack.log>]" % sys.argv[0])

def extractAddresses(data):
m = re.findall("(40[0-2](\d|[a-f]){5})", data)
if len(m) == 0:
return m

addresses = []
for item in m:
addresses.append(item[0])
return addresses
addresses.append(item[0])

return addresses

if __name__ == "__main__":
if len(sys.argv) not in list(range(2,4)):
usage()
sys.exit(1)

command = "xtensa-lx106-elf-addr2line -aipfC -e '%s' " % sys.argv[1]
pipe = subprocess.Popen(shlex.split(command), bufsize=1, stdin=subprocess.PIPE)

if len(sys.argv) > 2:
data = open(sys.argv[2]).read()
pipe.communicate("\n".join(extractAddresses(data)).encode('ascii'))
Expand All @@ -42,12 +41,12 @@ def extractAddresses(data):
addresses = extractAddresses(data)
if len(addresses) == 0:
continue

# print ( "[",addresses,"]" )

line = "\r\n".join(addresses)+"\r\n"
# line = line.ljust(125," ")

pipe.stdin.write(line)
pipe.stdin.flush()

24 changes: 12 additions & 12 deletions tools/memanalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
("rodata", "ReadOnly Data (RAM)"),
("bss", "Uninitialized Data (RAM)"),
("text", "Cached Code (IRAM)"),
("irom0_text", "Uncached Code (SPI)")
("irom0_text", "Uncached Code (SPI)")
])

if len(sys.argv) < 2:
Expand All @@ -35,10 +35,10 @@
sys.exit(1)


command = "%s -t '%s' " % (sys.argv[1], sys.argv[2])
command = "%s -t '%s' " % (sys.argv[1], sys.argv[2])
response = subprocess.check_output(shlex.split(command))
if isinstance(response, bytes):
response = response.decode('utf-8')
response = response.decode('utf-8')
lines = response.split('\n')

print("{0: >10}|{1: >30}|{2: >12}|{3: >12}|{4: >8}".format("Section", "Description", "Start (hex)", "End (hex)", "Used space"));
Expand All @@ -48,32 +48,32 @@
usedIRAM = 0;

i = 0
for (id, descr) in list(sections.items()):
sectionStartToken = " _%s_start" % id
sectionEndToken = " _%s_end" % id;
for (name, descr) in list(sections.items()):
sectionStartToken = " _%s_start" % name
sectionEndToken = " _%s_end" % name
sectionStart = -1;
sectionEnd = -1;
for line in lines:
if sectionStartToken in line:
data = line.split(' ')
sectionStart = int(data[0], 16)
if sectionEndToken in line:

if sectionEndToken in line:
data = line.split(' ')
sectionEnd = int(data[0], 16)

if sectionStart != -1 and sectionEnd != -1:
break

sectionLength = sectionEnd - sectionStart
if i < 3:
usedRAM += sectionLength
if i == 3:
usedIRAM = TOTAL_DRAM - sectionLength;

print("{0: >10}|{1: >30}|{2:12X}|{3:12X}|{4:8}".format(id, descr, sectionStart, sectionEnd, sectionLength))
print("{0: >10}|{1: >30}|{2:12X}|{3:12X}|{4:8}".format(name, descr, sectionStart, sectionEnd, sectionLength))
i += 1

print("Total Used RAM : %d" % usedRAM)
print("Free RAM : %d" % (TOTAL_IRAM - usedRAM))
print("Free IRam : %d" % usedIRAM)

0 comments on commit 08143b5

Please sign in to comment.