def emit(self, record): if record.levelno == ACTION or record.filename: # do not write ACTIONs to logfiles, they're only informative # also do not write messages from simulation mode return msg = recordToMessage(record, '') session.elogEvent('message', msg)
def beginScan(self): # Copy of the data.manager.beginScan with s/ScanDataset/ADScanDataset/ self._data._clean((BLOCK, )) dataset = ADScanDataset( subscan=self._subscan, devices=self._devices, environment=self._envlist, detectors=self._detlist, preset=self._preset, info=self._scaninfo, npoints=self._npoints, xindex=self._xindex, startpositions=self._startpositions, endpositions=self._endpositions, continuation=self._continuation, cont_direction=self._cont_direction, parameters=self._paraValueinfo, ) for sink in session.datasinks: if sink.isActive(dataset): handlers = sink.createHandlers(dataset) dataset.handlers.extend(handlers) if self._data._current: self._data._current.subsets.append(dataset) dataset.number = len(self._data._current.subsets) self._data._stack.append(dataset) # self.dataset = self._data._init(dataset) # XXX: when to clean these up? self.dataset = dataset self._data._last_scans.append(self.dataset) self.dataset.dispatch('prepare') self.dataset.dispatch('begin') session.elogEvent('scanbegin', self.dataset)
def endScan(self): session.experiment.data.finishScan() try: from nicos.core.data import ScanData session.elogEvent('scanend', ScanData(self.dataset)) except Exception: session.log.debug('could not add scan to electronic logbook', exc=1) session.breakpoint(1)
def _LogAttach(description, paths, names): """Attach one or more files to the electronic logbook. The file *paths* should be temporary file names accessible from the machine on which the electronic logbook daemon runs (i.e. on a common network share). They will be moved to the logbook using the given *names*. This is intended to be used from the NICOS GUI, from the respective dialogs. """ session.elogEvent('attachment', (description, paths, names))
def LogEntry(entry): """Make a free-form entry in the electronic logbook. The entry will be processed as Creole markup. Note: on the command line, you can also call this function by entering a Python comment. I.e., these two commands are equivalent at the command line: >>> LogEntry('improved sample holder') >>> # improved sample holder """ session.elogEvent('entry', entry)
def beginScan(self): self.dataset = session.experiment.data.beginScan( subscan=self._subscan, devices=self._devices, environment=self._envlist, detectors=self._detlist, preset=self._preset, info=self._scaninfo, npoints=self._npoints, xindex=self._xindex, startpositions=self._startpositions, endpositions=self._endpositions, continuation=self._continuation, cont_direction=self._cont_direction, ) session.elogEvent('scanbegin', self.dataset)
def doWriteOffset(self, value): """Adapt the limits to the new offset.""" old_offset = self.offset diff = value - old_offset if isinstance(self, HasLimits): self._adjustLimitsToOffset(value, diff) # For moveables, also adjust target to avoid getting value and # target out of sync if 'target' in self.parameters and self.target is not None: self._setROParam('target', self.target - diff) # Since offset changes directly change the device value, refresh # the cache instantly here if self._cache: self._cache.put(self, 'value', self.read(0) - diff, currenttime(), self.maxage) session.elogEvent('offset', (str(self), old_offset, value))
def execute(self, controller): """Execute the script in the given namespace, using "controller" to execute individual blocks. """ session.scriptEvent('start', (self.name, self.text)) session.countloop_request = None # reset any pause flag from before # this is to allow the traceback module to report the script's # source code correctly updateLinecache('<script>', self.text) # note: checking session._experiment since using session.experiment # would try to create the device, which means you can't execute any # command when the experiment fails if session._experiment and session.mode == MASTER: session.experiment.scripts += [self.text] self._exp_script_index = len(session.experiment.scripts) - 1 if self.name: session.elogEvent('scriptbegin', self.name) session.beginActionScope(path.basename(self.name)) # notify clients of "input" session.log.log(INPUT, formatScript(self)) try: while self.curblock < len(self.code) - 1: self._run.wait() self.curblock += 1 self.blockStart = time.time() self.emitETA(controller) controller.start_exec(self.code[self.curblock], controller.namespace, None, self.settrace) finally: if self.name: session.endActionScope() if session._experiment and session.mode == MASTER: session.experiment.scripts = session.experiment.scripts[:-1] if self.name: session.elogEvent('scriptend', self.name)
def __exit__(self, *args): session.endActionScope() if session.experiment and session.mode in (MASTER, SIMULATION): session.experiment.scripts = session.experiment.scripts[:-1] session.elogEvent('scriptend', self.filename)
def __enter__(self): session.beginActionScope(self.filename) if session.experiment and session.mode in (MASTER, SIMULATION): session.experiment.scripts += [self.code] session.elogEvent('scriptbegin', self.filename)
def doWriteSamplename(self, name): if name: session.elogEvent('sample', name)