Skip to content

Commit

Permalink
Minor fixes to script inputs and running.
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSNelson committed Jan 22, 2024
1 parent 5970aaa commit 8182a44
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ class PythonTestScripts {
"""
import sys
print('12345', '54321')
# Check if any command-line arguments were provided
if len(sys.argv) == 1:
for arg in sys.argv:
# Print each argument on a separate line
print(arg)
# No arguments were passed, print default coordinates
print('12345', '54321')
else:
# Arguments were passed, print an error message to standard error
print("Error: Unexpected arguments received.", file=sys.stderr)
print('12345', '54321')
sys.exit(1) # Optionally exit with a non-zero status to indicate an error"""
"""

return getStageCoordinatesTest
}
Expand All @@ -35,10 +34,10 @@ if len(sys.argv) == 3:
print(f"X: {X}, Y: {Y}")
except ValueError:
print("Invalid arguments. Both X and Y must be doubles.", file=sys.stderr)
#sys.exit(1)
sys.exit(1)
else:
print("Expected two arguments, X and Y as doubles", file=sys.stderr)
#sys.exit(1)
sys.exit(1)
"""
return sendStageCoordinatesTest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package qupath.ext.qp_scope.utilities

import javafx.application.Platform
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import qupath.lib.gui.QuPathGUI
import qupath.lib.gui.commands.ProjectCommands
Expand Down Expand Up @@ -204,7 +205,7 @@ class UtilityFunctions {
return runTestPythonScript(anacondaEnvPath, getStageScriptPath, arguments)
}
// Construct the command
String command = "\"" + pythonExecutable + "\" -u \"" + pythonScriptPath + "\" " + arguments
String command = "\"" + pythonExecutable + "\" -u \"" + getStageScriptPath + "\" " + arguments
// Execute the command
Process process = command.execute()
logger.info("Executing command: " + command)
Expand Down Expand Up @@ -301,7 +302,10 @@ class UtilityFunctions {
* @param arguments A list of arguments to pass to the python script.
* @return The output from the Python script execution, or null in case of an error.
*/

static runTestPythonScript(String anacondaEnvPath, String pythonScriptPath, List arguments) {
Logger logger2 = LoggerFactory.getLogger(QuPathGUI.class);
logger2.warn("Default script not found, running test script for $pythonScriptPath")
String pythonScript = "";
logger.info("calling runtestpythoncommand on $pythonScriptPath")
// Determine which test script to use based on the file name
Expand Down
18 changes: 11 additions & 7 deletions src/main/pythonScripts/getStageCoordinates.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import sys

print('12345', '54321')
# Check if any command-line arguments were provided
if len(sys.argv) == 2:

for arg in sys.argv:
# Print each argument on a separate line
print(arg)
# No arguments were passed, print default coordinates
print('12345', '54321')
else:
# Arguments were passed, print an error message to standard error
print("Error: Unexpected arguments received.", file=sys.stderr)
print('12345', '54321')
sys.exit(1) # Optionally exit with a non-zero status to indicate an error

# else:
# # Arguments were passed, print an error message to standard error
# print("Error: Unexpected arguments received.", file=sys.stderr)
# print('12345', '54321')
# sys.exit(1) # Optionally exit with a non-zero status to indicate an error
4 changes: 2 additions & 2 deletions src/main/pythonScripts/moveStageToCoordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
print(f"X: {X}, Y: {Y}")
except ValueError:
print("Invalid arguments. Both X and Y must be doubles.", file=sys.stderr)
#sys.exit(1)
sys.exit(1)
else:
print("Expected two arguments, X and Y as doubles", file=sys.stderr)
#sys.exit(1)
sys.exit(1)

0 comments on commit 8182a44

Please sign in to comment.