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=[
|
install_requires=[
|
||||||
'cryptography >= 2.1.4',
|
'cryptography >= 2.1.4',
|
||||||
'pyusb >= 1.0.2'
|
'pyusb >= 1.0.0'
|
||||||
],
|
],
|
||||||
data_files=[
|
data_files=[
|
||||||
('share/dbus-1/system.d/', ['dbus_service/io.github.uunicorn.Fprint.conf']),
|
('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 .tls import tls
|
||||||
from .util import assert_status
|
from .util import assert_status
|
||||||
from struct import pack, unpack
|
from binascii import hexlify
|
||||||
from binascii import hexlify, unhexlify
|
|
||||||
from .blobs import db_write_enable
|
from .blobs import db_write_enable
|
||||||
from .flash import call_cleanups
|
from .flash import call_cleanups
|
||||||
from .sid import *
|
from .sid import *
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
from .tls import tls
|
from .tls import tls
|
||||||
from struct import pack, unpack
|
from struct import pack, unpack
|
||||||
from binascii import hexlify, unhexlify
|
|
||||||
from .util import assert_status, unhex
|
from .util import assert_status, unhex
|
||||||
from .blobs import db_write_enable
|
from .blobs import db_write_enable
|
||||||
from .hw_tables import flash_ic_table_lookup
|
from .hw_tables import flash_ic_table_lookup
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
|
|
||||||
import atexit
|
import atexit
|
||||||
import signal
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from validitysensor.usb import usb
|
from validitysensor.usb import usb
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,6 @@ from struct import pack, unpack
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from .db import db
|
from .db import db
|
||||||
from .usb import usb
|
|
||||||
from .tls import tls
|
|
||||||
from .flash import read_flash
|
|
||||||
|
|
||||||
def machine_id_rec_value(b):
|
def machine_id_rec_value(b):
|
||||||
b = b.encode('utf-16le')
|
b = b.encode('utf-16le')
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from struct import pack, unpack
|
from struct import pack, unpack
|
||||||
from binascii import hexlify, unhexlify
|
from binascii import unhexlify
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from hashlib import sha256
|
from hashlib import sha256
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import logging
|
||||||
from usb import core as usb_core
|
from usb import core as usb_core
|
||||||
from .tls import tls
|
from .tls import tls
|
||||||
from .usb import usb, CancelledException
|
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 .flash import write_enable, call_cleanups, read_flash, erase_flash, write_flash_all, read_flash_all
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from struct import pack, unpack
|
from struct import pack, unpack
|
||||||
|
|
@ -70,11 +70,12 @@ def factory_reset():
|
||||||
reboot()
|
reboot()
|
||||||
|
|
||||||
class RomInfo():
|
class RomInfo():
|
||||||
def get():
|
@classmethod
|
||||||
|
def get(cls):
|
||||||
rsp=tls.cmd(b'\x01')
|
rsp=tls.cmd(b'\x01')
|
||||||
assert_status(rsp)
|
assert_status(rsp)
|
||||||
rsp=rsp[2:]
|
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):
|
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
|
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:
|
class SensorTypeInfo:
|
||||||
table=[]
|
table=[]
|
||||||
|
|
||||||
def get_by_type(sensor_type):
|
@classmethod
|
||||||
|
def get_by_type(cls, sensor_type):
|
||||||
from . import generated_tables
|
from . import generated_tables
|
||||||
for i in SensorTypeInfo.table:
|
for i in cls.table:
|
||||||
if i.sensor_type == sensor_type:
|
if i.sensor_type == sensor_type:
|
||||||
return i
|
return i
|
||||||
|
|
||||||
|
|
@ -46,7 +47,8 @@ def metric(i, rominfo):
|
||||||
class SensorCaptureProg:
|
class SensorCaptureProg:
|
||||||
table=[]
|
table=[]
|
||||||
|
|
||||||
def get(rominfo, sensor_type, a0, a1):
|
@classmethod
|
||||||
|
def get(cls, rominfo, sensor_type, a0, a1):
|
||||||
from . import generated_tables
|
from . import generated_tables
|
||||||
|
|
||||||
maximum = 0
|
maximum = 0
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
import re
|
|
||||||
import hmac
|
import hmac
|
||||||
import sys
|
|
||||||
import os
|
import os
|
||||||
import pickle
|
import pickle
|
||||||
import logging
|
import logging
|
||||||
|
|
@ -14,8 +12,8 @@ from cryptography.hazmat.primitives.asymmetric.utils import Prehashed
|
||||||
from cryptography.hazmat.primitives import hashes
|
from cryptography.hazmat.primitives import hashes
|
||||||
from hashlib import sha256
|
from hashlib import sha256
|
||||||
|
|
||||||
from .usb import unhex, usb
|
from .util import unhex
|
||||||
from .util import assert_status
|
from .usb import usb
|
||||||
|
|
||||||
|
|
||||||
password_hardcoded=unhexlify('717cd72d0962bc4a2846138dbb2c24192512a76407065f383846139d4bec2033')
|
password_hardcoded=unhexlify('717cd72d0962bc4a2846138dbb2c24192512a76407065f383846139d4bec2033')
|
||||||
|
|
@ -289,7 +287,7 @@ class Tls():
|
||||||
|
|
||||||
def handle_server_hello_done(self, p):
|
def handle_server_hello_done(self, p):
|
||||||
if p != b'':
|
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):
|
def handle_finish(self, b):
|
||||||
hs_hash = self.handshake_hash.copy().digest()
|
hs_hash = self.handshake_hash.copy().digest()
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,10 @@
|
||||||
|
|
||||||
from binascii import hexlify, unhexlify
|
|
||||||
from time import ctime
|
from time import ctime
|
||||||
import logging
|
import logging
|
||||||
from os.path import basename
|
from os.path import basename
|
||||||
|
|
||||||
from .tls import tls
|
|
||||||
from .usb import usb
|
from .usb import usb
|
||||||
from .sensor import reboot, write_hw_reg32, read_hw_reg32, identify_sensor
|
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 .flash import write_flash_all, write_fw_signature, get_fw_info
|
||||||
from .util import assert_status
|
|
||||||
|
|
||||||
firmware_home='/usr/share/python-validity'
|
firmware_home='/usr/share/python-validity'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,8 @@ import logging
|
||||||
import errno
|
import errno
|
||||||
import usb.core as ucore
|
import usb.core as ucore
|
||||||
from binascii import *
|
from binascii import *
|
||||||
from .util import assert_status, unhex
|
from .util import assert_status
|
||||||
from struct import unpack
|
from struct import unpack
|
||||||
from usb.util import claim_interface, release_interface
|
|
||||||
from threading import Thread
|
|
||||||
from usb.core import USBError
|
from usb.core import USBError
|
||||||
from .blobs import init_hardcoded, init_hardcoded_clean_slate
|
from .blobs import init_hardcoded, init_hardcoded_clean_slate
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue