コード例 #1
0
def makeBatch(images, iGrid):
    '''
	makes a batch of sprites out of images depending on if they are
	visible or not
	'''
    import pycallgraph
    pycallgraph.start_trace()
    batch = pyglet.graphics.Batch()
    sprites = []
    tiles = []
    xS = []
    yS = []
    print "Making sprite batch"
    i = 0
    for image, coords in images:
        i += 1
        print "image", i, "of", len(images)
        x, y = coords
        key = str(x) + str(y)
        if visible(image, coords):
            iGrid[key][1] = True
            sprites.append(pyglet.sprite.Sprite(image, x=x, y=y, batch=batch))
        else:
            iGrid[key][1] = False
    pycallgraph.make_dot_graph(r'C:\C9\test2.png')
    print "callgraph saved"
    return batch, sprites, iGrid
コード例 #2
0
def main():

    # Do the trace, remember the values for later
    pycallgraph.start_trace()
    import HTMLParser
    pycallgraph.stop_trace()

    # Set the edge colour to black for all examples
    pycallgraph.settings['edge_colour'] = lambda a, b: 'black'

    # Default node colouring
    pycallgraph.make_dot_graph('colours-default.png')

    # Rainbow
    pycallgraph.settings['node_colour'] = rainbow
    pycallgraph.make_dot_graph('colours-rainbow.png')

    # Greyscale
    pycallgraph.settings['node_colour'] = greyscale
    pycallgraph.make_dot_graph('colours-greyscale.png')

    # Orange/Green
    pycallgraph.settings['node_colour'] = orange_green
    pycallgraph.make_dot_graph('colours-orange-green.png')

    # Random
    pycallgraph.settings['node_colour'] = rand
    pycallgraph.make_dot_graph('colours-random.png')
コード例 #3
0
def filter_exclude():
    filter_func = pycallgraph.GlobbingFilter(exclude=['pycallgraph.*', \
        '*.secret_function'])
    pycallgraph.start_trace(filter_func=filter_func)
    banana = Banana()
    banana.eat()
    pycallgraph.make_dot_graph('filter-exclude.png')
コード例 #4
0
def filter_include():
    filter_func = pycallgraph.GlobbingFilter(include=['*.secret_function', \
        'Banana.__init__'])
    pycallgraph.start_trace(filter_func=filter_func)
    banana = Banana()
    banana.eat()
    pycallgraph.make_dot_graph('filter-include.png')
コード例 #5
0
ファイル: callgraphiti.py プロジェクト: silky/callgraphiti
    def render (self, include=None, exclude=None, **kwargs): # {{{
        """
            Actually returns an image (as png), and will reset the trace if the
            include or exclude parameters are different.
        """
        
        inc = self.last_include
        exc = self.last_exclude

        if include or include == "":
            inc = include.split(',')

        if exclude or exclude == "":
            exc = exclude.split(',')

        if inc != self.last_include or exc != self.last_exclude:
            # New trace, resetting the old one.

            pycallgraph.stop_trace()
            pycallgraph.start_trace(filter_func = self.filter_func(inc, exc), reset=True)

        pycallgraph.make_dot_graph("." + self.image_file, stop=False)

        cherrypy.response.headers['Content-Type'] = "image/png"
        f = open("." + self.image_file, "r+b")
        return f.read()
コード例 #6
0
ファイル: colours.py プロジェクト: 1bitaway/pycallgraph
def main():

    # Do the trace, remember the values for later
    pycallgraph.start_trace()
    import HTMLParser
    pycallgraph.stop_trace()

    # Set the edge colour to black for all examples
    pycallgraph.settings['edge_colour'] = lambda a, b: 'black'

    # Default node colouring
    pycallgraph.make_dot_graph('colours-default.png')

    # Rainbow
    pycallgraph.settings['node_colour'] = rainbow
    pycallgraph.make_dot_graph('colours-rainbow.png')

    # Greyscale
    pycallgraph.settings['node_colour'] = greyscale
    pycallgraph.make_dot_graph('colours-greyscale.png')

    # Orange/Green
    pycallgraph.settings['node_colour'] = orange_green
    pycallgraph.make_dot_graph('colours-orange-green.png')

    # Random
    pycallgraph.settings['node_colour'] = rand
    pycallgraph.make_dot_graph('colours-random.png')
コード例 #7
0
ファイル: profile.py プロジェクト: IvanLogvinov/soar
 def run_profile(self, app, *args, **kwargs):
     pycallgraph = self.pycallgraph
     pycallgraph.start_trace(reset=True, filter_func=self._filter)
     try:
         return app(*args, **kwargs)
     finally:
         pycallgraph.stop_trace()
コード例 #8
0
 def run_profile(self, app, *args, **kwargs):
     pycallgraph = self.pycallgraph
     pycallgraph.start_trace(reset=True, filter_func=self._filter)
     try:
         return app(*args, **kwargs)
     finally:
         pycallgraph.stop_trace()
コード例 #9
0
ファイル: import.py プロジェクト: 1bitaway/pycallgraph
def main():
    pycallgraph.settings['dont_exclude_anything'] = True
    import_list = ['pickle', 'htmllib']

    for imp in import_list:
        pycallgraph.start_trace()
        __import__(imp)
        pycallgraph.make_dot_graph('import-%s.png' % imp)
コード例 #10
0
def main():
    pycallgraph.settings['dont_exclude_anything'] = True
    import_list = ['pickle', 'htmllib']

    for imp in import_list:
        pycallgraph.start_trace()
        __import__(imp)
        pycallgraph.make_dot_graph('import-%s.png' % imp)
コード例 #11
0
 def callwrapper(*args, **kwargs):
     if not outfile: # allow deactivating
         return fn(*args, **kwargs)
     pycallgraph.start_trace()
     fn_output = fn(*args, **kwargs)
     pycallgraph.stop_trace()
     pycallgraph.make_dot_graph(outfile)
     return fn_output
コード例 #12
0
ファイル: analyse.py プロジェクト: rayman18/wydev
 def trace(*args, **kwds):
     res = None
     pycallgraph.start_trace()
     try:
         res = f(*args, **kwds)
         open(os.path.join('/tmp', '%s.dot' % f.__name__),
              'w').write(pycallgraph.get_dot(stop=self.stop_trace))
     finally:
         return res
コード例 #13
0
ファイル: Facade.py プロジェクト: Erotemic/hotspotter
 def call_graph(fac, cmd='fac.query(1)'):
     import pycallgraph
     import Image
     iom = fac.hs.iom
     logmsg('Call Graph Command: '+cmd)
     callgraph_fpath = iom.get_temp_fpath('callgraph'+cmd+'.png')
     pycallgraph.start_trace()
     eval(cmd)
     pycallgraph.stop_trace()
     pycallgraph.make_dot_graph(callgraph_fpath)
     Image.open(callgraph_fpath).show()
コード例 #14
0
ファイル: cuba_big_callgraph.py プロジェクト: JoErNanO/brian
def cuba():
    eqs = '''
    dv/dt = (ge+gi-(v+49*mV))/(20*ms) : volt
    dge/dt = -ge/(5*ms) : volt
    dgi/dt = -gi/(10*ms) : volt
    '''
    eqs = Equations(eqs)
    pycallgraph.start_trace(filter_func=ff)
    eqs.prepare()
    pycallgraph.stop_trace()
    pycallgraph.make_dot_graph('callgraphs/cuba-bigcallgraph-Equations.prepare.png')
コード例 #15
0
 def call_graph(fac, cmd='fac.query(1)'):
     import pycallgraph
     import Image
     iom = fac.hs.iom
     logmsg('Call Graph Command: ' + cmd)
     callgraph_fpath = iom.get_temp_fpath('callgraph' + cmd + '.png')
     pycallgraph.start_trace()
     eval(cmd)
     pycallgraph.stop_trace()
     pycallgraph.make_dot_graph(callgraph_fpath)
     Image.open(callgraph_fpath).show()
コード例 #16
0
def cuba():
    eqs = '''
    dv/dt = (ge+gi-(v+49*mV))/(20*ms) : volt
    dge/dt = -ge/(5*ms) : volt
    dgi/dt = -gi/(10*ms) : volt
    '''
    eqs = Equations(eqs)
    pycallgraph.start_trace(filter_func=ff)
    eqs.prepare()
    pycallgraph.stop_trace()
    pycallgraph.make_dot_graph(
        'callgraphs/cuba-bigcallgraph-Equations.prepare.png')
コード例 #17
0
            def callgraphed_application(*args, **kwargs):
                ''' Start measuring the callgraph and dispatch. '''

                global _runcount

                # start tracing right before dispatch
                pycallgraph.start_trace()
                for chunk in app(*args, **kwargs):
                    yield chunk  # exhaust app generator

                # stop tracing after request is finished
                pycallgraph.stop_trace()
                _runcount = _runcount + 1
                pycallgraph.make_dot_graph('/'.join(
                    prefix +
                    ['.profile',
                     '%s-%s-callgraph.png' % (appname, _runcount)]))
                raise StopIteration()
コード例 #18
0
ファイル: credito_performance.py プロジェクト: pacoqueen/ginn
def main():
    if PYCALLGRAPH:
        pycallgraph.start_trace()
        test_cetco()
        pycallgaph.make_dot_graph(os.path.join(os.path.dirname(__file__), 
            "..", "doc", "calcular_credito_disponible.png"))
    else:
        fechahora = time.localtime()
        fechahora = "%d%02d%02d%02d%02d%02d" % (fechahora.tm_year, 
                                                fechahora.tm_mon, 
                                                fechahora.tm_mday, 
                                                fechahora.tm_hour, 
                                                fechahora.tm_min, 
                                                fechahora.tm_sec)
        filestats = os.path.abspath(os.path.join(os.path.dirname(__file__), 
            "..", "doc", "credito_perf_%s.stats" % fechahora))
        #cProfile.run("test_cetco()", sort = 'cumulative')
        cProfile.run("test_cetco()", filestats, sort = 'cumulative')
        p = pstats.Stats(filestats)
        p.strip_dirs().sort_stats("time").print_stats("pclases", 10)
        p.strip_dirs().sort_stats("cumulative").print_stats("pclases", 10)
コード例 #19
0
    def run(self):
        '''Main code runner for testing. To set a new test, update the self.callTest attribute in __init__(). 
        '''
        fp = environLocal.getTempFile('.png')
        gf = pycallgraph.GlobbingFilter(exclude=self.excludeList)
        # create instnace; will call setup routines
        ct = self.callTest()

        # start timer
        print('starting test')
        t = common.Timer()
        t.start()

        pycallgraph.start_trace(filter_func = gf)
        ct.testFocus() # run routine

        pycallgraph.stop_trace()
        pycallgraph.make_dot_graph(fp)

        print('elpased time: %s' % t)
        # open the completed file
        environLocal.launch('png', fp)
コード例 #20
0
def makeBatch(images,iGrid):
	'''
	makes a batch of sprites out of images depending on if they are
	visible or not
	'''
	if profile:
		import pycallgraph
		pycallgraph.start_trace()
	batch = pyglet.graphics.Batch()
	sprites = []
	tiles = []
	xS = []
	yS = []
	#print"Making sprite batch"
	i = 0
	for size,coords in images:
		i+=1
		#print"image",i,"of",len(images)
		x,y = coords
		h,w = size
		key = str(x) + str(y)
		if visible(size,coords):
			iGrid[key][1] = True
			image = MainImage.get_region(x,y,w,h)
			print"x,y",x,y
			print"size",image.width,image.height
			try:
				sprites.append(pyglet.sprite.Sprite(image,x=x,y=y,batch=batch))
			except:
				print"error"
		else:
			iGrid[key][1] = False
	if profile:
		pycallgraph.make_dot_graph(r'C:\C9\test.png')
		print "callgraph saved"
		sys.exit()
	return batch,sprites,iGrid
コード例 #21
0
class UrlTest(unittest.TestCase):
    def setUp(self):
        # Every test needs access to the request factory.
        self.factory = RequestFactory()
        self.client = Client()
        self.user = User.objects.get(id=1)
        self.staff_client = TestClient()
        self.staff_client.login_user(self.user)

    def test_homepage(self):
        ''' Homepage: unit '''
        url = os.environ.get('URL', reverse('home'))
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response._is_rendered, True)
        if hasattr(self, 'n'):
            self.i += 1
            print_progress(self.i, self.n, "Homepage: benchmark ... ")

    def test_homepage_bench(self):
        ''' Homepage: benchmark '''
        n = os.environ.get('BENCHMARK')
        graph = os.environ.get('GRAPH')
        if not n:
            print 'no benchmark ',
            sys.stdout.flush()
            return
        try:
            self.n = int(n)
            self.i = 0
        except Exception, err:
            print err
        try:
            from compressor.storage import default_storage
            default_storage.entries
        except:
            pass
        if graph:
            try:
                import pycallgraph
                pycallgraph.start_trace(filter_func=pycall_django_filter)
            except:
                print "install pycallgraph to draw profiling graph"
                graph = None
        t = timeit.timeit(self.test_homepage, setup=self.setUp, number=self.n)
        if graph:
            pycallgraph.make_dot_graph('test_homepage_bench.png')
        print ' ... {0:.1f} ms/view '.format((t / self.n) * 1000),
        sys.stdout.flush()
コード例 #22
0
def cuba():
    N = 4000
    Ne = int(N * 0.8)
    Ni = N - Ne
    p = 80. / N

    eqs = '''
    dv/dt = (ge+gi-(v+49*mV))/(20*ms) : volt
    dge/dt = -ge/(5*ms) : volt
    dgi/dt = -gi/(10*ms) : volt
    '''

    pycallgraph.start_trace(filter_func=ff_nomagicstateupdater)
    P = NeuronGroup(N, eqs, threshold=-50 * mV, reset=-60 * mV)
    pycallgraph.stop_trace()
    pycallgraph.make_dot_graph(
        'callgraphs/cuba-bigcallgraph-NeuronGroup.__init__.no_magic_state_updater.png'
    )

    P.v = -60 * mV + 10 * mV * rand(len(P))
    Pe = P.subgroup(Ne)
    Pi = P.subgroup(Ni)

    pycallgraph.start_trace(filter_func=ff)
    Ce = Connection(Pe, P, 'ge', weight=1.62 * mV, sparseness=p)
    pycallgraph.stop_trace()
    pycallgraph.make_dot_graph(
        'callgraphs/cuba-bigcallgraph-Connection.__init__.png')

    Ci = Connection(Pi, P, 'gi', weight=-9 * mV, sparseness=p)

    pycallgraph.start_trace(filter_func=ff)
    M = SpikeMonitor(P)
    trace = StateMonitor(P, 'v', record=0)
    pycallgraph.stop_trace()
    pycallgraph.make_dot_graph(
        'callgraphs/cuba-bigcallgraph-Monitors.__init__.png')

    pycallgraph.start_trace(filter_func=ff_prepare)
    run(.1 * ms)
    pycallgraph.stop_trace()
    pycallgraph.make_dot_graph('callgraphs/cuba-bigcallgraph-run-prepare.png')
コード例 #23
0
ファイル: cuba_big_callgraph.py プロジェクト: JoErNanO/brian
def cuba():
    N = 4000
    Ne = int(N * 0.8)
    Ni = N - Ne
    p = 80. / N

    eqs = '''
    dv/dt = (ge+gi-(v+49*mV))/(20*ms) : volt
    dge/dt = -ge/(5*ms) : volt
    dgi/dt = -gi/(10*ms) : volt
    '''

    pycallgraph.start_trace(filter_func=ff_nomagicstateupdater)
    P = NeuronGroup(N, eqs,
                  threshold= -50 * mV, reset= -60 * mV)
    pycallgraph.stop_trace()
    pycallgraph.make_dot_graph('callgraphs/cuba-bigcallgraph-NeuronGroup.__init__.no_magic_state_updater.png')

    P.v = -60 * mV + 10 * mV * rand(len(P))
    Pe = P.subgroup(Ne)
    Pi = P.subgroup(Ni)

    pycallgraph.start_trace(filter_func=ff)
    Ce = Connection(Pe, P, 'ge', weight=1.62 * mV, sparseness=p)
    pycallgraph.stop_trace()
    pycallgraph.make_dot_graph('callgraphs/cuba-bigcallgraph-Connection.__init__.png')

    Ci = Connection(Pi, P, 'gi', weight= -9 * mV, sparseness=p)

    pycallgraph.start_trace(filter_func=ff)
    M = SpikeMonitor(P)
    trace = StateMonitor(P, 'v', record=0)
    pycallgraph.stop_trace()
    pycallgraph.make_dot_graph('callgraphs/cuba-bigcallgraph-Monitors.__init__.png')

    pycallgraph.start_trace(filter_func=ff_prepare)
    run(.1 * ms)
    pycallgraph.stop_trace()
    pycallgraph.make_dot_graph('callgraphs/cuba-bigcallgraph-run-prepare.png')
コード例 #24
0
def callgraph():
	import pycallgraph
	l = prepare()
	l.reset()
	lx = l.lexicon
	gr = l.grammar
	prp = l.properties
	#Lexicon Compile
	pycallgraph.start_trace()
	lx.compile(prp, True)
	pycallgraph.make_dot_graph('lexicon_compile.png')
	#Grammar Compile
	pycallgraph.start_trace()
	gr.compile(True)
	pycallgraph.make_dot_graph('grammar_compile.png')
	#Read
	pycallgraph.start_trace()
	l.read(u"mi pona e ilo")
	pycallgraph.make_dot_graph('read.png')
コード例 #25
0
ファイル: cuba_callgraph.py プロジェクト: JoErNanO/brian
from brian import *
set_global_preferences(useweave=True)
import cuba_runopts
cuba_runopts.duration = 100 * ms
import pycallgraph
from cuba import *

cg_func = 'Connection.do_propagate'

def ff(pat):
    def f(call_stack, module_name, class_name, func_name, full_name):
        if not 'brian' in module_name: return False
        for n in call_stack + [full_name]:
            if pat in n:
                return True
        return False
    return f

def cuba(P, Pe, Pi, Ce, Ci, M, net):
    net.run(duration)

c = cubanetwork(4000)
pycallgraph.start_trace(filter_func=ff(cg_func))
cuba(*c)
pycallgraph.stop_trace()
pycallgraph.make_dot_graph('callgraphs/cuba-callgraph-' + cg_func + '.png')
コード例 #26
0

def runit():
    pack_command.pack_command("ZADD", "foo", 1369198341, 10000)


def runitp():
    pack_command_python.pack_command("ZADD", "foo", 1369198341, 10000)


if profile:
    pr = cProfile.Profile()
    pr.enable()

if graph:
    pycallgraph.start_trace()

if timer:
    for name, t in (("Python", runitp), ("cython", runit)):
        res = timeit.Timer(t).repeat(sample, number)
        min_run = min(res)
        per_loop = min_run / number

        print u'{}'.format(name)
        print u'{} total run'.format(format_time(min_run))
        print u'{} per/loop'.format(format_time(per_loop))
        #print u'{} per/friend'.format(format_time(per_loop/friends_cnt))
else:
    for j in xrange(number):
        runit()
コード例 #27
0
ファイル: server_standalone.py プロジェクト: steveyen/moingo
def run(configClass):
    """ Create and run a moin server

    See StandaloneConfig for available options

    @param configClass: config class
    """
    # Run only once!
    global httpd, config
    if httpd is not None:
        raise RuntimeError("You can run only one server per process!")

    config = configClass()

    if config.hotshotProfile and config.cProfileProfile:
        raise RuntimeError("You cannot run two profilers simultaneously.")

    # Install hotshot profiled serve_moin method. To compare with other
    # servers, we profile the part that create and run the request.
    if config.hotshotProfile:
        import hotshot
        config.hotshotProfile = hotshot.Profile(config.hotshotProfile)
        MoinRequestHandler.serve_moin = hotshotProfileDecorator(
            MoinRequestHandler.serve_moin, config.hotshotProfile)

    if config.cProfileProfile:
        import cProfile
        # Create a new cProfile.Profile object using config.cProfileProfile
        # as the path for the output file.
        config.cProfile = cProfile.Profile()
        MoinRequestHandler.serve_moin = cProfileDecorator(
            MoinRequestHandler.serve_moin, config.cProfile)

    # Install a memory profiled serve_moin method
    if config.memoryProfile:
        config.memoryProfile.sample()
        MoinRequestHandler.serve_moin = memoryProfileDecorator(
            MoinRequestHandler.serve_moin, config.memoryProfile)

    # initialize pycallgraph, if wanted
    if config.pycallgraph_output:
        try:
            import pycallgraph
            pycallgraph.settings['include_stdlib'] = False
            pcg_filter = pycallgraph.GlobbingFilter(exclude=['pycallgraph.*',
                                                             'unknown.*',
                                                    ],
                                                    max_depth=9999)
            pycallgraph.start_trace(reset=True, filter_func=pcg_filter)
        except ImportError:
            config.pycallgraph_output = None


    registerSignalHandlers(quit)
    httpd = makeServer(config)

    # Run as a safe user (posix only)
    if os.name == 'posix' and os.getuid() == 0:
        switchUID(config.uid, config.gid)

    httpd.serve_forever()
コード例 #28
0
    def run(self, runWithEnviron=False):
        '''Main code runner for testing. To set a new test, update the self.callTest attribute in __init__(). 
        '''
        suffix = '.svg'
        fmt = suffix[1:]
        _MOD = "test.timeGraphs.py"

        if runWithEnviron:
            from music21 import environment
            environLocal = environment.Environment(_MOD)
            fp = environLocal.getTempFile(suffix)
        # manually get a temporary file
        else:
            import tempfile
            import os
            import sys
            if os.name in ['nt'] or sys.platform.startswith('win'):
                platform = 'win'
            else:
                platform = 'other'
            
            tempdir = os.path.join(tempfile.gettempdir(), 'music21')
            if platform != 'win':
                fd, fp = tempfile.mkstemp(dir=tempdir, suffix=suffix)
                if isinstance(fd, int):
                # on MacOS, fd returns an int, like 3, when this is called
                # in some context (specifically, programmatically in a 
                # TestExternal class. the fp is still valid and works
                # TODO: this did not work on MacOS 10.6.8 w/ py 2.7
                    pass
                else:
                    fd.close() 
            else:
                tf = tempfile.NamedTemporaryFile(dir=tempdir, suffix=suffix)
                fp = tf.name
                tf.close()

 
        if self.includeList is not None:
            gf = pycallgraph.GlobbingFilter(include=self.includeList, exclude=self.excludeList)
        else:
            gf = pycallgraph.GlobbingFilter(exclude=self.excludeList)
        # create instance; will call setup routines
        ct = self.callTest()

        # start timer
        print('%s starting test' % _MOD)
        t = Timer()
        t.start()

        pycallgraph.start_trace(filter_func = gf)
        ct.testFocus() # run routine

        pycallgraph.stop_trace()
        pycallgraph.make_dot_graph(fp, format=fmt, tool='/usr/local/bin/dot')
        print('elapsed time: %s' % t)
        # open the completed file
        print('file path: ' + fp)
        try:
            environLocal = environment.Environment(_MOD)
            environLocal.launch(format, fp)
        except NameError:
            pass
コード例 #29
0
def filter_none():
    pycallgraph.start_trace()
    for a in xrange(100):
        re.compile('test1-%i' % a)
    pycallgraph.make_dot_graph('filter-time-none.png')
コード例 #30
0
print "Network construction time:", time.time() - start_time, "seconds"
print len(P), "neurons in the network"
print "Simulation running..."

if use_synapses:
    net = Network(P, Se, Si, Me, Mi, M)  #, M0)
else:
    net = Network(P, Ce, Ci, Me, Mi, M)  #, M0)
net.run(100 * msecond)
#M0.plot()
#show()
#exit()

start_time = time.time()
if do_callgraph:
    pycallgraph.start_trace(filter_func=ff(cg_func))

net.run(1 * second)

duration = time.time() - start_time
if do_callgraph:
    pycallgraph.stop_trace()
    pycallgraph.make_dot_graph('cuba-callgraph.png')

print "Simulation time:", duration, "seconds"
print Me.nspikes, "excitatory spikes"
print Mi.nspikes, "inhibitory spikes"

#plot(M.times / ms, M.smooth_rate(2 * ms, 'gaussian'))
#show()
コード例 #31
0
ファイル: filter_time.py プロジェクト: 1bitaway/pycallgraph
def filter_none():
    pycallgraph.start_trace()
    for a in xrange(100):
        re.compile('test1-%i' % a)
    pycallgraph.make_dot_graph('filter-time-none.png')
コード例 #32
0
def main():
    pycallgraph.start_trace()
    banana = Banana()
    banana.eat()
    pycallgraph.make_gdf_graph('basic.gdf')
コード例 #33
0
ファイル: main.py プロジェクト: Caglow/cofe-ground-operations
try:
	import pycallgraph
	pycallgraph.start_trace()
except:
	pass


import queVars
import ipCheck


ipCheckWin = ipCheck.IpChecker(0)
ipCheckWin.MainLoop()


import galilInterface

import GUIInit						#GUI Handling
import serIO
import threading
#def __init__(self, ip, port = 23, fakeGalil = False, poll = False, resetGalil = False):


queVars.gInt = galilInterface.GalilInterface(ip=queVars.galilIP, fakeGalil=queVars.fakeGalil, poll=True, resetGalil=True)

queVars.serThread = threading.Thread(target = serIO.mainLoop, name = "serThread")
queVars.serThread.start()

#import time
#time.sleep(1)
コード例 #34
0
def filter_module():
    filter_func = pycallgraph.GlobbingFilter(include=['sre_parse.*'])
    pycallgraph.start_trace(time_filter_func=filter_func)
    for a in xrange(100):
        re.compile('test3-%i' % a)
    pycallgraph.make_dot_graph('filter-time-module.png')
