Browse Source

Improved Yaml robustness, not finished.

HEAD
Trevor Irons 7 years ago
parent
commit
b6112c9432
1 changed files with 28 additions and 28 deletions
  1. 28
    28
      akvo/gui/akvoGUI.py

+ 28
- 28
akvo/gui/akvoGUI.py View File

58
     def __init__(self):
58
     def __init__(self):
59
         self.Akvo_VERSION = version
59
         self.Akvo_VERSION = version
60
         self.Import = {}
60
         self.Import = {}
61
-        self.dataProcessing = {}
61
+        self.Processing = {}
62
         #self.data = {}
62
         #self.data = {}
63
     # For going the other way, data import based on Yaml serialization, 
63
     # For going the other way, data import based on Yaml serialization, 
64
     def __repr__(self):
64
     def __repr__(self):
65
-        return "%s(name=%r, hp=%r, ac=%r, attacks=%r)" % (
66
-            self.__class__.__name__, self.name, self.hp, self.ac, self.attacks, self.thingy)
65
+        return "%s(name=%r, Akvo_VESION=%r, Import=%r, Processing=%r)" % (
66
+            self.__class__.__name__, self.Akvo_VERSION, self.Import, self.Processing) #self.name, self.hp, self.ac, self.attacks, self.thingy)
67
     
67
     
68
 try:    
68
 try:    
69
     import thread 
69
     import thread 
492
             yaml.dump(INFO, outfile, default_flow_style=False)   
492
             yaml.dump(INFO, outfile, default_flow_style=False)   
493
  
493
  
494
     def SavePreprocess(self):
494
     def SavePreprocess(self):
495
-        
496
-        self.Log( ["Saved:" + datetime.datetime.now().isoformat()] )
497
-        
495
+     
496
+        if "Saved" not in self.YamlNode.Processing.keys():
497
+            self.YamlNode.Processing["Saved"] = []
498
+        self.YamlNode.Processing["Saved"].append(datetime.datetime.now().isoformat()) 
499
+        self.Log()
500
+ 
498
         import pickle, os 
501
         import pickle, os 
499
-
500
         try:
502
         try:
501
             with open('.akvo.last.path') as f: 
503
             with open('.akvo.last.path') as f: 
502
                 fpath = f.readline()  
504
                 fpath = f.readline()  
525
         INFO["deadTime"] = self.RAWDataProc.deadTime
527
         INFO["deadTime"] = self.RAWDataProc.deadTime
526
         INFO["transFreq"] = self.RAWDataProc.transFreq
528
         INFO["transFreq"] = self.RAWDataProc.transFreq
527
         INFO["headerstr"] = str(self.headerstr)
529
         INFO["headerstr"] = str(self.headerstr)
528
-        INFO["log"] = self.logText  #MAK 20170127
530
+        INFO["log"] = yaml.dump( self.YamlNode )  #self.logText  #MAK 20170127
529
 
531
 
530
         self.RAWDataProc.DATADICT["INFO"] = INFO 
532
         self.RAWDataProc.DATADICT["INFO"] = INFO 
531
 
533
 
581
         self.dataChan = self.RAWDataProc.DATADICT[ self.RAWDataProc.DATADICT["PULSES"][0] ]["chan"]
583
         self.dataChan = self.RAWDataProc.DATADICT[ self.RAWDataProc.DATADICT["PULSES"][0] ]["chan"]
582
         #To keep backwards compatibility with prior saved pickles
584
         #To keep backwards compatibility with prior saved pickles
583
         try:
585
         try:
584
-            self.logText = self.RAWDataProc.DATADICT["INFO"]["log"]
585
-            for a in self.logText:
586
-                self.ui.logTextBrowser.append(str(a))
586
+            self.logText = self.RAWDataProc.DATADICT["INFO"]["log"] # YAML 
587
+            #self.ui.logTextBrowser.clear() 
588
+            #self.ui.logTextBrowser.append( yaml.dump(self.YamlNode)) #, default_flow_style=False)  )
589
+            #for a in self.logText:
590
+            #    self.ui.logTextBrowser.append(str(a))
591
+            #self.ui.logTextBrowser
592
+            #self.ui.logTextBrowser.clear()
593
+            #print ( self.RAWDataProc.DATADICT["INFO"]["log"] )
594
+            #self.YamlNode = yaml.load( self.logText ) 
595
+            #self.ui.logTextBrowser.append( yaml.dump(self.YamlNode)) #, default_flow_style=False)  )
587
         except KeyError:
596
         except KeyError:
588
             pass
597
             pass
589
-        
590
-        self.Log( ["Loaded:" + datetime.datetime.now().isoformat()] )
598
+       
599
+        if "Loaded" not in self.YamlNode.Processing.keys():
600
+            self.YamlNode.Processing["Loaded"] = []
601
+        self.YamlNode.Processing["Loaded"].append(datetime.datetime.now().isoformat()) 
602
+        self.Log()
591
  
603
  
592
         # If we got this far, enable all the widgets
604
         # If we got this far, enable all the widgets
593
         self.ui.lcdNumberTauPulse1.setEnabled(True)
605
         self.ui.lcdNumberTauPulse1.setEnabled(True)
719
                 (str(self.headerstr), self.procStacks, self.dataChan, self.refChan, \
731
                 (str(self.headerstr), self.procStacks, self.dataChan, self.refChan, \
720
                  str(self.ui.FIDProcComboBox.currentText()), self.ui.mplwidget, \
732
                  str(self.ui.FIDProcComboBox.currentText()), self.ui.mplwidget, \
721
                 1e-3 * self.ui.DeadTimeSpinBox.value( ), self.ui.plotImportCheckBox.isChecked() )) #, self)) 
733
                 1e-3 * self.ui.DeadTimeSpinBox.value( ), self.ui.plotImportCheckBox.isChecked() )) #, self)) 
722
-        
723
-        nlogText = []
724
-        nlogText.append( "!<AkvoData>" )
725
-        nlogText.append( "Akvo_VERSION: " + str(1.0))
726
-        nlogText.append( "Import: " )
727
-        nlogText.append( "  GMR Header: " + self.headerstr )
728
-        nlogText.append( "  opened: " + datetime.datetime.now().isoformat() )
729
-        nlogText.append( "  pulse Type: " + str(self.RAWDataProc.pulseType) )
730
-        nlogText.append( "  stacks: " + str(self.procStacks) )
731
-        nlogText.append( "  data channels: " +  str(self.dataChan) ) 
732
-        nlogText.append( "  reference channels: " + str(self.refChan) )
733
-        nlogText.append( "  pulse records: " + str(self.ui.FIDProcComboBox.currentText()) ) 
734
-        nlogText.append( "  instrument dead time: " + str(1e-3 * self.ui.DeadTimeSpinBox.value( )) )   
734
+
735
         self.YamlNode.Import["GMR Header"] = self.headerstr
735
         self.YamlNode.Import["GMR Header"] = self.headerstr
736
         self.YamlNode.Import["opened"] = datetime.datetime.now().isoformat() 
736
         self.YamlNode.Import["opened"] = datetime.datetime.now().isoformat() 
737
         self.YamlNode.Import["pulse Type"] = str(self.RAWDataProc.pulseType) 
737
         self.YamlNode.Import["pulse Type"] = str(self.RAWDataProc.pulseType) 
741
         self.YamlNode.Import["pulse records"] = str(self.ui.FIDProcComboBox.currentText())  
741
         self.YamlNode.Import["pulse records"] = str(self.ui.FIDProcComboBox.currentText())  
742
         self.YamlNode.Import["instrument dead time"] = (1e-3 * self.ui.DeadTimeSpinBox.value( ))    
742
         self.YamlNode.Import["instrument dead time"] = (1e-3 * self.ui.DeadTimeSpinBox.value( ))    
743
 
743
 
744
-        self.Log ( nlogText )     
744
+        self.Log (  )     
745
 
745
 
746
         # should be already done
746
         # should be already done
747
 #        QtCore.QObject.connect(self.RAWDataProc, QtCore.SIGNAL("updateProgress(int)"), self.updateProgressBar)
747
 #        QtCore.QObject.connect(self.RAWDataProc, QtCore.SIGNAL("updateProgress(int)"), self.updateProgressBar)
763
         self.mpl_toolbar = NavigationToolbar2QT(self.ui.mplwidget, self.ui.mplwidget)
763
         self.mpl_toolbar = NavigationToolbar2QT(self.ui.mplwidget, self.ui.mplwidget)
764
         self.ui.mplwidget.draw()
764
         self.ui.mplwidget.draw()
765
 
765
 
766
-    def Log(self, nlogText):
766
+    def Log(self):
767
         #for line in yaml.dump(self.YamlNode, default_flow_style=False):
767
         #for line in yaml.dump(self.YamlNode, default_flow_style=False):
768
         #for line in nlogText: 
768
         #for line in nlogText: 
769
         #    self.ui.logTextBrowser.append( line )
769
         #    self.ui.logTextBrowser.append( line )

Loading…
Cancel
Save