Closed paul-1 closed 5 months ago
Hi Paul, I need to check for this. I've never had problem with this approach. Differently, I had rights issue at the time those two files were cloned from the remote repository, and the robot attempting to write on those.
It does not happen every time. It feels like there are multiple writes to the same file going on. One common result is the closing } getting repeated twice. I also saw values that were in the GUI as 3.1 getting written as “3”
Sent from my iPhone
On Mar 18, 2024, at 1:30 PM, Andrea @.***> wrote:
Hi Paul, I need to check for this. I've never had problem with this approach. Differently, I had rights issue at the time those two files were cloned from the remote repository, and the robot attempting to write on those.
— Reply to this email directly, view it on GitHubhttps://github.com/AndreaFavero71/cubotino/issues/25#issuecomment-2004529060, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABRMN4LEKLBGYVCZCHKDBN3YY4QELAVCNFSM6AAAAABE2NAHXKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMBUGUZDSMBWGA. You are receiving this because you authored the thread.Message ID: @.***>
Ah, then I know: It happens when writing on the same file with less characters than the initial file: The old } remains right after the new inserted one.
After each
f.write(json.dumps(whaterver_filename, indent=0))
Please add
f.truncate()
I'll test at my side, please give it a test at yours :-)
Hi Paul, the settings are saved in the Json files as string The settings reppresenting values are converted, to integers or to floats, when imported by the Cubotino_T_settings.manager.py In don't have an explanation about value 3.1 at GUI and "3" at the Json file, but the other way around is possible: Most of the sliders have steps larger than 0.01 (i.e. 0.02) while some default settings are for instance at 0.33 (legacy from before the GUI time).
For the issue you have raise, double } }, it can be reproduced sistematically:
I'm going to commit a fix.
Okay, the update seems to fix the bad json, so now the files are getting written properly. I should could not remember which slider was wrong when I responded today (I was at work)
But the error is in 'warp_slicing' and the problem is reading the slider as an int. https://github.com/AndreaFavero71/cubotino/blob/bce2f8f3f826e9d64b74439d2aa6d9244493a5a6/src/Cubotino_T_servos_GUI.py#L634
Hi paul, you're sharp and right. The warp_slicing parameter is meant to be a float while the slider in takes as integer; This mistake is there since day one of the GUI, 18th April 2023. This error isn't critic, I'll push the correction once something else will require a commit.
Correction is applied b01a6ec56089ce0dfbc9d7d62913982ef89324f2
I'm using the GUI to tune my servos. When saving from the GUI, I'm seeing values getting written wrong, and sometimes after writing, the file is no longer able to be read, as the json has a corrupt format. I believe it is because of conflicting open calls like this.
https://github.com/AndreaFavero71/cubotino/blob/e5fcf2e7af7ece9f6fb719ae576c74a5f2e58baa/src/Cubotino_T_settings_manager.py#L360
This is mixing python native file operations with low level os file routines. I'm not even sure how its working, but they are not compatible. I would recommend you just use the python open() commands. Those work with the context manager that you are using.