Skip to content

Commit

Permalink
Fixed configuration to work on new installations.
Browse files Browse the repository at this point in the history
This error was introduced in 0.6.5 when transitioning away from JSON5.
When a config file is not found, use default config as intended.
  • Loading branch information
mliberty1 committed Oct 9, 2019
1 parent ebef127 commit 2aff982
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
This file contains the list of changes made to pyjoulescope_ui.


## 0.6.6

2019 Oct 9

* Fixed configuration to work on new installations (error introduced in 0.6.5).


## 0.6.5

2019 Oct 9
Expand Down
4 changes: 2 additions & 2 deletions joulescope.iss
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
; http://www.jrsoftware.org/ishelp/index.php?topic=setup_signtool

#define MyAppName "Joulescope"
#define MyAppVersion "0.6.5"
#define MyAppVersionUnderscores "0_6_5"
#define MyAppVersion "0.6.6"
#define MyAppVersionUnderscores "0_6_6"
#define MyAppPublisher "Jetperch LLC"
#define MyAppURL "https://www.joulescope.com"
#define MyAppExeName "joulescope.exe"
Expand Down
2 changes: 2 additions & 0 deletions joulescope_ui/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ def load_config(config_def, path=None, default_on_error=None):
if os.path.isfile(p):
path = p
break
if path is None:
path = '__not_found__'
if not isinstance(path, str):
cfg = json.load(path)
elif not os.path.isfile(path):
Expand Down
15 changes: 15 additions & 0 deletions joulescope_ui/test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io
import tempfile
import shutil
import joulescope_ui.config
from joulescope_ui.config import load_config_def, load_config, save_config

MYPATH = os.path.dirname(os.path.abspath(__file__))
Expand Down Expand Up @@ -89,11 +90,25 @@ def test_filename(self):
class TestConfigSave(unittest.TestCase):

def setUp(self):
self._CONFIG_PATH_LIST = joulescope_ui.config.CONFIG_PATH_LIST
self._tempdir = tempfile.mkdtemp()
self._filename1 = os.path.join(self._tempdir, 'joulescope_config.json5')

def tearDown(self):
shutil.rmtree(self._tempdir)
joulescope_ui.config.CONFIG_PATH_LIST = self._CONFIG_PATH_LIST

def test_load_save_search_not_found(self):
d = load_config_def()
joulescope_ui.config.CONFIG_PATH_LIST = [os.path.join(MYPATH, 'not_there.json5')]
c1 = load_config(d)
self.assertEqual('auto', c1['Device']['i_range'])

def test_load_save_search_found(self):
d = load_config_def()
joulescope_ui.config.CONFIG_PATH_LIST = [os.path.join(MYPATH, 'cfg1.json5')]
c1 = load_config(d)
self.assertEqual('180 mA', c1['Device']['i_range'])

def test_load_save_load_path(self):
d = load_config_def()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import shutil


VERSION = '0.6.5' # CHANGE THIS VERSION!
VERSION = '0.6.6' # CHANGE THIS VERSION!
JOULESCOPE_VERSION_MIN = '0.6.5' # also update requirements.txt
MYPATH = os.path.abspath(os.path.dirname(__file__))
VERSION_PATH = os.path.join(MYPATH, 'joulescope_ui', 'version.py')
Expand Down

0 comments on commit 2aff982

Please sign in to comment.