Example #1
0
	def wait(self):
		"""Wait for graph to go away.."""
		try:
			self.g.wait_window(self.g)
		except:
			# effort to remove all unnamed exceptions:
			import pypedebug
			pypedebug.get_traceback(1)
			pass
Example #2
0
def drawnow(width=None, height=None):
    global HOLD, LAST, TABLE, NROWS, NCOLS, R, C
    if TABLE:
        try:
            TABLE.show(width=width, height=height)
        except:
			# [[effort to remove all unnamed exceptions:
			import pypedebug
			pypedebug.get_traceback(1)
			# effort to remove all unnamed exceptions:]]
    return None
Example #3
0
def drawnow(width=None, height=None):
    global HOLD, LAST, TABLE, NROWS, NCOLS, R, C
    if TABLE:
        try:
            TABLE.show(width=width, height=height)
        except:
            # [[effort to remove all unnamed exceptions:
            import pypedebug
            pypedebug.get_traceback(1)
            # effort to remove all unnamed exceptions:]]
    return None
Example #4
0
	def _reset(self, ev):
		try:
			self.axis_configure(XAXIS,
								min=float(self._x_axis[0]),
								max=float(self._x_axis[1]))
			self.axis_configure(YAXIS,
								min=float(self._y_axis[0]),
								max=float(self._y_axis[1]))
		except:
			# effort to remove all unnamed exceptions:
			import pypedebug
			pypedebug.get_traceback(1)
			
			self.axis_configure(XAXIS, min='', max='')
			self.axis_configure(YAXIS, min='', max='')
Example #5
0
    def save(self):
        # write to next file in pattern tmp-NNN.hoop
        try:
            nmax = 0
            for f in glob.glob('tmp-*.hoop'):
                f = int(f.split('-')[1].split('.')[0])
                nmax = max(nmax, f)
            f = 'tmp-%03d.hoop' % (nmax + 1)
            sortp = self.tdtconnx.sortparams()
            fp = open(f, 'w')
            fp.write(cPickle.dumps(sortp))
            fp.close()
            self.app.console.writenl('hoops -> %s' % f)
        except:
            warn('tdt save', 'Error saving TDT hoops');
			# [[effort to remove all unnamed exceptions:
			pypedebug.get_traceback(1)
			reporterror()
Example #6
0
	def __init__(self, app):
		self.lock = 0
		self.on = 1
		self.app = app
		self.s = None
		self.length = 100
		self.width = 10
		self.a = 0
		self.x = 100
		self.y = 100
		self.colorn = 0
		self.drift = 0
		self.drift_freq = 0.1;			# ~cycles/sec
		self.drift_amp = 50				# pixels
		self.jitter = 0
		self.xoff = 0
		self.yoff = 0
		self.blinktime = app.ts()
		self.app.udpy.xoffset = self.xoff
		self.app.udpy.yoffset = self.yoff
		self.live = 0
		self.blink = 0
		self.blink_freq = 1.0
		self.inten = 100
		self.colorstr = None
		self.barmode = BAR
		self.sfreq = 1.0
		self.rfreq = 0.0
		self.major_ax = None
		self.minor_ax = None
		self.bg = 128.0
		self.showinfo = 1
		self.probeid = None
		
		try:
			self.load()
		except:
			# [[effort to remove all unnamed exceptions:
			pypedebug.get_traceback(1)
			# effort to remove all unnamed exceptions:]]
			reporterror()
Example #7
0
def _comparedatafiles(a, b):
	"""Compare two datafile names for sorting

	Try to sort pype datafiles in descending order by file number..
	This is highly PYPE-SPECIFIC and is activated by passing keyword
	argument datafiles=1 to the Open() and SaveAs() functions below

	Pype data file names are of the form::

	  <animal_id><cell_number>.<taskname><taskversion>.<filenumber>

	eg, m0037.hmap7.002, where,

	- animal is "m"

	- task was hmap (version 7)

	- and this is the 3rd (0,1,2) datafile collected for cell m0037

	"""
	try:
		if int(a.split('.')[2]) > int(b.split('.')[2]):
			return -1
		else:
			return 1
	except (IndexError, ValueError):
		if a > b:
			return 1
		else:
			return -1
	except:
		# [[effort to remove all unnamed exceptions:
		import pypedebug
		pypedebug.get_traceback(1)
		# effort to remove all unnamed exceptions:]]
		if a > b:
			return 1
		else:
			return -1
