Skip to content

Commit 4702b73

Browse files
Merge pull request #37 from chrisjbillington/cruft-and-ctrl-c
Remove unused imports/PY2 compat, check_version() calls, and implement graceful ctrl-c handling
2 parents c841752 + 754af06 commit 4702b73

File tree

3 files changed

+16
-65
lines changed

3 files changed

+16
-65
lines changed

runviewer/__main__.py

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#####################################################################
22
# #
3-
# /main.pyw #
3+
# __main__.py #
44
# #
55
# Copyright 2014, Monash University #
66
# #
@@ -10,19 +10,9 @@
1010
# the project for the full license. #
1111
# #
1212
#####################################################################
13-
from __future__ import division, unicode_literals, print_function, absolute_import
14-
from labscript_utils import PY2
15-
1613
import os
1714
import labscript_utils.excepthook
1815

19-
try:
20-
from labscript_utils import check_version
21-
except ImportError:
22-
raise ImportError('Require labscript_utils > 2.1.0')
23-
24-
check_version('labscript_utils', '2.15.0', '3')
25-
2616
# Associate app windows with OS menu shortcuts:
2717
import desktop_app
2818
desktop_app.set_process_appid('runviewer')
@@ -39,22 +29,10 @@
3929
import time
4030
import threading
4131
import logging
42-
import socket
43-
if PY2:
44-
str = unicode
45-
from Queue import Queue
46-
else:
47-
from queue import Queue
32+
from queue import Queue
4833
import ast
4934
import pprint
50-
5135
import signal
52-
# Quit on ctrl-c
53-
signal.signal(signal.SIGINT, signal.SIG_DFL)
54-
55-
56-
splash.update_text('importing Qt')
57-
check_version('qtutils', '2.0.0', '3.0.0')
5836

5937
splash.update_text('importing labscript suite modules')
6038
from labscript_utils.setup_logging import setup_logging
@@ -65,23 +43,19 @@
6543
import labscript_utils.h5_lock
6644
import h5py
6745

68-
# This must be bumped until after the h5_lock import
69-
# This is because the check imports pyqtgraph, which imports h5py
70-
# h5py must be imported after h5_lock, thus we do the check here
71-
splash.update_text('importing pyqtgraph')
72-
check_version('pyqtgraph', '0.9.10', '1')
73-
46+
# No splash update for Qt - the splash screen already imported it
7447
from qtutils.qt.QtCore import *
7548
from qtutils.qt.QtGui import *
7649
from qtutils.qt.QtWidgets import *
7750

51+
splash.update_text('importing pyqtgraph')
52+
import pyqtgraph as pg
53+
7854
splash.update_text('importing numpy')
7955
import numpy
8056
splash.update_text('importing scipy')
8157
from scipy import interpolate
8258

83-
# must be imported after PySide/PyQt4
84-
import pyqtgraph as pg
8559
pg.setConfigOption('background', 'w')
8660
pg.setConfigOption('foreground', 'k')
8761

@@ -91,8 +65,7 @@
9165
from labscript_utils.connections import ConnectionTable
9266
import labscript_devices
9367

94-
from labscript_utils.labconfig import LabConfig, config_prefix
95-
check_version('labscript_utils', '2.11.0', '3')
68+
from labscript_utils.labconfig import LabConfig
9669
from labscript_utils.ls_zprocess import ZMQServer, ProcessTree
9770
process_tree = ProcessTree.instance()
9871
process_tree.zlock_client.set_process_name('runviewer')
@@ -1686,4 +1659,11 @@ def handler(self, h5_filepath):
16861659
def execute_program():
16871660
qapplication.exec_()
16881661

1662+
# Let the interpreter run every 500ms so it sees Ctrl-C interrupts:
1663+
timer = QTimer()
1664+
timer.start(500)
1665+
timer.timeout.connect(lambda: None)
1666+
# Upon seeing a ctrl-c interrupt, quit the event loop
1667+
signal.signal(signal.SIGINT, lambda *args: qapplication.exit())
1668+
16891669
sys.exit(execute_program())

runviewer/resample/__init__.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1 @@
1-
from __future__ import print_function, unicode_literals, division, absolute_import
2-
from labscript_utils import PY2, check_version
3-
if PY2:
4-
str = unicode
5-
import os
6-
7-
if PY2:
8-
try:
9-
import autocython
10-
except ImportError:
11-
msg = ('autocython required, installable via pip')
12-
raise RuntimeError(msg)
13-
14-
check_version('autocython', '1.1', '2.0')
15-
from autocython import ensure_extensions_compiled, import_extension
16-
17-
ensure_extensions_compiled(os.path.abspath(os.path.dirname(__file__)))
18-
extension = import_extension('runviewer.resample.resample')
19-
resample = extension.resample
20-
else:
21-
from .resample import resample
1+
from .resample import resample

setup.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
import os
22
from setuptools import setup
33

4-
try:
5-
from setuptools_conda import dist_conda
6-
CMDCLASS = {"dist_conda": dist_conda}
7-
except ImportError:
8-
CMDCLASS = {}
9-
104
VERSION_SCHEME = {
115
"version_scheme": os.getenv("SCM_VERSION_SCHEME", "guess-next-dev"),
126
"local_scheme": os.getenv("SCM_LOCAL_SCHEME", "node-and-date"),
137
}
148

15-
setup(
16-
use_scm_version=VERSION_SCHEME,
17-
cmdclass=CMDCLASS,
18-
)
9+
setup(use_scm_version=VERSION_SCHEME)

0 commit comments

Comments
 (0)