Skip to content

Commit

Permalink
Use shlex for joining command arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
arkq committed Jan 10, 2025
1 parent 49dee9a commit 82fd985
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions scripts/tools/bouffalolab/generate_factory_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import os
import random
import secrets
import shlex
import subprocess
import sys
from datetime import datetime, timedelta
Expand Down Expand Up @@ -185,7 +186,7 @@ def verify_certificates(chip_cert, paa_cert, pai_cert, dac_cert):
"--pai", pai_cert,
"--paa", paa_cert,
]
log.info("Verify Certificate Chain: {}".format(" ".join(cmd)))
log.info("Verify Certificate Chain: {}".format(shlex.join(cmd)))
subprocess.run(cmd)

def gen_dac_certificate(chip_cert, device_name, vendor_id, product_id, pai_cert, pai_key, dac_cert, dac_key, pai_issue_date, pai_expire_date):
Expand Down Expand Up @@ -214,7 +215,7 @@ def gen_valid_times(issue_date, expire_date):
"--valid-from", valid_from,
"--lifetime", str(lifetime),
]
log.info("Generate DAC: {}".format(" ".join(cmd)))
log.info("Generate DAC: {}".format(shlex.join(cmd)))
subprocess.run(cmd)

def convert_pem_to_der(chip_cert, action, pem):
Expand Down Expand Up @@ -254,7 +255,7 @@ def gen_cd(chip_cert, dac_vendor_id, dac_product_id, vendor_id, product_id, cd_c
"--dac-origin-product-id", hex(dac_product_id),
]

log.info("Generate CD: {}".format(" ".join(cmd)))
log.info("Generate CD: {}".format(shlex.join(cmd)))
subprocess.run(cmd)

pai_vendor_id, pai_product_id, pai_issue_date, pai_expire_date = parse_cert_file(pai_cert)
Expand Down
3 changes: 2 additions & 1 deletion scripts/tools/zap_regen_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import multiprocessing
import os
import os.path
import shlex
import shutil
import subprocess
import sys
Expand Down Expand Up @@ -209,7 +210,7 @@ def generate(self) -> TargetRunStats:
"""Runs a ZAP generate command on the configured zap/template/outputs.
"""
cmd = self.build_cmd()
logging.info("Generating target: %s" % " ".join(cmd))
logging.info("Generating target: %s" % shlex.join(cmd))

generate_start = time.time()
subprocess.check_call(cmd)
Expand Down
3 changes: 2 additions & 1 deletion third_party/tizen/tizen_dev_certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import argparse
import logging
import os
import shlex
import subprocess
import sys

Expand All @@ -29,7 +30,7 @@


def run(cmd):
logging.debug("Run: %s", " ".join(cmd))
logging.debug("Run: %s", shlex.join(cmd))
proc = subprocess.Popen(cmd, errors='replace',
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
Expand Down

0 comments on commit 82fd985

Please sign in to comment.