From: Ian Jackson Date: Mon, 27 Nov 2017 12:29:17 +0000 (+0000) Subject: vdbg infrastructure X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=9d9f45e555bf79d3ec25c67263335d9267512edd;p=moebius3.git vdbg infrastructure Signed-off-by: Ian Jackson --- diff --git a/helixish.py b/helixish.py index cf107ff..910e3de 100644 --- a/helixish.py +++ b/helixish.py @@ -7,7 +7,7 @@ from numpy import cos, sin import sys import subprocess -from moedebug import dbg +from moedebug import * from moenp import * from math import atan2, atan, sqrt @@ -170,6 +170,7 @@ class HelixishCurve(): l = findcurve_subproc.stdout.readline() l = l.rstrip() dbg('GOT ', l) + if not l: vdbg().crashing('findcurve EOF') l = eval(l) if l is None: break diff --git a/moedebug.py b/moedebug.py index 2e0be7a..4f1ea7c 100644 --- a/moedebug.py +++ b/moedebug.py @@ -13,3 +13,19 @@ def dbg(*args): for f in _files: print('// D ', *args, file=f) f.flush() + +class NullVisdebug(): + def curve(*a, **kw): pass + def crashing(*a, **kw): pass + +_nullvis = NullVisdebug() +_vis = [ _nullvis ] + +def vdbg(): + return _vis[0] + +def vdbg_enabled(): + return _vis[0] != _nullvis + +def vdbg_enable(vis): + _vis[0] = vis diff --git a/visual b/visual index a7d3290..95125e8 100755 --- a/visual +++ b/visual @@ -1,17 +1,32 @@ #!/usr/bin/python +from __future__ import print_function + import signal signal.signal(signal.SIGINT, signal.SIG_DFL) from visual import * from bezier import BezierSegment import numpy as np +import sys from moebius import * +from moedebug import * nv = 40 nw = 40 +class Visdebug(): + def curve(vd, fn): + # fn(t) => 3-tuple, 3-list, or similar, for t \elem [0,1] + curve(pos = [ list(fn(t)) for t in np.linspace(0,1,11) ]) + def crashing(vd, msg): + print("CRASHING - VISDEBUG", msg, file=sys.stderr) + rate(1E-8) + +dbg_file(sys.stderr) +vdbg_enable(Visdebug()) + m = Moebius(nv, nw) vs = range(0, nv+1)