Fix some Python errors and clean up unused imports.
This commit is contained in:
parent
c4597a7202
commit
9898b5d80a
11 changed files with 17 additions and 32 deletions
2
setup.py
2
setup.py
|
|
@ -12,7 +12,7 @@ setup(name='python-validity',
|
|||
],
|
||||
install_requires=[
|
||||
'cryptography >= 2.1.4',
|
||||
'pyusb >= 1.0.2'
|
||||
'pyusb >= 1.0.0'
|
||||
],
|
||||
data_files=[
|
||||
('share/dbus-1/system.d/', ['dbus_service/io.github.uunicorn.Fprint.conf']),
|
||||
|
|
|
|||
|
|
@ -1,10 +1,6 @@
|
|||
|
||||
import logging
|
||||
from .util import unhex
|
||||
from .tls import tls
|
||||
from .util import assert_status
|
||||
from struct import pack, unpack
|
||||
from binascii import hexlify, unhexlify
|
||||
from binascii import hexlify
|
||||
from .blobs import db_write_enable
|
||||
from .flash import call_cleanups
|
||||
from .sid import *
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
from .tls import tls
|
||||
from struct import pack, unpack
|
||||
from binascii import hexlify, unhexlify
|
||||
from .util import assert_status, unhex
|
||||
from .blobs import db_write_enable
|
||||
from .hw_tables import flash_ic_table_lookup
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
import atexit
|
||||
import signal
|
||||
import logging
|
||||
|
||||
from validitysensor.usb import usb
|
||||
|
|
|
|||
|
|
@ -3,9 +3,6 @@ from struct import pack, unpack
|
|||
import logging
|
||||
|
||||
from .db import db
|
||||
from .usb import usb
|
||||
from .tls import tls
|
||||
from .flash import read_flash
|
||||
|
||||
def machine_id_rec_value(b):
|
||||
b = b.encode('utf-16le')
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
import os
|
||||
from struct import pack, unpack
|
||||
from binascii import hexlify, unhexlify
|
||||
from binascii import unhexlify
|
||||
import logging
|
||||
|
||||
from hashlib import sha256
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import logging
|
|||
from usb import core as usb_core
|
||||
from .tls import tls
|
||||
from .usb import usb, CancelledException
|
||||
from .db import db, subtype_to_string
|
||||
from .db import db
|
||||
from .flash import write_enable, call_cleanups, read_flash, erase_flash, write_flash_all, read_flash_all
|
||||
from time import sleep
|
||||
from struct import pack, unpack
|
||||
|
|
@ -70,11 +70,12 @@ def factory_reset():
|
|||
reboot()
|
||||
|
||||
class RomInfo():
|
||||
def get():
|
||||
@classmethod
|
||||
def get(cls):
|
||||
rsp=tls.cmd(b'\x01')
|
||||
assert_status(rsp)
|
||||
rsp=rsp[2:]
|
||||
return RomInfo(*unpack('<LLBBxBxxxB', rsp[0:0x10]))
|
||||
return cls(*unpack('<LLBBxBxxxB', rsp[0:0x10]))
|
||||
|
||||
def __init__(self, timestamp, build, major, minor, product, u1):
|
||||
self.timestamp, self.build, self.major, self.minor, self.product, self.u1 = timestamp, build, major, minor, product, u1
|
||||
|
|
|
|||
|
|
@ -4,9 +4,10 @@ from binascii import hexlify, unhexlify
|
|||
class SensorTypeInfo:
|
||||
table=[]
|
||||
|
||||
def get_by_type(sensor_type):
|
||||
@classmethod
|
||||
def get_by_type(cls, sensor_type):
|
||||
from . import generated_tables
|
||||
for i in SensorTypeInfo.table:
|
||||
for i in cls.table:
|
||||
if i.sensor_type == sensor_type:
|
||||
return i
|
||||
|
||||
|
|
@ -46,7 +47,8 @@ def metric(i, rominfo):
|
|||
class SensorCaptureProg:
|
||||
table=[]
|
||||
|
||||
def get(rominfo, sensor_type, a0, a1):
|
||||
@classmethod
|
||||
def get(cls, rominfo, sensor_type, a0, a1):
|
||||
from . import generated_tables
|
||||
|
||||
maximum = 0
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import re
|
||||
import hmac
|
||||
import sys
|
||||
import os
|
||||
import pickle
|
||||
import logging
|
||||
|
|
@ -14,8 +12,8 @@ from cryptography.hazmat.primitives.asymmetric.utils import Prehashed
|
|||
from cryptography.hazmat.primitives import hashes
|
||||
from hashlib import sha256
|
||||
|
||||
from .usb import unhex, usb
|
||||
from .util import assert_status
|
||||
from .util import unhex
|
||||
from .usb import usb
|
||||
|
||||
|
||||
password_hardcoded=unhexlify('717cd72d0962bc4a2846138dbb2c24192512a76407065f383846139d4bec2033')
|
||||
|
|
@ -289,7 +287,7 @@ class Tls():
|
|||
|
||||
def handle_server_hello_done(self, p):
|
||||
if p != b'':
|
||||
raise Exeception('Not expecting any body for "server hello done" pkt: %s' % hexlify(p).decode())
|
||||
raise Exception('Not expecting any body for "server hello done" pkt: %s' % hexlify(p).decode())
|
||||
|
||||
def handle_finish(self, b):
|
||||
hs_hash = self.handshake_hash.copy().digest()
|
||||
|
|
|
|||
|
|
@ -1,14 +1,10 @@
|
|||
|
||||
from binascii import hexlify, unhexlify
|
||||
from time import ctime
|
||||
import logging
|
||||
from os.path import basename
|
||||
|
||||
from .tls import tls
|
||||
from .usb import usb
|
||||
from .sensor import reboot, write_hw_reg32, read_hw_reg32, identify_sensor
|
||||
from .flash import read_flash, erase_flash, write_flash_all, write_fw_signature, get_fw_info
|
||||
from .util import assert_status
|
||||
from .flash import write_flash_all, write_fw_signature, get_fw_info
|
||||
|
||||
firmware_home='/usr/share/python-validity'
|
||||
|
||||
|
|
|
|||
|
|
@ -3,10 +3,8 @@ import logging
|
|||
import errno
|
||||
import usb.core as ucore
|
||||
from binascii import *
|
||||
from .util import assert_status, unhex
|
||||
from .util import assert_status
|
||||
from struct import unpack
|
||||
from usb.util import claim_interface, release_interface
|
||||
from threading import Thread
|
||||
from usb.core import USBError
|
||||
from .blobs import init_hardcoded, init_hardcoded_clean_slate
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue