def check_lock(self, file_name): try: with Lock(file_name, timeout=2): pass except LockException as error: if self.confirm_action('Clear lock?', str(error)): Lock(file_name).release()
def accept(self): try: with Lock(self.reduce.wrapper_file): self.reduce.write_peaks(self.peaks) except LockException as error: if self.confirm_action('Clear lock?', str(error)): Lock(self.reduce.wrapper_file).release() self.stop() super(FindDialog, self).accept()
def outview(self): self.defaultview = self.outview scan = self.sample + '_' + self.scan_combo.currentText() entry = self.entry_combo.currentText() program = 'nx' + self.program_combo.currentText() if (program == 'nxcombine' or program == 'nxmasked_combine' or program == 'nxpdf'): entry = 'entry' wrapper_file = os.path.join(self.sample_directory, scan + '.nxs') with Lock(wrapper_file): root = nxload(wrapper_file) if program in root[entry]: text = 'Date: ' + root[entry][program]['date'].nxvalue + '\n' text = text + root[entry][program]['note/data'].nxvalue self.output_box.setPlainText(text) else: self.output_box.setPlainText('No output for %s' % program)
def clean_scan(self, scan_file): with Lock(scan_file): scan_root = nxload(scan_file, 'rw') for entry in scan_root: if 'transform' in scan_root[entry]: del scan_root[entry]['transform'] if 'masked_transform' in scan_root[entry]: del scan_root[entry]['masked_transform'] if 'nxtransform' in scan_root[entry]: del scan_root[entry]['nxtransform'] if 'nxcombine' in scan_root[entry]: del scan_root[entry]['nxcombine'] if 'nxmasked_transform' in scan_root[entry]: del scan_root[entry]['nxmasked_transform'] if 'nxmasked_combine' in scan_root[entry]: del scan_root[entry]['nxmasked_combine'] if 'data' in scan_root[entry]: if 'data' in scan_root[entry]['data']: del scan_root[entry]['data/data'] scan_root[entry]['data/data'] = NXlink( '/entry/data/data', self.scan_label + '/' + entry + '.h5') if 'data_mask' in scan_root[entry]['data']: del scan_root[entry]['data/data_mask']