From 3543e7d71643f3e94a41add14bdd3223ec0cf329 Mon Sep 17 00:00:00 2001 From: Andreas Freise <adf@star.bham.ac.uk> Date: Wed, 22 Apr 2015 11:12:50 +0100 Subject: [PATCH] fixing some python2/3 errors --- pykat/finesse.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pykat/finesse.py b/pykat/finesse.py index f9eac77..7075a2e 100644 --- a/pykat/finesse.py +++ b/pykat/finesse.py @@ -47,7 +47,6 @@ import collections import re import copy - try: # Python 2 from itertools import izip_longest @@ -1074,9 +1073,7 @@ class kat(object): if len(line) > 0: # remove any ANSI commands - #ansi = re.compile(r'\x1b[^m]*m') - #line = ansi.sub('', line) - line = re.sub(br'\x1b[^m]*m', '', line, re.UNICODE) + line = re.sub(br'\x1b[^m]*m',b'', line, re.UNICODE) # warnings and errors start with an asterisk # so if verbose show them @@ -1100,7 +1097,7 @@ class kat(object): sys.stdout.write(str(line,'utf-8')) elif line.rstrip().endswith(b'%'): - vals = line.split("-") + vals = line.split(b'-') action = vals[0].strip() prc = vals[1].strip()[:] @@ -1123,8 +1120,10 @@ class kat(object): for line in _out[::-1]: if line.lstrip().startswith('computation time:'): - r.runtime = float(line.split(":")[1].replace("s","")) - + try: + r.runtime = float(line.split(":")[1].replace("s","")) + except: + r.runtime = 0.0 if printout == 1: print (out) else: -- GitLab