Compare commits
5 Commits
392d10c587
...
bf754c79d6
Author | SHA1 | Date | |
---|---|---|---|
bf754c79d6 | |||
d5e33d2a39 | |||
456348d520 | |||
769f80ec72 | |||
b6a6ec5e3a |
@ -27,8 +27,7 @@ public class LinuxScheduler {
|
||||
try {
|
||||
String taskName = "numbers-station-main_" + settings.getName();
|
||||
|
||||
// TODO: assume it's on the PATH
|
||||
Process listProcess = new ProcessBuilder("/usr/bin/crontab", "-l").start();
|
||||
Process listProcess = new ProcessBuilder("crontab", "-l").start();
|
||||
if (!listProcess.waitFor(5, TimeUnit.SECONDS)) {
|
||||
String message = "Failed to query " + taskName + " task: process timed out";
|
||||
logger.log(Level.SEVERE, message);
|
||||
@ -69,8 +68,7 @@ public class LinuxScheduler {
|
||||
|
||||
String newCrontab = sb.toString();
|
||||
|
||||
// TODO: assume it's on the PATH
|
||||
Process addProcess = new ProcessBuilder("/usr/bin/crontab", "-").start();
|
||||
Process addProcess = new ProcessBuilder("crontab", "-").start();
|
||||
Writer w = new OutputStreamWriter(addProcess.getOutputStream(), "UTF-8");
|
||||
System.out.println(newCrontab);
|
||||
w.write(newCrontab);
|
||||
@ -94,23 +92,6 @@ public class LinuxScheduler {
|
||||
return Results.failure(message);
|
||||
}
|
||||
|
||||
// Path cronDPath = Paths.get("/etc/cron.d");
|
||||
// if (!Files.exists(cronDPath)) {
|
||||
// String message = "/etc/cron.d does not exist, cannot create cron entry. Select 'Manage schedule externally' and set up scheduling as desired.";
|
||||
// logger.log(Level.SEVERE, message);
|
||||
// return Results.failure(message);
|
||||
// }
|
||||
|
||||
// Path cronPath = cronDPath.resolve(settings.safeName());
|
||||
|
||||
// try {
|
||||
// Files.write(cronPath, cronEntry(settings).getBytes(StandardCharsets.UTF_8));
|
||||
// } catch (Exception e) {
|
||||
// String message = "Failed to write cron file at '" + cronPath.toString() + "'";
|
||||
// logger.log(Level.SEVERE, message, e);
|
||||
// return Results.failure(message);
|
||||
// }
|
||||
|
||||
return Results.success(true);
|
||||
}
|
||||
|
||||
|
@ -181,22 +181,26 @@ public class MainController implements Initializable {
|
||||
stationNameField.textProperty().bindBidirectional(selectedStationName);
|
||||
nextSendTimeLabel.textProperty().bind(nextSendTime);
|
||||
|
||||
nextSendTime.set("sup brah");
|
||||
|
||||
Result<MainSettings, Exception> result = MainSettings.load();
|
||||
if (!result.hasSuccess()) {
|
||||
// TODO: on failure, prompt user to re-initialize settings
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR, "Unable to load settings file. See log for details. Reinitialize settings? This may overwrite existing settings.", ButtonType.YES, ButtonType.NO);
|
||||
alert.setTitle("Settings load error");
|
||||
alert.setHeaderText(null);
|
||||
alert.setContentText("Unable to load settings file");
|
||||
alert.showAndWait();
|
||||
Optional<ButtonType> promptResult = alert.showAndWait();
|
||||
|
||||
return;
|
||||
if (!promptResult.isPresent()) {
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
if (promptResult.get() == ButtonType.NO) {
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
settings = new MainSettings();
|
||||
} else {
|
||||
settings = result.getSuccess().get();
|
||||
}
|
||||
|
||||
settings = result.getSuccess().get();
|
||||
|
||||
selectedStationName.set(settings.getSelectedStationName());
|
||||
|
||||
if (selectedStationName.get() == null || selectedStationName.get() == "") {
|
||||
@ -209,8 +213,6 @@ public class MainController implements Initializable {
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
// TODO: if there are no stations, then create a default station and select that
|
||||
|
||||
if (selectedStation == null) {
|
||||
logger.log(Level.SEVERE, "Selected station '" + selectedStationName.get() + "' not found");
|
||||
selectedStation = settings.getStations().get(0);
|
||||
@ -315,8 +317,6 @@ public class MainController implements Initializable {
|
||||
|
||||
settings.save();
|
||||
|
||||
// TODO: Load message from file
|
||||
// If the message we're overwriting is different from its file, then prompt to confirm
|
||||
Path nextMessagePath = selectedStation.stationPath().resolve("next-message.txt");
|
||||
|
||||
String messageText;
|
||||
|
@ -462,8 +462,14 @@ public class StationSettingsController {
|
||||
} else if (osName.contains("nix") || osName.contains("nux") || osName.contains("aix")) {
|
||||
LinuxScheduler.registerSchedule(settings);
|
||||
} else {
|
||||
logger.log(Level.SEVERE, "Unsupported OS " + osName);
|
||||
// TODO: Alert
|
||||
String message = "Unsupported OS " + osName;
|
||||
logger.log(Level.SEVERE, message);
|
||||
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||
alert.setTitle(message);
|
||||
alert.setHeaderText(null);
|
||||
alert.setContentText(message);
|
||||
alert.showAndWait();
|
||||
}
|
||||
|
||||
Node node = (Node) e.getSource();
|
||||
|
@ -228,7 +228,6 @@ public class WindowsScheduler {
|
||||
logger.info("Executable Path: " + executablePath);
|
||||
|
||||
Element command = doc.createElement("Command");
|
||||
// TODO: need to figure out the real invocation
|
||||
command.appendChild(doc.createTextNode(executablePath.toString()));
|
||||
exec.appendChild(command);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user