def _initLogging(self, prefix=None, console=True): Session._initLogging(self, prefix, console=False, logfile=not self._is_sandboxed) if self._debug_log: self.log.addHandler(SimDebugHandler()) self.log.addHandler(self.log_sender)
def __init__(self, appname, daemonized=False): self._console = None Session.__init__(self, appname, daemonized) # prompt color self._pscolor = 'reset' # showing prompt? self._prompting = False # our command completer for Python code self._completer = NicosCompleter(self.namespace).complete
def checkAccess(self, required): # for now, we have no way of knowing who the user is, so we cannot # respond to level= keyword if 'passcode' in required: code = required['passcode'] if input_func('Please enter "%s" to proceed, or press Enter to ' 'cancel: ' % code) != code: raise AccessError('passcode not correct') return Session.checkAccess(self, required)
def checkAccess(self, required): if 'level' in required: rlevel = self._string_to_level(required['level']) if rlevel > self._user_level: raise AccessError('%s access is not sufficient, %s access ' 'is required' % (ACCESS_LEVELS.get(self._user_level, str(self._user_level)), ACCESS_LEVELS.get(rlevel, str(rlevel)))) return Session.checkAccess(self, required)
"""Methods to parse setup files.""" from __future__ import absolute_import, division, print_function import glob import inspect import os from nicos.core.device import Device as _Class_device from nicos.core.sessions import Session from .utilities.excluded_devices import excluded_device_classes from .utilities.utilities import getNicosDir modules = {} session = Session('SetupFileTool') def init(log): # uses the provided directories to search for *.py files. # then tries to import that file. # the imported module will be appended to a dictionary, the key being # it's path splitted by dots an without the prepending nicos directory. # e.g. nicos.services.cache.server is the key to the module # <nicos directory>/nicos/services/cache/server.py # returns the dictionary. paths = [os.path.join(getNicosDir(), 'nicos', 'devices'), os.path.join(getNicosDir(), 'nicos', 'services')] + glob.glob( getNicosDir() + '/nicos_mlz/*/devices')
def readSetupInfo(self): # since we know the setups don't change, only read them once if not self._setup_info: return Session.readSetupInfo(self) return self._setup_info
def __init__(self, appname, daemonized=False): old_setup_info = getattr(self, '_setup_info', {}) Session.__init__(self, appname, daemonized) self._setup_info = old_setup_info self._setup_paths = (path.join(module_root, 'test', 'setups'), ) self._user_level = system_user.level
def setSPMode(self, on): Session.setSPMode(self, on) self.resetPrompt()
def setMode(self, mode): Session.setMode(self, mode) self.resetPrompt()
def loadSetup(self, *args, **kwds): Session.loadSetup(self, *args, **kwds) self.resetPrompt()
def _initLogging(self, prefix=None, console=True): Session._initLogging(self, prefix, console) sys.displayhook = self._displayhook