Compare commits

...

3 Commits

Author SHA1 Message Date
Matt
a5cc0808c4 Make photon targeting respect snapshot repo (#309) 2021-11-06 20:12:50 -04:00
Banks T
08fafe2607 Fix file delete, possible null on perms set (#303) 2021-11-06 19:58:07 -04:00
Matt
a2af7d9273 Add red warning text with server mode, team number not set (#308) 2021-11-03 09:12:29 -04:00
3 changed files with 22 additions and 12 deletions

View File

@@ -4,11 +4,6 @@
ref="form"
v-model="valid"
>
<CVSwitch
v-model="runNTServer"
name="Run NetworkTables Server"
tooltip="If enabled, this device will create a NT server. This is useful for home debugging, but should be disabled on-robot."
/>
<CVnumberinput
v-model="teamNumber"
:disabled="settings.runNTServer"
@@ -16,6 +11,7 @@
:rules="[v => (v > 0) || 'Team number must be greater than zero', v => (v < 10000) || 'Team number must have fewer than five digits']"
class="mb-4"
/>
<span v-if="parseInt(teamNumber) < 1 && !runNTServer" class="red font-weight-bold">Team number not set! NetworkTables cannot connect.</span>
<CVradio
v-model="connectionType"
:list="['DHCP','Static']"
@@ -35,9 +31,18 @@
:rules="[v => isHostname(v) || 'Invalid hostname']"
name="Hostname"
/>
Advanced
<v-divider/>
<CVSwitch
v-model="runNTServer"
name="Run NetworkTables Server (Debugging Only!)"
tooltip="If enabled, this device will create a NT server. This is useful for home debugging, but should be disabled on-robot."
/>
<span v-if="runNTServer" class="red font-weight-bold">Disable this switch if you're on a robot! Photonlib will NOT work.</span>
</v-form>
<v-btn
color="accent"
:class="runNTServer ? 'mt-3' : ''"
style="color: black; width: 100%;"
:disabled="!valid && !runNTServer"
@click="sendGeneralSettings()"

View File

@@ -18,6 +18,7 @@
package org.photonvision.common.util.file;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -35,7 +36,7 @@ public class FileUtils {
private FileUtils() {}
private static Logger logger = new Logger(FileUtils.class, LogGroup.General);
private static final Logger logger = new Logger(FileUtils.class, LogGroup.General);
private static final Set<PosixFilePermission> allReadWriteExecutePerms =
new HashSet<>(Arrays.asList(PosixFilePermission.values()));
@@ -49,7 +50,7 @@ public class FileUtils {
.sorted(Comparator.reverseOrder())
.map(Path::toFile)
.filter(File::isFile)
.forEach(File::delete);
.forEach((var file) -> deleteFile(file.toPath()));
// close the stream
files.close();
@@ -61,8 +62,10 @@ public class FileUtils {
public static void deleteFile(Path path) {
try {
Files.delete(path);
} catch (FileNotFoundException fe) {
logger.warn("Tried to delete file \"" + path + "\" but it did not exist");
} catch (IOException e) {
logger.error("Exception deleting file " + path + "!", e);
logger.error("Exception deleting file \"" + path + "\"!", e);
}
}
@@ -80,10 +83,11 @@ public class FileUtils {
Set<PosixFilePermission> perms =
Files.readAttributes(path, PosixFileAttributes.class).permissions();
if (!perms.equals(allReadWriteExecutePerms)) {
logger.info("Setting perms on" + path.toString());
logger.info("Setting perms on" + path);
Files.setPosixFilePermissions(path, perms);
if (thisFile.isDirectory()) {
for (File subfile : thisFile.listFiles()) {
var theseFiles = thisFile.listFiles();
if (thisFile.isDirectory() && theseFiles != null) {
for (File subfile : theseFiles) {
setFilePerms(subfile.toPath());
}
}

View File

@@ -6,11 +6,12 @@ def baseArtifactId = 'PhotonTargeting'
publishing {
repositories {
maven {
url 'https://maven.photonvision.org/repository/internal'
url ('https://maven.photonvision.org/repository/' + (isDev ? 'snapshots' : 'internal'))
credentials {
username 'ghactions'
password System.getenv("ARTIFACTORY_API_KEY")
}
println("Publishing PhotonTargeting to " + url)
}
}