[chronojump] on linux/mac importer can use python/2/3 selectable on prefs
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] on linux/mac importer can use python/2/3 selectable on prefs
- Date: Tue, 2 Jun 2020 09:54:08 +0000 (UTC)
commit 0907f6c28ff7de2f25a0131e06ca69231f6af36d
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Jun 2 11:53:19 2020 +0200
on linux/mac importer can use python/2/3 selectable on prefs
src/chronojumpImporter.cs | 24 +++++++++++++++---------
src/gui/chronojumpImporter.cs | 5 +++--
src/gui/preferences.cs | 10 +++++-----
src/preferences.cs | 15 +++++++++++++++
4 files changed, 38 insertions(+), 16 deletions(-)
---
diff --git a/src/chronojumpImporter.cs b/src/chronojumpImporter.cs
index ad5afa54..4ca1928f 100644
--- a/src/chronojumpImporter.cs
+++ b/src/chronojumpImporter.cs
@@ -51,6 +51,8 @@ class ChronojumpImporter
// to debug to a file if debug mode is started on preferences;
private bool debugToFile;
+ Preferences.pythonVersionEnum pythonVersion;
+
Gtk.Window parentWindow;
// Result struct holds the output, error and success operations. It's used to pass
@@ -72,7 +74,7 @@ class ChronojumpImporter
// ChronojumpImporter class imports a specific session from sourceFile to destinationFile.
// The main method is "import()" which does all the work.
public ChronojumpImporter(Gtk.Window parentWindow, string sourceFile, string destinationFile,
- int sourceSession, int destinationSession, bool debugToFile)
+ int sourceSession, int destinationSession, bool debugToFile,
Preferences.pythonVersionEnum pythonVersion)
{
this.parentWindow = parentWindow;
this.sourceFile = sourceFile;
@@ -80,6 +82,9 @@ class ChronojumpImporter
this.sourceSession = sourceSession;
this.destinationSession = destinationSession;
this.debugToFile = debugToFile;
+
+ this.pythonVersion = pythonVersion;
+
MessageToPulsebar = "";
}
@@ -229,7 +234,7 @@ LogB.Information("import A ");
else
parameters.Add ("NONE");
- Result result = executeChronojumpImporter (parameters);
+ Result result = executeChronojumpImporter (parameters, pythonVersion);
MessageToPulsebar = "Done!";
File.Delete (temporarySourceFile);
@@ -257,7 +262,7 @@ LogB.Information("import A ");
Sqlite.Connect ();
}
- private static Result getImporterInformation(string filePath)
+ private static Result getImporterInformation(string filePath, Preferences.pythonVersionEnum
pythonVersion)
{
// If Result.success == true Result.output contains a valid JSON string.
// It's a string and not a JsonValue for convenience with other methods (at the moment).
@@ -269,7 +274,7 @@ LogB.Information("import A ");
parameters.Add (filePath);
parameters.Add ("--json_information");
- Result result = executeChronojumpImporter (parameters);
+ Result result = executeChronojumpImporter (parameters, pythonVersion);
if (result.success) {
try {
@@ -285,9 +290,9 @@ LogB.Information("import A ");
}
}
- public static string GetSessionName(string filePath, int sessionId)
+ public static string GetSessionName(string filePath, int sessionId, Preferences.pythonVersionEnum
pythonVersion)
{
- Result information = getImporterInformation (filePath);
+ Result information = getImporterInformation (filePath, pythonVersion);
if (information.success == false) {
// This shouldn't happen, other getImporterInformation is used in different ways.
LogB.Information ("chronojumpImporter::getSessionName failed. Output:" +
information.output + "Error:" + information.error);
@@ -313,7 +318,7 @@ LogB.Information("import A ");
private Result getDatabaseVersionFromFile(string filePath)
{
- Result information = getImporterInformation (filePath);
+ Result information = getImporterInformation (filePath, pythonVersion);
if (information.success) {
JsonValue json = JsonValue.Parse (information.output);
@@ -323,7 +328,7 @@ LogB.Information("import A ");
}
}
- private static Result executeChronojumpImporter(List<string> parameters)
+ private static Result executeChronojumpImporter(List<string> parameters,
Preferences.pythonVersionEnum pythonVersion)
{
string importer_executable;
@@ -333,8 +338,9 @@ LogB.Information("import A ");
} else {
// On Linux and OSX we execute Python and we pass the path to the script as a first
argument
- importer_executable = "python"; // chronojump_importer.py works on Python 2
and Python 3
+ importer_executable = Preferences.GetPythonExecutable(pythonVersion);
+ LogB.Information("importer_executable: " + importer_executable);
string importer_script_path = System.IO.Path.Combine (Util.GetPrefixDir (),
"bin/chronojump_importer.py");
// first argument of the Python: the path to the script
diff --git a/src/gui/chronojumpImporter.cs b/src/gui/chronojumpImporter.cs
index d121d633..7f880263 100644
--- a/src/gui/chronojumpImporter.cs
+++ b/src/gui/chronojumpImporter.cs
@@ -62,7 +62,8 @@ public partial class ChronoJumpWindow
else
destinationSessionId = destinationSession.UniqueID;
- chronojumpImporter = new ChronojumpImporter (app1, source_filename, destination_filename,
sourceSession, destinationSessionId, preferences.debugMode);
+ chronojumpImporter = new ChronojumpImporter (app1, source_filename, destination_filename,
sourceSession, destinationSessionId,
+ preferences.debugMode, preferences.importerPythonVersion);
if(destinationSessionId == 0)
{
@@ -70,7 +71,7 @@ public partial class ChronoJumpWindow
importSessionFromDatabasePrepare2 (new object(), new EventArgs());
} else
{
- string sessionName = ChronojumpImporter.GetSessionName
(chronojumpImporter.SourceFile, chronojumpImporter.SourceSession);
+ string sessionName = ChronojumpImporter.GetSessionName
(chronojumpImporter.SourceFile, chronojumpImporter.SourceSession, preferences.importerPythonVersion);
app1s_LabelImportSessionName(sessionName);
app1s_LabelImportFile(chronojumpImporter.SourceFile);
diff --git a/src/gui/preferences.cs b/src/gui/preferences.cs
index bc57cb39..9a154152 100644
--- a/src/gui/preferences.cs
+++ b/src/gui/preferences.cs
@@ -679,13 +679,13 @@ public class PreferencesWindow
PreferencesWindowBox.radio_use_heights_on_jump_indexes.Active = true;
else
PreferencesWindowBox.radio_do_not_use_heights_on_jump_indexes.Active = true;
-
- if(preferences.importerPythonVersion == Preferences.pythonVersionEnum.Python)
- PreferencesWindowBox.radio_python_default.Active = true;
- else if(preferences.importerPythonVersion == Preferences.pythonVersionEnum.Python2)
+
+ if(preferences.importerPythonVersion == Preferences.pythonVersionEnum.Python2)
PreferencesWindowBox.radio_python_2.Active = true;
- else //if(preferences.importerPythonVersion == Preferences.pythonVersionEnum.Python3)
+ else if(preferences.importerPythonVersion == Preferences.pythonVersionEnum.Python3)
PreferencesWindowBox.radio_python_3.Active = true;
+ else //if(preferences.importerPythonVersion == Preferences.pythonVersionEnum.Python)
+ PreferencesWindowBox.radio_python_default.Active = true;
PreferencesWindowBox.preferences_win.Show ();
diff --git a/src/preferences.cs b/src/preferences.cs
index 429902f7..bded10c0 100644
--- a/src/preferences.cs
+++ b/src/preferences.cs
@@ -146,6 +146,21 @@ public class Preferences
public enum pythonVersionEnum { Python, Python2, Python3 };
public pythonVersionEnum importerPythonVersion;
+ /*
+ * at DB: 1.95, vales pythonVersionEnum were Python, Python2, Python3
+ * so we need the executable: python, python2, python3
+ * chronojump_importer.py works on python2 and python3
+ */
+ public static string GetPythonExecutable (pythonVersionEnum pv)
+ {
+ if(pv == pythonVersionEnum.Python2)
+ return "python2";
+ else if(pv == pythonVersionEnum.Python3)
+ return "python3";
+
+ return "python";
+ }
+
/*
* these are NOT sent to preferences window
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]