Example #8
0
def _comparedatafiles(a, b):
    """Compare two datafile names for sorting (INTERNAL ONLY)
    
    Try to sort pype datafiles in descending order by file number..
    This is highly PYPE-SPECIFIC and is activated by passing keyword
    argument datafiles=1 to the Open() and SaveAs() functions below

    Pype data file names are of the form::
    
      <animal_id><cell_number>.<taskname><taskversion>.<filenumber>
      
    eg, m0037.hmap7.002, where,

    - animal is "m"

    - task was hmap (version 7)

    - and this is the 3rd (0,1,2) datafile collected for cell m0037
                             
    """
    try:
        if int(string.split(a, '.')[2]) > int(string.split(b, '.')[2]):
            return -1
        else:
            return 1
    except (IndexError, ValueError):
        if a > b:
            return 1
        else:
            return -1
    except:
        # [[effort to remove all unnamed exceptions:
        import pypedebug
        pypedebug.get_traceback(1)
        # effort to remove all unnamed exceptions:]]
        if a > b:
            return 1
        else:
            return -1
Example #9
0
	def display(self, bargraph, name, percent=0, cnf={}, **kw):
		x = tuple(self.x)
		if percent:
			y = []
			for d in self.y:
				if self.count > 0:
					y.append(100.0 * float(d) / float(self.count))
				else:
					y.append(0)
			y = tuple(y)
		else:
			y = tuple(self.y)

		kw['xdata'] = x
		kw['ydata'] = y
		kw['barwidth'] = self.binwidth

		try:
			apply(bargraph.element_configure, (name,), kw)
		except:
			# effort to remove all unnamed exceptions:
			import pypedebug
			pypedebug.get_traceback(1)
			apply(bargraph.element_create, (name,), kw)
Example #10
0
    def __init__(self, bufsize=-1, debug=0, fixedsize=None, ask=None):
        """Start xmgrace, reading from a pipe that we control.

        Parameters:
          bufsize -- choose the size of the buffer used in the
                     communication.  grace won't act on commands that
                     haven't been flushed from the buffer, but speed
                     should supposedly be better with some buffering.
                     The default is -1, which means use the default
                     (full) buffering.  0 would mean use no buffering.
          debug -- when set, each command that is passed to xmgrace is
                   also echoed to stderr.
          fixedsize -- if set to None, the grace window is
                       freely resizable (`-free').  Otherwise set to a
                       tuple, which will set the fixed size of the
                       grace canvas.  (I don't know what units are
                       used.###)
          ask -- if set, xmgrace will ask before doing `dangerous'
                 things, like overwriting a file or even clearing the
                 display.  Default is not to ask.
        """

        self.debug = debug
        self.fixedsize = fixedsize
        self.ask = ask

        cmd = ('xmgrace',)

        # start with no toolbars..
        cmd = cmd + ('-barebones',)

        if self.fixedsize is None:
            cmd = cmd + ('-free',)
        else:
            cmd = cmd + ('-fixed', `self.fixedsize[0]`, `self.fixedsize[1]`)

        if self.ask is None:
            cmd = cmd + ('-noask',)

        # Python, by default, ignores SIGPIPE signals anyway
        #signal.signal(signal.SIGPIPE, signal.SIG_IGN)

        # Don't exit when our child "grace" exits (which it could if
        # the user clicks on `exit'):
        signal.signal(signal.SIGCHLD, signal.SIG_IGN)

        # Make the pipe that will be used for communication:
        (fd_r, fd_w) = os.pipe()
        cmd = cmd + ('-dpipe', `fd_r`)

        # Fork the subprocess that will start grace:
        self.pid = os.fork()

        # If we are the child, replace ourselves with grace
        if self.pid == 0:
            try:
                # This whole thing is within a try block to make sure
                # the child can't escape.
                for i in range(OPEN_MAX):
                    # close everything except stdin, stdout, stderr
                    # and the read part of the pipe
                    if i not in (fd_r,0,1,2):
                        try:
                            os.close(i)
                        except OSError:
                            pass
                try:
                    os.execvp('xmgrace', cmd)
                except:
                    # [[effort to remove all unnamed exceptions:
                    import pypedebug
                    pypedebug.get_traceback(1)
                    # effort to remove all unnamed exceptions:]]
                    
                    # we have to be careful in the child process.  We
                    # don't want to throw an exception because that would
                    # allow two threads to continue running.
                    sys.stderr.write('GraceProcess: Could not start xmgrace\n')
                    os._exit(1) # exit this forked process but not the parent
            except:
                # [[effort to remove all unnamed exceptions:
                import pypedebug
                pypedebug.get_traceback(1)
                # effort to remove all unnamed exceptions:]]
        
                sys.stderr.write('Unexpected exception in child!\n')
                os._exit(2) # exit child but not parent

        # We are the parent -> keep only the writeable side of the pipe
        os.close(fd_r)

        # turn the writeable side into a buffered file object:
        self.pipe = os.fdopen(fd_w, 'w', bufsize)
Example #11
0
    def __init__(self, bufsize=-1, debug=0, fixedsize=None, ask=None):
        """Start xmgrace, reading from a pipe that we control.

        Parameters:
          bufsize -- choose the size of the buffer used in the
                     communication.  grace won't act on commands that
                     haven't been flushed from the buffer, but speed
                     should supposedly be better with some buffering.
                     The default is -1, which means use the default
                     (full) buffering.  0 would mean use no buffering.
          debug -- when set, each command that is passed to xmgrace is
                   also echoed to stderr.
          fixedsize -- if set to None, the grace window is
                       freely resizable (`-free').  Otherwise set to a
                       tuple, which will set the fixed size of the
                       grace canvas.  (I don't know what units are
                       used.###)
          ask -- if set, xmgrace will ask before doing `dangerous'
                 things, like overwriting a file or even clearing the
                 display.  Default is not to ask.
        """

        self.debug = debug
        self.fixedsize = fixedsize
        self.ask = ask

        cmd = ('xmgrace', )

        # start with no toolbars..
        cmd = cmd + ('-barebones', )

        if self.fixedsize is None:
            cmd = cmd + ('-free', )
        else:
            cmd = cmd + ('-fixed', ` self.fixedsize[0] `, ` self.fixedsize[1]
                         `)

        if self.ask is None:
            cmd = cmd + ('-noask', )

        # Python, by default, ignores SIGPIPE signals anyway
        #signal.signal(signal.SIGPIPE, signal.SIG_IGN)

        # Don't exit when our child "grace" exits (which it could if
        # the user clicks on `exit'):
        signal.signal(signal.SIGCHLD, signal.SIG_IGN)

        # Make the pipe that will be used for communication:
        (fd_r, fd_w) = os.pipe()
        cmd = cmd + ('-dpipe', ` fd_r `)

        # Fork the subprocess that will start grace:
        self.pid = os.fork()

        # If we are the child, replace ourselves with grace
        if self.pid == 0:
            try:
                # This whole thing is within a try block to make sure
                # the child can't escape.
                for i in range(OPEN_MAX):
                    # close everything except stdin, stdout, stderr
                    # and the read part of the pipe
                    if i not in (fd_r, 0, 1, 2):
                        try:
                            os.close(i)
                        except OSError:
                            pass
                try:
                    os.execvp('xmgrace', cmd)
                except:
                    # [[effort to remove all unnamed exceptions:
                    import pypedebug
                    pypedebug.get_traceback(1)
                    # effort to remove all unnamed exceptions:]]

                    # we have to be careful in the child process.  We
                    # don't want to throw an exception because that would
                    # allow two threads to continue running.
                    sys.stderr.write('GraceProcess: Could not start xmgrace\n')
                    os._exit(1)  # exit this forked process but not the parent
            except:
                # [[effort to remove all unnamed exceptions:
                import pypedebug
                pypedebug.get_traceback(1)
                # effort to remove all unnamed exceptions:]]

                sys.stderr.write('Unexpected exception in child!\n')
                os._exit(2)  # exit child but not parent

        # We are the parent -> keep only the writeable side of the pipe
        os.close(fd_r)

        # turn the writeable side into a buffered file object:
        self.pipe = os.fdopen(fd_w, 'w', bufsize)