[chronojump/chronojump-importer] It actually imports (it still has a few hard coded paths).



commit c51476aa7932582aedab929ead9cab4ebfc34b42
Author: Carles Pina i Estany <carles pina cat>
Date:   Tue Sep 13 10:20:45 2016 +0100

    It actually imports (it still has a few hard coded paths).

 src/gui/chronojump.cs |   39 ++++++++++++++++++++++++++++++++++++++-
 src/gui/session.cs    |    4 ++++
 2 files changed, 42 insertions(+), 1 deletions(-)
---
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 3cbf7f4..e2d5768 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -33,6 +33,7 @@ using LongoMatch.Video.Capturer;
 using LongoMatch.Video.Common;
 using LongoMatch.Video.Utils;
 using System.Threading;
+using System.Diagnostics;
 
 public partial class ChronoJumpWindow 
 {
@@ -2609,7 +2610,43 @@ public partial class ChronoJumpWindow
        private void on_load_session_accepted_to_import(object o, EventArgs args)
        {
                int sessionNumber = sessionLoadWin.CurrentSessionId();
-               // TODO needs to import this session number
+               string databasePath = sessionLoadWin.DatabasePath();
+               LogB.Information (databasePath);
+
+               ImportSessionFromDatabase (databasePath, sessionNumber);
+       }
+
+       private void ImportSessionFromDatabase(string databasePath, int sessionNumber)
+       {
+               string pythonInterpreter = "/usr/bin/python3";
+               string importerPath = 
"/home/carles/git/chronojump/src/chronojump-importer/chronojump_importer.py";
+               string source_filename = databasePath;
+               string destination_filename = "/home/carles/.local/share/Chronojump/database/chronojump.db";
+               string session = Convert.ToString (sessionNumber);;
+
+               Process process = new Process();
+               ProcessStartInfo processStartInfo;
+
+               processStartInfo = new ProcessStartInfo();
+
+               processStartInfo.Arguments = importerPath + " --source " + source_filename + " --destination 
" + destination_filename + " --source_session " + session;
+               processStartInfo.FileName = pythonInterpreter;
+
+               processStartInfo.CreateNoWindow = true;
+               processStartInfo.UseShellExecute = false;
+               processStartInfo.RedirectStandardInput = false;
+               processStartInfo.RedirectStandardError = false;
+               processStartInfo.RedirectStandardOutput = true;
+               process.OutputDataReceived += new DataReceivedEventHandler(
+                       (s, e) =>
+                       { 
+                               Console.WriteLine(e.Data); 
+                       }
+               );
+               process.StartInfo = processStartInfo;
+               process.Start();
+               process.BeginOutputReadLine();
+               process.WaitForExit();
        }
 
        private void on_open_activate (object o, EventArgs args) 
diff --git a/src/gui/session.cs b/src/gui/session.cs
index 10c23a6..4d33425 100644
--- a/src/gui/session.cs
+++ b/src/gui/session.cs
@@ -930,6 +930,10 @@ public class SessionLoadWindow {
                }
                return -1;
        }
+
+       public string DatabasePath() {
+               return entry_path.Text;
+       }
        
        void on_row_double_clicked (object o, Gtk.RowActivatedArgs args)
        {


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