Skip to content
Snippets Groups Projects
Commit 42810831 authored by Daniel Brown's avatar Daniel Brown
Browse files

Adding progress message to pykat output for locks

parent 258facdb
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ from __future__ import division ...@@ -3,7 +3,7 @@ from __future__ import division
from __future__ import print_function from __future__ import print_function
from __future__ import unicode_literals from __future__ import unicode_literals
__version__ = "1.0.3" __version__ = "1.0.4"
# This flag is used to switch on the gui features in pkat at import time # This flag is used to switch on the gui features in pkat at import time
USE_GUI = False USE_GUI = False
......
...@@ -1370,7 +1370,7 @@ class kat(object): ...@@ -1370,7 +1370,7 @@ class kat(object):
rethrowExceptions - if true exceptions will be thrown again rather than being excepted and calling sys.exit() rethrowExceptions - if true exceptions will be thrown again rather than being excepted and calling sys.exit()
""" """
start = datetime.datetime.now() start = time.time()
try: try:
if not hasattr(self, "xaxis") and self.noxaxis != None and self.noxaxis == False: if not hasattr(self, "xaxis") and self.noxaxis != None and self.noxaxis == False:
...@@ -1400,7 +1400,7 @@ class kat(object): ...@@ -1400,7 +1400,7 @@ class kat(object):
raise pkex.MissingFinesse() raise pkex.MissingFinesse()
if self.verbose: print ("--------------------------------------------------------------") if self.verbose: print ("--------------------------------------------------------------")
if self.verbose: print ("Running kat - Started at " + str(start)) if self.verbose: print ("Running kat - Started at " + str(datetime.datetime.fromtimestamp(start)))
if hasattr(self, "x2axis") and self.noxaxis == False: if hasattr(self, "x2axis") and self.noxaxis == False:
r = katRun2D() r = katRun2D()
...@@ -1458,17 +1458,25 @@ class kat(object): ...@@ -1458,17 +1458,25 @@ class kat(object):
p = Popen(cmd, stderr=PIPE, stdout=PIPE) p = Popen(cmd, stderr=PIPE, stdout=PIPE)
if self.verbose: if self.verbose:
pb = progressbar.ProgressBar() if self.noxaxis:
maxval = 1
else:
maxval = 100
widgets = [progressbar.Percentage(), ' | ', progressbar.ETA(), ' | ', 'Status']
pb = progressbar.ProgressBar(widgets=widgets, maxval = maxval)
fifo = None fifo = None
start = time.time() _start_kat = time.time()
duration = 2 # Duration for searching for open pipe duration = 2 # Duration for searching for open pipe
try: try:
while fifo is None: while fifo is None:
try: try:
if time.time() < start + duration: if time.time() < _start_kat + duration:
time.sleep(0.1) time.sleep(0.1)
fifo = open(pipe_name, "r") fifo = open(pipe_name, "r")
self.__looking = False self.__looking = False
...@@ -1481,7 +1489,11 @@ class kat(object): ...@@ -1481,7 +1489,11 @@ class kat(object):
self.__looking = True self.__looking = True
for line in fifo: for line in fifo:
v = line.split(":", 1)
if (sys.version_info < (3, 0)):
line = line.decode("utf8") # Make sure we're using unicode encoding
v = line.split(u":", 1)
if len(v) != 2: if len(v) != 2:
continue continue
...@@ -1490,11 +1502,12 @@ class kat(object): ...@@ -1490,11 +1502,12 @@ class kat(object):
if tag == "version": if tag == "version":
r.katVersion = line r.katVersion = line
elif tag == "progress": elif tag == "progress" and self.verbose:
var = line.split("\t") var = line.split("\t")
if len(var) == 3 and self.verbose: if len(var) == 3:
pb.currval = int(var[1]) pb.currval = int(var[1])
pb.widgets[-1] = var[0] + " " + var[2][:-1]
pb.update() pb.update()
finally: finally:
if fifo is not None: if fifo is not None:
...@@ -1666,6 +1679,7 @@ class kat(object): ...@@ -1666,6 +1679,7 @@ class kat(object):
print ("") print ("")
print ("Finished in {0:g} seconds".format(float(time.time() - start))) print ("Finished in {0:g} seconds".format(float(time.time() - start)))
def remove(self, obj): def remove(self, obj):
try: try:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment