Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
9 changes: 7 additions & 2 deletions ait/core/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
Dictionaries contain command and argument definitions.
"""
import os
import atexit
import struct
import importlib
from io import IOBase
from contextlib import ExitStack

import pkg_resources
import yaml

import ait
Expand Down Expand Up @@ -518,7 +520,10 @@ def getDefaultDictFilename(): # noqa


def getDefaultSchema(): # noqa
return pkg_resources.resource_filename("ait.core", "data/cmd_schema.json")
file_manager = ExitStack()
atexit.register(file_manager.close)
ref = importlib.resources.files("ait.core") / "data/cmd_schema.json"
return file_manager.enter_context(importlib.resources.as_file(ref))


def getMaxCmdSize(): # noqa
Expand Down
9 changes: 7 additions & 2 deletions ait/core/evr.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
"""
import os
import re
import atexit
import importlib
from contextlib import ExitStack

import pkg_resources
import yaml

import ait.core
Expand Down Expand Up @@ -75,7 +77,10 @@ def toJSON(self): # noqa


def getDefaultSchema(): # noqa
return pkg_resources.resource_filename("ait.core", "data/evr_schema.json")
file_manager = ExitStack()
atexit.register(file_manager.close)
ref = importlib.resources.files("ait.core") / "data/evr_schema.json"
return file_manager.enter_context(importlib.resources.as_file(ref))


def getDefaultDict(reload=False): # noqa
Expand Down
9 changes: 7 additions & 2 deletions ait/core/limits.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@

"""
import os
import atexit
import importlib
from io import IOBase
from contextlib import ExitStack

import pkg_resources
import yaml

import ait
Expand Down Expand Up @@ -224,7 +226,10 @@ def getDefaultDict(reload=False): # noqa


def getDefaultSchema(): # noqa
return pkg_resources.resource_filename("ait.core", "data/limits_schema.json")
file_manager = ExitStack()
atexit.register(file_manager.close)
ref = importlib.resources.files("ait.core") / "data/limits_schema.json"
return file_manager.enter_context(importlib.resources.as_file(ref))


def getDefaultDictFilename(): # noqa
Expand Down
9 changes: 7 additions & 2 deletions ait/core/tlm.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
import collections.abc
import csv
import os
import atexit
import struct
import importlib
from io import IOBase
from contextlib import ExitStack

import pkg_resources
import yaml

import ait
Expand Down Expand Up @@ -1096,7 +1098,10 @@ def getDefaultDict(reload=False): # noqa


def getDefaultSchema(): # noqa
return pkg_resources.resource_filename("ait.core", "data/tlm_schema.json")
file_manager = ExitStack()
atexit.register(file_manager.close)
ref = importlib.resources.files("ait.core") / "data/tlm_schema.json"
return file_manager.enter_context(importlib.resources.as_file(ref))


def getDefaultDictFilename(): # noqa
Expand Down
4 changes: 2 additions & 2 deletions ait/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def load(self):

if sys.platform == "win32":
# On Windows, the best timer is time.clock
timer = time.clock
timer = time.perf_counter
else:
# On most other platforms the best timer is time.time
timer = time.time
Expand Down Expand Up @@ -162,7 +162,7 @@ def create(*args, **kwargs):
modname, clsname = parts
module = pydoc.locate(modname)
if module is None:
raise ImportError("No module named %d" % modname)
raise ImportError("No module named %s" % modname)
create.cls = getattr(module, clsname)
if create.cls is None:
raise ImportError("No class named %s" % extname)
Expand Down
18 changes: 9 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ include = [
]

[tool.poetry.dependencies]
python = '>= 3.7 < 3.11'
bottle = '0.12.23'
jsonschema = '3.0.2'
pyyaml = '6.0.1'
python = '>=3.11'
bottle = '>=0.12.23'
jsonschema = '>=3.0.2'
pyyaml = '>=6.0.1'
requests = '>= 2.22.0'
greenlet = '1.1.3'
greenlet = '>=1.1.3'
gevent = '*'
gevent-websocket = '0.10.1'
pyzmq = '24.0.0'
gipc = "^1.1.0"
setproctitle = "^1.2.3"
gevent-websocket = '>=0.10.1'
pyzmq = '>=24.0.0'
gipc = ">=1.1.0"
setproctitle = ">=1.2.3"
msgpack = '*'

[tool.poetry.dev-dependencies]
Expand Down
23 changes: 12 additions & 11 deletions tests/ait/core/test_val.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
gevent.monkey.patch_all()

import os
import pkg_resources
import jsonschema

import pytest
Expand Down Expand Up @@ -453,18 +452,20 @@ def testEvrValidation():
def testTableValidation():
# Validation test of current table configuration
yml = ait.config.table.filename
schema = pkg_resources.resource_filename("ait.core", "data/table_schema.json")
msgs, v = validate_schema([yml, schema])
dispmsgs(msgs)
assert v
assert len(msgs) == 0
ref = importlib.resources.files("ait.core") / "data/table_schema.json"
with importlib.resources.as_file(ref) as schema:
msgs, v = validate_schema([yml, schema])
dispmsgs(msgs)
assert v
assert len(msgs) == 0


def testLimitsValidation():
# Validation test of current table configuration
yml = ait.config.limits.filename
schema = pkg_resources.resource_filename("ait.core", "data/limits_schema.json")
msgs, v = validate_schema([yml, schema])
dispmsgs(msgs)
assert v
assert len(msgs) == 0
ref = importlib.resources.files("ait.core") / "data/limits_schema.json"
with importlib.resources.as_file(ref) as schema:
msgs, v = validate_schema([yml, schema])
dispmsgs(msgs)
assert v
assert len(msgs) == 0