Example #1
0
    def _get_file_list( self ):
        '''Populate the instances with the values
        '''
        # walk through the directories and read the 
        # values
        #
        for root, sub_folders, files in os.walk( self.dir ):
            for folder in sub_folders:
                ex_type_file = os.path.join( root, folder, 'ex_type.cls' )
                if os.path.exists( ex_type_file ):

                    # check if the class specification coincides with
                    # the klass trait of this table
                    #
                    f = open( ex_type_file, 'r' )
                    ex_type_klass = f.read().split( '\n' )[0] # use trim here
                    f.close()

                    klass = _find_class( ex_type_klass )
                    if klass == self.klass:

                        ex_type_dir = os.path.join( root, folder )
                        ex_type_files = os.listdir( ex_type_dir )
                        for filename in fnmatch.filter( ex_type_files, '*.DAT' ):
                            yield os.path.join( ex_type_dir, filename )
Example #2
0
    def __init__(self, data_file, **kw):
        """Initialization: the ex_run is defined by the 
        data_file. The additional data - inputs and derived outputs
        are stored in the data_file.pickle. If this file exists, 
        the exrun is constructed from this data file.
        """
        super(ExRun, self).__init__(**kw)
        self.data_file = data_file
        read_ok = False

        if os.path.exists(self.pickle_file_name):
            print "PICKLE FILE EXISTS"
            file = open(self.pickle_file_name, "r")
            try:
                self.ex_type = pickle.load(file)
                self.unsaved = False
                read_ok = True
            except EOFError:
                read_ok = False

            file.close()
            self.ex_type.data_file = self.data_file

            # In case that the code for processing data
            # has changed since the last dump - run
            # the processing anew. This can be skipped
            # if the code is finished.
            #
            # @todo - the refreshing of the process data
            # should be possible for all instances at once
            # this would avoid the - on-click-based refreshing
            # of the data performed here.
            #
            self.ex_type.process_source_data()
            self.ex_type.derived_data_available = True
            print "*** derived data available ***"

        if not read_ok and os.path.exists(self.ex_type_file_name):

            print "PICKLE FILE DOES NOT EXIST"

            f = open(self.ex_type_file_name, "r")
            ex_type_klass = f.read().split("\n")[0]  # use trim here
            f.close()
            theClass = _find_class(ex_type_klass)
            self.ex_type = theClass(data_file=self.data_file)
            self.unsaved = True
            read_ok = True

            self.ex_type.process_source_data()

        if not read_ok:
            raise ValueError, "Cannot instantiate ExType using %s" % data_file
Example #3
0
    def __init__(self, data_file, **kw):
        '''Initialization: the ex_run is defined by the 
        data_file. The additional data - inputs and derived outputs
        are stored in the data_file.pickle. If this file exists, 
        the exrun is constructed from this data file.
        '''
        super( ExRun, self ).__init__(**kw)
        self.data_file = data_file
        read_ok = False
        
        if os.path.exists( self.pickle_file_name ):
            
            file = open( self.pickle_file_name, 'r' )
            try:
                self.ex_type = pickle.load( file )
                self.unsaved = False
                read_ok = True
            except EOFError:
                read_ok = False

            file.close()
            
        if not read_ok and os.path.exists( self.ex_type_file_name ):
            f = open( self.ex_type_file_name, 'r' )
            ex_type_klass = f.read().split('\n')[0] # use trim here
            f.close()
    
            theClass = _find_class( ex_type_klass )
            self.ex_type = theClass()
            self.unsaved = True
            read_ok = True
                        
        if not read_ok:
            raise ValueError, 'Cannot instantiate ExType using %s' % data_file  

        self.ex_type.data_file = self.data_file
        self.ex_type.process_source_data()