sardana-nxsrecorder 3.21.1__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.1.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 +104 -32
- sardana_nxsrecorder-3.21.1.dist-info/RECORD +0 -6
- {sardana_nxsrecorder-3.21.1.dist-info → sardana_nxsrecorder-3.22.0.dist-info}/WHEEL +0 -0
- {sardana_nxsrecorder-3.21.1.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
|
@@ -102,6 +102,8 @@ class NXS_FileRecorder(BaseFileRecorder):
|
|
|
102
102
|
BaseFileRecorder.__init__(self)
|
|
103
103
|
#: (:obj:`str`) base filename
|
|
104
104
|
self.__base_filename = filename
|
|
105
|
+
#: (:obj:`str`) raw filename
|
|
106
|
+
self.__raw_filename = ""
|
|
105
107
|
self.__macro = weakref.ref(macro) if macro else None
|
|
106
108
|
#: (:class:`tango.Database`) tango database
|
|
107
109
|
self.__db = tango.Database()
|
|
@@ -164,7 +166,7 @@ class NXS_FileRecorder(BaseFileRecorder):
|
|
|
164
166
|
appendentry = self.__getConfVar("AppendEntry", True)
|
|
165
167
|
scanID = self.__env["ScanID"] \
|
|
166
168
|
if "ScanID" in self.__env.keys() else -1
|
|
167
|
-
|
|
169
|
+
self.__setFileName(
|
|
168
170
|
self.__base_filename, not appendentry, scanID)
|
|
169
171
|
|
|
170
172
|
def __command(self, server, command, *args):
|
|
@@ -339,10 +341,12 @@ class NXS_FileRecorder(BaseFileRecorder):
|
|
|
339
341
|
|
|
340
342
|
:param filename: sardana scanfile name
|
|
341
343
|
:type filename: :obj:`str`
|
|
342
|
-
:param
|
|
343
|
-
:param
|
|
344
|
+
:param number: True if append scanID
|
|
345
|
+
:param number: :obj:`bool`
|
|
344
346
|
:param scanID: scanID to append
|
|
345
347
|
:type scanID: :obj:`int`
|
|
348
|
+
:returns: True if append scanID
|
|
349
|
+
:rtype: :obj:`bool`
|
|
346
350
|
"""
|
|
347
351
|
if scanID is not None and scanID < 0:
|
|
348
352
|
return number
|
|
@@ -371,20 +375,30 @@ class NXS_FileRecorder(BaseFileRecorder):
|
|
|
371
375
|
|
|
372
376
|
subs = (len([None for _ in list(re.finditer('%', filename))]) == 1)
|
|
373
377
|
# construct the filename, e.g. : /dir/subdir/etcdir/prefix_00123.nxs
|
|
374
|
-
if
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
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
|
+
|
|
382
386
|
if subs:
|
|
383
387
|
try:
|
|
384
388
|
#: output file name
|
|
385
389
|
self.filename = filename % serial
|
|
386
390
|
except Exception:
|
|
387
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
|
|
388
402
|
|
|
389
403
|
if not subs:
|
|
390
404
|
if number:
|
|
@@ -958,12 +972,11 @@ class NXS_FileRecorder(BaseFileRecorder):
|
|
|
958
972
|
self.__setNexusDevices()
|
|
959
973
|
|
|
960
974
|
appendentry = self.__getConfVar("AppendEntry", True)
|
|
961
|
-
|
|
962
|
-
appendentry = not self.__setFileName(
|
|
975
|
+
appendscanid = not self.__setFileName(
|
|
963
976
|
self.__base_filename, not appendentry)
|
|
964
977
|
envRec = self.recordlist.getEnviron()
|
|
965
978
|
self.__vars["vars"]["serialno"] = ("_%05i" % envRec["serialno"]) \
|
|
966
|
-
if
|
|
979
|
+
if appendscanid else ""
|
|
967
980
|
self.__vars["vars"]["scan_id"] = envRec["serialno"]
|
|
968
981
|
self.__vars["vars"]["scan_title"] = envRec["title"]
|
|
969
982
|
if self.__macro:
|
|
@@ -1188,15 +1201,15 @@ class NXS_FileRecorder(BaseFileRecorder):
|
|
|
1188
1201
|
"""
|
|
1189
1202
|
result = ""
|
|
1190
1203
|
fpath = self.filename
|
|
1191
|
-
|
|
1192
|
-
|
|
1204
|
+
try:
|
|
1205
|
+
if fpath.startswith(bmtfpath):
|
|
1193
1206
|
if os.path.isdir(bmtfpath):
|
|
1194
1207
|
btml = [fl for fl in os.listdir(bmtfpath)
|
|
1195
1208
|
if (fl.startswith(bmtfprefix)
|
|
1196
1209
|
and fl.endswith(bmtfext))]
|
|
1197
1210
|
result = btml[0][len(bmtfprefix):-len(bmtfext)]
|
|
1198
|
-
|
|
1199
|
-
|
|
1211
|
+
except Exception:
|
|
1212
|
+
pass
|
|
1200
1213
|
return result
|
|
1201
1214
|
|
|
1202
1215
|
def beamtimeid(self):
|
|
@@ -1207,11 +1220,62 @@ class NXS_FileRecorder(BaseFileRecorder):
|
|
|
1207
1220
|
beamtimeid = self.beamtime_id(bmtfpath, bmtfprefix, bmtfext)
|
|
1208
1221
|
return beamtimeid or "00000000"
|
|
1209
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
|
+
|
|
1210
1274
|
def __appendSciCatDataset(self, hostname=None):
|
|
1211
1275
|
""" append dataset to SciCat ingestion list """
|
|
1212
1276
|
|
|
1277
|
+
sid = self.__vars["vars"]["scan_id"]
|
|
1213
1278
|
fdir, fname = os.path.split(self.filename)
|
|
1214
|
-
_, bfname = os.path.split(self.__base_filename)
|
|
1215
1279
|
sname, fext = os.path.splitext(fname)
|
|
1216
1280
|
beamtimeid = self.beamtimeid()
|
|
1217
1281
|
defprefix = "scicat-datasets-"
|
|
@@ -1231,12 +1295,17 @@ class NXS_FileRecorder(BaseFileRecorder):
|
|
|
1231
1295
|
variables = self.__getConfVar("ConfigVariables", None, True)
|
|
1232
1296
|
if isinstance(variables, dict) and "entryname" in variables:
|
|
1233
1297
|
entryname = variables["entryname"]
|
|
1234
|
-
try:
|
|
1235
|
-
scanname, _ = os.path.splitext(bfname % "")
|
|
1236
|
-
except Exception:
|
|
1237
|
-
scanname, _ = os.path.splitext(bfname)
|
|
1238
1298
|
|
|
1239
|
-
|
|
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:
|
|
1240
1309
|
sid = self.__vars["vars"]["scan_id"]
|
|
1241
1310
|
sname = "%s::/%s_%05i;%s_%05i" % (
|
|
1242
1311
|
scanname, entryname, sid, scanname, sid)
|
|
@@ -1274,15 +1343,17 @@ class NXS_FileRecorder(BaseFileRecorder):
|
|
|
1274
1343
|
def __createMeasurementFile(self):
|
|
1275
1344
|
""" create measurement file """
|
|
1276
1345
|
|
|
1346
|
+
sid = self.__vars["vars"]["scan_id"]
|
|
1277
1347
|
fdir, fname = os.path.split(self.filename)
|
|
1278
|
-
_, bfname = os.path.split(self.__base_filename)
|
|
1279
1348
|
sname, fext = os.path.splitext(fname)
|
|
1280
1349
|
# beamtimeid = self.beamtimeid()
|
|
1281
1350
|
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
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)
|
|
1286
1357
|
|
|
1287
1358
|
try:
|
|
1288
1359
|
sm = dict(self.__getEnvVar('SciCatMeasurements', {}))
|
|
@@ -1295,9 +1366,10 @@ class NXS_FileRecorder(BaseFileRecorder):
|
|
|
1295
1366
|
if isinstance(variables, dict) and "entryname" in variables:
|
|
1296
1367
|
entryname = variables["entryname"]
|
|
1297
1368
|
if appendentry is True:
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
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)
|
|
1301
1373
|
|
|
1302
1374
|
mntname = scanname
|
|
1303
1375
|
if fdir in sm.keys() and sm[fdir]:
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
sardananxsrecorder/__init__.py,sha256=oD-0m9QGVmtssbJ2KNAVtNlHgQc0-LN1W3acxQk15Cg,896
|
|
2
|
-
sardananxsrecorder/nxsrecorder.py,sha256=ywGXHnqP_-tOqOEtv_vMyciDjJXr5S0EAmjRpbcQCJA,53039
|
|
3
|
-
sardana_nxsrecorder-3.21.1.dist-info/METADATA,sha256=cpiIZsvcLBOkDLuyyglxUGqpLlR-4LYBS2L_YtxMwFU,7566
|
|
4
|
-
sardana_nxsrecorder-3.21.1.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
|
5
|
-
sardana_nxsrecorder-3.21.1.dist-info/top_level.txt,sha256=YdD3m417i-jlYyQWgiizgZ8lQQcOjM8y-bmUHrGkfY4,19
|
|
6
|
-
sardana_nxsrecorder-3.21.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|