Changeset cb9640f in sasview for src/sas/_config.py


Ignore:
Timestamp:
Dec 17, 2018 7:15:53 AM (5 years ago)
Author:
GitHub <noreply@…>
Branches:
master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249
Children:
dcd6efd
Parents:
33d3a74 (diff), 93b34cc (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Wojciech Potrzebowski <Wojciech.Potrzebowski@…> (12/17/18 07:15:53)
git-committer:
GitHub <noreply@…> (12/17/18 07:15:53)
Message:

Merge pull request #196 from SasView?/config-error

redo handling of cust config failures

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/_config.py

    rb963b20 r93b34cc  
    8686def setup_custom_config(app_dir, user_dir): 
    8787    path = make_custom_config_path(user_dir) 
     88    #logger.info("custom config path %s", path) 
    8889    if not os.path.isfile(path): 
    8990        try: 
     
    9495            logger.error("Could not copy default custom config.") 
    9596 
     97    custom_config = load_custom_config(path) 
     98 
    9699    #Adding SAS_OPENCL if it doesn't exist in the config file 
    97100    # - to support backcompability 
    98     if not "SAS_OPENCL" in open(path).read(): 
     101    if not hasattr(custom_config, "SAS_OPENCL"): 
     102        custom_config.SAS_OPENCL = None 
    99103        try: 
    100             open(config_file, "a+").write("SAS_OPENCL = \"None\"\n") 
     104            open(path, "a+").write("SAS_OPENCL = \"None\"\n") 
    101105        except Exception: 
    102106            logger.error("Could not update custom config with SAS_OPENCL.") 
    103107 
    104     custom_config = load_custom_config(path) 
    105108    return custom_config 
    106  
    107109 
    108110def load_custom_config(path): 
Note: See TracChangeset for help on using the changeset viewer.