Commit edc32f6a authored by Valentin Valls's avatar Valentin Valls
Browse files

Expose a standard command `flint`

parent 20ff082f
...@@ -146,6 +146,7 @@ __all__ = ( ...@@ -146,6 +146,7 @@ __all__ = (
"move", "move",
"plotinit", "plotinit",
"plotselect", "plotselect",
"flint",
"prdef", "prdef",
"sync", "sync",
"lslog", "lslog",
...@@ -809,6 +810,31 @@ example: ...@@ -809,6 +810,31 @@ example:
print("") print("")
def flint():
"""
Returns a proxy to the running Flint application used by BLISS, else create
one.
If there is problem to create or to connect to Flint, an exception is
raised.
# This can be used to start Flint
BLISS [1]: flint()
# This can be used to close Flint
BLISS [1]: f = flint()
BLISS [2]: f.close()
# This can be used to kill Flint
BLISS [1]: f = flint()
BLISS [2]: f.kill9()
"""
proxy = plot_module.get_flint(creation_allowed=True, mandatory=True)
print("Currently Flint PID: ", proxy.pid)
print("")
return proxy
@typeguardTypeError_to_hint @typeguardTypeError_to_hint
@typeguard.typechecked @typeguard.typechecked
def edit_roi_counters(detector: Lima, acq_time: Optional[float] = None): def edit_roi_counters(detector: Lima, acq_time: Optional[float] = None):
......
...@@ -3,12 +3,14 @@ import time ...@@ -3,12 +3,14 @@ import time
import builtins import builtins
import pytest import pytest
import numpy import numpy
import psutil
from bliss.shell.standard import wa, wm, sta, stm, _launch_silx, umv from bliss.shell.standard import wa, wm, sta, stm, _launch_silx, umv
from bliss.shell.standard import sin, cos, tan, arcsin, arccos, arctan, arctan2 from bliss.shell.standard import sin, cos, tan, arcsin, arccos, arctan, arctan2
from bliss.shell.standard import log, log10, sqrt, exp, power, deg2rad, rad2deg from bliss.shell.standard import log, log10, sqrt, exp, power, deg2rad, rad2deg
from bliss.shell.standard import rand, date, sleep from bliss.shell.standard import rand, date, sleep
from bliss.shell.standard import flint
@pytest.fixture @pytest.fixture
...@@ -292,3 +294,25 @@ def test_open_silx(xvfb): ...@@ -292,3 +294,25 @@ def test_open_silx(xvfb):
time.sleep(1) time.sleep(1)
assert process.returncode is None assert process.returncode is None
process.terminate() process.terminate()
def test_open_close_flint(test_session_without_flint):
f = flint()
assert f is not None
pid = f.pid
assert psutil.pid_exists(pid)
f.close()
process = psutil.Process(pid)
psutil.wait_procs([process], timeout=1)
assert not psutil.pid_exists(pid)
def test_open_kill_flint(test_session_without_flint):
f = flint()
assert f is not None
pid = f.pid
assert psutil.pid_exists(pid)
f.kill9()
process = psutil.Process(pid)
psutil.wait_procs([process], timeout=1)
assert not psutil.pid_exists(pid)
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