Skip to content

Commit

Permalink
fix OS version detection on Windows
Browse files Browse the repository at this point in the history
On Windows, the consumer-known version is included in the os.name
property, with Microsoft's internal version number in os.version.
The internal version number isn't very useful, and is also kind of
weird (for example, Windows 7's os.version is 6.1). So, it now checks
for "Windows " in os.name, and doesn't print os.version in that
case.
  • Loading branch information
leafstorm committed Aug 5, 2014
1 parent 94f7c5b commit b7fc8b5
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions jes/java/JESVersion.java.in
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,36 @@ public class JESVersion {
return SCM_INFO;
}

public static String getOSVersion () {
String name = System.getProperty("os.name");

// Windows includes the version the user would know in os.name.
// The os.version property doesn't include anything useful.
// (For example, os.name is "Windows 7" and os.version is "6.1"
// on my Windows 7 laptop.)
// So, on Windows platforms, we only return the name.
// It is more useful on OS X and Linux.
if (name.startsWith("Windows ")) {
return name;
} else {
return name + " " + System.getProperty("os.version");
}
}

public static String getMessage () {
return String.format(
"JES version %s\n" +
"Release date: %s\n" +
"Source control: %s\n" +
"Java version: %s (%s/%s)\n" +
"Jython version: %s (build %s)\n" +
"Computer OS: %s %s (%s architecture)",
"Computer OS: %s (%s architecture)",
RELEASE, RELEASE_DATE, SCM_INFO,
System.getProperty("java.version"),
System.getProperty("java.runtime.name"),
System.getProperty("java.vm.name"),
org.python.Version.PY_VERSION, org.python.Version.getBuildInfo(),
System.getProperty("os.name"), System.getProperty("os.version"),
System.getProperty("os.arch")
getOSVersion(), System.getProperty("os.arch")
);
}
}
Expand Down

0 comments on commit b7fc8b5

Please sign in to comment.