From ea7997c6256bf0085fb9f87204a79ab13a8750c1 Mon Sep 17 00:00:00 2001 From: Laurent Clouet Date: Wed, 17 Dec 2014 21:47:31 +0000 Subject: [PATCH] Improvement: check if the OS and the GPU are supported by the application --- src/com/sheepit/client/Client.java | 10 ++++++++++ src/com/sheepit/client/Configuration.java | 15 +++++++++++++++ src/com/sheepit/client/Error.java | 6 ++++++ src/com/sheepit/client/hardware/cpu/CPU.java | 7 ++++++- 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/com/sheepit/client/Client.java b/src/com/sheepit/client/Client.java index adc68cf..1ed690d 100644 --- a/src/com/sheepit/client/Client.java +++ b/src/com/sheepit/client/Client.java @@ -93,6 +93,16 @@ public class Client { } public int run() { + if (this.config.checkOSisSupported() == false) { + this.gui.error(Error.humanString(Error.Type.OS_NOT_SUPPORTED)); + return -3; + } + + if (this.config.checkCPUisSUpported() == false) { + this.gui.error(Error.humanString(Error.Type.CPU_NOT_SUPPORTED)); + return -4; + } + int step; try { step = this.log.newCheckPoint(); diff --git a/src/com/sheepit/client/Configuration.java b/src/com/sheepit/client/Configuration.java index 49492fc..538bc9d 100644 --- a/src/com/sheepit/client/Configuration.java +++ b/src/com/sheepit/client/Configuration.java @@ -29,7 +29,9 @@ import java.util.Calendar; import java.util.LinkedList; import java.util.List; +import com.sheepit.client.hardware.cpu.CPU; import com.sheepit.client.hardware.gpu.GPUDevice; +import com.sheepit.client.os.OS; public class Configuration { public enum ComputeType { @@ -277,4 +279,17 @@ public class Configuration { return ""; } } + + public boolean checkOSisSupported() { + return OS.getOS() != null; + } + + public boolean checkCPUisSUpported() { + OS os = OS.getOS(); + if (os != null) { + CPU cpu = os.getCPU(); + return cpu != null && cpu.haveData(); + } + return false; + } } diff --git a/src/com/sheepit/client/Error.java b/src/com/sheepit/client/Error.java index eb764a2..b1b6053 100644 --- a/src/com/sheepit/client/Error.java +++ b/src/com/sheepit/client/Error.java @@ -35,6 +35,8 @@ public class Error { RENDERER_KILLED, RENDERER_MISSING_LIBRARIES, FAILED_TO_EXECUTE, + OS_NOT_SUPPORTED, + CPU_NOT_SUPPORTED, UNKNOWN }; @@ -127,6 +129,10 @@ public class Error { return "The renderer stopped because either you asked to stop or the server did (usually for a render time too high)."; case SESSION_DISABLED: return "The server have disabled your session. Your client may have generated a broken frame (GPU not compatible, not enough RAM/VRAM, etc)."; + case OS_NOT_SUPPORTED: + return "Operating System not supported."; + case CPU_NOT_SUPPORTED: + return "CPU not supported."; default: return in.toString(); } diff --git a/src/com/sheepit/client/hardware/cpu/CPU.java b/src/com/sheepit/client/hardware/cpu/CPU.java index e114b8d..7939413 100644 --- a/src/com/sheepit/client/hardware/cpu/CPU.java +++ b/src/com/sheepit/client/hardware/cpu/CPU.java @@ -77,7 +77,12 @@ public class CPU { this.arch = "64bit"; } else { - this.arch = "xxbit"; + this.arch = null; } } + + public boolean haveData() { + return this.name != null && this.model != null && this.family != null && this.arch != null; + } + }