Skip to content

Commit 08fead2

Browse files
Remove all __future__ imports, PY2 checks and version checks
The version checks are not needed since packaging tools handle dependencies.
1 parent a07911a commit 08fead2

Some content is hidden

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

46 files changed

+32
-289
lines changed

labscript_utils/__init__.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import os
1616
import traceback
1717
from pathlib import Path
18+
import importlib
1819

1920
from .versions import get_version, NoVersionInfo
2021
__version__ = get_version(__name__, import_path=Path(__file__).parent.parent)
@@ -48,11 +49,8 @@ def import_or_reload(modulename):
4849
"""
4950
# see if the proposed module is already loaded
5051
# if so, we will need to re-run the code contained in it
51-
import importlib
52-
if not PY2:
53-
reload = importlib.reload
5452
if modulename in sys.modules.keys():
55-
reload(sys.modules[modulename])
53+
importlib.reload(sys.modules[modulename])
5654
return sys.modules[modulename]
5755
module = importlib.import_module(modulename)
5856
return module
@@ -105,14 +103,8 @@ def dedent(s):
105103
import labscript_utils.double_import_denier
106104
labscript_utils.double_import_denier.enable()
107105

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

labscript_utils/excepthook/__init__.py

Lines changed: 1 addition & 5 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 sys
1615
import os
1716
import threading
@@ -97,9 +96,6 @@ def set_logger(logger):
9796
# part of the Python standard library. I'll make it a dependency for
9897
# packaging, but this is an extra check at runtime so that if something
9998
# goes wrong with that we get an error at import rather than later:
100-
if sys.version_info[0] == 2:
101-
import Tkinter
102-
else:
103-
import tkinter
99+
import tkinter
104100
sys.excepthook = tkhandler
105101
install_thread_excepthook()

labscript_utils/excepthook/tk_exception.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,8 @@
1414
import sys
1515
import os
1616

17-
if sys.version < '3':
18-
import Tkinter as tkinter
19-
import Tkconstants as constants
20-
else:
21-
import tkinter
22-
import tkinter.constants as constants
17+
import tkinter
18+
import tkinter.constants as constants
2319

2420
error_im_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'error.gif')
2521

labscript_utils/filewatcher.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,8 @@
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-
from inspect import getargspec as getfullargspec
18-
from Queue import Queue, Empty
19-
else:
20-
from inspect import getfullargspec
21-
from queue import Queue, Empty
22-
13+
from inspect import getfullargspec
14+
from queue import Queue, Empty
2315
import threading
2416
import os
2517
import hashlib
@@ -145,7 +137,7 @@ def _modified_info_of_file(self, name):
145137
# Otherwise use last modified time for modified_info
146138
elif os.path.isdir(name):
147139
# Modified info of a directory is a hash of its entries:
148-
entries = os.listdir(name if PY2 else os.fsencode(name))
140+
entries = os.listdir(os.fsencode(name))
149141
return hashlib.md5(b'\0'.join(entries)).hexdigest()
150142
else:
151143
return os.path.getmtime(name)

labscript_utils/h5_lock.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,12 @@
1010
# for the full license. #
1111
# #
1212
#####################################################################
13-
from __future__ import division, unicode_literals, print_function, absolute_import
14-
1513
import sys
1614
import os
17-
import traceback
1815

1916
from labscript_utils.ls_zprocess import Lock, connect_to_zlock_server, kill_lock
20-
21-
from labscript_utils import check_version, dedent
22-
17+
from labscript_utils import dedent
2318
from labscript_utils.shared_drive import path_to_agnostic
24-
from labscript_utils import PY2
25-
if PY2:
26-
str = unicode
2719

2820
if 'h5py' in sys.modules:
2921
import labscript_utils.double_import_denier
@@ -43,9 +35,6 @@
4335
raise ImportError('h5_lock must be imported prior to importing h5py')
4436

4537
import h5py
46-
# This module used to contain a monkeypatch to work around an issue now fixed in h5py.
47-
# Depend on the fix since we no longer have the monkeypatch.
48-
check_version('h5py', '2.9', '3')
4938

5039
_File = h5py.File
5140
class File(_File):

labscript_utils/impprof.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
# for the full license. #
1111
# #
1212
#####################################################################
13-
from __future__ import division, unicode_literals, print_function, absolute_import
14-
1513
import time
1614

1715
class _ProfilingImporter(object):

labscript_utils/labconfig.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
# for the full license. #
1111
# #
1212
#####################################################################
13-
from __future__ import division, unicode_literals, print_function, absolute_import
14-
1513
import sys
1614
import os
1715
import socket

labscript_utils/ls_zprocess.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,11 @@
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
from socket import gethostbyname
2015
from distutils.version import LooseVersion
2116
import zmq
2217

23-
from labscript_utils import check_version
24-
check_version('zprocess', '2.18.0', '3.0.0')
25-
2618
import zprocess
2719
import zprocess.process_tree
2820
from zprocess.security import SecureContext

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