예제 #1
0
 def setUp(self):
     win32trace.InitRead()
     # If any other writers are running (even if not actively writing),
     # terminating the module will *not* close the handle, meaning old data
     # will remain. This can cause other tests to fail.
     win32trace.read()
     win32trace.InitWrite()
예제 #2
0
 def setUp(self):
     win32trace.InitRead()
     # If any other writers are running (even if not actively writing),
     # terminating the module will *not* close the handle, meaning old data
     # will remain. This can cause other tests to fail.
     win32trace.read()
     win32trace.InitWrite()
예제 #3
0
 def setUp(self):
     WriterThread.BucketCount = self.BucketCount        
     win32trace.InitRead()
     win32trace.read() # clear any old data.
     win32trace.InitWrite()
     CheckNoOtherReaders()
     self.threads = [WriterThread() for each in range(self.FullBucket)]
     self.buckets = list(range(self.BucketCount))
     for each in self.buckets:
         self.buckets[each] = 0
예제 #4
0
 def setUp(self):
     WriterThread.BucketCount = self.BucketCount        
     win32trace.InitRead()
     win32trace.read() # clear any old data.
     win32trace.InitWrite()
     CheckNoOtherReaders()
     self.threads = [WriterThread() for each in range(self.FullBucket)]
     self.buckets = range(self.BucketCount)
     for each in self.buckets:
         self.buckets[each] = 0
예제 #5
0
def CollectorThread(stopEvent, file):
    win32trace.InitRead()
    handle = win32trace.GetHandle()
    # Run this thread at a lower priority to the main message-loop (and printing output)
    # thread can keep up
    import win32process

    win32process.SetThreadPriority(
        win32api.GetCurrentThread(), win32process.THREAD_PRIORITY_BELOW_NORMAL
    )

    try:
        while 1:
            rc = win32event.WaitForMultipleObjects(
                (handle, stopEvent), 0, win32event.INFINITE
            )
            if rc == win32event.WAIT_OBJECT_0:
                # About the only char we can't live with is \0!
                file.write(win32trace.read().replace("\0", "<null>"))
            else:
                # Stop event
                break
    finally:
        win32trace.TermRead()
        print("Thread dieing")
예제 #6
0
 def _do_read_trace(self):
     """
     print buffer collected in win32trace
     """
     while self._read_trace:
         msg = win32trace.read()
         if msg:
             self.queue.put(msg)
예제 #7
0
def CheckNoOtherReaders():
    win32trace.write("Hi")
    time.sleep(0.05)
    if win32trace.read() != "Hi":
        # Reset everything so following tests still fail with this error!S
        win32trace.TermRead()
        win32trace.TermWrite()
        raise RuntimeError, "An existing win32trace reader appears to be " \
                            "running - please stop this process and try again"
예제 #8
0
def CheckNoOtherReaders():
    win32trace.write("Hi")
    time.sleep(0.05)
    if win32trace.read() != "Hi":
        # Reset everything so following tests still fail with this error!
        win32trace.TermRead()
        win32trace.TermWrite()
        raise RuntimeError("An existing win32trace reader appears to be " \
                            "running - please stop this process and try again")
예제 #9
0
    def testInitTermRead(self):
        with pytest.raises(win32trace.error):
            win32trace.read()
        win32trace.InitRead()
        result = win32trace.read()
        assert result == ''
        win32trace.TermRead()
        with pytest.raises(win32trace.error):
            win32trace.read()

        win32trace.InitRead()
        with pytest.raises(win32trace.error):
            win32trace.InitRead()
        win32trace.InitWrite()
        with pytest.raises(win32trace.error):
            win32trace.InitWrite()
        win32trace.TermWrite()
        win32trace.TermRead()
예제 #10
0
    def testTermSematics(self):
        win32trace.InitWrite()
        win32trace.write('Ta da')

        # if we both Write and Read are terminated at the same time,
        # we lose the data as the win32 object is closed.  Note that
        # if another writer is running, we do *not* lose the data - so
        # test for either the correct data or an empty string
        win32trace.TermWrite()
        win32trace.InitRead()
        self.failUnless(win32trace.read() in ['Ta da', ''])
        win32trace.TermRead()

        # we keep the data because we init read before terminating write
        win32trace.InitWrite()
        win32trace.write('Ta da')
        win32trace.InitRead()
        win32trace.TermWrite()
        self.assertEquals('Ta da', win32trace.read())
        win32trace.TermRead()
