Print

Print


Repository : ssh://g18-sc-serv-04.diamond.ac.uk/dials
On branch  : master




commit 86b61a1b92893537f0c6a463687fd9f1278922c0
Author: James Beilsten-Edmands <[log in to unmask]>
Date:   Wed Jul 25 09:45:46 2018 +0100

    Allow use of dials.geometry_viewer without images
    
    Allow use of phil parameter require_images=False to skip the format
    checking that requires images files etc for parsing the experimentlist.
    Also print a help suggestion if an error is raised during parsing in
    geometry viewer.
    
    This means one no longer needs to use the environment variable
    DIALS_EXPORT_DO_NOT_CHECK_FORMAT=FALSE, however the use of this
    is still allowed for compatibility, but a warning message is printed.
    
    Closes #484





86b61a1b92893537f0c6a463687fd9f1278922c0
command_line/geometry_viewer.py | 33 +++++++++++++++++++++++++++------
1 file changed, 27 insertions(+), 6 deletions(-)

diff --git a/command_line/geometry_viewer.py b/command_line/geometry_viewer.py
index 096219f5..4ee65ff7 100644
--- a/command_line/geometry_viewer.py
+++ b/command_line/geometry_viewer.py
@@ -41,6 +41,11 @@
   show_panel_axes = False
     .type = bool
     .help = "Plot the fast, slow and normal vectors for each panel."
+  require_images = True
+    .type = bool
+    .help = "Flag which can be set to False to launch image viewer without
+      checking the image format (needed for some image format classes).
+      Alternative to DIALS_EXPORT_DO_NOT_CHECK_FORMAT environment variable."
""")

def settings():
@@ -550,13 +555,12 @@ def run(args):
   from dials.util.options import flatten_datablocks
   from dials.util.options import flatten_experiments
   import libtbx.load_env
+  import os

   usage = "%s [options] datablock.json" %(
     libtbx.env.dispatcher_name)

-  import os
-  if 'DIALS_EXPORT_DO_NOT_CHECK_FORMAT' in os.environ:
-    parser = OptionParser(
+  parser = OptionParser(
       usage=usage,
       phil=phil_scope,
       read_datablocks=True,
@@ -564,19 +568,36 @@ def run(args):
       check_format=False,
       epilog=help_message)

+  params, options = parser.parse_args(quick_parse=True, show_diff_phil=True)
+
+  if 'DIALS_EXPORT_DO_NOT_CHECK_FORMAT' in os.environ:
+    print('\nWarning: use of DIALS_EXPORT_DO_NOT_CHECK_FORMAT environment variable'
+      '\nis no longer recommended, the recommended command is require_images=False')
+  if not params.require_images or 'DIALS_EXPORT_DO_NOT_CHECK_FORMAT' in os.environ:
+    check_format = False
   else:
-    parser = OptionParser(
+    check_format = True
+
+  parser = OptionParser(
       usage=usage,
       phil=phil_scope,
       read_datablocks=True,
       read_experiments=True,
-      check_format=True,
+      check_format=check_format,
       epilog=help_message)

-  params, options = parser.parse_args(show_diff_phil=True)
+  try:
+    params, options = parser.parse_args(show_diff_phil=False)
+  except Exception as e:
+    print(e)
+    print('dials.geometry_viewer help: Error in parsing data may be due to missing \n'
+      'files. If so, this may be overcome by require_images=False\n')
+    sys.exit()
+
   datablocks = flatten_datablocks(params.input.datablock)
   experiments = flatten_experiments(params.input.experiments)

+
   if (len(datablocks) == 0 and len(experiments) == 0):
     parser.print_help()
     exit(0)


To unsubscribe from the DIALS-COMMIT list, click the following link:
https://www.jiscmail.ac.uk/cgi-bin/webadmin?SUBED1=DIALS-COMMIT&A=1