diff --git a/app/femr/business/services/system/UpdatesService.java b/app/femr/business/services/system/UpdatesService.java index 0c3b02d2d..7ac00bb9d 100644 --- a/app/femr/business/services/system/UpdatesService.java +++ b/app/femr/business/services/system/UpdatesService.java @@ -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; @@ -83,7 +85,14 @@ public ServiceResponse> updateNetworkStatuses() ServiceResponse> response = new ServiceResponse<>(); ArrayList 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)); diff --git a/app/femr/ui/controllers/BackEndControllerHelper.java b/app/femr/ui/controllers/BackEndControllerHelper.java index 0b4480566..c9e8292f8 100644 --- a/app/femr/ui/controllers/BackEndControllerHelper.java +++ b/app/femr/ui/controllers/BackEndControllerHelper.java @@ -23,7 +23,12 @@ public static void executePythonScript(String absPath) { public static ArrayList executeSpeedTestScript(String absPath) { ArrayList 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")); diff --git a/app/femr/ui/views/admin/updates/manage.scala.html b/app/femr/ui/views/admin/updates/manage.scala.html index bbc6a9cdc..0d4277540 100644 --- a/app/femr/ui/views/admin/updates/manage.scala.html +++ b/app/femr/ui/views/admin/updates/manage.scala.html @@ -20,7 +20,6 @@ @downloadSpeed = @{ viewModel.getNetworkStatus.get("Download").split(" ")(0).toFloat.toInt } - @admin("Updates", currentUser, styles = additionalStyles, assets = assets, message = additionalMessages) {
diff --git a/docker-compose.yml b/docker-compose.yml index c37c3cafb..fb15e39d1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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