Task #1346

TBX: x.x, Improve the OS detection

Added by Sebastien Jacquot about 4 years ago. Updated about 4 years ago.

Status:Feedback Start date:05/20/2015
Priority:Normal Due date:
Assignee:- % Done:

80%

Category:Development Spent time: -
Target version:TXM 0.7.7

Description

OS detection in TBX is actually done by strings comparison and used in various places, e.g. System.getProperty("os.name").contains("win32") for Windows.
On some systems, System.getProperty("os.name") now returns "Windows 7" on Windows 7 OS leading to a failure of R/CQP launching on Win 7 because the Linux launching native code is executed instead of Win native code. Result in log is:

Failed to start RServe : org.txm.stat.engine.r.RWorkspaceException: ** The Statistics Engine program path is set but we couldn't find it : C:\XXXXXX\R\bin\R.exe

Solution 1

  • use org.ecplise.core.runtime.Platform.getOS()
  • bundle is present in TBX project
  • NOTE to clarify this issue: using Platform.getOS() in TBX layer leads to an Eclipse classloader problem in TXM Web/Portal layer. This solution 1 was used since revision 2967. To fix these classloader problems, the use of System.getProperty("os.name").contains("win32") comparison has been introduced in r2967 leading to the Windows bug detailed above.
    In future we should use this Platform class which really seems a better solution.

Solution 2

  • use org.apache.tools.ant.taskdefs.condition.Os
  • bundle is present in TBX project

Solution 3

  • org.apache.commons.exec.OS
  • bundle is NOT present in TBX project

Solution 4

  • implement own custom class using System.getProperty("os.name")

Solution 5

  • use solution 1, 2 or 3
  • centralize/encapsulate the OS detection code in a class, e.g. OSDetector in TBX layer to minimize impact of further string definition potential changes

Validation tests

  • start TXM on Linux
  • look for the following line in the console log:
    => "Statistical Engine launched."
  • create an AFC chart
  • start TXM on Windows
  • look for the following line in the console log:
    => "Statistical Engine launched."
  • create an AFC chart
  • start TXM on Mac
  • look for the following line in the console log:
    => "Statistical Engine launched."
  • create an AFC chart

History

#1 Updated by Sebastien Jacquot about 4 years ago

  • Description updated (diff)

#2 Updated by Sebastien Jacquot about 4 years ago

  • Description updated (diff)

#3 Updated by Sebastien Jacquot about 4 years ago

  • Description updated (diff)

#4 Updated by Sebastien Jacquot about 4 years ago

  • Status changed from New to Feedback
  • % Done changed from 0 to 80

Solutions 2 and 5 have been implemented. The /org.txm.toolbox/src/java/org/txm/utils/OSDetector.java class is now used in ToolBox when creating start and kill command lines for RServe and CQP, replacing the System.getProperty("os.name").contains("win32") tests. It is also used in the ToolBox initialization method to load TBX preferences file as "ISO-8859-1" for Windows family runtime target, replacing the System.getProperty("os.name").contains("win32") test.

#5 Updated by Sebastien Jacquot about 4 years ago

  • Description updated (diff)

#6 Updated by Sebastien Jacquot about 4 years ago

  • Description updated (diff)

#7 Updated by Sebastien Jacquot about 4 years ago

  • Description updated (diff)

Also available in: Atom PDF