Skip to content

Commit

Permalink
Command line tools: add flag to disable upgrade check
Browse files Browse the repository at this point in the history
Using the '-no-upgrade' flag with showinf or bfconvert now completely
disables the upgrade check, reducing the total execution time by a few
seconds.

See #7853.
  • Loading branch information
melissalinkert committed Aug 14, 2012
1 parent 572cc33 commit 051ce66
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
24 changes: 14 additions & 10 deletions components/scifio/src/loci/formats/tools/ImageConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ public final class ImageConverter {
private static final Logger LOGGER =
LoggerFactory.getLogger(ImageConverter.class);

private static final String NO_UPGRADE_CHECK = "-no-upgrade";

// -- Fields --

private String in = null, out = null;
Expand Down Expand Up @@ -176,7 +178,7 @@ else if (args[i].equals("-crop")) {
width = Integer.parseInt(tokens[2]);
height = Integer.parseInt(tokens[3]);
}
else {
else if (!args[i].equals(NO_UPGRADE_CHECK)) {
LOGGER.error("Found unknown command flag: {}; exiting.", args[i]);
return false;
}
Expand Down Expand Up @@ -209,9 +211,10 @@ else if (args[i].equals("-crop")) {
" [-bigtiff] [-compression codec] [-series series] [-map id]",
" [-range start end] [-crop x,y,w,h] [-channel channel] [-z Z]",
" [-timepoint timepoint] [-nogroup] [-autoscale] [-version]",
" in_file out_file",
" [-no-upgrade] in_file out_file",
"",
" -version: print the library version and exit",
" -no-upgrade: do not perform the upgrade check",
" -debug: turn on debugging output",
" -stitch: stitch input files with similar names",
" -separate: split RGB images into separate channels",
Expand Down Expand Up @@ -628,15 +631,16 @@ private void applyLUT(IFormatWriter writer)
// -- Main method --

public static void main(String[] args) throws FormatException, IOException {
UpgradeChecker checker = new UpgradeChecker();
boolean canUpgrade =
checker.newVersionAvailable(UpgradeChecker.DEFAULT_CALLER);
if (canUpgrade) {
LOGGER.info("*** A new stable version is available. ***");
LOGGER.info("*** Install the new version using: ***");
LOGGER.info("*** 'upgradechecker -install' ***");
if (DataTools.indexOf(args, NO_UPGRADE_CHECK) == -1) {
UpgradeChecker checker = new UpgradeChecker();
boolean canUpgrade =
checker.newVersionAvailable(UpgradeChecker.DEFAULT_CALLER);
if (canUpgrade) {
LOGGER.info("*** A new stable version is available. ***");
LOGGER.info("*** Install the new version using: ***");
LOGGER.info("*** 'upgradechecker -install' ***");
}
}

ImageConverter converter = new ImageConverter();
if (!converter.testConvert(new ImageWriter(), args)) System.exit(1);
System.exit(0);
Expand Down
23 changes: 14 additions & 9 deletions components/scifio/src/loci/formats/tools/ImageInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ public class ImageInfo {
private static final Logger LOGGER = LoggerFactory.getLogger(ImageInfo.class);
private static final String NEWLINE = System.getProperty("line.separator");

private static final String NO_UPGRADE_CHECK = "-no-upgrade";

// -- Fields --

private String id = null;
Expand Down Expand Up @@ -242,7 +244,7 @@ else if (args[i].equals("-shuffle")) {
}
else if (args[i].equals("-map")) map = args[++i];
else if (args[i].equals("-format")) format = args[++i];
else {
else if (!args[i].equals(NO_UPGRADE_CHECK)) {
LOGGER.error("Found unknown command flag: {}; exiting.", args[i]);
return false;
}
Expand All @@ -267,7 +269,7 @@ public void printUsage() {
" [-normalize] [-fast] [-debug] [-range start end] [-series num]",
" [-swap inputOrder] [-shuffle outputOrder] [-map id] [-preload]",
" [-crop x,y,w,h] [-autoscale] [-novalid] [-omexml-only] [-no-sas]",
" [-format Format]",
" [-no-upgrade] [-format Format]",
"",
" -version: print the library version and exit",
" file: the image file to read",
Expand Down Expand Up @@ -300,6 +302,7 @@ public void printUsage() {
" -novalid: do not perform validation of OME-XML",
"-omexml-only: only output the generated OME-XML",
" -no-sas: do not output OME-XML StructuredAnnotation elements",
" -no-upgrade: do not perform the upgrade check",
" -format: read file with a particular reader (e.g., ZeissZVI)",
"",
"* = may result in loss of precision",
Expand Down Expand Up @@ -1015,13 +1018,15 @@ public boolean testRead(String[] args)
// -- Main method --

public static void main(String[] args) throws Exception {
UpgradeChecker checker = new UpgradeChecker();
boolean canUpgrade =
checker.newVersionAvailable(UpgradeChecker.DEFAULT_CALLER);
if (canUpgrade) {
LOGGER.info("*** A new stable version is available. ***");
LOGGER.info("*** Install the new version using: ***");
LOGGER.info("*** 'upgradechecker -install' ***");
if (DataTools.indexOf(args, NO_UPGRADE_CHECK) == -1) {
UpgradeChecker checker = new UpgradeChecker();
boolean canUpgrade =
checker.newVersionAvailable(UpgradeChecker.DEFAULT_CALLER);
if (canUpgrade) {
LOGGER.info("*** A new stable version is available. ***");
LOGGER.info("*** Install the new version using: ***");
LOGGER.info("*** 'upgradechecker -install' ***");
}
}
if (!new ImageInfo().testRead(args)) System.exit(1);
}
Expand Down

0 comments on commit 051ce66

Please sign in to comment.