CI: set PYTHONWARNINGS=error (#1323)

* CI: set PYTHONWARNINGS=error

* update resetter

* fix build warnings

* bump jungle

* fix one more

* fix linter

---------

Co-authored-by: Bruce Wayne <batman@comma.ai>
This commit is contained in:
Adeeb Shihadeh 2023-04-02 09:33:35 -07:00 committed by GitHub
parent 3e89b7127a
commit b6c378ad02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 46 additions and 43 deletions

View File

@ -12,6 +12,8 @@ env:
export DOCKER_BUILDKIT=1
docker build --pull --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from ghcr.io/commaai/panda:latest -t panda -f Dockerfile .
PYTHONWARNINGS: "error"
jobs:
docker_push:
name: docker push

View File

@ -83,7 +83,7 @@ RUN cd /tmp/openpilot && \
git clone https://github.com/commaai/panda_jungle.git && \
cd panda_jungle && \
git fetch && \
git checkout 7b7197c605915ac34f3d62f314edd84e2e78a759 && \
git checkout 3a791be1f1877a69cf45de16a670992380622297 && \
rm -rf .git/
RUN cd /tmp/openpilot && \

3
Jenkinsfile vendored
View File

@ -2,6 +2,7 @@ def docker_run(String step_label, int timeout_mins, String cmd) {
timeout(time: timeout_mins, unit: 'MINUTES') {
sh script: "docker run --rm --privileged \
--env PARTIAL_TESTS=${env.PARTIAL_TESTS} \
--env PYTHONWARNINGS=error \
--volume /dev/bus/usb:/dev/bus/usb \
--volume /var/run/dbus:/var/run/dbus \
--workdir /tmp/openpilot/panda \
@ -32,6 +33,7 @@ export SOURCE_DIR=${env.SOURCE_DIR}
export GIT_BRANCH=${env.GIT_BRANCH}
export GIT_COMMIT=${env.GIT_COMMIT}
export PYTHONPATH=${env.TEST_DIR}/../
export PYTHONWARNINGS=error
cd ${env.TEST_DIR} || true
${cmd}
@ -61,6 +63,7 @@ pipeline {
environment {
CI = "1"
PARTIAL_TESTS = "${env.BRANCH_NAME == 'master' ? ' ' : '1'}"
PYTHONWARNINGS= "error"
DOCKER_IMAGE_TAG = "panda:build-${env.GIT_COMMIT}"
TEST_DIR = "/data/panda"

View File

@ -102,7 +102,8 @@ def get_key_header(name):
from Crypto.PublicKey import RSA
public_fn = File(f'../certs/{name}.pub').srcnode().abspath
rsa = RSA.importKey(open(public_fn).read())
with open(public_fn) as f:
rsa = RSA.importKey(f.read())
assert(rsa.size_in_bits() == 1024)
rr = pow(2**1024, 2, rsa.n)

View File

@ -9,28 +9,30 @@ import binascii
# increment this to make new hardware not run old versions
VERSION = 2
rsa = RSA.importKey(open(sys.argv[3]).read())
if __name__ == "__main__":
with open(sys.argv[3]) as k:
rsa = RSA.importKey(k.read())
with open(sys.argv[1], "rb") as f:
dat = f.read()
with open(sys.argv[1], "rb") as f:
dat = f.read()
print("signing", len(dat), "bytes")
print("signing", len(dat), "bytes")
with open(sys.argv[2], "wb") as f:
if os.getenv("SETLEN") is not None:
# add the version at the end
dat += b"VERS" + struct.pack("I", VERSION)
# add the length at the beginning
x = struct.pack("I", len(dat)) + dat[4:]
# mock signature of dat[4:]
dd = hashlib.sha1(dat[4:]).digest()
else:
x = dat
dd = hashlib.sha1(dat).digest()
with open(sys.argv[2], "wb") as f:
if os.getenv("SETLEN") is not None:
# add the version at the end
dat += b"VERS" + struct.pack("I", VERSION)
# add the length at the beginning
x = struct.pack("I", len(dat)) + dat[4:]
# mock signature of dat[4:]
dd = hashlib.sha1(dat[4:]).digest()
else:
x = dat
dd = hashlib.sha1(dat).digest()
print("hash:", str(binascii.hexlify(dd), "utf-8"))
dd = b"\x00\x01" + b"\xff" * 0x69 + b"\x00" + dd
rsa_out = pow(int.from_bytes(dd, byteorder='big', signed=False), rsa.d, rsa.n)
sig = (hex(rsa_out)[2:].rjust(0x100, '0'))
x += binascii.unhexlify(sig)
f.write(x)
print("hash:", str(binascii.hexlify(dd), "utf-8"))
dd = b"\x00\x01" + b"\xff" * 0x69 + b"\x00" + dd
rsa_out = pow(int.from_bytes(dd, byteorder='big', signed=False), rsa.d, rsa.n)
sig = (hex(rsa_out)[2:].rjust(0x100, '0'))
x += binascii.unhexlify(sig)
f.write(x)

View File

@ -612,9 +612,9 @@ class Panda:
@staticmethod
def get_signature_from_firmware(fn) -> bytes:
f = open(fn, 'rb')
f.seek(-128, 2) # Seek from end of file
return f.read(128)
with open(fn, 'rb') as f:
f.seek(-128, 2) # Seek from end of file
return f.read(128)
def get_signature(self) -> bytes:
part_1 = self._handle.controlRead(Panda.REQUEST_IN, 0xd3, 0, 0, 0x40)

View File

@ -9,31 +9,25 @@ class Resetter():
def close(self):
self._handle.close()
self._context.close()
self._handle = None
def connect(self):
if self._handle:
self.close()
context = usb1.USBContext()
self._handle = None
while True:
try:
for device in context.getDeviceList(skip_on_error=True):
if device.getVendorID() == 0xbbaa and device.getProductID() == 0xddc0:
try:
self._handle = device.open()
self._handle.claimInterface(0)
break
except Exception as e:
print(e)
continue
except Exception as e:
print(e)
if self._handle:
break
context = usb1.USBContext()
self._context = usb1.USBContext()
self._context.open()
for device in self._context.getDeviceList(skip_on_error=True):
if device.getVendorID() == 0xbbaa and device.getProductID() == 0xddc0:
try:
self._handle = device.open()
self._handle.claimInterface(0)
break
except Exception as e:
print(e)
assert self._handle
def enable_power(self, port, enabled):

View File

@ -1,3 +1,4 @@
#!/usr/bin/env python3
import os
import time
import subprocess