Skip to content

Commit 21c6d8a

Browse files
Merge pull request #42 from chrisjbillington/remove-cruft
Remove unused modules, version checks, and PY2 compat.
2 parents ecfb748 + 335f719 commit 21c6d8a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+53
-1098
lines changed

labscript_profile/__init__.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,17 @@
2727
LABSCRIPT_SUITE_PROFILE = None
2828

2929

30+
def hostname():
31+
if sys.platform == 'darwin':
32+
return check_output(['scutil', '--get', 'LocalHostName']).decode('utf8').strip()
33+
else:
34+
return socket.gethostname()
35+
36+
3037
def default_labconfig_path():
3138
if LABSCRIPT_SUITE_PROFILE is None:
3239
return None
33-
if sys.platform == 'darwin':
34-
cmd = ['scutil', '--get', 'LocalHostName']
35-
hostname = check_output(cmd).decode('utf8').strip()
36-
else:
37-
hostname = socket.gethostname()
38-
labconfig = LABSCRIPT_SUITE_PROFILE / 'labconfig' / f'{hostname}.ini'
39-
return labconfig
40+
return LABSCRIPT_SUITE_PROFILE / 'labconfig' / f'{hostname()}.ini'
4041

4142

4243
def add_userlib_and_pythonlib():
@@ -46,23 +47,22 @@ def add_userlib_and_pythonlib():
4647
labscript_utils, since we dont' want to import something like labscript_utils every
4748
time the interpreter starts up"""
4849
labconfig = default_labconfig_path()
49-
if labconfig is None or not os.path.exists(labconfig):
50-
return
51-
config = ConfigParser()
52-
config.read(labconfig)
53-
for option in ['userlib', 'pythonlib']:
54-
try:
55-
paths = config.get('DEFAULT', option).split(',')
56-
except (NoSectionError, NoOptionError):
57-
paths = []
58-
for path in paths:
59-
if os.path.exists(path):
60-
sys.path.append(path)
50+
if labconfig is not None and labconfig.exists():
51+
config = ConfigParser()
52+
config.read(labconfig)
53+
for option in ['userlib', 'pythonlib']:
54+
try:
55+
paths = config.get('DEFAULT', option).split(',')
56+
except (NoSectionError, NoOptionError):
57+
paths = []
58+
for path in paths:
59+
if os.path.exists(path):
60+
sys.path.append(path)
6161

6262

6363
def add_development_directories():
64-
"""Prepend directories in <labscript_suite_profile>/dev to the search path, if they
65-
are listed in the file <labscript_suite_profile>/dev/enabled (if that file
64+
"""Prepend directories in <LABSCRIPT_SUITE_PROFILE>/dev to the search path, if they
65+
are listed in the file <LABSCRIPT_SUITE_PROFILE>/dev/enabled (if that file
6666
exists)."""
6767
if LABSCRIPT_SUITE_PROFILE is None:
6868
return

labscript_utils/__init__.py

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,10 @@
1313

1414
import sys
1515
import os
16-
import traceback
17-
from pathlib import Path
16+
import importlib
1817

19-
from .versions import get_version, NoVersionInfo
2018
from .__version__ import __version__
2119

22-
PY2 = sys.version_info[0] == 2
23-
2420
from labscript_profile import LABSCRIPT_SUITE_PROFILE
2521

2622
if not os.path.exists(LABSCRIPT_SUITE_PROFILE):
@@ -32,8 +28,6 @@
3228
import labscript_profile
3329
labscript_profile.add_userlib_and_pythonlib()
3430

35-
# labscript_suite_install_dir alias for backward compatibility:
36-
labscript_suite_profile = labscript_suite_install_dir = str(LABSCRIPT_SUITE_PROFILE)
3731

3832
# This folder
3933
labscript_utils_dir = os.path.dirname(os.path.realpath(__file__))
@@ -46,19 +40,13 @@ def import_or_reload(modulename):
4640
"""
4741
# see if the proposed module is already loaded
4842
# if so, we will need to re-run the code contained in it
49-
import importlib
50-
if not PY2:
51-
reload = importlib.reload
5243
if modulename in sys.modules.keys():
53-
reload(sys.modules[modulename])
44+
importlib.reload(sys.modules[modulename])
5445
return sys.modules[modulename]
5546
module = importlib.import_module(modulename)
5647
return module
5748

5849

59-
from labscript_utils.versions import get_version, VersionException, check_version
60-
61-
6250
def dedent(s):
6351
"""Remove leading spaces from the first line of a string, all common leading
6452
indentation (spaces only) from subsequent lines, strip trailing spaces from all
@@ -103,14 +91,8 @@ def dedent(s):
10391
import labscript_utils.double_import_denier
10492
labscript_utils.double_import_denier.enable()
10593

106-
try:
107-
# If zprocess is new enough, disable the 'quick edit' feature of Windows' cmd.exe,
108-
# which causes console applicatons to freeze if their console windows are merely
109-
# clicked on. This causes all kinds of headaches, so we disable it in all labscript
110-
# programs:
111-
import zprocess
112-
if hasattr(zprocess, 'disable_quick_edit'):
113-
# Feature is present in zprocess > 2.10.0, but if not present we just ignore.
114-
zprocess.disable_quick_edit()
115-
except ImportError:
116-
pass
94+
# Disable the 'quick edit' feature of Windows' cmd.exe, which causes console applicatons
95+
# to freeze if their console windows are merely clicked on. This causes all kinds of
96+
# headaches, so we disable it in all labscript programs:
97+
import zprocess
98+
zprocess.disable_quick_edit()

labscript_utils/camera_server.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,14 @@
1010
# for the full license. #
1111
# #
1212
#####################################################################
13-
from __future__ import division, unicode_literals, print_function, absolute_import
14-
from labscript_utils import PY2
15-
if PY2:
16-
str = unicode
17-
1813
import sys
1914
import time
2015
import zprocess
21-
from labscript_utils import check_version
2216
import labscript_utils.shared_drive
2317
# importing this wraps zlock calls around HDF file openings and closings:
2418
import labscript_utils.h5_lock
2519
import h5py
2620
import numpy as np
27-
check_version('zprocess', '1.3.3', '3.0')
2821

2922
# This file implements the protocol for a camera server, that is, a program
3023
# that BLACS can interface with to control cameras. It contains a class that

labscript_utils/clean_repo_hook.py

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

labscript_utils/connections.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
# #
1212
#####################################################################
1313

14-
from __future__ import division, unicode_literals, print_function, absolute_import
1514
import labscript_utils.h5_lock, h5py
1615
import labscript_utils.properties
1716
import logging
@@ -22,9 +21,6 @@
2221
from labscript_utils.dict_diff import dict_diff
2322
import sys
2423
from zprocess import raise_exception_in_thread
25-
from labscript_utils import PY2
26-
if PY2:
27-
str = unicode
2824

2925
def _ensure_str(s):
3026
"""convert bytestrings and numpy strings to python strings"""

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy