org.apache.commons.exec.OS类的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(246)

本文整理了Java中org.apache.commons.exec.OS类的一些代码示例,展示了OS类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OS类的具体详情如下:
包路径:org.apache.commons.exec.OS
类名称:OS

OS介绍

[英]Condition that tests the OS type.
[中]测试操作系统类型的条件。

代码示例

代码示例来源:origin: org.apache.commons/commons-exec

  1. /**
  2. * Creates a map that obeys the casing rules of the current platform for key
  3. * lookup. E.g. on a Windows platform, the map keys will be
  4. * case-insensitive.
  5. *
  6. * @return The map for storage of environment variables, never
  7. * {@code null}.
  8. */
  9. private Map<String, String> createEnvironmentMap() {
  10. if (OS.isFamilyWindows()) {
  11. return new TreeMap<String, String>(new Comparator<String>() {
  12. public int compare(final String key0, final String key1) {
  13. return key0.compareToIgnoreCase(key1);
  14. }
  15. });
  16. }
  17. return new HashMap<String, String>();
  18. }

代码示例来源:origin: org.apache.commons/commons-exec

  1. /**
  2. * Determines if the OS on which Ant is executing matches the given OS name.
  3. *
  4. * @param name
  5. * the OS name to check for
  6. * @return true if the OS matches
  7. */
  8. public static boolean isName(final String name) {
  9. return isOs(null, name, null, null);
  10. }

代码示例来源:origin: org.apache.commons/commons-exec

  1. public static boolean isFamilyWindows() {
  2. return isFamily(FAMILY_WINDOWS);
  3. }

代码示例来源:origin: com.github.becauseQA/becauseQA-utils

  1. if (OS.isFamilyWindows()) {
  2. stopServerCommand = new String[]{"cmd", "/c",
  3. "echo off & FOR /F \"usebackq tokens=5\" %a in (`netstat -nao ^| findstr /R /C:\""
  4. + _serverArguments.get(AppiumCommonArgs.PORT_NUMBER)
  5. + " \"`) do (FOR /F \"usebackq\" %b in (`TASKLIST /FI \"PID eq %a\" ^| findstr /I node.exe`) do taskkill /F /PID %a)"};
  6. } else if (OS.isFamilyMac()) {
  7. } else if (OS.isFamilyUnix()) {

代码示例来源:origin: com.github.becauseQA/becauseQA-utils

  1. /**
  2. * Search the operating system for an Appium server installation directory.
  3. *
  4. * @return A File representation to the Appium server installation
  5. * directory.
  6. */
  7. private File searchForServerDirectory() {
  8. if (OS.isFamilyWindows()) {
  9. if (getArch().equals("32")) {
  10. return doesDirectoryExists(System.getenv("ProgramFiles")
  11. + "/Appium");
  12. } else {
  13. // must be the x86_64
  14. return doesDirectoryExists(System.getenv("ProgramFiles")
  15. + " (x86)/Appium");
  16. }
  17. } else if (OS.isFamilyMac()) {
  18. return doesDirectoryExists("/Applications/Appium.app/Contents/Resources");
  19. }
  20. // server directrory was not found.
  21. throw new ServerDirectoryNotFoundException();
  22. }

代码示例来源:origin: bonitasoft/bonita-engine

  1. public static CommandLine createCommandLine() {
  2. if (OS.isFamilyWindows() || OS.isFamilyWin9x()) {
  3. CommandLine oCmdLine = new CommandLine("cmd");
  4. oCmdLine.addArgument("/c");
  5. oCmdLine.addArgument("setup.bat");
  6. return oCmdLine;
  7. } else {
  8. CommandLine oCmdLine = new CommandLine("sh");
  9. oCmdLine.addArgument("setup.sh");
  10. return oCmdLine;
  11. }
  12. }
  13. }

代码示例来源:origin: vmi/selenese-runner-java

  1. @Override
  2. public WebDriver newInstance(DriverOptions driverOptions) {
  3. if (!OS.isFamilyMac())
  4. throw new UnsupportedOperationException("Unsupported platform: " + Platform.getCurrent());
  5. SafariDriverService service = setupBuilder(new SafariDriverService.Builder(), driverOptions, null).build();
  6. SafariOptions options = newSafariOptions(driverOptions);
  7. options.merge(driverOptions.getCapabilities());
  8. SafariDriver driver = new SafariDriver(service, options);
  9. setInitialWindowSize(driver, driverOptions);
  10. return driver;
  11. }
  12. }

