Commit 7facb94c authored by Guillaume Seguin's avatar Guillaume Seguin

Move format_time and format_duration to printrun_utils

parent b0160015
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
import os import os
import sys import sys
import gettext import gettext
import datetime
# Set up Internationalization using gettext # Set up Internationalization using gettext
# searching for installed locales on /usr/share; uses relative folder if not # searching for installed locales on /usr/share; uses relative folder if not
...@@ -77,6 +78,12 @@ def decode_utf8(s): ...@@ -77,6 +78,12 @@ def decode_utf8(s):
pass pass
return s return s
def format_time(timestamp):
return datetime.datetime.fromtimestamp(timestamp).strftime("%H:%M:%S")
def format_duration(delta):
return str(datetime.timedelta(seconds = int(delta)))
class RemainingTimeEstimator(object): class RemainingTimeEstimator(object):
drift = None drift = None
......
...@@ -20,7 +20,6 @@ import Queue ...@@ -20,7 +20,6 @@ import Queue
import re import re
import sys import sys
import time import time
import datetime
import threading import threading
import traceback import traceback
import cStringIO as StringIO import cStringIO as StringIO
...@@ -49,7 +48,7 @@ layerindex = 0 ...@@ -49,7 +48,7 @@ layerindex = 0
if os.name == "nt": if os.name == "nt":
winsize = (800, 530) winsize = (800, 530)
from printrun.printrun_utils import iconfile, configfile from printrun.printrun_utils import iconfile, configfile, format_time, format_duration
from printrun.gui import MainWindow from printrun.gui import MainWindow
from printrun.excluder import Excluder from printrun.excluder import Excluder
from pronsole import dosify, wxSetting, HiddenSetting, StringSetting, SpinSetting, FloatSpinSetting, BooleanSetting, StaticTextSetting from pronsole import dosify, wxSetting, HiddenSetting, StringSetting, SpinSetting, FloatSpinSetting, BooleanSetting, StaticTextSetting
...@@ -61,12 +60,6 @@ def parse_temperature_report(report): ...@@ -61,12 +60,6 @@ def parse_temperature_report(report):
matches = tempreport_exp.findall(report) matches = tempreport_exp.findall(report)
return dict((m[0], (m[1], m[2])) for m in matches) return dict((m[0], (m[1], m[2])) for m in matches)
def format_time(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):
self.stdout = sys.stdout self.stdout = sys.stdout
......
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