Save & Load Configuration Not Working in Version 4.4.1?
denzchoe opened this issue · 3 comments
denzchoe commented
running Python version 3.8.11
As per the title, saving and loading configuration doesn't work.
File is created during the save attempt but it is an empty file.
The following error log was reported:
Traceback (most recent call last):
File "C:\Users\Denz\anaconda3\envs\PYBERT_Env\lib\site-packages\pybert\pybert_view.py", line 78, in do_save_cfg
pickle.dump(the_PyBertCfg, the_file)
TypeError: write() argument must be str, not bytes
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Denz\anaconda3\envs\PYBERT_Env\lib\site-packages\traitsui\qt4\ui_base.py", line 57, in perform
self.ui.do_undoable(handler.perform, self.ui.info, self.action, None)
File "C:\Users\Denz\anaconda3\envs\PYBERT_Env\lib\site-packages\traitsui\ui.py", line 655, in do_undoable
action(*args, **kw)
File "C:\Users\Denz\anaconda3\envs\PYBERT_Env\lib\site-packages\traitsui\handler.py", line 217, in perform
method(info)
File "C:\Users\Denz\anaconda3\envs\PYBERT_Env\lib\site-packages\pybert\pybert_view.py", line 83, in do_save_cfg
the_pybert.log("Exception raised by pybert.pybert_view.MyHandler.do_save_cfg().",
File "C:\Users\Denz\anaconda3\envs\PYBERT_Env\lib\site-packages\pybert\pybert.py", line 608, in log
raise exception
RuntimeError: The following error occured:
{err}
The configuration was NOT saved.
capn-freako commented
Try changing line 75 of pybert_view.py from this:
with open(dlg.path, "w") as the_file:
to this:
with open(dlg.path, "wb") as the_file:
(“w” ==> “wb”).
…-db
On Sep 15, 2021, at 7:45 PM, denzchoe ***@***.***> wrote:
running Python version 3.8.11
As per the title, saving and loading configuration doesn't work.
File is created during the save attempt but it is an empty file.
<https://user-images.githubusercontent.com/26157143/133540884-2f8c2233-80bb-4184-b785-968c7ae3856d.png>
The following error log was reported:
Traceback (most recent call last):
File "C:\Users\Denz\anaconda3\envs\PYBERT_Env\lib\site-packages\pybert\pybert_view.py", line 78, in do_save_cfg
pickle.dump(the_PyBertCfg, the_file)
TypeError: write() argument must be str, not bytes
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Denz\anaconda3\envs\PYBERT_Env\lib\site-packages\traitsui\qt4\ui_base.py", line 57, in perform
self.ui.do_undoable(handler.perform, self.ui.info, self.action, None)
File "C:\Users\Denz\anaconda3\envs\PYBERT_Env\lib\site-packages\traitsui\ui.py", line 655, in do_undoable
action(*args, **kw)
File "C:\Users\Denz\anaconda3\envs\PYBERT_Env\lib\site-packages\traitsui\handler.py", line 217, in perform
method(info)
File "C:\Users\Denz\anaconda3\envs\PYBERT_Env\lib\site-packages\pybert\pybert_view.py", line 83, in do_save_cfg
the_pybert.log("Exception raised by pybert.pybert_view.MyHandler.do_save_cfg().",
File "C:\Users\Denz\anaconda3\envs\PYBERT_Env\lib\site-packages\pybert\pybert.py", line 608, in log
raise exception
RuntimeError: The following error occured:
{err}
The configuration was NOT saved.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#93>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAH7XGXLTL2WCL3CD6ABH63UCFK5HANCNFSM5EDXRJGA>.
Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
denzchoe commented
Hi David,
I've edited the lines from the file as you have recommended. The saving feature works (i think). But the loading feature does not.
Here is the error log after trying to load it.
Traceback (most recent call last):
File "C:\Users\Denz\anaconda3\envs\PYBERT_Env\lib\site-packages\pybert\pybert_view.py", line 95, in do_load_cfg
the_PyBertCfg = pickle.load(the_file)
File "C:\Users\Denz\anaconda3\envs\PYBERT_Env\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 46: character maps to <undefined>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Denz\anaconda3\envs\PYBERT_Env\lib\site-packages\traitsui\qt4\ui_base.py", line 57, in perform
self.ui.do_undoable(handler.perform, self.ui.info, self.action, None)
File "C:\Users\Denz\anaconda3\envs\PYBERT_Env\lib\site-packages\traitsui\ui.py", line 655, in do_undoable
action(*args, **kw)
File "C:\Users\Denz\anaconda3\envs\PYBERT_Env\lib\site-packages\traitsui\handler.py", line 217, in perform
method(info)
File "C:\Users\Denz\anaconda3\envs\PYBERT_Env\lib\site-packages\pybert\pybert_view.py", line 113, in do_load_cfg
the_pybert.log("Exception raised by pybert.pybert_view.MyHandler.do_load_cfg().",
File "C:\Users\Denz\anaconda3\envs\PYBERT_Env\lib\site-packages\pybert\pybert.py", line 608, in log
raise exception
RuntimeError: The following error occured:
'charmap' codec can't decode byte 0x81 in position 46: character maps to <undefined>
The configuration was NOT loaded.
denzchoe commented
Found the fix.
According to documentation here;
https://github.com/enthought/pyface/blob/9ad6e3a73dae6a52289f8b1d04016451ac325192/pyface/image/image.py#L145
The line from here should be edited from;
Line 93 in f9678ea
to
`with open(dlg.path, "rb") as the_file:`
If anyone else can verify this, I guess the issue can be closed after the bug fix?