Procházet zdrojové kódy

Improved Yaml robustness, not finished.

HEAD
Trevor Irons před 7 roky
rodič
revize
b6112c9432
1 změnil soubory, kde provedl 28 přidání a 28 odebrání
  1. 28
    28
      akvo/gui/akvoGUI.py

+ 28
- 28
akvo/gui/akvoGUI.py Zobrazit soubor

@@ -58,12 +58,12 @@ class AkvoYamlNode(yaml.YAMLObject):
58 58
     def __init__(self):
59 59
         self.Akvo_VERSION = version
60 60
         self.Import = {}
61
-        self.dataProcessing = {}
61
+        self.Processing = {}
62 62
         #self.data = {}
63 63
     # For going the other way, data import based on Yaml serialization, 
64 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 68
 try:    
69 69
     import thread 
@@ -492,11 +492,13 @@ class ApplicationWindow(QtWidgets.QMainWindow):
492 492
             yaml.dump(INFO, outfile, default_flow_style=False)   
493 493
  
494 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 501
         import pickle, os 
499
-
500 502
         try:
501 503
             with open('.akvo.last.path') as f: 
502 504
                 fpath = f.readline()  
@@ -525,7 +527,7 @@ class ApplicationWindow(QtWidgets.QMainWindow):
525 527
         INFO["deadTime"] = self.RAWDataProc.deadTime
526 528
         INFO["transFreq"] = self.RAWDataProc.transFreq
527 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 532
         self.RAWDataProc.DATADICT["INFO"] = INFO 
531 533
 
@@ -581,13 +583,23 @@ class ApplicationWindow(QtWidgets.QMainWindow):
581 583
         self.dataChan = self.RAWDataProc.DATADICT[ self.RAWDataProc.DATADICT["PULSES"][0] ]["chan"]
582 584
         #To keep backwards compatibility with prior saved pickles
583 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 596
         except KeyError:
588 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 604
         # If we got this far, enable all the widgets
593 605
         self.ui.lcdNumberTauPulse1.setEnabled(True)
@@ -719,19 +731,7 @@ class ApplicationWindow(QtWidgets.QMainWindow):
719 731
                 (str(self.headerstr), self.procStacks, self.dataChan, self.refChan, \
720 732
                  str(self.ui.FIDProcComboBox.currentText()), self.ui.mplwidget, \
721 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 735
         self.YamlNode.Import["GMR Header"] = self.headerstr
736 736
         self.YamlNode.Import["opened"] = datetime.datetime.now().isoformat() 
737 737
         self.YamlNode.Import["pulse Type"] = str(self.RAWDataProc.pulseType) 
@@ -741,7 +741,7 @@ class ApplicationWindow(QtWidgets.QMainWindow):
741 741
         self.YamlNode.Import["pulse records"] = str(self.ui.FIDProcComboBox.currentText())  
742 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 746
         # should be already done
747 747
 #        QtCore.QObject.connect(self.RAWDataProc, QtCore.SIGNAL("updateProgress(int)"), self.updateProgressBar)
@@ -763,7 +763,7 @@ class ApplicationWindow(QtWidgets.QMainWindow):
763 763
         self.mpl_toolbar = NavigationToolbar2QT(self.ui.mplwidget, self.ui.mplwidget)
764 764
         self.ui.mplwidget.draw()
765 765
 
766
-    def Log(self, nlogText):
766
+    def Log(self):
767 767
         #for line in yaml.dump(self.YamlNode, default_flow_style=False):
768 768
         #for line in nlogText: 
769 769
         #    self.ui.logTextBrowser.append( line )

Načítá se…
Zrušit
Uložit