mirror of
https://github.com/infiniteCable2/panda.git
synced 2026-02-18 09:13:52 +08:00
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:
2
.github/workflows/test.yaml
vendored
2
.github/workflows/test.yaml
vendored
@@ -12,6 +12,8 @@ env:
|
|||||||
export DOCKER_BUILDKIT=1
|
export DOCKER_BUILDKIT=1
|
||||||
docker build --pull --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from ghcr.io/commaai/panda:latest -t panda -f Dockerfile .
|
docker build --pull --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from ghcr.io/commaai/panda:latest -t panda -f Dockerfile .
|
||||||
|
|
||||||
|
PYTHONWARNINGS: "error"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docker_push:
|
docker_push:
|
||||||
name: docker push
|
name: docker push
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ RUN cd /tmp/openpilot && \
|
|||||||
git clone https://github.com/commaai/panda_jungle.git && \
|
git clone https://github.com/commaai/panda_jungle.git && \
|
||||||
cd panda_jungle && \
|
cd panda_jungle && \
|
||||||
git fetch && \
|
git fetch && \
|
||||||
git checkout 7b7197c605915ac34f3d62f314edd84e2e78a759 && \
|
git checkout 3a791be1f1877a69cf45de16a670992380622297 && \
|
||||||
rm -rf .git/
|
rm -rf .git/
|
||||||
|
|
||||||
RUN cd /tmp/openpilot && \
|
RUN cd /tmp/openpilot && \
|
||||||
|
|||||||
3
Jenkinsfile
vendored
3
Jenkinsfile
vendored
@@ -2,6 +2,7 @@ def docker_run(String step_label, int timeout_mins, String cmd) {
|
|||||||
timeout(time: timeout_mins, unit: 'MINUTES') {
|
timeout(time: timeout_mins, unit: 'MINUTES') {
|
||||||
sh script: "docker run --rm --privileged \
|
sh script: "docker run --rm --privileged \
|
||||||
--env PARTIAL_TESTS=${env.PARTIAL_TESTS} \
|
--env PARTIAL_TESTS=${env.PARTIAL_TESTS} \
|
||||||
|
--env PYTHONWARNINGS=error \
|
||||||
--volume /dev/bus/usb:/dev/bus/usb \
|
--volume /dev/bus/usb:/dev/bus/usb \
|
||||||
--volume /var/run/dbus:/var/run/dbus \
|
--volume /var/run/dbus:/var/run/dbus \
|
||||||
--workdir /tmp/openpilot/panda \
|
--workdir /tmp/openpilot/panda \
|
||||||
@@ -32,6 +33,7 @@ export SOURCE_DIR=${env.SOURCE_DIR}
|
|||||||
export GIT_BRANCH=${env.GIT_BRANCH}
|
export GIT_BRANCH=${env.GIT_BRANCH}
|
||||||
export GIT_COMMIT=${env.GIT_COMMIT}
|
export GIT_COMMIT=${env.GIT_COMMIT}
|
||||||
export PYTHONPATH=${env.TEST_DIR}/../
|
export PYTHONPATH=${env.TEST_DIR}/../
|
||||||
|
export PYTHONWARNINGS=error
|
||||||
|
|
||||||
cd ${env.TEST_DIR} || true
|
cd ${env.TEST_DIR} || true
|
||||||
${cmd}
|
${cmd}
|
||||||
@@ -61,6 +63,7 @@ pipeline {
|
|||||||
environment {
|
environment {
|
||||||
CI = "1"
|
CI = "1"
|
||||||
PARTIAL_TESTS = "${env.BRANCH_NAME == 'master' ? ' ' : '1'}"
|
PARTIAL_TESTS = "${env.BRANCH_NAME == 'master' ? ' ' : '1'}"
|
||||||
|
PYTHONWARNINGS= "error"
|
||||||
DOCKER_IMAGE_TAG = "panda:build-${env.GIT_COMMIT}"
|
DOCKER_IMAGE_TAG = "panda:build-${env.GIT_COMMIT}"
|
||||||
|
|
||||||
TEST_DIR = "/data/panda"
|
TEST_DIR = "/data/panda"
|
||||||
|
|||||||
@@ -102,7 +102,8 @@ def get_key_header(name):
|
|||||||
from Crypto.PublicKey import RSA
|
from Crypto.PublicKey import RSA
|
||||||
|
|
||||||
public_fn = File(f'../certs/{name}.pub').srcnode().abspath
|
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)
|
assert(rsa.size_in_bits() == 1024)
|
||||||
|
|
||||||
rr = pow(2**1024, 2, rsa.n)
|
rr = pow(2**1024, 2, rsa.n)
|
||||||
|
|||||||
@@ -9,28 +9,30 @@ import binascii
|
|||||||
# increment this to make new hardware not run old versions
|
# increment this to make new hardware not run old versions
|
||||||
VERSION = 2
|
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:
|
with open(sys.argv[1], "rb") as f:
|
||||||
dat = f.read()
|
dat = f.read()
|
||||||
|
|
||||||
print("signing", len(dat), "bytes")
|
print("signing", len(dat), "bytes")
|
||||||
|
|
||||||
with open(sys.argv[2], "wb") as f:
|
with open(sys.argv[2], "wb") as f:
|
||||||
if os.getenv("SETLEN") is not None:
|
if os.getenv("SETLEN") is not None:
|
||||||
# add the version at the end
|
# add the version at the end
|
||||||
dat += b"VERS" + struct.pack("I", VERSION)
|
dat += b"VERS" + struct.pack("I", VERSION)
|
||||||
# add the length at the beginning
|
# add the length at the beginning
|
||||||
x = struct.pack("I", len(dat)) + dat[4:]
|
x = struct.pack("I", len(dat)) + dat[4:]
|
||||||
# mock signature of dat[4:]
|
# mock signature of dat[4:]
|
||||||
dd = hashlib.sha1(dat[4:]).digest()
|
dd = hashlib.sha1(dat[4:]).digest()
|
||||||
else:
|
else:
|
||||||
x = dat
|
x = dat
|
||||||
dd = hashlib.sha1(dat).digest()
|
dd = hashlib.sha1(dat).digest()
|
||||||
|
|
||||||
print("hash:", str(binascii.hexlify(dd), "utf-8"))
|
print("hash:", str(binascii.hexlify(dd), "utf-8"))
|
||||||
dd = b"\x00\x01" + b"\xff" * 0x69 + b"\x00" + dd
|
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)
|
rsa_out = pow(int.from_bytes(dd, byteorder='big', signed=False), rsa.d, rsa.n)
|
||||||
sig = (hex(rsa_out)[2:].rjust(0x100, '0'))
|
sig = (hex(rsa_out)[2:].rjust(0x100, '0'))
|
||||||
x += binascii.unhexlify(sig)
|
x += binascii.unhexlify(sig)
|
||||||
f.write(x)
|
f.write(x)
|
||||||
|
|||||||
@@ -612,9 +612,9 @@ class Panda:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_signature_from_firmware(fn) -> bytes:
|
def get_signature_from_firmware(fn) -> bytes:
|
||||||
f = open(fn, 'rb')
|
with open(fn, 'rb') as f:
|
||||||
f.seek(-128, 2) # Seek from end of file
|
f.seek(-128, 2) # Seek from end of file
|
||||||
return f.read(128)
|
return f.read(128)
|
||||||
|
|
||||||
def get_signature(self) -> bytes:
|
def get_signature(self) -> bytes:
|
||||||
part_1 = self._handle.controlRead(Panda.REQUEST_IN, 0xd3, 0, 0, 0x40)
|
part_1 = self._handle.controlRead(Panda.REQUEST_IN, 0xd3, 0, 0, 0x40)
|
||||||
|
|||||||
@@ -9,31 +9,25 @@ class Resetter():
|
|||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self._handle.close()
|
self._handle.close()
|
||||||
|
self._context.close()
|
||||||
self._handle = None
|
self._handle = None
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
if self._handle:
|
if self._handle:
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
context = usb1.USBContext()
|
|
||||||
self._handle = None
|
self._handle = None
|
||||||
|
|
||||||
while True:
|
self._context = usb1.USBContext()
|
||||||
try:
|
self._context.open()
|
||||||
for device in context.getDeviceList(skip_on_error=True):
|
for device in self._context.getDeviceList(skip_on_error=True):
|
||||||
if device.getVendorID() == 0xbbaa and device.getProductID() == 0xddc0:
|
if device.getVendorID() == 0xbbaa and device.getProductID() == 0xddc0:
|
||||||
try:
|
try:
|
||||||
self._handle = device.open()
|
self._handle = device.open()
|
||||||
self._handle.claimInterface(0)
|
self._handle.claimInterface(0)
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
continue
|
|
||||||
except Exception as e:
|
|
||||||
print(e)
|
|
||||||
if self._handle:
|
|
||||||
break
|
|
||||||
context = usb1.USBContext()
|
|
||||||
assert self._handle
|
assert self._handle
|
||||||
|
|
||||||
def enable_power(self, port, enabled):
|
def enable_power(self, port, enabled):
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|||||||
Reference in New Issue
Block a user