Skip to content

Commit

Permalink
Clean up minor warnings from LGTM.com (#7500)
Browse files Browse the repository at this point in the history
* Clean up minor warnings from LGTM.com

LGTM (Semmie) is a tool, bought by GitHub last year, that conducts basic
linting tasks on code and HTML.

Clean up the warnings identified in the latest report:
https://lgtm.com/projects/g/esp8266/Arduino/?mode=list

No functionality should change, however this may fix some issues with
the perl utilities not exiting properly on a Ctrl-C from the command
line.

* Back out HTML changes and rerun boards.txt.py
  • Loading branch information
earlephilhower authored Aug 4, 2020
1 parent a8e35a5 commit 9afb084
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 43 deletions.
2 changes: 1 addition & 1 deletion doc/boards.rst
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,6 @@ DOIT ESP-Mx DevKit (ESP8285)
----------------------------

DOIT ESP-Mx DevKit - This is a development board by DOIT, with a DOIT ESP-Mx module (`datasheet <https://github.com/SmartArduino/SZDOITWiKi/wiki/ESP8285---ESP-M2>`__) using a ESP8285 Chip. With the DOIT ESP-Mx module, GPIO pins 9 and 10 are not available. The DOIT ESP-Mx DevKit board has a red power LED and a blue LED connected to GPIO16 and is active low to turn on. It uses a CH340C, USB to Serial converter chip.
ESP8285 (`datasheet <http://www.espressif.com/sites/default/files/0a-esp8285_datasheet_en_v1.0_20160422.pdf>`__) is a multi-chip package which contains ESP8266 and 1MB flash.

ESP8285 (`datasheet <http://www.espressif.com/sites/default/files/0a-esp8285_datasheet_en_v1.0_20160422.pdf>`__) is a multi-chip package which contains ESP8266 and 1MB flash.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3
#!/usr/bin/env python3

# This script pulls the list of Mozilla trusted certificate authorities
# from the web at the "mozurl" below, parses the file to grab the PEM
Expand All @@ -14,11 +14,11 @@
from subprocess import Popen, PIPE, call
try:
from urllib.request import urlopen
except:
except Exception:
from urllib2 import urlopen
try:
from StringIO import StringIO
except:
except Exception:
from io import StringIO

# Mozilla's URL for the CSV file with included PEM certs
Expand All @@ -42,7 +42,7 @@
# Try and make ./data, skip if present
try:
os.mkdir("data")
except:
except Exception:
pass

derFiles = []
Expand Down
5 changes: 0 additions & 5 deletions package/upload_release.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

from github import Github
import argparse
import collections
import glob
import json
import mimetypes
import os

parser = argparse.ArgumentParser(description='Upload a set of files to a new draft release')
parser.add_argument('--user', help="Github username", type=str, required=True)
Expand Down
37 changes: 18 additions & 19 deletions tools/boards.txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,23 +907,23 @@
'1M',
],
'desc': [
'ESP8266 based devices from ITEAD: Sonoff SV, Sonoff TH, Sonoff Basic, '
'ESP8266 based devices from ITEAD: Sonoff SV, Sonoff TH, Sonoff Basic, ' +
'and Sonoff S20',
'',
'These are not development boards. The development process is '
'inconvenient with these devices. When flashing firmware you will '
'These are not development boards. The development process is ' +
'inconvenient with these devices. When flashing firmware you will ' +
'need a Serial Adapter to connect it to your computer.',
'',
' | Most of these devices, during normal operation, are connected to '
'*wall power (AKA Mains Electricity)*. **NEVER** try to flash these '
'devices when connected to *wall power*. **ALWAYS** have them '
'disconnected from *wall power* when connecting them to your '
' | Most of these devices, during normal operation, are connected to ' +
'*wall power (AKA Mains Electricity)*. **NEVER** try to flash these ' +
'devices when connected to *wall power*. **ALWAYS** have them ' +
'disconnected from *wall power* when connecting them to your ' +
'computer. Your life may depend on it!',
'',
'When flashing you will need to hold down the push button connected '
'to the GPIO0 pin, while powering up with a safe 3.3 Volt source. Some USB '
'Serial Adapters may supply enough power to handle flashing; '
'however, it many may not supply enough power to handle the '
'When flashing you will need to hold down the push button connected ' +
'to the GPIO0 pin, while powering up with a safe 3.3 Volt source. Some USB ' +
'Serial Adapters may supply enough power to handle flashing; ' +
'however, it many may not supply enough power to handle the ' +
'activities when the device reboots.',
'',
'More product details at the bottom of https://www.itead.cc/wiki/Product/'
Expand All @@ -943,15 +943,14 @@
'1M',
],
'desc': [
'DOIT ESP-Mx DevKit - This is a development board by DOIT, with a DOIT ESP-Mx module '
'(`datasheet <https://github.com/SmartArduino/SZDOITWiKi/wiki/ESP8285---ESP-M2>`__) '
'using a ESP8285 Chip. With the DOIT ESP-Mx module, GPIO pins 9 and 10 are not available. '
'The DOIT ESP-Mx DevKit board has a red power LED and a blue LED connected to GPIO16 '
'and is active low to turn on. It uses a CH340C, USB to Serial converter chip. '
'',
'ESP8285 (`datasheet <http://www.espressif.com/sites/default/files/0a-esp8285_datasheet_en_v1.0_20160422.pdf>`__) '
'is a multi-chip package which contains ESP8266 and 1MB flash. ',
'DOIT ESP-Mx DevKit - This is a development board by DOIT, with a DOIT ESP-Mx module ' +
'(`datasheet <https://github.com/SmartArduino/SZDOITWiKi/wiki/ESP8285---ESP-M2>`__) ' +
'using a ESP8285 Chip. With the DOIT ESP-Mx module, GPIO pins 9 and 10 are not available. ' +
'The DOIT ESP-Mx DevKit board has a red power LED and a blue LED connected to GPIO16 ' +
'and is active low to turn on. It uses a CH340C, USB to Serial converter chip. ',
'',
'ESP8285 (`datasheet <http://www.espressif.com/sites/default/files/0a-esp8285_datasheet_en_v1.0_20160422.pdf>`__) ' +
'is a multi-chip package which contains ESP8266 and 1MB flash. '
],

})
Expand Down
4 changes: 2 additions & 2 deletions tools/elf2bin.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def get_segment_size_addr(elf, segment, path):
def read_segment(elf, segment, path):
fd, tmpfile = tempfile.mkstemp()
os.close(fd)
p = subprocess.check_call([path + "/xtensa-lx106-elf-objcopy", '-O', 'binary', '--only-section=' + segment, elf, tmpfile], stdout=subprocess.PIPE)
subprocess.check_call([path + "/xtensa-lx106-elf-objcopy", '-O', 'binary', '--only-section=' + segment, elf, tmpfile], stdout=subprocess.PIPE)
with open(tmpfile, "rb") as f:
raw = f.read()
os.remove(tmpfile)
Expand Down Expand Up @@ -85,7 +85,7 @@ def write_bin(out, args, elf, segments, to_addr):
try:
for data in raw:
checksum = checksum ^ ord(data)
except:
except Exception:
for data in raw:
checksum = checksum ^ data
total_size += 1
Expand Down
14 changes: 7 additions & 7 deletions tools/espota.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def serve(remoteAddr, localAddr, remotePort, localPort, password, filename, comm
try:
sock.bind(server_address)
sock.listen(1)
except:
except Exception:
logging.error("Listen Failed")
return 1

Expand All @@ -100,11 +100,11 @@ def serve(remoteAddr, localAddr, remotePort, localPort, password, filename, comm
logging.info('Sending invitation to: %s', remoteAddr)
sock2 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
remote_address = (remoteAddr, int(remotePort))
sent = sock2.sendto(message.encode(), remote_address)
sock2.sendto(message.encode(), remote_address)
sock2.settimeout(10)
try:
data = sock2.recv(128).decode()
except:
except Exception:
logging.error('No Answer')
sock2.close()
return 1
Expand All @@ -123,7 +123,7 @@ def serve(remoteAddr, localAddr, remotePort, localPort, password, filename, comm
sock2.settimeout(10)
try:
data = sock2.recv(32).decode()
except:
except Exception:
sys.stderr.write('FAIL\n')
logging.error('No Answer to our Authentication')
sock2.close()
Expand All @@ -147,7 +147,7 @@ def serve(remoteAddr, localAddr, remotePort, localPort, password, filename, comm
connection, client_address = sock.accept()
sock.settimeout(None)
connection.settimeout(None)
except:
except Exception:
logging.error('No response from device')
sock.close()
return 1
Expand All @@ -173,7 +173,7 @@ def serve(remoteAddr, localAddr, remotePort, localPort, password, filename, comm
if connection.recv(32).decode().find('O') >= 0:
# connection will receive only digits or 'OK'
received_ok = True
except:
except Exception:
sys.stderr.write('\n')
logging.error('Error Uploading')
connection.close()
Expand Down Expand Up @@ -207,7 +207,7 @@ def serve(remoteAddr, localAddr, remotePort, localPort, password, filename, comm
if received_ok:
return 0
return 1
except:
except Exception:
logging.error('No Result!')
connection.close()
f.close()
Expand Down
6 changes: 3 additions & 3 deletions tools/makecorever.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def git(*args):
try:
git_ver = git("rev-parse", "--short=8", "HEAD")
git_desc = git("describe", "--tags")
except:
except Exception:
pass

text = "#define ARDUINO_ESP8266_GIT_VER 0x{}\n".format(git_ver)
Expand All @@ -43,7 +43,7 @@ def git(*args):
old_text = inp.read()
if old_text == text:
return
except:
except Exception:
pass

with open(path, "w") as out:
Expand Down Expand Up @@ -73,7 +73,7 @@ def git(*args):
include_dir = os.path.join(args.build_path, args.include_dir)
try:
os.makedirs(include_dir)
except:
except Exception:
pass

generate(
Expand Down
1 change: 0 additions & 1 deletion tools/signing.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def main():
f.write(val)
return 0
elif args.mode == "sign":
val = ""
if not os.path.isfile(args.privatekey):
return
try:
Expand Down
2 changes: 1 addition & 1 deletion tools/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
sys.path.insert(0, toolspath + "/pyserial") # Add pyserial dir to search path
sys.path.insert(0, toolspath + "/esptool") # Add esptool dir to search path
import esptool # If this fails, we can't continue and will bomb below
except:
except Exception:
sys.stderr.write("pyserial or esptool directories not found next to this upload.py tool.\n")
sys.exit(1)

Expand Down

0 comments on commit 9afb084

Please sign in to comment.