代码示例来源:origin: com.github.becausetesting/commons

  1. if (OS.isFamilyWindows()) {
  2. stopServerCommand = new String[]{"cmd", "/c",
  3. "echo off & FOR /F \"usebackq tokens=5\" %a in (`netstat -nao ^| findstr /R /C:\""
  4. + _serverArguments.get(AppiumCommonArgs.PORT_NUMBER)
  5. + " \"`) do (FOR /F \"usebackq\" %b in (`TASKLIST /FI \"PID eq %a\" ^| findstr /I node.exe`) do taskkill /F /PID %a)"};
  6. } else if (OS.isFamilyMac()) {
  7. } else if (OS.isFamilyUnix()) {

代码示例来源:origin: com.github.becausetesting/commons

  1. /**
  2. * Search the operating system for an Appium server installation directory.
  3. *
  4. * @return A File representation to the Appium server installation
  5. * directory.
  6. */
  7. private File searchForServerDirectory() {
  8. if (OS.isFamilyWindows()) {
  9. if (getArch().equals("32")) {
  10. return doesDirectoryExists(System.getenv("ProgramFiles")
  11. + "/Appium");
  12. } else {
  13. // must be the x86_64
  14. return doesDirectoryExists(System.getenv("ProgramFiles")
  15. + " (x86)/Appium");
  16. }
  17. } else if (OS.isFamilyMac()) {
  18. return doesDirectoryExists("/Applications/Appium.app/Contents/Resources");
  19. }
  20. // server directrory was not found.
  21. throw new ServerDirectoryNotFoundException();
  22. }

代码示例来源:origin: com.addc.mojo/addc-mojo

  1. /**
  2. * Get the Executable name with .exe appended if on Windows and with the
  3. * exePath prepended.
  4. *
  5. * @param executableName
  6. * The base(UNIX) name of the process
  7. * @return The executable name with .exe appended if on Windows and with the
  8. * exePath prepended.
  9. */
  10. protected String getExecutable(String executableName) {
  11. String exeName= OS.isFamilyWindows() ? executableName + ".exe" : executableName;
  12. if (exePath != null) {
  13. File exec= new File(exePath, exeName);
  14. return exec.getAbsolutePath();
  15. }
  16. return exeName;
  17. }

代码示例来源:origin: com.github.becauseQA/becauseQA-utils

  1. if (OS.isFamilyWindows()) {
  2. commanddLine = new CommandLine("\"" + command + "\"");
  3. } else if (OS.isFamilyMac() || OS.isFamilyUnix()) {
  4. commanddLine = new CommandLine(command.contains(" ") ? "'" + command + "'" : command);
  5. } else {
  6. if (OS.isFamilyWindows()) {
  7. for (String parameter : parameters) {
  8. commanddLine.addArgument("\"" + parameter + "\"", false);
  9. } else if (OS.isFamilyMac() || OS.isFamilyUnix()) {
  10. for (String parameter : parameters) {
  11. commanddLine.addArgument(parameter.contains(" ") ? "'" + parameter + "'" : parameter, false);

代码示例来源:origin: org.apache.commons/commons-exec

  1. /**
  2. * Determines if the OS on which Ant is executing matches the given OS
  3. * architecture.
  4. *
  5. * @param arch
  6. * the OS architecture to check for
  7. * @return true if the OS matches
  8. */
  9. public static boolean isArch(final String arch) {
  10. return isOs(null, null, arch, null);
  11. }

代码示例来源:origin: org.apache.commons/commons-exec

  1. public static boolean isFamilyMac() {
  2. return isFamily(FAMILY_MAC);
  3. }

代码示例来源:origin: com.github.becauseQA/becauseQA-utils

  1. /**
  2. * Constructs an Appium server instance. You specify the custom directory to
  3. * your Appium server.
  4. *
  5. * @param absoluteServerDirectory The custom directory to your Appium
  6. * server. The directory that contains the "node_modules" directory &amp;
  7. * the NodeJS executable.
  8. * @param serverArguments The server arguments to be used when working with
  9. * the server.
  10. */
  11. public AppiumServer(File absoluteServerDirectory, ServerArguments serverArguments) {
  12. this._absoluteServerDirectory = absoluteServerDirectory;
  13. this._serverArguments = serverArguments;
  14. // make sure to get the node executable file path along with the appium.js path too.
  15. _nodeExecutableFilePath = new File(OS.isFamilyWindows()
  16. ? _absoluteServerDirectory + node_execuable : _absoluteServerDirectory + "/node/bin/node");
  17. _appiumJavaScriptFilePath = new File(_absoluteServerDirectory
  18. + appium_server);
  19. }

代码示例来源:origin: com.github.becausetesting/commons

  1. if (OS.isFamilyWindows()) {
  2. commanddLine = new CommandLine("\"" + command + "\"");
  3. } else if (OS.isFamilyMac() || OS.isFamilyUnix()) {
  4. commanddLine = new CommandLine(command.contains(" ") ? "'" + command + "'" : command);
  5. } else {
  6. if (OS.isFamilyWindows()) {
  7. for (String parameter : parameters) {
  8. commanddLine.addArgument("\"" + parameter + "\"", false);
  9. } else if (OS.isFamilyMac() || OS.isFamilyUnix()) {
  10. for (String parameter : parameters) {
  11. commanddLine.addArgument(parameter.contains(" ") ? "'" + parameter + "'" : parameter, false);

代码示例来源:origin: org.apache.commons/commons-exec

  1. /**
  2. * Determines if the OS on which Ant is executing matches the given OS
  3. * version.
  4. *
  5. * @param version
  6. * the OS version to check for
  7. * @return true if the OS matches
  8. */
  9. public static boolean isVersion(final String version) {
  10. return isOs(null, null, null, version);
  11. }

代码示例来源:origin: org.apache.commons/commons-exec

  1. public static boolean isFamilyOS400() {
  2. return isFamily(FAMILY_OS_400);
  3. }

代码示例来源:origin: com.github.becausetesting/commons

  1. /**
  2. * Constructs an Appium server instance. You specify the custom directory to
  3. * your Appium server.
  4. *
  5. * @param absoluteServerDirectory The custom directory to your Appium
  6. * server. The directory that contains the "node_modules" directory &amp;
  7. * the NodeJS executable.
  8. * @param serverArguments The server arguments to be used when working with
  9. * the server.
  10. */
  11. public AppiumServer(File absoluteServerDirectory, ServerArguments serverArguments) {
  12. this._absoluteServerDirectory = absoluteServerDirectory;
  13. this._serverArguments = serverArguments;
  14. // make sure to get the node executable file path along with the appium.js path too.
  15. _nodeExecutableFilePath = new File(OS.isFamilyWindows()
  16. ? _absoluteServerDirectory + node_execuable : _absoluteServerDirectory + "/node/bin/node");
  17. _appiumJavaScriptFilePath = new File(_absoluteServerDirectory
  18. + appium_server);
  19. }

代码示例来源:origin: org.apache.commons/commons-exec

  1. /**
  2. * Determines if the OS on which Ant is executing matches the given OS
  3. * family. * Possible values:<br />
  4. * <ul>
  5. * <li>dos</li>
  6. * <li>mac</li>
  7. * <li>netware</li>
  8. * <li>os/2</li>
  9. * <li>tandem</li>
  10. * <li>unix</li>
  11. * <li>windows</li>
  12. * <li>win9x</li>
  13. * <li>z/os</li>
  14. * <li>os/400</li>
  15. * </ul>
  16. *
  17. * @param family
  18. * the family to check for
  19. * @return true if the OS matches
  20. */
  21. private static boolean isFamily(final String family) {
  22. return isOs(family, null, null, null);
  23. }

代码示例来源:origin: org.apache.commons/commons-exec

  1. public static boolean isFamilyOS2() {
  2. return isFamily(FAMILY_OS_2);
  3. }

相关文章