1515# GNU General Public License for more details.
1616
1717import sys , os , linuxcnc , hashlib
18+ import shutil # for backup of tooltable
1819datadir = os .path .abspath (os .path .dirname (__file__ ))
1920KEYWORDS = ['S' ,'T' , 'P' , 'X' , 'Y' , 'Z' , 'A' , 'B' , 'C' , 'U' , 'V' , 'W' , 'D' , 'I' , 'J' , 'Q' , ';' ]
2021
@@ -330,6 +331,7 @@ def save(self,widget):
330331 self .warning_dialog (line_number )
331332 return
332333
334+ shutil .copy (self .toolfile , self .toolfile + ".bak" )
333335 file = open (self .toolfile , "w" )
334336 #print self.toolfile
335337 for row in liststore :
@@ -345,7 +347,11 @@ def save(self,widget):
345347 line = line + "%s%s " % (KEYWORDS [num ],test )
346348 else :
347349 test = i .lstrip () # localized floats
348- line = line + "%s%s " % (KEYWORDS [num ], locale .atof (test ))
350+ try :
351+ line = line + "%s%s " % (KEYWORDS [num ], locale .atof (test ))
352+ except ValueError :
353+ raise ExceptionMessage ("\n \n " + _ ("Error converting a float with the given localization setting. A backup file has been created: "
354+ + self .toolfile + ".bak" ))
349355
350356 print (line , file = file )
351357 # These lines are required to make sure the OS doesn't cache the data
@@ -694,6 +700,12 @@ def on_tree_navigate_key_press(self, treeview, event, filter):
694700 else :
695701 pass
696702
703+ class ExceptionMessage (Exception ):
704+ """ Exception to display a Message as an Eception.
705+ Usage: raise ExceptionMessage(<message>)
706+ """
707+ def __init__ (self , message ):
708+ super ().__init__ (message )
697709
698710# for testing without glade editor:
699711# for what ever reason tooledit always shows both display lists,
0 commit comments