Commit 58fc9952 authored by Piergiorgio Pancino's avatar Piergiorgio Pancino
Browse files

bliss/shell/standard

- created module to contain shell printing functions
- splitted frontend to backend part from bliss/common/standard
parent 7e2cdac4
......@@ -53,6 +53,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `SCAN_SAVING` is now available only in Bliss Shell. Refers to `current_session.scan_saving`
- Command line arguments
- `--tmux-debug` command line option changed to only `--debug`
- bliss.common.standard
- this module is intended to be the entry point for Bliss as a library, function that
were printing to stdout has been changed to return some forms of aggregated data
- function to be used inside the Bliss shell (with print to stdout) are moved to bliss.shell.standard
### Fixed
......
......@@ -153,7 +153,7 @@ def cleanup(*args, **kwargs):
)
if axis.POS in restore_list:
if verbose:
from bliss.common.standard import umv
from bliss.shell.standard import umv
umv(*previous_motor_position)
else:
......
This diff is collapsed.
......@@ -120,7 +120,7 @@ def initialize(session_name=None):
env_dict = __main__.__dict__
exec("from bliss.common.standard import *", env_dict)
exec("from bliss.shell.standard import *", env_dict)
from bliss.scanning.scan import ScanDisplay
env_dict["SCAN_DISPLAY"] = ScanDisplay(session.name)
......
......@@ -45,7 +45,7 @@ from bliss.data.display import ScanPrinter, ScanEventHandler
from .prompt import BlissPrompt
from .typing_helper import TypingHelper
from bliss.common.standard import info
from bliss.shell.standard import info
from bliss.shell.cli.ptpython_statusbar_patch import NEWstatus_bar, TMUXstatus_bar
logger = logging.getLogger(__name__)
......
This diff is collapsed.
......@@ -164,7 +164,7 @@ BLISS [4]: [a]
```
The equivalent of `repr(obj)` or `str(obj)` is also availabe in
`bliss.common.standard` as `info(obj)` which can be used also outside the Bliss
`bliss.shell.standard` as `info(obj)` which can be used also outside the Bliss
shell.
```
......@@ -172,7 +172,7 @@ Python 3.7.3 (default, Mar 27 2019, 22:11:17)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from bliss.common.standard import info
>>> from bliss.shell.standard import info
>>> class A(object):
... def __repr__(self):
......
......@@ -127,7 +127,7 @@ Help about BLISS functions can be accessed with `help(<command_name>)`:
```
BLISS [2]: help(wa)
Help on function wa in module bliss.common.standard:
Help on function wa in module bliss.shell.standard:
wa(**kwargs)
Displays all positions (Where All) in both user and dial units
......
......@@ -2,7 +2,7 @@
use :
` from bliss.common.standard import *`
` from bliss.shell.standard import *`
to get access to standard shell functions.
......
import pytest
from bliss.common import scans
from bliss.common.standard import wm
from bliss.shell.standard import wm
from bliss import global_map
alias_dump = """Alias Original fullname
......
......@@ -12,7 +12,7 @@ import re
from bliss.common.logtools import *
from bliss.common.logtools import Log
from bliss import logging_startup
from bliss.common.standard import *
from bliss.shell.standard import *
from bliss.common.mapping import Map, map_id
from bliss import global_map
import bliss
......
......@@ -2,7 +2,7 @@
import pytest
import gevent
from bliss.common.standard import lscnt, bench
from bliss.shell.standard import lscnt, bench
EXPECTED = """
Fullname Shape Controller Name Alias
......
......@@ -7,7 +7,7 @@ from mock import Mock
from bliss.common import scans
from bliss.controllers.mca.mythen import Mythen
from bliss.controllers.mca.mythen import lib as mythenlib
from bliss.common.standard import info
from bliss.shell.standard import info
@pytest.fixture
......
......@@ -97,9 +97,7 @@ def test_soft_axis_scan(session):
numpy.testing.assert_array_almost_equal(data["another_motor"], positions)
def test_soft_axis_wa(session, capsys):
def test_soft_axis_wa(session):
o = Object()
m0 = SoftAxis("bla", o)
wa() # call where all
captured = capsys.readouterr()
assert "bla" in captured.out
assert any(whereall.axis_name == "bla" for whereall in wa())
......@@ -8,7 +8,6 @@
import pytest
import gevent
from bliss.common.axis import Axis
from bliss.common.standard import ascan
def test_pseudo_axes_position(s1f, s1b, s1u, s1d, s1vg, s1vo, s1hg, s1ho):
......
......@@ -13,7 +13,7 @@ from bliss.common import scans
from bliss.scanning import scan, chain
from bliss.scanning.acquisition import timer, calc, motor, counter
from bliss.common import event
from bliss.common.standard import plotselect
from bliss.shell.standard import plotselect
def test_pkcom_ascan_gauss(session):
......
......@@ -17,7 +17,7 @@ from bliss.scanning.acquisition.counter import SamplingCounterAcquisitionSlave
from bliss.scanning.scan import Scan, ScanSaving
from bliss.data.scan import watch_session_scans
from bliss.scanning.chain import AcquisitionChain
from bliss.common.standard import info
from bliss.shell.standard import info
from bliss.common import scans
......
......@@ -9,7 +9,7 @@ import pytest
from bliss.common import measurementgroup
from bliss import setup_globals
from bliss.common import scans
from bliss.common.standard import info
from bliss.shell.standard import info
# 3 measurement groups : test_mg MG1 MG2 are configured
# in tests/test_configuration/sessions/test.yml
......
import pytest
from bliss.shell.standard import wa, wm, sta, stm
@pytest.fixture
def s1hg(default_session):
s1hg = default_session.config.get("s1hg")
yield s1hg
s1hg.__close__()
def test_wa_normal(default_session, capsys):
bad = default_session.config.get("bad")
bad.controller.bad_position = False
wa()
captured = capsys.readouterr()
output = "Current Positions: user\n"
output += " dial\n"
output += "\n"
output += " bad\n"
output += "-------\n"
output += "0.00000\n"
output += "0.00000\n"
assert captured.out == output
def test_wa_exception(default_session, capsys):
bad = default_session.config.get("bad")
bad.controller.bad_position = True
wa()
captured = capsys.readouterr()
output = "Current Positions: user\n"
output += " dial\n"
output += "\n"
output += "bad\n"
output += "-----\n"
output += "!ERR\n"
output += "!ERR\n"
assert captured.out[: len(output)] == output
errmsg = "Traceback (most recent call last):\n"
assert captured.err[: len(errmsg)] == errmsg
def test_wa_slits(s1hg, capsys):
wa()
captured = capsys.readouterr()
assert "s1hg" in captured.out
assert not "s1f" in captured.out
assert not "s1b" in captured.out
def test_wm_normal(default_session, capsys):
bad = default_session.config.get("bad")
bad.controller.bad_position = False
wm("bad")
captured = capsys.readouterr()
output = "\n"
output += " bad\n"
output += "-------- -------\n"
output += "User\n"
output += " High inf\n"
output += " Current 0.00000\n"
output += " Low -inf\n"
output += "Offset 0.00000\n"
output += "\n"
output += "Dial\n"
output += " High inf\n"
output += " Current 0.00000\n"
output += " Low -inf\n"
assert captured.out == output
def test_wm_exception(default_session, capsys):
bad = default_session.config.get("bad")
bad.controller.bad_position = True
wm("bad")
captured = capsys.readouterr()
output = "\n"
output += " bad\n"
output += "-------- -----\n"
output += "User\n"
output += " High inf\n"
output += " Current !ERR\n"
output += " Low -inf\n"
output += "Offset 0\n"
output += "\n"
output += "Dial\n"
output += " High inf\n"
output += " Current !ERR\n"
output += " Low -inf\n"
assert captured.out[: len(output)] == output
errmsg = "Traceback (most recent call last):\n"
assert captured.err[: len(errmsg)] == errmsg
errmsg = "RuntimeError: Error on motor 'bad': BAD POSITION\n"
assert captured.err[-len(errmsg) :] == errmsg
def test_sta_normal(default_session, capsys):
bad = default_session.config.get("bad")
bad.controller.bad_position = False
sta()
captured = capsys.readouterr()
output = "Axis Status\n"
output += "------ ---------------------\n"
output += "bad READY (Axis is READY)\n"
assert captured.out == output
def test_sta_slits(s1hg, capsys):
sta()
captured = capsys.readouterr()
assert "s1hg" in captured.out
assert not "s1f" in captured.out
assert not "s1b" in captured.out
def test_sta_exception(default_session, capsys):
bad = default_session.config.get("bad")
bad.controller.bad_position = True
sta()
captured = capsys.readouterr()
output = "Axis Status\n"
output += "------ --------\n"
output += "bad !ERR\n"
assert captured.out[: len(output)] == output
errmsg = "Traceback (most recent call last):\n"
assert captured.err[: len(errmsg)] == errmsg
errmsg = "RuntimeError: Error on motor 'bad': BAD POSITION\n"
assert captured.err[-len(errmsg) :] == errmsg
def test_stm_normal(default_session, capsys):
bad = default_session.config.get("bad")
bad.controller.bad_position = False
stm("bad")
captured = capsys.readouterr()
output = "Axis Status\n"
output += "------ ---------------------\n"
output += "bad READY (Axis is READY)\n"
assert captured.out == output
def test_stm_exception(default_session, capsys):
bad = default_session.config.get("bad")
bad.controller.bad_position = True
stm("bad")
captured = capsys.readouterr()
output = "Axis Status\n"
output += "------ --------\n"
output += "bad !ERR\n"
assert captured.out[: len(output)] == output
errmsg = "Traceback (most recent call last):\n"
assert captured.err[: len(errmsg)] == errmsg
errmsg = "RuntimeError: Error on motor 'bad': BAD POSITION\n"
assert captured.err[-len(errmsg) :] == errmsg
import random
from bliss import current_session
from bliss.common.standard import *
from bliss.shell.standard import *
from bliss.common.counter import SamplingCounter
import numpy
import gevent
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment