[Avida-cvs] [Avida2-svn] r192 - trunk/source/python/AvidaGui2

baerb at myxo.css.msu.edu baerb at myxo.css.msu.edu
Wed Jun 8 13:42:25 PDT 2005


Author: baerb
Date: 2005-06-08 16:42:25 -0400 (Wed, 08 Jun 2005)
New Revision: 192

Modified:
   trunk/source/python/AvidaGui2/pyFreezeDialogCtrl.py
   trunk/source/python/AvidaGui2/pyFreezerCtrl.py
   trunk/source/python/AvidaGui2/pyOneAna_GraphCtrl.py
   trunk/source/python/AvidaGui2/pyOneAnalyzeCtrl.py
   trunk/source/python/AvidaGui2/pyOnePop_GraphCtrl.py
   trunk/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py
   trunk/source/python/AvidaGui2/pyOnePopulationCtrl.py
   trunk/source/python/AvidaGui2/pyPetriConfigureCtrl.py
   trunk/source/python/AvidaGui2/pySessionCtrl.py
   trunk/source/python/AvidaGui2/pyTemporaryReloads.py
   trunk/source/python/AvidaGui2/pyWriteToFreezer.py
Log:
Removed hardcode / and replace with os.path.join when creatign directory names

Changed WriteGenesis to WriteGenesisEvent

Put current average.dat and count.dat into temp_dir/output




Modified: trunk/source/python/AvidaGui2/pyFreezeDialogCtrl.py
===================================================================
--- trunk/source/python/AvidaGui2/pyFreezeDialogCtrl.py	2005-06-08 20:34:29 UTC (rev 191)
+++ trunk/source/python/AvidaGui2/pyFreezeDialogCtrl.py	2005-06-08 20:42:25 UTC (rev 192)
@@ -28,7 +28,7 @@
         if self.EmptyRadioButton.isChecked():
           if (tmp_name.endswith(".empty") == False):
             tmp_name = tmp_name + ".empty"
-          tmp_name = freezer_dir + tmp_name
+          tmp_name = os.path.join(freezer_dir, tmp_name)
           if os.path.exists(tmp_name):
             found_valid_name = False
             self.MainMessageTextLabel.setText("Petri Dish Exists, Please Enter a Different Name")
@@ -38,7 +38,7 @@
         else:
           if (tmp_name.endswith(".full") == False):
             tmp_name = tmp_name + ".full"
-          tmp_name = freezer_dir + tmp_name
+          tmp_name = os.path.join(freezer_dir, tmp_name)
           if os.path.exists(tmp_name):
             found_valid_name = False
             self.MainMessageTextLabel.setText("Petri Dish Exists, Please Enter a Different Name")

Modified: trunk/source/python/AvidaGui2/pyFreezerCtrl.py
===================================================================
--- trunk/source/python/AvidaGui2/pyFreezerCtrl.py	2005-06-08 20:34:29 UTC (rev 191)
+++ trunk/source/python/AvidaGui2/pyFreezerCtrl.py	2005-06-08 20:42:25 UTC (rev 192)
@@ -4,6 +4,7 @@
 from qt import *
 from pyFreezerView import pyFreezerView
 from pyReadFreezer import pyReadFreezer
+import os.path
 
 class pyFreezerCtrl(pyFreezerView):
 
@@ -63,6 +64,7 @@
 # if mouse is pressed on list item prepare its info to be dragged        
   def pressed_itemSlot(self, item):
 
+
     if item != None and item.depth() > 0:
       top_level = item
       while top_level.parent():
@@ -104,10 +106,11 @@
       if str(top_level.text(0)).startswith(" Empty Petri"):
         file_name = str(item.text(0)) + ".empty"
       elif str(top_level.text(0)).startswith(" Full Petri"):
-        file_name = str(item.text(0)) + ".full/petri_dish"
+        file_name = str(item.text(0)) + ".full"
+        file_name = os.path.join(file_name, "petri_dish")
       elif str(top_level.text(0)).startswith(" Organism"):
         file_name = str(item.text(0)) + ".organism"
-      file_name = self.m_session_mdl.m_current_freezer + file_name
+      file_name = os.path.join(self.m_session_mdl.m_current_freezer, file_name)
       thawed_item = pyReadFreezer(file_name)
       self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("doDefrostDishSig"),
         (item.text(0), thawed_item,))

Modified: trunk/source/python/AvidaGui2/pyOneAna_GraphCtrl.py
===================================================================
--- trunk/source/python/AvidaGui2/pyOneAna_GraphCtrl.py	2005-06-08 20:34:29 UTC (rev 191)
+++ trunk/source/python/AvidaGui2/pyOneAna_GraphCtrl.py	2005-06-08 20:42:25 UTC (rev 192)
@@ -6,8 +6,8 @@
 from pyOneAna_GraphView import pyOneAna_GraphView
 from qt import *
 from qwt import *
-import os
 import os.path
+import os.path
 
 
 class PrintFilter(QwtPlotPrintFilter):
@@ -100,6 +100,16 @@
       self.printGraphSlot)
 
   def load(self, filename, colx, coly):
+    
+    # Brian's old code, delete 
+    # init_file_name_str = os.path.join(self.m_session_mdl.m_current_freezer, str(self.m_petri_dish_dir_path) + '.full', filename)
+    # init_file = cInitFile(cString(init_file_name_str))
+    #
+    # print "loading"
+    # if not init_file.IsOpen():
+    #   print "the file you are looking for does not exist"
+    #   return
+
     init_file = cInitFile(cString(os.path.join(str(self.m_petri_dish_dir_path), filename)))
     init_file.Load()
     init_file.Compress()
@@ -141,7 +151,7 @@
         print "index_1[2] is"
         print self.m_avida_stats_interface.m_entries[index_1][2]
         self.m_curve_1_arrays = self.load(
-            self.m_avida_stats_interface.m_entries[index_1][1],
+            os.path.join(self.m_session_mdl.m_tempdir_out, self.m_avida_stats_interface.m_entries[index_1][1]),
             1,
             self.m_avida_stats_interface.m_entries[index_1][2]
         )
@@ -163,7 +173,7 @@
         self.m_graph_ctrl.enableYRightAxis(True)      
         self.m_graph_ctrl.setAxisAutoScale(QwtPlot.yRight)
         self.m_curve_2_arrays = self.load(
-            self.m_avida_stats_interface.m_entries[index_2][1],
+            os.path.join(self.m_session_mdl.m_tempdir_out, self.m_avida_stats_interface.m_entries[index_2][1]),
             1,
             self.m_avida_stats_interface.m_entries[index_2][2]
         )

Modified: trunk/source/python/AvidaGui2/pyOneAnalyzeCtrl.py
===================================================================
--- trunk/source/python/AvidaGui2/pyOneAnalyzeCtrl.py	2005-06-08 20:34:29 UTC (rev 191)
+++ trunk/source/python/AvidaGui2/pyOneAnalyzeCtrl.py	2005-06-08 20:42:25 UTC (rev 192)
@@ -2,7 +2,7 @@
 
 from qt import *
 from pyOneAnalyzeView import pyOneAnalyzeView
-import os
+import os.path
 
 class pyOneAnalyzeCtrl(pyOneAnalyzeView):
 
@@ -20,7 +20,7 @@
 
   def dropEvent( self, e ):
     freezer_item_name = QString()
-
+    print "something was dropped"
     if ( QTextDrag.decode( e, freezer_item_name ) ) :
       if os.path.exists( str(freezer_item_name)) == False:
         print "that was not a valid path(3)" 
@@ -34,4 +34,4 @@
 #            QTextDrag.canDecode( e ) or
 #            QImageDrag.canDecode( e ) or
 #            QUriDrag.canDecode( e )):
-#    e.accept()
\ No newline at end of file
+#    e.accept()

Modified: trunk/source/python/AvidaGui2/pyOnePop_GraphCtrl.py
===================================================================
--- trunk/source/python/AvidaGui2/pyOnePop_GraphCtrl.py	2005-06-08 20:34:29 UTC (rev 191)
+++ trunk/source/python/AvidaGui2/pyOnePop_GraphCtrl.py	2005-06-08 20:42:25 UTC (rev 192)
@@ -6,6 +6,7 @@
 from pyOnePop_GraphView import pyOnePop_GraphView
 from qt import *
 from qwt import *
+import os.path
 
 class PrintFilter(QwtPlotPrintFilter):
   def __init__(self):
@@ -65,7 +66,7 @@
       self.printGraphSlot)
 
   def load(self, filename, colx, coly):
-    print "pyOnePop_GraphCtrl.load"
+    print "pyOnePop_GraphCtrl.load file name = " + filename
     if (self.m_avida is None) or (self.m_avida.m_population.GetStats().GetUpdate() == 0):
       print " m_avida is None, or update is zero. Not loading from file."
       self.m_x_array = zeros(1, Float)
@@ -89,7 +90,7 @@
     self.m_graph_ctrl.clear()
     if index:
       self.load(
-        self.m_avida_stats_interface.m_entries[index][1],
+        os.path.join(self.m_session_mdl.m_tempdir_out, self.m_avida_stats_interface.m_entries[index][1]),
         1,
         self.m_avida_stats_interface.m_entries[index][2]
       )

Modified: trunk/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py
===================================================================
--- trunk/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py	2005-06-08 20:34:29 UTC (rev 191)
+++ trunk/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py	2005-06-08 20:42:25 UTC (rev 192)
@@ -80,7 +80,7 @@
       return
     current_page = self.m_petri_dish_widget_stack.visibleWidget()
     current_page_int = self.m_petri_dish_widget_stack.id(current_page)
-    if (current_page_int == 0):
+    if (current_page_int != 0):
        self.m_petri_dish_widget_stack.raiseWidget(1)
        
   def SetDishDisabledSlot(self):

Modified: trunk/source/python/AvidaGui2/pyOnePopulationCtrl.py
===================================================================
--- trunk/source/python/AvidaGui2/pyOnePopulationCtrl.py	2005-06-08 20:34:29 UTC (rev 191)
+++ trunk/source/python/AvidaGui2/pyOnePopulationCtrl.py	2005-06-08 20:42:25 UTC (rev 192)
@@ -2,7 +2,7 @@
 
 from qt import *
 from pyOnePopulationView import pyOnePopulationView
-import os
+import os.path
 
 class pyOnePopulationCtrl(pyOnePopulationView):
 
@@ -26,4 +26,4 @@
         print "that was not a valid path (1)" 
       else: 
         self.emit(PYSIGNAL("petriDishDroppedInPopViewSig"), (e,))
-        print "emitted"
\ No newline at end of file
+        print "emitted"

Modified: trunk/source/python/AvidaGui2/pyPetriConfigureCtrl.py
===================================================================
--- trunk/source/python/AvidaGui2/pyPetriConfigureCtrl.py	2005-06-08 20:34:29 UTC (rev 191)
+++ trunk/source/python/AvidaGui2/pyPetriConfigureCtrl.py	2005-06-08 20:42:25 UTC (rev 192)
@@ -3,14 +3,14 @@
 from pyAvida import pyAvida
 from pyFreezeDialogCtrl import pyFreezeDialogCtrl
 from pyPetriConfigureView import pyPetriConfigureView
-from pyWriteGenesis import pyWriteGenesis
+from pyWriteGenesisEvent import pyWriteGenesisEvent
 from pyWriteToFreezer import pyWriteToFreezer
 
 from AvidaCore import cGenesis, cString
 
 from qt import *
 
-import os
+import os, os.path, shutil
 import math
 
 class pyPetriConfigureCtrl(pyPetriConfigureView):
@@ -197,12 +197,18 @@
       PYSIGNAL("doDisablePetriDishSig"), ())
 
   def CreateFilesFromPetriSlot(self, out_dir = None):
+
+    # The input files will be placed in a python generated temporary directory
+    # ouput files will be stored in tmp_dir/output until the data is frozen
+    # (ie saved)
+
     self.full_petri_dict["SETTINGS"] = self.Form2Dictionary()
-    write_object = pyWriteGenesis(self.full_petri_dict, 
+    write_object = pyWriteGenesisEvent(self.full_petri_dict, 
       self.m_session_mdl.m_current_workspace,
-      self.m_session_mdl.m_current_freezer, self.m_session_mdl.m_tempdir)
+      self.m_session_mdl.m_current_freezer, self.m_session_mdl.m_tempdir,
+      self.m_session_mdl.m_tempdir_out)
     self.m_session_mdl.m_session_mdtr.emit(
-      PYSIGNAL("doInitializeAvidaPhaseIISig"), (self.m_session_mdl.m_tempdir + "genesis.avida",))
+      PYSIGNAL("doInitializeAvidaPhaseIISig"), (os.path.join(self.m_session_mdl.m_tempdir, "genesis.avida"),))
       
   def Form2Dictionary(self):
     settings_dict = {}
@@ -240,12 +246,23 @@
     tmp_dict["SETTINGS"] = self.Form2Dictionary()
     m_pop_up_freezer_file_name = pyFreezeDialogCtrl()
     file_name = m_pop_up_freezer_file_name.showDialog(self.m_session_mdl.m_current_freezer)
+
+    # If the user is saving a full population expand the name and insert
+    # the population dictionary into the temporary dictionary
+
     if (m_pop_up_freezer_file_name.isEmpty() == False):
       os.mkdir(file_name)
-      file_name = file_name + "/petri_dish"
+
+      # Copy the average and count files from the teporary output directory
+      # to the Freezer directory
+        
+      shutil.copyfile(os.path.join(self.m_session_mdl.m_tempdir_out, "average.dat"), os.path.join(file_name, "average.dat"))
+      shutil.copyfile(os.path.join(self.m_session_mdl.m_tempdir_out, "count.dat"), os.path.join(file_name, "count.dat"))
+      file_name = os.path.join(file_name, "petri_dish")
       tmp_dict["POPULATION"] = population_dict
     is_empty_dish = m_pop_up_freezer_file_name.EmptyRadioButton.isChecked()
     freezer_file = pyWriteToFreezer(tmp_dict, is_empty_dish, file_name)
+    
     self.m_session_mdl.m_session_mdtr.emit(
       PYSIGNAL("doRefreshFreezerInventorySig"), ())
     if send_reset_signal:
@@ -288,4 +305,4 @@
         print "that was not a valid path (2)" 
       else: 
         self.emit(PYSIGNAL("petriDishDroppedInPopViewSig"), (e,))
-        print "emitted(1)"
\ No newline at end of file
+        print "emitted(1)"

Modified: trunk/source/python/AvidaGui2/pySessionCtrl.py
===================================================================
--- trunk/source/python/AvidaGui2/pySessionCtrl.py	2005-06-08 20:34:29 UTC (rev 191)
+++ trunk/source/python/AvidaGui2/pySessionCtrl.py	2005-06-08 20:42:25 UTC (rev 192)
@@ -9,7 +9,7 @@
 
 import qt
 
-import os
+import os, os.path
 import tempfile
 
 class pySessionCtrl(qt.QObject):
@@ -39,11 +39,13 @@
     # Create "model" for storing state data.
     class pyMdl: pass
     self.m_session_mdl = pyMdl()
-    self.m_session_mdl.m_current_workspace = "default.workspace/"
-    self.m_session_mdl.m_current_freezer = self.m_session_mdl.m_current_workspace + "freezer/"
+    self.m_session_mdl.m_current_workspace = "default.workspace"
+    self.m_session_mdl.m_current_freezer = os.path.join(self.m_session_mdl.m_current_workspace, "freezer")
 
     # Create a temporary subdirectory for general use in this session.
-    self.m_session_mdl.m_tempdir = tempfile.mkdtemp('','AvidaEd-pid%d-'%os.getpid()) + "/"
+    self.m_session_mdl.m_tempdir = tempfile.mkdtemp('','AvidaEd-pid%d-'%os.getpid())
+    self.m_session_mdl.m_tempdir_out = os.path.join(self.m_session_mdl.m_tempdir, "output")
+    os.mkdir(self.m_session_mdl.m_tempdir_out)
 
     # Create session mediator.
     self.m_session_mdl.m_session_mdtr = pyMdtr()

Modified: trunk/source/python/AvidaGui2/pyTemporaryReloads.py
===================================================================
--- trunk/source/python/AvidaGui2/pyTemporaryReloads.py	2005-06-08 20:34:29 UTC (rev 191)
+++ trunk/source/python/AvidaGui2/pyTemporaryReloads.py	2005-06-08 20:42:25 UTC (rev 192)
@@ -75,7 +75,7 @@
   "AvidaGui2.pyReadFreezer",
   "AvidaGui2.pyTimelineView",
   "AvidaGui2.pyTimelineCtrl",
-  "AvidaGui2.pyWriteGenesis",
+  "AvidaGui2.pyWriteGenesisEvent",
   "AvidaGui2.pyWriteToFreezer",
   
   "AvidaGui2.pyOneAna_GraphView",

Modified: trunk/source/python/AvidaGui2/pyWriteToFreezer.py
===================================================================
--- trunk/source/python/AvidaGui2/pyWriteToFreezer.py	2005-06-08 20:34:29 UTC (rev 191)
+++ trunk/source/python/AvidaGui2/pyWriteToFreezer.py	2005-06-08 20:42:25 UTC (rev 192)
@@ -48,4 +48,4 @@
           curr_genome_num = organism_dict[genome]
         in_dict["CELLS"][cell] = curr_genome_num
       
-      
\ No newline at end of file
+      




More information about the Avida-cvs mailing list