Skip to content

Commit

Permalink
refactor: Remove legacy custombtn and configfile
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rockstorm101 committed Feb 16, 2025
1 parent c49e3d9 commit 6a57b2f
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 47 deletions.
17 changes: 0 additions & 17 deletions custombtn.txt

This file was deleted.

23 changes: 1 addition & 22 deletions printrun/pronterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions printrun/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 6a57b2f

Please sign in to comment.