Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
sosthene-nitrokey committed Aug 16, 2023
1 parent 00de18b commit dab5dc6
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions pynitrokey/cli/nk3/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
from enum import Enum, auto, unique
from hashlib import sha256
from struct import unpack
from threading import Thread
from types import TracebackType
from typing import Any, Callable, Iterable, Optional, Tuple, Type, Union
from threading import Thread

from tqdm import tqdm

from pynitrokey.cli.exceptions import CliException
Expand Down Expand Up @@ -361,26 +362,29 @@ def test_se050(ctx: TestContext, device: Nitrokey3Base) -> TestResult:
return TestResult(TestStatus.SKIPPED)

result = None

def internal_se050_run():
result = AdminApp(device).se050_tests()
print(result)

t = Thread(target = internal_se050_run)
t = Thread(target=internal_se050_run)
t.start()
bar = tqdm(desc="Running SE050 test", unit="%", bar_format="{l_bar}{bar}", total=900)
bar = tqdm(
desc="Running SE050 test", unit="%", bar_format="{l_bar}{bar}", total=900
)
# 1m30 in increments of 0.1 second
for i in range(900):
t.join(0.1)
bar.update(1)
if not t.is_alive():
break
if i == 900-1:
if i == 900 - 1:
bar.close()
return TestResult(
return TestResult(
TestStatus.FAILURE,
f"Test timed out after 1m30",
)

bar.close()

if result is None or len(result) < 11:
Expand All @@ -401,8 +405,8 @@ def internal_se050_run():
for b in result[11:]:
i += 1
if i != b:
index = SE050_STEPS[i-1] if i < max else hex(i)
return TestResult(
index = SE050_STEPS[i - 1] if i < max else hex(i)
return TestResult(
TestStatus.FAILURE,
f"Failed at {index}, got {result[10+i:].hex()} of {result.hex()}",
)
Expand Down

0 comments on commit dab5dc6

Please sign in to comment.