[chronojump/chronojump-importer: 65/66] Finds the chronojump_importer.py instead of assuming that will be in the path.



commit d2b20bfb4f85dcccb43ce839eb341a5c7caa0c02
Author: Carles Pina i Estany <carles pina cat>
Date:   Tue Sep 27 00:15:15 2016 +0200

    Finds the chronojump_importer.py instead of assuming that will be in the path.

 src/gui/chronojump.cs |    9 +++++----
 src/utilEncoder.cs    |   11 +++++------
 2 files changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index f53726e..c3fcf68 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -2405,18 +2405,19 @@ public partial class ChronoJumpWindow
 
        private void ImportSessionFromDatabase(string databasePath, int sessionNumber)
        {
-               string importerPath = UtilEncoder.GetChronojumpImporter ();
+               string pythonExecutable = UtilEncoder.GetPythonExecutable ();
                string source_filename = databasePath;
                string destination_filename = Sqlite.DatabaseFilePath;
-               string session = Convert.ToString (sessionNumber);;
+               string session = Convert.ToString (sessionNumber);
+               string importer_executable = System.IO.Path.Combine (Util.GetPrefixDir (), "bin" + 
Path.DirectorySeparatorChar + "chronojump_importer.py");
 
                Process process = new Process();
                ProcessStartInfo processStartInfo;
 
                processStartInfo = new ProcessStartInfo();
 
-               processStartInfo.Arguments = " --source " + source_filename + " --destination " + 
destination_filename + " --source_session " + session;
-               processStartInfo.FileName = importerPath;
+               processStartInfo.Arguments = importer_executable + " --source " + source_filename + " 
--destination " + destination_filename + " --source_session " + session;
+               processStartInfo.FileName = pythonExecutable;
 
                LogB.Debug ("chronojump-importer fileName:" + processStartInfo.FileName);
                LogB.Debug ("chronojump-importer Arguments:" + processStartInfo.Arguments);
diff --git a/src/utilEncoder.cs b/src/utilEncoder.cs
index 185363c..df161bb 100644
--- a/src/utilEncoder.cs
+++ b/src/utilEncoder.cs
@@ -178,15 +178,14 @@ public class UtilEncoder
                return false;
        }
        
-       public static string GetChronojumpImporter() {
+       public static string GetPythonExecutable() {
                if (UtilAll.IsWindows ()) {
-                       // TODO
-                       return "";
+                       //on Windows we need the \"str\" to call without problems in path with spaces
+                       return  "\"" + System.IO.Path.Combine(Util.GetPrefixDir(), "python3" + 
Path.DirectorySeparatorChar + "python.exe") + "\"";
                } else {
-                       // It's installed in the PATH.
-                       return "chronojump_importer.py";
+                       // We assume that it's installed in the PATH and that we don't care if it's Python2 
or Python3
+                       return "python";
                }
-               // What about OSX?
        }
 
        /*      


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