mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-20 00:51:41 +00:00
Fix isRaspian() to properly detect Buster image (#637)
* Revised isRaspian() call to look in multiple spots to check if we're a Pi or not * wpiformat * linefeed fixup * whoops * WIP updating platform * More platform fixups WIP * Condensed metrics classes, but expanded the configuration to default to file, but fall back on hardcoded commands for certain platforms * Migrate unixSupported to isLinux * applied spotless * wpiformat * Linux metrics (#641) * Move generic commands from PiCmds to LinuxCmds; have PiCmds inherit from LinuxCmds * Better names for variables to save the total memory values * Remove "Bionic" from the architecture; that is not actually determined. * Trigger PhotonVision CI * Dummy change to trigger CI * Run format Update index.html Co-authored-by: Mohammad Durrani <46766905+mdurrani808@users.noreply.github.com> Co-authored-by: Paul Rensing <prensing@gmail.com> Co-authored-by: Matt <matthew.morley.ca@gmail.com>
This commit is contained in:
@@ -29,6 +29,7 @@ import org.photonvision.common.configuration.CameraConfiguration;
|
||||
import org.photonvision.common.configuration.ConfigManager;
|
||||
import org.photonvision.common.dataflow.networktables.NetworkTablesManager;
|
||||
import org.photonvision.common.hardware.HardwareManager;
|
||||
import org.photonvision.common.hardware.PiVersion;
|
||||
import org.photonvision.common.hardware.Platform;
|
||||
import org.photonvision.common.logging.LogGroup;
|
||||
import org.photonvision.common.logging.LogLevel;
|
||||
@@ -321,8 +322,8 @@ public class Main {
|
||||
"Starting PhotonVision version "
|
||||
+ PhotonVersion.versionString
|
||||
+ " on "
|
||||
+ Platform.currentPlatform.toString()
|
||||
+ (Platform.isRaspberryPi() ? (" (Pi " + Platform.currentPiVersion.name() + ")") : ""));
|
||||
+ Platform.getPlatformName()
|
||||
+ (Platform.isRaspberryPi() ? (" (Pi " + PiVersion.getPiVersion() + ")") : ""));
|
||||
|
||||
ConfigManager.getInstance().load(); // init config manager
|
||||
ConfigManager.getInstance().requestSave();
|
||||
|
||||
@@ -35,7 +35,6 @@ import org.photonvision.common.configuration.NetworkConfig;
|
||||
import org.photonvision.common.dataflow.networktables.NetworkTablesManager;
|
||||
import org.photonvision.common.hardware.HardwareManager;
|
||||
import org.photonvision.common.hardware.Platform;
|
||||
import org.photonvision.common.hardware.metrics.MetricsPublisher;
|
||||
import org.photonvision.common.logging.LogGroup;
|
||||
import org.photonvision.common.logging.Logger;
|
||||
import org.photonvision.common.networking.NetworkManager;
|
||||
@@ -113,37 +112,29 @@ public class RequestHandler {
|
||||
logger.info("New .jar uploaded successfully.");
|
||||
|
||||
if (file != null) {
|
||||
if (Platform.isLinux()) {
|
||||
try {
|
||||
Path filePath =
|
||||
Paths.get(ProgramDirectoryUtilities.getProgramDirectory(), "photonvision.jar");
|
||||
File targetFile = new File(filePath.toString());
|
||||
var stream = new FileOutputStream(targetFile);
|
||||
try {
|
||||
Path filePath =
|
||||
Paths.get(ProgramDirectoryUtilities.getProgramDirectory(), "photonvision.jar");
|
||||
File targetFile = new File(filePath.toString());
|
||||
var stream = new FileOutputStream(targetFile);
|
||||
|
||||
logger.info(
|
||||
"Streaming user-provided " + file.getFilename() + " into " + targetFile.toString());
|
||||
logger.info(
|
||||
"Streaming user-provided " + file.getFilename() + " into " + targetFile.toString());
|
||||
|
||||
file.getContent().transferTo(stream);
|
||||
stream.close();
|
||||
file.getContent().transferTo(stream);
|
||||
stream.close();
|
||||
|
||||
ctx.status(200);
|
||||
logger.info("New .jar in place, going down for restart...");
|
||||
restartProgram();
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
logger.error(
|
||||
".jar of this program could not be found. How the heck this program started in the first place is a mystery.");
|
||||
ctx.status(500);
|
||||
} catch (IOException e) {
|
||||
logger.error("Could not overwrite the .jar for this instance of photonvision.");
|
||||
ctx.status(500);
|
||||
}
|
||||
|
||||
} else {
|
||||
logger.error("Hot .jar replace currently only supported on Linux. Ignoring.");
|
||||
ctx.status(200);
|
||||
logger.info("New .jar in place, going down for restart...");
|
||||
restartProgram();
|
||||
} catch (FileNotFoundException e) {
|
||||
logger.error(
|
||||
".jar of this program could not be found. How the heck this program started in the first place is a mystery.");
|
||||
ctx.status(500);
|
||||
} catch (IOException e) {
|
||||
logger.error("Could not overwrite the .jar for this instance of photonvision.");
|
||||
ctx.status(500);
|
||||
}
|
||||
|
||||
} else {
|
||||
logger.error("Couldn't read provided file for new .jar! Ignoring.");
|
||||
ctx.status(500);
|
||||
@@ -274,7 +265,7 @@ public class RequestHandler {
|
||||
}
|
||||
|
||||
public static void sendMetrics(Context ctx) {
|
||||
MetricsPublisher.getInstance().publish();
|
||||
HardwareManager.getInstance().publishMetrics();
|
||||
// TimedTaskManager.getInstance().addOneShotTask(() -> RoborioFinder.getInstance().findRios(),
|
||||
// 0);
|
||||
ctx.status(200);
|
||||
|
||||
Reference in New Issue
Block a user