tls_example: Fix python lint errors
Change-Id: Ie90b4423a53c0e7f84f954d7c7cda3a47e0853d9
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/experimental/+/39826
Commit-Queue: Anthony DiGirolamo <tonymd@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index fd0d4ec..cf9239f 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -64,6 +64,7 @@
# This depends on the 'tools' target in //tools/BUILD.gn
python_deps = [
"tools",
+ "//applications/tls_example/trust_store/py",
"//pw_console/py",
"//third_party/pigweed/pw_env_setup:python",
"//third_party/pigweed/pw_env_setup:target_support_packages",
diff --git a/applications/tls_example/time_injection/generate_time_code.py b/applications/tls_example/time_injection/generate_time_code.py
index 3c1f232..85094fe 100644
--- a/applications/tls_example/time_injection/generate_time_code.py
+++ b/applications/tls_example/time_injection/generate_time_code.py
@@ -28,9 +28,7 @@
inject specified time: genearte_time_code <output> -t "03/29/2021 12:00:00"
inject current time: genearte_time_code <output>
"""
-import datetime
from datetime import datetime
-import time
import argparse
import subprocess
@@ -66,6 +64,7 @@
def parse_args():
+ """Setup argparse."""
parser = argparse.ArgumentParser()
parser.add_argument("out", help="path for output header file")
parser.add_argument("--time", "-t", help="time to inject")
@@ -93,4 +92,4 @@
"clang-format",
"-i",
args.out,
- ])
+ ], check=True)
diff --git a/applications/tls_example/trust_store/py/trust_store_generation/generate_trust_store.py b/applications/tls_example/trust_store/py/trust_store_generation/generate_trust_store.py
index b94a5ac..c96a718 100644
--- a/applications/tls_example/trust_store/py/trust_store_generation/generate_trust_store.py
+++ b/applications/tls_example/trust_store/py/trust_store_generation/generate_trust_store.py
@@ -13,8 +13,8 @@
# the License.
"""Trusts tore synthesis
-The script generates source code for implementing built-in certificates. The code
-template is:
+The script generates source code for implementing built-in certificates. The
+code template is:
namespace {
const unsigned char kRootCACert_0[] = {...};
@@ -41,10 +41,9 @@
"""
import argparse
-import os
import subprocess
import sys
-from OpenSSL import crypto
+from OpenSSL import crypto # type: ignore
LICENSE_HEADER = """// Copyright 2021 The Pigweed Authors
//
@@ -70,6 +69,7 @@
def parse_args():
+ """Setup argparse."""
parser = argparse.ArgumentParser()
parser.add_argument("out", help="output header")
parser.add_argument("--root_cert",
@@ -99,11 +99,15 @@
def generate_der_c_array_for_cert(file, var_name):
+ """Load cert file and return a generated c array declaration."""
+
data = load_certificate_file(file)
return generate_c_array_declaration(data, var_name)
def main():
+ """Generate Trust Store Main."""
+
args = parse_args()
print(args)
with open(args.out, "w") as header:
@@ -136,7 +140,7 @@
"clang-format",
"-i",
args.out,
- ])
+ ], check=True)
if __name__ == "__main__":