Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .github/workflows/code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python: [cp27, cp36, cp37, cp38, cp39]

exclude:
# No cothread or asyncio for windows python 2.7 so doesn't work
- os: windows-latest
python: cp27
python: [cp36, cp37, cp38, cp39]

include:
# Put coverage in the project directory for mac
Expand Down
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.languageServer": "Pylance",
"files.trimTrailingWhitespace": true,
"files.trimFinalNewlines": true,
}
16 changes: 8 additions & 8 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ long_description_content_type = text/x-rst
classifiers =
Development Status :: 5 - Production/Stable
License :: OSI Approved :: Apache Software License
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9

[options]
packages = softioc
python_requires = >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*
python_requires = >=3.6

[options.entry_points]
# Include a command line script
Expand All @@ -39,11 +39,11 @@ useful =
aioca >=1.3
# Dev and docs dependencies
dev =
pytest-cov
pytest-cov
pytest-flake8
sphinx-rtd-theme-github-versions; python_version > "3.0"
pytest-asyncio; python_version > "3.0"
aioca >=1.3 ; python_version > "3.0"
sphinx-rtd-theme-github-versions
pytest-asyncio
aioca >=1.3
cothread; sys_platform != "win32"
p4p

Expand All @@ -57,8 +57,8 @@ extend-ignore =
[tool:pytest]
# Run pytest with all our checkers, and don't spam us with massive tracebacks on error
# Don't do flake8 here as we need to separate it out for CI
addopts =
--tb=native -vv --doctest-modules --ignore=iocStats --ignore=epicscorelibs --ignore=docs
addopts =
--tb=native -vv --doctest-modules --ignore=iocStats --ignore=epicscorelibs --ignore=docs
--cov=softioc --cov-report term --cov-report xml:cov.xml

[coverage:run]
Expand Down
3 changes: 1 addition & 2 deletions softioc/device_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ class DSET(DSET_BASE):
# Hang onto the values we publish to EPICS to ensure that they persist!
# We also need to ensure that the device name persits.
cls.__dset = dset
if sys.version_info >= (3,):
cls._device_name_ = cls._device_name_.encode()
cls._device_name_ = cls._device_name_.encode()
imports.registryDeviceSupportAdd(cls._device_name_, byref(cls.__dset))
Comment thread
AlexanderWells-diamond marked this conversation as resolved.


Expand Down
18 changes: 3 additions & 15 deletions softioc/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,6 @@
}


if sys.version_info >= (3,):
def decode(string):
return string.decode()
def encode(string):
return string.encode()
else:
def decode(string):
return string
def encode(string):
return string


class RecordFactory(object):
def __init__(self, record_type, fields):
'''Uses the EPICS static database to discover the offset in the record
Expand Down Expand Up @@ -110,9 +98,9 @@ def __getattr__(self, field):
if field == 'TIME':
return self.__get_time(address)
elif field_type == DBF_STRING:
return decode(string_at(cast(address, c_char_p)))
return string_at(cast(address, c_char_p)).decode()
elif field_type in [DBF_INLINK, DBF_OUTLINK]:
return decode(cast(address, POINTER(c_char_p))[0])
return cast(address, POINTER(c_char_p))[0].decode()
else:
ctypes_type = DbfCodeToCtypes[field_type]
return cast(address, POINTER(ctypes_type))[0]
Expand All @@ -124,7 +112,7 @@ def __setattr__(self, field, value):
if field == 'TIME':
self.__set_time(address, value)
elif field_type == DBF_STRING:
value = encode(str(value))
value = str(value).encode()
buffer = create_string_buffer(value)
if size > len(value) + 1:
size = len(value) + 1
Expand Down
34 changes: 13 additions & 21 deletions softioc/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,19 @@ def expect_true(status, function, args):
assert status, 'Expected True'


if sys.version_info < (3,):
# Python 2
auto_encode = c_char_p
def auto_decode(result, func, args):
return result

else:
# Python 3

# Encode all strings to c_char_p
class auto_encode(c_char_p):
encoded = []
@classmethod
def from_param(cls, value):
if value is None:
return value
else:
return value.encode()

def auto_decode(result, func, args):
return result.decode()

# Encode all strings to c_char_p
class auto_encode(c_char_p):
encoded = []
Comment thread
AlexanderWells-diamond marked this conversation as resolved.
Outdated
@classmethod
def from_param(cls, value):
if value is None:
return value
else:
return value.encode()

def auto_decode(result, func, args):
return result.decode()
Comment thread
AlexanderWells-diamond marked this conversation as resolved.
Outdated


# int registryDeviceSupportAdd(
Expand Down
8 changes: 1 addition & 7 deletions softioc/softioc.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,14 +310,8 @@ def interactive_ioc(context = {}, call_exit = True):
exports = dict((key, globals()[key]) for key in command_names)
import code

if sys.version_info < (3, 6):
interact_args = {}
else:
# This suppresses irritating exit message introduced by Python3. Alas,
# this option is only available in Python 3.6!
interact_args = dict(exitmsg = '')
try:
code.interact(local = dict(exports, **context), **interact_args)
code.interact(local = dict(exports, **context), exitmsg = '')
except SystemExit as e:
if call_exit:
safeEpicsExit(e.code)
Expand Down
6 changes: 0 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@

import pytest

if sys.version_info < (3,):
# Python2 has no asyncio, so ignore these tests
collect_ignore = [
"test_asyncio.py", "sim_asyncio_ioc.py", "sim_asyncio_ioc_override.py"
]

class SubprocessIOC:
def __init__(self, ioc_py):
self.pv_prefix = "".join(
Expand Down