def __init__(self,comp,width,height,total_width=-1,total_height=-1): gobject.GObject.__init__(self) if 'win' == sys.platform[:3]: (self.readfd, self.writefd) = fract4dc.pipe() else: # This is the line that was screwing Windows up.. changed to be run only on Linux, for Windows, we want to do this in fract4dc.. (self.readfd, self.writefd) = os.pipe() self.nthreads = 1 self.compiler = comp self.x = self.y = 0 self.button = 0 self.last_progress = 0.0 self.skip_updates = False self.running = False self.frozen = False # if true, don't emit signals self.site = fract4dc.fdsite_create(self.writefd) self.f = None self.try_init_fractal() self.input_add(self.readfd, self.onData) self.width = width self.height = height self.image = image.T( self.width,self.height,total_width,total_height) self.msgbuf = "" self.io_subsys = gtkio();
def __init__(self, comp, width, height, total_width=-1, total_height=-1): GObject.GObject.__init__(self) (self.readfd, self.writefd) = os.pipe() self.nthreads = 1 self.compiler = comp self.x = self.y = 0 self.button = 0 self.last_progress = 0.0 self.skip_updates = False self.running = False self.frozen = False # if true, don't emit signals self.site = fract4dc.fdsite_create(self.writefd) self.f = None self.try_init_fractal() self.input_add(self.readfd, self.onData) self.width = width self.height = height self.image = image.T( self.width, self.height, total_width, total_height) self.msgbuf = b"" self.io_subsys = gtkio()
def __init__(self, comp, width, height, total_width=-1, total_height=-1): gobject.GObject.__init__(self) if "win" == sys.platform[:3]: (self.readfd, self.writefd) = fract4dc.pipe() else: # This is the line that was screwing Windows up.. changed to be run only on Linux, for Windows, we want to do this in fract4dc.. (self.readfd, self.writefd) = os.pipe() self.nthreads = 1 self.compiler = comp self.x = self.y = 0 self.button = 0 self.last_progress = 0.0 self.skip_updates = False self.running = False self.frozen = False # if true, don't emit signals self.site = fract4dc.fdsite_create(self.writefd) self.f = None self.try_init_fractal() self.input_add(self.readfd, self.onData) self.width = width self.height = height self.image = image.T(self.width, self.height, total_width, total_height) self.msgbuf = "" self.io_subsys = gtkio()
def __init__(self,comp,width,height,total_width=-1,total_height=-1): GObject.GObject.__init__(self) (self.readfd, self.writefd) = os.pipe() self.nthreads = 1 self.compiler = comp self.x = self.y = 0 self.button = 0 self.last_progress = 0.0 self.skip_updates = False self.running = False self.frozen = False # if true, don't emit signals self.site = fract4dc.fdsite_create(self.writefd) self.f = None self.try_init_fractal() self.input_add(self.readfd, self.onData) self.width = width self.height = height self.image = image.T( self.width,self.height,total_width,total_height) self.msgbuf = b"" self.io_subsys = gtkio()
def testFDSite(self): xsize = 64 ysize = int(xsize * 3.0 / 4.0) im = image.T(xsize, ysize) (rfd, wfd) = os.pipe() site = fract4dc.fdsite_create(wfd) file = self.compileColorMandel() handle = fract4dc.pf_load(file) pfunc = fract4dc.pf_create(handle) for x in range(2): fract4dc.pf_init(pfunc, pos_params, self.color_mandel_params) cmap = fract4dc.cmap_create( [(0.0, 0, 0, 0, 255), (1 / 256.0, 255, 255, 255, 255), (1.0, 255, 255, 255, 255)]) fract4dc.calc( params=[0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], antialias=0, maxiter=100, yflip=0, nthreads=1, pfo=pfunc, cmap=cmap, auto_deepen=0, periodicity=1, render_type=0, image=im._img, site=site, asynchronous=True) while True: # read message type and size # we use a buffer here like in gtkfractal.py "onData" nb = 2 * 4 bytes = b"" while True: # wait up to 1 sec until we can read, otherwise we assume the counterpart is gone (an error ocurred on the C++ layer) r, w, e = select.select([rfd], [], [], 1) if rfd in r: temp = os.read(rfd, nb - len(bytes)) else: self.fail("no one on the other side") bytes = bytes + temp if (len(bytes) == nb): break elif temp == '': self.fail( "bad message with length %s, value %s" % (len(bytes), bytes)) (t, size) = struct.unpack("2i", bytes) # read the actual message bytes = os.read(rfd, size) if len(bytes) < size: self.fail("bad message") break msg = messages.parse(t, bytes) # if the fractal is done if msg.name == "Status" and msg.status == 0: # fract4dc.interrupt(site) break
def testFDSite(self): xsize = 64 ysize = int(xsize * 3.0/4.0) im = image.T(xsize,ysize) (rfd,wfd) = os.pipe() site = fract4dc.fdsite_create(wfd) file = self.compileColorMandel() for x in range(2): handle = fract4dc.pf_load(file) pfunc = fract4dc.pf_create(handle) fract4dc.pf_init(pfunc,pos_params,self.color_mandel_params) cmap = fract4dc.cmap_create( [(0.0,0,0,0,255), (1/256.0,255,255,255,255), (1.0, 255, 255, 255, 255)]) fract4dc.calc( params=[0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], antialias=0, maxiter=100, yflip=0, nthreads=1, pfo=pfunc, cmap=cmap, auto_deepen=0, periodicity=1, render_type=0, image=im._img, site=site, asynchronous=True) nrecved = 0 while True: if nrecved == x: #print "hit message count" fract4dc.interrupt(site) nb = 2*4 bytes = os.read(rfd,nb) if len(bytes) < nb: self.fail("bad message with length %s, value %s" % (len(bytes), bytes)) break (t,size) = struct.unpack("2i",bytes) #print "read %d, len %d" % (t,size) # read the rest of the message bytes = os.read(rfd,size) if len(bytes) < size: self.fail("bad message") break msg = messages.parse(t, bytes) #print "msg: %s" % msg.show() if msg.name == "Status" and msg.status == 0: #done #print "done" break nrecved += 1
def testFDSite(self): xsize = 64 ysize = int(xsize * 3.0 / 4.0) im = image.T(xsize, ysize) (rfd, wfd) = os.pipe() site = fract4dc.fdsite_create(wfd) file = self.compileColorMandel() for x in range(2): handle = fract4dc.pf_load(file) pfunc = fract4dc.pf_create(handle) fract4dc.pf_init(pfunc, pos_params, self.color_mandel_params) cmap = fract4dc.cmap_create([(0.0, 0, 0, 0, 255), (1 / 256.0, 255, 255, 255, 255), (1.0, 255, 255, 255, 255)]) fract4dc.calc( params=[0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], antialias=0, maxiter=100, yflip=0, nthreads=1, pfo=pfunc, cmap=cmap, auto_deepen=0, periodicity=1, render_type=0, image=im._img, site=site, asynchronous=True) nrecved = 0 while True: if nrecved == x: # print "hit message count" fract4dc.interrupt(site) nb = 2 * 4 bytes = os.read(rfd, nb) if len(bytes) < nb: self.fail("bad message with length %s, value %s" % (len(bytes), bytes)) break (t, size) = struct.unpack("2i", bytes) # print "read %d, len %d" % (t,size) # read the rest of the message bytes = os.read(rfd, size) if len(bytes) < size: self.fail("bad message") break msg = messages.parse(t, bytes) # print "msg: %s" % msg.show() if msg.name == "Status" and msg.status == 0: # done # print "done" break nrecved += 1