From: Ben Soares Date: Thu, 17 Aug 2023 11:47:57 +0000 (+0100) Subject: Merge branch 'feature/JAL-629_--output_-_means_output_to_STDOUT' into improvement... X-Git-Tag: Release_2_11_3_0~8^2~30^2~1 X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=fd814da2180509657dbc6a644cf3e812e8e00c92 Merge branch 'feature/JAL-629_--output_-_means_output_to_STDOUT' into improvement/JAL-3830_remove_dock_icon_in_headless_mode --- fd814da2180509657dbc6a644cf3e812e8e00c92 diff --cc help/help/html/features/clarguments-basic.html index e2f984f,70b42f1..7eb2294 --- a/help/help/html/features/clarguments-basic.html +++ b/help/help/html/features/clarguments-basic.html @@@ -409,9 -410,23 +410,23 @@@

- Important! If you use --output or any other argument that outputs a file, then it will be assumed you want to run Jalview in headless mode (as if you had specified --headless). To use Jalview with --output and not assume headless mode, use the --gui or --noheadless argument (the order doesn't matter). + Important! If you use --output or any other argument that outputs a file, then it will be assumed you want to run Jalview in headless mode (as if you had specified --headless). To use Jalview with --output and not assume headless mode, use the --gui argument (the order doesn't matter).

+

+ If you would like to output an alignment file directly to standard output (often referred to as STDOUT), then use the filename - (a single hyphen). In this case any messages that would normally appear on STDOUT will be diverted to STDERR to avoid invalidating the output file. +

+

+ For example, to open a Stockholm file and pipe it to another command as a Block file, do +

+   jalview --open alignment1.stk --output - --format blc | another_command
+   
+ or equivalently +
+   jalview alignment1.stk --output=[format=blc]- | another_command
+   
+

+

--format

