コード例 #1
0
ファイル: tool.py プロジェクト: hku8/UCSF-RBVI-Internship
 def _run(self, atomspec):
     # Execute "sample count" command for given atomspec
     from chimerax.core.commands import run
     from chimerax.core.logger import StringPlainTextLog
     with StringPlainTextLog(self.session.logger) as log:
         try:
             run(self.session, "sample count " + atomspec)
         finally:
             html = "<pre>\n%s</pre>" % log.getvalue()
             js = ('document.getElementById("output").innerHTML = %s'
                   % repr(html))
             self.html_view.page().runJavaScript(js)
コード例 #2
0
 def f(session, batch_commands, q=q):
     ret_dict = {}
     for cmd in batch_commands:
         with StringPlainTextLog(session.logger) as rest_log:
             fname, args, kwargs = cmd
             f_dict = ret_dict[fname] = {}
             func = self.standard_functions.get(fname, None)
             if func is None:
                 err_msg = 'Unrecognised function name: {}'.format(fname)
                 ret_dict['error'] = err_msg
                 break
             f_dict.update(func(session, *args, **kwargs))
             f_dict['log'] = rest_log.getvalue()
     q.put(ret_dict)
コード例 #3
0
ファイル: __init__.py プロジェクト: tristanic/isolde
 def inner_func(session, *args, q=q, **kwargs):
     from chimerax.core.logger import StringPlainTextLog
     with StringPlainTextLog(session.logger) as rest_log:
         ret = {}
         try:
             ret.update(func(session, *args, **kwargs))
         except Exception as e:
             import traceback
             ret.update({
                 'error': str(e),
                 'traceback': traceback.format_exc()
             })
         ret['log'] = rest_log.getvalue()
     q.put(ret)
コード例 #4
0
ファイル: devel.py プロジェクト: Yongcheng123/ChimeraX
def _run(path, logger, exit, unbound_method, *args, **kw):
    from chimerax.core.logger import StringPlainTextLog
    bb = _get_builder(path, logger)
    exit_status = 0
    if bb is not None:
        with StringPlainTextLog(logger) as log:
            try:
                unbound_method(bb, *args, **kw)
            except Exception:
                import traceback
                logger.bug(traceback.format_exc())
                exit_status = 1
            output = log.getvalue()
        logger.info(output)
    else:
        exit_status = 1
    if exit:
        raise SystemExit(exit_status)
    return exit_status
コード例 #5
0
 def f(args=args, session=session, q=q):
     logger = session.logger
     # rest_log.log_summary gets called at the end
     # of the "with" statement
     with StringPlainTextLog(logger) as rest_log:
         from chimerax.core.commands import run
         try:
             commands = args["command"]
         except KeyError:
             logger.error("\"command\" parameter missing")
         else:
             try:
                 for cmd in commands:
                     if isinstance(cmd, bytes):
                         cmd = cmd.decode('utf-8')
                     run(session, cmd, log=False)
             except NotABug as e:
                 logger.info(str(e))
         q.put(rest_log.getvalue())