Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Try removing shell=True from the python calls on Windows

Dmitry Kazakov1df1146d6e62
diff --git a/build-tools/ci-scripts/build-windows-package.py b/build-tools/ci-scripts/build-windows-package.py
index 51db1dbe93..1bacd45bba 100644
--- a/build-tools/ci-scripts/build-windows-package.py
+++ b/build-tools/ci-scripts/build-windows-package.py
@@ -73,7 +73,7 @@ commandToRun = ' '.join([sys.executable,
# Run the command
try:
print( "## RUNNING: " + commandToRun )
- subprocess.check_call( commandToRun, stdout=sys.stdout, stderr=sys.stderr, shell=True )
+ subprocess.check_call(commandToRun)
except Exception:
print("## Failed to build zip package")
sys.exit(1)
@@ -96,8 +96,7 @@ if arguments.build_installers:
# Run the command
try:
print( "## RUNNING: " + commandToRun )
- subprocess.check_call( commandToRun, stdout=sys.stdout, stderr=sys.stderr, shell=True,
- cwd=installerFolder )
+ subprocess.check_call(commandToRun, cwd=installerFolder)
except Exception:
print("## Failed to build the installer")
sys.exit(1)
@@ -114,7 +113,7 @@ if arguments.build_installers:
# Run the command
try:
print( "## RUNNING: " + commandToRun )
- subprocess.check_call( commandToRun, stdout=sys.stdout, stderr=sys.stderr, shell=True )
+ subprocess.check_call(commandToRun)
except Exception:
print("## Failed to sign the installer")
sys.exit(1)
@@ -126,7 +125,7 @@ if arguments.build_installers:
os.path.join('packaging', 'windows', 'find-libs-with-debug.py'),
'-s', '-f', installerFileName
])
- subprocess.check_call( commandToRun, stdout=sys.stdout, stderr=sys.stderr, shell=True )
+ subprocess.check_call(commandToRun)
except Exception:
print("## Failed to verify the installer signature")
sys.exit(1)
@@ -151,8 +150,7 @@ if arguments.build_installers:
# Run the command
try:
print( "## RUNNING: " + commandToRun )
- subprocess.check_call( commandToRun, stdout=sys.stdout, stderr=sys.stderr, shell=True,
- env=msixEnvironment, cwd=msixFolder )
+ subprocess.check_call(commandToRun, env=msixEnvironment, cwd=msixFolder)
except Exception:
print("## Failed to build the MSIX package")
sys.exit(1)
diff --git a/build-tools/ci-scripts/sign-windows-package-at-notary-service.py b/build-tools/ci-scripts/sign-windows-package-at-notary-service.py
index 12953e1eea..8824c0a104 100644
--- a/build-tools/ci-scripts/sign-windows-package-at-notary-service.py
+++ b/build-tools/ci-scripts/sign-windows-package-at-notary-service.py
@@ -35,12 +35,12 @@ with open("files-to-sign.txt", 'w') as toSign:
print(filePath, file=toSign)
commandToRun = f"{sys.executable} -u ci-notary-service/signwindowsbinaries.py --config {KRITACI_WINDOWS_SIGN_CONFIG} --files-from files-to-sign.txt"
-subprocess.check_call(commandToRun, stdout=sys.stdout, stderr=sys.stderr, shell=True )
+subprocess.check_call(commandToRun)
if release_package_naming:
print(f"Verify that all executables have a signature in {pkg_root}")
commandToRun = f"{sys.executable} -u packaging/windows/find-libs-with-debug.py -s -d {pkg_root}"
- subprocess.check_call(commandToRun, stdout=sys.stdout, stderr=sys.stderr, shell=True )
+ subprocess.check_call(commandToRun)
diff --git a/build-tools/ci-scripts/upload-nightly-packages.py b/build-tools/ci-scripts/upload-nightly-packages.py
index 68d931744f..8003180b82 100644
--- a/build-tools/ci-scripts/upload-nightly-packages.py
+++ b/build-tools/ci-scripts/upload-nightly-packages.py
@@ -67,8 +67,7 @@ commandToRun = ' '.join([sys.executable,
packagesFolder])
try:
print( "## RUNNING: " + commandToRun )
- subprocess.check_call( commandToRun, stdout=sys.stdout, stderr=sys.stderr,
- shell=True)
+ subprocess.check_call(commandToRun)
except Exception:
print("## Failed to upload packages")
sys.exit(1)
diff --git a/packaging/windows/find-libs-with-debug.py b/packaging/windows/find-libs-with-debug.py
index 8fbd0bc05e..9acd70f767 100644
--- a/packaging/windows/find-libs-with-debug.py
+++ b/packaging/windows/find-libs-with-debug.py
@@ -50,10 +50,13 @@ if args.directory is None and args.file is None:
OBJDUMP = False
for arg in ("objdump", "llvm-objdump"):
- commandToRun = f"{arg} --version"
- ret = subprocess.call(commandToRun, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, shell=True)
- if ret != 1:
- OBJDUMP = arg
+ try:
+ ret = subprocess.call([arg, "--version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
+ if ret != 1:
+ OBJDUMP = arg
+ except FileNotFoundError:
+ pass
+
if not OBJDUMP:
warnings.warn("ERROR: objdump is not working.")
sys.exit(1)
diff --git a/packaging/windows/msix/build_msix.py b/packaging/windows/msix/build_msix.py
index 5769ef4627..ab9652846a 100644
--- a/packaging/windows/msix/build_msix.py
+++ b/packaging/windows/msix/build_msix.py
@@ -88,7 +88,7 @@ if not environ['KRITA_DIR']:
os.mkdir(fr"{environ['OUTPUT_DIR']}\installer_content")
commandToRun = f"{environ['SEVENZIP_EXE']} x {environ['KRITA_INSTALLER']}"
try:
- subprocess.check_call(commandToRun, stdout=sys.stdout, stderr=sys.stderr, shell=True)
+ subprocess.check_call(commandToRun)
except subprocess.CalledProcessError:
warnings.warn(f"ERROR failed to extract installer {environ['KRITA_INSTALLER']}")
sys.exit(1)
@@ -171,7 +171,7 @@ print("\n=== Step 1: Generate resources.pri ===")
commandToRun = fr'"{environ["MAKEPRI"]}" new /pr "{scriptDir}\pkg" /mn "{scriptDir}\manifest.xml" /cf "{scriptDir}\priconfig.xml" /o /of "{environ["OUTPUT_DIR"]}\resources.pri"'
try:
- subprocess.check_call(commandToRun, stdout=sys.stdout, stderr=sys.stderr, shell=True)
+ subprocess.check_call(commandToRun)
except subprocess.CalledProcessError:
warnings.warn("ERROR running makepri")
sys.exit(1)
@@ -233,7 +233,7 @@ The arguments stands for:
commandToRun = fr'"{environ["MAKEAPPX"]}" pack /v /f "{environ["OUTPUT_DIR"]}\mapping.txt" /p "{environ["OUTPUT_DIR"]}\krita.msix" /o'
try:
- subprocess.check_call(commandToRun, stdout=sys.stdout, stderr=sys.stderr, shell=True)
+ subprocess.check_call(commandToRun)
except subprocess.CalledProcessError:
warnings.warn("ERROR running makeappx")
sys.exit(1)
@@ -244,7 +244,7 @@ if environ.get('SIGNTOOL_SIGN_FLAGS'):
print("Signing MSIX...")
commandToRun = fr'"{environ["SIGNTOOL"]}" sign {environ["SIGNTOOL_SIGN_FLAGS"]} /fd sha256 "{environ["OUTPUT_DIR"]}\krita.msix"'
try:
- subprocess.check_call(commandToRun, stdout=sys.stdout, stderr=sys.stderr, shell=True)
+ subprocess.check_call(commandToRun)
except subprocess.CalledProcessError:
warnings.warn("ERROR running signtool\n" +
"If you need to specify a PFX keyfile and its password, run:\n" +
diff --git a/packaging/windows/package-complete.py b/packaging/windows/package-complete.py
index 29d1e83244..d4f175a65c 100644
--- a/packaging/windows/package-complete.py
+++ b/packaging/windows/package-complete.py
@@ -285,7 +285,7 @@ for arg in ("objdump", "llvm-objdump"):
if not OBJDUMP:
warnings.warn("ERROR: objdump is not working.")
sys.exit(1)
-output = subprocess.check_output(fr"{OBJDUMP} -f {KRITA_INSTALL_DIR}\bin\krita.exe", shell=True, text=True)
+output = subprocess.check_output(fr"{OBJDUMP} -f {KRITA_INSTALL_DIR}\bin\krita.exe", text=True)
targetArchLines = output.splitlines()
TARGET_ARCH_LINE = ""
@@ -375,7 +375,7 @@ elif IS_LLVM_MINGW:
asanLibName = 'libclang_rt.asan_dynamic-x86_64'
os.environ['STDLIBS_DIR'] = fr"{os.environ['MINGW_BIN_DIR']}\..\x86_64-w64-mingw32\bin"
- output = subprocess.check_output(fr"{OBJDUMP} -p {KRITA_INSTALL_DIR}\bin\krita.exe", shell=True, text=True)
+ output = subprocess.check_output(fr"{OBJDUMP} -p {KRITA_INSTALL_DIR}\bin\krita.exe", text=True)
if re.search(asanLibName, output):
print('The package contains ASAN, packaging the ASAN runtime as well!')
@@ -661,7 +661,7 @@ if not os.environ.get('KRITACI_SKIP_SPLIT_DEBUG', '0').lower() in ['true', '1',
commandToRun = f"objcopy --only-keep-debug {arg1} {arg1}.debug"
try:
- subprocess.check_call(commandToRun, stdout=sys.stdout, stderr=sys.stderr, shell=True)
+ subprocess.check_call(commandToRun)
except subprocess.CalledProcessError as status:
return status.returncode
# If the debug file is small enough then consider there being no debug info.
@@ -675,14 +675,14 @@ if not os.environ.get('KRITACI_SKIP_SPLIT_DEBUG', '0').lower() in ['true', '1',
os.mkdir(debugDir)
shutil.move(f"{arg1}.debug", debugDir+"\\")
commandToRun = f"strip --strip-debug {arg1}"
- subprocess.check_call(commandToRun, stdout=sys.stdout, stderr=sys.stderr, shell=True)
+ subprocess.check_call(commandToRun)
# Add debuglink
# FIXME: There is a problem with gdb that cause it to output this warning
# FIXME: "warning: section .gnu_debuglink not found in xxx.debug"
# FIXME: I tried adding a link to itself but this kills drmingw :(
commandToRun = fr'objcopy --add-gnu-debuglink="{debugDir}\{os.path.basename(arg1)}.debug" {arg1}'
try:
- subprocess.check_call(commandToRun, stdout=sys.stdout, stderr=sys.stderr, shell=True)
+ subprocess.check_call(commandToRun)
except subprocess.CalledProcessError as status:
return status.returncode
return 0
@@ -713,10 +713,10 @@ if args.pre_zip_hook:
print("Running pre-zip hook...")
if args.pre_zip_hook.endswith('.cmd'):
subprocess.run(["cmd", "/c", args.pre_zip_hook,
- f"{pkg_root}\\"], stdout=sys.stdout, stderr=sys.stderr, shell=True, check=True)
+ f"{pkg_root}\\"], check=True)
elif args.pre_zip_hook.endswith('.py'):
subprocess.run([sys.executable, "-u", args.pre_zip_hook,
- f"{pkg_root}\\"], stdout=sys.stdout, stderr=sys.stderr, shell=True, check=True)
+ f"{pkg_root}\\"], check=True)
else:
warnings.warn("ERROR: pre-zip hook has unknown format!")
sys.exit(102)
diff --git a/packaging/windows/sign-package.py b/packaging/windows/sign-package.py
index 522d1875ca..0409d93b5a 100644
--- a/packaging/windows/sign-package.py
+++ b/packaging/windows/sign-package.py
@@ -53,7 +53,7 @@ for rootPath, dirs, files in os.walk(pkg_root):
print(f"Signing {filePath}")
try:
commandToRun = f'"{environ["SIGNTOOL"]}" sign {environ["SIGNTOOL_SIGN_FLAGS"]} "{filePath}"'
- subprocess.check_call(commandToRun, stdout=sys.stdout, stderr=sys.stderr, shell=True)
+ subprocess.check_call(commandToRun)
except subprocess.CalledProcessError as status:
print(f"ERROR: Got exit code {status.returncode} from signtool!")
sys.exit(1)