Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

Refactoring Javadoc and methods/variables names. #29

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
dd446b8
Refactoring CommandRunner class and updating its documentation. For t…
clebersa Feb 15, 2016
985c84b
Refactoring FileSystem class and updating its documentation. For this…
clebersa Feb 15, 2016
2bda26f
Refactoring Injector class. For this refactoring, the contants and me…
clebersa Feb 15, 2016
ec38aca
Updating documentation of the class Lifetimes. For this updating, the…
clebersa Feb 15, 2016
0b294b3
Refactoring Messenger class and updating its documentation. For this …
clebersa Feb 15, 2016
f60732f
Refactoring Moe class and updating its documentation. For this refact…
clebersa Feb 15, 2016
eef9fac
Refacotoring MeoModule class. For this refactoring, the methods were …
clebersa Feb 15, 2016
2c7c5e3
Refactoring the MeoProblem class. For this refactoring, the class doc…
clebersa Feb 15, 2016
78b4d7c
Refacotring and updating documentation of the MoeUserProblem class. T…
clebersa Feb 15, 2016
1c74af9
Refactoring MeoUserProblem class. For this refactoring, a param tag w…
clebersa Feb 15, 2016
f75c5ed
Adding comments to the functions of SystemCommandRunner and its priva…
clebersa Feb 23, 2016
7de134e
Adding javadoc comments to the SystemFileSytem methods. Renaming meth…
clebersa Feb 23, 2016
297e244
Adding javadoc comments to the class SystemUi. Renaming methods param…
clebersa Feb 23, 2016
443b2fd
Refactoring the Ui class. Some methods had the name changed to action…
clebersa Feb 24, 2016
2b10d4e
Adding Google licence header to the Task class file.
clebersa Feb 24, 2016
43a88b1
Refactoring Utils class by adding javadoc comments to the methods.
clebersa Feb 24, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions java/com/google/devtools/moe/client/CommandException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2011 Google, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.devtools.moe.client;

import java.util.Collections;
import java.util.List;

/**
* A class responsible for storing the information about the exception for a
* command execution.
*/
public class CommandException extends Exception {

public final String COMMAND;
public final List<String> ARGS;
public final String STDOUT;
public final String STDERR;
public final int RETURN_STATUS;

public CommandException(String command, List<String> args, String stdout,
String stderr, int returnStatus) {
super(String.format(
"Running %s with args %s returned %d with stdout %s and stderr %s",
command,
args,
returnStatus,
stdout,
stderr));
this.COMMAND = command;
this.ARGS = Collections.unmodifiableList(args);
this.STDOUT = stdout;
this.STDERR = stderr;
this.RETURN_STATUS = returnStatus;
}
}
39 changes: 39 additions & 0 deletions java/com/google/devtools/moe/client/CommandOutput.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2011 Google, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.devtools.moe.client;

/**
* The complete result, including stdout and stderr, of running a command.
*/
public class CommandOutput {

private final String stdout;
private final String stderr;

public CommandOutput(String stdout, String stderr) {
this.stdout = stdout;
this.stderr = stderr;
}

public String getStdout() {
return stdout;
}

public String getStderr() {
return stderr;
}
}
79 changes: 16 additions & 63 deletions java/com/google/devtools/moe/client/CommandRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,84 +16,37 @@

package com.google.devtools.moe.client;

import java.util.Collections;
import java.util.List;

/**
* A wrapper around call-outs to out-of-process executable programs.
*/
public interface CommandRunner {

public static class CommandException extends Exception {
public final String cmd;
public final List<String> args;
public final String stdout;
public final String stderr;
public final int returnStatus;

public CommandException(
String cmd, List<String> args, String stdout, String stderr, int returnStatus) {
super(
String.format(
"Running %s with args %s returned %d with stdout %s and stderr %s",
cmd,
args,
returnStatus,
stdout,
stderr));
this.cmd = cmd;
this.args = Collections.unmodifiableList(args);
this.stdout = stdout;
this.stderr = stderr;
this.returnStatus = returnStatus;
}
}

/**
* The complete result, including stdout and stderr, of running a command.
*/
public static class CommandOutput {
private final String stdout;
private final String stderr;

public CommandOutput(String stdout, String stderr) {
this.stdout = stdout;
this.stderr = stderr;
}

public String getStdout() {
return stdout;
}

public String getStderr() {
return stderr;
}
}

/**
* Runs a command.
*
* @param cmd the binary to invoke. If not a path, it will be resolved.
* @param args the arguments to pass to the binary
* @param workingDirectory the directory to run in
*
* @returns the output of the command
* @throws CommandException
*
* TODO(dbentley): make it easier to do error-handling
* @param command the binary to invoke. If not a path, it will be resolved.
* @param args the arguments to pass to the binary.
* @param workingDirectory the directory to run in.
*
* @return the output of the command.
* @throws CommandException if some error occurs in the command execution.
*/
String runCommand(String cmd, List<String> args, String workingDirectory) throws CommandException;
// TODO(dbentley): make it easier to do error-handling
public String runCommand(String command, List<String> args, String workingDirectory)
throws CommandException;

/**
* Runs a command.
*
* @param cmd the binary to invoke. If not a path, it will be resolved.
* @param args the arguments to pass to the binary
* @param workingDirectory the directory to run in
* @param command the binary to invoke. If not a path, it will be resolved.
* @param args the arguments to pass to the binary.
* @param workingDirectory the directory to run in.
*
* @returns a {@link CommandOutput} with the full results of the command
* @throws CommandException
* @return a {@link CommandOutput} with the full results of the command.
* @throws CommandException if some error occurs in the command execution.
*/
CommandOutput runCommandWithFullOutput(String cmd, List<String> args, String workingDirectory)
throws CommandException;
public CommandOutput runCommandWithFullOutput(String command, List<String> args,
String workingDirectory) throws CommandException;
}
Loading