def shutdown_kernel(self): """Cleanly shut down the kernel and client subprocesses""" info('Shutting down kernel...') if self.kernel_client: self.kernel_client.stop_channels() if self.kernel_manager and self.kernel_manager.kernel: self.kernel_manager.shutdown_kernel()
def main(env=None): if env is not None: taurus.info('ignoring obsolete env parameter to qtdesigner_start') version = "taurusdesigner %s" % (taurus.Release.version) usage = "Usage: %prog [options] <ui file(s)>" description = "The Qt designer application customized for taurus" parser = optparse.OptionParser(version=version, usage=usage, description=description) parser.add_option("--taurus-path", dest="tauruspath", default="", help="additional directories to look for taurus widgets") parser.add_option( "--qt-designer-path", dest="pyqtdesignerpath", default="", help="additional directories to look for python qt widgets") options, args = parser.parse_args() taurus_extra_path = None # Set TAURUSQTDESIGNERPATH if len(options.tauruspath) > 0: taurus_extra_path = options.tauruspath if env is None: env = get_taurus_designer_env(taurus_extra_path=taurus_extra_path) sys.exit(qtdesigner_start(args, env=env))
def main(): import taurus.qt.qtgui.application Application = taurus.qt.qtgui.application.TaurusApplication app = Application.instance() owns_app = app is None if owns_app: app = Application(app_name="Logging demo", app_version="1.0", org_domain="Taurus", org_name="Taurus community") taurus.setLogLevel(taurus.Trace) taurus.disableLogOutput() w = QLoggingWidget() taurus.trace("trace message") taurus.debug("debug message") taurus.info("Hello world") taurus.warning("Warning message") taurus.error("error message") taurus.critical("critical message") w.setMinimumSize(1200, 600) w.show() app.exec_() w.stop_logging()
def register_subcommands(): """Discover and add subcommands to taurus_cmd""" # Add subcommands from the taurus_subcommands entry point for ep in pkg_resources.iter_entry_points("taurus.cli.subcommands"): try: subcommand = ep.load() taurus_cmd.add_command(subcommand) except Exception as e: # ----------------------------------------------------------- # Use info instead of warning in case of nonimportable Qwt5 # (e.g. when using py3 or Qt5) to avoid spam # This special case can be removed when taurus.qt.qtgui.qwt5 # is moved to a separate plugin, since the entry point will # be registered only if the plugin is installed if ep.name == "qwt5": taurus.info( 'Cannot add "%s" subcommand to taurus. Reason: %r', ep.name, e, ) continue # ----------------------------------------------------------- taurus.warning('Cannot add "%s" subcommand to taurus. Reason: %r', ep.name, e)
def taurus_cmd(log_level, polling_period, serialization_mode, rconsole_port, default_formatter): """The main taurus command""" # set log level taurus.setLogLevel(getattr(taurus, log_level)) # set polling period if polling_period is not None: taurus.changeDefaultPollingPeriod(polling_period) # set serialization mode if serialization_mode is not None: from taurus.core.taurusbasetypes import TaurusSerializationMode m = getattr(TaurusSerializationMode, serialization_mode) taurus.Manager().setSerializationMode(m) # enable the remote console port if rconsole_port is not None: try: import rfoo.utils.rconsole rfoo.utils.rconsole.spawn_server(port=rconsole_port) taurus.info(("rconsole started. " + "You can connect to it by typing: rconsole -p %d"), rconsole_port) except Exception as e: taurus.warning("Cannot spawn debugger. Reason: %s", e) # set the default formatter if default_formatter is not None: from taurus import tauruscustomsettings setattr(tauruscustomsettings, 'DEFAULT_FORMATTER', default_formatter)
def run(user_ns=None): # TODO: Temporary solution, available while Taurus3 is being supported. from taurus import tauruscustomsettings from sardana import sardanacustomsettings max_counts = getattr(sardanacustomsettings, 'TAURUS_MAX_DEPRECATION_COUNTS', 0) tauruscustomsettings._MAX_DEPRECATIONS_LOGGED = max_counts # # initialize input handler as soon as possible import sardana.spock.inputhandler input_handler = sardana.spock.inputhandler.InputHandler() try: mainloop(user_ns=user_ns) finally: try: clean_up() except Exception: pass # TODO: Temporary solution, available while Taurus3 is being supported. try: from taurus.core.util.log import _DEPRECATION_COUNT from taurus import info info('\n*********************\n%s', _DEPRECATION_COUNT.pretty()) except: pass
def run(): # TODO: Temporary solution, available while Taurus3 is being supported. from taurus import tauruscustomsettings from sardana import sardanacustomsettings max_counts = getattr(sardanacustomsettings, 'TAURUS_MAX_DEPRECATION_COUNTS', 0) tauruscustomsettings._MAX_DEPRECATIONS_LOGGED = max_counts try: check_requirements() except exception.SpockMissingRequirement as requirement: print(str(requirement)) sys.exit(-1) except exception.SpockMissingRecommended as recommended: print(str(recommended)) prepare_input_handler() prepare_cmdline() launch_new_instance() # TODO: Temporary solution, available while Taurus3 is being supported. try: from taurus.core.util.log import _DEPRECATION_COUNT from taurus import info info('\n*********************\n%s', _DEPRECATION_COUNT.pretty()) except: pass
def main(): # set the log level to WARNING avoid spamming the CLI while loading # subcommands # it will be restored to the desired one first thing in taurus_cmd() taurus.setLogLevel(taurus.Warning) # Add subcommands from the taurus_subcommands entry point for ep in pkg_resources.iter_entry_points('taurus.cli.subcommands'): try: subcommand = ep.load() taurus_cmd.add_command(subcommand) except Exception as e: # ----------------------------------------------------------- # Use info instead of warning in case of nonimportable Qwt5 # (e.g. when using py3 or Qt5) to avoid spam # This special case can be removed when taurus.qt.qtgui.qwt5 # is moved to a separate plugin, since the entry point will # be registered only if the plugin is installed if ep.name == 'qwt5': taurus.info('Cannot add "%s" subcommand to taurus. Reason: %r', ep.name, e) continue # ----------------------------------------------------------- taurus.warning('Cannot add "%s" subcommand to taurus. Reason: %r', ep.name, e) # launch the taurus command taurus_cmd()
def __init__(self, parent=None, selectables=None, host=None, designMode=None, singleModel=False): '''Creator of TaurusModelChooser :param parent: (QObject) parent for the dialog :param selectables: (list<TaurusElementType>) if passed, only elements of the tree whose type is in the list will be selectable. :param host: (QObject) Tango host to be explored by the chooser :param designMode: (bool) needed for taurusdesigner but ignored here :param singleModel: (bool) If True, the selection will be of just one model. Otherwise (default) a list of models can be selected ''' TaurusWidget.__init__(self, parent) if host is None: try: # TODO: Tango-centric! host = taurus.Factory('tango').getAuthority().getFullName() except Exception as e: taurus.info('Cannot populate Tango Tree: %r', e) self._allowDuplicates = False self.setLayout(Qt.QVBoxLayout()) self.tree = TaurusModelSelectorTree(selectables=selectables, buttonsPos=Qt.Qt.BottomToolBarArea) self.tree.setModel(host) self.list = TaurusModelList() self.list.setSelectionMode(Qt.QAbstractItemView.ExtendedSelection) applyBT = Qt.QToolButton() applyBT.setToolButtonStyle(Qt.Qt.ToolButtonTextBesideIcon) applyBT.setText('Apply') applyBT.setIcon(Qt.QIcon("status:available.svg")) self.setSingleModelMode(singleModel) # toolbar self._toolbar = self.tree._toolbar self._toolbar.addAction(self.list.removeSelectedAction) self._toolbar.addAction(self.list.removeAllAction) self._toolbar.addAction(self.list.moveUpAction) self._toolbar.addAction(self.list.moveDownAction) self._toolbar.addSeparator() self._toolbar.addWidget(applyBT) self.layout().addWidget(self.tree) self.layout().addWidget(self.list) # self.tree.setUseParentModel(True) #It does not work!!!! # @todo: This is Workaround because UseSetParentModel is giving trouble again! self.modelChanged.connect(self.tree.setModel) # connections: self.tree.addModels.connect(self.addModels) applyBT.clicked.connect(self._onUpdateModels)
def init_taurus_args(parser=None, args=None, values=None): """Parses the command line using :func:`taurus.core.util.argparse.parse_taurus_args`. After the command line is parsed, actions are taken on each recognized parameter. For example, the taurus log level and the default tango host are set accordingly. :param parser: an option parser or None (default) to create a new parser :type parser: :class:`optparse.OptionParser` :param args: the list of arguments to process (default is None meaning: sys.argv[1:]) :type args: seq<str> :param values: a :class:`optparse.Values` object to store option arguments in (default is None meaning: a new instance of Values) - if you give an existing object, the option defaults will not be initialized on it :return: a tuple of three elements: parser, options, args :rtype: :class:`optparse.OptionParser`, :class:`optparse.Values`, seq<str> """ import taurus parser, options, args = parse_taurus_args(parser=parser, args=args, values=values) # initialize taurus log level log_level_str = options.taurus_log_level.capitalize() if hasattr(taurus, log_level_str): log_level = getattr(taurus, log_level_str) taurus.setLogLevel(log_level) # initialize tango host if options.tango_host is not None: tango_factory = taurus.Factory("tango") tango_host = options.tango_host tango_factory.set_default_tango_host(tango_host) # initialize taurus polling period if options.taurus_polling_period is not None: taurus.Manager().changeDefaultPollingPeriod( options.taurus_polling_period) # initialize taurus serialization mode if options.taurus_serialization_mode is not None: import taurus.core.taurusbasetypes SerMode = taurus.core.taurusbasetypes.TaurusSerializationMode m = options.taurus_serialization_mode.capitalize() if hasattr(SerMode, m): m = getattr(SerMode, m) taurus.Manager().setSerializationMode(m) # initialize remote console port if options.remote_console_port is not None: try: import rfoo.utils.rconsole rfoo.utils.rconsole.spawn_server(port=options.remote_console_port) taurus.info( "rconsole started. You can connect to it by typing: rconsole -p %d", options.remote_console_port) except Exception, e: taurus.warning("Cannot spawn debugger. Reason: %s", str(e))
def exec_(*args, **kwargs): # TODO: substitute this ugly hack by some more general mechanism try: ret = Qt.QApplication.exec_(*args, **kwargs) except TypeError: ret = Qt.QApplication.exec_(*args) from taurus.core.util.log import _DEPRECATION_COUNT from taurus import info info('\n*********************\n%s', _DEPRECATION_COUNT.pretty()) return ret
def init_taurus_args(parser=None, args=None, values=None): """Parses the command line using :func:`taurus.core.util.argparse.parse_taurus_args`. After the command line is parsed, actions are taken on each recognized parameter. For example, the taurus log level and the default tango host are set accordingly. :param parser: an option parser or None (default) to create a new parser :type parser: :class:`optparse.OptionParser` :param args: the list of arguments to process (default is None meaning: sys.argv[1:]) :type args: seq<str> :param values: a :class:`optparse.Values` object to store option arguments in (default is None meaning: a new instance of Values) - if you give an existing object, the option defaults will not be initialized on it :return: a tuple of three elements: parser, options, args :rtype: :class:`optparse.OptionParser`, :class:`optparse.Values`, seq<str> """ import taurus parser, options, args = parse_taurus_args( parser=parser, args=args, values=values) # initialize taurus log level log_level_str = options.taurus_log_level.capitalize() if hasattr(taurus, log_level_str): log_level = getattr(taurus, log_level_str) taurus.setLogLevel(log_level) # initialize tango host if options.tango_host is not None: tango_factory = taurus.Factory("tango") tango_factory.set_default_tango_host(options.tango_host) # initialize taurus polling period if options.taurus_polling_period is not None: taurus.Manager().changeDefaultPollingPeriod(options.taurus_polling_period) # initialize taurus serialization mode if options.taurus_serialization_mode is not None: import taurus.core.taurusbasetypes SerMode = taurus.core.taurusbasetypes.TaurusSerializationMode m = options.taurus_serialization_mode.capitalize() if hasattr(SerMode, m): m = getattr(SerMode, m) taurus.Manager().setSerializationMode(m) # initialize remote console port if options.remote_console_port is not None: try: import rfoo.utils.rconsole rfoo.utils.rconsole.spawn_server(port=options.remote_console_port) taurus.info("rconsole started. You can connect to it by typing: rconsole -p %d", options.remote_console_port) except Exception, e: taurus.warning("Cannot spawn debugger. Reason: %s", str(e))
def _load_class_from_group(group, include=(".*", ), exclude=()): """ Factory that returns the first available class from the group entry point. The selection is done among the classes registered in the `group` entry-point, prioritized according to the given `include` and `exclude` patterns (see :func:`taurus.core.util.plugin.selectEntryPoints`) """ eps = selectEntryPoints(group, include=include, exclude=exclude) for ep in eps: try: return ep.load(), ep.name except: info("Cannot load %s", ep.name) raise ImportError("Could not load any class from {}".format(eps))
def fill_log(): import time import random for i in xrange(10): taurus.info("Hello world %04d" % i) loggers = ["Object%02d" % (i + 1) for i in range(10)] i = 0 while True: time.sleep(random.random()) logger = logging.getLogger(random.choice(loggers)) level = random.randint(taurus.Trace, taurus.Critical) logger.log(level, "log message %04d" % i) i += 1
def import_ep(name, package, entry_point): """ Lazily imports a module defined in an entry point. The LazyModule is inserted in sys.modules as <package>.<name> :param name: name of the module :param package: name of the package to which the module belongs :param entry_point: entry-point for a module :return: A LazyModule object """ m = LazyModule(name, package, entry_point) setattr(sys.modules[package], name, m) modname = "{}.{}".format(package, name) sys.modules[modname] = m info('Plugin "%s" lazy-loaded as "%s"', entry_point.module_name, modname) return m
def _launch_kernel(self, kernel_cmd, **kw): try: profile = kernel_cmd[kernel_cmd.index("--profile") + 1] except ValueError: self.is_valid_spock_profile = False else: if check_spock_profile(profile): self.is_valid_spock_profile = True else: index = kernel_cmd.index("--profile") del kernel_cmd[index] del kernel_cmd[index] for arg in kernel_cmd[:]: if arg.startswith("--Spock"): kernel_cmd.remove(arg) self.is_valid_spock_profile = False error("Checking spock profile failed.") info('Starting kernel...') self.kernel_about_to_launch.emit() return super()._launch_kernel(kernel_cmd, **kw)
def __init__(self, parent=None, taurusItemsConf=None, showXcol=True): super(TaurusItemConfDlg, self).__init__(parent) self.loadUi() self._showXcol = showXcol if taurusItemsConf is None: taurusItemsConf = [ TaurusItemConf(YModel=None, XModel=None, name=None) ] self.ui.tangoTree.setButtonsPos(Qt.Qt.RightToolBarArea) # @todo: The action for this button is not yet implemented self.ui.reloadBT.setEnabled(False) self.model = TaurusCurveItemTableModel(taurusItemsConf) table = self.ui.curvesTable table.setModel(self.model) table.setColumnHidden(X, not self._showXcol) # ------------------------------------------------------------------- # I get "UnboundLocalError: local variable 'taurus' referenced before # assignment" if I don't import taurus again here # TODO: check if this workaround is really needed import taurus # ------------------------------------------------------------------- try: # TODO: Tango-centric! host = taurus.Factory('tango').getAuthority().getFullName() self.ui.tangoTree.setModel(host) except Exception as e: taurus.info('Cannot populate Tango Tree: %r', e) # Connections self.ui.applyBT.clicked.connect(self.onApply) self.ui.reloadBT.clicked.connect(self.onReload) self.ui.cancelBT.clicked.connect(self.close) self.ui.tangoTree.addModels.connect(self.onModelsAdded) self.ui.curvesTable.customContextMenuRequested.connect( self.onTableContextMenu)
def taurusgui(confname=None): from taurus.qt.qtgui.taurusgui import TaurusGui taurus.info('Starting execution of TaurusGui') parser = argparse.get_taurus_parser() parser.set_usage("%prog [options] confname") parser.set_description("The taurus GUI application") parser.add_option( "", "--config-dir", dest="config_dir", default=None, help="use the given configuration directory for initialization") parser.add_option( "", "--new-gui", action="store_true", dest="new_gui", default=None, help="launch a wizard for creating a new TaurusGUI application") parser.add_option( "", "--fail-proof", action="store_true", dest="fail_proof", default=None, help= "launch in fail proof mode (it prevents potentially problematic configs from being loaded)" ) app = TaurusApplication(cmd_line_parser=parser, app_name="taurusgui", app_version=taurus.Release.version) args = app.get_command_line_args() options = app.get_command_line_options() if options.new_gui: # launch app settings wizard instead of taurusgui from taurus.qt.qtgui.taurusgui import AppSettingsWizard wizard = AppSettingsWizard() wizard.show() sys.exit(app.exec_()) if confname is None: confname = options.config_dir if confname is None: if len( args ) == 1: # for backwards compat, we allow to specify the confname without the "--config-dir" parameter confname = args[0] else: parser.print_help(sys.stderr) sys.exit(1) if options.fail_proof: configRecursionDepth = 0 else: configRecursionDepth = None gui = TaurusGui(None, confname=confname, configRecursionDepth=configRecursionDepth) gui.show() ret = app.exec_() taurus.info('Finished execution of TaurusGui') sys.exit(ret)
def prepare_logging(options, args, tango_args, start_time=None, log_messages=None): taurus.setLogLevel(taurus.Debug) root = Logger.getRootLog() # output logger configuration log_output_level = options.log_level log_level_map = { "0" : taurus.Critical, "critical" : taurus.Critical, "1" : taurus.Error, "error" : taurus.Error, "2" : taurus.Warning, "warning" : taurus.Warning, "3" : taurus.Info, "info" : taurus.Info, "4" : taurus.Debug, "debug" : taurus.Debug, "5" : taurus.Trace, "trace" : taurus.Trace, } log_output_level = log_level_map[log_output_level] root.handlers[0].setLevel(log_output_level) if not options.without_log_file: log_file_level = options.log_file_level log_file_level = log_level_map[log_file_level] # Create a file handler if options.log_file_name is None: _, ds_name = os.path.split(args[0]) ds_name, _ = os.path.splitext(ds_name) ds_instance = args[-1].lower() import getpass try: tangodir = 'tango-%s' % getpass.getuser() #include the user name to avoid permission errors except: tangodir = 'tango' % getpass.getuser() path = os.path.join(os.sep, "tmp", tangodir, ds_name, ds_instance) log_file_name = os.path.join(path, 'log.txt') else: log_file_name = options.log_file_name path = os.path.dirname(log_file_name) # because some versions of python have a bug in logging.shutdown (this # function is not protected against deleted handlers) we store the # handlers we create to make sure a strong reference exists when the # logging.shutdown is called taurus._handlers = handlers = [] try: if not os.path.exists(path): os.makedirs(path, 0777) from sardana import sardanacustomsettings maxBytes = getattr(sardanacustomsettings, 'LOG_FILES_SIZE', 1E7) backupCount = getattr(sardanacustomsettings, 'LOG_BCK_COUNT', 5) fmt = Logger.getLogFormat() f_h = logging.handlers.RotatingFileHandler(log_file_name, maxBytes=maxBytes, backupCount=backupCount) f_h.setFormatter(fmt) f_h.setLevel(log_file_level) root.addHandler(f_h) handlers.append(f_h) if start_time is not None: taurus.info("Started at %s", start_time) else: taurus.info("Starting up...") taurus.info("Log is being stored in %s", log_file_name) except: if start_time is not None: taurus.info("Started at %s", start_time) else: taurus.info("Starting up...") taurus.warning("'%s' could not be created. Logs will not be stored", log_file_name) taurus.debug("Error description", exc_info=1) if log_messages is None: log_messages = [] for log_message in log_messages: taurus.info(*log_message) taurus.debug("Start args=%s", args) taurus.debug("Start tango args=%s", tango_args) taurus.debug("Start options=%s", options) taurus.debug("Using PyTango %s from %s", PyTango.Release.version, PyTango.__path__[0]) taurus.debug("Using taurus %s from %s", taurus.Release.version, taurus.__path__[0]) taurus.debug("Using sardana %s from %s", sardana.Release.version, sardana.__path__[0])
def run_tango_server(tango_util=None, start_time=None): try: if tango_util is None: tango_util = Util(sys.argv) util = Util.instance() SardanaServer.server_state = State.Init util.server_init() SardanaServer.server_state = State.Running if start_time is not None: import datetime dt = datetime.datetime.now() - start_time taurus.info("Ready to accept request in %s", dt) else: taurus.info("Ready to accept request") util.server_run() SardanaServer.server_state = State.Off taurus.info("Exiting") except DevFailed: taurus.info("Exiting") taurus.critical("Server exited with DevFailed", exc_info=1) except KeyboardInterrupt: taurus.info("Exiting") taurus.critical("Interrupted by keyboard") except Exception: taurus.info("Exiting") taurus.critical("Server exited with unforeseen exception", exc_info=1) taurus.info("Exited")
def prepare_logging(options, args, tango_args, start_time=None, log_messages=None): taurus.setLogLevel(taurus.Debug) root = Logger.getRootLog() # output logger configuration log_output_level = options.log_level log_level_map = { "0": taurus.Critical, "critical": taurus.Critical, "1": taurus.Error, "error": taurus.Error, "2": taurus.Warning, "warning": taurus.Warning, "3": taurus.Info, "info": taurus.Info, "4": taurus.Debug, "debug": taurus.Debug, "5": taurus.Trace, "trace": taurus.Trace, } log_output_level = log_level_map[log_output_level] root.handlers[0].setLevel(log_output_level) if not options.without_log_file: log_file_level = options.log_file_level log_file_level = log_level_map[log_file_level] # Create a file handler if options.log_file_name is None: _, ds_name = os.path.split(args[0]) ds_name, _ = os.path.splitext(ds_name) ds_instance = args[-1].lower() import getpass try: # include the user name to avoid permission errors tangodir = 'tango-%s' % getpass.getuser() except: tangodir = 'tango' % getpass.getuser() path = os.path.join(os.sep, "tmp", tangodir, ds_name, ds_instance) log_file_name = os.path.join(path, 'log.txt') else: log_file_name = options.log_file_name path = os.path.dirname(log_file_name) # because some versions of python have a bug in logging.shutdown (this # function is not protected against deleted handlers) we store the # handlers we create to make sure a strong reference exists when the # logging.shutdown is called taurus._handlers = handlers = [] try: if not os.path.exists(path): os.makedirs(path, 0777) from sardana import sardanacustomsettings maxBytes = getattr(sardanacustomsettings, 'LOG_FILES_SIZE', 1E7) backupCount = getattr(sardanacustomsettings, 'LOG_BCK_COUNT', 5) fmt = Logger.getLogFormat() f_h = logging.handlers.RotatingFileHandler(log_file_name, maxBytes=maxBytes, backupCount=backupCount) f_h.setFormatter(fmt) f_h.setLevel(log_file_level) root.addHandler(f_h) handlers.append(f_h) if start_time is not None: taurus.info("Started at %s", start_time) else: taurus.info("Starting up...") taurus.info("Log is being stored in %s", log_file_name) except: if start_time is not None: taurus.info("Started at %s", start_time) else: taurus.info("Starting up...") taurus.warning( "'%s' could not be created. Logs will not be stored", log_file_name) taurus.debug("Error description", exc_info=1) if log_messages is None: log_messages = [] for log_message in log_messages: taurus.info(*log_message) taurus.debug("Start args=%s", args) taurus.debug("Start tango args=%s", tango_args) taurus.debug("Start options=%s", options) taurus.debug("Using PyTango %s from %s", PyTango.Release.version, PyTango.__path__[0]) taurus.debug("Using taurus %s from %s", taurus.Release.version, taurus.__path__[0]) taurus.debug("Using sardana %s from %s", sardana.Release.version, sardana.__path__[0])
elif config: try: import imp print('Loading %s as python module'%config) config = imp.find_module(config.replace('.','/'))[1] dirname = os.path.dirname(config) except: pass dirname = dirname or os.path.dirname(config) or \ vu.get_vacca_property('VACCA_DIR',extract=1) or '' vu.VACCA_DIR = os.environ['VACCA_DIR'] = dirname vu.VACCA_CONFIG = os.environ['VACCA_CONFIG'] = config print('Vacca Environment variables (vacca.main):') print('\n'.join(map(str,(t for t in os.environ.items() if 'VACCA' in t[0])))) ### MAIN CODE FOR PANELS GENERATION IS IN vacca.config SUBMODULE print '-'*80 confname = 'vaccagui' app = TaurusApplication() gui = TaurusGui(None, confname=confname) gui.show() ret = app.exec_() taurus.info('Finished execution of TaurusGui') sys.exit(ret)
def _banner_default(self): config = get_config() return config.FrontendWidget.banner IPythonQtConsoleApp.widget_factory = SpockConsole except ImportError: pass try: check_requirements() except exception.SpockMissingRequirement, requirement: print str(requirement) sys.exit(-1) except exception.SpockMissingRecommended, recommended: print str(recommended) prepare_input_handler() prepare_cmdline() launch_new_instance() # TODO: Temporary solution, available while Taurus3 is being supported. try: from taurus.core.util.log import _DEPRECATION_COUNT from taurus import info info('\n*********************\n%s', _DEPRECATION_COUNT.pretty()) except: pass
def run_tango_server(tango_util=None, start_time=None): # Import here to avoid circular import from sardana.tango.core.SardanaDevice import SardanaDevice try: if tango_util is None: tango_util = Util(sys.argv) util = Util.instance() SardanaServer.server_state = State.Init util.server_init() for device in util.get_device_list("*"): if isinstance(device, SardanaDevice): device.sardana_init_hook() SardanaServer.server_state = State.Running if start_time is not None: import datetime dt = datetime.datetime.now() - start_time taurus.info("Ready to accept request in %s", dt) else: taurus.info("Ready to accept request") util.server_run() SardanaServer.server_state = State.Off taurus.info("Exiting") except DevFailed: taurus.info("Exiting") taurus.critical("Server exited with DevFailed", exc_info=1) except KeyboardInterrupt: taurus.info("Exiting") taurus.critical("Interrupted by keyboard") except Exception: taurus.info("Exiting") taurus.critical("Server exited with unforeseen exception", exc_info=1) taurus.info("Exited")