[chronojump/chronojump-importer] Installs the chronojump_importer.py correctly. Executes it correctly on Linux.
- From: Carles Pina i Estany <carlespina src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump/chronojump-importer] Installs the chronojump_importer.py correctly. Executes it correctly on Linux.
- Date: Tue, 13 Sep 2016 17:23:36 +0000 (UTC)
commit a6a22e52ea6419c310d890f05fbfdda2d1c75bb2
Author: Carles Pina i Estany <carles pina cat>
Date: Tue Sep 13 18:23:05 2016 +0100
Installs the chronojump_importer.py correctly. Executes it correctly on Linux.
src/chronojump-importer/Makefile.am | 7 ++-----
src/gui/chronojump.cs | 30 ++++++++++++++++++++++--------
src/utilEncoder.cs | 10 ++++++++++
3 files changed, 34 insertions(+), 13 deletions(-)
---
diff --git a/src/chronojump-importer/Makefile.am b/src/chronojump-importer/Makefile.am
index de0fc61..48f6ab0 100644
--- a/src/chronojump-importer/Makefile.am
+++ b/src/chronojump-importer/Makefile.am
@@ -1,6 +1,3 @@
-TARGET = exe
+TARGET = all
-chronojump_importerdir = "@bindir@"
-chronojump_importer_DATA = chronojump_importer.py
-
-EXTRA_DIST = $(chronojump_importer_DATA)
+bin_SCRIPTS = chronojump_importer.py
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index e6b2bac..a3308a4 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -2618,8 +2618,7 @@ public partial class ChronoJumpWindow
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 importerPath = UtilEncoder.GetChronojumpImporter ();
string source_filename = databasePath;
string destination_filename = Sqlite.DatabaseFilePath;
string session = Convert.ToString (sessionNumber);;
@@ -2629,8 +2628,11 @@ public partial class ChronoJumpWindow
processStartInfo = new ProcessStartInfo();
- processStartInfo.Arguments = importerPath + " --source " + source_filename + " --destination
" + destination_filename + " --source_session " + session;
- processStartInfo.FileName = pythonInterpreter;
+ processStartInfo.Arguments = " --source " + source_filename + " --destination " +
destination_filename + " --source_session " + session;
+ processStartInfo.FileName = importerPath;
+
+ LogB.Debug ("chronojump-importer fileName:" + processStartInfo.FileName);
+ LogB.Debug ("chronojump-importer Arguments:" + processStartInfo.Arguments);
processStartInfo.CreateNoWindow = true;
processStartInfo.UseShellExecute = false;
@@ -2640,13 +2642,25 @@ public partial class ChronoJumpWindow
process.OutputDataReceived += new DataReceivedEventHandler(
(s, e) =>
{
- Console.WriteLine(e.Data);
+ LogB.Debug(e.Data);
}
);
process.StartInfo = processStartInfo;
- process.Start();
- process.BeginOutputReadLine();
- process.WaitForExit();
+
+ bool started = false;
+ try {
+ process.Start();
+ started = true;
+ }
+ catch(Exception e) {
+ string errorMessage;
+ errorMessage = String.Format ("Cannot execute:\n {0}\nwith the parameters:\n
{1}\n\nThe exception is: {2}", processStartInfo.FileName, processStartInfo.Arguments, e.Message);
+ ErrorWindow.Show (errorMessage);
+ }
+
+ if (started) {
+ process.BeginOutputReadLine ();
+ }
}
private void on_open_activate (object o, EventArgs args)
diff --git a/src/utilEncoder.cs b/src/utilEncoder.cs
index a44f9ad..185363c 100644
--- a/src/utilEncoder.cs
+++ b/src/utilEncoder.cs
@@ -178,6 +178,16 @@ public class UtilEncoder
return false;
}
+ public static string GetChronojumpImporter() {
+ if (UtilAll.IsWindows ()) {
+ // TODO
+ return "";
+ } else {
+ // It's installed in the PATH.
+ return "chronojump_importer.py";
+ }
+ // What about OSX?
+ }
/*
private static string getEncoderScriptCapturePython() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]