Cleanup issues identified by lgtm (#14459)
* cleanup issues identified by lgtm * fix the git_status check
This commit is contained in:
parent
5f38a98fa0
commit
fce9cb9338
@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
import hid
|
import hid
|
||||||
import time
|
import time
|
||||||
import string
|
|
||||||
import psutil
|
import psutil
|
||||||
import GPUtil
|
import GPUtil
|
||||||
import datetime
|
import datetime
|
||||||
|
@ -584,11 +584,6 @@ def unicode_macro_cases(config):
|
|||||||
for macro_id, uc_hex in config['unicode_macros'].items():
|
for macro_id, uc_hex in config['unicode_macros'].items():
|
||||||
hi = int(uc_hex, 16) >> 8
|
hi = int(uc_hex, 16) >> 8
|
||||||
lo = int(uc_hex, 16) & 0xFF
|
lo = int(uc_hex, 16) & 0xFF
|
||||||
unimacro_keys = ", ".join(
|
|
||||||
"T({})".format(
|
|
||||||
"KP_" + digit if digit.isdigit() else digit
|
|
||||||
) for digit in uc_hex
|
|
||||||
)
|
|
||||||
yield UNICODE_MACRO_TEMPLATE.format(
|
yield UNICODE_MACRO_TEMPLATE.format(
|
||||||
macro_id=macro_id, hi=hi, lo=lo
|
macro_id=macro_id, hi=hi, lo=lo
|
||||||
)
|
)
|
||||||
|
@ -227,7 +227,6 @@ class KeymapBeautifier:
|
|||||||
self.layer_keys_pointer = 0
|
self.layer_keys_pointer = 0
|
||||||
|
|
||||||
begin = self.layer_keys_pointer
|
begin = self.layer_keys_pointer
|
||||||
end = begin + n_columns
|
|
||||||
return self.layer_keys[self.layer_keys_pointer-n_keys:self.layer_keys_pointer]
|
return self.layer_keys[self.layer_keys_pointer-n_keys:self.layer_keys_pointer]
|
||||||
|
|
||||||
key_coordinates_counter = 0
|
key_coordinates_counter = 0
|
||||||
|
@ -8,7 +8,6 @@ import time
|
|||||||
|
|
||||||
from math import floor
|
from math import floor
|
||||||
from os.path import dirname
|
from os.path import dirname
|
||||||
from subprocess import Popen, PIPE, STDOUT
|
|
||||||
from blessings import Terminal
|
from blessings import Terminal
|
||||||
|
|
||||||
class Heatmap(object):
|
class Heatmap(object):
|
||||||
@ -122,7 +121,6 @@ class Heatmap(object):
|
|||||||
|
|
||||||
for (c, r) in self.log:
|
for (c, r) in self.log:
|
||||||
coords = self.coord(c, r)
|
coords = self.coord(c, r)
|
||||||
b, n = coords
|
|
||||||
cap = self.max_cnt
|
cap = self.max_cnt
|
||||||
if cap == 0:
|
if cap == 0:
|
||||||
cap = 1
|
cap = 1
|
||||||
@ -302,7 +300,7 @@ def main(opts):
|
|||||||
break
|
break
|
||||||
if not process_line(line, heatmaps, opts):
|
if not process_line(line, heatmaps, opts):
|
||||||
continue
|
continue
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
stamped_log = open ("%s/stamped-log" % (out_dir), "a+")
|
stamped_log = open ("%s/stamped-log" % (out_dir), "a+")
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
charmap = {
|
charmap = {
|
||||||
|
@ -584,11 +584,6 @@ def unicode_macro_cases(config):
|
|||||||
for macro_id, uc_hex in config['unicode_macros'].items():
|
for macro_id, uc_hex in config['unicode_macros'].items():
|
||||||
hi = int(uc_hex, 16) >> 8
|
hi = int(uc_hex, 16) >> 8
|
||||||
lo = int(uc_hex, 16) & 0xFF
|
lo = int(uc_hex, 16) & 0xFF
|
||||||
unimacro_keys = ", ".join(
|
|
||||||
"T({})".format(
|
|
||||||
"KP_" + digit if digit.isdigit() else digit
|
|
||||||
) for digit in uc_hex
|
|
||||||
)
|
|
||||||
yield UNICODE_MACRO_TEMPLATE.format(
|
yield UNICODE_MACRO_TEMPLATE.format(
|
||||||
macro_id=macro_id, hi=hi, lo=lo
|
macro_id=macro_id, hi=hi, lo=lo
|
||||||
)
|
)
|
||||||
|
@ -118,10 +118,9 @@ def check_udev_rules():
|
|||||||
cli.log.warning("{fg_yellow}Found old, deprecated udev rules for '%s' boards. The new rules on https://docs.qmk.fm/#/faq_build?id=linux-udev-rules offer better security with the same functionality.", bootloader)
|
cli.log.warning("{fg_yellow}Found old, deprecated udev rules for '%s' boards. The new rules on https://docs.qmk.fm/#/faq_build?id=linux-udev-rules offer better security with the same functionality.", bootloader)
|
||||||
else:
|
else:
|
||||||
# For caterina, check if ModemManager is running
|
# For caterina, check if ModemManager is running
|
||||||
if bootloader == "caterina":
|
if bootloader == "caterina" and check_modem_manager():
|
||||||
if check_modem_manager():
|
|
||||||
rc = CheckStatus.WARNING
|
|
||||||
cli.log.warning("{fg_yellow}Detected ModemManager without the necessary udev rules. Please either disable it or set the appropriate udev rules if you are using a Pro Micro.")
|
cli.log.warning("{fg_yellow}Detected ModemManager without the necessary udev rules. Please either disable it or set the appropriate udev rules if you are using a Pro Micro.")
|
||||||
|
|
||||||
rc = CheckStatus.WARNING
|
rc = CheckStatus.WARNING
|
||||||
cli.log.warning("{fg_yellow}Missing or outdated udev rules for '%s' boards. Run 'sudo cp %s/util/udev/50-qmk.rules /etc/udev/rules.d/'.", bootloader, QMK_FIRMWARE)
|
cli.log.warning("{fg_yellow}Missing or outdated udev rules for '%s' boards. Run 'sudo cp %s/util/udev/50-qmk.rules /etc/udev/rules.d/'.", bootloader, QMK_FIRMWARE)
|
||||||
|
|
||||||
@ -167,6 +166,5 @@ def os_test_linux():
|
|||||||
return CheckStatus.OK
|
return CheckStatus.OK
|
||||||
else:
|
else:
|
||||||
cli.log.info("Detected {fg_cyan}Linux{fg_reset}.")
|
cli.log.info("Detected {fg_cyan}Linux{fg_reset}.")
|
||||||
from .linux import check_udev_rules
|
|
||||||
|
|
||||||
return check_udev_rules()
|
return check_udev_rules()
|
||||||
|
@ -79,12 +79,13 @@ def doctor(cli):
|
|||||||
cli.log.info('CLI version: %s', cli.version)
|
cli.log.info('CLI version: %s', cli.version)
|
||||||
cli.log.info('QMK home: {fg_cyan}%s', QMK_FIRMWARE)
|
cli.log.info('QMK home: {fg_cyan}%s', QMK_FIRMWARE)
|
||||||
|
|
||||||
status = os_tests()
|
status = os_status = os_tests()
|
||||||
|
git_status = git_tests()
|
||||||
|
|
||||||
status = git_tests()
|
if git_status == CheckStatus.ERROR or (os_status == CheckStatus.OK and git_status == CheckStatus.WARNING):
|
||||||
|
status = git_status
|
||||||
|
|
||||||
venv = in_virtualenv()
|
if in_virtualenv():
|
||||||
if venv:
|
|
||||||
cli.log.info('CLI installed in virtualenv.')
|
cli.log.info('CLI installed in virtualenv.')
|
||||||
|
|
||||||
# Make sure the basic CLI tools we need are available and can be executed.
|
# Make sure the basic CLI tools we need are available and can be executed.
|
||||||
|
@ -173,7 +173,7 @@ def generate_config_h(cli):
|
|||||||
kb_info_json = dotty(info_json(cli.args.keyboard))
|
kb_info_json = dotty(info_json(cli.args.keyboard))
|
||||||
|
|
||||||
# Build the info_config.h file.
|
# Build the info_config.h file.
|
||||||
config_h_lines = ['/* This file was generated by `qmk generate-config-h`. Do not edit or copy.' ' */', '', '#pragma once']
|
config_h_lines = ['/* This file was generated by `qmk generate-config-h`. Do not edit or copy.', ' */', '', '#pragma once']
|
||||||
|
|
||||||
generate_config_items(kb_info_json, config_h_lines)
|
generate_config_items(kb_info_json, config_h_lines)
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ def generate_dfu_header(cli):
|
|||||||
# Build the Keyboard.h file.
|
# Build the Keyboard.h file.
|
||||||
kb_info_json = dotty(info_json(cli.config.generate_dfu_header.keyboard))
|
kb_info_json = dotty(info_json(cli.config.generate_dfu_header.keyboard))
|
||||||
|
|
||||||
keyboard_h_lines = ['/* This file was generated by `qmk generate-dfu-header`. Do not edit or copy.' ' */', '', '#pragma once']
|
keyboard_h_lines = ['/* This file was generated by `qmk generate-dfu-header`. Do not edit or copy.', ' */', '', '#pragma once']
|
||||||
keyboard_h_lines.append(f'#define MANUFACTURER {kb_info_json["manufacturer"]}')
|
keyboard_h_lines.append(f'#define MANUFACTURER {kb_info_json["manufacturer"]}')
|
||||||
keyboard_h_lines.append(f'#define PRODUCT {cli.config.generate_dfu_header.keyboard} Bootloader')
|
keyboard_h_lines.append(f'#define PRODUCT {cli.config.generate_dfu_header.keyboard} Bootloader')
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ def generate_keyboard_h(cli):
|
|||||||
has_layout_h = would_populate_layout_h(cli.args.keyboard)
|
has_layout_h = would_populate_layout_h(cli.args.keyboard)
|
||||||
|
|
||||||
# Build the layouts.h file.
|
# Build the layouts.h file.
|
||||||
keyboard_h_lines = ['/* This file was generated by `qmk generate-keyboard-h`. Do not edit or copy.' ' */', '', '#pragma once', '#include "quantum.h"']
|
keyboard_h_lines = ['/* This file was generated by `qmk generate-keyboard-h`. Do not edit or copy.', ' */', '', '#pragma once', '#include "quantum.h"']
|
||||||
|
|
||||||
if not has_layout_h:
|
if not has_layout_h:
|
||||||
keyboard_h_lines.append('#pragma error("<keyboard>.h is only optional for data driven keyboards - kb.h == bad times")')
|
keyboard_h_lines.append('#pragma error("<keyboard>.h is only optional for data driven keyboards - kb.h == bad times")')
|
||||||
|
@ -38,7 +38,7 @@ def generate_layouts(cli):
|
|||||||
kb_info_json = info_json(cli.config.generate_layouts.keyboard)
|
kb_info_json = info_json(cli.config.generate_layouts.keyboard)
|
||||||
|
|
||||||
# Build the layouts.h file.
|
# Build the layouts.h file.
|
||||||
layouts_h_lines = ['/* This file was generated by `qmk generate-layouts`. Do not edit or copy.' ' */', '', '#pragma once']
|
layouts_h_lines = ['/* This file was generated by `qmk generate-layouts`. Do not edit or copy.', ' */', '', '#pragma once']
|
||||||
|
|
||||||
if 'matrix_pins' in kb_info_json:
|
if 'matrix_pins' in kb_info_json:
|
||||||
if 'direct' in kb_info_json['matrix_pins']:
|
if 'direct' in kb_info_json['matrix_pins']:
|
||||||
|
@ -29,10 +29,10 @@ def info_json(keyboard):
|
|||||||
"""Generate the info.json data for a specific keyboard.
|
"""Generate the info.json data for a specific keyboard.
|
||||||
"""
|
"""
|
||||||
cur_dir = Path('keyboards')
|
cur_dir = Path('keyboards')
|
||||||
rules = parse_rules_mk_file(cur_dir / keyboard / 'rules.mk')
|
root_rules_mk = parse_rules_mk_file(cur_dir / keyboard / 'rules.mk')
|
||||||
if 'DEFAULT_FOLDER' in rules:
|
|
||||||
keyboard = rules['DEFAULT_FOLDER']
|
if 'DEFAULT_FOLDER' in root_rules_mk:
|
||||||
rules = parse_rules_mk_file(cur_dir / keyboard / 'rules.mk', rules)
|
keyboard = root_rules_mk['DEFAULT_FOLDER']
|
||||||
|
|
||||||
info_data = {
|
info_data = {
|
||||||
'keyboard_name': str(keyboard),
|
'keyboard_name': str(keyboard),
|
||||||
|
@ -149,8 +149,8 @@ def is_keymap_dir(keymap, c=True, json=True, additional_files=None):
|
|||||||
for file in files:
|
for file in files:
|
||||||
if (keymap / file).is_file():
|
if (keymap / file).is_file():
|
||||||
if additional_files:
|
if additional_files:
|
||||||
for file in additional_files:
|
for additional_file in additional_files:
|
||||||
if not (keymap / file).is_file():
|
if not (keymap / additional_file).is_file():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from functools import reduce
|
from functools import reduce
|
||||||
import re
|
|
||||||
|
|
||||||
strings = []
|
strings = []
|
||||||
number_of_strings = -1
|
number_of_strings = -1
|
||||||
|
@ -197,7 +197,6 @@ def dumpBinary(data, canonical):
|
|||||||
print("")
|
print("")
|
||||||
|
|
||||||
size = len(data)
|
size = len(data)
|
||||||
empty_rows = 0
|
|
||||||
prev_row = ''
|
prev_row = ''
|
||||||
first_repeat = True
|
first_repeat = True
|
||||||
for pos in range(0, size, 16):
|
for pos in range(0, size, 16):
|
||||||
|
@ -78,7 +78,7 @@ def convert_from_uf2(buf):
|
|||||||
if datalen > 476:
|
if datalen > 476:
|
||||||
assert False, "Invalid UF2 data size at " + ptr
|
assert False, "Invalid UF2 data size at " + ptr
|
||||||
newaddr = hd[3]
|
newaddr = hd[3]
|
||||||
if curraddr == None:
|
if curraddr is None:
|
||||||
appstartaddr = newaddr
|
appstartaddr = newaddr
|
||||||
curraddr = newaddr
|
curraddr = newaddr
|
||||||
padding = newaddr - curraddr
|
padding = newaddr - curraddr
|
||||||
@ -171,7 +171,7 @@ def convert_from_hex_to_uf2(buf):
|
|||||||
break
|
break
|
||||||
elif tp == 0:
|
elif tp == 0:
|
||||||
addr = upper | (rec[1] << 8) | rec[2]
|
addr = upper | (rec[1] << 8) | rec[2]
|
||||||
if appstartaddr == None:
|
if appstartaddr is None:
|
||||||
appstartaddr = addr
|
appstartaddr = addr
|
||||||
i = 4
|
i = 4
|
||||||
while i < len(rec) - 1:
|
while i < len(rec) - 1:
|
||||||
@ -215,7 +215,7 @@ def get_drives():
|
|||||||
def has_info(d):
|
def has_info(d):
|
||||||
try:
|
try:
|
||||||
return os.path.isfile(d + INFO_FILE)
|
return os.path.isfile(d + INFO_FILE)
|
||||||
except:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return list(filter(has_info, drives))
|
return list(filter(has_info, drives))
|
||||||
@ -300,7 +300,7 @@ def main():
|
|||||||
(ext, len(outbuf), appstartaddr))
|
(ext, len(outbuf), appstartaddr))
|
||||||
if args.convert or ext != "uf2":
|
if args.convert or ext != "uf2":
|
||||||
drives = []
|
drives = []
|
||||||
if args.output == None:
|
if args.output is None:
|
||||||
args.output = "flash." + ext
|
args.output = "flash." + ext
|
||||||
else:
|
else:
|
||||||
drives = get_drives()
|
drives = get_drives()
|
||||||
|
Loading…
Reference in New Issue
Block a user