...
 
Commits (5370)

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

......@@ -3,6 +3,7 @@
*.pyc
*.pyo
*~
*.py,cover
*.bck
build
*.swp
......@@ -24,3 +25,8 @@ htmlcov/
.pytest_cache/
.vscode/*
*.so
bliss/release.py
prof
.mypy_cache/
graph.dot
graph.png
This diff is collapsed.
[submodule "driver/ct2/linux"]
path = driver/ct2/linux
url = git://gitlab.esrf.fr/Hardware/p201.git
repos:
- repo: https://github.com/ambv/black
- repo: https://github.com/psf/black
rev: 18.6b4
hooks:
- id: black
language_version: python3 # Should be >= 3.6
\ No newline at end of file
language_version: python3 # Should be >= 3.6
- repo: local
hooks:
- id: flake8-diff
name: flake8-diff
description: Run flake8 linter on diff lines of stage area
language: script
entry: ./flake8-diff.sh
verbose: true # force output when the hook passes
[MASTER]
extension-pkg-whitelist=PyQt5
This diff is collapsed.
Bliss
======
[![build status](https://gitlab.esrf.fr/bliss/bliss/badges/master/build.svg)](http://bliss.gitlab-pages.esrf.fr/bliss)
[![coverage report](https://gitlab.esrf.fr/bliss/bliss/badges/master/coverage.svg)](http://bliss.gitlab-pages.esrf.fr/bliss/htmlcov)
[![build status](https://gitlab.esrf.fr/bliss/bliss/badges/master/pipeline.svg)](https://gitlab.esrf.fr/bliss/bliss/pipelines/master/latest)
[![coverage report](https://gitlab.esrf.fr/bliss/bliss/badges/master/coverage.svg)](https://bliss.gitlab-pages.esrf.fr/bliss/master/htmlcov)
The bliss control library.
Latest documentation from master can be found [here](http://bliss.gitlab-pages.esrf.fr/bliss)
\ No newline at end of file
Latest documentation from master can be found [here](https://bliss.gitlab-pages.esrf.fr/bliss/master)
In short
--------
To update BLISS from source:
```
conda install --file ./requirements-conda.txt
exit and re-enter into conda environment
pip install --no-deps -e .
```
#!python
import re
import sys
from bliss.controllers.demo import lima_diff_simulation_plugin as DiffSimulationPlugin
sys.modules["Lima.Server.plugins.DiffSimulationPlugin"] = DiffSimulationPlugin
from Lima.Server import plugins
plugins.__all__.append("DiffSimulationPlugin")
from Lima.Server.LimaCCDs import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())
#!python
import re
import sys
from bliss.controllers.demo import lima_slits_simulation_plugin as SlitsSimulationPlugin
sys.modules["Lima.Server.plugins.SlitsSimulationPlugin"]=SlitsSimulationPlugin
from Lima.Server import plugins
plugins.__all__.append("SlitsSimulationPlugin")
from Lima.Server.LimaCCDs import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())
#!python
import re
import sys
from bliss.controllers.demo import lima_tomo_simulation_plugin as TomoSimulationPlugin
sys.modules["Lima.Server.plugins.TomoSimulationPlugin"] = TomoSimulationPlugin
from Lima.Server import plugins
plugins.__all__.append("TomoSimulationPlugin")
from Lima.Server.LimaCCDs import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())
......@@ -3,7 +3,7 @@
#
# This file is part of the bliss project
#
# Copyright (c) 2016 Beamline Control Unit, ESRF
# Copyright (c) 2015-2020 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
import gevent
from gevent import socket
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This file is part of the bliss project
#
# Copyright (c) 2016 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
"""
Usage: bliss_webserver [-p <port> | --port=<port>]
bliss_webserver (-h | --help)
Options:
-p, --port=<port> Port number [default: 8099]
-h, --help Show this screen.
"""
import os
import docopt
import logging
import bliss
from bliss.shell.web import bliss_webserver
try:
arguments = docopt.docopt(__doc__)
port = int(arguments["--port"])
except docopt.DocoptExit as e:
print(e.message)
else:
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
bliss_webserver.serve_forever(port)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This file is part of the bliss project
#
# Copyright (c) 2016 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
"""
Usage: sps_data_watch [(-s | --session)] <name>...
sps_data_watch (-h | --help)
Options:
-s, --session Follow data from session(s).
-h, --help Show this screen.
"""
import docopt
import gevent
import json
from bliss.common.utils import OrderedDict
try:
import sps
except ImportError:
try:
from PyMca5.PyMcaIO import sps
except ImportError: # last chance
from PyMca import sps
from bliss.data.node import DataNodeIterator, _get_or_create_node, is_zerod
ARRAY_NAME = "SCAN_D"
class _MaxPointReach(Exception):
pass
class _MaxCounterReach(Exception):
pass
class _NewCounter(Exception):
pass
def copy_data(zerod, zerod_index, session_name, max_nb_counter, max_nb_points):
data_channel = zerod
channel_name = zerod.name
previous_cnt_number = len(zerod_index)
channel_info = zerod_index.setdefault(
channel_name, {"from": 0, "index": len(zerod_index)}
)
if len(zerod_index) > max_nb_counter:
raise _MaxCounterReach()
elif previous_cnt_number != len(zerod_index):
raise _NewCounter()
from_index = channel_info.get("from")
data = data_channel.get(from_index, -1)
nb_points = from_index + len(data)
if nb_points > max_nb_points:
raise _MaxPointReach()
channel_info["from"] = nb_points
if len(data):
sps_index = channel_info["index"]
sps_data = sps.getdata(session_name, ARRAY_NAME)
sps_data.T[sps_index][from_index : from_index + len(data)] = data
sps.putdata(session_name, ARRAY_NAME, sps_data)
min_index = nb_points
for channel_name, channel_info in zerod_index.items():
point_nb = channel_info.get("from")
if point_nb < min_index:
min_index = point_nb
sps.putinfo(session_name, ARRAY_NAME, json.dumps((min_index, "running")))
def new_scanno(last={"scanno": 0}):
last["scanno"] += 1
return last["scanno"]
def watch_data(scan_node, session_name):
npoints = max(scan_node.info.get("npoints"), 4096)
title = scan_node.info.get("title") or "unknown scan"
nbcounters = 64
while True:
try:
scan_data_iterator = DataNodeIterator(scan_node)
pubsub = scan_data_iterator.children_event_register()
sps.create(session_name, ARRAY_NAME, npoints, nbcounters)
zerod_index = OrderedDict()
for channel in scan_data_iterator.walk(filter="channel", wait=False):
if is_zerod(channel):
channel_name = channel.name
zerod_index.setdefault(
channel_name, {"from": 0, "index": len(zerod_index)}
)
copy_data(channel, zerod_index, session_name, nbcounters, npoints)
allcountersdict = dict([(i, "") for i in range(nbcounters)])
allcountersdict.update(
dict(((i, name) for i, name in enumerate(zerod_index)))
)
sps.putmetadata(
session_name,
ARRAY_NAME,
json.dumps(
(
allcountersdict,
{
"npts": npoints,
"allmotorm": "",
"scanno": new_scanno(),
"datafile": "bliss",
"spec": session_name,
"columnnames": list(zerod_index.keys())
+ [""] * (nbcounters - len(list(zerod_index.keys()))),
"columns": len(list(zerod_index.keys())),
"selectedcounters": ";".join(list(zerod_index.keys())),
},
{},
)
),
)
for event_type, zerod in scan_data_iterator.wait_for_event(
pubsub, filter="channel"
):
if not is_zerod(zerod):
continue
if event_type is scan_data_iterator.NEW_CHILD_EVENT:
copy_data(zerod, zerod_index, session_name, nbcounters, npoints)
elif event_type is scan_data_iterator.NEW_DATA_IN_CHANNEL_EVENT:
copy_data(zerod, zerod_index, session_name, nbcounters, npoints)
except _MaxCounterReach:
nbcounters *= 2
except _MaxPointReach:
if npoints < 10000:
npoints *= 32
else:
npoints *= 2
except _NewCounter:
pass
def watch_session(session_name):
session_node = _get_or_create_node(session_name, node_type="session")
if session_node is not None:
data_iterator = DataNodeIterator(session_node)
pubsub = data_iterator.children_event_register()
last_scan_node = None
for last_scan_node in data_iterator.walk(filter="scan", wait=False):
pass
watch_data_task = None
if last_scan_node is not None:
watch_data_task = gevent.spawn(watch_data, last_scan_node, session_name)
for event_type, scan_node in data_iterator.wait_for_event(
pubsub, filter="scan"
):
if event_type != data_iterator.NEW_CHILD_EVENT:
continue
if watch_data_task:
watch_data_task.kill()
watch_data_task = gevent.spawn(watch_data, scan_node, session_name)
def main():
try:
# Parse arguments, use file docstring as a parameter definition
arguments = docopt.docopt(__doc__)
sessions_name = arguments["<name>"]
except docopt.DocoptExit as e:
print(e.message)
else:
tasks = list()
for session in sessions_name:
tasks.append(gevent.spawn(watch_session, session))
try:
gevent.joinall(tasks)
except KeyboardInterrupt:
pass
if __name__ == "__main__":
main()
......@@ -3,7 +3,7 @@
#
# This file is part of the bliss project
#
# Copyright (c) 2016 Beamline Control Unit, ESRF
# Copyright (c) 2015-2020 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
import argparse
......
......@@ -2,16 +2,11 @@
#
# This file is part of the bliss project
#
# Copyright (c) 2016 Beamline Control Unit, ESRF
# Copyright (c) 2015-2020 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
"""Bliss main package
For your convenience, configuration motion and scan APIs have been made available
directly at this level.
Here are the main bliss sub-systems:
.. autosummary::
:toctree:
......@@ -24,8 +19,8 @@ Here are the main bliss sub-systems:
scanning
shell
tango
flint
"""
from . import release
__version__ = release.version
......@@ -33,6 +28,78 @@ __author__ = release.author
__license__ = release.license
version_info = release.version_info
from gevent import monkey
from gevent import monkey as _monkey
_monkey.patch_all(thread=False)
from bliss.common.proxy import Proxy as _Proxy
import atexit
def _get_current_session():
from bliss.common import session
return session.get_current_session()
current_session = _Proxy(_get_current_session)
from bliss.common.alias import MapWithAliases as _MapWithAliases
global_map = _MapWithAliases(current_session)
atexit.register(global_map.clear)
from bliss.common.logtools import Log as _Log
global_log = _Log(map=global_map)
def logging_startup(
log_level="WARNING", fmt="%(levelname)s %(asctime)-15s %(name)s: %(message)s"
):
"""
Provides basicConfig functionality to bliss activating at proper level the root loggers
"""
import logging # this is not to pollute the global namespace
# save log messages format
global_log.set_log_format(fmt)
global_log._LOG_DEFAULT_LEVEL = log_level # to restore level of non-BlissLoggers
# setting startup level for session and bliss logger
logging.getLogger("global").setLevel(log_level)
logging.getLogger("bliss").setLevel(log_level)
logging.getLogger("flint").setLevel(log_level)
# install an additional handler, only for debug messages
# (debugon / debugoff)
global_log.start_stdout_handler()
# Beacon logging handler through SocketServer
from bliss.config.conductor.client import get_log_server_address
try:
host, port = get_log_server_address()
except RuntimeError:
pass
else:
global_log.start_beacon_handler((host, port))
# Bliss shell mode False indicates Bliss in running in library mode
_BLISS_SHELL_MODE = False
def set_bliss_shell_mode(mode=True):
"""
Set Bliss shell mode
"""
global _BLISS_SHELL_MODE
_BLISS_SHELL_MODE = mode
monkey.patch_all(thread=False)
def is_bliss_shell():
"""
Tells if Bliss is running in shell or library mode
"""
return _BLISS_SHELL_MODE