Skip to content

Commit

Permalink
TST #329 no shortcut for datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed Jul 4, 2020
1 parent a656081 commit 62f2370
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions apstools/filewriters.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@


from collections import OrderedDict
from datetime import datetime
import datetime
import getpass
import h5py
import logging
Expand Down Expand Up @@ -256,8 +256,8 @@ def _empty_comments_dict(self):

def _cmt(self, key, text):
"""enter a comment"""
dt = self._datetime or datetime.now()
ts = datetime.strftime(dt, SPEC_TIME_FORMAT)
dt = self._datetime or datetime.datetime.now()
ts = datetime.datetime.strftime(dt, SPEC_TIME_FORMAT)
if self.scanning:
dest = self.comments
else:
Expand All @@ -281,9 +281,9 @@ def receiver(self, key, document):
logger.debug("%s document, uid=%s", key, str(uid))
ts = document.get("time")
if ts is None:
ts = datetime.now()
ts = datetime.datetime.now()
else:
ts = datetime.fromtimestamp(document["time"])
ts = datetime.datetime.fromtimestamp(document["time"])
self._datetime = ts
xref[key](document)
else:
Expand Down Expand Up @@ -336,7 +336,7 @@ def start(self, doc):
obj[key] = None

cmt = "plan_type = " + doc["plan_type"]
ts = datetime.strftime(self._datetime, SPEC_TIME_FORMAT)
ts = datetime.datetime.strftime(self._datetime, SPEC_TIME_FORMAT)
self.comments["start"].insert(0, f"{ts}. {cmt}")
self.scan_command = _rebuild_scan_command(doc)

Expand Down Expand Up @@ -436,11 +436,11 @@ def prepare_scan_contents(self):
:returns: [str] a list of lines to append to the data file
"""
dt = datetime.fromtimestamp(self.scan_epoch)
dt = datetime.datetime.fromtimestamp(self.scan_epoch)
lines = []
lines.append("")
lines.append("#S " + self.scan_command)
lines.append("#D " + datetime.strftime(dt, SPEC_TIME_FORMAT))
lines.append("#D " + datetime.datetime.strftime(dt, SPEC_TIME_FORMAT))
if self.T_or_M is not None:
lines.append(f"#{self.T_or_M} {self.T_or_M_value}")

Expand Down Expand Up @@ -499,11 +499,11 @@ def _write_lines_(self, lines, mode="a"):

def write_header(self):
"""write the header section of a SPEC data file"""
dt = datetime.fromtimestamp(self.spec_epoch)
dt = datetime.datetime.fromtimestamp(self.spec_epoch)
lines = []
lines.append(f"#F {self.spec_filename}")
lines.append(f"#E {self.spec_epoch}")
lines.append(f"#D {datetime.strftime(dt, SPEC_TIME_FORMAT)}")
lines.append(f"#D {datetime.datetime.strftime(dt, SPEC_TIME_FORMAT)}")
lines.append(f"#C Bluesky user = {self.spec_user} host = {self.spec_host}")
lines.append(f"#O0 ")
lines.append(f"#o0 ")
Expand Down Expand Up @@ -543,8 +543,8 @@ def write_scan(self):

def make_default_filename(self):
"""generate a file name to be used as default"""
now = datetime.now()
return datetime.strftime(now, "%Y%m%d-%H%M%S")+".dat"
now = datetime.datetime.now()
return datetime.datetime.strftime(now, "%Y%m%d-%H%M%S")+".dat"

def newfile(self, filename=None, scan_id=None, RE=None):
"""
Expand Down Expand Up @@ -1006,7 +1006,7 @@ def stop(self, doc):
if not self.scanning:
return
self.exit_status = doc["exit_status"]
self.stop_reason = doc["reason"]
self.stop_reason = doc.get("reason", "not available")
self.stop_time = doc["time"]
self.scanning = False

Expand Down

0 comments on commit 62f2370

Please sign in to comment.