[chronojump] ChronojumpImporter with a debug mode depending on preferences/debug



commit 1c4b0b3fd43beb8f3d0c4f9961cddf633182d008
Author: Xavier de Blas <xaviblas gmail com>
Date:   Sun Oct 6 18:12:53 2019 +0200

    ChronojumpImporter with a debug mode depending on preferences/debug

 src/chronojump-importer/chronojump_importer.py | 14 ++++++++++++++
 src/chronojumpImporter.cs                      | 13 ++++++++++++-
 src/gui/chronojump.cs                          |  4 ++--
 3 files changed, 28 insertions(+), 3 deletions(-)
---
diff --git a/src/chronojump-importer/chronojump_importer.py b/src/chronojump-importer/chronojump_importer.py
index 502d10f1..0e9b5631 100755
--- a/src/chronojump-importer/chronojump_importer.py
+++ b/src/chronojump-importer/chronojump_importer.py
@@ -11,6 +11,9 @@ import re
 
 logging.basicConfig(level=logging.INFO)
 
+DEBUGTOFILE = False
+debugFile = ""
+
 """
 /*
  * This file is part of ChronoJump
@@ -771,6 +774,8 @@ def process_command_line():
                              "new session.")
     parser.add_argument("--json_information", required=False, action='store_true',
                         help="Shows information of the source database")
+    parser.add_argument("--debug_to_file", type=str, required=False,
+                        help="path to print debug info to file")
     args = parser.parse_args()
 
     if args.json_information:
@@ -782,6 +787,15 @@ def process_command_line():
             else:
                 source_base_directory = os.path.join(args.source, "../..")
 
+            # to use the global variable on this function
+            global DEBUGTOFILE
+            global debugFile
+            if args.debug_to_file == "NONE":
+                DEBUGTOFILE = False
+            elif args.debug_to_file != "":
+                DEBUGTOFILE = True
+                debugFile = open('/tmp/debugFile.txt', 'w')
+
             importer = ImportSession(args.source, args.destination, source_base_directory)
 
             if args.destination_session is None:
diff --git a/src/chronojumpImporter.cs b/src/chronojumpImporter.cs
index 515956a3..d8e8ec16 100644
--- a/src/chronojumpImporter.cs
+++ b/src/chronojumpImporter.cs
@@ -24,6 +24,7 @@ using Mono.Unix;
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  * Copyright (C) 2016-2017   Carles Pina i Estany <carles pina cat>
+ * Copyright (C) 2019   Xavier de Blas <xaviblas gmail com>
  */
 
 
@@ -42,6 +43,9 @@ class ChronojumpImporter
        // a new session, otherwise it will import it into the session indicated by it
        private int destinationSession;
 
+       // to debug to a file if debug mode is started on preferences;
+       private bool debugToFile;
+
        Gtk.Window parentWindow;
 
        // Result struct holds the output, error and success operations. It's used to pass
@@ -62,13 +66,15 @@ 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)
+       public ChronojumpImporter(Gtk.Window parentWindow, string sourceFile, string destinationFile,
+                       int sourceSession, int destinationSession, bool debugToFile)
        {
                this.parentWindow = parentWindow;
                this.sourceFile = sourceFile;
                this.destinationFile = destinationFile;
                this.sourceSession = sourceSession;
                this.destinationSession = destinationSession;
+               this.debugToFile = debugToFile;
        }
 
        // Shows a dialogue to the user and lets him cancel the operation. The dialog information depends on
@@ -169,6 +175,11 @@ class ChronojumpImporter
                        parameters.Add ("--destination_session");
                        parameters.Add (Convert.ToString (destinationSession));
                }
+               parameters.Add ("--debug_to_file");
+               if(debugToFile)
+                       parameters.Add (Path.Combine(Path.GetTempPath(), "chronojumpImportDebug.txt"));
+               else
+                       parameters.Add ("NONE");
 
                Result result = executeChronojumpImporter (parameters);
 
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 0ab5de24..8dee32de 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -2461,7 +2461,7 @@ public partial class ChronoJumpWindow
                        destinationSessionId = destinationSession.UniqueID;
                }
 
-               ChronojumpImporter chronojumpImporter = new ChronojumpImporter (app1, source_filename, 
destination_filename, sourceSession, destinationSessionId);
+               ChronojumpImporter chronojumpImporter = new ChronojumpImporter (app1, source_filename, 
destination_filename, sourceSession, destinationSessionId, preferences.debugMode);
 
                Gtk.ResponseType response = chronojumpImporter.showImportConfirmation ();
 
@@ -6868,7 +6868,7 @@ LogB.Debug("mc finished 5");
 
                encoderRProcCapture.Debug = true;
                encoderRProcAnalyze.Debug = true;
-               preferences.debugMode = true; //be used by force sensor
+               preferences.debugMode = true; //be used by force sensor, importer (can be used easily for all 
software)
                LogB.PrintAllThreads = true;
 
                hbox_gui_tests.Visible = true;


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