Date: Mon, 12 Sep 2022 14:19:50 +0100
Subject: [PATCH 28/82] Removed yet more fields from config
---
src/sas/config_system/config.py | 8 --------
src/sas/qtgui/MainWindow/AboutBox.py | 2 +-
src/sas/qtgui/MainWindow/GuiManager.py | 3 ++-
src/sas/qtgui/MainWindow/UnitTesting/AboutBoxTest.py | 4 ++--
src/sas/qtgui/MainWindow/WelcomePanel.py | 2 +-
src/sas/system/legal.py | 2 +-
src/sas/system/web.py | 1 +
7 files changed, 8 insertions(+), 14 deletions(-)
diff --git a/src/sas/config_system/config.py b/src/sas/config_system/config.py
index a3cbbc7871..db9b2a1ac8 100644
--- a/src/sas/config_system/config.py
+++ b/src/sas/config_system/config.py
@@ -140,8 +140,6 @@ def __init__(self):
self.__appname__ = "SasView"
self.__version__ = sas.sasview.__version__
self.__build__ = sas.sasview.__build__
- self.__download_page__ = 'https://github.com/SasView/sasview/releases'
- self.__update_URL__ = 'https://www.sasview.org/latestversion.json'
# Debug message flag
self.__EVT_DEBUG__ = False
@@ -166,8 +164,6 @@ def __init__(self):
self._corner_image = os.path.join(self.icon_path, "angles_flat.png")
self._welcome_image = os.path.join(self.icon_path, "SVwelcome.png")
- # self._copyright = "(c) 2009 - 2022, UTK, UMD, NIST, ORNL, ISIS, ESS, ILL, ANSTO, TU Delft and DLS"
- self._copyright = "Copyright (c) 2009-2022 UTK, UMD, ESS, NIST, ORNL, ISIS, ILL, DLS, TUD, BAM and ANSTO"
# edit the list of file state your plugin can read
self.APPLICATION_WLIST = 'SasView files (*.svs)|*.svs'
@@ -247,10 +243,6 @@ def __init__(self):
# Time out for updating sasview
self.UPDATE_TIMEOUT = 2
- # Logging levels to disable, if any
- self.DISABLE_LOGGING = logging.NOTSET
-
- # Location of the marketplace
#
# Lock the class down
diff --git a/src/sas/qtgui/MainWindow/AboutBox.py b/src/sas/qtgui/MainWindow/AboutBox.py
index c838cc80ca..117d1f7f0f 100644
--- a/src/sas/qtgui/MainWindow/AboutBox.py
+++ b/src/sas/qtgui/MainWindow/AboutBox.py
@@ -43,7 +43,7 @@ def addText(self):
Build{config.__build__}
- {legal._copyright}
+ {legal.copyright}
{web.homepage_url}
diff --git a/src/sas/qtgui/MainWindow/GuiManager.py b/src/sas/qtgui/MainWindow/GuiManager.py
index c3c9b6a112..3b2a177f59 100644
--- a/src/sas/qtgui/MainWindow/GuiManager.py
+++ b/src/sas/qtgui/MainWindow/GuiManager.py
@@ -66,6 +66,7 @@
from sas.qtgui.Utilities.FileConverter import FileConverterWidget
from sas import config
+from sas.system import web
logger = logging.getLogger(__name__)
@@ -529,7 +530,7 @@ def checkUpdate(self):
a call-back method when the current version number has been obtained.
"""
version_info = {"version": "0.0.0"}
- c = ConnectionProxy(config.__update_URL__, config.UPDATE_TIMEOUT)
+ c = ConnectionProxy(web.update_url, config.UPDATE_TIMEOUT)
response = c.connect()
if response is None:
return
diff --git a/src/sas/qtgui/MainWindow/UnitTesting/AboutBoxTest.py b/src/sas/qtgui/MainWindow/UnitTesting/AboutBoxTest.py
index 3bb8b6b588..42c51a5860 100644
--- a/src/sas/qtgui/MainWindow/UnitTesting/AboutBoxTest.py
+++ b/src/sas/qtgui/MainWindow/UnitTesting/AboutBoxTest.py
@@ -8,7 +8,7 @@
from unittest.mock import MagicMock
from sas import config
-from sas.system import web
+from sas.system import web, legal
# Local
from sas.qtgui.MainWindow.AboutBox import AboutBox
@@ -55,7 +55,7 @@ def testAbout(self):
# build version
self.assertIn(str(config.__build__), about.text())
# License
- self.assertIn(str(config._copyright), about.text())
+ self.assertIn(str(legal.copyright), about.text())
# URLs
self.assertIn(str(web.homepage_url), about.text())
self.assertIn(str(config.download_url), about.text())
diff --git a/src/sas/qtgui/MainWindow/WelcomePanel.py b/src/sas/qtgui/MainWindow/WelcomePanel.py
index 9f1d98d546..729761c4a6 100644
--- a/src/sas/qtgui/MainWindow/WelcomePanel.py
+++ b/src/sas/qtgui/MainWindow/WelcomePanel.py
@@ -17,7 +17,7 @@ def __init__(self, parent=None):
version = sas.sasview.__version__ # TODO: Make consistent with other version references
build = sas.sasview.__build__ # TODO: Make consistent with other build references
- ver = "\nSasView %s\nBuild: %s\n%s" % (version, build, legal._copyright)
+ ver = "\nSasView %s\nBuild: %s\n%s" % (version, build, legal.copyright)
self.lblVersion.setText(ver)
diff --git a/src/sas/system/legal.py b/src/sas/system/legal.py
index 7274590fe6..1c900b1dbd 100644
--- a/src/sas/system/legal.py
+++ b/src/sas/system/legal.py
@@ -1,6 +1,6 @@
class Legal:
def __init__(self):
- self._copyright = "Copyright (c) 2009-2022 UTK, UMD, ESS, NIST, ORNL, ISIS, ILL, DLS, TUD, BAM and ANSTO"
+ self.copyright = "Copyright (c) 2009-2022 UTK, UMD, ESS, NIST, ORNL, ISIS, ILL, DLS, TUD, BAM and ANSTO"
legal = Legal()
\ No newline at end of file
diff --git a/src/sas/system/web.py b/src/sas/system/web.py
index 4a309b7ef0..45a665945d 100644
--- a/src/sas/system/web.py
+++ b/src/sas/system/web.py
@@ -15,6 +15,7 @@ def __init__(self):
self.homepage_url = "https://www.sasview.org"
self.download_url = 'https://github.com/SasView/sasview/releases'
+ self.update_url = 'https://www.sasview.org/latestversion.json'
self._license = "help@sasview.org" # TODO: Rename
From 351359d3fbc2e4a53564bfb6f23d93e89d93d21b Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Mon, 12 Sep 2022 14:23:24 +0100
Subject: [PATCH 29/82] Moved more urls out of config
---
src/sas/config_system/config.py | 4 ++--
src/sas/qtgui/MainWindow/GuiManager.py | 3 +--
src/sas/system/web.py | 1 +
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/sas/config_system/config.py b/src/sas/config_system/config.py
index db9b2a1ac8..8ae4308338 100644
--- a/src/sas/config_system/config.py
+++ b/src/sas/config_system/config.py
@@ -232,7 +232,6 @@ def __init__(self):
self.TOOLBAR_SHOW = True
self.DEFAULT_PERSPECTIVE = "Fitting"
self.SAS_OPENCL = "None"
- self.MARKETPLACE_URL = "http://marketplace.sasview.org/"
# Logging options
self.FILTER_DEBUG_LOGS = True
@@ -245,7 +244,8 @@ def __init__(self):
#
- # Lock the class down
+ # Lock the class down, this is necessary both for
+ # securing the class, and for setting up reading/writing files
#
self.finalise()
diff --git a/src/sas/qtgui/MainWindow/GuiManager.py b/src/sas/qtgui/MainWindow/GuiManager.py
index 3b2a177f59..a2ecba6ce1 100644
--- a/src/sas/qtgui/MainWindow/GuiManager.py
+++ b/src/sas/qtgui/MainWindow/GuiManager.py
@@ -1213,8 +1213,7 @@ def actionMarketplace(self):
"""
Open the marketplace link in default browser
"""
- url = config.MARKETPLACE_URL
- webbrowser.open_new(url)
+ webbrowser.open_new(web.marketplace_url)
def actionAbout(self):
"""
diff --git a/src/sas/system/web.py b/src/sas/system/web.py
index 45a665945d..feb442666d 100644
--- a/src/sas/system/web.py
+++ b/src/sas/system/web.py
@@ -15,6 +15,7 @@ def __init__(self):
self.homepage_url = "https://www.sasview.org"
self.download_url = 'https://github.com/SasView/sasview/releases'
+ self.marketplace_url = "http://marketplace.sasview.org/"
self.update_url = 'https://www.sasview.org/latestversion.json'
self._license = "help@sasview.org" # TODO: Rename
From d68dc077da7c8dba4e9b5a6b3cb650de84e65495 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Mon, 12 Sep 2022 15:04:32 +0100
Subject: [PATCH 30/82] More notes in config
---
src/sas/config_system/config.py | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/sas/config_system/config.py b/src/sas/config_system/config.py
index 8ae4308338..ca4fb8e570 100644
--- a/src/sas/config_system/config.py
+++ b/src/sas/config_system/config.py
@@ -93,7 +93,14 @@
problem at hand, but about the future maintainability of SasView in
general.
-Deleting from Config class:
+Adding to the Config class:
+Before adding a variable, think about whether it might more properly
+belong somewhere else, perhaps in the web or legal classes in the
+system package.
+Remember that config variables are accessed across the whole of sasview
+and that names need to be suitably descriptive.
+
+Deleting from the Config class:
Currently (02/09/2022) the consequences of providing an entry in a
config file that is not properly reflected in the Config class is a
error. To ease backward compatibility, it is possible to disable
From ed5ab9027ee98264396d013f63e14b33e32da445 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Mon, 12 Sep 2022 15:19:38 +0100
Subject: [PATCH 31/82] Removed more stuff from config
---
src/sas/config_system/config.py | 3 +-
src/sas/qtgui/Utilities/GuiUtils.py | 67 ++++++++++-------------------
2 files changed, 23 insertions(+), 47 deletions(-)
diff --git a/src/sas/config_system/config.py b/src/sas/config_system/config.py
index ca4fb8e570..0d1eedfcea 100644
--- a/src/sas/config_system/config.py
+++ b/src/sas/config_system/config.py
@@ -188,8 +188,7 @@ def __init__(self):
self.DATAPANEL_HEIGHT = 700
self.SPLASH_SCREEN_PATH = os.path.join(self.icon_path, "SVwelcome_mini.png")
self.TUTORIAL_PATH = os.path.join(self.media_path, "Tutorial.pdf")
- # DEFAULT_STYLE = GUIFRAME.MULTIPLE_APPLICATIONS|GUIFRAME.MANAGER_ON\
- # |GUIFRAME.CALCULATOR_ON|GUIFRAME.TOOLBAR_ON
+
self.DEFAULT_STYLE = 64
self.SPLASH_SCREEN_WIDTH = 512
diff --git a/src/sas/qtgui/Utilities/GuiUtils.py b/src/sas/qtgui/Utilities/GuiUtils.py
index b08cd34e62..8b1c64ff84 100644
--- a/src/sas/qtgui/Utilities/GuiUtils.py
+++ b/src/sas/qtgui/Utilities/GuiUtils.py
@@ -135,16 +135,6 @@ def _find_local_config(confg_file, path):
# else:
# pass
-#
-#
-# c_conf_dir = CustomDir.setup_conf_dir(PATH_APP)
-# custom_config = _find_local_config('custom_config', c_conf_dir)
-# if custom_config is None:
-# custom_config = _find_local_config('custom_config', os.getcwd())
-# if custom_config is None:
-# msgConfig = "Custom_config file was not imported"
-custom_config = config
-# logging.info("Custom config path: %s", custom_config)
#read some constants from config
APPLICATION_STATE_EXTENSION = config.APPLICATION_STATE_EXTENSION
@@ -154,46 +144,33 @@ def _find_local_config(confg_file, path):
SPLASH_SCREEN_WIDTH = config.SPLASH_SCREEN_WIDTH
SPLASH_SCREEN_HEIGHT = config.SPLASH_SCREEN_HEIGHT
SS_MAX_DISPLAY_TIME = config.SS_MAX_DISPLAY_TIME
+
if not WELCOME_PANEL_ON:
WELCOME_PANEL_SHOW = False
else:
WELCOME_PANEL_SHOW = True
-try:
- DATALOADER_SHOW = custom_config.DATALOADER_SHOW
- TOOLBAR_SHOW = custom_config.TOOLBAR_SHOW
- FIXED_PANEL = custom_config.FIXED_PANEL
- if WELCOME_PANEL_ON:
- WELCOME_PANEL_SHOW = custom_config.WELCOME_PANEL_SHOW
- PLOPANEL_WIDTH = custom_config.PLOPANEL_WIDTH
- DATAPANEL_WIDTH = custom_config.DATAPANEL_WIDTH
- GUIFRAME_WIDTH = custom_config.GUIFRAME_WIDTH
- GUIFRAME_HEIGHT = custom_config.GUIFRAME_HEIGHT
- CONTROL_WIDTH = custom_config.CONTROL_WIDTH
- CONTROL_HEIGHT = custom_config.CONTROL_HEIGHT
- DEFAULT_PERSPECTIVE = custom_config.DEFAULT_PERSPECTIVE
- CLEANUP_PLOT = custom_config.CLEANUP_PLOT
- SAS_OPENCL = custom_config.SAS_OPENCL
- # custom open_path
- open_folder = custom_config.DEFAULT_OPEN_FOLDER
- if open_folder is not None and os.path.isdir(open_folder):
- DEFAULT_OPEN_FOLDER = os.path.abspath(open_folder)
- else:
- DEFAULT_OPEN_FOLDER = PATH_APP
-except AttributeError:
- DATALOADER_SHOW = True
- TOOLBAR_SHOW = True
- FIXED_PANEL = True
- WELCOME_PANEL_SHOW = False
- PLOPANEL_WIDTH = config.PLOPANEL_WIDTH
- DATAPANEL_WIDTH = config.DATAPANEL_WIDTH
- GUIFRAME_WIDTH = config.GUIFRAME_WIDTH
- GUIFRAME_HEIGHT = config.GUIFRAME_HEIGHT
- CONTROL_WIDTH = -1
- CONTROL_HEIGHT = -1
- DEFAULT_PERSPECTIVE = None
- CLEANUP_PLOT = False
+
+DATALOADER_SHOW = config.DATALOADER_SHOW
+TOOLBAR_SHOW = config.TOOLBAR_SHOW
+FIXED_PANEL = config.FIXED_PANEL
+if WELCOME_PANEL_ON:
+ WELCOME_PANEL_SHOW = config.WELCOME_PANEL_SHOW
+PLOPANEL_WIDTH = config.PLOPANEL_WIDTH
+DATAPANEL_WIDTH = config.DATAPANEL_WIDTH
+GUIFRAME_WIDTH = config.GUIFRAME_WIDTH
+GUIFRAME_HEIGHT = config.GUIFRAME_HEIGHT
+CONTROL_WIDTH = config.CONTROL_WIDTH
+CONTROL_HEIGHT = config.CONTROL_HEIGHT
+DEFAULT_PERSPECTIVE = config.DEFAULT_PERSPECTIVE
+CLEANUP_PLOT = config.CLEANUP_PLOT
+SAS_OPENCL = config.SAS_OPENCL
+# custom open_path
+open_folder = config.DEFAULT_OPEN_FOLDER
+if open_folder is not None and os.path.isdir(open_folder):
+ DEFAULT_OPEN_FOLDER = os.path.abspath(open_folder)
+else:
DEFAULT_OPEN_FOLDER = PATH_APP
- SAS_OPENCL = config.SAS_OPENCL
+
#DEFAULT_STYLE = config.DEFAULT_STYLE
From b11146e3ad4a15161b4d143d378dff08577aef25 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Mon, 12 Sep 2022 15:22:39 +0100
Subject: [PATCH 32/82] Removed printEVT
---
src/sas/config_system/config.py | 15 ---------------
1 file changed, 15 deletions(-)
diff --git a/src/sas/config_system/config.py b/src/sas/config_system/config.py
index 0d1eedfcea..da9c975f2d 100644
--- a/src/sas/config_system/config.py
+++ b/src/sas/config_system/config.py
@@ -255,20 +255,5 @@ def __init__(self):
#
self.finalise()
- def printEVT(self, message):
- if self.__EVT_DEBUG__:
- """
- :TODO - Need method doc string
- """
- print("%g: %s" % (time.clock(), message))
-
- if self.__EVT_DEBUG_2_FILE__:
- out = open(self.__EVT_DEBUG_FILENAME__, 'a')
- out.write("%10g: %s\n" % (time.clock(), message))
- out.close()
-
-
-
-
From 86b8745884bfdb79545730bd4f8ae349fe919494 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Mon, 12 Sep 2022 16:12:29 +0100
Subject: [PATCH 33/82] Config loading and saving properly implemented
---
src/sas/__init__.py | 4 ++++
src/sas/config_system/config_meta.py | 31 +++++++++++++++++++++-----
src/sas/qtgui/MainWindow/GuiManager.py | 5 +----
test/config/utest_config.py | 8 +++----
4 files changed, 34 insertions(+), 14 deletions(-)
diff --git a/src/sas/__init__.py b/src/sas/__init__.py
index d2133d3999..a41c7ecb5f 100644
--- a/src/sas/__init__.py
+++ b/src/sas/__init__.py
@@ -6,6 +6,10 @@
__all__ = ['get_app_dir', 'get_user_dir', 'config']
+# Load the config file
+config.load()
+
+
_APP_DIR = None
def get_app_dir():
"""
diff --git a/src/sas/config_system/config_meta.py b/src/sas/config_system/config_meta.py
index eb72c17796..a25c61961c 100644
--- a/src/sas/config_system/config_meta.py
+++ b/src/sas/config_system/config_meta.py
@@ -1,9 +1,11 @@
-from typing import Optional, Dict, Any, List, Set
-import json
+from typing import Dict, Any, List
+import os
import logging
-from sas.config_system.schema_elements import create_schema_element, CoercionError, SchemaElement
+import json
from copy import deepcopy
+
import sas
+from sas.config_system.schema_elements import create_schema_element, CoercionError, SchemaElement
logger = logging.getLogger("sas.config_system")
@@ -39,7 +41,9 @@ def __init__(self):
self._schema: Dict[str, SchemaElement] = {}
self._defaults: Dict[str, SchemaElement] = {}
self._deleted_attributes: List[str] = []
- self._meta_attributes = ["_locked", "_schema", "_defaults", "_deleted_attributes", "_meta_attributes"]
+ self._write_disabled = False
+ self._meta_attributes = ["_locked", "_schema", "_defaults",
+ "_deleted_attributes", "_meta_attributes", "_write_disabled"]
def finalise(self):
""" Call this at the end of the config to make this class 'final'
@@ -71,7 +75,15 @@ def update(self, data: Dict[str, Any]):
else:
logger.error(f"Unknown config key: '{key}', skipping")
- def save(self, file):
+ def save(self):
+ if self._write_disabled:
+ logger.error("Write disabled, this is probably because it will overwrite an outdated config.")
+ return
+
+ with open("config.json", 'w') as file:
+ self.save_to_file_object(file)
+
+ def save_to_file_object(self, file):
""" Save config file
Only changed variables will be included in the saved file
@@ -89,7 +101,13 @@ def save(self, file):
json.dump(output_data, file)
- def load(self, file):
+ def load(self):
+ filename = "config.json"
+ if os.path.exists(filename):
+ with open("config.json", 'r') as file:
+ self.load_from_file_object(file)
+
+ def load_from_file_object(self, file):
""" Load config file """
data = json.load(file)
@@ -119,6 +137,7 @@ def load(self, file):
if int(file_major_version) != int(sasview_major_version):
logger.warning(f"Attempting to used outdated config file (config is"
f" for {file_version}, this SasView version is {sas.__version__})")
+ self._write_disabled = True
self.update(data["config_data"])
diff --git a/src/sas/qtgui/MainWindow/GuiManager.py b/src/sas/qtgui/MainWindow/GuiManager.py
index a2ecba6ce1..0360d522f7 100644
--- a/src/sas/qtgui/MainWindow/GuiManager.py
+++ b/src/sas/qtgui/MainWindow/GuiManager.py
@@ -1300,10 +1300,7 @@ def saveCustomConfig(self):
"""
Save the config file based on current session values
"""
- # TODO: Decide what to do with config locations
- logger.warning("Config paths have not yet been set up")
- with open("config.json", 'w') as file:
- config.save(file)
+ config.save()
def customSavePaths(self, config_content):
"""
diff --git a/test/config/utest_config.py b/test/config/utest_config.py
index b02d72f94b..5be7a5ec45 100644
--- a/test/config/utest_config.py
+++ b/test/config/utest_config.py
@@ -133,7 +133,7 @@ def test_save_basics(self):
# Check saving with no changes, should be empty and
config = Config()
- config.save(file)
+ config.save_to_file_object(file)
file.seek(0)
@@ -156,7 +156,7 @@ def test_save_changes(self):
file = StringIO()
config = Config()
config.update({key: test_dict[key]})
- config.save(file)
+ config.save_to_file_object(file)
file.seek(0)
observed = json.load(file)
@@ -189,7 +189,7 @@ def test_only_save_actual_changes(self):
config.update({key: test_dict[key]})
config.update({key: getattr(backup, key)})
- config.save(file)
+ config.save_to_file_object(file)
file.seek(0)
observed = json.load(file)
@@ -211,7 +211,7 @@ def test_bad_config_version(self):
with self.assertLogs('sas.config_system', level="WARN") as cm:
# Try the bad value
- config.load(file)
+ config.load_from_file_object(file)
self.assertTrue(cm.output[0].startswith("WARNING:sas.config_system:"))
From 85b300e01a9cc687a25aef9d784c27a5f25b6613 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Mon, 12 Sep 2022 16:43:08 +0100
Subject: [PATCH 34/82] Removed some more things
---
src/sas/config_system/config.py | 5 -----
src/sas/qtgui/MainWindow/GuiManager.py | 1 +
2 files changed, 1 insertion(+), 5 deletions(-)
diff --git a/src/sas/config_system/config.py b/src/sas/config_system/config.py
index da9c975f2d..82eeacec79 100644
--- a/src/sas/config_system/config.py
+++ b/src/sas/config_system/config.py
@@ -158,11 +158,6 @@ def __init__(self):
self.__EVT_DEBUG_2_FILE__ = False
self.__EVT_DEBUG_FILENAME__ = "debug.log"
- # About box info
- self._do_aboutbox = True
- self._do_acknowledge = True
- self._do_tutorial = True
-
self.icon_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "images"))
# logging.info("icon path: %s" % icon_path)
self.media_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "media"))
diff --git a/src/sas/qtgui/MainWindow/GuiManager.py b/src/sas/qtgui/MainWindow/GuiManager.py
index 0360d522f7..e6c0ecd177 100644
--- a/src/sas/qtgui/MainWindow/GuiManager.py
+++ b/src/sas/qtgui/MainWindow/GuiManager.py
@@ -1317,6 +1317,7 @@ def customSavePaths(self, config_content):
changed = True
return changed
+
def customSaveOpenCL(self, config_content):
"""
Update the config module with current session OpenCL choice
From 72680b92f9125a2e030d6749354b35bcc64addcd Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Mon, 12 Sep 2022 17:03:32 +0100
Subject: [PATCH 35/82] GuiUtils now duplicates variables, removing some
---
run.py | 2 +-
src/sas/config_system/config.py | 15 ++++++---------
src/sas/qtgui/Utilities/GuiUtils.py | 16 +++-------------
3 files changed, 10 insertions(+), 23 deletions(-)
diff --git a/run.py b/run.py
index 11563f3c27..bc24a79b0c 100644
--- a/run.py
+++ b/run.py
@@ -122,7 +122,7 @@ def prepare():
root = abspath(dirname(realpath(sys.argv[0])))
addpath(joinpath(root, 'src'))
- addpath(joinpath(root, joinpath('..', 'sasmodels'))) # dependency (for loading custom_config.py during log setup)
+ # addpath(joinpath(root, joinpath('..', 'sasmodels'))) # dependency (for loading custom_config.py during log setup)
#from sas.logger_config import SetupLogger
#logger = SetupLogger(__name__).config_development()
diff --git a/src/sas/config_system/config.py b/src/sas/config_system/config.py
index 82eeacec79..9887c2d54f 100644
--- a/src/sas/config_system/config.py
+++ b/src/sas/config_system/config.py
@@ -163,20 +163,18 @@ def __init__(self):
self.media_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "media"))
self.test_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "test"))
-
- self._corner_image = os.path.join(self.icon_path, "angles_flat.png")
- self._welcome_image = os.path.join(self.icon_path, "SVwelcome.png")
-
# edit the list of file state your plugin can read
self.APPLICATION_WLIST = 'SasView files (*.svs)|*.svs'
self.APPLICATION_STATE_EXTENSION = '.svs'
self.GUIFRAME_WIDTH = 1150
self.GUIFRAME_HEIGHT = 840
self.PLUGIN_STATE_EXTENSIONS = ['.fitv', '.inv', '.prv', '.crf']
- self.PLUGINS_WLIST = ['Fitting files (*.fitv)|*.fitv',
- 'Invariant files (*.inv)|*.inv',
- 'P(r) files (*.prv)|*.prv',
- 'Corfunc files (*.crf)|*.crf']
+ self.PLUGINS_WLIST = [
+ 'Fitting files (*.fitv)|*.fitv',
+ 'Invariant files (*.inv)|*.inv',
+ 'P(r) files (*.prv)|*.prv',
+ 'Corfunc files (*.crf)|*.crf']
+
self.PLOPANEL_WIDTH = 415
self.PLOPANEL_HEIGTH = 370
self.DATAPANEL_WIDTH = 235
@@ -184,7 +182,6 @@ def __init__(self):
self.SPLASH_SCREEN_PATH = os.path.join(self.icon_path, "SVwelcome_mini.png")
self.TUTORIAL_PATH = os.path.join(self.media_path, "Tutorial.pdf")
- self.DEFAULT_STYLE = 64
self.SPLASH_SCREEN_WIDTH = 512
self.SPLASH_SCREEN_HEIGHT = 366
diff --git a/src/sas/qtgui/Utilities/GuiUtils.py b/src/sas/qtgui/Utilities/GuiUtils.py
index 8b1c64ff84..3360c0791f 100644
--- a/src/sas/qtgui/Utilities/GuiUtils.py
+++ b/src/sas/qtgui/Utilities/GuiUtils.py
@@ -137,24 +137,14 @@ def _find_local_config(confg_file, path):
#read some constants from config
-APPLICATION_STATE_EXTENSION = config.APPLICATION_STATE_EXTENSION
-APPLICATION_NAME = config.__appname__
-SPLASH_SCREEN_PATH = config.SPLASH_SCREEN_PATH
-WELCOME_PANEL_ON = config.WELCOME_PANEL_ON
SPLASH_SCREEN_WIDTH = config.SPLASH_SCREEN_WIDTH
SPLASH_SCREEN_HEIGHT = config.SPLASH_SCREEN_HEIGHT
SS_MAX_DISPLAY_TIME = config.SS_MAX_DISPLAY_TIME
-if not WELCOME_PANEL_ON:
- WELCOME_PANEL_SHOW = False
-else:
- WELCOME_PANEL_SHOW = True
-
DATALOADER_SHOW = config.DATALOADER_SHOW
TOOLBAR_SHOW = config.TOOLBAR_SHOW
FIXED_PANEL = config.FIXED_PANEL
-if WELCOME_PANEL_ON:
- WELCOME_PANEL_SHOW = config.WELCOME_PANEL_SHOW
+
PLOPANEL_WIDTH = config.PLOPANEL_WIDTH
DATAPANEL_WIDTH = config.DATAPANEL_WIDTH
GUIFRAME_WIDTH = config.GUIFRAME_WIDTH
@@ -179,8 +169,8 @@ def _find_local_config(confg_file, path):
VIEW_MENU = config.VIEW_MENU
EDIT_MENU = config.EDIT_MENU
extension_list = []
-if APPLICATION_STATE_EXTENSION is not None:
- extension_list.append(APPLICATION_STATE_EXTENSION)
+if config.APPLICATION_STATE_EXTENSION is not None:
+ extension_list.append(config.APPLICATION_STATE_EXTENSION)
EXTENSIONS = PLUGIN_STATE_EXTENSIONS + extension_list
try:
PLUGINS_WLIST = '|'.join(config.PLUGINS_WLIST)
From de53a085673170693f380c467022445feb0295c8 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Mon, 12 Sep 2022 17:05:59 +0100
Subject: [PATCH 36/82] Removed unused splash screen params from GuiUtils
---
src/sas/qtgui/Utilities/GuiUtils.py | 3 ---
1 file changed, 3 deletions(-)
diff --git a/src/sas/qtgui/Utilities/GuiUtils.py b/src/sas/qtgui/Utilities/GuiUtils.py
index 3360c0791f..6f1660ff9b 100644
--- a/src/sas/qtgui/Utilities/GuiUtils.py
+++ b/src/sas/qtgui/Utilities/GuiUtils.py
@@ -137,9 +137,6 @@ def _find_local_config(confg_file, path):
#read some constants from config
-SPLASH_SCREEN_WIDTH = config.SPLASH_SCREEN_WIDTH
-SPLASH_SCREEN_HEIGHT = config.SPLASH_SCREEN_HEIGHT
-SS_MAX_DISPLAY_TIME = config.SS_MAX_DISPLAY_TIME
DATALOADER_SHOW = config.DATALOADER_SHOW
TOOLBAR_SHOW = config.TOOLBAR_SHOW
From 4ad188f0330c71a2f98bef8672e8b01a2cd84450 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Mon, 12 Sep 2022 17:06:55 +0100
Subject: [PATCH 37/82] Removed more GuiUtil duplicates
---
src/sas/qtgui/Utilities/GuiUtils.py | 4 ----
1 file changed, 4 deletions(-)
diff --git a/src/sas/qtgui/Utilities/GuiUtils.py b/src/sas/qtgui/Utilities/GuiUtils.py
index 6f1660ff9b..f9ead8e9ae 100644
--- a/src/sas/qtgui/Utilities/GuiUtils.py
+++ b/src/sas/qtgui/Utilities/GuiUtils.py
@@ -138,10 +138,6 @@ def _find_local_config(confg_file, path):
#read some constants from config
-DATALOADER_SHOW = config.DATALOADER_SHOW
-TOOLBAR_SHOW = config.TOOLBAR_SHOW
-FIXED_PANEL = config.FIXED_PANEL
-
PLOPANEL_WIDTH = config.PLOPANEL_WIDTH
DATAPANEL_WIDTH = config.DATAPANEL_WIDTH
GUIFRAME_WIDTH = config.GUIFRAME_WIDTH
From 533d08f7fe65d7b5d26b06c1f04235b1cb525609 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Mon, 12 Sep 2022 17:12:09 +0100
Subject: [PATCH 38/82] Removed more unused variables from GuiUtils
---
src/sas/qtgui/Utilities/GuiUtils.py | 8 --------
1 file changed, 8 deletions(-)
diff --git a/src/sas/qtgui/Utilities/GuiUtils.py b/src/sas/qtgui/Utilities/GuiUtils.py
index f9ead8e9ae..da18a9d395 100644
--- a/src/sas/qtgui/Utilities/GuiUtils.py
+++ b/src/sas/qtgui/Utilities/GuiUtils.py
@@ -138,14 +138,6 @@ def _find_local_config(confg_file, path):
#read some constants from config
-PLOPANEL_WIDTH = config.PLOPANEL_WIDTH
-DATAPANEL_WIDTH = config.DATAPANEL_WIDTH
-GUIFRAME_WIDTH = config.GUIFRAME_WIDTH
-GUIFRAME_HEIGHT = config.GUIFRAME_HEIGHT
-CONTROL_WIDTH = config.CONTROL_WIDTH
-CONTROL_HEIGHT = config.CONTROL_HEIGHT
-DEFAULT_PERSPECTIVE = config.DEFAULT_PERSPECTIVE
-CLEANUP_PLOT = config.CLEANUP_PLOT
SAS_OPENCL = config.SAS_OPENCL
# custom open_path
open_folder = config.DEFAULT_OPEN_FOLDER
From 7f6d833cd14c60f23c6ecee4b26970a74f75de4a Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Mon, 12 Sep 2022 17:20:16 +0100
Subject: [PATCH 39/82] Removed more GuiUtil things, and some references to it
from DataExplorer
---
src/sas/config_system/config.py | 6 ++++++
src/sas/qtgui/MainWindow/DataExplorer.py | 17 +++++++----------
src/sas/qtgui/Utilities/GuiUtils.py | 3 +++
3 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/src/sas/config_system/config.py b/src/sas/config_system/config.py
index 9887c2d54f..cd3cb3002e 100644
--- a/src/sas/config_system/config.py
+++ b/src/sas/config_system/config.py
@@ -175,6 +175,12 @@ def __init__(self):
'P(r) files (*.prv)|*.prv',
'Corfunc files (*.crf)|*.crf']
+ self.ANALYSIS_TYPES = [
+ 'Fitting files (*.fitv)',
+ 'Invariant files (*.inv)',
+ 'P(r) files (*.prv)',
+ 'Corfunc files (*.crf)']
+
self.PLOPANEL_WIDTH = 415
self.PLOPANEL_HEIGTH = 370
self.DATAPANEL_WIDTH = 235
diff --git a/src/sas/qtgui/MainWindow/DataExplorer.py b/src/sas/qtgui/MainWindow/DataExplorer.py
index 69af555f34..d2b830116c 100644
--- a/src/sas/qtgui/MainWindow/DataExplorer.py
+++ b/src/sas/qtgui/MainWindow/DataExplorer.py
@@ -30,10 +30,7 @@
from sas.qtgui.MainWindow.NameChanger import ChangeName
import sas.qtgui.Perspectives as Perspectives
-
-DEFAULT_PERSPECTIVE = "Fitting"
-ANALYSIS_TYPES = ['Fitting (*.fitv)', 'Inversion (*.pr)', 'Invariant (*.inv)',
- 'Corfunc (*.crf)', 'All Files (*.*)']
+from sas import config
logger = logging.getLogger(__name__)
@@ -57,7 +54,7 @@ def __init__(self, parent=None, guimanager=None, manager=None):
# Read in default locations
self.default_save_location = None
- self.default_load_location = GuiUtils.DEFAULT_OPEN_FOLDER
+ self.default_load_location = config.DEFAULT_OPEN_FOLDER
self.default_project_location = None
self.manager = manager if manager is not None else DataManager()
@@ -196,7 +193,7 @@ def initPerspectives(self):
self.cbFitting.addItems(available_perspectives)
self.cbFitting.currentIndexChanged.connect(self.updatePerspectiveCombo)
# Set the index so we see the default (Fitting)
- self.cbFitting.setCurrentIndex(self.cbFitting.findText(DEFAULT_PERSPECTIVE))
+ self.cbFitting.setCurrentIndex(self.cbFitting.findText(config.DEFAULT_PERSPECTIVE))
def _perspective(self):
"""
@@ -290,7 +287,7 @@ def loadAnalysis(self):
"""
Called when the "Open Analysis" menu item chosen.
"""
- file_filter = ';;'.join(ANALYSIS_TYPES)
+ file_filter = ';;'.join(config.ANALYSIS_TYPES + ['All Files (*.*)'])
kwargs = {
'parent' : self,
'caption' : 'Open Analysis',
@@ -506,7 +503,7 @@ def readProject(self, filename):
logging.error("Project load failed with " + str(ex))
return
cs_keys = []
- visible_perspective = DEFAULT_PERSPECTIVE
+ visible_perspective = config.DEFAULT_PERSPECTIVE
for key, value in all_data.items():
if key == 'is_batch':
self.chkBatch.setChecked(value == 'True')
@@ -527,7 +524,7 @@ def readProject(self, filename):
self.updatePerspectiveWithProperties(key, value)
# Set to fitting perspective and load in Batch and C&S Pages
self.cbFitting.setCurrentIndex(
- self.cbFitting.findText(DEFAULT_PERSPECTIVE))
+ self.cbFitting.findText(config.DEFAULT_PERSPECTIVE))
# See if there are any batch pages defined and create them, if so
self.updateWithBatchPages(all_data)
# Get the constraint dict and apply it
@@ -581,7 +578,7 @@ def updatePerspectiveWithProperties(self, key, value):
items = self.updateModelFromData(data_dict)
if 'fit_params' in value:
- self.cbFitting.setCurrentIndex(self.cbFitting.findText(DEFAULT_PERSPECTIVE))
+ self.cbFitting.setCurrentIndex(self.cbFitting.findText(config.DEFAULT_PERSPECTIVE))
params = value['fit_params']
# Make the perspective read the rest of the read data
if not isinstance(params, list):
diff --git a/src/sas/qtgui/Utilities/GuiUtils.py b/src/sas/qtgui/Utilities/GuiUtils.py
index da18a9d395..4f6a690625 100644
--- a/src/sas/qtgui/Utilities/GuiUtils.py
+++ b/src/sas/qtgui/Utilities/GuiUtils.py
@@ -146,6 +146,9 @@ def _find_local_config(confg_file, path):
else:
DEFAULT_OPEN_FOLDER = PATH_APP
+if config.DEFAULT_OPEN_FOLDER != "":
+ config.DEFAULT_OPEN_FOLDER = PATH_APP
+
#DEFAULT_STYLE = config.DEFAULT_STYLE
From d9650e7d6fb8615482c666e24fa3f78764e5e91b Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Tue, 13 Sep 2022 09:35:42 +0100
Subject: [PATCH 40/82] Fixed test
---
test/config/utest_config.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/config/utest_config.py b/test/config/utest_config.py
index 5be7a5ec45..ecc03c624c 100644
--- a/test/config/utest_config.py
+++ b/test/config/utest_config.py
@@ -247,7 +247,7 @@ def test_bad_config_file_structure(self):
file.seek(0)
with self.assertRaises(MalformedFile):
- config.load(file)
+ config.load_from_file_object(file)
def test_schema_union(self):
From 97cd81dc63ec419f41d2a15d1150dcaeb991f800 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Tue, 13 Sep 2022 11:30:10 +0100
Subject: [PATCH 41/82] Deleted _config
---
src/sas/_config.py | 65 ----------------------------------------------
1 file changed, 65 deletions(-)
delete mode 100644 src/sas/_config.py
diff --git a/src/sas/_config.py b/src/sas/_config.py
deleted file mode 100644
index 99beda90e7..0000000000
--- a/src/sas/_config.py
+++ /dev/null
@@ -1,65 +0,0 @@
-# Setup and find Custom config dir
-from __future__ import print_function
-
-import sys
-import os
-from os.path import exists, expanduser, dirname, realpath, join as joinpath
-import logging
-import shutil
-
-from sasmodels.custom import load_module_from_path
-
-logger = logging.getLogger(__name__)
-
-# TODO: REMOVE
-def make_custom_config_path(user_dir):
- raise RuntimeError("Tried to run make_custom_config_path - this is now forbidden")
- # """
- # The location of the cusstom config file.
- #
- # Returns ~/.sasview/config/custom_config.py
- # """
- # dirname = os.path.join(user_dir, 'config')
- # # If the directory doesn't exist, create it
- # if not os.path.exists(dirname):
- # os.makedirs(dirname)
- # path = os.path.join(dirname, "custom_config.py")
- # return path
-
-def setup_custom_config(app_dir, user_dir):
- raise RuntimeError("Tried to run setup_custom_config - this is now forbidden")
-
- # path = make_custom_config_path(user_dir)
- # if not os.path.isfile(path):
- # try:
- # # if the custom config file does not exist, copy the default from
- # # the app dir
- # shutil.copyfile(os.path.join(app_dir, "custom_config.py"), path)
- # except Exception:
- # logger.error("Could not copy default custom config.")
- #
- # #Adding SAS_OPENCL if it doesn't exist in the config file
- # # - to support backcompability
- # if not "SAS_OPENCL" in open(path).read():
- # try:
- # open(path, "a+").write("SAS_OPENCL = \"None\"\n")
- # except Exception:
- # logger.error("Could not update custom config with SAS_OPENCL.")
- #
- # custom_config = load_custom_config(path)
- # return custom_config
-
-
-def load_custom_config(path):
- raise RuntimeError("Tried to call load_custom_config - this is now forbidden")
- # if os.path.exists(path):
- # try:
- # module = load_module_from_path('sas.custom_config', path)
- # #logger.info("GuiManager loaded %s", path)
- # return module
- # except Exception as exc:
- # logger.error("Error loading %s: %s", path, exc)
- #
- # from sas.sasview import custom_config
- # logger.info("GuiManager custom_config defaults to sas.sasview.custom_config")
- # return custom_config
\ No newline at end of file
From 19af85e2c9a78eba30967a6d2ad36ea80e9dc8af Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Tue, 13 Sep 2022 11:34:39 +0100
Subject: [PATCH 42/82] Removed unused config variables
---
src/sas/config_system/config.py | 17 ++---------------
src/sas/qtgui/MainWindow/GuiManager.py | 2 +-
2 files changed, 3 insertions(+), 16 deletions(-)
diff --git a/src/sas/config_system/config.py b/src/sas/config_system/config.py
index cd3cb3002e..8e0fe9bf5a 100644
--- a/src/sas/config_system/config.py
+++ b/src/sas/config_system/config.py
@@ -189,12 +189,7 @@ def __init__(self):
self.TUTORIAL_PATH = os.path.join(self.media_path, "Tutorial.pdf")
- self.SPLASH_SCREEN_WIDTH = 512
- self.SPLASH_SCREEN_HEIGHT = 366
- self.SS_MAX_DISPLAY_TIME = 2000
- self.WELCOME_PANEL_ON = True
- self.WELCOME_PANEL_SHOW = False
- self.CLEANUP_PLOT = False
+ self.SHOW_WELCOME_PANEL = False
# OPEN and SAVE project menu
self.OPEN_SAVE_PROJECT_MENU = True
# VIEW MENU
@@ -202,15 +197,9 @@ def __init__(self):
# EDIT MENU
self.EDIT_MENU = True
- self.SetupIconFile_win = os.path.join(self.icon_path, "ball.ico")
- self.SetupIconFile_mac = os.path.join(self.icon_path, "ball.icns")
- self.DefaultGroupName = "."
- self.OutputBaseFilename = "setupSasView"
self.FIXED_PANEL = True
self.DATALOADER_SHOW = True
- self.CLEANUP_PLOT = False
- self.WELCOME_PANEL_SHOW = False
# Show or hide toolbar at the start up
self.TOOLBAR_SHOW = True
# set a default perspective
@@ -231,11 +220,9 @@ def __init__(self):
self.GUIFRAME_WIDTH = -1
self.CONTROL_WIDTH = -1
self.CONTROL_HEIGHT = -1
- self.DEFAULT_OPEN_FOLDER = None
- self.WELCOME_PANEL_SHOW = False
+ self.DEFAULT_OPEN_FOLDER = ""
self.TOOLBAR_SHOW = True
self.DEFAULT_PERSPECTIVE = "Fitting"
- self.SAS_OPENCL = "None"
# Logging options
self.FILTER_DEBUG_LOGS = True
diff --git a/src/sas/qtgui/MainWindow/GuiManager.py b/src/sas/qtgui/MainWindow/GuiManager.py
index e6c0ecd177..e711b7bc06 100644
--- a/src/sas/qtgui/MainWindow/GuiManager.py
+++ b/src/sas/qtgui/MainWindow/GuiManager.py
@@ -601,7 +601,7 @@ def showWelcomeMessage(self):
# Assure the welcome screen is requested
show_welcome_widget = True
- if config.WELCOME_PANEL_SHOW:
+ if config.SHOW_WELCOME_PANEL:
self.actionWelcome()
def addCallbacks(self):
From 36ed14da84bafd05dcb1da00d6f9bd75b94c18c1 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Tue, 13 Sep 2022 11:36:48 +0100
Subject: [PATCH 43/82] Removed more unused config items
---
src/sas/config_system/config.py | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/src/sas/config_system/config.py b/src/sas/config_system/config.py
index 8e0fe9bf5a..00bd6c5cf3 100644
--- a/src/sas/config_system/config.py
+++ b/src/sas/config_system/config.py
@@ -166,8 +166,6 @@ def __init__(self):
# edit the list of file state your plugin can read
self.APPLICATION_WLIST = 'SasView files (*.svs)|*.svs'
self.APPLICATION_STATE_EXTENSION = '.svs'
- self.GUIFRAME_WIDTH = 1150
- self.GUIFRAME_HEIGHT = 840
self.PLUGIN_STATE_EXTENSIONS = ['.fitv', '.inv', '.prv', '.crf']
self.PLUGINS_WLIST = [
'Fitting files (*.fitv)|*.fitv',
@@ -200,13 +198,7 @@ def __init__(self):
self.FIXED_PANEL = True
self.DATALOADER_SHOW = True
- # Show or hide toolbar at the start up
- self.TOOLBAR_SHOW = True
- # set a default perspective
- self.DEFAULT_PERSPECTIVE = 'None'
- # Time out for updating sasview
- self.UPDATE_TIMEOUT = 2
# OpenCL option
self.SAS_OPENCL = None
@@ -216,8 +208,6 @@ def __init__(self):
self.FIXED_PANEL = True
self.PLOPANEL_WIDTH = -1
self.DATALOADER_SHOW = True
- self.GUIFRAME_HEIGHT = -1
- self.GUIFRAME_WIDTH = -1
self.CONTROL_WIDTH = -1
self.CONTROL_HEIGHT = -1
self.DEFAULT_OPEN_FOLDER = ""
From 4b7ec882db69deab2127b8ece77637a38a769789 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Tue, 13 Sep 2022 11:37:30 +0100
Subject: [PATCH 44/82] Removed further config items
---
src/sas/config_system/config.py | 8 --------
1 file changed, 8 deletions(-)
diff --git a/src/sas/config_system/config.py b/src/sas/config_system/config.py
index 00bd6c5cf3..a900748b80 100644
--- a/src/sas/config_system/config.py
+++ b/src/sas/config_system/config.py
@@ -158,11 +158,6 @@ def __init__(self):
self.__EVT_DEBUG_2_FILE__ = False
self.__EVT_DEBUG_FILENAME__ = "debug.log"
- self.icon_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "images"))
- # logging.info("icon path: %s" % icon_path)
- self.media_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "media"))
- self.test_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "test"))
-
# edit the list of file state your plugin can read
self.APPLICATION_WLIST = 'SasView files (*.svs)|*.svs'
self.APPLICATION_STATE_EXTENSION = '.svs'
@@ -183,9 +178,6 @@ def __init__(self):
self.PLOPANEL_HEIGTH = 370
self.DATAPANEL_WIDTH = 235
self.DATAPANEL_HEIGHT = 700
- self.SPLASH_SCREEN_PATH = os.path.join(self.icon_path, "SVwelcome_mini.png")
- self.TUTORIAL_PATH = os.path.join(self.media_path, "Tutorial.pdf")
-
self.SHOW_WELCOME_PANEL = False
# OPEN and SAVE project menu
From 11a1ef2fb231d6b1c0b456bb998b63616f806dff Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Tue, 13 Sep 2022 16:38:37 +0100
Subject: [PATCH 45/82] Moved some packages, started on environment variable
interface
---
setup.py | 5 ++-
src/sas/__init__.py | 2 +-
src/sas/config_system/config.py | 16 +------
src/sas/qtgui/MainWindow/GuiManager.py | 32 --------------
src/sas/qtgui/MainWindow/MainWindow.py | 3 +-
.../qtgui/Perspectives/Fitting/GPUOptions.py | 3 ++
src/sas/system/environment.py | 42 +++++++++++++++++++
src/sas/{logging.ini => system/log.ini} | 0
src/sas/{logger_config.py => system/log.py} | 6 +--
src/sas/version.py | 5 ---
10 files changed, 55 insertions(+), 59 deletions(-)
create mode 100644 src/sas/system/environment.py
rename src/sas/{logging.ini => system/log.ini} (100%)
rename src/sas/{logger_config.py => system/log.py} (94%)
delete mode 100644 src/sas/version.py
diff --git a/setup.py b/setup.py
index 7ad66afad4..c841501d48 100644
--- a/setup.py
+++ b/setup.py
@@ -242,7 +242,6 @@ def run(self):
"sas.qtgui.Plotting.Slicers", "sas.qtgui.Plotting.Masks"])
# SasView
-package_data['sas'] = ['logging.ini']
package_data['sas.sasview'] = ['images/*',
'media/*']
@@ -260,6 +259,10 @@ def run(self):
'upcoming_formats/*',
]
packages.append("sas.sasview")
+
+package_data["sas.system"] = ["*"]
+packages.append("sas.system")
+
package_data['sas.qtgui'] = ['Calculators/UI/*',
'MainWindow/UI/*',
'Perspectives/Corfunc/UI/*',
diff --git a/src/sas/__init__.py b/src/sas/__init__.py
index a41c7ecb5f..2d8785e921 100644
--- a/src/sas/__init__.py
+++ b/src/sas/__init__.py
@@ -1,10 +1,10 @@
-from sas.version import __version__
import os
import sys
from sas.config_system import configuration as config
__all__ = ['get_app_dir', 'get_user_dir', 'config']
+__version__ = "5.0.5"
# Load the config file
config.load()
diff --git a/src/sas/config_system/config.py b/src/sas/config_system/config.py
index a900748b80..b75252eebc 100644
--- a/src/sas/config_system/config.py
+++ b/src/sas/config_system/config.py
@@ -174,11 +174,6 @@ def __init__(self):
'P(r) files (*.prv)',
'Corfunc files (*.crf)']
- self.PLOPANEL_WIDTH = 415
- self.PLOPANEL_HEIGTH = 370
- self.DATAPANEL_WIDTH = 235
- self.DATAPANEL_HEIGHT = 700
-
self.SHOW_WELCOME_PANEL = False
# OPEN and SAVE project menu
self.OPEN_SAVE_PROJECT_MENU = True
@@ -188,23 +183,14 @@ def __init__(self):
self.EDIT_MENU = True
- self.FIXED_PANEL = True
- self.DATALOADER_SHOW = True
-
# OpenCL option
self.SAS_OPENCL = None
- self.DATAPANEL_WIDTH = -1
- self.CLEANUP_PLOT = False
- self.FIXED_PANEL = True
- self.PLOPANEL_WIDTH = -1
- self.DATALOADER_SHOW = True
- self.CONTROL_WIDTH = -1
- self.CONTROL_HEIGHT = -1
self.DEFAULT_OPEN_FOLDER = ""
self.TOOLBAR_SHOW = True
self.DEFAULT_PERSPECTIVE = "Fitting"
+ # self.DEFAULT_PERSPECTIVE = "Corfunc"
# Logging options
self.FILTER_DEBUG_LOGS = True
diff --git a/src/sas/qtgui/MainWindow/GuiManager.py b/src/sas/qtgui/MainWindow/GuiManager.py
index e711b7bc06..d6ce27b609 100644
--- a/src/sas/qtgui/MainWindow/GuiManager.py
+++ b/src/sas/qtgui/MainWindow/GuiManager.py
@@ -1301,35 +1301,3 @@ def saveCustomConfig(self):
Save the config file based on current session values
"""
config.save()
-
- def customSavePaths(self, config_content):
- """
- Update the config module with current session paths
- Returns True if update was done, False, otherwise
- """
- changed = False
- # Find load path
- open_path = GuiUtils.DEFAULT_OPEN_FOLDER
- defined_path = self.filesWidget.default_load_location
- if open_path != defined_path:
- # Replace the load path
- config_content.DEFAULT_OPEN_FOLDER = defined_path
- changed = True
- return changed
-
-
- def customSaveOpenCL(self, config_content):
- """
- Update the config module with current session OpenCL choice
- Returns True if update was done, False, otherwise
- """
- changed = False
- # Find load path
- file_value = GuiUtils.SAS_OPENCL
- session_value = os.environ.get("SAS_OPENCL", "")
- if file_value != session_value:
- # Replace the load path
- config_content.SAS_OPENCL = session_value
- changed = True
- return changed
-
diff --git a/src/sas/qtgui/MainWindow/MainWindow.py b/src/sas/qtgui/MainWindow/MainWindow.py
index ba4cb1d321..92fcbe3879 100644
--- a/src/sas/qtgui/MainWindow/MainWindow.py
+++ b/src/sas/qtgui/MainWindow/MainWindow.py
@@ -13,7 +13,6 @@
from PyQt5.QtCore import Qt
# Local UI
-from sas.qtgui.UI import main_resources_rc
from .UI.MainWindowUI import Ui_SasView
class MainSasViewWindow(QMainWindow, Ui_SasView):
@@ -71,7 +70,7 @@ def run_sasview():
app = QApplication([])
#Initialize logger
- from sas.logger_config import SetupLogger
+ from sas.system.log import SetupLogger
SetupLogger(__name__).config_development()
# initialize sasmodels settings
diff --git a/src/sas/qtgui/Perspectives/Fitting/GPUOptions.py b/src/sas/qtgui/Perspectives/Fitting/GPUOptions.py
index 4b1fe584a9..8bd9a41bb5 100644
--- a/src/sas/qtgui/Perspectives/Fitting/GPUOptions.py
+++ b/src/sas/qtgui/Perspectives/Fitting/GPUOptions.py
@@ -108,6 +108,9 @@ def checked(self):
else:
self.sas_open_cl = None
+ logger.info(self.sas_open_cl)
+ print(self.sas_open_cl)
+
def set_sas_open_cl(self):
"""
Set SAS_OPENCL value when tests run or OK button clicked
diff --git a/src/sas/system/environment.py b/src/sas/system/environment.py
new file mode 100644
index 0000000000..9fa9d5d7c4
--- /dev/null
+++ b/src/sas/system/environment.py
@@ -0,0 +1,42 @@
+""" Interface for environmental variable access,
+
+This is intended to handle any conversion from the environment variable string to more natural types.
+"""
+import os
+import logging
+
+class Envrironment:
+
+ logger = logging.getLogger(__name__)
+
+ @property
+ def sas_opencl(self) -> int:
+ """
+ Get the value of the environment variable SAS_OPENCL, which specifies which OpenCL device
+ should be used.
+
+ FAQ: Why use -1 to represent the no-device state, rather than None? Isn't None a better choice?
+ Ans: This helps keep the config files in order (see docs on that), as the type of -1 (the default)
+ can be inferred and checked online.
+
+ """
+
+ string_value = os.environ.get("SAS_OPENCL", "None")
+ if string_value.lower() == "none":
+ return -1
+ else:
+ try:
+ int_value = int(string_value)
+ return int_value
+ except ValueError:
+ self.logger.warning(
+ f"Failed to parse SAS_OPENCL environment variable, expected an integer or 'none', got {string_value}")
+ return -1
+
+ @sas_opencl.setter
+ def sas_opencl(self, value: int):
+ """
+ Set the value of the environment variable SAS_OPENCL
+ """
+
+ os.environ["SAS_OPENCL"] = str(value)
diff --git a/src/sas/logging.ini b/src/sas/system/log.ini
similarity index 100%
rename from src/sas/logging.ini
rename to src/sas/system/log.ini
diff --git a/src/sas/logger_config.py b/src/sas/system/log.py
similarity index 94%
rename from src/sas/logger_config.py
rename to src/sas/system/log.py
index de2f2ad73e..bd923d2856 100644
--- a/src/sas/logger_config.py
+++ b/src/sas/system/log.py
@@ -62,7 +62,7 @@ def _update_all_logs_to_debug(self, logger):
for name, _ in logging.Logger.manager.loggerDict.items():
logging.getLogger(name).setLevel(logging.DEBUG)
- def _find_config_file(self, filename="logging.ini"):
+ def _find_config_file(self, filename="log.ini"):
'''
The config file is in:
Debug ./sasview/
@@ -73,8 +73,8 @@ def _find_config_file(self, filename="logging.ini"):
places_to_look_for_conf_file = [
os.path.join(os.path.abspath(os.path.dirname(__file__)), filename),
filename,
- os.path.join("sas", "sasview", filename),
- os.path.join(os.getcwd(), "sas", "sasview", filename),
+ os.path.join("sas", "system", filename),
+ os.path.join(os.getcwd(), "sas", "system", filename),
os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), filename) #For OSX app
]
diff --git a/src/sas/version.py b/src/sas/version.py
deleted file mode 100644
index 024bb246f3..0000000000
--- a/src/sas/version.py
+++ /dev/null
@@ -1,5 +0,0 @@
-""" This file is just for containing the version number, nothing else
-
-It is imported by sas.__init__ so that sas.__version__ exists too"""
-
-__version__ = "5.0.5"
\ No newline at end of file
From 3a755d004e96658b9fe74df1f3d21ac21394de72 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Wed, 14 Sep 2022 10:38:31 +0100
Subject: [PATCH 46/82] Updated config variables
---
run.py | 43 ++++---------------
.../qtgui/Perspectives/Fitting/GPUOptions.py | 26 +++++------
src/sas/system/__init__.py | 3 +-
src/sas/system/{environment.py => env.py} | 7 ++-
4 files changed, 27 insertions(+), 52 deletions(-)
rename src/sas/system/{environment.py => env.py} (89%)
diff --git a/run.py b/run.py
index bc24a79b0c..ed37b2ef6c 100644
--- a/run.py
+++ b/run.py
@@ -59,9 +59,6 @@ def prepare():
# Don't create *.pyc files
sys.dont_write_bytecode = True
- # Debug numpy warnings
- #import numpy; numpy.seterr(all='raise')
-
# find the directories for the source and build
from distutils.util import get_platform
root = abspath(dirname(realpath(__file__)))
@@ -73,15 +70,6 @@ def prepare():
# place than it otherwise would be.
os.environ['SASVIEW_DOC_PATH'] = joinpath(build_path, "doc")
- # Make sure that we have a private version of mplconfig
- #mplconfig = joinpath(abspath(dirname(__file__)), '.mplconfig')
- #os.environ['MPLCONFIGDIR'] = mplconfig
- #if not os.path.exists(mplconfig): os.mkdir(mplconfig)
- #import matplotlib
- # matplotlib.use('Agg')
- # print matplotlib.__file__
- #import pylab; pylab.hold(False)
- # add periodictable to the path
try:
import periodictable
except ImportError:
@@ -92,28 +80,20 @@ def prepare():
except ImportError:
addpath(joinpath(root, '..', 'bumps'))
- # == no more C sources so no need to build project to run it ==
- ## Build project if the build directory does not already exist.
- #if not os.path.exists(build_path):
- # import subprocess
- # with cd(root):
- # subprocess.call((sys.executable, "setup.py", "build"), shell=False)
-
# Put the source trees on the path
addpath(joinpath(root, 'src'))
# sasmodels on the path
addpath(joinpath(root, '../sasmodels/'))
- # Note: only needed when running gui so suppress for now.
- ## Run the UI conversion tool.
- #import sas.qtgui.convertUI
-
- # initialize OpenCL setting
- import sas
- SAS_OPENCL = sas.config.SAS_OPENCL
- if SAS_OPENCL and "SAS_OPENCL" not in os.environ:
- os.environ["SAS_OPENCL"] = SAS_OPENCL
+ # If the SAS_OPENCL environment setting is set, set the config from it
+ # if it isn't set, set it from the config
+ from sas import config
+ from sas.system import env
+ if "SAS_OPENCL" in os.environ:
+ config.SAS_OPENCL = env.sas_opencl
+ else:
+ env.sas_opencl = config.SAS_OPENCL
if __name__ == "__main__":
@@ -122,13 +102,8 @@ def prepare():
root = abspath(dirname(realpath(sys.argv[0])))
addpath(joinpath(root, 'src'))
- # addpath(joinpath(root, joinpath('..', 'sasmodels'))) # dependency (for loading custom_config.py during log setup)
-
- #from sas.logger_config import SetupLogger
- #logger = SetupLogger(__name__).config_development()
-
- #logger.debug("Starting SASVIEW in debug mode.")
prepare()
+
# Run the UI conversion tool when executed from script. This has to
# happen after prepare() so that sas.qtgui is on the path.
import sas.qtgui.convertUI
diff --git a/src/sas/qtgui/Perspectives/Fitting/GPUOptions.py b/src/sas/qtgui/Perspectives/Fitting/GPUOptions.py
index 8bd9a41bb5..be323658d5 100644
--- a/src/sas/qtgui/Perspectives/Fitting/GPUOptions.py
+++ b/src/sas/qtgui/Perspectives/Fitting/GPUOptions.py
@@ -18,6 +18,9 @@
from sas.qtgui.Perspectives.Fitting.UI.GPUOptionsUI import Ui_GPUOptions
from sas.qtgui.Perspectives.Fitting.UI.GPUTestResultsUI import Ui_GPUTestResults
+from sas.system import env
+from sas import config
+
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
@@ -64,10 +67,10 @@ def addOpenCLOptions(self):
"""
# Get list of openCL options and add to GUI
cl_tuple = _get_clinfo()
- self.sas_open_cl = os.environ.get("SAS_OPENCL", "")
+ self.sas_open_cl = config.sas_opencl
# Keys are the names in the form "platform: device". Corresponding values are the combined indices, e.g.
- # "0:1", for setting the SAS_OPENCL env.
+ # "0:1", for setting the SAS_OPENCL env. TODO This appears not to be the case
self.cl_options = {}
for title, descr in cl_tuple:
@@ -76,8 +79,7 @@ def addOpenCLOptions(self):
check_box.setObjectName(_fromUtf8(descr))
check_box.setText(_translate("GPUOptions", descr, None))
self.optionsLayout.addWidget(check_box)
- if (title == self.sas_open_cl) or (
- title == "None" and not self.clicked):
+ if (title == self.sas_open_cl) or (title == "None" and not self.clicked):
check_box.click()
self.clicked = True
self.cl_options[descr] = title
@@ -106,23 +108,15 @@ def checked(self):
if hasattr(checked, "text"):
self.sas_open_cl = self.cl_options[str(checked.text())]
else:
- self.sas_open_cl = None
-
- logger.info(self.sas_open_cl)
- print(self.sas_open_cl)
+ self.sas_open_cl = -1
def set_sas_open_cl(self):
"""
Set SAS_OPENCL value when tests run or OK button clicked
"""
- no_opencl_msg = False
- if self.sas_open_cl:
- os.environ["SAS_OPENCL"] = self.sas_open_cl
- if self.sas_open_cl.lower() == "none":
- no_opencl_msg = True
- else:
- if "SAS_OPENCL" in os.environ:
- del os.environ["SAS_OPENCL"]
+ no_opencl_msg = self.sas_open_cl == -1
+ env.sas_opencl = self.sas_open_cl
+
# CRUFT: next version of reset_environment() will return env
sasmodels.sasview_model.reset_environment()
return no_opencl_msg
diff --git a/src/sas/system/__init__.py b/src/sas/system/__init__.py
index ecca45334f..c4b441ad04 100644
--- a/src/sas/system/__init__.py
+++ b/src/sas/system/__init__.py
@@ -1,4 +1,5 @@
from .web import web
from .legal import legal
+from .env import env
-__all__ = ["web", "legal"]
\ No newline at end of file
+__all__ = ["web", "legal", "env"]
\ No newline at end of file
diff --git a/src/sas/system/environment.py b/src/sas/system/env.py
similarity index 89%
rename from src/sas/system/environment.py
rename to src/sas/system/env.py
index 9fa9d5d7c4..fe591e8d98 100644
--- a/src/sas/system/environment.py
+++ b/src/sas/system/env.py
@@ -39,4 +39,9 @@ def sas_opencl(self, value: int):
Set the value of the environment variable SAS_OPENCL
"""
- os.environ["SAS_OPENCL"] = str(value)
+ if value == -1:
+ del os.environ["SAS_OPENCL"]
+ else:
+ os.environ["SAS_OPENCL"] = str(value)
+
+env = Envrironment()
\ No newline at end of file
From fe81a7f99fc695b371ec51ab10e93244f3bbd46f Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Wed, 14 Sep 2022 10:54:46 +0100
Subject: [PATCH 47/82] Removing old config, adjusting CL state representation
---
src/sas/__init__.py | 2 +-
src/sas/config_system/config.py | 12 ------------
src/sas/qtgui/MainWindow/AboutBox.py | 2 +-
src/sas/qtgui/MainWindow/GuiManager.py | 4 ++--
src/sas/qtgui/MainWindow/PackageGatherer.py | 2 +-
src/sas/qtgui/MainWindow/UnitTesting/AboutBoxTest.py | 5 +++--
src/sas/system/env.py | 2 +-
src/sas/system/log.py | 2 +-
8 files changed, 10 insertions(+), 21 deletions(-)
diff --git a/src/sas/__init__.py b/src/sas/__init__.py
index 2d8785e921..575abfd44e 100644
--- a/src/sas/__init__.py
+++ b/src/sas/__init__.py
@@ -1,10 +1,10 @@
+from sas.sasview import __version__
import os
import sys
from sas.config_system import configuration as config
__all__ = ['get_app_dir', 'get_user_dir', 'config']
-__version__ = "5.0.5"
# Load the config file
config.load()
diff --git a/src/sas/config_system/config.py b/src/sas/config_system/config.py
index b75252eebc..ad38f79a06 100644
--- a/src/sas/config_system/config.py
+++ b/src/sas/config_system/config.py
@@ -143,21 +143,9 @@ class Config(ConfigBase, metaclass=ConfigMeta):
def __init__(self):
super().__init__()
- # Version of the application
- self.__appname__ = "SasView"
- self.__version__ = sas.sasview.__version__
- self.__build__ = sas.sasview.__build__
-
- # Debug message flag
- self.__EVT_DEBUG__ = False
-
# Flag for automated testing
self.__TEST__ = False
- # Debug message should be written to a file?
- self.__EVT_DEBUG_2_FILE__ = False
- self.__EVT_DEBUG_FILENAME__ = "debug.log"
-
# edit the list of file state your plugin can read
self.APPLICATION_WLIST = 'SasView files (*.svs)|*.svs'
self.APPLICATION_STATE_EXTENSION = '.svs'
diff --git a/src/sas/qtgui/MainWindow/AboutBox.py b/src/sas/qtgui/MainWindow/AboutBox.py
index 117d1f7f0f..f5378e9ad6 100644
--- a/src/sas/qtgui/MainWindow/AboutBox.py
+++ b/src/sas/qtgui/MainWindow/AboutBox.py
@@ -40,7 +40,7 @@ def addText(self):
- Build{config.__build__}
+ Build{sas.sasview.__build__}
{legal.copyright}
diff --git a/src/sas/qtgui/MainWindow/GuiManager.py b/src/sas/qtgui/MainWindow/GuiManager.py
index d6ce27b609..5960dee42c 100644
--- a/src/sas/qtgui/MainWindow/GuiManager.py
+++ b/src/sas/qtgui/MainWindow/GuiManager.py
@@ -65,6 +65,7 @@
from sas.qtgui.Utilities.ImageViewer import ImageViewer
from sas.qtgui.Utilities.FileConverter import FileConverterWidget
+import sas
from sas import config
from sas.system import web
@@ -571,7 +572,7 @@ def processVersion(self, version_info):
msg += " Please try again later."
self.communicate.statusBarUpdateSignal.emit(msg)
- elif version.__gt__(config.__version__):
+ elif version.__gt__(sas.__version__):
msg = "Version %s is available! " % str(version)
if "download_url" in version_info:
webbrowser.open(version_info["download_url"])
@@ -580,7 +581,6 @@ def processVersion(self, version_info):
self.communicate.statusBarUpdateSignal.emit(msg)
else:
msg = "You have the latest version"
- msg += " of %s" % str(config.__appname__)
self.communicate.statusBarUpdateSignal.emit(msg)
except:
msg = "guiframe: could not get latest application"
diff --git a/src/sas/qtgui/MainWindow/PackageGatherer.py b/src/sas/qtgui/MainWindow/PackageGatherer.py
index d6a447706d..e3bb4bdc04 100644
--- a/src/sas/qtgui/MainWindow/PackageGatherer.py
+++ b/src/sas/qtgui/MainWindow/PackageGatherer.py
@@ -69,7 +69,7 @@ def get_imported_packages(self):
:returns: A dictionary with the package names as the key, with their respective version numbers as the value.
:rtype: dict
"""
- package_versions_dict = {'python': sys.version, 'SasView': sas.sasview.__version__}
+ package_versions_dict = {'python': sys.version, 'SasView': sas.__version__}
err_version_dict = {}
no_version_list = []
# Generate a list of standard modules by looking at the local python library
diff --git a/src/sas/qtgui/MainWindow/UnitTesting/AboutBoxTest.py b/src/sas/qtgui/MainWindow/UnitTesting/AboutBoxTest.py
index 42c51a5860..dc7ec47aef 100644
--- a/src/sas/qtgui/MainWindow/UnitTesting/AboutBoxTest.py
+++ b/src/sas/qtgui/MainWindow/UnitTesting/AboutBoxTest.py
@@ -7,6 +7,7 @@
from PyQt5 import QtCore
from unittest.mock import MagicMock
+import sas.sasview
from sas import config
from sas.system import web, legal
@@ -44,7 +45,7 @@ def testVersion(self):
"""
version = self.widget.lblVersion
self.assertIsInstance(version, QtWidgets.QLabel)
- self.assertEqual(str(version.text()), str(config.__version__))
+ self.assertEqual(str(version.text()), str(sas.__version__))
def testAbout(self):
"""
@@ -53,7 +54,7 @@ def testAbout(self):
about = self.widget.lblAbout
self.assertIsInstance(about, QtWidgets.QLabel)
# build version
- self.assertIn(str(config.__build__), about.text())
+ self.assertIn(str(sas.sasview.__build__), about.text())
# License
self.assertIn(str(legal.copyright), about.text())
# URLs
diff --git a/src/sas/system/env.py b/src/sas/system/env.py
index fe591e8d98..4a8c4c5af6 100644
--- a/src/sas/system/env.py
+++ b/src/sas/system/env.py
@@ -1,4 +1,4 @@
-""" Interface for environmental variable access,
+""" Interface for environment variable access
This is intended to handle any conversion from the environment variable string to more natural types.
"""
diff --git a/src/sas/system/log.py b/src/sas/system/log.py
index bd923d2856..bfc4451220 100644
--- a/src/sas/system/log.py
+++ b/src/sas/system/log.py
@@ -90,5 +90,5 @@ def _find_config_file(self, filename="log.ini"):
if os.path.exists(filepath):
self.config_file = filepath
return
- print("ERROR: Logging.ini not found...")
+ print(f"'{filename}' not found.", file=sys.stderr)
self.config_file = None
From 8d91a0b011704c1eab869b5adbb599aa6dad70c9 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Wed, 14 Sep 2022 14:40:05 +0100
Subject: [PATCH 48/82] GPU settings updated
---
run.py | 8 --
src/sas/config_system/config.py | 4 +-
src/sas/qtgui/MainWindow/MainWindow.py | 16 +++-
.../qtgui/Perspectives/Fitting/GPUOptions.py | 74 +++++++++----------
src/sas/system/env.py | 29 ++------
5 files changed, 55 insertions(+), 76 deletions(-)
diff --git a/run.py b/run.py
index ed37b2ef6c..74a88afeeb 100644
--- a/run.py
+++ b/run.py
@@ -86,14 +86,6 @@ def prepare():
# sasmodels on the path
addpath(joinpath(root, '../sasmodels/'))
- # If the SAS_OPENCL environment setting is set, set the config from it
- # if it isn't set, set it from the config
- from sas import config
- from sas.system import env
- if "SAS_OPENCL" in os.environ:
- config.SAS_OPENCL = env.sas_opencl
- else:
- env.sas_opencl = config.SAS_OPENCL
if __name__ == "__main__":
diff --git a/src/sas/config_system/config.py b/src/sas/config_system/config.py
index ad38f79a06..b0a6acbf71 100644
--- a/src/sas/config_system/config.py
+++ b/src/sas/config_system/config.py
@@ -172,8 +172,8 @@ def __init__(self):
- # OpenCL option
- self.SAS_OPENCL = None
+ # OpenCL option - should be a string, either, "none", a number, or pair of form "A:B"
+ self.SAS_OPENCL = "none"
self.DEFAULT_OPEN_FOLDER = ""
self.TOOLBAR_SHOW = True
diff --git a/src/sas/qtgui/MainWindow/MainWindow.py b/src/sas/qtgui/MainWindow/MainWindow.py
index 92fcbe3879..dbc9672dc2 100644
--- a/src/sas/qtgui/MainWindow/MainWindow.py
+++ b/src/sas/qtgui/MainWindow/MainWindow.py
@@ -1,9 +1,12 @@
# UNLESS EXEPTIONALLY REQUIRED TRY TO AVOID IMPORTING ANY MODULES HERE
# ESPECIALLY ANYTHING IN SAS, SASMODELS NAMESPACE
+import logging
import os
import sys
from sas.sasview import __version__ as SASVIEW_VERSION
+from sas import config
+from sas.system import env
from PyQt5.QtWidgets import QMainWindow
from PyQt5.QtWidgets import QMdiArea
@@ -74,13 +77,18 @@ def run_sasview():
SetupLogger(__name__).config_development()
# initialize sasmodels settings
- from sas import config, get_user_dir
+ from sas import get_user_dir
if "SAS_DLL_PATH" not in os.environ:
os.environ["SAS_DLL_PATH"] = os.path.join(
get_user_dir(), "compiled_models")
- SAS_OPENCL = config.SAS_OPENCL
- if SAS_OPENCL and "SAS_OPENCL" not in os.environ:
- os.environ["SAS_OPENCL"] = SAS_OPENCL
+
+ # Set open cl config from environment variable, if it is set
+ if "SAS_OPENCL" in os.environ:
+ logging.getLogger(__name__).info("Getting OpenCL settings from environment variables")
+ config.SAS_OPENCL = env.sas_opencl
+ else:
+ logging.getLogger(__name__).info("Getting OpenCL settings from config")
+ env.sas_opencl = config.SAS_OPENCL
# Make the event loop interruptable quickly
import signal
diff --git a/src/sas/qtgui/Perspectives/Fitting/GPUOptions.py b/src/sas/qtgui/Perspectives/Fitting/GPUOptions.py
index be323658d5..8abd142ff4 100644
--- a/src/sas/qtgui/Perspectives/Fitting/GPUOptions.py
+++ b/src/sas/qtgui/Perspectives/Fitting/GPUOptions.py
@@ -42,8 +42,6 @@ class GPUOptions(QtWidgets.QDialog, Ui_GPUOptions):
OpenCL Dialog to select the desired OpenCL driver
"""
- clicked = False
- sas_open_cl = None
cl_options = None
testingDoneSignal = QtCore.pyqtSignal(str)
testingFailedSignal = QtCore.pyqtSignal(str)
@@ -52,70 +50,64 @@ def __init__(self, parent=None):
super(GPUOptions, self).__init__(parent)
self.parent = parent
self.setupUi(self)
+
+ self.radio_buttons = []
+
# disable the context help icon
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint)
- self.addOpenCLOptions()
+ self.add_options()
self.progressBar.setVisible(False)
self.progressBar.setFormat(" Test %v / %m")
- self.createLinks()
+
+ self.testButton.clicked.connect(self.testButtonClicked)
+ self.helpButton.clicked.connect(self.helpButtonClicked)
self.testingDoneSignal.connect(self.testCompleted)
self.testingFailedSignal.connect(self.testFailed)
- def addOpenCLOptions(self):
+
+ def add_options(self):
"""
Populate the window with a list of OpenCL options
"""
# Get list of openCL options and add to GUI
cl_tuple = _get_clinfo()
- self.sas_open_cl = config.sas_opencl
- # Keys are the names in the form "platform: device". Corresponding values are the combined indices, e.g.
- # "0:1", for setting the SAS_OPENCL env. TODO This appears not to be the case
self.cl_options = {}
+
for title, descr in cl_tuple:
+
# Create an item for each openCL option
- check_box = QtWidgets.QCheckBox()
- check_box.setObjectName(_fromUtf8(descr))
- check_box.setText(_translate("GPUOptions", descr, None))
- self.optionsLayout.addWidget(check_box)
- if (title == self.sas_open_cl) or (title == "None" and not self.clicked):
- check_box.click()
- self.clicked = True
+ radio_button = QtWidgets.QRadioButton()
+ radio_button.setObjectName(_fromUtf8(descr))
+ radio_button.setText(_translate("GPUOptions", descr, None))
+ self.optionsLayout.addWidget(radio_button)
+ if title.lower() == config.SAS_OPENCL.lower():
+
+ radio_button.setChecked(True)
+
self.cl_options[descr] = title
+ self.radio_buttons.append(radio_button)
+
self.openCLCheckBoxGroup.setMinimumWidth(self.optionsLayout.sizeHint().width()+10)
- def createLinks(self):
+ def set_sas_open_cl(self):
"""
- Link user interactions to function calls
+ Set SAS_OPENCL value when tests run or OK button clicked
"""
- self.testButton.clicked.connect(self.testButtonClicked)
- self.helpButton.clicked.connect(self.helpButtonClicked)
- for item in self.openCLCheckBoxGroup.findChildren(QtWidgets.QCheckBox):
- item.clicked.connect(self.checked)
- def checked(self):
- """
- Only allow a single check box to be selected. Uncheck others.
- """
checked = None
- for box in self.openCLCheckBoxGroup.findChildren(QtWidgets.QCheckBox):
- if box.isChecked() and (self.cl_options[str(box.text())] == self.sas_open_cl or (
- str(box.text()) == "No OpenCL" and self.sas_open_cl == "")):
- box.setChecked(False)
- elif box.isChecked():
+ for box in self.radio_buttons:
+ if box.isChecked():
checked = box
- if hasattr(checked, "text"):
- self.sas_open_cl = self.cl_options[str(checked.text())]
- else:
- self.sas_open_cl = -1
- def set_sas_open_cl(self):
- """
- Set SAS_OPENCL value when tests run or OK button clicked
- """
- no_opencl_msg = self.sas_open_cl == -1
- env.sas_opencl = self.sas_open_cl
+ if checked is None:
+ raise RuntimeError("Error: No radio button selected somehow")
+
+ sas_open_cl = self.cl_options[str(checked.text())]
+ no_opencl_msg = sas_open_cl.lower() == "none"
+ env.sas_opencl = sas_open_cl
+ config.SAS_OPENCL = sas_open_cl
# CRUFT: next version of reset_environment() will return env
sasmodels.sasview_model.reset_environment()
@@ -347,5 +339,5 @@ def _get_clinfo():
d_index += 1
p_index += 1
- clinfo.append(("None", "No OpenCL"))
+ clinfo.append(("none", "No OpenCL"))
return clinfo
diff --git a/src/sas/system/env.py b/src/sas/system/env.py
index 4a8c4c5af6..e1063cc5bd 100644
--- a/src/sas/system/env.py
+++ b/src/sas/system/env.py
@@ -10,38 +10,25 @@ class Envrironment:
logger = logging.getLogger(__name__)
@property
- def sas_opencl(self) -> int:
+ def sas_opencl(self) -> str:
"""
Get the value of the environment variable SAS_OPENCL, which specifies which OpenCL device
should be used.
-
- FAQ: Why use -1 to represent the no-device state, rather than None? Isn't None a better choice?
- Ans: This helps keep the config files in order (see docs on that), as the type of -1 (the default)
- can be inferred and checked online.
-
"""
- string_value = os.environ.get("SAS_OPENCL", "None")
- if string_value.lower() == "none":
- return -1
- else:
- try:
- int_value = int(string_value)
- return int_value
- except ValueError:
- self.logger.warning(
- f"Failed to parse SAS_OPENCL environment variable, expected an integer or 'none', got {string_value}")
- return -1
+ return os.environ.get("SAS_OPENCL", "none")
+
@sas_opencl.setter
- def sas_opencl(self, value: int):
+ def sas_opencl(self, value: str):
"""
Set the value of the environment variable SAS_OPENCL
"""
- if value == -1:
- del os.environ["SAS_OPENCL"]
+ if value.lower() == "none":
+ if "SAS_OPENCL" in os.environ:
+ del os.environ["SAS_OPENCL"]
else:
- os.environ["SAS_OPENCL"] = str(value)
+ os.environ["SAS_OPENCL"] = value
env = Envrironment()
\ No newline at end of file
From fe8fb8f81cdad7084075ea970f8899769d079634 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Wed, 14 Sep 2022 14:44:05 +0100
Subject: [PATCH 49/82] Disabled test flag to see if it breaks anything
---
src/sas/config_system/config.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/sas/config_system/config.py b/src/sas/config_system/config.py
index b0a6acbf71..4381db468d 100644
--- a/src/sas/config_system/config.py
+++ b/src/sas/config_system/config.py
@@ -144,7 +144,7 @@ def __init__(self):
super().__init__()
# Flag for automated testing
- self.__TEST__ = False
+ # self.__TEST__ = False
# edit the list of file state your plugin can read
self.APPLICATION_WLIST = 'SasView files (*.svs)|*.svs'
From bffd91024005ff35721a6d911ebe3db915831838 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Wed, 14 Sep 2022 15:38:29 +0100
Subject: [PATCH 50/82] Fixed file references for moved files
---
installers/sasview.spec | 4 ++--
test/utest_sasview.py | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/installers/sasview.spec b/installers/sasview.spec
index 749b52cc5a..b1e5371b23 100644
--- a/installers/sasview.spec
+++ b/installers/sasview.spec
@@ -19,8 +19,8 @@ datas = [
# ('../src/sas/sasview/local_config.py', '.'),
# ('../src/sas/sasview/wxcruft.py', '.'),
('../src/sas/qtgui/Perspectives/Fitting/plugin_models', 'plugin_models'),
- ('../src/sas/logger_config.py', '.'),
- ('../src/sas/logging.ini', '.'),
+# ('../src/sas/logger_config.py', '.'),
+ ('../src/sas/system/log.ini', '.'),
('../../sasmodels/sasmodels','sasmodels'),
('../docs/sphinx-docs/build/html','doc')
]
diff --git a/test/utest_sasview.py b/test/utest_sasview.py
index 08df8776aa..a5de8d4eb9 100755
--- a/test/utest_sasview.py
+++ b/test/utest_sasview.py
@@ -7,7 +7,7 @@
import logging
import logging.config
-LOGGER_CONFIG_FILE = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'logging.ini')
+LOGGER_CONFIG_FILE = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'system', 'log.ini')
logging.config.fileConfig(LOGGER_CONFIG_FILE)
logger = logging.getLogger(__name__)
From 658f2fa7fc151c418ccb42fe4b9c063e6fb69a72 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Wed, 14 Sep 2022 16:43:30 +0100
Subject: [PATCH 51/82] Moved config_system to system.config
---
setup.py | 4 ++--
src/sas/__init__.py | 2 +-
src/sas/config_system/__init__.py | 1 -
src/sas/system/config/__init__.py | 1 +
.../{config_system => system/config}/config.py | 7 +------
.../config}/config_meta.py | 4 ++--
.../config}/schema_elements.py | 0
.../{config_system => system/config}/test_list | 0
.../{config_system => system/config}/util.py | 5 +----
test/config/utest_config.py | 18 +++++++++---------
10 files changed, 17 insertions(+), 25 deletions(-)
delete mode 100644 src/sas/config_system/__init__.py
create mode 100644 src/sas/system/config/__init__.py
rename src/sas/{config_system => system/config}/config.py (98%)
rename src/sas/{config_system => system/config}/config_meta.py (98%)
rename src/sas/{config_system => system/config}/schema_elements.py (100%)
rename src/sas/{config_system => system/config}/test_list (100%)
rename src/sas/{config_system => system/config}/util.py (51%)
diff --git a/setup.py b/setup.py
index c841501d48..d100e6a6ae 100644
--- a/setup.py
+++ b/setup.py
@@ -278,8 +278,8 @@ def run(self):
]
packages.append("sas.qtgui")
-package_data["sas.config_system"] = ["*"]
-packages.append("sas.config_system")
+package_data["sas.config"] = ["*"]
+packages.append("sas.config")
required = [
'bumps>=0.7.5.9', 'periodictable>=1.5.0', 'pyparsing>=2.0.0',
diff --git a/src/sas/__init__.py b/src/sas/__init__.py
index 575abfd44e..a9348117ba 100644
--- a/src/sas/__init__.py
+++ b/src/sas/__init__.py
@@ -2,7 +2,7 @@
import os
import sys
-from sas.config_system import configuration as config
+from sas.system.config import configuration as config
__all__ = ['get_app_dir', 'get_user_dir', 'config']
diff --git a/src/sas/config_system/__init__.py b/src/sas/config_system/__init__.py
deleted file mode 100644
index 715f89dab7..0000000000
--- a/src/sas/config_system/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from sas.config_system.util import configuration
diff --git a/src/sas/system/config/__init__.py b/src/sas/system/config/__init__.py
new file mode 100644
index 0000000000..49e067a2a3
--- /dev/null
+++ b/src/sas/system/config/__init__.py
@@ -0,0 +1 @@
+from sas.system.config.util import configuration
diff --git a/src/sas/config_system/config.py b/src/sas/system/config/config.py
similarity index 98%
rename from src/sas/config_system/config.py
rename to src/sas/system/config/config.py
index 4381db468d..a8915e2036 100644
--- a/src/sas/config_system/config.py
+++ b/src/sas/system/config/config.py
@@ -130,12 +130,7 @@
different configs difficult.
"""
-from sas.config_system.config_meta import ConfigBase, ConfigMeta
-
-import sas.sasview
-import os
-import time
-import logging
+from sas.system.config.config_meta import ConfigBase, ConfigMeta
class Config(ConfigBase, metaclass=ConfigMeta):
diff --git a/src/sas/config_system/config_meta.py b/src/sas/system/config/config_meta.py
similarity index 98%
rename from src/sas/config_system/config_meta.py
rename to src/sas/system/config/config_meta.py
index a25c61961c..0485e60842 100644
--- a/src/sas/config_system/config_meta.py
+++ b/src/sas/system/config/config_meta.py
@@ -5,9 +5,9 @@
from copy import deepcopy
import sas
-from sas.config_system.schema_elements import create_schema_element, CoercionError, SchemaElement
+from sas.system.config.schema_elements import create_schema_element, CoercionError, SchemaElement
-logger = logging.getLogger("sas.config_system")
+logger = logging.getLogger("sas.config")
class MalformedFile(Exception):
diff --git a/src/sas/config_system/schema_elements.py b/src/sas/system/config/schema_elements.py
similarity index 100%
rename from src/sas/config_system/schema_elements.py
rename to src/sas/system/config/schema_elements.py
diff --git a/src/sas/config_system/test_list b/src/sas/system/config/test_list
similarity index 100%
rename from src/sas/config_system/test_list
rename to src/sas/system/config/test_list
diff --git a/src/sas/config_system/util.py b/src/sas/system/config/util.py
similarity index 51%
rename from src/sas/config_system/util.py
rename to src/sas/system/config/util.py
index 0260719051..c44ce82348 100644
--- a/src/sas/config_system/util.py
+++ b/src/sas/system/config/util.py
@@ -1,8 +1,5 @@
-from sas.config_system.config import Config
+from sas.system.config.config import Config
-import sys
-import os
-import os
def get_config() -> Config:
return Config()
diff --git a/test/config/utest_config.py b/test/config/utest_config.py
index ecc03c624c..ddc1380857 100644
--- a/test/config/utest_config.py
+++ b/test/config/utest_config.py
@@ -8,11 +8,11 @@
import sas
-from sas.config_system.config import Config
+from sas.system.config import Config
-from sas.config_system.config_meta import MalformedFile
+from sas.system.config.config_meta import MalformedFile
-from sas.config_system.schema_elements import \
+from sas.system.config import \
pairwise_schema_union, create_schema_element, \
SchemaBool, SchemaInt, SchemaFloat, SchemaStr, \
SchemaList, SchemaNonSpecified, \
@@ -93,9 +93,9 @@ def test_invalid_update_bad_name(self):
name += "x"
# try and set it
- with self.assertLogs('sas.config_system', level="ERROR") as cm:
+ with self.assertLogs('sas.config', level="ERROR") as cm:
config.update({name: None})
- self.assertTrue(cm.output[0].startswith("ERROR:sas.config_system:"))
+ self.assertTrue(cm.output[0].startswith("ERROR:sas.config:"))
def test_invalid_update_bad_type(self):
@@ -120,12 +120,12 @@ def test_invalid_update_bad_type(self):
# Only test the ones that fail, i.e. cannot be coerced
if pairwise_schema_union(test_value_schema, config._schema[key]) is None:
- with self.assertLogs('sas.config_system', level="ERROR") as cm:
+ with self.assertLogs('sas.config', level="ERROR") as cm:
# Try the bad value
config.update({key: test_value})
- self.assertTrue(cm.output[0].startswith("ERROR:sas.config_system:"))
+ self.assertTrue(cm.output[0].startswith("ERROR:sas.config:"))
def test_save_basics(self):
@@ -209,11 +209,11 @@ def test_bad_config_version(self):
file.seek(0)
- with self.assertLogs('sas.config_system', level="WARN") as cm:
+ with self.assertLogs('sas.config', level="WARN") as cm:
# Try the bad value
config.load_from_file_object(file)
- self.assertTrue(cm.output[0].startswith("WARNING:sas.config_system:"))
+ self.assertTrue(cm.output[0].startswith("WARNING:sas.config:"))
def test_bad_config_file_structure(self):
From 77d4a0048bf1284fcbd7cdc85dd58e0822a44fbf Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Wed, 14 Sep 2022 17:06:27 +0100
Subject: [PATCH 52/82] Tweaked config layout and updated setup.py
---
setup.py | 5 ++---
src/sas/__init__.py | 2 +-
src/sas/system/__init__.py | 3 ++-
src/sas/system/config/config.py | 1 +
src/sas/system/config/test_list | 10 ----------
src/sas/system/config/util.py | 7 -------
6 files changed, 6 insertions(+), 22 deletions(-)
delete mode 100644 src/sas/system/config/test_list
delete mode 100644 src/sas/system/config/util.py
diff --git a/setup.py b/setup.py
index d100e6a6ae..534c312f25 100644
--- a/setup.py
+++ b/setup.py
@@ -260,7 +260,8 @@ def run(self):
]
packages.append("sas.sasview")
-package_data["sas.system"] = ["*"]
+package_data["sas.system"] = ["*",
+ "config/*"]
packages.append("sas.system")
package_data['sas.qtgui'] = ['Calculators/UI/*',
@@ -278,8 +279,6 @@ def run(self):
]
packages.append("sas.qtgui")
-package_data["sas.config"] = ["*"]
-packages.append("sas.config")
required = [
'bumps>=0.7.5.9', 'periodictable>=1.5.0', 'pyparsing>=2.0.0',
diff --git a/src/sas/__init__.py b/src/sas/__init__.py
index a9348117ba..eb37bca711 100644
--- a/src/sas/__init__.py
+++ b/src/sas/__init__.py
@@ -2,7 +2,7 @@
import os
import sys
-from sas.system.config import configuration as config
+from sas.system import config
__all__ = ['get_app_dir', 'get_user_dir', 'config']
diff --git a/src/sas/system/__init__.py b/src/sas/system/__init__.py
index c4b441ad04..5b84646217 100644
--- a/src/sas/system/__init__.py
+++ b/src/sas/system/__init__.py
@@ -1,5 +1,6 @@
from .web import web
from .legal import legal
from .env import env
+from .config.config import config
-__all__ = ["web", "legal", "env"]
\ No newline at end of file
+__all__ = ["web", "legal", "env", "config"]
\ No newline at end of file
diff --git a/src/sas/system/config/config.py b/src/sas/system/config/config.py
index a8915e2036..fc4dfe35fb 100644
--- a/src/sas/system/config/config.py
+++ b/src/sas/system/config/config.py
@@ -193,3 +193,4 @@ def __init__(self):
+config = Config()
\ No newline at end of file
diff --git a/src/sas/system/config/test_list b/src/sas/system/config/test_list
deleted file mode 100644
index fdb8513cbb..0000000000
--- a/src/sas/system/config/test_list
+++ /dev/null
@@ -1,10 +0,0 @@
-Places where config has been replaced
-
-AboutBox
-GuiManger save state
-DensityCalculatorTest
-AboutBoxTest
-WelcomePanel
-ModelThread.Calc2D
-FittingWidget
-FittingWidgetTest
\ No newline at end of file
diff --git a/src/sas/system/config/util.py b/src/sas/system/config/util.py
deleted file mode 100644
index c44ce82348..0000000000
--- a/src/sas/system/config/util.py
+++ /dev/null
@@ -1,7 +0,0 @@
-from sas.system.config.config import Config
-
-
-def get_config() -> Config:
- return Config()
-
-configuration = get_config()
\ No newline at end of file
From d908dbcf537c0c2b926bb38b161f55c6fa169224 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Wed, 14 Sep 2022 17:19:54 +0100
Subject: [PATCH 53/82] Changed bad package name
---
src/sas/system/config/__init__.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/sas/system/config/__init__.py b/src/sas/system/config/__init__.py
index 49e067a2a3..e69de29bb2 100644
--- a/src/sas/system/config/__init__.py
+++ b/src/sas/system/config/__init__.py
@@ -1 +0,0 @@
-from sas.system.config.util import configuration
From 741febe99dea2618968c26e798c96543fb8654e8 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Wed, 14 Sep 2022 17:35:17 +0100
Subject: [PATCH 54/82] Fixed bad imports in utest
---
test/config/utest_config.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/config/utest_config.py b/test/config/utest_config.py
index ddc1380857..b78aa138af 100644
--- a/test/config/utest_config.py
+++ b/test/config/utest_config.py
@@ -8,11 +8,11 @@
import sas
-from sas.system.config import Config
+from sas.system.config.config import Config
from sas.system.config.config_meta import MalformedFile
-from sas.system.config import \
+from sas.system.config.schema_elements import \
pairwise_schema_union, create_schema_element, \
SchemaBool, SchemaInt, SchemaFloat, SchemaStr, \
SchemaList, SchemaNonSpecified, \
From e3c41e003de41a87b18b3da033a4f406f4fb04db Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Wed, 14 Sep 2022 18:14:56 +0100
Subject: [PATCH 55/82] Updated .gitignore to miss config.json
---
.gitignore | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index 8990c97167..82466c2068 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,7 +30,6 @@
*.so
*.exe
-/.vagrant
/build
/dist
sasview.egg-info
@@ -39,6 +38,7 @@ default_categories.json
/setup.cfg
**/UI/*.py
!**/UI/__init__.py
+config.json
# doc build
/docs/sphinx-docs/build
From 0c9fba32c81e2572f5d8b4905becac6d246b53d7 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Thu, 15 Sep 2022 14:30:17 +0100
Subject: [PATCH 56/82] Cleaned up __init__s, made user, version, and zenodo
files in system
---
run.py | 4 +-
src/sas/__init__.py | 84 +------------------
src/sas/qtgui/MainWindow/AboutBox.py | 6 +-
src/sas/qtgui/MainWindow/Acknowledgements.py | 6 +-
src/sas/qtgui/MainWindow/DataManager.py | 2 +-
src/sas/qtgui/MainWindow/GuiManager.py | 8 +-
src/sas/qtgui/MainWindow/MainWindow.py | 4 +-
src/sas/qtgui/MainWindow/PackageGatherer.py | 5 +-
.../MainWindow/UnitTesting/AboutBoxTest.py | 5 +-
.../UnitTesting/DataExplorerTest.py | 2 +-
src/sas/qtgui/MainWindow/WelcomePanel.py | 6 +-
.../Perspectives/Fitting/ReportPageLogic.py | 2 +-
src/sas/qtgui/Utilities/FileConverter.py | 2 +-
src/sas/qtgui/Utilities/Reports/reports.py | 5 +-
src/sas/sascalc/fit/models.py | 2 +-
src/sas/sascalc/fit/pagestate.py | 2 +-
src/sas/sasview/__init__.py | 8 --
src/sas/system/config/config_meta.py | 7 +-
src/sas/system/user.py | 24 ++++++
src/sas/system/version.py | 7 ++
src/sas/system/zenodo.py | 1 +
test/config/utest_config.py | 13 +--
22 files changed, 79 insertions(+), 126 deletions(-)
delete mode 100644 src/sas/sasview/__init__.py
create mode 100644 src/sas/system/user.py
create mode 100644 src/sas/system/version.py
create mode 100644 src/sas/system/zenodo.py
diff --git a/run.py b/run.py
index 74a88afeeb..55626da346 100644
--- a/run.py
+++ b/run.py
@@ -20,6 +20,8 @@
from os.path import abspath, dirname, realpath, join as joinpath
from contextlib import contextmanager
+import sas.system.user
+
PLUGIN_MODEL_DIR = 'plugin_models'
def addpath(path):
@@ -52,7 +54,7 @@ def setup_sasmodels():
"""
# Set SAS_MODELPATH so sasmodels can find our custom models
import sas
- plugin_dir = os.path.join(sas.get_user_dir(), PLUGIN_MODEL_DIR)
+ plugin_dir = os.path.join(sas.system.user.get_user_dir(), PLUGIN_MODEL_DIR)
os.environ['SAS_MODELPATH'] = plugin_dir
def prepare():
diff --git a/src/sas/__init__.py b/src/sas/__init__.py
index eb37bca711..f0cd9a8647 100644
--- a/src/sas/__init__.py
+++ b/src/sas/__init__.py
@@ -1,87 +1,9 @@
-from sas.sasview import __version__
+from sas.system.version import __version__
-import os
-import sys
-from sas.system import config
+from sas.system import config, user
-__all__ = ['get_app_dir', 'get_user_dir', 'config']
+__all__ = ['config']
# Load the config file
config.load()
-
-_APP_DIR = None
-def get_app_dir():
- """
- The directory where the sasview application is found.
-
- Returns the path to sasview if running in place or installed with setup.
- If the application is frozen, returns the parent directory of the
- application resources such as test files and images.
- """
- global _APP_DIR
- if not _APP_DIR:
- _APP_DIR = find_app_dir()
- return _APP_DIR
-
-# TODO: Replace with more idomatic version
-def dirn(path, n):
- """
- Return the directory n up from the current path
- """
- path = os.path.realpath(path)
- for _ in range(n):
- path = os.path.dirname(path)
- return path
-
-
-def find_app_dir():
- """
- Locate the parent directory of the sasview resources. For the normal
- application this will be the directory containing sasview.py. For the
- frozen application this will be the path where the resources are installed.
- """
- # We are starting out with the following info:
- # __file__ = .../sas/__init__.pyc
- # Check if the path .../sas/sasview exists, and use it as the
- # app directory. This will only be the case if the app is not frozen.
- path = os.path.join(os.path.dirname(__file__), 'sasview')
- if os.path.exists(path):
- return path
-
- # If we are running frozen, then root is a parent directory
- if sys.platform == 'darwin':
- # Here is the path to the file on the mac:
- # .../Sasview.app/Contents/Resources/lib/python2.7/site-packages.zip/sas/__init__.pyc
- # We want the path to the Resources directory.
- path = dirn(__file__, 5)
- elif os.name == 'nt':
- # Here is the path to the file on windows:
- # ../Sasview/library.zip/sas/__init__.pyc
- # We want the path to the Sasview directory.
- path = dirn(__file__, 3)
- else:
- raise RuntimeError("Couldn't find the app directory")
- return path
-
-def make_user_dir():
- """
- Create the user directory ~/.sasview if it doesn't already exist.
- """
- path = os.path.join(os.path.expanduser("~"),'.sasview')
- if not os.path.exists(path):
- os.mkdir(path)
- return path
-
-
-_USER_DIR = None
-def get_user_dir():
- """
- The directory where the per-user configuration is stored.
-
- Returns ~/.sasview, creating it if it does not already exist.
- """
- global _USER_DIR
- if not _USER_DIR:
- _USER_DIR = make_user_dir()
- return _USER_DIR
diff --git a/src/sas/qtgui/MainWindow/AboutBox.py b/src/sas/qtgui/MainWindow/AboutBox.py
index f5378e9ad6..fac573d81b 100644
--- a/src/sas/qtgui/MainWindow/AboutBox.py
+++ b/src/sas/qtgui/MainWindow/AboutBox.py
@@ -3,6 +3,7 @@
import sas.sasview
import sas.qtgui.Utilities.GuiUtils as GuiUtils
+import sas.system.version
from sas.qtgui.UI import images_rc
from sas.qtgui.UI import main_resources_rc
@@ -28,7 +29,7 @@ def addText(self):
"""
Modify the labels so the text corresponds to the current version
"""
- version = sas.sasview.__version__
+ version = sas.system.version.__version__
self.lblVersion.setText(str(version))
lbl_font = self.font()
@@ -39,9 +40,6 @@ def addText(self):
-
- Build{sas.sasview.__build__}
-
{legal.copyright}
diff --git a/src/sas/qtgui/MainWindow/Acknowledgements.py b/src/sas/qtgui/MainWindow/Acknowledgements.py
index e14f41cc05..69bfb23215 100644
--- a/src/sas/qtgui/MainWindow/Acknowledgements.py
+++ b/src/sas/qtgui/MainWindow/Acknowledgements.py
@@ -2,6 +2,8 @@
from PyQt5 import QtWidgets, QtCore
import sas.sasview
+import sas.system.version
+import sas.system.zenodo
from .UI.AcknowledgementsUI import Ui_Acknowledgements
@@ -19,8 +21,8 @@ def addText(self):
"""
Modify the labels so the text corresponds to the current version
"""
- version = sas.sasview.__version__
- doi = sas.sasview.__DOI__
+ version = sas.system.version.__version__
+ doi = sas.system.zenodo.__DOI__
acknowledgement_text_1 = "This work benefited from the use of the SasView application, originally developed " \
"under NSF Award DMR - 0520547. SasView also contains code developed with funding" \
" from the EU Horizon 2020 programme under the SINE2020 project Grant No 654000."
diff --git a/src/sas/qtgui/MainWindow/DataManager.py b/src/sas/qtgui/MainWindow/DataManager.py
index d5d4671fd0..b07bdc2b45 100755
--- a/src/sas/qtgui/MainWindow/DataManager.py
+++ b/src/sas/qtgui/MainWindow/DataManager.py
@@ -42,7 +42,7 @@
# used for import/export
from sasdata.dataloader.data_info import Sample, Source, Vector
-from sas.sasview import __version__ as SASVIEW_VERSION
+from sas.system.version import __version__ as SASVIEW_VERSION
class DataManager(object):
diff --git a/src/sas/qtgui/MainWindow/GuiManager.py b/src/sas/qtgui/MainWindow/GuiManager.py
index 5960dee42c..8f4563cd0b 100644
--- a/src/sas/qtgui/MainWindow/GuiManager.py
+++ b/src/sas/qtgui/MainWindow/GuiManager.py
@@ -12,10 +12,12 @@
from PyQt5.QtCore import Qt, QLocale
import matplotlib as mpl
+
+import sas.system.version
+
mpl.use("Qt5Agg")
-from sas.sasview import __version__ as SASVIEW_VERSION
-from sas.sasview import __release_date__ as SASVIEW_RELEASE_DATE
+from sas.system.version import __version__ as SASVIEW_VERSION, __release_date__ as SASVIEW_RELEASE_DATE
from twisted.internet import reactor
# General SAS imports
@@ -572,7 +574,7 @@ def processVersion(self, version_info):
msg += " Please try again later."
self.communicate.statusBarUpdateSignal.emit(msg)
- elif version.__gt__(sas.__version__):
+ elif version.__gt__(sas.system.version.__version__):
msg = "Version %s is available! " % str(version)
if "download_url" in version_info:
webbrowser.open(version_info["download_url"])
diff --git a/src/sas/qtgui/MainWindow/MainWindow.py b/src/sas/qtgui/MainWindow/MainWindow.py
index dbc9672dc2..44eb6b9fe9 100644
--- a/src/sas/qtgui/MainWindow/MainWindow.py
+++ b/src/sas/qtgui/MainWindow/MainWindow.py
@@ -4,7 +4,7 @@
import os
import sys
-from sas.sasview import __version__ as SASVIEW_VERSION
+from ...system.version import __version__ as SASVIEW_VERSION
from sas import config
from sas.system import env
@@ -77,7 +77,7 @@ def run_sasview():
SetupLogger(__name__).config_development()
# initialize sasmodels settings
- from sas import get_user_dir
+ from sas.system.user import get_user_dir
if "SAS_DLL_PATH" not in os.environ:
os.environ["SAS_DLL_PATH"] = os.path.join(
get_user_dir(), "compiled_models")
diff --git a/src/sas/qtgui/MainWindow/PackageGatherer.py b/src/sas/qtgui/MainWindow/PackageGatherer.py
index e3bb4bdc04..be7d7ef968 100644
--- a/src/sas/qtgui/MainWindow/PackageGatherer.py
+++ b/src/sas/qtgui/MainWindow/PackageGatherer.py
@@ -4,6 +4,7 @@
import pathlib
import sas
+import sas.system.version
logger = logging.getLogger(__name__)
@@ -69,7 +70,7 @@ def get_imported_packages(self):
:returns: A dictionary with the package names as the key, with their respective version numbers as the value.
:rtype: dict
"""
- package_versions_dict = {'python': sys.version, 'SasView': sas.__version__}
+ package_versions_dict = {'python': sys.version, 'SasView': sas.system.version.__version__}
err_version_dict = {}
no_version_list = []
# Generate a list of standard modules by looking at the local python library
@@ -146,7 +147,7 @@ def get_imported_packages(self):
if hasattr(package, '__version__'):
# Module has __version__ attribute
try:
- package_versions_dict[package_name] = package.__version__
+ package_versions_dict[package_name] = sas.system.version.__version__
continue
except Exception as e:
# Unable to access module
diff --git a/src/sas/qtgui/MainWindow/UnitTesting/AboutBoxTest.py b/src/sas/qtgui/MainWindow/UnitTesting/AboutBoxTest.py
index dc7ec47aef..e5f7c5311e 100644
--- a/src/sas/qtgui/MainWindow/UnitTesting/AboutBoxTest.py
+++ b/src/sas/qtgui/MainWindow/UnitTesting/AboutBoxTest.py
@@ -8,6 +8,7 @@
from unittest.mock import MagicMock
import sas.sasview
+import sas.system.version
from sas import config
from sas.system import web, legal
@@ -45,7 +46,7 @@ def testVersion(self):
"""
version = self.widget.lblVersion
self.assertIsInstance(version, QtWidgets.QLabel)
- self.assertEqual(str(version.text()), str(sas.__version__))
+ self.assertEqual(str(version.text()), str(sas.system.version.__version__))
def testAbout(self):
"""
@@ -53,8 +54,6 @@ def testAbout(self):
"""
about = self.widget.lblAbout
self.assertIsInstance(about, QtWidgets.QLabel)
- # build version
- self.assertIn(str(sas.sasview.__build__), about.text())
# License
self.assertIn(str(legal.copyright), about.text())
# URLs
diff --git a/src/sas/qtgui/MainWindow/UnitTesting/DataExplorerTest.py b/src/sas/qtgui/MainWindow/UnitTesting/DataExplorerTest.py
index b6f6acf9e6..430d0e9bae 100644
--- a/src/sas/qtgui/MainWindow/UnitTesting/DataExplorerTest.py
+++ b/src/sas/qtgui/MainWindow/UnitTesting/DataExplorerTest.py
@@ -27,7 +27,7 @@
from sas.qtgui.Plotting.Plotter2D import Plotter2D
import sas.qtgui.Plotting.PlotHelper as PlotHelper
-from sas.sasview import __version__ as SASVIEW_VERSION
+from sas.system.version import __version__ as SASVIEW_VERSION
if not QApplication.instance():
app = QApplication(sys.argv)
diff --git a/src/sas/qtgui/MainWindow/WelcomePanel.py b/src/sas/qtgui/MainWindow/WelcomePanel.py
index 729761c4a6..e5d694041b 100644
--- a/src/sas/qtgui/MainWindow/WelcomePanel.py
+++ b/src/sas/qtgui/MainWindow/WelcomePanel.py
@@ -1,6 +1,7 @@
from PyQt5 import QtWidgets
import sas.sasview
+import sas.system.version
from sas import config
from sas.system import legal
@@ -14,10 +15,9 @@ def __init__(self, parent=None):
self.setWindowTitle("Welcome")
- version = sas.sasview.__version__ # TODO: Make consistent with other version references
- build = sas.sasview.__build__ # TODO: Make consistent with other build references
+ version = sas.system.version.__version__ # TODO: Make consistent with other version references
- ver = "\nSasView %s\nBuild: %s\n%s" % (version, build, legal.copyright)
+ ver = "\nSasView %s\n%s" % (version, legal.copyright)
self.lblVersion.setText(ver)
diff --git a/src/sas/qtgui/Perspectives/Fitting/ReportPageLogic.py b/src/sas/qtgui/Perspectives/Fitting/ReportPageLogic.py
index 73a7ceb859..70e63dc6a4 100644
--- a/src/sas/qtgui/Perspectives/Fitting/ReportPageLogic.py
+++ b/src/sas/qtgui/Perspectives/Fitting/ReportPageLogic.py
@@ -18,7 +18,7 @@
from sas.qtgui.Plotting.PlotterBase import PlotterBase
from sas.qtgui.Utilities.Reports.reportdata import ReportData
-from sas.sasview import __version__ as SASVIEW_VERSION
+from sas.system.version import __version__ as SASVIEW_VERSION
from sasmodels import __version__ as SASMODELS_VERSION
# TODO: Integrate with other reports
diff --git a/src/sas/qtgui/Utilities/FileConverter.py b/src/sas/qtgui/Utilities/FileConverter.py
index 5b7e0ef7d1..97b82161eb 100644
--- a/src/sas/qtgui/Utilities/FileConverter.py
+++ b/src/sas/qtgui/Utilities/FileConverter.py
@@ -23,7 +23,7 @@
import sas.qtgui.Utilities.GuiUtils as GuiUtils
from sas.qtgui.Utilities.FrameSelect import FrameSelect
-from sas.sasview import __version__ as SASVIEW_VERSION
+from ...system.version import __version__ as SASVIEW_VERSION
from .UI.FileConverterUI import Ui_FileConverterUI
diff --git a/src/sas/qtgui/Utilities/Reports/reports.py b/src/sas/qtgui/Utilities/Reports/reports.py
index 5d256e10b1..a2e0b2414f 100644
--- a/src/sas/qtgui/Utilities/Reports/reports.py
+++ b/src/sas/qtgui/Utilities/Reports/reports.py
@@ -20,6 +20,7 @@
from xhtml2pdf import pisa
import sas.sasview
+import sas.system.version
import sasmodels
import logging
@@ -97,7 +98,7 @@ def __init__(self,
with self._html_doc.head:
meta(http_equiv="Content-Type", content="text/html; charset=utf-8")
- meta(name="Generator", content=f"SasView {sas.sasview.__version__}")
+ meta(name="Generator", content=f"SasView {sas.system.version.__version__}")
if style_link is not None:
link(rel="stylesheet", href=style_link)
@@ -113,7 +114,7 @@ def __init__(self,
h1(title)
p(datetime.datetime.now().strftime("%I:%M%p, %B %d, %Y"))
with div(id="version-info"):
- p(f"sasview {sas.sasview.__version__}, sasmodels {sasmodels.__version__}", cls="sasview-details")
+ p(f"sasview {sas.system.version.__version__}, sasmodels {sasmodels.__version__}", cls="sasview-details")
div(id="perspective")
with div(id="data"):
diff --git a/src/sas/sascalc/fit/models.py b/src/sas/sascalc/fit/models.py
index a5dd930bea..22e0dda92e 100644
--- a/src/sas/sascalc/fit/models.py
+++ b/src/sas/sascalc/fit/models.py
@@ -17,7 +17,7 @@
from sasmodels.sasview_model import load_custom_model, load_standard_models
-from sas import get_user_dir
+from sas.system.user import get_user_dir
# Explicitly import from the pluginmodel module so that py2exe
# places it in the distribution. The Model1DPlugin class is used
diff --git a/src/sas/sascalc/fit/pagestate.py b/src/sas/sascalc/fit/pagestate.py
index 3dc1853d81..fedd825f7b 100644
--- a/src/sas/sascalc/fit/pagestate.py
+++ b/src/sas/sascalc/fit/pagestate.py
@@ -28,7 +28,7 @@
from sasmodels import convert
import sasmodels.weights
-from sas.sasview import __version__ as SASVIEW_VERSION
+from sas.system.version import __version__ as SASVIEW_VERSION
import sasdata.dataloader
from sasdata.dataloader.readers.cansas_reader import Reader as CansasReader
diff --git a/src/sas/sasview/__init__.py b/src/sas/sasview/__init__.py
deleted file mode 100644
index e451e2feb2..0000000000
--- a/src/sas/sasview/__init__.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from distutils.version import StrictVersion
-# The version number must follow StrictVersion rules as outlined
-# in http://epydoc.sourceforge.net/stdlib/distutils.version.StrictVersion-class.html
-__version__ = "5.0.5"
-StrictVersion(__version__)
-__DOI__ = "Zenodo, 10.5281/zenodo.6331344"
-__release_date__ = "2022"
-__build__ = "GIT_COMMIT"
diff --git a/src/sas/system/config/config_meta.py b/src/sas/system/config/config_meta.py
index 0485e60842..63157cc0be 100644
--- a/src/sas/system/config/config_meta.py
+++ b/src/sas/system/config/config_meta.py
@@ -5,6 +5,7 @@
from copy import deepcopy
import sas
+import sas.system.version
from sas.system.config.schema_elements import create_schema_element, CoercionError, SchemaElement
logger = logging.getLogger("sas.config")
@@ -96,7 +97,7 @@ def save_to_file_object(self, file):
data[key] = new_value
output_data = {
- "sasview_version": sas.__version__,
+ "sasview_version": sas.system.version.__version__,
"config_data": data}
json.dump(output_data, file)
@@ -132,11 +133,11 @@ def load_from_file_object(self, file):
# Check major version
file_version = data["sasview_version"]
file_major_version = file_version.split(".")[0]
- sasview_major_version = sas.__version__.split(".")[0]
+ sasview_major_version = sas.system.version.__version__.split(".")[0]
if int(file_major_version) != int(sasview_major_version):
logger.warning(f"Attempting to used outdated config file (config is"
- f" for {file_version}, this SasView version is {sas.__version__})")
+ f" for {file_version}, this SasView version is {sas.system.version.__version__})")
self._write_disabled = True
self.update(data["config_data"])
diff --git a/src/sas/system/user.py b/src/sas/system/user.py
new file mode 100644
index 0000000000..4fda655def
--- /dev/null
+++ b/src/sas/system/user.py
@@ -0,0 +1,24 @@
+import os
+
+_USER_DIR = None
+
+def make_user_dir():
+ """
+ Create the user directory ~/.sasview if it doesn't already exist.
+ """
+ path = os.path.join(os.path.expanduser("~"),'.sasview')
+ if not os.path.exists(path):
+ os.mkdir(path)
+ return path
+
+
+def get_user_dir():
+ """
+ The directory where the per-user configuration is stored.
+
+ Returns ~/.sasview, creating it if it does not already exist.
+ """
+ global _USER_DIR
+ if not _USER_DIR:
+ _USER_DIR = make_user_dir()
+ return _USER_DIR
diff --git a/src/sas/system/version.py b/src/sas/system/version.py
new file mode 100644
index 0000000000..755d4128c3
--- /dev/null
+++ b/src/sas/system/version.py
@@ -0,0 +1,7 @@
+from distutils.version import StrictVersion
+
+__version__ = "5.0.5"
+__release_date__ = "2022"
+
+
+StrictVersion(__version__)
\ No newline at end of file
diff --git a/src/sas/system/zenodo.py b/src/sas/system/zenodo.py
new file mode 100644
index 0000000000..c93f5ed1bf
--- /dev/null
+++ b/src/sas/system/zenodo.py
@@ -0,0 +1 @@
+__DOI__ = "Zenodo, 10.5281/zenodo.6331344"
diff --git a/test/config/utest_config.py b/test/config/utest_config.py
index b78aa138af..2bbb029344 100644
--- a/test/config/utest_config.py
+++ b/test/config/utest_config.py
@@ -7,6 +7,7 @@
import json
import sas
+import sas.system.version
from sas.system.config.config import Config
@@ -140,7 +141,7 @@ def test_save_basics(self):
observed = json.load(file)
empty_file = {
- "sasview_version": sas.__version__,
+ "sasview_version": sas.system.version.__version__,
"config_data": {}
}
@@ -162,7 +163,7 @@ def test_save_changes(self):
observed = json.load(file)
expected = {
- "sasview_version": sas.__version__,
+ "sasview_version": sas.system.version.__version__,
"config_data": {key: test_dict[key]}
}
@@ -176,7 +177,7 @@ def test_only_save_actual_changes(self):
# (3) Check
empty_file = {
- "sasview_version": sas.__version__,
+ "sasview_version": sas.system.version.__version__,
"config_data": {}
}
@@ -221,7 +222,7 @@ def test_bad_config_file_structure(self):
bad_structures = [
{
- "sasview_version": sas.__version__,
+ "sasview_version": sas.system.version.__version__,
"quanfig_data": {}
},
{
@@ -229,11 +230,11 @@ def test_bad_config_file_structure(self):
"config_data": {}
},
{
- "sassy_verberry": sas.__version__,
+ "sassy_verberry": sas.system.version.__version__,
"config_data": {}
},
{
- "sasview_version": sas.__version__,
+ "sasview_version": sas.system.version.__version__,
"config_data": []
},
{}
From c18428ad9fa28d61c3b7aa9d7c6940456cd30b24 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Thu, 15 Sep 2022 14:49:06 +0100
Subject: [PATCH 57/82] Update release automation script for new structure
---
build_tools/release_automation.py | 41 +++++++++++++++++--------------
src/sas/system/version.py | 3 +--
2 files changed, 24 insertions(+), 20 deletions(-)
diff --git a/build_tools/release_automation.py b/build_tools/release_automation.py
index 2d495632c1..73b5943f34 100644
--- a/build_tools/release_automation.py
+++ b/build_tools/release_automation.py
@@ -135,29 +135,34 @@ def generate_zenodo(sasview_data, zenodo_api_key):
"and attach to Zenodo release record.\n- Publish Zenodo record")
return newDOI
-def update_sasview_init(version, doi):
- """
+version_template = \
+"""
+from distutils.version import StrictVersion
- :return:
+__version__ = "%s"
+__release_date__ = "%i"
+
+StrictVersion(__version__)
+"""
+
+zenodo_template = '__DOI__ = "%s"'
+
+def update_sasview_metadata(version, doi):
+ """
+ Update version and zenodo DOI
"""
- init_file = os.path.join('sasview','src', 'sas', 'sasview', '__init__.py')
- output_lines = []
+ system_directory = "sasview/src/sas/system"
+ version_filename = os.path.join(system_directory, "version.py")
+ zenodo_filename = os.path.join(system_directory, "zenodo.py")
+
year = datetime.datetime.now().year
- with open(init_file, 'r') as f:
- for line in f.readlines():
- if line[:11] in '__version__':
- output_lines.append('__version__ = \"'+version+'\"\n')
- elif line[:7] in '__DOI__' :
- output_lines.append('__DOI__ = \"Zenodo, ' + str(doi) + '\"\n')
- elif line[:16] in '__release_date__':
- output_lines.append('__release_date__ = \"' + str(year) + '\"\n')
- else:
- output_lines.append(line)
- with open(init_file, 'w') as f:
- f.writelines(output_lines)
+ with open(version_filename, 'w') as file:
+ file.write(version_template % (version, year))
+ with open(zenodo_filename, 'w') as file:
+ file.write(zenodo_template % doi)
def update_sasmodels_init(version):
"""
@@ -241,7 +246,7 @@ def prepare_release_notes(issues_list, repository, username, password):
zenodo_api_key = args.zenodo
new_doi = generate_zenodo(sasview_data, zenodo_api_key)
- update_sasview_init(sasview_version, new_doi)
+ update_sasview_metadata(sasview_version, new_doi)
update_sasmodels_init(sasmodels_version)
year = datetime.datetime.now().year
diff --git a/src/sas/system/version.py b/src/sas/system/version.py
index 755d4128c3..f6c31d1a75 100644
--- a/src/sas/system/version.py
+++ b/src/sas/system/version.py
@@ -3,5 +3,4 @@
__version__ = "5.0.5"
__release_date__ = "2022"
-
-StrictVersion(__version__)
\ No newline at end of file
+StrictVersion(__version__)
From 93cb3bcc13416f9998fd1a1a1bdd40d3c109b32a Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Thu, 15 Sep 2022 14:55:46 +0100
Subject: [PATCH 58/82] Removed commented datas
---
installers/sasview.spec | 5 -----
1 file changed, 5 deletions(-)
diff --git a/installers/sasview.spec b/installers/sasview.spec
index b1e5371b23..d55f1c044c 100644
--- a/installers/sasview.spec
+++ b/installers/sasview.spec
@@ -9,17 +9,12 @@ import sys
block_cipher = None
PYTHON_LOC = sys.exec_prefix
-#TODO: Removed commented lines
datas = [
('../src/sas/sasview/images', 'images'),
('../src/sas/sasview/media', 'media'),
('../src/sas/example_data', 'example_data'),
('../src/sas/qtgui/Utilities/Reports/report_style.css', 'sas/qtgui/Utilities/Reports'),
-# ('../src/sas/sasview/custom_config.py', '.'),
-# ('../src/sas/sasview/local_config.py', '.'),
-# ('../src/sas/sasview/wxcruft.py', '.'),
('../src/sas/qtgui/Perspectives/Fitting/plugin_models', 'plugin_models'),
-# ('../src/sas/logger_config.py', '.'),
('../src/sas/system/log.ini', '.'),
('../../sasmodels/sasmodels','sasmodels'),
('../docs/sphinx-docs/build/html','doc')
From db8ef6439e1561e908243d24f0003531da6e0c0c Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Thu, 15 Sep 2022 15:04:39 +0100
Subject: [PATCH 59/82] Cleaning up GuiUtils
---
src/sas/qtgui/Utilities/GuiUtils.py | 55 ++-----------------
.../Utilities/UnitTesting/GuiUtilsTest.py | 6 --
2 files changed, 6 insertions(+), 55 deletions(-)
diff --git a/src/sas/qtgui/Utilities/GuiUtils.py b/src/sas/qtgui/Utilities/GuiUtils.py
index 4f6a690625..1a1d8b546b 100644
--- a/src/sas/qtgui/Utilities/GuiUtils.py
+++ b/src/sas/qtgui/Utilities/GuiUtils.py
@@ -44,6 +44,7 @@
from sas.sascalc.fit.AbstractFitEngine import FitData1D, FitData2D
from sasmodels.sasview_model import SasviewModel
+import sas
from sas import config
from sasdata.dataloader.loader import Loader
@@ -68,7 +69,7 @@
logger = logging.getLogger(__name__)
-def get_app_dir():
+def get_sensible_default_open_directory():
"""
:returns: app_path - the path to the application directory
"""
@@ -77,55 +78,14 @@ def get_app_dir():
if os.path.isfile(app_path):
return os.path.dirname(app_path)
- #
- # # Next, try the current working directory
- # if os.path.isfile(os.path.join(os.getcwd(), "custom_config.py")):
- # #logging.info("Using application path: %s", os.getcwd())
- # return os.path.abspath(os.getcwd())
+ # if this fails, use try the directory of the sasview module
+ return os.path.dirname(sas.__file__)
- # Finally, try the directory of the sasview module
- # TODO: gui_manager will have to know about sasview until we
- # clean all these module variables and put them into a config class
- # that can be passed by sasview.py.
- # logging.info(sys.executable)
- # logging.info(str(sys.argv))
- from sas import sasview as sasview
- app_path = os.path.dirname(sasview.__file__)
- # logging.info("Using application path: %s", app_path)
- return app_path
-
-def get_user_directory():
- """
- Returns the user's home directory
- """
- userdir = os.path.join(os.path.expanduser("~"), ".sasview")
- if not os.path.isdir(userdir):
- os.makedirs(userdir)
- return userdir
-
-def _find_local_config(confg_file, path):
- """
- Find configuration file for the current application
- """
- config_module = None
- fObj = None
- try:
- fObj, path_config, descr = imp.find_module(confg_file, [path])
- config_module = imp.load_module(confg_file, fObj, path_config, descr)
- except ImportError:
- pass
- except ValueError:
- print("Value error")
- pass
- finally:
- if fObj is not None:
- fObj.close()
- return config_module
# Get APP folder
-PATH_APP = get_app_dir()
-DATAPATH = PATH_APP
+PATH_APP = get_sensible_default_open_directory()
+
# Read in the local config, which can either be with the main
# application or in the installation directory
# config = _find_local_config('local_config', PATH_APP)
@@ -150,10 +110,7 @@ def _find_local_config(confg_file, path):
config.DEFAULT_OPEN_FOLDER = PATH_APP
-#DEFAULT_STYLE = config.DEFAULT_STYLE
-
PLUGIN_STATE_EXTENSIONS = config.PLUGIN_STATE_EXTENSIONS
-OPEN_SAVE_MENU = config.OPEN_SAVE_PROJECT_MENU
VIEW_MENU = config.VIEW_MENU
EDIT_MENU = config.EDIT_MENU
extension_list = []
diff --git a/src/sas/qtgui/Utilities/UnitTesting/GuiUtilsTest.py b/src/sas/qtgui/Utilities/UnitTesting/GuiUtilsTest.py
index 1736cff5d8..dbd55ed011 100644
--- a/src/sas/qtgui/Utilities/UnitTesting/GuiUtilsTest.py
+++ b/src/sas/qtgui/Utilities/UnitTesting/GuiUtilsTest.py
@@ -46,12 +46,6 @@ def testGetAppDir(self):
"""
pass
- def testGetUserDirectory(self):
- """
- Simple test of user directory getter
- """
- home_dir = os.path.expanduser("~")
- self.assertIn(home_dir, get_user_directory())
def testCommunicate(self):
"""
From 92da71d27e9b3a68715e220421d056aa658113f0 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Thu, 15 Sep 2022 15:22:32 +0100
Subject: [PATCH 60/82] Cleaned some of GuiUtils and removed more config
entries
---
src/sas/qtgui/MainWindow/DataExplorer.py | 6 ++-
src/sas/qtgui/Plotting/SlicerParameters.py | 3 +-
src/sas/qtgui/Utilities/GuiUtils.py | 50 ++--------------------
src/sas/system/config/config.py | 8 ----
4 files changed, 10 insertions(+), 57 deletions(-)
diff --git a/src/sas/qtgui/MainWindow/DataExplorer.py b/src/sas/qtgui/MainWindow/DataExplorer.py
index d2b830116c..2b39df65dd 100644
--- a/src/sas/qtgui/MainWindow/DataExplorer.py
+++ b/src/sas/qtgui/MainWindow/DataExplorer.py
@@ -1312,7 +1312,11 @@ def readData(self, path):
for index, p_file in enumerate(path):
basename = os.path.basename(p_file)
_, extension = os.path.splitext(basename)
- if extension.lower() in GuiUtils.EXTENSIONS:
+ extension_list = config.PLUGIN_STATE_EXTENSIONS
+ if config.APPLICATION_STATE_EXTENSION is not None:
+ extension_list.append(config.APPLICATION_STATE_EXTENSION)
+
+ if extension.lower() in extension_list:
any_error = True
log_msg = "Data Loader cannot "
log_msg += "load: %s\n" % str(p_file)
diff --git a/src/sas/qtgui/Plotting/SlicerParameters.py b/src/sas/qtgui/Plotting/SlicerParameters.py
index e1ee338dd5..b1bca0945f 100644
--- a/src/sas/qtgui/Plotting/SlicerParameters.py
+++ b/src/sas/qtgui/Plotting/SlicerParameters.py
@@ -21,6 +21,7 @@
from sasdata.file_converter.nxcansas_writer import NXcanSASWriter
# Local UI
from sas.qtgui.Plotting.UI.SlicerParametersUI import Ui_SlicerParametersUI
+from sas import config
class SlicerParameters(QtWidgets.QDialog, Ui_SlicerParametersUI):
@@ -44,7 +45,7 @@ def __init__(self, parent=None,
self.model = model
self.validate_method = validate_method
self.active_plots = active_plots
- self.save_location = GuiUtils.DEFAULT_OPEN_FOLDER
+ self.save_location = config.DEFAULT_OPEN_FOLDER
self.communicator = communicator
# Initially, Apply is disabled
diff --git a/src/sas/qtgui/Utilities/GuiUtils.py b/src/sas/qtgui/Utilities/GuiUtils.py
index 1a1d8b546b..cfe7670ba0 100644
--- a/src/sas/qtgui/Utilities/GuiUtils.py
+++ b/src/sas/qtgui/Utilities/GuiUtils.py
@@ -48,9 +48,6 @@
from sas import config
from sasdata.dataloader.loader import Loader
-from sasdata.file_converter.nxcansas_writer import NXcanSASWriter
-
-from sas.qtgui.Utilities import CustomDir
if os.path.splitext(sys.argv[0])[1].lower() != ".py":
HELP_DIRECTORY_LOCATION = "doc"
@@ -82,51 +79,10 @@ def get_sensible_default_open_directory():
return os.path.dirname(sas.__file__)
-
-# Get APP folder
-PATH_APP = get_sensible_default_open_directory()
-
-# Read in the local config, which can either be with the main
-# application or in the installation directory
-# config = _find_local_config('local_config', PATH_APP)
-#
-# if config is None:
-# config = _find_local_config('local_config', os.getcwd())
-# else:
-# pass
-
-
-#read some constants from config
-
-SAS_OPENCL = config.SAS_OPENCL
# custom open_path
-open_folder = config.DEFAULT_OPEN_FOLDER
-if open_folder is not None and os.path.isdir(open_folder):
- DEFAULT_OPEN_FOLDER = os.path.abspath(open_folder)
-else:
- DEFAULT_OPEN_FOLDER = PATH_APP
-
-if config.DEFAULT_OPEN_FOLDER != "":
- config.DEFAULT_OPEN_FOLDER = PATH_APP
-
-
-PLUGIN_STATE_EXTENSIONS = config.PLUGIN_STATE_EXTENSIONS
-VIEW_MENU = config.VIEW_MENU
-EDIT_MENU = config.EDIT_MENU
-extension_list = []
-if config.APPLICATION_STATE_EXTENSION is not None:
- extension_list.append(config.APPLICATION_STATE_EXTENSION)
-EXTENSIONS = PLUGIN_STATE_EXTENSIONS + extension_list
-try:
- PLUGINS_WLIST = '|'.join(config.PLUGINS_WLIST)
-except AttributeError:
- PLUGINS_WLIST = ''
-APPLICATION_WLIST = config.APPLICATION_WLIST
-IS_WIN = True
-IS_LINUX = False
-CLOSE_SHOW = True
-TIME_FACTOR = 2
-NOT_SO_GRAPH_LIST = ["BoxSum"]
+if config.DEFAULT_OPEN_FOLDER == "" or not os.path.isdir(config.DEFAULT_OPEN_FOLDER):
+ config.DEFAULT_OPEN_FOLDER = get_sensible_default_open_directory()
+
class Communicate(QtCore.QObject):
diff --git a/src/sas/system/config/config.py b/src/sas/system/config/config.py
index fc4dfe35fb..98cc0ed26f 100644
--- a/src/sas/system/config/config.py
+++ b/src/sas/system/config/config.py
@@ -138,8 +138,6 @@ class Config(ConfigBase, metaclass=ConfigMeta):
def __init__(self):
super().__init__()
- # Flag for automated testing
- # self.__TEST__ = False
# edit the list of file state your plugin can read
self.APPLICATION_WLIST = 'SasView files (*.svs)|*.svs'
@@ -158,12 +156,6 @@ def __init__(self):
'Corfunc files (*.crf)']
self.SHOW_WELCOME_PANEL = False
- # OPEN and SAVE project menu
- self.OPEN_SAVE_PROJECT_MENU = True
- # VIEW MENU
- self.VIEW_MENU = True
- # EDIT MENU
- self.EDIT_MENU = True
From c9a070d5d7222c61cc94900789e1ab789cd67176 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Thu, 15 Sep 2022 15:25:30 +0100
Subject: [PATCH 61/82] Removed CustomDir.py
---
src/sas/qtgui/Utilities/CustomDir.py | 56 ----------------------------
1 file changed, 56 deletions(-)
delete mode 100755 src/sas/qtgui/Utilities/CustomDir.py
diff --git a/src/sas/qtgui/Utilities/CustomDir.py b/src/sas/qtgui/Utilities/CustomDir.py
deleted file mode 100755
index 8ca8ebe4b2..0000000000
--- a/src/sas/qtgui/Utilities/CustomDir.py
+++ /dev/null
@@ -1,56 +0,0 @@
-# Setup and find Custom config dir
-import os.path
-from sas import config
-
-def _find_usersasview_dir():
- """
- Find and return user/.sasview dir
- """
- return os.path.join(os.path.expanduser("~"), ("." + config.APPLICATION_NAME))
-
-def _find_customconf_dir():
- """
- Find path of the config directory.
- The plugin directory is located in the user's home directory.
- """
- u_dir = _find_usersasview_dir()
- return os.path.join(u_dir, config.CONF_DIR)
-
-def setup_conf_dir(path):
- raise RuntimeError("Tried to call setup_conf_dir")
- # """
- # Setup the custom config dir and cat file
- # """
- # conf_dir = _find_customconf_dir()
- # # If the plugin directory doesn't exist, create it
- # if not os.path.isdir(conf_dir):
- # os.makedirs(conf_dir)
- # config_file = os.path.join(conf_dir, "custom_config.py")
- #
- # # Place example user models as needed
- # try:
- # if not os.path.isfile(config_file):
- # shutil.copyfile(os.path.join(path, "custom_config.py"), config_file)
- #
- # #Adding SAS_OPENCL if it doesn't exist in the config file
- # # - to support backcompability
- # if not "SAS_OPENCL" in open(config_file).read():
- # open(config_file,"a+").write("SAS_OPENCL = \"None\"\n")
- # except:
- # # Check for data path next to exe/zip file.
- # #Look for maximum n_dir up of the current dir to find plugins dir
- # n_dir = 12
- # is_dir = False
- # f_dir = path
- # for i in range(n_dir):
- # if i > 1:
- # f_dir, _ = os.path.split(f_dir)
- # temp_path = os.path.join(f_dir, "custom_config.py")
- # if os.path.isfile(temp_path):
- # shutil.copyfile(temp_path, config_file)
- # is_dir = True
- # break
- # if not is_dir:
- # raise
- # return conf_dir
- #
From 4780943191d53150f242dc439ae11e8dba045ff7 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Thu, 15 Sep 2022 15:44:10 +0100
Subject: [PATCH 62/82] Update web links
---
src/sas/system/web.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/sas/system/web.py b/src/sas/system/web.py
index feb442666d..bd1b9afd0e 100644
--- a/src/sas/system/web.py
+++ b/src/sas/system/web.py
@@ -1,6 +1,6 @@
class WebLinks:
def __init__(self):
- self.nist_url = "https://www.nist.gov/"
+ self.nist_url = "https://www.nist.gov/ncnr"
self.umd_url = "https://www.umd.edu/"
self.sns_url = "https://neutrons.ornl.gov/"
self.nsf_url = "https://www.nsf.gov"
@@ -14,7 +14,7 @@ def __init__(self):
self.diamond_url = "http://www.diamond.ac.uk"
self.homepage_url = "https://www.sasview.org"
- self.download_url = 'https://github.com/SasView/sasview/releases'
+ self.download_url = 'https://github.com/SasView/sasview/releases/latest'
self.marketplace_url = "http://marketplace.sasview.org/"
self.update_url = 'https://www.sasview.org/latestversion.json'
From b7a6b2e187ba4460f6e720c3fb8e90cd87c4f8a4 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Thu, 15 Sep 2022 15:59:03 +0100
Subject: [PATCH 63/82] Fixed build number issues
---
.github/workflows/docs.yml | 2 +-
.github/workflows/installers.yml | 2 +-
.github/workflows/release.yml | 2 +-
.github/workflows/test.yml | 2 +-
build_tools/release_automation.py | 1 +
src/sas/system/version.py | 1 +
6 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index 1536843af9..ba524e15bc 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -93,7 +93,7 @@ jobs:
run: |
# SET SASVIEW GITHASH
githash=$( git rev-parse HEAD )
- sed -i.bak s/GIT_COMMIT/$githash/g src/sas/sasview/__init__.py
+ sed -i.bak s/GIT_COMMIT/$githash/g src/sas/system/version.py
# BUILD SASVIEW
python setup.py clean
python setup.py build
diff --git a/.github/workflows/installers.yml b/.github/workflows/installers.yml
index e1200344dc..77fcd44b58 100644
--- a/.github/workflows/installers.yml
+++ b/.github/workflows/installers.yml
@@ -144,7 +144,7 @@ jobs:
run: |
# SET SASVIEW GITHASH
githash=$( git rev-parse HEAD )
- sed -i.bak s/GIT_COMMIT/$githash/g src/sas/sasview/__init__.py
+ sed -i.bak s/GIT_COMMIT/$githash/g src/sas/system/version.py
# BUILD SASVIEW
python setup.py clean
python setup.py build
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 1f86936993..c962b2a21b 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -146,7 +146,7 @@ jobs:
run: |
# SET SASVIEW GITHASH
githash=$( git rev-parse HEAD )
- sed -i.bak s/GIT_COMMIT/$githash/g src/sas/sasview/__init__.py
+ sed -i.bak s/GIT_COMMIT/$githash/g src/sas/system/version.py
# BUILD SASVIEW
python setup.py clean
python setup.py build
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index d67f169b2e..ca2fda6cde 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -107,7 +107,7 @@ jobs:
run: |
# SET SASVIEW GITHASH
githash=$( git rev-parse HEAD )
- sed -i.bak s/GIT_COMMIT/$githash/g src/sas/sasview/__init__.py
+ sed -i.bak s/GIT_COMMIT/$githash/g src/sas/system/version.py
# BUILD SASVIEW
python setup.py clean
python setup.py build
diff --git a/build_tools/release_automation.py b/build_tools/release_automation.py
index 73b5943f34..cfb8508ad5 100644
--- a/build_tools/release_automation.py
+++ b/build_tools/release_automation.py
@@ -141,6 +141,7 @@ def generate_zenodo(sasview_data, zenodo_api_key):
__version__ = "%s"
__release_date__ = "%i"
+__build__ = "GIT_COMMIT"
StrictVersion(__version__)
"""
diff --git a/src/sas/system/version.py b/src/sas/system/version.py
index f6c31d1a75..0ca23f807f 100644
--- a/src/sas/system/version.py
+++ b/src/sas/system/version.py
@@ -2,5 +2,6 @@
__version__ = "5.0.5"
__release_date__ = "2022"
+__build__ = "GIT_COMMIT"
StrictVersion(__version__)
From 69d1d9551795be2f846b800d8791c698a5675104 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Thu, 15 Sep 2022 16:05:08 +0100
Subject: [PATCH 64/82] Fixed version location in setup
---
setup.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/setup.py b/setup.py
index 534c312f25..8bb1cb7fbc 100644
--- a/setup.py
+++ b/setup.py
@@ -14,13 +14,14 @@
from setuptools import setup
# Manage version number ######################################
-with open(os.path.join("src", "sas", "sasview", "__init__.py")) as fid:
+version_file = os.path.join("src", "sas", "system", "version.py")
+with open(version_file) as fid:
for line in fid:
if line.startswith('__version__'):
VERSION = line.split('"')[1]
break
else:
- raise ValueError("Could not find version in src/sas/sasview/__init__.py")
+ raise ValueError(f"Could not find version in {version_file}")
##############################################################
package_dir = {}
From 6b6527af2a409d6ebb3e97ed44d466ee73e730f3 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Fri, 16 Sep 2022 09:43:19 +0100
Subject: [PATCH 65/82] Removed hide toolbar text
---
src/sas/qtgui/MainWindow/GuiManager.py | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/sas/qtgui/MainWindow/GuiManager.py b/src/sas/qtgui/MainWindow/GuiManager.py
index 8f4563cd0b..3727b7df83 100644
--- a/src/sas/qtgui/MainWindow/GuiManager.py
+++ b/src/sas/qtgui/MainWindow/GuiManager.py
@@ -181,8 +181,7 @@ def addWidgets(self):
self.results_panel.windowClosedSignal.connect(lambda: self.results_frame.setVisible(False))
self._workspace.toolBar.setVisible(config.TOOLBAR_SHOW)
- self._workspace.actionHide_Toolbar.setText("Show Toolbar")
-
+
# Add calculators - floating for usability
self.SLDCalculator = SldPanel(self)
self.DVCalculator = DensityPanel(self)
From 7ca5d50f32f10b87d1cd2579d859b6746f7e9541 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Mon, 26 Sep 2022 08:50:14 +0100
Subject: [PATCH 66/82] Fixed version
---
src/sas/qtgui/MainWindow/PackageGatherer.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/sas/qtgui/MainWindow/PackageGatherer.py b/src/sas/qtgui/MainWindow/PackageGatherer.py
index be7d7ef968..b5fc3159b5 100644
--- a/src/sas/qtgui/MainWindow/PackageGatherer.py
+++ b/src/sas/qtgui/MainWindow/PackageGatherer.py
@@ -147,7 +147,7 @@ def get_imported_packages(self):
if hasattr(package, '__version__'):
# Module has __version__ attribute
try:
- package_versions_dict[package_name] = sas.system.version.__version__
+ package_versions_dict[package_name] = package.__version__
continue
except Exception as e:
# Unable to access module
From 576eacc0ed545b13a251d6666a841cb6b0f848d2 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Mon, 26 Sep 2022 08:52:05 +0100
Subject: [PATCH 67/82] Delft URL
---
src/sas/system/web.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/sas/system/web.py b/src/sas/system/web.py
index bd1b9afd0e..ae09f4f126 100644
--- a/src/sas/system/web.py
+++ b/src/sas/system/web.py
@@ -9,7 +9,8 @@ def __init__(self):
self.ill_url = "https://www.ill.eu/"
self.ansto_url = "https://www.ansto.gov.au/"
self.bam_url = "http://www.bam.de/"
- self.delft_url = "http://www.tudelft.nl/en/tnw/business/facilities/reactor-instituut-delft/"
+ self.delft_url = \
+ "https://www.tudelft.nl/en/faculty-of-applied-sciences/business/facilities/reactor-institute-delft"
self.inst_url = "https://www.utk.edu"
self.diamond_url = "http://www.diamond.ac.uk"
From 6656884e046ecb6ce52030c46c6e665239436a9d Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Mon, 26 Sep 2022 08:55:09 +0100
Subject: [PATCH 68/82] Moved sas.system.user import
---
run.py | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/run.py b/run.py
index 55626da346..065b80c37a 100644
--- a/run.py
+++ b/run.py
@@ -20,8 +20,6 @@
from os.path import abspath, dirname, realpath, join as joinpath
from contextlib import contextmanager
-import sas.system.user
-
PLUGIN_MODEL_DIR = 'plugin_models'
def addpath(path):
@@ -54,6 +52,7 @@ def setup_sasmodels():
"""
# Set SAS_MODELPATH so sasmodels can find our custom models
import sas
+ import sas.system.user
plugin_dir = os.path.join(sas.system.user.get_user_dir(), PLUGIN_MODEL_DIR)
os.environ['SAS_MODELPATH'] = plugin_dir
From 38957fe0459d133103103e8630c3c51ca58260f5 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Mon, 26 Sep 2022 08:56:48 +0100
Subject: [PATCH 69/82] Changed import again
---
run.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/run.py b/run.py
index 065b80c37a..9c1aa05819 100644
--- a/run.py
+++ b/run.py
@@ -51,9 +51,9 @@ def setup_sasmodels():
Prepare sasmodels for running within sasview.
"""
# Set SAS_MODELPATH so sasmodels can find our custom models
- import sas
- import sas.system.user
- plugin_dir = os.path.join(sas.system.user.get_user_dir(), PLUGIN_MODEL_DIR)
+
+ from sas.system.user import get_user_dir
+ plugin_dir = os.path.join(get_user_dir(), PLUGIN_MODEL_DIR)
os.environ['SAS_MODELPATH'] = plugin_dir
def prepare():
From ea5ce84bdb24750ff2c0f22fa7da1161466f28ae Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Mon, 26 Sep 2022 09:01:43 +0100
Subject: [PATCH 70/82] Removed strict version requirement - isn't really
necessary
---
build_tools/release_automation.py | 4 ----
run.py | 2 +-
src/sas/system/version.py | 3 ---
3 files changed, 1 insertion(+), 8 deletions(-)
diff --git a/build_tools/release_automation.py b/build_tools/release_automation.py
index cfb8508ad5..06377e3a8e 100644
--- a/build_tools/release_automation.py
+++ b/build_tools/release_automation.py
@@ -137,13 +137,9 @@ def generate_zenodo(sasview_data, zenodo_api_key):
version_template = \
"""
-from distutils.version import StrictVersion
-
__version__ = "%s"
__release_date__ = "%i"
__build__ = "GIT_COMMIT"
-
-StrictVersion(__version__)
"""
zenodo_template = '__DOI__ = "%s"'
diff --git a/run.py b/run.py
index 9c1aa05819..4fd65f4c53 100644
--- a/run.py
+++ b/run.py
@@ -51,7 +51,7 @@ def setup_sasmodels():
Prepare sasmodels for running within sasview.
"""
# Set SAS_MODELPATH so sasmodels can find our custom models
-
+
from sas.system.user import get_user_dir
plugin_dir = os.path.join(get_user_dir(), PLUGIN_MODEL_DIR)
os.environ['SAS_MODELPATH'] = plugin_dir
diff --git a/src/sas/system/version.py b/src/sas/system/version.py
index 0ca23f807f..1cd06c4312 100644
--- a/src/sas/system/version.py
+++ b/src/sas/system/version.py
@@ -1,7 +1,4 @@
-from distutils.version import StrictVersion
-
__version__ = "5.0.5"
__release_date__ = "2022"
__build__ = "GIT_COMMIT"
-StrictVersion(__version__)
From a6f233998c7587e19f73ea2a6efa6174d8020116 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Mon, 26 Sep 2022 09:06:59 +0100
Subject: [PATCH 71/82] Attempt to fix images issue
---
setup.py | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/setup.py b/setup.py
index 8bb1cb7fbc..3e1519f978 100644
--- a/setup.py
+++ b/setup.py
@@ -230,6 +230,11 @@ def run(self):
"src", "sas", "qtgui", "Perspectives", "Corfunc", "UI")
packages.extend(["sas.qtgui.Perspectives.Corfunc", "sas.qtgui.Perspectives.Corfunc.UI"])
+
+package_dir["sas.qtgui.images"] = os.path.join(
+ "src", "sas", "qtgui", "images")
+packages.append("sas.qtgui.images")
+
## Plotting
package_dir["sas.qtgui.Plotting"] = os.path.join(
"src", "sas", "qtgui", "Plotting")
From 0323f5f03c1fc0c8e06b831014da139b2202cc4d Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Wed, 28 Sep 2022 09:44:56 +0100
Subject: [PATCH 72/82] Rename web._licence to something not totally weird
---
src/sas/qtgui/MainWindow/AboutBox.py | 2 +-
src/sas/qtgui/MainWindow/UnitTesting/AboutBoxTest.py | 2 +-
src/sas/system/web.py | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/sas/qtgui/MainWindow/AboutBox.py b/src/sas/qtgui/MainWindow/AboutBox.py
index fac573d81b..582e633c6f 100644
--- a/src/sas/qtgui/MainWindow/AboutBox.py
+++ b/src/sas/qtgui/MainWindow/AboutBox.py
@@ -50,7 +50,7 @@ def addText(self):
Comments? Bugs? Requests?
- Send us a ticket
+ Send us a ticket
diff --git a/src/sas/qtgui/MainWindow/UnitTesting/AboutBoxTest.py b/src/sas/qtgui/MainWindow/UnitTesting/AboutBoxTest.py
index e5f7c5311e..8363b0b053 100644
--- a/src/sas/qtgui/MainWindow/UnitTesting/AboutBoxTest.py
+++ b/src/sas/qtgui/MainWindow/UnitTesting/AboutBoxTest.py
@@ -59,7 +59,7 @@ def testAbout(self):
# URLs
self.assertIn(str(web.homepage_url), about.text())
self.assertIn(str(config.download_url), about.text())
- self.assertIn(str(config._license), about.text())
+ self.assertIn(str(config.help_email), about.text())
# Are links enabled?
self.assertTrue(about.openExternalLinks())
diff --git a/src/sas/system/web.py b/src/sas/system/web.py
index ae09f4f126..bfdf4cc200 100644
--- a/src/sas/system/web.py
+++ b/src/sas/system/web.py
@@ -19,7 +19,7 @@ def __init__(self):
self.marketplace_url = "http://marketplace.sasview.org/"
self.update_url = 'https://www.sasview.org/latestversion.json'
- self._license = "help@sasview.org" # TODO: Rename
+ self.help_email = "help@sasview.org"
web = WebLinks()
From 488540bbc421b0ee1ef4a55ef2fc9699d9b48ae1 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Wed, 28 Sep 2022 09:47:57 +0100
Subject: [PATCH 73/82] __version__ import fix
---
src/sas/qtgui/MainWindow/MainWindow.py | 6 ++----
src/sas/qtgui/MainWindow/UnitTesting/GuiManagerTest.py | 3 ---
2 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/src/sas/qtgui/MainWindow/MainWindow.py b/src/sas/qtgui/MainWindow/MainWindow.py
index 44eb6b9fe9..330c66aace 100644
--- a/src/sas/qtgui/MainWindow/MainWindow.py
+++ b/src/sas/qtgui/MainWindow/MainWindow.py
@@ -4,9 +4,8 @@
import os
import sys
-from ...system.version import __version__ as SASVIEW_VERSION
from sas import config
-from sas.system import env
+from sas.system import env, version
from PyQt5.QtWidgets import QMainWindow
from PyQt5.QtWidgets import QMdiArea
@@ -26,8 +25,7 @@ def __init__(self, screen_resolution, parent=None):
self.setupUi(self)
# Add the version number to window title
- self.setWindowTitle(f"SasView {SASVIEW_VERSION}")
-
+ self.setWindowTitle(f"SasView {version.__version__}")
# define workspace for dialogs.
self.workspace = QMdiArea(self)
# some perspectives are fixed size.
diff --git a/src/sas/qtgui/MainWindow/UnitTesting/GuiManagerTest.py b/src/sas/qtgui/MainWindow/UnitTesting/GuiManagerTest.py
index 48a01eb0a4..f4190c42ae 100644
--- a/src/sas/qtgui/MainWindow/UnitTesting/GuiManagerTest.py
+++ b/src/sas/qtgui/MainWindow/UnitTesting/GuiManagerTest.py
@@ -10,9 +10,6 @@
from PyQt5 import QtCore
from unittest.mock import MagicMock
-# set up import paths
-import path_prepare
-
# Local
from sas.qtgui.MainWindow.DataExplorer import DataExplorerWindow
from sas.qtgui.MainWindow.AboutBox import AboutBox
From f26c4bc50bbe2120068c39cdefa3f86045a85fe6 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Wed, 28 Sep 2022 09:55:41 +0100
Subject: [PATCH 74/82] Changed version import
---
src/sas/qtgui/Utilities/FileConverter.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/sas/qtgui/Utilities/FileConverter.py b/src/sas/qtgui/Utilities/FileConverter.py
index 97b82161eb..bcca50d41d 100644
--- a/src/sas/qtgui/Utilities/FileConverter.py
+++ b/src/sas/qtgui/Utilities/FileConverter.py
@@ -23,7 +23,7 @@
import sas.qtgui.Utilities.GuiUtils as GuiUtils
from sas.qtgui.Utilities.FrameSelect import FrameSelect
-from ...system.version import __version__ as SASVIEW_VERSION
+from sas.system import version
from .UI.FileConverterUI import Ui_FileConverterUI
@@ -284,7 +284,7 @@ def readMetadata(self):
'detector': [self.getDetectorMetadata()],
'sample': self.getSampleMetadata(),
'source': self.getSourceMetadata(),
- 'notes': [f'Data file generated by SasView v{SASVIEW_VERSION}'],
+ 'notes': [f'Data file generated by SasView v{version.__version__}'],
}
self.metadata = metadata
From 5b172b836b30b23edf88dfecc46b9e4369c1c821 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Mon, 10 Oct 2022 10:32:46 +0100
Subject: [PATCH 75/82] Weaker config requirements, pretty print
---
src/sas/system/config/config_meta.py | 36 +++++++++++++++-------------
src/sas/system/log.py | 2 --
src/sas/system/user.py | 5 ++--
3 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/src/sas/system/config/config_meta.py b/src/sas/system/config/config_meta.py
index 63157cc0be..86efcc311b 100644
--- a/src/sas/system/config/config_meta.py
+++ b/src/sas/system/config/config_meta.py
@@ -1,4 +1,4 @@
-from typing import Dict, Any, List
+from typing import Dict, Any, List, Set
import os
import logging
import json
@@ -6,6 +6,7 @@
import sas
import sas.system.version
+from sas.system import user
from sas.system.config.schema_elements import create_schema_element, CoercionError, SchemaElement
logger = logging.getLogger("sas.config")
@@ -42,9 +43,15 @@ def __init__(self):
self._schema: Dict[str, SchemaElement] = {}
self._defaults: Dict[str, SchemaElement] = {}
self._deleted_attributes: List[str] = []
- self._write_disabled = False
+ self._bad_entries: Dict[str, Any] = {}
self._meta_attributes = ["_locked", "_schema", "_defaults",
- "_deleted_attributes", "_meta_attributes", "_write_disabled"]
+ "_deleted_attributes", "_meta_attributes",
+ "_bad_keys"]
+
+ def config_filename(self, create_if_nonexistent=False):
+ """Filename for saving config items"""
+ version_parts = sas.system.version.__version__.split(".")
+ return os.path.join(user.get_user_dir(create_if_nonexistent), f"config-{version_parts[0]}.json")
def finalise(self):
""" Call this at the end of the config to make this class 'final'
@@ -61,6 +68,7 @@ def update(self, data: Dict[str, Any]):
# Skip over any deleted attributes
if key in self._deleted_attributes:
+ self._bad_entries[key] = data[key]
continue
# Check the variable is in the schema
@@ -74,20 +82,17 @@ def update(self, data: Dict[str, Any]):
logger.error(f"Cannot set set variable '{key}', improper type ({e.message})")
else:
- logger.error(f"Unknown config key: '{key}', skipping")
+ logger.warning(f"Unknown config key: '{key}', skipping")
+ self._bad_entries[key] = data[key]
def save(self):
- if self._write_disabled:
- logger.error("Write disabled, this is probably because it will overwrite an outdated config.")
- return
-
- with open("config.json", 'w') as file:
+ with open(self.config_filename(True), 'w') as file:
self.save_to_file_object(file)
def save_to_file_object(self, file):
""" Save config file
- Only changed variables will be included in the saved file
+ Only changed and unknown variables will be included in the saved file
"""
data = {}
for key in self._defaults:
@@ -96,16 +101,18 @@ def save_to_file_object(self, file):
if new_value != old_value:
data[key] = new_value
+ data.update(self._bad_entries)
+
output_data = {
"sasview_version": sas.system.version.__version__,
"config_data": data}
- json.dump(output_data, file)
+ json.dump(output_data, file, indent=2)
def load(self):
- filename = "config.json"
+ filename = self.config_filename(False)
if os.path.exists(filename):
- with open("config.json", 'r') as file:
+ with open(filename, 'r') as file:
self.load_from_file_object(file)
def load_from_file_object(self, file):
@@ -138,7 +145,6 @@ def load_from_file_object(self, file):
if int(file_major_version) != int(sasview_major_version):
logger.warning(f"Attempting to used outdated config file (config is"
f" for {file_version}, this SasView version is {sas.system.version.__version__})")
- self._write_disabled = True
self.update(data["config_data"])
@@ -176,8 +182,6 @@ def __setattr__(self, key, value):
if key not in self.__dict__:
raise ConfigLocked("New attribute attempt")
-
-
super().__setattr__(key, value)
diff --git a/src/sas/system/log.py b/src/sas/system/log.py
index bfc4451220..c16840d8db 100644
--- a/src/sas/system/log.py
+++ b/src/sas/system/log.py
@@ -8,8 +8,6 @@
import pkg_resources
-from sas import config
-
'''
Module that manages the global logging
'''
diff --git a/src/sas/system/user.py b/src/sas/system/user.py
index 4fda655def..96cc6b9f40 100644
--- a/src/sas/system/user.py
+++ b/src/sas/system/user.py
@@ -12,13 +12,14 @@ def make_user_dir():
return path
-def get_user_dir():
+def get_user_dir(create_if_nonexistent=True):
"""
The directory where the per-user configuration is stored.
Returns ~/.sasview, creating it if it does not already exist.
"""
global _USER_DIR
- if not _USER_DIR:
+ if create_if_nonexistent and not _USER_DIR:
_USER_DIR = make_user_dir()
return _USER_DIR
+
From 554567f6573900a129371d8abb43e2820f414da9 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Mon, 10 Oct 2022 10:33:50 +0100
Subject: [PATCH 76/82] Removed config entries from logger
---
src/sas/system/log.py | 6 ------
1 file changed, 6 deletions(-)
diff --git a/src/sas/system/log.py b/src/sas/system/log.py
index c16840d8db..77dabb0362 100644
--- a/src/sas/system/log.py
+++ b/src/sas/system/log.py
@@ -38,15 +38,9 @@ def config_development(self):
logger = logging.getLogger(self.name)
self._update_all_logs_to_debug(logger)
logging.captureWarnings(True)
- self._disable_debug_from_config()
logging.getLogger('matplotlib').setLevel(logging.WARN)
return logger
- def _disable_debug_from_config(self):
- '''disable DEBUG logs as per user configuration (DEBUG logs disabled by default)'''
- if config.FILTER_DEBUG_LOGS:
- logging.disable(logging.DEBUG)
-
def _read_config_file(self):
if self.config_file is not None:
logging.config.fileConfig(self.config_file)
From 728e21098907d191776948a2daf9e5ea86dcad7d Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Mon, 10 Oct 2022 10:46:34 +0100
Subject: [PATCH 77/82] Bugfix
---
src/sas/system/config/config_meta.py | 12 ++++++++++--
src/sas/system/config/schema_elements.py | 2 +-
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/sas/system/config/config_meta.py b/src/sas/system/config/config_meta.py
index 86efcc311b..ea0809cf99 100644
--- a/src/sas/system/config/config_meta.py
+++ b/src/sas/system/config/config_meta.py
@@ -46,12 +46,16 @@ def __init__(self):
self._bad_entries: Dict[str, Any] = {}
self._meta_attributes = ["_locked", "_schema", "_defaults",
"_deleted_attributes", "_meta_attributes",
- "_bad_keys"]
+ "_bad_entries"]
def config_filename(self, create_if_nonexistent=False):
"""Filename for saving config items"""
version_parts = sas.system.version.__version__.split(".")
- return os.path.join(user.get_user_dir(create_if_nonexistent), f"config-{version_parts[0]}.json")
+ user_dir = user.get_user_dir(create_if_nonexistent)
+ if user_dir is None:
+ return None
+ else:
+ return os.path.join(user_dir, f"config-{version_parts[0]}.json")
def finalise(self):
""" Call this at the end of the config to make this class 'final'
@@ -111,6 +115,10 @@ def save_to_file_object(self, file):
def load(self):
filename = self.config_filename(False)
+
+ if filename is None:
+ return
+
if os.path.exists(filename):
with open(filename, 'r') as file:
self.load_from_file_object(file)
diff --git a/src/sas/system/config/schema_elements.py b/src/sas/system/config/schema_elements.py
index 3154b3c03b..51f7ec0382 100644
--- a/src/sas/system/config/schema_elements.py
+++ b/src/sas/system/config/schema_elements.py
@@ -177,7 +177,7 @@ def create_schema_element(name: str, value, recursion_depth: int=10) -> SchemaEl
return SchemaStr()
else:
- raise SchemaError(f"Config element is not a bool, int, float, str, or a homogeneous list thereof ({value})")
+ raise SchemaError(f"Config element is not a bool, int, float, str, or a homogeneous list thereof ({name}={value})")
def schema_union(elements: List[SchemaElement]):
From 9e8f789fadcd6d49ab29d73b024985742b6154fd Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Mon, 10 Oct 2022 11:40:29 +0100
Subject: [PATCH 78/82] Save to user dir
---
src/sas/qtgui/MainWindow/MainWindow.py | 3 ++-
.../qtgui/Perspectives/Fitting/GPUOptions.py | 3 +++
src/sas/system/config/config_meta.py | 11 ++++-------
src/sas/system/env.py | 12 ++++++++----
src/sas/system/user.py | 17 +++++------------
5 files changed, 22 insertions(+), 24 deletions(-)
diff --git a/src/sas/qtgui/MainWindow/MainWindow.py b/src/sas/qtgui/MainWindow/MainWindow.py
index 330c66aace..6a81d6bcce 100644
--- a/src/sas/qtgui/MainWindow/MainWindow.py
+++ b/src/sas/qtgui/MainWindow/MainWindow.py
@@ -83,7 +83,8 @@ def run_sasview():
# Set open cl config from environment variable, if it is set
if "SAS_OPENCL" in os.environ:
logging.getLogger(__name__).info("Getting OpenCL settings from environment variables")
- config.SAS_OPENCL = env.sas_opencl
+ if env.SAS_OPENCL != "none":
+ config.SAS_OPENCL = env.sas_opencl
else:
logging.getLogger(__name__).info("Getting OpenCL settings from config")
env.sas_opencl = config.SAS_OPENCL
diff --git a/src/sas/qtgui/Perspectives/Fitting/GPUOptions.py b/src/sas/qtgui/Perspectives/Fitting/GPUOptions.py
index 8abd142ff4..e972f71bf6 100644
--- a/src/sas/qtgui/Perspectives/Fitting/GPUOptions.py
+++ b/src/sas/qtgui/Perspectives/Fitting/GPUOptions.py
@@ -82,6 +82,9 @@ def add_options(self):
radio_button.setObjectName(_fromUtf8(descr))
radio_button.setText(_translate("GPUOptions", descr, None))
self.optionsLayout.addWidget(radio_button)
+
+ print(title, config.SAS_OPENCL)
+
if title.lower() == config.SAS_OPENCL.lower():
radio_button.setChecked(True)
diff --git a/src/sas/system/config/config_meta.py b/src/sas/system/config/config_meta.py
index ea0809cf99..22ce37cf1e 100644
--- a/src/sas/system/config/config_meta.py
+++ b/src/sas/system/config/config_meta.py
@@ -52,10 +52,7 @@ def config_filename(self, create_if_nonexistent=False):
"""Filename for saving config items"""
version_parts = sas.system.version.__version__.split(".")
user_dir = user.get_user_dir(create_if_nonexistent)
- if user_dir is None:
- return None
- else:
- return os.path.join(user_dir, f"config-{version_parts[0]}.json")
+ return os.path.join(user_dir, f"config-{version_parts[0]}.json")
def finalise(self):
""" Call this at the end of the config to make this class 'final'
@@ -116,13 +113,13 @@ def save_to_file_object(self, file):
def load(self):
filename = self.config_filename(False)
- if filename is None:
- return
-
if os.path.exists(filename):
with open(filename, 'r') as file:
self.load_from_file_object(file)
+ else:
+ logger.warning(f"No config file found - one will be created when sasview exits")
+
def load_from_file_object(self, file):
""" Load config file """
data = json.load(file)
diff --git a/src/sas/system/env.py b/src/sas/system/env.py
index e1063cc5bd..9ff4018666 100644
--- a/src/sas/system/env.py
+++ b/src/sas/system/env.py
@@ -4,28 +4,32 @@
"""
import os
import logging
+from typing import Optional
class Envrironment:
logger = logging.getLogger(__name__)
@property
- def sas_opencl(self) -> str:
+ def sas_opencl(self) -> Optional[str]:
"""
Get the value of the environment variable SAS_OPENCL, which specifies which OpenCL device
should be used.
"""
- return os.environ.get("SAS_OPENCL", "none")
+ if "SAS_OPENCL" in os.environ:
+ return os.environ.get("SAS_OPENCL", "none")
+ else:
+ return None
@sas_opencl.setter
- def sas_opencl(self, value: str):
+ def sas_opencl(self, value: Optional[str]):
"""
Set the value of the environment variable SAS_OPENCL
"""
- if value.lower() == "none":
+ if value is None or value.lower() == "none":
if "SAS_OPENCL" in os.environ:
del os.environ["SAS_OPENCL"]
else:
diff --git a/src/sas/system/user.py b/src/sas/system/user.py
index 96cc6b9f40..86df6c3a54 100644
--- a/src/sas/system/user.py
+++ b/src/sas/system/user.py
@@ -1,15 +1,6 @@
import os
-_USER_DIR = None
-
-def make_user_dir():
- """
- Create the user directory ~/.sasview if it doesn't already exist.
- """
- path = os.path.join(os.path.expanduser("~"),'.sasview')
- if not os.path.exists(path):
- os.mkdir(path)
- return path
+_USER_DIR = os.path.join(os.path.expanduser("~"), '.sasview')
def get_user_dir(create_if_nonexistent=True):
@@ -19,7 +10,9 @@ def get_user_dir(create_if_nonexistent=True):
Returns ~/.sasview, creating it if it does not already exist.
"""
global _USER_DIR
- if create_if_nonexistent and not _USER_DIR:
- _USER_DIR = make_user_dir()
+
+ if create_if_nonexistent and not os.path.exists(_USER_DIR):
+ os.mkdir(_USER_DIR)
+
return _USER_DIR
From 45ad22a3a442787d78ef4c5a08d1fbc89f4decf2 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Mon, 10 Oct 2022 11:50:41 +0100
Subject: [PATCH 79/82] Updated utest to reflect change in logging level
---
test/config/utest_config.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/test/config/utest_config.py b/test/config/utest_config.py
index 2bbb029344..87bedc448c 100644
--- a/test/config/utest_config.py
+++ b/test/config/utest_config.py
@@ -82,7 +82,7 @@ def test_valid_update(self):
def test_invalid_update_bad_name(self):
- """ Check that an error is logged when there is a bad name in the config"""
+ """ Check that a warning is logged when there is a bad name in the config"""
config = Config()
@@ -94,9 +94,9 @@ def test_invalid_update_bad_name(self):
name += "x"
# try and set it
- with self.assertLogs('sas.config', level="ERROR") as cm:
+ with self.assertLogs('sas.config', level="WARNING") as cm:
config.update({name: None})
- self.assertTrue(cm.output[0].startswith("ERROR:sas.config:"))
+ self.assertTrue(cm.output[0].startswith("WARNING:sas.config:"))
def test_invalid_update_bad_type(self):
From d06a9f08fe4f3736f5b44f49821c73db4c27c9a2 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Mon, 10 Oct 2022 15:11:14 +0100
Subject: [PATCH 80/82] Removed debugging print statement
---
src/sas/qtgui/Perspectives/Fitting/GPUOptions.py | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/sas/qtgui/Perspectives/Fitting/GPUOptions.py b/src/sas/qtgui/Perspectives/Fitting/GPUOptions.py
index e972f71bf6..0297630002 100644
--- a/src/sas/qtgui/Perspectives/Fitting/GPUOptions.py
+++ b/src/sas/qtgui/Perspectives/Fitting/GPUOptions.py
@@ -83,8 +83,6 @@ def add_options(self):
radio_button.setText(_translate("GPUOptions", descr, None))
self.optionsLayout.addWidget(radio_button)
- print(title, config.SAS_OPENCL)
-
if title.lower() == config.SAS_OPENCL.lower():
radio_button.setChecked(True)
From 74bbe1245d90c4ae83a828324a8aa3e6a92c072e Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Tue, 11 Oct 2022 14:52:17 +0100
Subject: [PATCH 81/82] Updated web links to https
---
src/sas/system/web.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/sas/system/web.py b/src/sas/system/web.py
index bfdf4cc200..50d8040b20 100644
--- a/src/sas/system/web.py
+++ b/src/sas/system/web.py
@@ -8,7 +8,7 @@ def __init__(self):
self.ess_url = "https://europeanspallationsource.se/"
self.ill_url = "https://www.ill.eu/"
self.ansto_url = "https://www.ansto.gov.au/"
- self.bam_url = "http://www.bam.de/"
+ self.bam_url = "https://www.bam.de/"
self.delft_url = \
"https://www.tudelft.nl/en/faculty-of-applied-sciences/business/facilities/reactor-institute-delft"
self.inst_url = "https://www.utk.edu"
@@ -16,7 +16,7 @@ def __init__(self):
self.homepage_url = "https://www.sasview.org"
self.download_url = 'https://github.com/SasView/sasview/releases/latest'
- self.marketplace_url = "http://marketplace.sasview.org/"
+ self.marketplace_url = "https://marketplace.sasview.org/"
self.update_url = 'https://www.sasview.org/latestversion.json'
self.help_email = "help@sasview.org"
From db897fbdd5cbb8b19102708f805e4b97f0ac04e9 Mon Sep 17 00:00:00 2001
From: lucas-wilkins
Date: Wed, 12 Oct 2022 12:19:27 +0100
Subject: [PATCH 82/82] Updated MainWindow config-env stuff
---
src/sas/qtgui/MainWindow/MainWindow.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/sas/qtgui/MainWindow/MainWindow.py b/src/sas/qtgui/MainWindow/MainWindow.py
index 6a81d6bcce..875332ea1f 100644
--- a/src/sas/qtgui/MainWindow/MainWindow.py
+++ b/src/sas/qtgui/MainWindow/MainWindow.py
@@ -81,10 +81,10 @@ def run_sasview():
get_user_dir(), "compiled_models")
# Set open cl config from environment variable, if it is set
- if "SAS_OPENCL" in os.environ:
+
+ if env.sas_opencl is not None:
logging.getLogger(__name__).info("Getting OpenCL settings from environment variables")
- if env.SAS_OPENCL != "none":
- config.SAS_OPENCL = env.sas_opencl
+ config.SAS_OPENCL = env.sas_opencl
else:
logging.getLogger(__name__).info("Getting OpenCL settings from config")
env.sas_opencl = config.SAS_OPENCL