Commit 4728fd1f authored by Guillaume Seguin's avatar Guillaume Seguin

Factorize gcode loading in pronsole and pronterface

parent ee16eeba
...@@ -897,10 +897,14 @@ class pronsole(cmd.Cmd): ...@@ -897,10 +897,14 @@ class pronsole(cmd.Cmd):
if not os.path.exists(filename): if not os.path.exists(filename):
self.logError("File not found!") self.logError("File not found!")
return return
self.load_gcode(filename)
self.log("Loaded %s, %d lines." % (filename, len(self.fgcode)))
def load_gcode(self, filename):
self.fgcode = gcoder.GCode(open(filename, "rU"), self.fgcode = gcoder.GCode(open(filename, "rU"),
get_home_pos(self.build_dimensions_list)) get_home_pos(self.build_dimensions_list))
self.fgcode.estimate_duration()
self.filename = filename self.filename = filename
self.log("Loaded %s, %d lines." % (filename, len(self.fgcode)))
def complete_load(self, text, line, begidx, endidx): def complete_load(self, text, line, begidx, endidx):
s = line.split() s = line.split()
......
...@@ -30,8 +30,7 @@ import logging ...@@ -30,8 +30,7 @@ import logging
from . import pronsole from . import pronsole
from . import printcore from . import printcore
from printrun.printrun_utils import install_locale, setup_logging, \ from printrun.printrun_utils import install_locale, setup_logging
get_home_pos
install_locale('pronterface') install_locale('pronterface')
try: try:
...@@ -1511,8 +1510,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>.""" ...@@ -1511,8 +1510,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
fn = self.filename fn = self.filename
try: try:
self.filename = self.model_to_gcode_filename(self.filename) self.filename = self.model_to_gcode_filename(self.filename)
self.fgcode = gcoder.GCode(open(self.filename, "rU"), self.load_gcode(self.filename)
get_home_pos(self.build_dimensions_list))
if self.p.online: if self.p.online:
wx.CallAfter(self.printbtn.Enable) wx.CallAfter(self.printbtn.Enable)
...@@ -1582,8 +1580,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>.""" ...@@ -1582,8 +1580,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
self.skein(name) self.skein(name)
else: else:
self.filename = name self.filename = name
self.fgcode = gcoder.GCode(open(self.filename, "rU"), self.load_gcode(self.filename)
get_home_pos(self.build_dimensions_list))
self.statusbar.SetStatusText(_("Loaded %s, %d lines") % (name, len(self.fgcode))) self.statusbar.SetStatusText(_("Loaded %s, %d lines") % (name, len(self.fgcode)))
print _("Loaded %s, %d lines") % (name, len(self.fgcode)) print _("Loaded %s, %d lines") % (name, len(self.fgcode))
wx.CallAfter(self.printbtn.SetLabel, _("Print")) wx.CallAfter(self.printbtn.SetLabel, _("Print"))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment