From 1af6ad91085564a2302bca7155869e14cb7294e7 Mon Sep 17 00:00:00 2001 From: Rock Storm Date: Mon, 17 Feb 2025 23:06:21 +0100 Subject: [PATCH] refactor: Remove legacy custombtn and configfile (#1483) custombtn.txt was deprecated before Printrun 2.x but the code was left. The code didn't even work as expected so this potentially breaking change has a very low chance of affecting any users. Closes #1236 The `configfile` function was outdated and only used for handling custombtn.txt so it is safe to remove as well. Closes #1286 --- custombtn.txt | 17 ----------------- printrun/pronterface.py | 23 +---------------------- printrun/utils.py | 8 -------- 3 files changed, 1 insertion(+), 47 deletions(-) delete mode 100644 custombtn.txt diff --git a/custombtn.txt b/custombtn.txt deleted file mode 100644 index bc56492bf..000000000 --- a/custombtn.txt +++ /dev/null @@ -1,17 +0,0 @@ -btns=[ -###Defining custom buttons for pronterface is easy. Here's how. -###Below these instructions, add a line with the following format for each button -# ["button name","command",color(RGB)], <--That comma is important, do not forget it -###As an example: (Remove the # to try it out): -#["Read temp","M105",(200,100,100)], -#["Disable Axes","M84",(400,100,100)], -###You can use gcodes or any pronsole/pronterface commands -###The first four buttons will end up at the top of the window, visible in mini mode -###The rest of the buttons will be at the bottom under the gcode preview -###ADD BUTTON DEFINITIONS BELOW THIS LINE - - - - -###ADD BUTTON DEFINITIONS ABOVE THIS LINE -] diff --git a/printrun/pronterface.py b/printrun/pronterface.py index 59407abdc..b90df86b0 100644 --- a/printrun/pronterface.py +++ b/printrun/pronterface.py @@ -34,7 +34,7 @@ from printrun.spoolmanager import spoolmanager_gui from .utils import install_locale, setup_logging, dosify, \ - iconfile, configfile, format_time, format_duration, \ + iconfile, format_time, format_duration, \ hexcolor_to_float, parse_temperature_report, \ prepare_command, check_rgb_color, check_rgba_color, compile_file, \ write_history_to, read_history_from @@ -199,27 +199,6 @@ def __init__(self, app, filename = None, size = winsize): self.p.z_feedrate = self.settings.z_feedrate self.panel.SetBackgroundColour(self.bgcolor) - customdict = {} - try: - exec(compile_file(configfile("custombtn.txt")), customdict) - if len(customdict["btns"]): - if not len(self.custombuttons): - try: - self.custombuttons = customdict["btns"] - for n in range(len(self.custombuttons)): - self.cbutton_save(n, self.custombuttons[n]) - os.rename("custombtn.txt", "custombtn.old") - 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")) - rco.close() - except IOError as x: - logging.error(str(x)) - else: - logging.warning(_("Note!!! You have specified custom buttons in both custombtn.txt and .pronsolerc")) - logging.warning(_("Ignoring custombtn.txt. Remove all current buttons to revert to custombtn.txt")) - - except: - pass self.menustrip = wx.MenuBar() self.reload_ui() # disable all printer controls until we connect to a printer diff --git a/printrun/utils.py b/printrun/utils.py index a85e2312d..fd1764197 100644 --- a/printrun/utils.py +++ b/printrun/utils.py @@ -181,14 +181,6 @@ def sharedfile(filename): shared_pronterface_dir = os.path.join(DATADIR, 'pronterface') return lookup_file(filename, [shared_pronterface_dir]) -def configfile(filename): - ''' - Get the full path to filename by checking in the - standard configuration directory (See the lookup_file - function's documentation for behavior). - ''' - return lookup_file(filename, [os.path.expanduser("~/.printrun/"), ]) - def decode_utf8(s): """Attempt to decode a string, return the string otherwise""" if isinstance(s, bytes):