sardana-nxsrecorder 3.21.0__py3-none-any.whl → 3.22.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sardana_nxsrecorder-3.21.0.dist-info → sardana_nxsrecorder-3.22.0.dist-info}/METADATA +1 -1
- sardana_nxsrecorder-3.22.0.dist-info/RECORD +6 -0
- sardananxsrecorder/__init__.py +1 -1
- sardananxsrecorder/nxsrecorder.py +109 -33
- sardana_nxsrecorder-3.21.0.dist-info/RECORD +0 -6
- {sardana_nxsrecorder-3.21.0.dist-info → sardana_nxsrecorder-3.22.0.dist-info}/WHEEL +0 -0
- {sardana_nxsrecorder-3.21.0.dist-info → sardana_nxsrecorder-3.22.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
sardananxsrecorder/__init__.py,sha256=gUu5k6aJRyRksDS_IRn8O6fVbNsgLNZVeuowa4MISt4,896
|
|
2
|
+
sardananxsrecorder/nxsrecorder.py,sha256=ypWSER8Y-DiWs8KPf81EBxjYD0LtL5Iw6kJMAXj7j9I,55536
|
|
3
|
+
sardana_nxsrecorder-3.22.0.dist-info/METADATA,sha256=m8tvcIFVtkqFb5RHHpXcicV-UvudHoTUXNaiADVdm3o,7566
|
|
4
|
+
sardana_nxsrecorder-3.22.0.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
|
5
|
+
sardana_nxsrecorder-3.22.0.dist-info/top_level.txt,sha256=YdD3m417i-jlYyQWgiizgZ8lQQcOjM8y-bmUHrGkfY4,19
|
|
6
|
+
sardana_nxsrecorder-3.22.0.dist-info/RECORD,,
|
sardananxsrecorder/__init__.py
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
|
|
23
23
|
import os
|
|
24
24
|
import re
|
|
25
|
+
import sys
|
|
25
26
|
|
|
26
27
|
import numpy
|
|
27
28
|
import json
|
|
@@ -101,6 +102,8 @@ class NXS_FileRecorder(BaseFileRecorder):
|
|
|
101
102
|
BaseFileRecorder.__init__(self)
|
|
102
103
|
#: (:obj:`str`) base filename
|
|
103
104
|
self.__base_filename = filename
|
|
105
|
+
#: (:obj:`str`) raw filename
|
|
106
|
+
self.__raw_filename = ""
|
|
104
107
|
self.__macro = weakref.ref(macro) if macro else None
|
|
105
108
|
#: (:class:`tango.Database`) tango database
|
|
106
109
|
self.__db = tango.Database()
|
|
@@ -163,7 +166,7 @@ class NXS_FileRecorder(BaseFileRecorder):
|
|
|
163
166
|
appendentry = self.__getConfVar("AppendEntry", True)
|
|
164
167
|
scanID = self.__env["ScanID"] \
|
|
165
168
|
if "ScanID" in self.__env.keys() else -1
|
|
166
|
-
|
|
169
|
+
self.__setFileName(
|
|
167
170
|
self.__base_filename, not appendentry, scanID)
|
|
168
171
|
|
|
169
172
|
def __command(self, server, command, *args):
|
|
@@ -338,10 +341,12 @@ class NXS_FileRecorder(BaseFileRecorder):
|
|
|
338
341
|
|
|
339
342
|
:param filename: sardana scanfile name
|
|
340
343
|
:type filename: :obj:`str`
|
|
341
|
-
:param
|
|
342
|
-
:param
|
|
344
|
+
:param number: True if append scanID
|
|
345
|
+
:param number: :obj:`bool`
|
|
343
346
|
:param scanID: scanID to append
|
|
344
347
|
:type scanID: :obj:`int`
|
|
348
|
+
:returns: True if append scanID
|
|
349
|
+
:rtype: :obj:`bool`
|
|
345
350
|
"""
|
|
346
351
|
if scanID is not None and scanID < 0:
|
|
347
352
|
return number
|
|
@@ -370,20 +375,30 @@ class NXS_FileRecorder(BaseFileRecorder):
|
|
|
370
375
|
|
|
371
376
|
subs = (len([None for _ in list(re.finditer('%', filename))]) == 1)
|
|
372
377
|
# construct the filename, e.g. : /dir/subdir/etcdir/prefix_00123.nxs
|
|
373
|
-
if
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
378
|
+
if scanID is None:
|
|
379
|
+
serial = self.recordlist.getEnvironValue('serialno')
|
|
380
|
+
elif scanID >= 0:
|
|
381
|
+
if isarver >= 304 or isarver == 0:
|
|
382
|
+
serial = scanID
|
|
383
|
+
else:
|
|
384
|
+
serial = scanID + 1
|
|
385
|
+
|
|
381
386
|
if subs:
|
|
382
387
|
try:
|
|
383
388
|
#: output file name
|
|
384
389
|
self.filename = filename % serial
|
|
385
390
|
except Exception:
|
|
386
391
|
subs = False
|
|
392
|
+
if not self.__raw_filename:
|
|
393
|
+
self.__raw_filename = self.__rawfilename(serial)
|
|
394
|
+
self.debug('Raw Filename: %s' % str(self.__raw_filename))
|
|
395
|
+
if not subs and self.__raw_filename and \
|
|
396
|
+
"{ScanID" in self.__raw_filename:
|
|
397
|
+
try:
|
|
398
|
+
self.filename = self.__raw_filename.format(ScanID=serial)
|
|
399
|
+
subs = True
|
|
400
|
+
except Exception:
|
|
401
|
+
pass
|
|
387
402
|
|
|
388
403
|
if not subs:
|
|
389
404
|
if number:
|
|
@@ -957,12 +972,11 @@ class NXS_FileRecorder(BaseFileRecorder):
|
|
|
957
972
|
self.__setNexusDevices()
|
|
958
973
|
|
|
959
974
|
appendentry = self.__getConfVar("AppendEntry", True)
|
|
960
|
-
|
|
961
|
-
appendentry = not self.__setFileName(
|
|
975
|
+
appendscanid = not self.__setFileName(
|
|
962
976
|
self.__base_filename, not appendentry)
|
|
963
977
|
envRec = self.recordlist.getEnviron()
|
|
964
978
|
self.__vars["vars"]["serialno"] = ("_%05i" % envRec["serialno"]) \
|
|
965
|
-
if
|
|
979
|
+
if appendscanid else ""
|
|
966
980
|
self.__vars["vars"]["scan_id"] = envRec["serialno"]
|
|
967
981
|
self.__vars["vars"]["scan_title"] = envRec["title"]
|
|
968
982
|
if self.__macro:
|
|
@@ -1129,7 +1143,10 @@ class NXS_FileRecorder(BaseFileRecorder):
|
|
|
1129
1143
|
tz = pytz.timezone(self.__timezone)
|
|
1130
1144
|
|
|
1131
1145
|
fmt = '%Y-%m-%dT%H:%M:%S.%f%z'
|
|
1132
|
-
|
|
1146
|
+
if sys.version_info > (3, 6):
|
|
1147
|
+
starttime = mtime.replace(tzinfo=tz)
|
|
1148
|
+
else:
|
|
1149
|
+
starttime = tz.localize(mtime)
|
|
1133
1150
|
return str(starttime.strftime(fmt))
|
|
1134
1151
|
|
|
1135
1152
|
def _endRecordList(self, recordlist):
|
|
@@ -1184,15 +1201,15 @@ class NXS_FileRecorder(BaseFileRecorder):
|
|
|
1184
1201
|
"""
|
|
1185
1202
|
result = ""
|
|
1186
1203
|
fpath = self.filename
|
|
1187
|
-
|
|
1188
|
-
|
|
1204
|
+
try:
|
|
1205
|
+
if fpath.startswith(bmtfpath):
|
|
1189
1206
|
if os.path.isdir(bmtfpath):
|
|
1190
1207
|
btml = [fl for fl in os.listdir(bmtfpath)
|
|
1191
1208
|
if (fl.startswith(bmtfprefix)
|
|
1192
1209
|
and fl.endswith(bmtfext))]
|
|
1193
1210
|
result = btml[0][len(bmtfprefix):-len(bmtfext)]
|
|
1194
|
-
|
|
1195
|
-
|
|
1211
|
+
except Exception:
|
|
1212
|
+
pass
|
|
1196
1213
|
return result
|
|
1197
1214
|
|
|
1198
1215
|
def beamtimeid(self):
|
|
@@ -1203,11 +1220,62 @@ class NXS_FileRecorder(BaseFileRecorder):
|
|
|
1203
1220
|
beamtimeid = self.beamtime_id(bmtfpath, bmtfprefix, bmtfext)
|
|
1204
1221
|
return beamtimeid or "00000000"
|
|
1205
1222
|
|
|
1223
|
+
def __rawfilename(self, serial):
|
|
1224
|
+
""" find scan name
|
|
1225
|
+
"""
|
|
1226
|
+
try:
|
|
1227
|
+
scan_file = self.__macro().getEnv('ScanFile')
|
|
1228
|
+
except Exception:
|
|
1229
|
+
scan_file = []
|
|
1230
|
+
try:
|
|
1231
|
+
scan_dir = self.__macro().getEnv('ScanDir')
|
|
1232
|
+
except Exception:
|
|
1233
|
+
scan_dir = "/"
|
|
1234
|
+
if isinstance(scan_file, str):
|
|
1235
|
+
scan_file = [scan_file]
|
|
1236
|
+
bfilename = ""
|
|
1237
|
+
|
|
1238
|
+
for sfile in scan_file:
|
|
1239
|
+
sfile = os.path.join(scan_dir, sfile)
|
|
1240
|
+
try:
|
|
1241
|
+
ffile = sfile.format(ScanID=serial)
|
|
1242
|
+
except KeyError:
|
|
1243
|
+
ffile = sfile
|
|
1244
|
+
if ffile == self.__base_filename:
|
|
1245
|
+
bfilename = sfile
|
|
1246
|
+
break
|
|
1247
|
+
bfilename = bfilename or self.__base_filename
|
|
1248
|
+
return bfilename
|
|
1249
|
+
|
|
1250
|
+
def __scanname(self, serial):
|
|
1251
|
+
""" find scan name
|
|
1252
|
+
"""
|
|
1253
|
+
if not self.__raw_filename:
|
|
1254
|
+
self.__raw_filename = self.__rawfilename(serial)
|
|
1255
|
+
bfilename = self.__raw_filename
|
|
1256
|
+
_, bfname = os.path.split(bfilename)
|
|
1257
|
+
if bfname.endswith(".tmp"):
|
|
1258
|
+
bfname = bfname[:-4]
|
|
1259
|
+
sname, fext = os.path.splitext(bfname)
|
|
1260
|
+
scanname = os.path.commonprefix(
|
|
1261
|
+
[sname.format(ScanID=11111111),
|
|
1262
|
+
sname.format(ScanID=99999999)])
|
|
1263
|
+
if '%' in scanname:
|
|
1264
|
+
try:
|
|
1265
|
+
scanname = os.path.commonprefix(
|
|
1266
|
+
[scanname % 11111111,
|
|
1267
|
+
scanname % 99999999])
|
|
1268
|
+
except Exception:
|
|
1269
|
+
pass
|
|
1270
|
+
if scanname.endswith("_"):
|
|
1271
|
+
scanname = scanname[:-1]
|
|
1272
|
+
return scanname
|
|
1273
|
+
|
|
1206
1274
|
def __appendSciCatDataset(self, hostname=None):
|
|
1207
1275
|
""" append dataset to SciCat ingestion list """
|
|
1208
1276
|
|
|
1277
|
+
sid = self.__vars["vars"]["scan_id"]
|
|
1209
1278
|
fdir, fname = os.path.split(self.filename)
|
|
1210
|
-
_, bfname = os.path.split(self.__base_filename)
|
|
1211
1279
|
sname, fext = os.path.splitext(fname)
|
|
1212
1280
|
beamtimeid = self.beamtimeid()
|
|
1213
1281
|
defprefix = "scicat-datasets-"
|
|
@@ -1227,12 +1295,17 @@ class NXS_FileRecorder(BaseFileRecorder):
|
|
|
1227
1295
|
variables = self.__getConfVar("ConfigVariables", None, True)
|
|
1228
1296
|
if isinstance(variables, dict) and "entryname" in variables:
|
|
1229
1297
|
entryname = variables["entryname"]
|
|
1230
|
-
try:
|
|
1231
|
-
scanname, _ = os.path.splitext(bfname % "")
|
|
1232
|
-
except Exception:
|
|
1233
|
-
scanname, _ = os.path.splitext(bfname)
|
|
1234
1298
|
|
|
1235
|
-
|
|
1299
|
+
scanname = self.__scanname(sid)
|
|
1300
|
+
# _, bfname = os.path.split(self.__base_filename)
|
|
1301
|
+
# try:
|
|
1302
|
+
# scanname, _ = os.path.splitext(bfname % "")
|
|
1303
|
+
# except Exception:
|
|
1304
|
+
# scanname, _ = os.path.splitext(bfname)
|
|
1305
|
+
|
|
1306
|
+
if appendentry is True and \
|
|
1307
|
+
'%' not in self.__raw_filename and \
|
|
1308
|
+
"{ScanID" not in self.__raw_filename:
|
|
1236
1309
|
sid = self.__vars["vars"]["scan_id"]
|
|
1237
1310
|
sname = "%s::/%s_%05i;%s_%05i" % (
|
|
1238
1311
|
scanname, entryname, sid, scanname, sid)
|
|
@@ -1270,15 +1343,17 @@ class NXS_FileRecorder(BaseFileRecorder):
|
|
|
1270
1343
|
def __createMeasurementFile(self):
|
|
1271
1344
|
""" create measurement file """
|
|
1272
1345
|
|
|
1346
|
+
sid = self.__vars["vars"]["scan_id"]
|
|
1273
1347
|
fdir, fname = os.path.split(self.filename)
|
|
1274
|
-
_, bfname = os.path.split(self.__base_filename)
|
|
1275
1348
|
sname, fext = os.path.splitext(fname)
|
|
1276
1349
|
# beamtimeid = self.beamtimeid()
|
|
1277
1350
|
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1351
|
+
scanname = self.__scanname(sid)
|
|
1352
|
+
# _, bfname = os.path.split(self.__base_filename)
|
|
1353
|
+
# try:
|
|
1354
|
+
# scanname, _ = os.path.splitext(bfname % "")
|
|
1355
|
+
# except Exception:
|
|
1356
|
+
# scanname, _ = os.path.splitext(bfname)
|
|
1282
1357
|
|
|
1283
1358
|
try:
|
|
1284
1359
|
sm = dict(self.__getEnvVar('SciCatMeasurements', {}))
|
|
@@ -1291,9 +1366,10 @@ class NXS_FileRecorder(BaseFileRecorder):
|
|
|
1291
1366
|
if isinstance(variables, dict) and "entryname" in variables:
|
|
1292
1367
|
entryname = variables["entryname"]
|
|
1293
1368
|
if appendentry is True:
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1369
|
+
if '%' not in self.__raw_filename and \
|
|
1370
|
+
"{ScanID" not in self.__raw_filename:
|
|
1371
|
+
sname = sname + ("_%05i" % sid)
|
|
1372
|
+
entryname = entryname + ("_%05i" % sid)
|
|
1297
1373
|
|
|
1298
1374
|
mntname = scanname
|
|
1299
1375
|
if fdir in sm.keys() and sm[fdir]:
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
sardananxsrecorder/__init__.py,sha256=mRcY04cojI1Qy7WCfg8k-CErYNwBhFdURBiNoU_7cLo,896
|
|
2
|
-
sardananxsrecorder/nxsrecorder.py,sha256=VWgx3cCBmhZMFOv9Pa-SxXDWjApYVCV55ABF-eBrlCY,52923
|
|
3
|
-
sardana_nxsrecorder-3.21.0.dist-info/METADATA,sha256=MlKRvkayInGgNBv0ReKWcwnOhxgk302JUbNmF3Owfi8,7566
|
|
4
|
-
sardana_nxsrecorder-3.21.0.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
|
5
|
-
sardana_nxsrecorder-3.21.0.dist-info/top_level.txt,sha256=YdD3m417i-jlYyQWgiizgZ8lQQcOjM8y-bmUHrGkfY4,19
|
|
6
|
-
sardana_nxsrecorder-3.21.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|