Skip to content

Commit

Permalink
Merge branch 'main' into 1009-deprecate-EpicsMotorLimitsMixin
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed Oct 24, 2024
2 parents c1270bb + cb5779b commit 5d8a1a9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
13 changes: 12 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,18 @@ describe future plans.
1.7.1
******
release expected by 2024-12-31
Bugfix release expected by 2024-11-01.

Fixes
-----

- Allow imports to succeed when developing or testing with databroker v2.0+.
- In SpecWriterCallback2, set spec_filename in constructor.

Maintenance
-----------

- Use 'NeXus_release' file attribute in 'nxwriter' callback.

Deprecations
------------
Expand Down
9 changes: 5 additions & 4 deletions apstools/callbacks/spec_file_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ def write_scan(self):
def make_default_filename(self):
"""generate a file name to be used as default"""
now = datetime.datetime.now()
filename = datetime.datetime.strftime(now, "%Y%m%d-%H%M%S") + ".dat"
filename = now.strftime("%Y%m%d-%H%M%S") + ".dat"
return pathlib.Path(filename)

def newfile(self, filename=None, scan_id=None, RE=None):
Expand Down Expand Up @@ -718,7 +718,7 @@ class SpecWriterCallback2(FileWriterCallbackBase):
.. rubric: Properties
.. autosummary::
~spec_filename
*New in apstools 1.7.0.*
"""

Expand All @@ -731,6 +731,7 @@ def __init__(self, *args, **kwargs):
self._file_header_motor_keys = None
self._motor_stream_name = "label_start_motor"
self.file_epoch = None
self.spec_filename = None
self.write_new_file_header = True

def descriptor(self, doc):
Expand Down Expand Up @@ -862,7 +863,7 @@ def _cmt(self, text):
def make_default_filename(self):
"""generate a file name to be used as default"""
now = datetime.datetime.now()
filename = datetime.datetime.strftime(now, "%Y%m%d-%H%M%S") + ".dat"
filename = now.strftime("%Y%m%d-%H%M%S") + ".dat"
return pathlib.Path(filename)

def newfile(self, filename=None, scan_id=None, RE=None):
Expand Down Expand Up @@ -1085,7 +1086,7 @@ def spec_filename(self):

@spec_filename.setter
def spec_filename(self, file_name):
self.file_name = file_name
self.file_name = file_name or self.make_default_filename()


def spec_comment(comment, doc=None, writer=None):
Expand Down
11 changes: 11 additions & 0 deletions apstools/callbacks/tests/test_specwriter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pytest
from ..spec_file_writer import SpecWriterCallback
from ..spec_file_writer import SpecWriterCallback2


@pytest.mark.parametrize("callback", [SpecWriterCallback, SpecWriterCallback2])
def test_filename_defined(callback):
"""Test that default file name is not 'None'."""
specwriter = callback()
assert specwriter is not None
assert specwriter.spec_filename is not None

0 comments on commit 5d8a1a9

Please sign in to comment.