Skip to content

Commit 0d9936a

Browse files
committed
Move ui and graph vis to external libs
1 parent a09c185 commit 0d9936a

File tree

9 files changed

+49
-1816
lines changed

9 files changed

+49
-1816
lines changed

CHANGELOG.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
## [UNRELEASED] - (2.2.0)
1+
## [2.2.0] - 19.06.2019
22

33
### Added
4-
- Enable configuration of rate at which the monitoring thread checks on components/hosts.
5-
- Add possibility to specify optional requirements for components. This is useful for combination with the exclude
4+
- Enabled configuration of rate at which the monitoring thread checks on components/hosts.
5+
- Added possibility to specify optional requirements for components. This is useful for combination with the exclude
66
feature.
77

8+
### Changed
9+
- Moved user interfaces and graph drawing to external libraries
10+
811
### Fixed
912
- Having requires or depends defined as empty list does not cause an exception anymore.
1013
- Program will exit with correct exit code on missing urwid installation after showing the error output.

README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,13 @@ Inspired by [vdemo](https://code.cor-lab.org/projects/vdemo) and [TMuLE](https:/
1212
Hyperion (like TMuLE) is written in Python and utilizes the [tmux library for python](https://github.com/tmux-python/libtmux) to start components in detached sessions. For each host defined in the components a master session is created, in which each component will be started in a window. Components are managed by a main server that delegates commands to slave server instances on remote machines and forwards information to subscribed user interfaces.
1313

1414
## Installation
15-
This package strictly separates optional content from the core which reflects in the install options.
16-
The minimal Hyperion package can be installed via setuptools ```python setup.py install``` or via pip ```pip install .```
15+
The Hyperion core package can be installed via setuptools ```python setup.py install``` or via pip ```pip install .```
1716

18-
To enable dependency graph visualisation, you need to install via pip with ```pip install -e .[GRAPH]``` (if you are running zsh, you need to escape the brackets: ```pip install -e .\[GRAPH\]```).
17+
To enable dependency graph visualisation, you need to install the [graph visualisation extension](https://github.com/hyperion-start/hyperion-graph-visualisation)
1918

20-
If you want to use the interactive cli based on urwid, install with ```pip install -e .[I-CLI]```.
19+
If you want to use the interactive cli based on urwid, you need to install the [user interfaces extension](https://github.com/hyperion-start/hyperion-ui).
2120

22-
If you wish to use the PyQt gui, Qt4 for python has to be installed via a package manager (```apt install python-qt4``` on debian based distributions). This is due to the fact, that the PyQt4 package can not be managed by pip. Hyperion is able to detect if PyQt4 is installed at runtime and if so enable the GUI features.
23-
24-
To make use of all optional features, run the install with ```pip install -e .[FULL]```. Note that to use the PyQt gui you still need to install the python-qt4 package manually.
21+
If you wish to use the PyQt gui, additionally to the ui extension Qt4 for python has to be installed via a package manager (```apt install python-qt4``` on debian based distributions). This is due to the fact, that the PyQt4 package can not be managed by pip. Hyperion is able to detect if PyQt4 is installed at runtime and if so enable the GUI features.
2522

2623
## Quick Guide
2724

hyperion/lib/util/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ExitStatus(Enum):
1616
ENVIRONMENT_FILE_MISSING = 9
1717
MISSING_SSH_CONFIG = 10
1818
CONFIG_RESET_FAILED = 11
19-
MISSING_URWID_INSTALL = 12
19+
MISSING_UI_INSTALL = 12
2020

2121

2222
class CheckState(Enum):

hyperion/lib/util/graph_generator.py

Lines changed: 0 additions & 110 deletions
This file was deleted.

hyperion/runner.py

Lines changed: 37 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from manager import ControlCenter, SlaveManager, ensure_dir, BASE_DIR, clear_log, conf_preprocessing
1111
from lib.networking import clientInterface, server
1212
from lib.util.config import TMP_LOG_PATH, DEFAULT_TCP_PORT, FORMAT
13-
from lib.util.graph_generator import draw_graph
1413
from logging.config import fileConfig
1514
from lib.util.exception import *
1615

@@ -20,27 +19,35 @@
2019
###########################
2120
# Optional feature imports
2221
###########################
23-
try:
24-
from PyQt4 import QtGui
25-
except ImportError:
26-
gui_enabled = False
27-
else:
28-
import user_interfaces.hyperGUI as hyperGUI
22+
gui_enabled = False
23+
graph_enabled = False
24+
interactive_enabled = False
25+
26+
ui_plugins = {}
27+
for ui_plugin in pkg_resources.iter_entry_points('hyperion.user_interfaces'):
28+
try:
29+
ui_plugins.update({ui_plugin.name: ui_plugin.load()})
30+
print("Loaded entry point '%s'" % ui_plugin.name)
31+
except ImportError as e:
32+
print("Could not load entry point '%s'" % ui_plugin.name)
33+
print(e.message)
34+
35+
if 'urwid' in ui_plugins:
36+
interactive_enabled = True
37+
38+
if 'pyqt' in ui_plugins:
2939
gui_enabled = True
3040

31-
try:
32-
import graphviz
33-
except ImportError:
34-
graph_enabled = False
35-
else:
36-
graph_enabled = True
41+
vis_plugins = {}
42+
for vis_plugin in pkg_resources.iter_entry_points('hyperion.visualisation'):
43+
try:
44+
vis_plugins.update({vis_plugin.name: vis_plugin.load()})
45+
print("Loaded entry point '%s'" % vis_plugin.name)
46+
except ImportError:
47+
print("Could not load entry point '%s'" % vis_plugin.name)
3748

38-
try:
39-
import user_interfaces.interactiveCLI as interactiveCLI
40-
except ImportError:
41-
interactive_enabled = False
42-
else:
43-
interactive_enabled = True
49+
if 'graph_gen' in vis_plugins:
50+
graph_enabled = True
4451

4552
ensure_dir('%s/any.log' % TMP_LOG_PATH)
4653

@@ -59,22 +66,6 @@
5966
###################
6067
# GUI
6168
###################
62-
def start_gui(ui):
63-
"""Start the PyQt4 guided interface.
64-
65-
:param ui: User interface to display
66-
:type ui: hyperGUI.UiMainWindow
67-
:return: None
68-
"""
69-
70-
app = QtGui.QApplication(sys.argv)
71-
main_window = QtGui.QMainWindow()
72-
ui.ui_init(main_window)
73-
app.aboutToQuit.connect(ui.close)
74-
main_window.show()
75-
app.exec_()
76-
77-
7869
def main():
7970
"""Parse the command line arguments and start hyperion with the specified configuration in the desired mode.
8071
@@ -238,10 +229,10 @@ def main():
238229
if gui_enabled:
239230
logger.debug('Launching GUI runner mode')
240231

241-
ui = hyperGUI.UiMainWindow(cc)
232+
ui = ui_plugins['pyqt'].UiMainWindow(cc)
242233
signal(SIGINT, SIG_DFL)
243234

244-
start_gui(ui)
235+
ui_plugins['pyqt'].start_gui(ui)
245236
else:
246237
cc.cleanup(False, config.ExitStatus.MISSING_PYQT_INSTALL)
247238
logger.error('To use this feature you need PyQt4! Check the README.md for install instructions')
@@ -255,12 +246,12 @@ def main():
255246
remove.append(handler)
256247
[root_logger.removeHandler(h) for h in remove]
257248

258-
cc.cleanup(interactiveCLI.main(cc, log_file_path))
249+
cc.cleanup(ui_plugins['urwid'].main(cc, log_file_path))
259250
else:
260-
cc.cleanup(False, config.ExitStatus.MISSING_URWID_INSTALL)
261-
logger.error('To use this feature you need urwid! Check the README.md for install instructions. If you'
262-
' already ran the installation try adding site-packages of your installation prefix to'
263-
' your PYTHONPATH environment variable.')
251+
cc.cleanup(False, config.ExitStatus.MISSING_UI_INSTALL)
252+
logger.error('To use this feature you need hyperion-uis installed! Check the README.md for install '
253+
'instructions. If you already ran the installation try adding site-packages of your '
254+
'installation prefix to your PYTHONPATH environment variable.')
264255

265256
if args.cmd == 'edit':
266257
logger.debug('Launching editor mode')
@@ -339,11 +330,11 @@ def main():
339330
pass
340331

341332
if graph_enabled:
342-
draw_graph(cc, unmet)
333+
vis_plugins['graph_gen'].draw_graph(cc, unmet)
343334
else:
344-
logger.error('This feature requires graphviz. To use it install hyperion with the GRAPH option '
345-
"(pip install -e .['GRAPH']). If you already ran the installation try adding site-packages"
346-
" of your installation prefix to your PYTHONPATH environment variable.")
335+
logger.error('To use this feature you need hyperion-graph-vis installed! Check the README.md for '
336+
'install instructions. If you already ran the installation try adding site-packages of '
337+
'your installation prefix to your PYTHONPATH environment variable.')
347338
else:
348339
try:
349340
cc.set_dependencies()

hyperion/user_interfaces/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)