Commit 08c42443 authored by Guillaume Seguin's avatar Guillaume Seguin

Improve (and fix) time displays

parent aba88486
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
# along with Printrun. If not, see <http://www.gnu.org/licenses/>. # along with Printrun. If not, see <http://www.gnu.org/licenses/>.
import cmd, sys import cmd, sys
import glob, os, time import glob, os, time, datetime
import sys, subprocess import sys, subprocess
import math, codecs import math, codecs
from math import sqrt from math import sqrt
...@@ -178,7 +178,7 @@ def estimate_duration(g): ...@@ -178,7 +178,7 @@ def estimate_duration(g):
lastf = f lastf = f
#print "Total Duration: " #, time.strftime('%H:%M:%S', time.gmtime(totalduration)) #print "Total Duration: " #, time.strftime('%H:%M:%S', time.gmtime(totalduration))
return "{0:d} layers, ".format(int(layercount))+time.strftime('%H:%M:%S', time.gmtime(totalduration)) return "{0:d} layers, ".format(int(layercount)) + str(datetime.timedelta(seconds = int(totalduration)))
class Settings: class Settings:
#def _temperature_alias(self): return {"pla":210,"abs":230,"off":0} #def _temperature_alias(self): return {"pla":210,"abs":230,"off":0}
......
...@@ -25,7 +25,7 @@ try: ...@@ -25,7 +25,7 @@ try:
except: except:
print _("WX is not installed. This program requires WX to run.") print _("WX is not installed. This program requires WX to run.")
raise raise
import sys, glob, time, threading, traceback, cStringIO, subprocess import sys, glob, time, datetime, threading, traceback, cStringIO, subprocess
from printrun.pronterface_widgets import * from printrun.pronterface_widgets import *
...@@ -57,7 +57,10 @@ def parse_temperature_report(report, key): ...@@ -57,7 +57,10 @@ def parse_temperature_report(report, key):
return float(filter(lambda x: x.startswith(key), report.split())[0].split(":")[1].split("/")[0]) return float(filter(lambda x: x.startswith(key), report.split())[0].split(":")[1].split("/")[0])
def format_time(timestamp): def format_time(timestamp):
return time.strftime('%H:%M:%S', timestamp) return datetime.datetime.fromtimestamp(timestamp).strftime("%H:%M:%S")
def format_duration(delta):
return str(datetime.timedelta(seconds = int(delta)))
class Tee(object): class Tee(object):
def __init__(self, target): def __init__(self, target):
...@@ -188,7 +191,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -188,7 +191,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
def endcb(self): def endcb(self):
if(self.p.queueindex==0): if(self.p.queueindex==0):
print "Print ended at: " + format_time(time.time()) print "Print ended at: " + format_time(time.time())
print "and took: " + format_time(int(time.time () - self.starttime + self.extra_print_time)) print_duration = int(time.time () - self.starttime + self.extra_print_time)
print "and took: " + format_duration(print_duration)
wx.CallAfter(self.pausebtn.Disable) wx.CallAfter(self.pausebtn.Disable)
wx.CallAfter(self.printbtn.SetLabel,_("Print")) wx.CallAfter(self.printbtn.SetLabel,_("Print"))
...@@ -196,7 +200,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -196,7 +200,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
if not param: if not param:
return return
import shlex import shlex
pararray=[i.replace("$s",str(self.filename)).replace("$t", format_time(int(time.time()-self.starttime+self.extra_print_time))).encode() for i in shlex.split(param.replace("\\","\\\\").encode())] pararray=[i.replace("$s",str(self.filename)).replace("$t", format_duration(print_duration)).encode() for i in shlex.split(param.replace("\\","\\\\").encode())]
self.finalp=subprocess.Popen(pararray,stderr=subprocess.STDOUT,stdout=subprocess.PIPE) self.finalp=subprocess.Popen(pararray,stderr=subprocess.STDOUT,stdout=subprocess.PIPE)
def online(self): def online(self):
...@@ -1357,8 +1361,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1357,8 +1361,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
secondselapsed = int(time.time() - self.starttime + self.extra_print_time) secondselapsed = int(time.time() - self.starttime + self.extra_print_time)
secondsestimate = secondselapsed / fractioncomplete secondsestimate = secondselapsed / fractioncomplete
secondsremain = secondsestimate - secondselapsed secondsremain = secondsestimate - secondselapsed
string += _(" Est: %s of %s remaining | ") % (format_time(secondsremain), string += _(" Est: %s of %s remaining | ") % (format_duration(secondsremain),
format_time(secondsestimate)) format_duration(secondsestimate))
string += _(" Z: %0.2f mm") % self.curlayer string += _(" Z: %0.2f mm") % self.curlayer
wx.CallAfter(self.status.SetStatusText, string) wx.CallAfter(self.status.SetStatusText, string)
wx.CallAfter(self.gviz.Refresh) wx.CallAfter(self.gviz.Refresh)
......
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