コード例 #35
0
ファイル: callgraph.py プロジェクト: itavor/itavor_lib
 def process_view(self, request, callback, callback_args, callback_kwargs):
     if settings.DEBUG and 'graph' in request.GET:
         filter_func = pycallgraph.GlobbingFilter(include=['*'],
                 exclude=['debug_toolbar.*', '*.debug.*'])
         pycallgraph.start_trace(filter_func=filter_func)
コード例 #36
0
def run_tests(test_labels,
              verbosity=1,
              interactive=True,
              extra_tests=[],
              nodatabase=False,
              xml_out=False,
              callgraph=False):
    """
    Test runner which displays a code coverage report at the end of the
    run.
    """
    cov = coverage.coverage()
    cov.erase()
    cov.use_cache(0)

    test_labels = test_labels or getattr(settings, "TEST_APPS", None)
    cover_branch = getattr(settings, "COVERAGE_BRANCH_COVERAGE", False)
    cov = coverage.coverage(branch=cover_branch, cover_pylib=False)
    cov.use_cache(0)

    coverage_modules = []
    if test_labels:
        for label in test_labels:
            # Don't report coverage if you're only running a single
            # test case.
            if '.' not in label:
                app = get_app(label)
                coverage_modules.extend(get_all_coverage_modules(app))
    else:
        for app in get_apps():
            coverage_modules.extend(get_all_coverage_modules(app))

    morfs = filter(is_wanted_module, coverage_modules)

    if callgraph:
        try:
            import pycallgraph
            #_include = [i.__name__ for i in coverage_modules]
            _included = getattr(settings, "COVERAGE_INCLUDE_MODULES", [])
            _excluded = getattr(settings, "COVERAGE_EXCLUDE_MODULES", [])

            _included = [i.strip('*') + '*' for i in _included]
            _excluded = [i.strip('*') + '*' for i in _included]

            _filter_func = pycallgraph.GlobbingFilter(
                include=_included or ['*'],
                #include=['lotericas.*'],
                #exclude=[],
                #max_depth=options.max_depth,
            )

            pycallgraph_enabled = True
        except ImportError:
            pycallgraph_enabled = False
    else:
        pycallgraph_enabled = False

    cov.start()

    if pycallgraph_enabled:
        pycallgraph.start_trace(filter_func=_filter_func)

    if nodatabase:
        results = nodatabase_run_tests(test_labels, verbosity, interactive,
                                       extra_tests)
    else:
        results = django_test_runner(test_labels, verbosity, interactive,
                                     extra_tests)

    if callgraph and pycallgraph_enabled:
        pycallgraph.stop_trace()

    cov.stop()

    report_methd = cov.report
    if getattr(settings, "COVERAGE_HTML_REPORT", False) or \
            os.environ.get("COVERAGE_HTML_REPORT"):
        output_dir = getattr(settings, "COVERAGE_HTML_DIRECTORY", "covhtml")
        report_method = curry(cov.html_report, directory=output_dir)
        if callgraph and pycallgraph_enabled:
            callgraph_path = output_dir + '/' + 'callgraph.png'
            pycallgraph.make_dot_graph(callgraph_path)

        print >> sys.stdout
        print >> sys.stdout, "Coverage HTML reports were output to '%s'" % output_dir
        if callgraph:
            if pycallgraph_enabled:
                print >> sys.stdout, "Call graph was output to '%s'" % callgraph_path
            else:
                print >> sys.stdout, "Call graph was not generated: Install 'pycallgraph' module to do so"

    else:
        report_method = cov.report

    if coverage_modules:
        if xml_out:
            # using the same output directory as the --xml function uses for testing
            if not os.path.isdir(os.path.join("temp", "xml")):
                os.makedirs(os.path.join("temp", "xml"))
            output_filename = 'temp/xml/coverage_output.xml'
            cov.xml_report(morfs=coverage_modules, outfile=output_filename)

        cov.report(coverage_modules, show_missing=1)

    return results
コード例 #37
0
def run_tests(test_labels, verbosity=1, interactive=True,
        extra_tests=[], nodatabase=False, xml_out=False, callgraph=False, html_only=False):
    """
    Test runner which displays a code coverage report at the end of the
    run.
    """
    cov = coverage.coverage()
    cov.erase()
    cov.use_cache(0)

    test_labels = test_labels or getattr(settings, "TEST_APPS", None)
    cover_branch = getattr(settings, "COVERAGE_BRANCH_COVERAGE", False)
    cov = coverage.coverage(branch=cover_branch, cover_pylib=False)
    cov.use_cache(0)

    coverage_modules = []
    if test_labels:
        for label in test_labels:
            # Don't report coverage if you're only running a single
            # test case.
            if '.' not in label:
                app = get_app(label)
                coverage_modules.extend(get_all_coverage_modules(app))
    else:
        for app in get_apps():
            coverage_modules.extend(get_all_coverage_modules(app))

    morfs = filter(is_wanted_module, coverage_modules)

    if callgraph:
        try:
            import pycallgraph
            #_include = [i.__name__ for i in coverage_modules]
            _included = getattr(settings, "COVERAGE_INCLUDE_MODULES", [])
            _excluded = getattr(settings, "COVERAGE_EXCLUDE_MODULES", [])

            _included = [i.strip('*')+'*' for i in _included]
            _excluded = [i.strip('*')+'*' for i in _included]

            _filter_func = pycallgraph.GlobbingFilter(
                include=_included or ['*'],
                #include=['lotericas.*'],
                #exclude=[],
                #max_depth=options.max_depth,
            )

            pycallgraph_enabled = True
        except ImportError:
            pycallgraph_enabled = False
    else:
        pycallgraph_enabled = False

    cov.start()

    if pycallgraph_enabled:
        pycallgraph.start_trace(filter_func=_filter_func)

    if nodatabase:
        results = nodatabase_run_tests(test_labels, verbosity, interactive,
            extra_tests)
    else:
        tr = django_test_runner(verbosity, interactive)
        results = tr.run_tests(test_labels, extra_tests)
        #results = django_test_runner(test_labels, verbosity, interactive,
        #    extra_tests)

    if callgraph and pycallgraph_enabled:
        pycallgraph.stop_trace()

    cov.stop()

    if getattr(settings, "COVERAGE_HTML_REPORT", False) or \
            os.environ.get("COVERAGE_HTML_REPORT"):
        output_dir = getattr(settings, "COVERAGE_HTML_DIRECTORY", "covhtml")
        report_method = curry(cov.html_report, directory=output_dir)
        if callgraph and pycallgraph_enabled:
            callgraph_path = output_dir + '/' + 'callgraph.png'
            pycallgraph.make_dot_graph(callgraph_path)

        print >>sys.stdout
        print >>sys.stdout, "Coverage HTML reports were output to '%s'" %output_dir
        if callgraph:
            if pycallgraph_enabled:
                print >>sys.stdout, "Call graph was output to '%s'" %callgraph_path
            else:
                print >>sys.stdout, "Call graph was not generated: Install 'pycallgraph' module to do so"

    else:
        report_method = cov.report

    if coverage_modules:
        if xml_out:
            # using the same output directory as the --xml function uses for testing
            if not os.path.isdir(os.path.join("temp", "xml")):
                os.makedirs(os.path.join("temp", "xml"))
            output_filename = 'temp/xml/coverage_output.xml'
            cov.xml_report(morfs=coverage_modules, outfile=output_filename)

        if not html_only:
            cov.report(coverage_modules, show_missing=1)

    return results
コード例 #38
0
ファイル: large.py プロジェクト: animator/jsonpycallgraph
def main():
    pycallgraph.start_trace()
    import urllib
    from xml.dom.minidom import parse, parseString
    parseString(urllib.urlopen('http://w3.org/').read())
    pycallgraph.make_dot_graph('large.png')
コード例 #39
0
ファイル: large.py プロジェクト: 1bitaway/pycallgraph
def main():
    pycallgraph.start_trace()
    import urllib
    from xml.dom.minidom import parse, parseString
    parseString(urllib.urlopen('http://w3.org/').read())
    pycallgraph.make_dot_graph('large.png')
コード例 #40
0
 def __call__(self, *args, **kwargs):
     pycallgraph.start_trace(reset=False)
     return_value = self.func(*args, **kwargs)
     pycallgraph.stop_trace()
     return return_value
コード例 #41
0
ファイル: recursive.py プロジェクト: animator/jsonpycallgraph
def main():
    pycallgraph.start_trace()
    for a in xrange(1, 10):
        factorial(a)

    pycallgraph.make_dot_graph('recursive.png')
コード例 #42
0
 def wrapper(*args, **kwargs):
     pycallgraph.start_trace()
     func(*args, **kwargs)
     pycallgraph.save_dot('callgraph.log')
     pycallgraph.make_dot_graph('callgraph.png')
コード例 #43
0
def filter_max_depth():
    filter_func = pycallgraph.GlobbingFilter(max_depth=1)
    pycallgraph.start_trace(filter_func=filter_func)
    banana = Banana()
    banana.eat()
    pycallgraph.make_dot_graph('filter-max-depth.png')
コード例 #44
0
M = SpikeMonitor(P)

net = MagicNetwork()

start = time.time()
net.prepare()
net.run(1 * ms)
print 'Preparation time:', time.time() - start

if do_callgraph:
    import pycallgraph

    def ff(call_stack, module_name, class_name, func_name, full_name):
        if not 'brian' in module_name: return False
        return True

    pycallgraph.start_trace(filter_func=ff)

start = time.time()
net.run(1 * second)
print 'Run time:', time.time() - start

if do_callgraph:
    pycallgraph.stop_trace()
    pycallgraph.make_dot_graph('callgraph.png')

if plot_output:
    raster_plot(M)
    show()
コード例 #45
0
ファイル: callgraphiti.py プロジェクト: silky/callgraphiti
 def start (self): # {{{
     self.started = True
     pycallgraph.start_trace(filter_func = self.filter_func())
コード例 #46
0
ファイル: basic.py プロジェクト: animator/jsonpycallgraph
def main():
    pycallgraph.start_trace()
    banana = Banana()
    banana.eat()
    pycallgraph.make_dot_graph('basic.png')
