This commit is contained in:
Otto Winter 2019-05-24 17:20:06 +02:00
parent aa7389432e
commit 422754ed63
No known key found for this signature in database
GPG key ID: DB66C0BE6013F97E
5 changed files with 21 additions and 8 deletions

View file

@ -19,7 +19,8 @@ void DeepSleepComponent::setup() {
void DeepSleepComponent::dump_config() { void DeepSleepComponent::dump_config() {
ESP_LOGCONFIG(TAG, "Setting up Deep Sleep..."); ESP_LOGCONFIG(TAG, "Setting up Deep Sleep...");
if (this->sleep_duration_.has_value()) { if (this->sleep_duration_.has_value()) {
ESP_LOGCONFIG(TAG, " Sleep Duration: %u ms", *this->sleep_duration_ / 1000); uint32_t duration = *this->sleep_duration_ / 1000;
ESP_LOGCONFIG(TAG, " Sleep Duration: %u ms", duration);
} }
if (this->run_duration_.has_value()) { if (this->run_duration_.has_value()) {
ESP_LOGCONFIG(TAG, " Run Duration: %u ms", *this->run_duration_); ESP_LOGCONFIG(TAG, " Run Duration: %u ms", *this->run_duration_);

View file

@ -13,7 +13,7 @@ import threading
import click import click
sys.path.append(os.path.dirname(__file__)) sys.path.append(os.path.dirname(__file__))
from helpers import basepath, get_output, walk_files, filter_changed from helpers import basepath, get_output, git_ls_files, filter_changed
is_py2 = sys.version[0] == '2' is_py2 = sys.version[0] == '2'
@ -83,7 +83,7 @@ def main():
return 1 return 1
files = [] files = []
for path in walk_files(basepath): for path in git_ls_files():
filetypes = ('.cpp', '.h', '.tcc') filetypes = ('.cpp', '.h', '.tcc')
ext = os.path.splitext(path)[1] ext = os.path.splitext(path)[1]
if ext in filetypes: if ext in filetypes:

View file

@ -18,7 +18,7 @@ import threading
sys.path.append(os.path.dirname(__file__)) sys.path.append(os.path.dirname(__file__))
from helpers import basepath, shlex_quote, get_output, build_compile_commands, \ from helpers import basepath, shlex_quote, get_output, build_compile_commands, \
build_all_include, temp_header_file, walk_files, filter_changed build_all_include, temp_header_file, git_ls_files, filter_changed
is_py2 = sys.version[0] == '2' is_py2 = sys.version[0] == '2'
@ -100,7 +100,7 @@ def main():
build_compile_commands() build_compile_commands()
files = [] files = []
for path in walk_files(basepath): for path in git_ls_files():
filetypes = ('.cpp',) filetypes = ('.cpp',)
ext = os.path.splitext(path)[1] ext = os.path.splitext(path)[1]
if ext in filetypes: if ext in filetypes:

View file

@ -126,3 +126,13 @@ def filter_changed(files):
for c in files: for c in files:
print(" {}".format(c)) print(" {}".format(c))
return files return files
def git_ls_files():
command = ['git', 'ls-files', '-s']
proc = subprocess.Popen(command, stdout=subprocess.PIPE)
output, err = proc.communicate()
lines = [x.split() for x in output.decode('utf-8').splitlines()]
return {
s[3].strip(): int(s[0]) for s in lines
}

View file

@ -9,7 +9,7 @@ import re
import sys import sys
sys.path.append(os.path.dirname(__file__)) sys.path.append(os.path.dirname(__file__))
from helpers import basepath, get_output, walk_files, filter_changed from helpers import get_output, git_ls_files, filter_changed
def main(): def main():
@ -21,10 +21,10 @@ def main():
args = parser.parse_args() args = parser.parse_args()
files = [] files = []
for path in walk_files(basepath): for path in git_ls_files():
filetypes = ('.py',) filetypes = ('.py',)
ext = os.path.splitext(path)[1] ext = os.path.splitext(path)[1]
if ext in filetypes: if ext in filetypes and path.startswith('esphome'):
path = os.path.relpath(path, os.getcwd()) path = os.path.relpath(path, os.getcwd())
files.append(path) files.append(path)
# Match against re # Match against re
@ -35,6 +35,8 @@ def main():
files = filter_changed(files) files = filter_changed(files)
files.sort() files.sort()
if not files:
sys.exit(0)
errors = collections.defaultdict(list) errors = collections.defaultdict(list)
cmd = ['flake8'] + files cmd = ['flake8'] + files