From 73055e59a8bbb109cb74d23121855ae10ec7426d Mon Sep 17 00:00:00 2001 From: Kliment Yanev Date: Sun, 15 Jul 2012 13:07:16 +0200 Subject: [PATCH] Fix math domain error in estimation code. Make crash in estimation code not block file load. Diable web interface by default. --- pronsole.py | 2 +- pronterface.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pronsole.py b/pronsole.py index c854ba1..61f7ef8 100755 --- a/pronsole.py +++ b/pronsole.py @@ -157,7 +157,7 @@ def estimate_duration(g): # then calculate the time taken to complete the remaining distance currenttravel = hypot3d(x, y, z, lastx, lasty, lastz) - distance = 2* ((lastf+f) * (f-lastf) * 0.5 ) / acceleration #2x because we have to accelerate and decelerate + distance = abs(2* ((lastf+f) * (f-lastf) * 0.5 ) / acceleration) #2x because we have to accelerate and decelerate if distance <= currenttravel and ( lastf + f )!=0 and f!=0: moveduration = 2 * distance / ( lastf + f ) currenttravel -= distance diff --git a/pronterface.py b/pronterface.py index e34beb1..aa56e75 100755 --- a/pronterface.py +++ b/pronterface.py @@ -55,10 +55,11 @@ from zbuttons import ZButtons from graph import Graph import pronsole -webavail = True +webavail = False try : - import cherrypy, webinterface - from threading import Thread + if webavail: + import cherrypy, webinterface + from threading import Thread except: print _("CherryPy is not installed. Web Interface Disabled.") webavail = False @@ -1552,7 +1553,10 @@ class PronterWindow(wx.Frame,pronsole.pronsole): self.webInterface.AddLog(_("the print goes from %f mm to %f mm in X\nand is %f mm wide\n") % (Xmin, Xmax, Xtot)) print _("the print goes from %f mm to %f mm in Y\nand is %f mm wide\n") % (Ymin, Ymax, Ytot) print _("the print goes from %f mm to %f mm in Z\nand is %f mm high\n") % (Zmin, Zmax, Ztot) - print _("Estimated duration (pessimistic): "), pronsole.estimate_duration(self.f) + try: + print _("Estimated duration (pessimistic): "), pronsole.estimate_duration(self.f) + except: + pass #import time #t0=time.time() self.gviz.clear()