flake8 in pre-commit(#1583)

albatross
Willem Melching 2020-05-27 20:33:05 -07:00 committed by GitHub
parent bd06434243
commit 29aaa44740
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 34 additions and 41 deletions

View File

@ -6,6 +6,13 @@ repos:
- id: check-json
- id: check-xml
- id: check-yaml
- repo: https://gitlab.com/PyCQA/flake8
rev: master
hooks:
- id: flake8
exclude: '^(pyextra)|(external)/'
args:
- --select=F
- repo: local
hooks:
- id: pylint

View File

@ -1,6 +1,5 @@
import numpy as np
import unittest
import timeit
from common.numpy_fast import interp

View File

@ -1,5 +1,4 @@
#!/usr/bin/env python3
import time
import numpy as np
import cereal.messaging as messaging
from PIL import ImageFont, ImageDraw, Image
@ -36,4 +35,3 @@ if __name__ == "__main__":
idx += 1
rk.keep_time()
#time.sleep(1.0)

View File

@ -1,5 +1,4 @@
import os
from common.basedir import BASEDIR
from cffi import FFI

View File

@ -340,7 +340,7 @@ class LocKalman():
for n in range(N):
idx = dim_main + n * dim_augment
err_idx = dim_main_err + n * dim_augment_err # FIXME: Why is this not used?
# err_idx = dim_main_err + n * dim_augment_err # FIXME: Why is this not used?
x, y, z = state[idx:idx + 3]
q = state[idx + 3:idx + 7]
quat_rot = quat_rotate(*q)

View File

@ -36,11 +36,11 @@ def get_workdir():
def heartbeat():
work_dir = get_workdir()
env = {
"LD_LIBRARY_PATH": "",
"ANDROID_DATA": "/data",
"ANDROID_ROOT": "/system",
}
# env = {
# "LD_LIBRARY_PATH": "",
# "ANDROID_DATA": "/data",
# "ANDROID_ROOT": "/system",
# }
while True:
try:
@ -53,7 +53,7 @@ def heartbeat():
try:
tmux = os.popen('tail -n 100 /tmp/tmux_out').read()
except:
except Exception:
pass
params = Params()

View File

@ -1,14 +1,12 @@
#!/usr/bin/env python3
import os
import time
from tqdm import tqdm
import selfdrive.manager as manager
from cereal.messaging import PubMaster, recv_one, sub_sock
from tools.lib.framereader import FrameReader
import subprocess
import selfdrive.manager as manager
def rreplace(s, old, new, occurrence):
@ -22,7 +20,6 @@ def regen_model(msgs, pm, frame_reader, model_sock):
if msg.which() == 'liveCalibration':
pm.send('liveCalibration', msg.as_builder())
out_msgs = []
fidx = 0
for msg in tqdm(msgs):

View File

@ -1,7 +1,6 @@
#!/usr/bin/env python3
import os
import time
import cProfile
import pprofile
import pyprof2calltree

View File

@ -11,10 +11,10 @@ def setup_leon_fan():
for i in [0,1,2,3]:
print("FAN SPEED", i)
if i == 0:
ret = bus.write_i2c_block_data(0x67, 0xa, [0])
bus.write_i2c_block_data(0x67, 0xa, [0])
else:
ret = bus.write_i2c_block_data(0x67, 0xa, [0x20])
ret = bus.write_i2c_block_data(0x67, 0x8, [(i-1)<<6])
bus.write_i2c_block_data(0x67, 0xa, [0x20])
bus.write_i2c_block_data(0x67, 0x8, [(i-1)<<6])
time.sleep(1)
bus.close()

View File

@ -1,6 +1,4 @@
#!/usr/bin/env python3
import tempfile
import shutil
import subprocess
from common.basedir import BASEDIR
from azure.storage.blob import BlockBlobService
@ -8,8 +6,7 @@ from azure.storage.blob import BlockBlobService
from selfdrive.test.test_car_models import routes as test_car_models_routes
from selfdrive.test.process_replay.test_processes import segments as replay_segments
from xx.chffr.lib import azureutil
from xx.chffr.lib.storage import upload_dir_serial, download_dir_tpe
from xx.chffr.lib.storage import _DATA_ACCOUNT_PRODUCTION, _DATA_ACCOUNT_CI, _DATA_BUCKET_PRODUCTION, _DATA_BUCKET_CI
from xx.chffr.lib.storage import _DATA_ACCOUNT_PRODUCTION, _DATA_ACCOUNT_CI, _DATA_BUCKET_PRODUCTION
SOURCES = [
(_DATA_ACCOUNT_PRODUCTION, _DATA_BUCKET_PRODUCTION),

View File

@ -8,6 +8,7 @@ import tempfile
import threading
import xml.etree.ElementTree as ET
import numpy as np
import _io
if sys.version_info >= (3,0):
import queue
import pickle
@ -83,7 +84,7 @@ def ffprobe(fn, fmt=None):
try:
ffprobe_output = subprocess.check_output(cmd)
except subprocess.CalledProcessError as e:
except subprocess.CalledProcessError:
raise DataUnreadableError(fn)
return json.loads(ffprobe_output)
@ -99,7 +100,7 @@ def vidindex(fn, typ):
tempfile.NamedTemporaryFile() as index_f:
try:
subprocess.check_call([vidindex, typ, fn, prefix_f.name, index_f.name])
except subprocess.CalledProcessError as e:
except subprocess.CalledProcessError:
raise DataUnreadableError("vidindex failed on file %s" % fn)
with open(index_f.name, "rb") as f:
index = f.read()
@ -388,8 +389,6 @@ def index_pstream(fns, typ, cache_prefix=None):
assert frame_b >= 0
assert index[frame_b, 0] == H264_SLICE_I
end_len = len(index)-frame_b
with FileReader(fns[i]) as vid:
vid.seek(index[frame_b, 1])
end_data = vid.read()
@ -433,7 +432,7 @@ def _set_pdeathsig(sig=signal.SIGTERM):
def vidindex_mp4(fn):
try:
xmls = subprocess.check_output(["MP4Box", fn, "-diso", "-out", "/dev/stdout"])
except subprocess.CalledProcessError as e:
except subprocess.CalledProcessError:
raise DataUnreadableError(fn)
tree = ET.fromstring(xmls)

View File

@ -1,7 +1,6 @@
#!/usr/bin/env python
import sys
import random
import math
# Simple hacky Matroska generator
# Reads mp3 file "q.mp3" and jpeg images from img/0.jpg, img/1.jpg and so on and

View File

@ -8,6 +8,7 @@
# See "mkvuser.py" for the example
# pylint: skip-file
# flake8: noqa
import traceback
from struct import unpack

View File

@ -63,7 +63,6 @@ def ui_thread(addr, frame_address):
camera_surface = pygame.surface.Surface((640, 480), 0, 24).convert()
cameraw_surface = pygame.surface.Surface(MODEL_INPUT_SIZE, 0, 24).convert()
cameraw_test_surface = pygame.surface.Surface(MODEL_INPUT_SIZE, 0, 24)
top_down_surface = pygame.surface.Surface((UP.lidar_x, UP.lidar_y),0,8)
frame = messaging.sub_sock('frame', addr=addr, conflate=True)

View File

@ -79,7 +79,6 @@ def go(q):
threading.Thread(target=health_function).start()
threading.Thread(target=fake_driver_monitoring).start()
import carla # pylint: disable=import-error
client = carla.Client("127.0.0.1", 2000)
client.set_timeout(5.0)
world = client.load_world('Town04')

View File

@ -1,7 +1,8 @@
import time
import sys
import termios
from termios import *
import time
from termios import (BRKINT, VMIN, CS8, CSIZE, ECHO, ICANON, ICRNL, IEXTEN,
INPCK, ISIG, ISTRIP, IXON, PARENB, VTIME)
# Indexes for termios list.
IFLAG = 0
@ -58,4 +59,3 @@ if __name__ == '__main__':
p.start()
keyboard_poll_thread(q)

View File

@ -133,7 +133,7 @@ def wheel_poll_thread(q):
# Enable FF
import evdev # pylint: disable=import-error
from evdev import ecodes, InputDevice, ff # pylint: disable=import-error
from evdev import ecodes, InputDevice # pylint: disable=import-error
device = evdev.list_devices()[0]
evtdev = InputDevice(device)
val = 24000

View File

@ -40,12 +40,12 @@ def receiver_thread():
ctx = av.codec.codec.Codec('hevc', 'r').create()
ctx.decode(av.packet.Packet(start.decode("hex")))
import time
# import time
while 1:
t1 = time.time()
# t1 = time.time()
ts, raw = s.recv_multipart()
ts = struct.unpack('q', ts)[0] * 1000
t1, t2 = time.time(), t1
# t1, t2 = time.time(), t1
#print 'ms to get frame:', (t1-t2)*1000
pkt = av.packet.Packet(raw)
@ -53,14 +53,14 @@ def receiver_thread():
if not f:
continue
f = f[0]
t1, t2 = time.time(), t1
# t1, t2 = time.time(), t1
#print 'ms to decode:', (t1-t2)*1000
y_plane = np.frombuffer(f.planes[0], np.uint8).reshape((874, 1216))[:, 0:1164]
u_plane = np.frombuffer(f.planes[1], np.uint8).reshape((437, 608))[:, 0:582]
v_plane = np.frombuffer(f.planes[2], np.uint8).reshape((437, 608))[:, 0:582]
yuv_img = y_plane.tobytes() + u_plane.tobytes() + v_plane.tobytes()
t1, t2 = time.time(), t1
# t1, t2 = time.time(), t1
#print 'ms to make yuv:', (t1-t2)*1000
#print 'tsEof:', ts