Skip to content

Commit

Permalink
Added compatibility for running refresh internet status in docker and…
Browse files Browse the repository at this point in the history
… IDE
  • Loading branch information
bholt13 committed Nov 18, 2024
1 parent 5e2cff5 commit 2182a54
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
11 changes: 10 additions & 1 deletion app/femr/business/services/system/UpdatesService.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.UnresolvedPermission;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -83,7 +85,14 @@ public ServiceResponse<List<? extends INetworkStatus>> updateNetworkStatuses()
ServiceResponse<List<? extends INetworkStatus>> response = new ServiceResponse<>();
ArrayList<String> data = new ArrayList<>();
try {
data = BackEndControllerHelper.executeSpeedTestScript("/usr/src/speedtest/sptest.py");
String isDocker = System.getenv("IS_DOCKER");
if("true".equals(isDocker)) { //running in docker
data = BackEndControllerHelper.executeSpeedTestScript("/usr/src/speedtest/sptest.py");
}else{ //running in IDE
Path speedPath = Paths.get(System.getProperty("user.dir"), "speedtest", "sptest.py");
data = BackEndControllerHelper.executeSpeedTestScript(speedPath.toString());
}
//data = BackEndControllerHelper.executeSpeedTestScript("/usr/src/speedtest/sptest.py");
//data = BackEndControllerHelper.executeSpeedTestScript("speedtest/sptest.py");
//Update Status
Float Ping = Float.parseFloat(data.get(2));
Expand Down
7 changes: 6 additions & 1 deletion app/femr/ui/controllers/BackEndControllerHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ public static void executePythonScript(String absPath) {
public static ArrayList<String> executeSpeedTestScript(String absPath) {
ArrayList<String> speedInfo = new ArrayList<>();
try {
ProcessBuilder pb = new ProcessBuilder("python3", absPath);
ProcessBuilder pb;
if(absPath.equals("/usr/src/speedtest/sptest.py")){
pb = new ProcessBuilder("python3", absPath);
}else{
pb = new ProcessBuilder("python", absPath);
}
Process p = pb.start();
BufferedReader bfr = new BufferedReader(new InputStreamReader(p.getInputStream(), "UTF-8"));

Expand Down
1 change: 0 additions & 1 deletion app/femr/ui/views/admin/updates/manage.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

@downloadSpeed = @{ viewModel.getNetworkStatus.get("Download").split(" ")(0).toFloat.toInt }


@admin("Updates", currentUser, styles = additionalStyles, assets = assets, message = additionalMessages) {

<div id="updates-content">
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ services:
DB_URL: 'jdbc:mysql://db:3306/femr_db?characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true'
DB_USER: 'femr'
DB_PASS: 'password'
IS_DOCKER: 'true'

volumes:
- ./speedtest:/usr/src/speedtest
Expand Down

0 comments on commit 2182a54

Please sign in to comment.