Changeset 4155


Ignore:
Timestamp:
Sep 19, 2019 9:04:40 PM (2 years ago)
Author:
toby
Message:

better error reporting w/bad config.py, make copy & overwrite on save

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIctrlGUI.py

    r4093 r4155  
    47184718    except ImportError: # no config.py file yet
    47194719        savefile = os.path.join(GSASIIpath.path2GSAS2,'config.py')
     4720    except Exception as err: # import failed
     4721        # find the bad file, save it in a new name and prepare to overwrite it
     4722        for p in sys.path:
     4723            savefile = os.path.join(p,'config.py')
     4724            if os.path.exists(savefile):
     4725                import distutils.file_util as dfu
     4726                keepfile = os.path.join(p,'config.py_corrupt')
     4727                print('Current config file contains an error:',savefile)
     4728                print('saving that file as',keepfile)
     4729                dfu.copy_file(savefile,keepfile)
     4730                print('preparing to overwrite...')
     4731                break
     4732        else:
     4733            print('unexpected error importing config.py')
     4734            savefile = os.path.join(GSASIIpath.path2GSAS2,'config.py')
     4735       
    47204736    # try to open file for write
    47214737    try:
  • trunk/GSASIIpath.py

    r4154 r4155  
    978978        configDict = {'Clip_on':True}
    979979    except Exception as err:
     980        print(60*'*',"\nError reading config.py file")
    980981        if printInfo:
    981             print("Error importing config.py file: "+str(err))
     982            import traceback
     983            print(traceback.format_exc())
     984        print(60*'*')
    982985        configDict = {'Clip_on':True}
    983986
Note: See TracChangeset for help on using the changeset viewer.