From 6ccfb95921826682fbca335b648ff99d675732e0 Mon Sep 17 00:00:00 2001 From: Pete Jemian Date: Tue, 12 Jul 2022 09:42:47 -0500 Subject: [PATCH] ENH https://github.com/BCDA-APS/use_bluesky/issues/119 --- .../console/__start_bluesky_instrument__.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 bluesky/console/__start_bluesky_instrument__.py diff --git a/bluesky/console/__start_bluesky_instrument__.py b/bluesky/console/__start_bluesky_instrument__.py new file mode 100644 index 00000000..8ec7c020 --- /dev/null +++ b/bluesky/console/__start_bluesky_instrument__.py @@ -0,0 +1,28 @@ +""" +start bluesky in IPython console session +""" + +# start a Bluesky data collection console session +import pathlib, sys + +# add the "bluesky/" directory to the system path +__BLUESKY_IN_HOME_DIRECTORY__ = False +# first, identify the parent directory +if __BLUESKY_IN_HOME_DIRECTORY__: + BLUESKY_DIRECTORY = pathlib.Path.home() +else: + # + BLUESKY_DIRECTORY = pathlib.Path(__file__).absolute().parent.parent.parent +# next, name the "bluesky" subdirectory +BLUESKY_DIRECTORY = BLUESKY_DIRECTORY / "bluesky" +if not BLUESKY_DIRECTORY.exists(): + raise FileNotFoundError( + f"Cannot find bluesky directory: {BLUESKY_DIRECTORY}" + ) +# put bluesky directory on the import path +sys.path.append(str(BLUESKY_DIRECTORY)) + +# terse error dumps (Exception tracebacks) +get_ipython().run_line_magic('xmode', 'Minimal') + +from instrument.collection import *