[chronojump] Better check of R on OSX and cannot run "Power" without it



commit 140a99ebfcb40d92f22d242a4cd52fbe8aec326e
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Dec 25 22:19:53 2015 +0100

    Better check of R on OSX and cannot run "Power" without it

 src/constants.cs      |    9 +++++++++
 src/encoderRProc.cs   |    8 +-------
 src/gui/chronojump.cs |   11 +++++++++++
 src/gui/encoder.cs    |    3 ++-
 src/stats/main.cs     |    3 ++-
 src/util.cs           |    2 ++
 6 files changed, 27 insertions(+), 9 deletions(-)
---
diff --git a/src/constants.cs b/src/constants.cs
index f9ab3db..9b75183 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -689,6 +689,15 @@ public class Constants
         * chronojump / encoder / sessionID / graphs
         */
        
+       /*
+        * The installer as from R 3.2.2 puts links to R and Rscript
+        * in /usr/bin (Mavericks, Yosemite) or /usr/local/bin (El Capitan and later).
+        * If these are missing, you can run directly the versions in 
/Library/Frameworks/R.framework/Resources/.
+        * https://cran.r-project.org/doc/manuals/r-devel/R-admin.pdf
+        */
+       public static string ROSX = "/Library/Frameworks/R.framework/Resources/R";
+       public static string RScriptOSX = "/Library/Frameworks/R.framework/Resources/RScript";
+       
        //public static string EncoderScriptCapturePythonLinux = "pyserial_pyper.py";
        //public static string EncoderScriptCapturePythonWindows = "pyserial_pyper_windows.exe";
        public static string EncoderScriptCallCaptureNoRDotNet = "call_capture.R";
diff --git a/src/encoderRProc.cs b/src/encoderRProc.cs
index a56c142..5a20242 100644
--- a/src/encoderRProc.cs
+++ b/src/encoderRProc.cs
@@ -166,13 +166,7 @@ public abstract class EncoderRProc
                }
                else if(UtilAll.GetOSEnum() == UtilAll.OperatingSystems.MACOSX)
                {
-                       /*
-                        * The installer as from R 3.2.2 puts links to R and Rscript
-                        * in /usr/bin (Mavericks, Yosemite) or /usr/local/bin (El Capitan and later).
-                        * If these are missing, you can run directly the versions in 
/Library/Frameworks/R.framework/Resources/.
-                        * https://cran.r-project.org/doc/manuals/r-devel/R-admin.pdf
-                        */
-                       pBin = "/Library/Frameworks/R.framework/Resources/Rscript.exe";
+                       pBin = Constants.RScriptOSX;
                }
 
                LogB.Information("pBin:", pBin);
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index d413af7..6261729 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -2987,6 +2987,17 @@ public partial class ChronoJumpWindow
                        menuitem_mode_selected_runs.Visible = true;
                        radio_mode_runs_small.Active = true;
                } else if(m == menuitem_modes.POWER) {
+                       //on OSX R is not installed by default. Check if it's installed. Needed for encoder
+                       if( UtilAll.GetOSEnum() == UtilAll.OperatingSystems.MACOSX &&
+                                       ! Util.FileExists(Constants.ROSX) )
+                       {
+                               new DialogMessage(Constants.MessageTypes.WARNING,
+                                               Catalog.GetString("Sorry, R software is not installed.") +
+                                               "\n" + Catalog.GetString("Please, install it from here:") +
+                                               "\n\nhttp://cran.cnr.berkeley.edu/bin/macosx/R-latest.pkg";);
+                               return;
+                       }
+
                        notebook_sup.CurrentPage = 1;
                        menuitem_mode_selected_power.Visible = true;
                } else {        //m == menuitem_modes.OTHER (contacts / other)
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 6c8258e..4352d1b 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -5273,7 +5273,8 @@ public partial class ChronoJumpWindow
                                        new DialogMessage(Constants.MessageTypes.WARNING, 
                                                        Catalog.GetString("Sorry. Error doing graph.") + 
                                                        "\n" + Catalog.GetString("Maybe R is not installed.") 
+ 
-                                                       "\n\nhttp://www.r-project.org/";);
+                                                       "\n" + Catalog.GetString("Please, install it from 
here:") +
+                                                       
"\n\nhttp://cran.cnr.berkeley.edu/bin/macosx/R-latest.pkg";);
                                        encoderProcessProblems = false;
                                } else {
                                        if(action == encoderActions.CAPTURE_IM)
diff --git a/src/stats/main.cs b/src/stats/main.cs
index b47b545..89473bd 100644
--- a/src/stats/main.cs
+++ b/src/stats/main.cs
@@ -1514,7 +1514,8 @@ public class Stat
                                new DialogMessage(Constants.MessageTypes.WARNING, 
                                                Catalog.GetString("Sorry. Error doing graph.") + 
                                                "\n" + Catalog.GetString("Maybe R is not installed.") + 
-                                               "\n\nhttp://www.r-project.org/";);
+                                               "\n" + Catalog.GetString("Please, install it from here:") +
+                                               "\n\nhttp://cran.cnr.berkeley.edu/bin/macosx/R-latest.pkg";);
                        else
                                new DialogImageTest(Catalog.GetString("Chronojump Graph"), fileName, 
DialogImageTest.ArchiveType.FILE);
                }
diff --git a/src/util.cs b/src/util.cs
index a7becef..dbf99e2 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -1128,6 +1128,8 @@ public class Util
  
                if (UtilAll.IsWindows())
                        rBin=System.IO.Path.Combine(GetPrefixDir(), "bin/R.exe");
+               else if(UtilAll.GetOSEnum() == UtilAll.OperatingSystems.MACOSX)
+                       rBin = Constants.ROSX;
 
                pinfo = new ProcessStartInfo();
                pinfo.FileName=rBin;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]