Open Poikilos opened 2 years ago
- otherwise it could be doing anything from replacing the entire GUI to launching a rocket into space and no one would know whether to be surprised.
If there is a rocket launch script on a computer ... https://quotefancy.com/quote/985524/Anton-Chekhov-If-there-is-a-gun-hanging-on-the-wall-in-the-first-act-it-must-fire-in-the
If you do it that way, then custombnt.txt will just get moved again and again (the backup will be lost). I suggest:
if not os.path.exists("custombtn.old"):
os.rename("custombtn.txt", "custombtn.old")
# else ignore it. Overwriting below is OK since a backup exists.
rco = open("custombtn.txt", "w")
rco.write(_("# I moved all your custom buttons into .pronsolerc.\n# Please don't add them here any more.\n# Backup of your old buttons is in custombtn.old\n"))
Regarding rockstorm101's comment that I pasted into the original post:
cbutton_save
(save new) then os.rename
(backup old)).configfile
to find it. Is "~/.printrun/" really where custombtn.txt used to be?If yes, then maybe rename configfile
to old_configpath
for clarity. There could be a new configfile
function, sure, but it is never used anywhere else (the appdirs
module's user_config_dir
function appears to take the place of it), and the code you pointed out only needs the old one.
IMO all of these functions ending in file
should be renamed to end in path
to make the function names self-explanatory: When I was first reading the code they appeared to be IO functions from the context, but they return a path not a file handle.
If you do it that way, then custombnt.txt will just get moved again and again (the backup will be lost).
Probably not, i think this will guard against it https://github.com/kliment/Printrun/blob/65ec26827191f2e08b932614ecaeee27ab497dbb/printrun/pronterface.py#L197-L198 See https://github.com/kliment/Printrun/issues/1236 for a probably broken custombtns.
IMO all of these functions ending in
file
should be renamed to end inpath
to make the function names self-explanatory
I sometimes want to rename functions, but refrain because I am afraid that some references can be missed. Have you used a tool that you are confident it won't break code.
Yeah, if people may use those functions for custombtns or other extensibility, I agree renaming them isn't good. So is it clear whether the "~/.printrun/" directory used in configfile
is the real old directory? Or is the real old directory something like
. . . AFAIK pronterface/pronsole look for a config file in either
~/.config/Printrun/pronsolerc
,~/.pronsolerc
or~/printrunconf.ini
"
?
Does anyone know?
cutombtn.txt has been deprecated for years. I think it's okay to break it now - it was there to migrate people's configurations so they wouldn't lose their macros when we deprecated it. All of those should now be migrated, so let's drop it.
As noted on PR #1285 (but unrelated to it):
printrun/utils.py
-rockstorm101
As soon as someone figures out what custombtn.txt is and whether arbitrary code execution is even safe or expected here, we can figure out what to do:
grep "custombtn\.txt" -r
in the main branch) is not even very helpful:(Those two messages are also translated into 5 languages in pot and po files, but of course that doesn't say anything new...)