Skip to content

Commit eda27d1

Browse files
committed
add check to see that index.html is in required location
1 parent 868f19b commit eda27d1

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

GSASII/GSASIIseqGUI.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,22 +307,36 @@ def show_project_dialog():
307307
if not useCol[i]: continue
308308
row.append(f"{val:.{colDecimals[i]}f}")
309309
table_data.append(row)
310-
# Get location where software is installed
310+
311+
# Get location where Cinema software is installed
312+
# must have the index.html file
311313
selected_dir = GSASIIpath.GetConfigValue('CINEMA_DS_directory')
312-
if not (selected_dir and os.path.exists(selected_dir)):
314+
while ((selected_dir is None) or (not os.path.exists(selected_dir))
315+
or (not os.path.exists(os.path.join(selected_dir,'index.html')))
316+
):
313317
with wx.DirDialog(
314-
None,
318+
G2frame,
315319
message="Select Cinema directory containing index.html", # Dialog title
316320
defaultPath="", # Initial directory (empty = current)
317321
style=wx.DD_DEFAULT_STYLE # Dialog style
318322
) as dialogDir:
323+
dialogDir.CenterOnParent()
319324
if dialogDir.ShowModal() == wx.ID_OK:
320-
selected_dir = dialogDir.GetPath() # Get selected directory
325+
selected_dir = dialogDir.GetPath()
321326
dialogDir.Destroy()
322327
else:
323328
dialogDir.Destroy()
329+
print('Cancelling Cinema export')
324330
return
325-
GSASIIpath.SetConfigValue({'CINEMA_DS_directory':[None,selected_dir]})
331+
if not (os.path.exists(selected_dir) and
332+
os.path.exists(os.path.join(selected_dir,'index.html'))):
333+
G2G.G2MessageBox(G2frame,
334+
f'Directory {selected_dir!r} does not exist or '+
335+
'does not contain an index.html file. Try again',
336+
'Invalid location')
337+
continue # don't save if not valid
338+
GSASIIpath.SetConfigValue({'CINEMA_DS_directory':
339+
[None,selected_dir]})
326340
config = G2G.GetConfigValsDocs()
327341
G2G.SaveConfigVars(config)
328342

@@ -347,6 +361,7 @@ def show_project_dialog():
347361
dlg.Destroy()
348362
else:
349363
dlg.Destroy()
364+
print('Cancelling Cinema export')
350365
return
351366
file_path = os.path.join(db_directory, DATA_CSV_FILENAME)
352367

@@ -410,6 +425,7 @@ def show_project_dialog():
410425
return # Terminate execution if directory creation failed
411426
else:
412427
dlg.Destroy()
428+
print('Cancelling Cinema export')
413429
return
414430

415431
try:
@@ -2333,8 +2349,9 @@ def OnSelection(event):
23332349

23342350
def ExportSequentialImages(G2frame,histNames,outdir,dpi='figure'):
23352351
'''Used to create plot images as PNG for each fit in the sequential results
2336-
table in images are created in a temporary directory.
2352+
table.
23372353
For PWDR entries only.
2354+
Used in Cinema: D-S to create refinement thumbnails.
23382355
23392356
:param wx.Frame G2frame: reference to main GSAS-II frame
23402357
:param list histNames: a list of the tree name entries

0 commit comments

Comments
 (0)