From 437b0dd9295a485b82e2994b7bd1edff3cde020c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Thu, 8 Feb 2018 11:12:44 +0100 Subject: [PATCH] Fix some codacy issues with python files --- README.md | 2 +- code/espurna/config/build.h | 3 --- code/extra_scripts.py | 4 ++-- code/memanalyzer.py | 4 ++-- code/ota.py | 12 ++++-------- 5 files changed, 9 insertions(+), 16 deletions(-) delete mode 100644 code/espurna/config/build.h diff --git a/README.md b/README.md index a2981fb3..7e58e1a4 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ It uses the Arduino Core for ESP8266 framework and a number of 3rd party librari [![version](https://img.shields.io/badge/version-1.12.4a-brightgreen.svg)](CHANGELOG.md) ![branch](https://img.shields.io/badge/branch-dev-orange.svg) [![travis](https://travis-ci.org/xoseperez/espurna.svg?branch=dev)](https://travis-ci.org/xoseperez/espurna) -[![codacy](https://img.shields.io/codacy/grade/c9496e25cf07434cba786b462cb15f49/dev.svg)](https://www.codacy.com/app/xoseperez/espurna/dashboard)[![license](https://img.shields.io/github/license/xoseperez/espurna.svg)](LICENSE) +[![codacy](https://img.shields.io/codacy/grade/c9496e25cf07434cba786b462cb15f49/dev.svg)](https://www.codacy.com/app/xoseperez/espurna/dashboard) [![donate](https://img.shields.io/badge/donate-PayPal-blue.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=xose%2eperez%40gmail%2ecom&lc=US&no_note=0¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHostedGuest) [![twitter](https://img.shields.io/twitter/follow/xoseperez.svg?style=social)](https://twitter.com/intent/follow?screen_name=xoseperez) diff --git a/code/espurna/config/build.h b/code/espurna/config/build.h deleted file mode 100644 index 106e7989..00000000 --- a/code/espurna/config/build.h +++ /dev/null @@ -1,3 +0,0 @@ -// DO NOT EDIT THIS FILE MANUALLY -// This file is modified by PlatformIO -#define APP_BUILD_FLAGS "" diff --git a/code/extra_scripts.py b/code/extra_scripts.py index 43e54ec4..77123648 100644 --- a/code/extra_scripts.py +++ b/code/extra_scripts.py @@ -6,7 +6,7 @@ Import("env") # Utils # ------------------------------------------------------------------------------ -class Color: +class Color(object): BLACK = '\x1b[1;30m' RED = '\x1b[1;31m' GREEN = '\x1b[1;32m' @@ -32,7 +32,7 @@ def clr(color, text): # ------------------------------------------------------------------------------ def check_size(source, target, env): - time.sleep(1) + time.sleep(2) size = target[0].get_size() print clr(Color.LIGHT_BLUE, "Binary size: %s bytes" % size) #if size > 512000: diff --git a/code/memanalyzer.py b/code/memanalyzer.py index 181e7283..c2f236b1 100644 --- a/code/memanalyzer.py +++ b/code/memanalyzer.py @@ -50,7 +50,7 @@ description = "ESPurna Memory Analyzer v0.1" def file_size(file): try: return os.stat(file).st_size - except: + except OSError: return 0 @@ -65,7 +65,7 @@ def analyse_memory(elf_file): # print("------------------------------------------------------------------------------"); ret = {} - for (id_, descr) in list(sections.items()): + for (id_, _) in list(sections.items()): section_start_token = " _%s_start" % id_ section_end_token = " _%s_end" % id_ section_start = -1 diff --git a/code/ota.py b/code/ota.py index ddc7aa26..4726eb76 100755 --- a/code/ota.py +++ b/code/ota.py @@ -155,7 +155,7 @@ def input_board(): # Choose the board try: index = int(input("Choose the board you want to flash (empty if none of these): ")) - except: + except ValueError: index = 0 if index < 0 or len(devices) < index: print("Board number must be between 1 and %s\n" % str(len(devices))) @@ -175,7 +175,7 @@ def input_board(): print() try: index = int(input("Choose the board type you want to flash: ")) - except: + except ValueError: index = 0 if index < 1 or len(boards) < index: print("Board number must be between 1 and %s\n" % str(len(boards))) @@ -186,17 +186,13 @@ def input_board(): if board.get('size', 0) == 0: try: board['size'] = int(input("Board memory size (1 for 1M, 4 for 4M): ")) - except: + except ValueError: print("Wrong memory size") return None # Choose IP of none before if len(board.get('ip', '')) == 0: - try: - board['ip'] = input("IP of the device to flash (empty for 192.168.4.1): ") or "192.168.4.1" - except: - print("Wrong IP") - return None + board['ip'] = input("IP of the device to flash (empty for 192.168.4.1): ") or "192.168.4.1" return board