예제 #11
0
    def testTermSematics(self):
        win32trace.InitWrite()
        win32trace.write('Ta da')

        # if we both Write and Read are terminated at the same time,
        # we lose the data as the win32 object is closed.  Note that
        # if another writer is running, we do *not* lose the data - so
        # test for either the correct data or an empty string
        win32trace.TermWrite()
        win32trace.InitRead()
        self.failUnless(win32trace.read() in ['Ta da', ''])
        win32trace.TermRead()

        # we keep the data because we init read before terminating write
        win32trace.InitWrite()
        win32trace.write('Ta da')
        win32trace.InitRead()
        win32trace.TermWrite()
        self.assertEquals('Ta da', win32trace.read())
        win32trace.TermRead()
예제 #12
0
    def testInitTermRead(self):
        self.assertRaises(win32trace.error, win32trace.read)
        win32trace.InitRead()
        result = win32trace.read()
        self.assertEquals(result, '')
        win32trace.TermRead()
        self.assertRaises(win32trace.error, win32trace.read)

        win32trace.InitRead()
        self.assertRaises(win32trace.error, win32trace.InitRead)
        win32trace.InitWrite()
        self.assertRaises(win32trace.error, win32trace.InitWrite)
        win32trace.TermWrite()
        win32trace.TermRead()
예제 #13
0
    def testInitTermRead(self):
        self.assertRaises(win32trace.error, win32trace.read)
        win32trace.InitRead()
        result = win32trace.read()
        self.assertEquals(result, '')
        win32trace.TermRead()
        self.assertRaises(win32trace.error, win32trace.read)

        win32trace.InitRead()
        self.assertRaises(win32trace.error, win32trace.InitRead)
        win32trace.InitWrite()
        self.assertRaises(win32trace.error, win32trace.InitWrite)
        win32trace.TermWrite()
        win32trace.TermRead()
def CollectorThread(stopEvent, file):
	win32trace.InitRead()
	handle = win32trace.GetHandle()
	# Run this thread at a lower priority to the main message-loop (and printing output)
	# thread can keep up
	import win32process
	win32process.SetThreadPriority(win32api.GetCurrentThread(), win32process.THREAD_PRIORITY_BELOW_NORMAL)

	try:
		while 1:
			rc = win32event.WaitForMultipleObjects((handle, stopEvent), 0, win32event.INFINITE)
			if rc == win32event.WAIT_OBJECT_0:
				# About the only char we can't live with is \0!
				file.write(win32trace.read().replace("\0", "<null>"))
			else:
				# Stop event
				break
	finally:
		win32trace.TermRead()
		print("Thread dieing")
예제 #15
0
 def testRoundTrip(self):
     win32trace.write('Syver Enstad')
     syverEnstad = win32trace.read()
     self.assertEquals('Syver Enstad', syverEnstad)
예제 #16
0
 def setUp(self):
     # clear old data
     win32trace.InitRead()
     win32trace.read()
     win32trace.TermRead()
예제 #17
0
 def setUp(self):
     win32trace.InitRead()
     win32trace.read() # clear any old data
     win32trace.InitWrite()
예제 #18
0
 def setUp(self):
     win32trace.InitRead()
     win32trace.read() # clear any old data
     win32trace.InitWrite()
예제 #19
0
 def testRoundTrip(self):
     win32trace.write("Syver Enstad")
     syverEnstad = win32trace.read()
     self.assertEqual("Syver Enstad", syverEnstad)
예제 #20
0
 def setUp(self):
     # clear old data
     win32trace.InitRead()
     win32trace.read()
     win32trace.TermRead()
예제 #21
0
 def testRoundTripUnicode(self):
     win32trace.write('\xa9opyright Syver Enstad')
     syverEnstad = win32trace.read()
     # str objects are always returned in py2k (latin-1 encoding was used
     # on unicode objects)
     self.assertEquals('\xa9opyright Syver Enstad', syverEnstad)
예제 #22
0
 def testRoundTrip(self):
     win32trace.write('Syver Enstad')
     syverEnstad = win32trace.read()
     assert 'Syver Enstad' == syverEnstad
예제 #23
0
 def testRoundTrip(self):
     win32trace.write('Syver Enstad')
     syverEnstad = win32trace.read()
     self.assertEquals('Syver Enstad', syverEnstad)
예제 #24
0
 def testRoundTripUnicode(self):
     win32trace.write('\xa9opyright Syver Enstad')
     syverEnstad = win32trace.read()
     # str objects are always returned in py2k (latin-1 encoding was used
     # on unicode objects)
     self.assertEquals('\xa9opyright Syver Enstad', syverEnstad)