Wie kann ich Argumente verwenden, die ";"; zu subprocess.run?Python

Python-Programme
Anonymous
 Wie kann ich Argumente verwenden, die ";"; zu subprocess.run?

Post by Anonymous »

Ich muss ein JVM aus einem Python -Skript starten. Dazu versuche ich, subprozess.run zu verwenden. Eines der Argumente für die JVM ist der Klassenpfad. In Windows ist das Trennzeichen in einem Java -Klassenpfad das Semikolon; . Ich muss dem Klassenpfad mehrere Gläser hinzufügen. Aber wenn ich versuche, es mit Subprozess zu starten. Ich vermute, dass dies etwas damit zu tun hat, dass das Semikolon der Windows -Befehlsabscheider ist. Jemand weiß, wie man es umgeht?

Code: Select all

def run_groovy_script(groovy_script: str, *args):
# This function calls sys.exit in case of error. The idea is to run several commands in sequence and immediately abort with error message if one fails.
# Construct the command to run the Groovy script with arguments
command = ["groovy.bat", "-cp", "tools/slf4j-simple-2.0.13.jar;tools", groovy_script] + list(args)

try:
result = subprocess.run(command, check=True)
except subprocess.CalledProcessError as e:
print(f"{groovy_script} failed with return code {e.returncode}")
sys.exit(1)
except Exception as e:
print(f"An error occurred executing {groovy_script}: {str(e)}")
sys.exit(1)
< /code>
Erfolgreicher CMD -Aufruf < /p>
groovy.bat -cp "tools/slf4j-simple-2.0.13.jar;tools" tools/script.groovy build hej

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post