Made shlex.join use optional

Introduced in Python 3.8
This commit is contained in:
Salvador E. Tropea 2023-08-08 11:19:47 -03:00
parent 50782078d0
commit 67ae12bf1d
8 changed files with 10 additions and 15 deletions

View File

@ -14,6 +14,7 @@ except ImportError:
IU_PER_MM = 1
IU_PER_MILS = 1
from datetime import datetime
import shlex
from shutil import copy2
from sys import exit, exc_info
from traceback import extract_stack, format_list, print_tb
@ -189,6 +190,7 @@ class GS(object):
global_kicad_dnp_applied = None
global_kicad_dnp_applies_to_3D = None
global_cross_using_kicad = None
pasteable_cmd = shlex.join if hasattr(shlex, 'join') else lambda x: str(x) # novermin
@staticmethod
def set_sch(name):

View File

@ -14,7 +14,6 @@ import os
import re
from sys import exit
from sys import path as sys_path
import shlex
from shutil import which, copy2
from subprocess import run, PIPE, STDOUT, Popen, CalledProcessError
from glob import glob
@ -154,7 +153,7 @@ def _run_command(command, change_to):
def run_command(command, change_to=None, just_raise=False, use_x11=False):
logger.debug('Executing: '+shlex.join(command))
logger.debug('Executing: '+GS.pasteable_cmd(command))
if change_to is not None:
logger.debug('- CWD: '+change_to)
try:
@ -176,7 +175,7 @@ def run_command(command, change_to=None, just_raise=False, use_x11=False):
def exec_with_retry(cmd, exit_with=None):
cmd_str = shlex.join(cmd)
cmd_str = GS.pasteable_cmd(cmd)
logger.debug('Executing: '+cmd_str)
if GS.debug_level > 2:
logger.debug('Command line: '+str(cmd))

View File

@ -21,7 +21,6 @@ Dependencies:
import os
import subprocess
import pprint
import shlex
from shutil import copy2
from math import ceil
from struct import unpack
@ -144,7 +143,7 @@ a:hover, a:active { text-decoration: underline;}
def _run_command(cmd):
logger.debug('- Executing: '+shlex.join(cmd))
logger.debug('- Executing: '+GS.pasteable_cmd(cmd))
try:
cmd_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:

View File

@ -34,7 +34,6 @@ import os
import subprocess
import importlib
from pcbnew import B_Cu, B_Mask, F_Cu, F_Mask, FromMM, IsCopperLayer, LSET, PLOT_CONTROLLER, PLOT_FORMAT_SVG
import shlex
from shutil import rmtree
from tempfile import NamedTemporaryFile, mkdtemp
from .error import KiPlotConfigurationError
@ -73,7 +72,7 @@ def pcbdraw_warnings(tag, msg):
def _run_command(cmd):
logger.debug('- Executing: '+shlex.join(cmd))
logger.debug('- Executing: '+GS.pasteable_cmd(cmd))
try:
cmd_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:

View File

@ -19,7 +19,6 @@ Dependencies:
role: Automatically adjust SVG margin
"""
import os
import shlex
import subprocess
from tempfile import NamedTemporaryFile
# Here we import the whole module to make monkeypatch work
@ -52,7 +51,7 @@ def _get_tmp_name(ext):
def _run_command(cmd):
logger.debug('Executing: '+shlex.join(cmd))
logger.debug('Executing: '+GS.pasteable_cmd(cmd))
try:
cmd_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:

View File

@ -13,7 +13,6 @@ Dependencies:
role: Automatically crop images
"""
import os
import shlex
import subprocess
from .misc import (RENDER_3D_ERR, PCB_MAT_COLORS, PCB_FINISH_COLORS, SOLDER_COLORS, SILK_COLORS,
KICAD_VERSION_6_0_2, MISSING_TOOL)
@ -26,7 +25,7 @@ logger = log.get_logger()
def _run_command(cmd):
logger.debug('- Executing: '+shlex.join(cmd))
logger.debug('- Executing: '+GS.pasteable_cmd(cmd))
try:
cmd_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:

View File

@ -18,7 +18,6 @@ Dependencies:
import os
import re
import pcbnew
import shlex
from subprocess import check_output, STDOUT, CalledProcessError
from .gs import GS
@ -851,7 +850,7 @@ class ReportOptions(BaseOptions):
if not out.endswith('.'+self.convert_to):
logger.warning(W_WRONGEXT+'The conversion tool detects the output format using the extension')
cmd = [command, '--from', self.convert_from, resources, fname, '-o', out]
logger.debug('Executing: '+shlex.join(cmd))
logger.debug('Executing: '+GS.pasteable_cmd(cmd))
try:
check_output(cmd, stderr=STDOUT)
except CalledProcessError as e:

View File

@ -13,7 +13,6 @@ Dependencies:
import json
import os
import re
import shlex
from subprocess import run, PIPE
import sys
from .error import KiPlotConfigurationError
@ -132,7 +131,7 @@ class Set_Text_Variables(BasePreFlight): # noqa: F821
if not bash_command:
bash_command = self.ensure_tool('Bash')
cmd = [bash_command, '-c', command]
logger.debug('Executing: '+shlex.join(command))
logger.debug('Executing: '+GS.pasteable_cmd(command))
result = run(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
if result.returncode:
logger.error('Failed to execute:\n{}\nreturn code {}'.format(r.command, result.returncode))