本文整理汇总了Java中org.apache.commons.exec.OS.isFamilyMac方法的典型用法代码示例。如果您正苦于以下问题:Java OS.isFamilyMac方法的具体用法?Java OS.isFamilyMac怎么用?Java OS.isFamilyMac使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.exec.OS
的用法示例。
在下文中一共展示了OS.isFamilyMac方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: searchForServerDirectory
import org.apache.commons.exec.OS; //导入方法依赖的package包/类
/**
* 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(APPIUM_SERVER_MAC_DEFAULT_DIRECTORY);
}
// server directrory was not found.
throw new ServerDirectoryNotFoundException();
}
示例2: init
import org.apache.commons.exec.OS; //导入方法依赖的package包/类
private void init() throws MojoExecutionException {
// Supply variables that are OS dependent
if (OS.isFamilyWindows()) {
if (command == null) {
command = "taskkill";
}
} else if (OS.isFamilyUnix() || OS.isFamilyMac()) {
if (command == null) {
command = "kill";
}
} else {
if (command == null) {
throw new MojoExecutionException(
"Unknown OS - You must use the 'command' parameter");
}
}
}
示例3: applyFileMode
import org.apache.commons.exec.OS; //导入方法依赖的package包/类
private static void applyFileMode(final File file, final FileMode fileMode)
throws MojoExecutionException {
if (OS.isFamilyUnix() || OS.isFamilyMac()) {
final String smode = fileMode.toChmodStringFull();
final CommandLine cmdLine = new CommandLine("chmod");
cmdLine.addArgument(smode);
cmdLine.addArgument(file.getAbsolutePath());
final Executor executor = new DefaultExecutor();
try {
final int result = executor.execute(cmdLine);
if (result != 0) {
throw new MojoExecutionException("Error # " + result + " while trying to set mode \""
+ smode + "\" for file: " + file.getAbsolutePath());
}
} catch (final IOException ex) {
throw new MojoExecutionException("Error while trying to set mode \"" + smode + "\" for file: "
+ file.getAbsolutePath(), ex);
}
} else {
file.setReadable(fileMode.isUr() || fileMode.isGr() || fileMode.isOr());
file.setWritable(fileMode.isUw() || fileMode.isGw() || fileMode.isOw());
file.setExecutable(fileMode.isUx() || fileMode.isGx() || fileMode.isOx());
}
}
示例4: getProcessStatus
import org.apache.commons.exec.OS; //导入方法依赖的package包/类
/**
* get the status of the processname.
*
* @param processname
* the process name
* @return the status of the process
* @throws IOException
* throw IOException if occur error
*/
public static String getProcessStatus(String processname) throws IOException {
if (isLinux() || OS.isFamilyMac()) {
String line = "ps -ef";
String r = run(line);
StringBuilder sb = new StringBuilder();
String[] ss = r.split("\n");
if (ss != null && ss.length > 0) {
for (String s : ss) {
if (s.contains(processname)) {
sb.append(s).append("\n");
}
}
}
return sb.toString();
} else if (OS.isFamilyWindows()) {
String cmd = "tasklist /nh /FI \"IMAGENAME eq " + processname + "\"";
return run(cmd);
} else {
throw new IOException("not support");
}
}
示例5: getStartScriptName
import org.apache.commons.exec.OS; //导入方法依赖的package包/类
public static String getStartScriptName() throws URISyntaxException {
String base="Transkribus.";
if (OS.isFamilyWindows()) {
String exe = base+"exe";
String cmd = "cmd /c start "+exe;
// cmd += "& del "+getCurrentJar().getName(); // this cleans the old version in windows after the new version has started --> should work, as current JVM should exit sooner than new program has started!
return cmd;
} else if (OS.isFamilyMac()) {
return "./"+base+"command";
} else {
return "./"+base+"sh";
}
}
示例6: createCommandLine
import org.apache.commons.exec.OS; //导入方法依赖的package包/类
private CommandLine createCommandLine() throws MojoExecutionException {
final CommandLine cmdLine = new CommandLine(command);
if (OS.isFamilyWindows()) {
cmdLine.addArgument("/PID");
cmdLine.addArgument(readPid());
cmdLine.addArgument("/F");
} else if (OS.isFamilyUnix() || OS.isFamilyMac()) {
cmdLine.addArgument("-SIGKILL");
cmdLine.addArgument(readPid());
} else {
throw new MojoExecutionException(
"Unknown OS - Cannot kill the process");
}
return cmdLine;
}
示例7: init
import org.apache.commons.exec.OS; //导入方法依赖的package包/类
private void init() throws MojoExecutionException {
// Supply variables that are OS dependent
if (OS.isFamilyWindows()) {
if (command == null) {
// For some strange reasons this does not work without the
// path...
command = getEventStoreDir() + File.separator
+ "EventStore.ClusterNode.exe";
}
} else if (OS.isFamilyUnix()) {
if (command == null) {
command = "./run-node.sh";
}
} else if (OS.isFamilyMac()) {
if (command == null) {
command = "./run-node.sh";
}
} else {
if (command == null) {
throw new MojoExecutionException(
"Unknown OS - You must use the 'command' parameter");
}
}
// Use in-memory mode if nothing else is set
if (arguments == null) {
arguments = new String[1];
arguments[0] = "--mem-db=TRUE";
}
}
示例8: getCurrentOS
import org.apache.commons.exec.OS; //导入方法依赖的package包/类
/**
* This method returns a member of {@code OperatingSystem} representing the
* current Operating System.
*
* @since 1.0.2
* @return Current Operating System
*/
public static OperatingSystem getCurrentOS() {
OperatingSystem currentOS = OperatingSystem.UNKNOWN;
if (OS.isFamilyUnix()) {
currentOS = OperatingSystem.LINUX;
}
if (OS.isFamilyMac()) {
currentOS = OperatingSystem.MAC;
}
if (OS.isFamilyWindows()) {
currentOS = OperatingSystem.WINDOWS;
}
return currentOS;
}
示例9: createWebDriver
import org.apache.commons.exec.OS; //导入方法依赖的package包/类
@Override
public RemoteWebDriver createWebDriver() {
SafariDriver safari = new SafariDriver();
if (OS.isFamilyMac()) {
try {
// put the browser in the foreground:
String cmdline = "open -a safari";
SeleniumJavaRobot.log("Executing: " + cmdline);
Runtime.getRuntime().exec(cmdline);
} catch (Exception e) {
}
}
return safari;
}
示例10: isMac
import org.apache.commons.exec.OS; //导入方法依赖的package包/类
public static boolean isMac() {
if (_mac == -1) {
_mac = OS.isFamilyMac() ? 1 : 0;
}
return _mac == 1;
}
示例11: isCtrlOrCommandKeyDown
import org.apache.commons.exec.OS; //导入方法依赖的package包/类
/**
* On MAC, returns true if command key is down, elsewise if ctrl key is down
*/
public static boolean isCtrlOrCommandKeyDown(int mask) {
return OS.isFamilyMac() ? isCommandKeyDown(mask) : CanvasKeys.isCtrlKeyDown(mask);
}
示例12: initUsingLatest
import org.apache.commons.exec.OS; //导入方法依赖的package包/类
private void initUsingLatest() throws MojoExecutionException {
try {
final URL versionURL = new URL(versionUrl);
final File jsonVersionFile = new File(canonicalFile(targetDir),
"event-store-versions.json");
final Downloads downloads = new Downloads(versionURL,
jsonVersionFile);
downloads.parse();
final String os;
if (OS.isFamilyWindows()) {
os = "win";
} else if (OS.isFamilyMac()) {
os = "osx-10.10";
} else if (OS.isFamilyUnix()) {
os = "ubuntu-14.04";
} else {
throw new MojoExecutionException(
"Unknown OS - You must use the 'archive-name' parameter");
}
final DownloadOS downloadOS = downloads.findOS(os);
if (downloadOS == null) {
throw new MojoExecutionException("Couldn't find OS '" + os
+ "' in '" + downloads.getJsonDownloadsFile() + "'");
}
final DownloadVersion version = downloadOS.getLatestVersion();
if (version == null) {
throw new MojoExecutionException(
"No latest version found for OS '" + os + "'");
}
downloadUrl = version.getUrl();
} catch (final IOException ex) {
throw new MojoExecutionException(
"Error parsing the event store version file", ex);
}
}
示例13: initUsingVersion
import org.apache.commons.exec.OS; //导入方法依赖的package包/类
private void initUsingVersion() throws MojoExecutionException {
// Make sure base URL always ends with a slash
if (!baseUrl.endsWith("/")) {
baseUrl = baseUrl + "/";
}
// Supply variables that are OS dependent
if (OS.isFamilyWindows()) {
if (archiveName == null) {
archiveName = "EventStore-OSS-Win";
}
if (archiveExtension == null) {
archiveExtension = "zip";
}
} else if (OS.isFamilyMac()) {
if (archiveName == null) {
archiveName = "EventStore-OSS-Mac";
}
if (archiveExtension == null) {
archiveExtension = "tar.gz";
}
} else if (OS.isFamilyUnix()) {
if (archiveName == null) {
if (isUbuntuVersion()) {
archiveName = "EventStore-OSS-Ubuntu-14.04";
} else {
archiveName = "EventStore-OSS-Linux";
}
}
if (archiveExtension == null) {
archiveExtension = "tar.gz";
}
} else {
if (archiveName == null) {
throw new MojoExecutionException(
"Unknown OS - You must use the 'archive-name' parameter");
}
if (archiveExtension == null) {
throw new MojoExecutionException(
"Unknown OS - You must use the 'archive-ext' parameter");
}
}
downloadUrl = baseUrl + archiveName + "-v" + archiveVersion + "."
+ archiveExtension;
}
示例14: main
import org.apache.commons.exec.OS; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
SeleniumJavaRobot seleniumJavaRobot = new SeleniumJavaRobot();
String browser;
seleniumJavaRobot.autoRestart = false;
if (OS.isFamilyMac()) {
browser = "safari";
} else {
browser = "firefox";
}
seleniumJavaRobot.url = "http://localhost:7777/__attester__/slave.html";
String usageString = String
.format("Usage: selenium-java-robot [options]\nOptions:\n --auto-restart\n --url <url> [default: %s]\n --browser <browser> [default: %s, accepted values: %s]\n -DpropertyName=value",
seleniumJavaRobot.url, browser, BROWSERS_LIST.toString());
for (int i = 0, l = args.length; i < l; i++) {
String curParam = args[i];
if ("--browser".equalsIgnoreCase(curParam) && i + 1 < l) {
browser = args[i + 1];
i++;
} else if ("--url".equalsIgnoreCase(curParam) && i + 1 < l) {
seleniumJavaRobot.url = args[i + 1];
i++;
} else if ("--auto-restart".equalsIgnoreCase(curParam)) {
seleniumJavaRobot.autoRestart = true;
} else if ("--version".equalsIgnoreCase(curParam)) {
System.out.println(Main.class.getPackage().getImplementationVersion());
return;
} else if ("--help".equalsIgnoreCase(curParam)) {
System.out.println(usageString);
return;
} else {
Matcher matcher = SET_SYSTEM_PROPERTY_REGEXP.matcher(curParam);
if (matcher.matches()) {
System.setProperty(matcher.group(1), matcher.group(2));
} else {
System.err.println("Unknown command line option: " + curParam);
System.err.println(usageString);
return;
}
}
}
seleniumJavaRobot.robotizedBrowserFactory = LocalRobotizedBrowserFactory.createRobotizedWebDriverFactory(browser);
seleniumJavaRobot.start();
closeOnStreamEnd(seleniumJavaRobot, System.in);
closeOnProcessEnd(seleniumJavaRobot);
}