本文整理了Java中org.apache.commons.exec.OS
类的一些代码示例,展示了OS
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OS
类的具体详情如下:
包路径:org.apache.commons.exec.OS
类名称:OS
[英]Condition that tests the OS type.
[中]测试操作系统类型的条件。
代码示例来源:origin: org.apache.commons/commons-exec
/**
* Creates a map that obeys the casing rules of the current platform for key
* lookup. E.g. on a Windows platform, the map keys will be
* case-insensitive.
*
* @return The map for storage of environment variables, never
* {@code null}.
*/
private Map<String, String> createEnvironmentMap() {
if (OS.isFamilyWindows()) {
return new TreeMap<String, String>(new Comparator<String>() {
public int compare(final String key0, final String key1) {
return key0.compareToIgnoreCase(key1);
}
});
}
return new HashMap<String, String>();
}
代码示例来源:origin: org.apache.commons/commons-exec
/**
* Determines if the OS on which Ant is executing matches the given OS name.
*
* @param name
* the OS name to check for
* @return true if the OS matches
*/
public static boolean isName(final String name) {
return isOs(null, name, null, null);
}
代码示例来源:origin: org.apache.commons/commons-exec
public static boolean isFamilyWindows() {
return isFamily(FAMILY_WINDOWS);
}
代码示例来源:origin: com.github.becauseQA/becauseQA-utils
if (OS.isFamilyWindows()) {
stopServerCommand = new String[]{"cmd", "/c",
"echo off & FOR /F \"usebackq tokens=5\" %a in (`netstat -nao ^| findstr /R /C:\""
+ _serverArguments.get(AppiumCommonArgs.PORT_NUMBER)
+ " \"`) do (FOR /F \"usebackq\" %b in (`TASKLIST /FI \"PID eq %a\" ^| findstr /I node.exe`) do taskkill /F /PID %a)"};
} else if (OS.isFamilyMac()) {
} else if (OS.isFamilyUnix()) {
代码示例来源:origin: com.github.becauseQA/becauseQA-utils
/**
* Search the operating system for an Appium server installation directory.
*
* @return A File representation to the Appium server installation
* directory.
*/
private File searchForServerDirectory() {
if (OS.isFamilyWindows()) {
if (getArch().equals("32")) {
return doesDirectoryExists(System.getenv("ProgramFiles")
+ "/Appium");
} else {
// must be the x86_64
return doesDirectoryExists(System.getenv("ProgramFiles")
+ " (x86)/Appium");
}
} else if (OS.isFamilyMac()) {
return doesDirectoryExists("/Applications/Appium.app/Contents/Resources");
}
// server directrory was not found.
throw new ServerDirectoryNotFoundException();
}
代码示例来源:origin: bonitasoft/bonita-engine
public static CommandLine createCommandLine() {
if (OS.isFamilyWindows() || OS.isFamilyWin9x()) {
CommandLine oCmdLine = new CommandLine("cmd");
oCmdLine.addArgument("/c");
oCmdLine.addArgument("setup.bat");
return oCmdLine;
} else {
CommandLine oCmdLine = new CommandLine("sh");
oCmdLine.addArgument("setup.sh");
return oCmdLine;
}
}
}
代码示例来源:origin: vmi/selenese-runner-java
@Override
public WebDriver newInstance(DriverOptions driverOptions) {
if (!OS.isFamilyMac())
throw new UnsupportedOperationException("Unsupported platform: " + Platform.getCurrent());
SafariDriverService service = setupBuilder(new SafariDriverService.Builder(), driverOptions, null).build();
SafariOptions options = newSafariOptions(driverOptions);
options.merge(driverOptions.getCapabilities());
SafariDriver driver = new SafariDriver(service, options);
setInitialWindowSize(driver, driverOptions);
return driver;
}
}
代码示例来源:origin: com.github.becausetesting/commons
if (OS.isFamilyWindows()) {
stopServerCommand = new String[]{"cmd", "/c",
"echo off & FOR /F \"usebackq tokens=5\" %a in (`netstat -nao ^| findstr /R /C:\""
+ _serverArguments.get(AppiumCommonArgs.PORT_NUMBER)
+ " \"`) do (FOR /F \"usebackq\" %b in (`TASKLIST /FI \"PID eq %a\" ^| findstr /I node.exe`) do taskkill /F /PID %a)"};
} else if (OS.isFamilyMac()) {
} else if (OS.isFamilyUnix()) {
代码示例来源:origin: com.github.becausetesting/commons
/**
* Search the operating system for an Appium server installation directory.
*
* @return A File representation to the Appium server installation
* directory.
*/
private File searchForServerDirectory() {
if (OS.isFamilyWindows()) {
if (getArch().equals("32")) {
return doesDirectoryExists(System.getenv("ProgramFiles")
+ "/Appium");
} else {
// must be the x86_64
return doesDirectoryExists(System.getenv("ProgramFiles")
+ " (x86)/Appium");
}
} else if (OS.isFamilyMac()) {
return doesDirectoryExists("/Applications/Appium.app/Contents/Resources");
}
// server directrory was not found.
throw new ServerDirectoryNotFoundException();
}
代码示例来源:origin: com.addc.mojo/addc-mojo
/**
* Get the Executable name with .exe appended if on Windows and with the
* exePath prepended.
*
* @param executableName
* The base(UNIX) name of the process
* @return The executable name with .exe appended if on Windows and with the
* exePath prepended.
*/
protected String getExecutable(String executableName) {
String exeName= OS.isFamilyWindows() ? executableName + ".exe" : executableName;
if (exePath != null) {
File exec= new File(exePath, exeName);
return exec.getAbsolutePath();
}
return exeName;
}
代码示例来源:origin: com.github.becauseQA/becauseQA-utils
if (OS.isFamilyWindows()) {
commanddLine = new CommandLine("\"" + command + "\"");
} else if (OS.isFamilyMac() || OS.isFamilyUnix()) {
commanddLine = new CommandLine(command.contains(" ") ? "'" + command + "'" : command);
} else {
if (OS.isFamilyWindows()) {
for (String parameter : parameters) {
commanddLine.addArgument("\"" + parameter + "\"", false);
} else if (OS.isFamilyMac() || OS.isFamilyUnix()) {
for (String parameter : parameters) {
commanddLine.addArgument(parameter.contains(" ") ? "'" + parameter + "'" : parameter, false);
代码示例来源:origin: org.apache.commons/commons-exec
/**
* Determines if the OS on which Ant is executing matches the given OS
* architecture.
*
* @param arch
* the OS architecture to check for
* @return true if the OS matches
*/
public static boolean isArch(final String arch) {
return isOs(null, null, arch, null);
}
代码示例来源:origin: org.apache.commons/commons-exec
public static boolean isFamilyMac() {
return isFamily(FAMILY_MAC);
}
代码示例来源:origin: com.github.becauseQA/becauseQA-utils
/**
* Constructs an Appium server instance. You specify the custom directory to
* your Appium server.
*
* @param absoluteServerDirectory The custom directory to your Appium
* server. The directory that contains the "node_modules" directory &
* the NodeJS executable.
* @param serverArguments The server arguments to be used when working with
* the server.
*/
public AppiumServer(File absoluteServerDirectory, ServerArguments serverArguments) {
this._absoluteServerDirectory = absoluteServerDirectory;
this._serverArguments = serverArguments;
// make sure to get the node executable file path along with the appium.js path too.
_nodeExecutableFilePath = new File(OS.isFamilyWindows()
? _absoluteServerDirectory + node_execuable : _absoluteServerDirectory + "/node/bin/node");
_appiumJavaScriptFilePath = new File(_absoluteServerDirectory
+ appium_server);
}
代码示例来源:origin: com.github.becausetesting/commons
if (OS.isFamilyWindows()) {
commanddLine = new CommandLine("\"" + command + "\"");
} else if (OS.isFamilyMac() || OS.isFamilyUnix()) {
commanddLine = new CommandLine(command.contains(" ") ? "'" + command + "'" : command);
} else {
if (OS.isFamilyWindows()) {
for (String parameter : parameters) {
commanddLine.addArgument("\"" + parameter + "\"", false);
} else if (OS.isFamilyMac() || OS.isFamilyUnix()) {
for (String parameter : parameters) {
commanddLine.addArgument(parameter.contains(" ") ? "'" + parameter + "'" : parameter, false);
代码示例来源:origin: org.apache.commons/commons-exec
/**
* Determines if the OS on which Ant is executing matches the given OS
* version.
*
* @param version
* the OS version to check for
* @return true if the OS matches
*/
public static boolean isVersion(final String version) {
return isOs(null, null, null, version);
}
代码示例来源:origin: org.apache.commons/commons-exec
public static boolean isFamilyOS400() {
return isFamily(FAMILY_OS_400);
}
代码示例来源:origin: com.github.becausetesting/commons
/**
* Constructs an Appium server instance. You specify the custom directory to
* your Appium server.
*
* @param absoluteServerDirectory The custom directory to your Appium
* server. The directory that contains the "node_modules" directory &
* the NodeJS executable.
* @param serverArguments The server arguments to be used when working with
* the server.
*/
public AppiumServer(File absoluteServerDirectory, ServerArguments serverArguments) {
this._absoluteServerDirectory = absoluteServerDirectory;
this._serverArguments = serverArguments;
// make sure to get the node executable file path along with the appium.js path too.
_nodeExecutableFilePath = new File(OS.isFamilyWindows()
? _absoluteServerDirectory + node_execuable : _absoluteServerDirectory + "/node/bin/node");
_appiumJavaScriptFilePath = new File(_absoluteServerDirectory
+ appium_server);
}
代码示例来源:origin: org.apache.commons/commons-exec
/**
* Determines if the OS on which Ant is executing matches the given OS
* family. * Possible values:<br />
* <ul>
* <li>dos</li>
* <li>mac</li>
* <li>netware</li>
* <li>os/2</li>
* <li>tandem</li>
* <li>unix</li>
* <li>windows</li>
* <li>win9x</li>
* <li>z/os</li>
* <li>os/400</li>
* </ul>
*
* @param family
* the family to check for
* @return true if the OS matches
*/
private static boolean isFamily(final String family) {
return isOs(family, null, null, null);
}
代码示例来源:origin: org.apache.commons/commons-exec
public static boolean isFamilyOS2() {
return isFamily(FAMILY_OS_2);
}
内容来源于网络,如有侵权,请联系作者删除!