コード例 #47
0
ファイル: basic_gdf.py プロジェクト: 1bitaway/pycallgraph
def main():
    pycallgraph.start_trace()
    banana = Banana()
    banana.eat()
    pycallgraph.make_gdf_graph('basic.gdf')
コード例 #48
0
ファイル: timeGraphs.py プロジェクト: knuton/music21
def timeHumdrum():
    masterStream = music21.humdrum.parseData(htf.mazurka6).stream

def timeMozart():
    a = music21.converter.parse(music21.corpus.getWork('k155')[0])
#    ls = music21.lily.LilyString("{" + a[0].lily + "}")
#    ls.showPNG()
#    a = music21.converter.parse(mxtf.ALL[1])

def timeCapua():
    c1 = music21.trecento.capua.Test()
    c1.testRunPiece()

def timeCapua2():
    music21.trecento.capua.ruleFrequency()

excludeList =  ['pycallgraph.*','re.*','sre_*', 'copy*', '*xlrd*',]
excludeList += ['*meter*', 'encodings*', '*isClass*', '*duration.Duration*']

gf = pycallgraph.GlobbingFilter(exclude=excludeList)

print(time.ctime())

pycallgraph.start_trace(filter_func = gf)

timeCapua2()

pycallgraph.make_dot_graph('d:\\desktop\\test1.png')

print(time.ctime())
コード例 #49
0
def filter_min_depth():
    filter_func = pycallgraph.GlobbingFilter(min_depth=7)
    pycallgraph.start_trace(time_filter_func=filter_func)
    for a in xrange(100):
        re.compile('test2-%i' % a)
    pycallgraph.make_dot_graph('filter-time-min-depth.png')
コード例 #50
0
ファイル: filter_time.py プロジェクト: 1bitaway/pycallgraph
def filter_min_depth():
    filter_func = pycallgraph.GlobbingFilter(min_depth=7)
    pycallgraph.start_trace(time_filter_func=filter_func)
    for a in xrange(100):
        re.compile('test2-%i' % a)
    pycallgraph.make_dot_graph('filter-time-min-depth.png')
コード例 #51
0
def main():
    pycallgraph.start_trace()
    re.search('(hel[j-s]o).*(th[^e]*ere)', 'hello there')
    pycallgraph.make_dot_graph('regexp.png')
コード例 #52
0
ファイル: filter_time.py プロジェクト: 1bitaway/pycallgraph
def filter_module():
    filter_func = pycallgraph.GlobbingFilter(include=['sre_parse.*'])
    pycallgraph.start_trace(time_filter_func=filter_func)
    for a in xrange(100):
        re.compile('test3-%i' % a)
    pycallgraph.make_dot_graph('filter-time-module.png')
コード例 #53
0
ファイル: basic.py プロジェクト: 1bitaway/pycallgraph
def main():
    pycallgraph.start_trace()
    banana = Banana()
    banana.eat()
    pycallgraph.make_dot_graph('basic.png')
コード例 #54
0
    def run(self, runWithEnviron=True):
        '''
        Main code runner for testing. To set a new test, update the self.callTest attribute in __init__(). 
        
        Note that the default of runWithEnviron imports music21.environment.  That might
        skew results
        '''
        suffix = '.svg'
        outputFormat = suffix[1:]
        _MOD = "test.timeGraphs.py"

        if runWithEnviron:
            from music21 import environment
            environLocal = environment.Environment(_MOD)
            fp = environLocal.getTempFile(suffix)
        # manually get a temporary file
        else:
            import tempfile
            import os
            import sys
            if os.name in ['nt'] or sys.platform.startswith('win'):
                platform = 'win'
            else:
                platform = 'other'

            tempdir = os.path.join(tempfile.gettempdir(), 'music21')
            if platform != 'win':
                fd, fp = tempfile.mkstemp(dir=tempdir, suffix=suffix)
                if isinstance(fd, int):
                    # on MacOS, fd returns an int, like 3, when this is called
                    # in some context (specifically, programmatically in a
                    # TestExternal class. the fp is still valid and works
                    # TODO: this did not work on MacOS 10.6.8 w/ py 2.7
                    pass
                else:
                    fd.close()
            else:
                tf = tempfile.NamedTemporaryFile(dir=tempdir, suffix=suffix)
                fp = tf.name
                tf.close()

        if self.includeList is not None:
            gf = pycallgraph.GlobbingFilter(include=self.includeList,
                                            exclude=self.excludeList)
        else:
            gf = pycallgraph.GlobbingFilter(exclude=self.excludeList)
        # create instance; will call setup routines
        ct = self.callTest()

        # start timer
        print('%s starting test' % _MOD)
        t = Timer()
        t.start()

        pycallgraph.start_trace(filter_func=gf)
        ct.testFocus()  # run routine

        pycallgraph.stop_trace()
        pycallgraph.make_dot_graph(fp,
                                   format=outputFormat,
                                   tool='/usr/local/bin/dot')
        print('elapsed time: %s' % t)
        # open the completed file
        print('file path: ' + fp)
        try:
            environLocal = environment.Environment(_MOD)
            environLocal.launch(outputFormat, fp)
        except NameError:
            pass
コード例 #55
0
def pygraphit():
    import pycallgraph
    pycallgraph.start_trace()
    pycallgraph.stop_trace()
    pycallgraph.make_graph('/tmp/bleh.png')