def test_all_grids(): # get the directory of this file current_path = os.path.dirname(__file__) # navigate to the grids folder grids_path = os.path.join(current_path, 'data', 'grids') files = os.listdir(grids_path) failed = list() for file_name in files: path = os.path.join(grids_path, file_name) print('-' * 160) print('Loading', file_name, '...', end='') try: file_handler = FileOpen(path) circuit = file_handler.open() print('ok') except: print('Failed') failed.append(file_name) print('Failed:') for f in failed: print('\t', f) for f in failed: print('Attempting', f) path = os.path.join(grids_path, f) file_handler = FileOpen(path) circuit = file_handler.open() assert len(failed) == 0
def run(self): """ run the file open procedure """ self.circuit = MultiCircuit() if isinstance(self.file_name, list): path, fname = os.path.split(self.file_name[0]) self.progress_text.emit('Loading ' + fname + '...') else: path, fname = os.path.split(self.file_name) self.progress_text.emit('Loading ' + fname + '...') self.logger = Logger() file_handler = FileOpen(file_name=self.file_name) self.circuit = file_handler.open( text_func=self.progress_text.emit, progress_func=self.progress_signal.emit) self.logger += file_handler.logger self.valid = True # post events self.progress_text.emit('Done!') self.done_signal.emit()
def run(self): """ run the file save procedure """ # create class to open the file fopen = FileOpen(self.file_name) while not self.__cancel__: if not self.__pause__: if os.path.exists(self.file_name): # load the remote file file_circuit = fopen.open( text_func=self.progress_text.emit, progress_func=self.progress_signal.emit) if file_circuit is not None: # sync the models self.issues, self.version_conflict = model_check( self.circuit, file_circuit) self.highest_version = max(self.circuit.model_version, file_circuit.model_version) # notify the external world that we did sync self.sync_event.emit() else: # the sync failed because the file was being used by another sync process pass else: # the file disappeared! self.logger.add('File missing for synchronization:' + self.file_name) self.cancel() # sleep time.sleep(self.sleep_time) else: # sleep 1 second to catch other events time.sleep(1) # post events self.progress_text.emit('Done!') self.done_signal.emit()