diff --cc src/jalview/bin/HiDPISetting.java index 77228c0,3f57aed..e14c032 --- a/src/jalview/bin/HiDPISetting.java +++ b/src/jalview/bin/HiDPISetting.java @@@ -116,8 -117,8 +116,9 @@@ public class HiDPISettin } } catch (NumberFormatException e) { - System.err.println(setHiDPIScalePropertyName + " property give (" - + setHiDPIScaleProperty + ") but not parseable as integer"); - jalview.bin.Console.errPrintln(setHiDPIScalePropertyName + " property give (" - + setHiDPIScaleProperty + ") but not parseable as integer"); ++ jalview.bin.Console.errPrintln(setHiDPIScalePropertyName ++ + " property give (" + setHiDPIScaleProperty ++ + ") but not parseable as integer"); } } if (setHiDPI && setHiDPIScale > 0) @@@ -134,8 -135,8 +135,8 @@@ try { int existingPropertyVal = Integer.parseInt(existingProperty); - System.out.println("Existing " + scalePropertyName + " is " - + existingPropertyVal); - jalview.bin.Console.outPrintln("Existing " + scalePropertyName + " is " - + existingPropertyVal); ++ jalview.bin.Console.outPrintln("Existing " + scalePropertyName ++ + " is " + existingPropertyVal); if (existingPropertyVal > 1) { setHiDPIScale(existingPropertyVal); @@@ -143,8 -144,8 +144,9 @@@ } } catch (NumberFormatException e) { - System.out.println("Could not convert property " + scalePropertyName - + " vale '" + existingProperty + "' to number"); - jalview.bin.Console.outPrintln("Could not convert property " + scalePropertyName - + " vale '" + existingProperty + "' to number"); ++ jalview.bin.Console.outPrintln( ++ "Could not convert property " + scalePropertyName ++ + " vale '" + existingProperty + "' to number"); } } @@@ -158,11 -159,7 +160,11 @@@ dpi = screenInfo.getScreenResolution(); } catch (HeadlessException e) { - jalview.bin.Console.errPrintln("Cannot get screen resolution: " + e.getMessage()); + if (isLinux) + { - System.err - .println("Cannot get screen resolution: " + e.getMessage()); ++ jalview.bin.Console.errPrintln( ++ "Cannot get screen resolution: " + e.getMessage()); + } } // try and get screen size height and width @@@ -174,11 -171,8 +176,12 @@@ mindimension = Math.min(height, width); } catch (HeadlessException e) { - jalview.bin.Console.errPrintln( - "Cannot get screen size height and width:" + e.getMessage()); + if (isLinux) + { - System.err.println("Cannot get screen size height and width:" - + e.getMessage()); ++ jalview.bin.Console ++ .errPrintln("Cannot get screen size height and width:" ++ + e.getMessage()); + } } // attempt at a formula for scaling based on screen dpi and mindimension. diff --cc src/jalview/bin/Launcher.java index 20a466b,77992f5..e1415be --- a/src/jalview/bin/Launcher.java +++ b/src/jalview/bin/Launcher.java @@@ -64,19 -85,49 +64,21 @@@ public class Launche { if (!LaunchUtils.checkJavaVersion()) { - System.err.println("WARNING - The Java version being used (Java " - + LaunchUtils.getJavaVersion() - + ") may lead to problems. This installation of Jalview should be used with Java " - + LaunchUtils.getJavaCompileVersion() + "."); - jalview.bin.Console.errPrintln("WARNING - The Java version being used (Java " - + LaunchUtils.getJavaVersion() - + ") may lead to problems. This installation of Jalview should be used with Java " - + LaunchUtils.getJavaCompileVersion() + "."); - } - final String appName = ChannelProperties.getProperty("app_name"); - final String javaBinDir = System.getProperty("java.home") - + File.separator + "bin" + File.separator; - String javaBin = null; - if (javaBin == null && checkJVMSymlink(javaBinDir + appName)) - { - javaBin = javaBinDir + appName; - } - if (javaBin == null && checkJVMSymlink(javaBinDir + "Jalview")) - { - javaBin = javaBinDir + "Jalview"; ++ jalview.bin.Console ++ .errPrintln("WARNING - The Java version being used (Java " ++ + LaunchUtils.getJavaVersion() ++ + ") may lead to problems. This installation of Jalview should be used with Java " ++ + LaunchUtils.getJavaCompileVersion() + "."); } - if (javaBin == null) - { - javaBin = "java"; - } - - List command = new ArrayList<>(); - command.add(javaBin); - - String memSetting = null; - - boolean isAMac = System.getProperty("os.name").indexOf("Mac") > -1; - - for (String jvmArg : ManagementFactory.getRuntimeMXBean() - .getInputArguments()) - { - command.add(jvmArg); - } - command.add("-cp"); - command.add(ManagementFactory.getRuntimeMXBean().getClassPath()); String jvmmempc = null; String jvmmemmax = null; boolean debug = false; boolean wait = true; boolean quiet = false; + boolean headless = false; + boolean gui = false; + boolean stdout = false; // must set --debug before --launcher... boolean launcherstop = false; boolean launcherprint = false; @@@ -92,14 -144,11 +95,19 @@@ { quiet = true; } + if (arg.equals("--headless")) + { + headless = true; + } + if (arg.equals("--gui")) + { + gui = true; + } + if (arg.equals("--output=-") + || (arg.equals("-") && "--output".equals(previousArg))) + { + stdout = true; + } if (debug && arg.equals("--launcherprint")) { launcherprint = true; @@@ -320,7 -337,7 +329,8 @@@ { if (e.getMessage().toLowerCase(Locale.ROOT).contains("memory")) { - System.err.println("Caught a memory exception: " + e.getMessage()); - jalview.bin.Console.errPrintln("Caught a memory exception: " + e.getMessage()); ++ jalview.bin.Console ++ .errPrintln("Caught a memory exception: " + e.getMessage()); // Probably the "Cannot allocate memory" error, try without the memory // setting ArrayList commandNoMem = new ArrayList<>();