mirror-cockpit-project-cockpit/pkg/lib/python.ts
Martin Pitt a7ae147258 REUSE: Convert license headers to SPDX format
Replace full LGPL/GPL/MIT/BSD license header with
SPDX-License-Identifier in all source files. This is more concise and
makes the license information machine readable.

Keep the full text of ISC for src/common/cockpitbase64.[hc], it's small
enough and only used in this pair of files. Also keep the CC-BY-SA
paragraph in pkg/storaged/icons/gnome-icons.jsx as explained in the
previous commit.

See https://reuse.software/spec-2.0/#2-include-a-copyright-notice-and-license-in-each-file

https://issues.redhat.com/browse/COCKPIT-1742
2026-02-04 10:24:11 +01:00

26 lines
834 B
TypeScript

/*
* Copyright (C) 2017 Red Hat, Inc.
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
import cockpit, { BasicError } from "cockpit";
const pyinvoke = ["sh", "-ec", "exec $(command -v /usr/libexec/platform-python || command -v python3) -c \"$@\"", "--"];
export interface PythonExitStatus extends BasicError {
exit_status: number | null,
exit_signal: number | null,
}
// only declare the string variant for the time being; we don't use the binary variant
export function spawn (
script_pieces: string | string[],
args?: string[],
options?: cockpit.SpawnOptions & { binary?: false; }
): cockpit.Spawn<string> {
const script = (typeof script_pieces == "string")
? script_pieces
: script_pieces.join("\n");
return cockpit.spawn(pyinvoke.concat([script]).concat(args ?? []), options);
}