You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hawq.apache.org by rl...@apache.org on 2016/06/21 02:41:17 UTC

[01/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code

Repository: incubator-hawq
Updated Branches:
  refs/heads/master 84dd4d4b2 -> 80e25b468


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_result.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_result.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_result.py
new file mode 100644
index 0000000..a6dc16c
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_result.py
@@ -0,0 +1,416 @@
+import sys
+import textwrap
+from StringIO import StringIO
+
+import unittest2
+
+
+class Test_TestResult(unittest2.TestCase):
+    # Note: there are not separate tests for TestResult.wasSuccessful(),
+    # TestResult.errors, TestResult.failures, TestResult.testsRun or
+    # TestResult.shouldStop because these only have meaning in terms of
+    # other TestResult methods.
+    #
+    # Accordingly, tests for the aforenamed attributes are incorporated
+    # in with the tests for the defining methods.
+    ################################################################
+
+    def test_init(self):
+        result = unittest2.TestResult()
+
+        self.assertTrue(result.wasSuccessful())
+        self.assertEqual(len(result.errors), 0)
+        self.assertEqual(len(result.failures), 0)
+        self.assertEqual(result.testsRun, 0)
+        self.assertEqual(result.shouldStop, False)
+        self.assertIsNone(result._stdout_buffer)
+        self.assertIsNone(result._stderr_buffer)
+
+    # "This method can be called to signal that the set of tests being
+    # run should be aborted by setting the TestResult's shouldStop
+    # attribute to True."
+    def test_stop(self):
+        result = unittest2.TestResult()
+
+        result.stop()
+
+        self.assertEqual(result.shouldStop, True)
+
+    # "Called when the test case test is about to be run. The default
+    # implementation simply increments the instance's testsRun counter."
+    def test_startTest(self):
+        class Foo(unittest2.TestCase):
+            def test_1(self):
+                pass
+
+        test = Foo('test_1')
+
+        result = unittest2.TestResult()
+
+        result.startTest(test)
+
+        self.assertTrue(result.wasSuccessful())
+        self.assertEqual(len(result.errors), 0)
+        self.assertEqual(len(result.failures), 0)
+        self.assertEqual(result.testsRun, 1)
+        self.assertEqual(result.shouldStop, False)
+
+        result.stopTest(test)
+
+    # "Called after the test case test has been executed, regardless of
+    # the outcome. The default implementation does nothing."
+    def test_stopTest(self):
+        class Foo(unittest2.TestCase):
+            def test_1(self):
+                pass
+
+        test = Foo('test_1')
+
+        result = unittest2.TestResult()
+
+        result.startTest(test)
+
+        self.assertTrue(result.wasSuccessful())
+        self.assertEqual(len(result.errors), 0)
+        self.assertEqual(len(result.failures), 0)
+        self.assertEqual(result.testsRun, 1)
+        self.assertEqual(result.shouldStop, False)
+
+        result.stopTest(test)
+
+        # Same tests as above; make sure nothing has changed
+        self.assertTrue(result.wasSuccessful())
+        self.assertEqual(len(result.errors), 0)
+        self.assertEqual(len(result.failures), 0)
+        self.assertEqual(result.testsRun, 1)
+        self.assertEqual(result.shouldStop, False)
+
+    # "Called before and after tests are run. The default implementation does nothing."
+    def test_startTestRun_stopTestRun(self):
+        result = unittest2.TestResult()
+        result.startTestRun()
+        result.stopTestRun()
+
+    # "addSuccess(test)"
+    # ...
+    # "Called when the test case test succeeds"
+    # ...
+    # "wasSuccessful() - Returns True if all tests run so far have passed,
+    # otherwise returns False"
+    # ...
+    # "testsRun - The total number of tests run so far."
+    # ...
+    # "errors - A list containing 2-tuples of TestCase instances and
+    # formatted tracebacks. Each tuple represents a test which raised an
+    # unexpected exception. Contains formatted
+    # tracebacks instead of sys.exc_info() results."
+    # ...
+    # "failures - A list containing 2-tuples of TestCase instances and
+    # formatted tracebacks. Each tuple represents a test where a failure was
+    # explicitly signalled using the TestCase.fail*() or TestCase.assert*()
+    # methods. Contains formatted tracebacks instead
+    # of sys.exc_info() results."
+    def test_addSuccess(self):
+        class Foo(unittest2.TestCase):
+            def test_1(self):
+                pass
+
+        test = Foo('test_1')
+
+        result = unittest2.TestResult()
+
+        result.startTest(test)
+        result.addSuccess(test)
+        result.stopTest(test)
+
+        self.assertTrue(result.wasSuccessful())
+        self.assertEqual(len(result.errors), 0)
+        self.assertEqual(len(result.failures), 0)
+        self.assertEqual(result.testsRun, 1)
+        self.assertEqual(result.shouldStop, False)
+
+    # "addFailure(test, err)"
+    # ...
+    # "Called when the test case test signals a failure. err is a tuple of
+    # the form returned by sys.exc_info(): (type, value, traceback)"
+    # ...
+    # "wasSuccessful() - Returns True if all tests run so far have passed,
+    # otherwise returns False"
+    # ...
+    # "testsRun - The total number of tests run so far."
+    # ...
+    # "errors - A list containing 2-tuples of TestCase instances and
+    # formatted tracebacks. Each tuple represents a test which raised an
+    # unexpected exception. Contains formatted
+    # tracebacks instead of sys.exc_info() results."
+    # ...
+    # "failures - A list containing 2-tuples of TestCase instances and
+    # formatted tracebacks. Each tuple represents a test where a failure was
+    # explicitly signalled using the TestCase.fail*() or TestCase.assert*()
+    # methods. Contains formatted tracebacks instead
+    # of sys.exc_info() results."
+    def test_addFailure(self):
+        class Foo(unittest2.TestCase):
+            def test_1(self):
+                pass
+
+        test = Foo('test_1')
+        try:
+            test.fail("foo")
+        except:
+            exc_info_tuple = sys.exc_info()
+
+        result = unittest2.TestResult()
+
+        result.startTest(test)
+        result.addFailure(test, exc_info_tuple)
+        result.stopTest(test)
+
+        self.assertFalse(result.wasSuccessful())
+        self.assertEqual(len(result.errors), 0)
+        self.assertEqual(len(result.failures), 1)
+        self.assertEqual(result.testsRun, 1)
+        self.assertEqual(result.shouldStop, False)
+
+        test_case, formatted_exc = result.failures[0]
+        self.assertTrue(test_case is test)
+        self.assertIsInstance(formatted_exc, str)
+
+    # "addError(test, err)"
+    # ...
+    # "Called when the test case test raises an unexpected exception err
+    # is a tuple of the form returned by sys.exc_info():
+    # (type, value, traceback)"
+    # ...
+    # "wasSuccessful() - Returns True if all tests run so far have passed,
+    # otherwise returns False"
+    # ...
+    # "testsRun - The total number of tests run so far."
+    # ...
+    # "errors - A list containing 2-tuples of TestCase instances and
+    # formatted tracebacks. Each tuple represents a test which raised an
+    # unexpected exception. Contains formatted
+    # tracebacks instead of sys.exc_info() results."
+    # ...
+    # "failures - A list containing 2-tuples of TestCase instances and
+    # formatted tracebacks. Each tuple represents a test where a failure was
+    # explicitly signalled using the TestCase.fail*() or TestCase.assert*()
+    # methods. Contains formatted tracebacks instead
+    # of sys.exc_info() results."
+    def test_addError(self):
+        class Foo(unittest2.TestCase):
+            def test_1(self):
+                pass
+
+        test = Foo('test_1')
+        try:
+            raise TypeError()
+        except:
+            exc_info_tuple = sys.exc_info()
+
+        result = unittest2.TestResult()
+
+        result.startTest(test)
+        result.addError(test, exc_info_tuple)
+        result.stopTest(test)
+
+        self.assertFalse(result.wasSuccessful())
+        self.assertEqual(len(result.errors), 1)
+        self.assertEqual(len(result.failures), 0)
+        self.assertEqual(result.testsRun, 1)
+        self.assertEqual(result.shouldStop, False)
+
+        test_case, formatted_exc = result.errors[0]
+        self.assertTrue(test_case is test)
+        self.assertIsInstance(formatted_exc, str)
+
+    def testGetDescriptionWithoutDocstring(self):
+        result = unittest2.TextTestResult(None, True, 1)
+        self.assertEqual(
+                result.getDescription(self),
+                'testGetDescriptionWithoutDocstring (' + __name__ +
+                '.Test_TestResult)')
+
+    def testGetDescriptionWithOneLineDocstring(self):
+        """Tests getDescription() for a method with a docstring."""
+        result = unittest2.TextTestResult(None, True, 1)
+        self.assertEqual(
+                result.getDescription(self),
+               ('testGetDescriptionWithOneLineDocstring '
+                '(' + __name__ + '.Test_TestResult)\n'
+                'Tests getDescription() for a method with a docstring.'))
+
+    def testGetDescriptionWithMultiLineDocstring(self):
+        """Tests getDescription() for a method with a longer docstring.
+        The second line of the docstring.
+        """
+        result = unittest2.TextTestResult(None, True, 1)
+        self.assertEqual(
+                result.getDescription(self),
+               ('testGetDescriptionWithMultiLineDocstring '
+                '(' + __name__ + '.Test_TestResult)\n'
+                'Tests getDescription() for a method with a longer '
+                'docstring.'))
+
+    def testStackFrameTrimming(self):
+        class Frame(object):
+            class tb_frame(object):
+                f_globals = {}
+        result = unittest2.TestResult()
+        self.assertFalse(result._is_relevant_tb_level(Frame))
+        
+        Frame.tb_frame.f_globals['__unittest'] = True
+        self.assertTrue(result._is_relevant_tb_level(Frame))
+
+    def testFailFast(self):
+        result = unittest2.TestResult()
+        result._exc_info_to_string = lambda *_: ''
+        result.failfast = True
+        result.addError(None, None)
+        self.assertTrue(result.shouldStop)
+
+        result = unittest2.TestResult()
+        result._exc_info_to_string = lambda *_: ''
+        result.failfast = True
+        result.addFailure(None, None)
+        self.assertTrue(result.shouldStop)
+
+        result = unittest2.TestResult()
+        result._exc_info_to_string = lambda *_: ''
+        result.failfast = True
+        result.addUnexpectedSuccess(None)
+        self.assertTrue(result.shouldStop)
+
+    def testFailFastSetByRunner(self):
+        runner = unittest2.TextTestRunner(stream=StringIO(), failfast=True)
+        self.testRan = False
+        def test(result):
+            self.testRan = True
+            self.assertTrue(result.failfast)
+        runner.run(test)
+        self.assertTrue(self.testRan)
+
+
+class TestOutputBuffering(unittest2.TestCase):
+
+    def setUp(self):
+        self._real_out = sys.stdout
+        self._real_err = sys.stderr
+
+    def tearDown(self):
+        sys.stdout = self._real_out
+        sys.stderr = self._real_err
+
+    def testBufferOutputOff(self):
+        real_out = self._real_out
+        real_err = self._real_err
+        
+        result = unittest2.TestResult()
+        self.assertFalse(result.buffer)
+    
+        self.assertIs(real_out, sys.stdout)
+        self.assertIs(real_err, sys.stderr)
+        
+        result.startTest(self)
+        
+        self.assertIs(real_out, sys.stdout)
+        self.assertIs(real_err, sys.stderr)
+
+    def testBufferOutputStartTestAddSuccess(self):
+        real_out = self._real_out
+        real_err = self._real_err
+        
+        result = unittest2.TestResult()
+        self.assertFalse(result.buffer)
+        
+        result.buffer = True
+    
+        self.assertIs(real_out, sys.stdout)
+        self.assertIs(real_err, sys.stderr)
+        
+        result.startTest(self)
+        
+        self.assertIsNot(real_out, sys.stdout)
+        self.assertIsNot(real_err, sys.stderr)
+        self.assertIsInstance(sys.stdout, StringIO)
+        self.assertIsInstance(sys.stderr, StringIO)
+        self.assertIsNot(sys.stdout, sys.stderr)
+        
+        out_stream = sys.stdout
+        err_stream = sys.stderr
+        
+        result._original_stdout = StringIO()
+        result._original_stderr = StringIO()
+        
+        print 'foo'
+        print >> sys.stderr, 'bar'
+        
+        self.assertEqual(out_stream.getvalue(), 'foo\n')
+        self.assertEqual(err_stream.getvalue(), 'bar\n')
+        
+        self.assertEqual(result._original_stdout.getvalue(), '')
+        self.assertEqual(result._original_stderr.getvalue(), '')
+        
+        result.addSuccess(self)
+        result.stopTest(self)
+        
+        self.assertIs(sys.stdout, result._original_stdout)
+        self.assertIs(sys.stderr, result._original_stderr)
+        
+        self.assertEqual(result._original_stdout.getvalue(), '')
+        self.assertEqual(result._original_stderr.getvalue(), '')
+        
+        self.assertEqual(out_stream.getvalue(), '')
+        self.assertEqual(err_stream.getvalue(), '')
+        
+
+    def getStartedResult(self):
+        result = unittest2.TestResult()
+        result.buffer = True
+        result.startTest(self)
+        return result
+
+    def testBufferOutputAddErrorOrFailure(self):
+        for message_attr, add_attr, include_error in [
+            ('errors', 'addError', True), 
+            ('failures', 'addFailure', False),
+            ('errors', 'addError', True), 
+            ('failures', 'addFailure', False)
+        ]:
+            result = self.getStartedResult()
+            result._original_stderr = StringIO()
+            result._original_stdout = StringIO()
+            
+            print >> sys.stdout, 'foo'
+            if include_error:
+                print >> sys.stderr, 'bar'
+            
+            addFunction = getattr(result, add_attr)
+            addFunction(self, (None, None, None))
+            result.stopTest(self)
+            
+            result_list = getattr(result, message_attr)
+            self.assertEqual(len(result_list), 1)
+            
+            test, message = result_list[0]
+            expectedOutMessage = textwrap.dedent("""
+                Stdout:
+                foo
+            """)
+            expectedErrMessage = ''
+            if include_error:
+                expectedErrMessage = textwrap.dedent("""
+                Stderr:
+                bar
+            """)
+            expectedFullMessage = 'None\n%s%s' % (expectedOutMessage, expectedErrMessage)
+
+            self.assertIs(test, self)
+            self.assertEqual(result._original_stdout.getvalue(), expectedOutMessage)
+            self.assertEqual(result._original_stderr.getvalue(), expectedErrMessage)
+            self.assertMultiLineEqual(message, expectedFullMessage)
+        
+        
+
+if __name__ == '__main__':
+    unittest2.main()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_runner.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_runner.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_runner.py
new file mode 100644
index 0000000..38b39ef
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_runner.py
@@ -0,0 +1,129 @@
+import pickle
+
+from cStringIO import StringIO
+from unittest2.test.support import LoggingResult, OldTestResult
+
+import unittest2
+
+
+class Test_TextTestRunner(unittest2.TestCase):
+    """Tests for TextTestRunner."""
+
+    def test_init(self):
+        runner = unittest2.TextTestRunner()
+        self.assertFalse(runner.failfast)
+        self.assertFalse(runner.buffer)
+        self.assertEqual(runner.verbosity, 1)
+        self.assertTrue(runner.descriptions)
+        self.assertEqual(runner.resultclass, unittest2.TextTestResult)
+
+
+    def testBufferAndFailfast(self):
+        class Test(unittest2.TestCase):
+            def testFoo(self):
+                pass
+        result = unittest2.TestResult()
+        runner = unittest2.TextTestRunner(stream=StringIO(), failfast=True,
+                                           buffer=True)
+        # Use our result object
+        runner._makeResult = lambda: result
+        runner.run(Test('testFoo'))
+        
+        self.assertTrue(result.failfast)
+        self.assertTrue(result.buffer)
+
+    def testRunnerRegistersResult(self):
+        class Test(unittest2.TestCase):
+            def testFoo(self):
+                pass
+        originalRegisterResult = unittest2.runner.registerResult
+        def cleanup():
+            unittest2.runner.registerResult = originalRegisterResult
+        self.addCleanup(cleanup)
+        
+        result = unittest2.TestResult()
+        runner = unittest2.TextTestRunner(stream=StringIO())
+        # Use our result object
+        runner._makeResult = lambda: result
+        
+        self.wasRegistered = 0
+        def fakeRegisterResult(thisResult):
+            self.wasRegistered += 1
+            self.assertEqual(thisResult, result)
+        unittest2.runner.registerResult = fakeRegisterResult
+        
+        runner.run(unittest2.TestSuite())
+        self.assertEqual(self.wasRegistered, 1)
+        
+    def test_works_with_result_without_startTestRun_stopTestRun(self):
+        class OldTextResult(OldTestResult):
+            def __init__(self, *_):
+                super(OldTextResult, self).__init__()
+            separator2 = ''
+            def printErrors(self):
+                pass
+
+        runner = unittest2.TextTestRunner(stream=StringIO(), 
+                                          resultclass=OldTextResult)
+        runner.run(unittest2.TestSuite())
+
+    def test_startTestRun_stopTestRun_called(self):
+        class LoggingTextResult(LoggingResult):
+            separator2 = ''
+            def printErrors(self):
+                pass
+
+        class LoggingRunner(unittest2.TextTestRunner):
+            def __init__(self, events):
+                super(LoggingRunner, self).__init__(StringIO())
+                self._events = events
+
+            def _makeResult(self):
+                return LoggingTextResult(self._events)
+
+        events = []
+        runner = LoggingRunner(events)
+        runner.run(unittest2.TestSuite())
+        expected = ['startTestRun', 'stopTestRun']
+        self.assertEqual(events, expected)
+
+    def test_pickle_unpickle(self):
+        # Issue #7197: a TextTestRunner should be (un)pickleable. This is
+        # required by test_multiprocessing under Windows (in verbose mode).
+        import StringIO
+        # cStringIO objects are not pickleable, but StringIO objects are.
+        stream = StringIO.StringIO("foo")
+        runner = unittest2.TextTestRunner(stream)
+        for protocol in range(pickle.HIGHEST_PROTOCOL + 1):
+            s = pickle.dumps(runner, protocol=protocol)
+            obj = pickle.loads(s)
+            # StringIO objects never compare equal, a cheap test instead.
+            self.assertEqual(obj.stream.getvalue(), stream.getvalue())
+
+    def test_resultclass(self):
+        def MockResultClass(*args):
+            return args
+        STREAM = object()
+        DESCRIPTIONS = object()
+        VERBOSITY = object()
+        runner = unittest2.TextTestRunner(STREAM, DESCRIPTIONS, VERBOSITY,
+                                         resultclass=MockResultClass)
+        self.assertEqual(runner.resultclass, MockResultClass)
+
+        expectedresult = (runner.stream, DESCRIPTIONS, VERBOSITY)
+        self.assertEqual(runner._makeResult(), expectedresult)
+
+
+    def test_oldresult(self):
+        class Test(unittest2.TestCase):
+            def testFoo(self):
+                pass
+        runner = unittest2.TextTestRunner(resultclass=OldTestResult,
+                                          stream=StringIO())
+        # This will raise an exception if TextTestRunner can't handle old
+        # test result objects
+        runner.run(Test('testFoo'))
+
+
+if __name__ == '__main__':
+    unittest2.main()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_setups.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_setups.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_setups.py
new file mode 100644
index 0000000..55c7f57
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_setups.py
@@ -0,0 +1,502 @@
+import sys
+
+from cStringIO import StringIO
+
+import unittest2
+from unittest2.test.support import resultFactory
+
+
+class TestSetups(unittest2.TestCase):
+    
+    def getRunner(self):
+        return unittest2.TextTestRunner(resultclass=resultFactory,
+                                          stream=StringIO())
+    def runTests(self, *cases):
+        suite = unittest2.TestSuite()
+        for case in cases:
+            tests = unittest2.defaultTestLoader.loadTestsFromTestCase(case)
+            suite.addTests(tests)
+        
+        runner = self.getRunner()
+        
+        # creating a nested suite exposes some potential bugs
+        realSuite = unittest2.TestSuite()
+        realSuite.addTest(suite)
+        # adding empty suites to the end exposes potential bugs
+        suite.addTest(unittest2.TestSuite())
+        realSuite.addTest(unittest2.TestSuite())
+        return runner.run(realSuite)
+    
+    def test_setup_class(self):
+        class Test(unittest2.TestCase):
+            setUpCalled = 0
+            @classmethod
+            def setUpClass(cls):
+                Test.setUpCalled += 1
+                unittest2.TestCase.setUpClass()
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+            
+        result = self.runTests(Test)
+        
+        self.assertEqual(Test.setUpCalled, 1)
+        self.assertEqual(result.testsRun, 2)
+        self.assertEqual(len(result.errors), 0)
+
+    def test_teardown_class(self):
+        class Test(unittest2.TestCase):
+            tearDownCalled = 0
+            @classmethod
+            def tearDownClass(cls):
+                Test.tearDownCalled += 1
+                unittest2.TestCase.tearDownClass()
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+            
+        result = self.runTests(Test)
+        
+        self.assertEqual(Test.tearDownCalled, 1)
+        self.assertEqual(result.testsRun, 2)
+        self.assertEqual(len(result.errors), 0)
+    
+    def test_teardown_class_two_classes(self):
+        class Test(unittest2.TestCase):
+            tearDownCalled = 0
+            @classmethod
+            def tearDownClass(cls):
+                Test.tearDownCalled += 1
+                unittest2.TestCase.tearDownClass()
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+            
+        class Test2(unittest2.TestCase):
+            tearDownCalled = 0
+            @classmethod
+            def tearDownClass(cls):
+                Test2.tearDownCalled += 1
+                unittest2.TestCase.tearDownClass()
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+        
+        result = self.runTests(Test, Test2)
+        
+        self.assertEqual(Test.tearDownCalled, 1)
+        self.assertEqual(Test2.tearDownCalled, 1)
+        self.assertEqual(result.testsRun, 4)
+        self.assertEqual(len(result.errors), 0)
+
+    def test_error_in_setupclass(self):
+        class BrokenTest(unittest2.TestCase):
+            @classmethod
+            def setUpClass(cls):
+                raise TypeError('foo')
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+        
+        result = self.runTests(BrokenTest)
+        
+        self.assertEqual(result.testsRun, 0)
+        self.assertEqual(len(result.errors), 1)
+        error, _ = result.errors[0]
+        self.assertEqual(str(error), 
+                    'setUpClass (%s.BrokenTest)' % __name__)
+
+    def test_error_in_teardown_class(self):
+        class Test(unittest2.TestCase):
+            tornDown = 0
+            @classmethod
+            def tearDownClass(cls):
+                Test.tornDown += 1
+                raise TypeError('foo')
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+            
+        class Test2(unittest2.TestCase):
+            tornDown = 0
+            @classmethod
+            def tearDownClass(cls):
+                Test2.tornDown += 1
+                raise TypeError('foo')
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+        
+        result = self.runTests(Test, Test2)
+        self.assertEqual(result.testsRun, 4)
+        self.assertEqual(len(result.errors), 2)
+        self.assertEqual(Test.tornDown, 1)
+        self.assertEqual(Test2.tornDown, 1)
+        
+        error, _ = result.errors[0]
+        self.assertEqual(str(error), 
+                    'tearDownClass (%s.Test)' % __name__)
+
+    def test_class_not_torndown_when_setup_fails(self):
+        class Test(unittest2.TestCase):
+            tornDown = False
+            @classmethod
+            def setUpClass(cls):
+                raise TypeError
+            @classmethod
+            def tearDownClass(cls):
+                Test.tornDown = True
+                raise TypeError('foo')
+            def test_one(self):
+                pass
+
+        self.runTests(Test)
+        self.assertFalse(Test.tornDown)
+    
+    def test_class_not_setup_or_torndown_when_skipped(self):
+        class Test(unittest2.TestCase):
+            classSetUp = False
+            tornDown = False
+            @classmethod
+            def setUpClass(cls):
+                Test.classSetUp = True
+            @classmethod
+            def tearDownClass(cls):
+                Test.tornDown = True
+            def test_one(self):
+                pass
+
+        Test = unittest2.skip("hop")(Test)
+        self.runTests(Test)
+        self.assertFalse(Test.classSetUp)
+        self.assertFalse(Test.tornDown)
+
+    def test_setup_teardown_order_with_pathological_suite(self):
+        results = []
+        
+        class Module1(object):
+            @staticmethod
+            def setUpModule():
+                results.append('Module1.setUpModule')
+            @staticmethod
+            def tearDownModule():
+                results.append('Module1.tearDownModule')
+    
+        class Module2(object):
+            @staticmethod
+            def setUpModule():
+                results.append('Module2.setUpModule')
+            @staticmethod
+            def tearDownModule():
+                results.append('Module2.tearDownModule')
+                
+        class Test1(unittest2.TestCase):
+            @classmethod
+            def setUpClass(cls):
+                results.append('setup 1')
+            @classmethod
+            def tearDownClass(cls):
+                results.append('teardown 1')
+            def testOne(self):
+                results.append('Test1.testOne')
+            def testTwo(self):
+                results.append('Test1.testTwo')
+            
+        class Test2(unittest2.TestCase):
+            @classmethod
+            def setUpClass(cls):
+                results.append('setup 2')
+            @classmethod
+            def tearDownClass(cls):
+                results.append('teardown 2')
+            def testOne(self):
+                results.append('Test2.testOne')
+            def testTwo(self):
+                results.append('Test2.testTwo')
+            
+        class Test3(unittest2.TestCase):
+            @classmethod
+            def setUpClass(cls):
+                results.append('setup 3')
+            @classmethod
+            def tearDownClass(cls):
+                results.append('teardown 3')
+            def testOne(self):
+                results.append('Test3.testOne')
+            def testTwo(self):
+                results.append('Test3.testTwo')
+        
+        Test1.__module__ = Test2.__module__ = 'Module'
+        Test3.__module__ = 'Module2'
+        sys.modules['Module'] = Module1
+        sys.modules['Module2'] = Module2
+        
+        first = unittest2.TestSuite((Test1('testOne'),))
+        second = unittest2.TestSuite((Test1('testTwo'),))
+        third = unittest2.TestSuite((Test2('testOne'),))
+        fourth = unittest2.TestSuite((Test2('testTwo'),))
+        fifth = unittest2.TestSuite((Test3('testOne'),))
+        sixth = unittest2.TestSuite((Test3('testTwo'),))
+        suite = unittest2.TestSuite((first, second, third, fourth, fifth, sixth))
+        
+        runner = self.getRunner()
+        result = runner.run(suite)
+        self.assertEqual(result.testsRun, 6)
+        self.assertEqual(len(result.errors), 0)
+
+        self.assertEqual(results,
+                         ['Module1.setUpModule', 'setup 1', 
+                          'Test1.testOne', 'Test1.testTwo', 'teardown 1',
+                          'setup 2', 'Test2.testOne', 'Test2.testTwo', 
+                          'teardown 2', 'Module1.tearDownModule',
+                          'Module2.setUpModule', 'setup 3',
+                          'Test3.testOne', 'Test3.testTwo', 
+                          'teardown 3', 'Module2.tearDownModule'])
+        
+    def test_setup_module(self):
+        class Module(object):
+            moduleSetup = 0
+            @staticmethod
+            def setUpModule():
+                Module.moduleSetup += 1
+        
+        class Test(unittest2.TestCase):
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+        Test.__module__ = 'Module'
+        sys.modules['Module'] = Module
+        
+        result = self.runTests(Test)
+        self.assertEqual(Module.moduleSetup, 1)
+        self.assertEqual(result.testsRun, 2)
+        self.assertEqual(len(result.errors), 0)
+    
+    def test_error_in_setup_module(self):
+        class Module(object):
+            moduleSetup = 0
+            moduleTornDown = 0
+            @staticmethod
+            def setUpModule():
+                Module.moduleSetup += 1
+                raise TypeError('foo')
+            @staticmethod
+            def tearDownModule():
+                Module.moduleTornDown += 1
+        
+        class Test(unittest2.TestCase):
+            classSetUp = False
+            classTornDown = False
+            @classmethod
+            def setUpClass(cls):
+                Test.classSetUp = True
+            @classmethod
+            def tearDownClass(cls):
+                Test.classTornDown = True
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+        
+        class Test2(unittest2.TestCase):
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+        Test.__module__ = 'Module'
+        Test2.__module__ = 'Module'
+        sys.modules['Module'] = Module
+        
+        result = self.runTests(Test, Test2)
+        self.assertEqual(Module.moduleSetup, 1)
+        self.assertEqual(Module.moduleTornDown, 0)
+        self.assertEqual(result.testsRun, 0)
+        self.assertFalse(Test.classSetUp)
+        self.assertFalse(Test.classTornDown)
+        self.assertEqual(len(result.errors), 1)
+        error, _ = result.errors[0]
+        self.assertEqual(str(error), 'setUpModule (Module)')
+        
+    def test_testcase_with_missing_module(self):
+        class Test(unittest2.TestCase):
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+        Test.__module__ = 'Module'
+        sys.modules.pop('Module', None)
+        
+        result = self.runTests(Test)
+        self.assertEqual(result.testsRun, 2)
+
+    def test_teardown_module(self):
+        class Module(object):
+            moduleTornDown = 0
+            @staticmethod
+            def tearDownModule():
+                Module.moduleTornDown += 1
+        
+        class Test(unittest2.TestCase):
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+        Test.__module__ = 'Module'
+        sys.modules['Module'] = Module
+        
+        result = self.runTests(Test)
+        self.assertEqual(Module.moduleTornDown, 1)
+        self.assertEqual(result.testsRun, 2)
+        self.assertEqual(len(result.errors), 0)
+
+    def test_error_in_teardown_module(self):
+        class Module(object):
+            moduleTornDown = 0
+            @staticmethod
+            def tearDownModule():
+                Module.moduleTornDown += 1
+                raise TypeError('foo')
+        
+        class Test(unittest2.TestCase):
+            classSetUp = False
+            classTornDown = False
+            @classmethod
+            def setUpClass(cls):
+                Test.classSetUp = True
+            @classmethod
+            def tearDownClass(cls):
+                Test.classTornDown = True
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+        
+        class Test2(unittest2.TestCase):
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+        Test.__module__ = 'Module'
+        Test2.__module__ = 'Module'
+        sys.modules['Module'] = Module
+        
+        result = self.runTests(Test, Test2)
+        self.assertEqual(Module.moduleTornDown, 1)
+        self.assertEqual(result.testsRun, 4)
+        self.assertTrue(Test.classSetUp)
+        self.assertTrue(Test.classTornDown)
+        self.assertEqual(len(result.errors), 1)
+        error, _ = result.errors[0]
+        self.assertEqual(str(error), 'tearDownModule (Module)')
+
+    def test_skiptest_in_setupclass(self):
+        class Test(unittest2.TestCase):
+            @classmethod
+            def setUpClass(cls):
+                raise unittest2.SkipTest('foo')
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+
+        result = self.runTests(Test)
+        self.assertEqual(result.testsRun, 0)
+        self.assertEqual(len(result.errors), 0)
+        self.assertEqual(len(result.skipped), 1)
+        skipped = result.skipped[0][0]
+        self.assertEqual(str(skipped), 'setUpClass (%s.Test)' % __name__)
+
+    def test_skiptest_in_setupmodule(self):
+        class Test(unittest2.TestCase):
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+
+        class Module(object):
+            @staticmethod
+            def setUpModule():
+                raise unittest2.SkipTest('foo')
+
+        Test.__module__ = 'Module'
+        sys.modules['Module'] = Module
+
+        result = self.runTests(Test)
+        self.assertEqual(result.testsRun, 0)
+        self.assertEqual(len(result.errors), 0)
+        self.assertEqual(len(result.skipped), 1)
+        skipped = result.skipped[0][0]
+        self.assertEqual(str(skipped), 'setUpModule (Module)')
+
+    def test_suite_debug_executes_setups_and_teardowns(self):
+        ordering = []
+
+        class Module(object):
+            @staticmethod
+            def setUpModule():
+                ordering.append('setUpModule')
+            @staticmethod
+            def tearDownModule():
+                ordering.append('tearDownModule')
+
+        class Test(unittest2.TestCase):
+            @classmethod
+            def setUpClass(cls):
+                ordering.append('setUpClass')
+            @classmethod
+            def tearDownClass(cls):
+                ordering.append('tearDownClass')
+            def test_something(self):
+                ordering.append('test_something')
+
+        Test.__module__ = 'Module'
+        sys.modules['Module'] = Module
+
+        suite = unittest2.defaultTestLoader.loadTestsFromTestCase(Test)
+        suite.debug()
+        expectedOrder = ['setUpModule', 'setUpClass', 'test_something', 'tearDownClass', 'tearDownModule']
+        self.assertEqual(ordering, expectedOrder)
+
+    def test_suite_debug_propagates_exceptions(self):
+        class Module(object):
+            @staticmethod
+            def setUpModule():
+                if phase == 0:
+                    raise Exception('setUpModule')
+            @staticmethod
+            def tearDownModule():
+                if phase == 1:
+                    raise Exception('tearDownModule')
+
+        class Test(unittest2.TestCase):
+            @classmethod
+            def setUpClass(cls):
+                if phase == 2:
+                    raise Exception('setUpClass')
+            @classmethod
+            def tearDownClass(cls):
+                if phase == 3:
+                    raise Exception('tearDownClass')
+            def test_something(self):
+                if phase == 4:
+                    raise Exception('test_something')
+
+        Test.__module__ = 'Module'
+        sys.modules['Module'] = Module
+
+        _suite = unittest2.defaultTestLoader.loadTestsFromTestCase(Test)
+        suite = unittest2.TestSuite()
+        
+        # nesting a suite again exposes a bug in the initial implementation
+        suite.addTest(_suite)
+        messages = ('setUpModule', 'tearDownModule', 'setUpClass', 'tearDownClass', 'test_something')
+        for phase, msg in enumerate(messages):
+            self.assertRaisesRegexp(Exception, msg, suite.debug)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_skipping.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_skipping.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_skipping.py
new file mode 100644
index 0000000..9555b9f
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_skipping.py
@@ -0,0 +1,143 @@
+from unittest2.test.support import LoggingResult
+
+import unittest2
+
+
+class Test_TestSkipping(unittest2.TestCase):
+
+    def test_skipping(self):
+        class Foo(unittest2.TestCase):
+            def test_skip_me(self):
+                self.skipTest("skip")
+        events = []
+        result = LoggingResult(events)
+        test = Foo("test_skip_me")
+        test.run(result)
+        self.assertEqual(events, ['startTest', 'addSkip', 'stopTest'])
+        self.assertEqual(result.skipped, [(test, "skip")])
+
+        # Try letting setUp skip the test now.
+        class Foo(unittest2.TestCase):
+            def setUp(self):
+                self.skipTest("testing")
+            def test_nothing(self): pass
+        events = []
+        result = LoggingResult(events)
+        test = Foo("test_nothing")
+        test.run(result)
+        self.assertEqual(events, ['startTest', 'addSkip', 'stopTest'])
+        self.assertEqual(result.skipped, [(test, "testing")])
+        self.assertEqual(result.testsRun, 1)
+
+    def test_skipping_decorators(self):
+        op_table = ((unittest2.skipUnless, False, True),
+                    (unittest2.skipIf, True, False))
+        for deco, do_skip, dont_skip in op_table:
+            class Foo(unittest2.TestCase):
+                @deco(do_skip, "testing")
+                def test_skip(self): 
+                    pass
+
+                @deco(dont_skip, "testing")
+                def test_dont_skip(self): 
+                    pass
+            
+            test_do_skip = Foo("test_skip")
+            test_dont_skip = Foo("test_dont_skip")
+            suite = unittest2.TestSuite([test_do_skip, test_dont_skip])
+            events = []
+            result = LoggingResult(events)
+            suite.run(result)
+            self.assertEqual(len(result.skipped), 1)
+            expected = ['startTest', 'addSkip', 'stopTest',
+                        'startTest', 'addSuccess', 'stopTest']
+            self.assertEqual(events, expected)
+            self.assertEqual(result.testsRun, 2)
+            self.assertEqual(result.skipped, [(test_do_skip, "testing")])
+            self.assertTrue(result.wasSuccessful())
+        
+    def test_skip_class(self):
+        class Foo(unittest2.TestCase):
+            def test_1(self):
+                record.append(1)
+        
+        # was originally a class decorator...
+        Foo = unittest2.skip("testing")(Foo)
+        record = []
+        result = unittest2.TestResult()
+        test = Foo("test_1")
+        suite = unittest2.TestSuite([test])
+        suite.run(result)
+        self.assertEqual(result.skipped, [(test, "testing")])
+        self.assertEqual(record, [])
+
+    def test_expected_failure(self):
+        class Foo(unittest2.TestCase):
+            @unittest2.expectedFailure
+            def test_die(self):
+                self.fail("help me!")
+        events = []
+        result = LoggingResult(events)
+        test = Foo("test_die")
+        test.run(result)
+        self.assertEqual(events,
+                         ['startTest', 'addExpectedFailure', 'stopTest'])
+        self.assertEqual(result.expectedFailures[0][0], test)
+        self.assertTrue(result.wasSuccessful())
+
+    def test_unexpected_success(self):
+        class Foo(unittest2.TestCase):
+            @unittest2.expectedFailure
+            def test_die(self):
+                pass
+        events = []
+        result = LoggingResult(events)
+        test = Foo("test_die")
+        test.run(result)
+        self.assertEqual(events,
+                         ['startTest', 'addUnexpectedSuccess', 'stopTest'])
+        self.assertFalse(result.failures)
+        self.assertEqual(result.unexpectedSuccesses, [test])
+        self.assertTrue(result.wasSuccessful())
+
+    def test_skip_doesnt_run_setup(self):
+        class Foo(unittest2.TestCase):
+            wasSetUp = False
+            wasTornDown = False
+            def setUp(self):
+                Foo.wasSetUp = True
+            def tornDown(self):
+                Foo.wasTornDown = True
+            @unittest2.skip('testing')
+            def test_1(self):
+                pass
+        
+        result = unittest2.TestResult()
+        test = Foo("test_1")
+        suite = unittest2.TestSuite([test])
+        suite.run(result)
+        self.assertEqual(result.skipped, [(test, "testing")])
+        self.assertFalse(Foo.wasSetUp)
+        self.assertFalse(Foo.wasTornDown)
+    
+    def test_decorated_skip(self):
+        def decorator(func):
+            def inner(*a):
+                return func(*a)
+            return inner
+        
+        class Foo(unittest2.TestCase):
+            @decorator
+            @unittest2.skip('testing')
+            def test_1(self):
+                pass
+        
+        result = unittest2.TestResult()
+        test = Foo("test_1")
+        suite = unittest2.TestSuite([test])
+        suite.run(result)
+        self.assertEqual(result.skipped, [(test, "testing")])
+
+
+if __name__ == '__main__':
+    unittest2.main()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_suite.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_suite.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_suite.py
new file mode 100644
index 0000000..64a72bb
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_suite.py
@@ -0,0 +1,341 @@
+from unittest2.test.support import EqualityMixin, LoggingResult
+
+import sys
+import unittest2
+
+class Test(object):
+    class Foo(unittest2.TestCase):
+        def test_1(self): pass
+        def test_2(self): pass
+        def test_3(self): pass
+        def runTest(self): pass
+
+def _mk_TestSuite(*names):
+    return unittest2.TestSuite(Test.Foo(n) for n in names)
+
+
+class Test_TestSuite(unittest2.TestCase, EqualityMixin):
+
+    ### Set up attributes needed by inherited tests
+    ################################################################
+
+    # Used by EqualityMixin.test_eq
+    eq_pairs = [(unittest2.TestSuite(), unittest2.TestSuite()),
+                (unittest2.TestSuite(), unittest2.TestSuite([])),
+                (_mk_TestSuite('test_1'), _mk_TestSuite('test_1'))]
+
+    # Used by EqualityMixin.test_ne
+    ne_pairs = [(unittest2.TestSuite(), _mk_TestSuite('test_1')),
+                (unittest2.TestSuite([]), _mk_TestSuite('test_1')),
+                (_mk_TestSuite('test_1', 'test_2'), _mk_TestSuite('test_1', 'test_3')),
+                (_mk_TestSuite('test_1'), _mk_TestSuite('test_2'))]
+
+    ################################################################
+    ### /Set up attributes needed by inherited tests
+
+    ### Tests for TestSuite.__init__
+    ################################################################
+
+    # "class TestSuite([tests])"
+    #
+    # The tests iterable should be optional
+    def test_init__tests_optional(self):
+        suite = unittest2.TestSuite()
+
+        self.assertEqual(suite.countTestCases(), 0)
+
+    # "class TestSuite([tests])"
+    # ...
+    # "If tests is given, it must be an iterable of individual test cases
+    # or other test suites that will be used to build the suite initially"
+    #
+    # TestSuite should deal with empty tests iterables by allowing the
+    # creation of an empty suite
+    def test_init__empty_tests(self):
+        suite = unittest2.TestSuite([])
+
+        self.assertEqual(suite.countTestCases(), 0)
+
+    # "class TestSuite([tests])"
+    # ...
+    # "If tests is given, it must be an iterable of individual test cases
+    # or other test suites that will be used to build the suite initially"
+    #
+    # TestSuite should allow any iterable to provide tests
+    def test_init__tests_from_any_iterable(self):
+        def tests():
+            yield unittest2.FunctionTestCase(lambda: None)
+            yield unittest2.FunctionTestCase(lambda: None)
+
+        suite_1 = unittest2.TestSuite(tests())
+        self.assertEqual(suite_1.countTestCases(), 2)
+
+        suite_2 = unittest2.TestSuite(suite_1)
+        self.assertEqual(suite_2.countTestCases(), 2)
+
+        suite_3 = unittest2.TestSuite(set(suite_1))
+        self.assertEqual(suite_3.countTestCases(), 2)
+
+    # "class TestSuite([tests])"
+    # ...
+    # "If tests is given, it must be an iterable of individual test cases
+    # or other test suites that will be used to build the suite initially"
+    #
+    # Does TestSuite() also allow other TestSuite() instances to be present
+    # in the tests iterable?
+    def test_init__TestSuite_instances_in_tests(self):
+        def tests():
+            ftc = unittest2.FunctionTestCase(lambda: None)
+            yield unittest2.TestSuite([ftc])
+            yield unittest2.FunctionTestCase(lambda: None)
+
+        suite = unittest2.TestSuite(tests())
+        self.assertEqual(suite.countTestCases(), 2)
+
+    ################################################################
+    ### /Tests for TestSuite.__init__
+
+    # Container types should support the iter protocol
+    def test_iter(self):
+        test1 = unittest2.FunctionTestCase(lambda: None)
+        test2 = unittest2.FunctionTestCase(lambda: None)
+        suite = unittest2.TestSuite((test1, test2))
+
+        self.assertEqual(list(suite), [test1, test2])
+
+    # "Return the number of tests represented by the this test object.
+    # ...this method is also implemented by the TestSuite class, which can
+    # return larger [greater than 1] values"
+    #
+    # Presumably an empty TestSuite returns 0?
+    def test_countTestCases_zero_simple(self):
+        suite = unittest2.TestSuite()
+
+        self.assertEqual(suite.countTestCases(), 0)
+
+    # "Return the number of tests represented by the this test object.
+    # ...this method is also implemented by the TestSuite class, which can
+    # return larger [greater than 1] values"
+    #
+    # Presumably an empty TestSuite (even if it contains other empty
+    # TestSuite instances) returns 0?
+    def test_countTestCases_zero_nested(self):
+        class Test1(unittest2.TestCase):
+            def test(self):
+                pass
+
+        suite = unittest2.TestSuite([unittest2.TestSuite()])
+
+        self.assertEqual(suite.countTestCases(), 0)
+
+    # "Return the number of tests represented by the this test object.
+    # ...this method is also implemented by the TestSuite class, which can
+    # return larger [greater than 1] values"
+    def test_countTestCases_simple(self):
+        test1 = unittest2.FunctionTestCase(lambda: None)
+        test2 = unittest2.FunctionTestCase(lambda: None)
+        suite = unittest2.TestSuite((test1, test2))
+
+        self.assertEqual(suite.countTestCases(), 2)
+
+    # "Return the number of tests represented by the this test object.
+    # ...this method is also implemented by the TestSuite class, which can
+    # return larger [greater than 1] values"
+    #
+    # Make sure this holds for nested TestSuite instances, too
+    def test_countTestCases_nested(self):
+        class Test1(unittest2.TestCase):
+            def test1(self): pass
+            def test2(self): pass
+
+        test2 = unittest2.FunctionTestCase(lambda: None)
+        test3 = unittest2.FunctionTestCase(lambda: None)
+        child = unittest2.TestSuite((Test1('test2'), test2))
+        parent = unittest2.TestSuite((test3, child, Test1('test1')))
+
+        self.assertEqual(parent.countTestCases(), 4)
+
+    # "Run the tests associated with this suite, collecting the result into
+    # the test result object passed as result."
+    #
+    # And if there are no tests? What then?
+    def test_run__empty_suite(self):
+        events = []
+        result = LoggingResult(events)
+
+        suite = unittest2.TestSuite()
+
+        suite.run(result)
+
+        self.assertEqual(events, [])
+
+    # "Note that unlike TestCase.run(), TestSuite.run() requires the
+    # "result object to be passed in."
+    def test_run__requires_result(self):
+        suite = unittest2.TestSuite()
+
+        try:
+            suite.run()
+        except TypeError:
+            pass
+        else:
+            self.fail("Failed to raise TypeError")
+
+    # "Run the tests associated with this suite, collecting the result into
+    # the test result object passed as result."
+    def test_run(self):
+        events = []
+        result = LoggingResult(events)
+
+        class LoggingCase(unittest2.TestCase):
+            def run(self, result):
+                events.append('run %s' % self._testMethodName)
+
+            def test1(self): pass
+            def test2(self): pass
+
+        tests = [LoggingCase('test1'), LoggingCase('test2')]
+
+        unittest2.TestSuite(tests).run(result)
+
+        self.assertEqual(events, ['run test1', 'run test2'])
+
+    # "Add a TestCase ... to the suite"
+    def test_addTest__TestCase(self):
+        class Foo(unittest2.TestCase):
+            def test(self): pass
+
+        test = Foo('test')
+        suite = unittest2.TestSuite()
+
+        suite.addTest(test)
+
+        self.assertEqual(suite.countTestCases(), 1)
+        self.assertEqual(list(suite), [test])
+
+    # "Add a ... TestSuite to the suite"
+    def test_addTest__TestSuite(self):
+        class Foo(unittest2.TestCase):
+            def test(self): pass
+
+        suite_2 = unittest2.TestSuite([Foo('test')])
+
+        suite = unittest2.TestSuite()
+        suite.addTest(suite_2)
+
+        self.assertEqual(suite.countTestCases(), 1)
+        self.assertEqual(list(suite), [suite_2])
+
+    # "Add all the tests from an iterable of TestCase and TestSuite
+    # instances to this test suite."
+    #
+    # "This is equivalent to iterating over tests, calling addTest() for
+    # each element"
+    def test_addTests(self):
+        class Foo(unittest2.TestCase):
+            def test_1(self): pass
+            def test_2(self): pass
+
+        test_1 = Foo('test_1')
+        test_2 = Foo('test_2')
+        inner_suite = unittest2.TestSuite([test_2])
+
+        def gen():
+            yield test_1
+            yield test_2
+            yield inner_suite
+
+        suite_1 = unittest2.TestSuite()
+        suite_1.addTests(gen())
+
+        self.assertEqual(list(suite_1), list(gen()))
+
+        # "This is equivalent to iterating over tests, calling addTest() for
+        # each element"
+        suite_2 = unittest2.TestSuite()
+        for t in gen():
+            suite_2.addTest(t)
+
+        self.assertEqual(suite_1, suite_2)
+
+    # "Add all the tests from an iterable of TestCase and TestSuite
+    # instances to this test suite."
+    #
+    # What happens if it doesn't get an iterable?
+    def test_addTest__noniterable(self):
+        suite = unittest2.TestSuite()
+
+        try:
+            suite.addTests(5)
+        except TypeError:
+            pass
+        else:
+            self.fail("Failed to raise TypeError")
+
+    def test_addTest__noncallable(self):
+        suite = unittest2.TestSuite()
+        self.assertRaises(TypeError, suite.addTest, 5)
+
+    def test_addTest__casesuiteclass(self):
+        suite = unittest2.TestSuite()
+        self.assertRaises(TypeError, suite.addTest, Test_TestSuite)
+        self.assertRaises(TypeError, suite.addTest, unittest2.TestSuite)
+
+    def test_addTests__string(self):
+        suite = unittest2.TestSuite()
+        self.assertRaises(TypeError, suite.addTests, "foo")
+
+    def test_function_in_suite(self):
+        def f(_):
+            pass
+        suite = unittest2.TestSuite()
+        suite.addTest(f)
+
+        # when the bug is fixed this line will not crash
+        suite.run(unittest2.TestResult())
+
+
+    def test_basetestsuite(self):
+        class Test(unittest2.TestCase):
+            wasSetUp = False
+            wasTornDown = False
+            @classmethod
+            def setUpClass(cls):
+                cls.wasSetUp = True
+            @classmethod
+            def tearDownClass(cls):
+                cls.wasTornDown = True
+            def testPass(self):
+                pass
+            def testFail(self):
+                fail
+        class Module(object):
+            wasSetUp = False
+            wasTornDown = False
+            @staticmethod
+            def setUpModule():
+                Module.wasSetUp = True
+            @staticmethod
+            def tearDownModule():
+                Module.wasTornDown = True
+        
+        Test.__module__ = 'Module'
+        sys.modules['Module'] = Module
+        self.addCleanup(sys.modules.pop, 'Module')
+        
+        suite = unittest2.BaseTestSuite()
+        suite.addTests([Test('testPass'), Test('testFail')])
+        self.assertEqual(suite.countTestCases(), 2)
+
+        result = unittest2.TestResult()
+        suite.run(result)
+        self.assertFalse(Module.wasSetUp)
+        self.assertFalse(Module.wasTornDown)
+        self.assertFalse(Test.wasSetUp)
+        self.assertFalse(Test.wasTornDown)
+        self.assertEqual(len(result.errors), 1)
+        self.assertEqual(len(result.failures), 0)
+        self.assertEqual(result.testsRun, 2)
+
+if __name__ == '__main__':
+    unittest2.main()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_unittest2_with.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_unittest2_with.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_unittest2_with.py
new file mode 100644
index 0000000..6a08b6f
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_unittest2_with.py
@@ -0,0 +1,143 @@
+from __future__ import with_statement
+
+import unittest2
+from unittest2.test.support import OldTestResult, catch_warnings
+
+import warnings
+# needed to enable the deprecation warnings
+warnings.simplefilter('default')
+
+class TestWith(unittest2.TestCase):
+    """Tests that use the with statement live in this
+    module so that all other tests can be run with Python 2.4.
+    """
+
+    def testAssertRaisesExcValue(self):
+        class ExceptionMock(Exception):
+            pass
+
+        def Stub(foo):
+            raise ExceptionMock(foo)
+        v = "particular value"
+
+        ctx = self.assertRaises(ExceptionMock)
+        with ctx:
+            Stub(v)
+        e = ctx.exception
+        self.assertIsInstance(e, ExceptionMock)
+        self.assertEqual(e.args[0], v)
+
+    
+    def test_assertRaises(self):
+        def _raise(e):
+            raise e
+        self.assertRaises(KeyError, _raise, KeyError)
+        self.assertRaises(KeyError, _raise, KeyError("key"))
+        try:
+            self.assertRaises(KeyError, lambda: None)
+        except self.failureException, e:
+            self.assertIn("KeyError not raised", e.args)
+        else:
+            self.fail("assertRaises() didn't fail")
+        try:
+            self.assertRaises(KeyError, _raise, ValueError)
+        except ValueError:
+            pass
+        else:
+            self.fail("assertRaises() didn't let exception pass through")
+        with self.assertRaises(KeyError) as cm:
+            try:
+                raise KeyError
+            except Exception, e:
+                raise
+        self.assertIs(cm.exception, e)
+
+        with self.assertRaises(KeyError):
+            raise KeyError("key")
+        try:
+            with self.assertRaises(KeyError):
+                pass
+        except self.failureException, e:
+            self.assertIn("KeyError not raised", e.args)
+        else:
+            self.fail("assertRaises() didn't fail")
+        try:
+            with self.assertRaises(KeyError):
+                raise ValueError
+        except ValueError:
+            pass
+        else:
+            self.fail("assertRaises() didn't let exception pass through")
+
+    def test_assert_dict_unicode_error(self):
+        with catch_warnings(record=True):
+            # This causes a UnicodeWarning due to its craziness
+            one = ''.join(chr(i) for i in range(255))
+            # this used to cause a UnicodeDecodeError constructing the failure msg
+            with self.assertRaises(self.failureException):
+                self.assertDictContainsSubset({'foo': one}, {'foo': u'\uFFFD'})
+
+    def test_formatMessage_unicode_error(self):
+        with catch_warnings(record=True):
+            # This causes a UnicodeWarning due to its craziness
+            one = ''.join(chr(i) for i in range(255))
+            # this used to cause a UnicodeDecodeError constructing msg
+            self._formatMessage(one, u'\uFFFD')
+                
+    def assertOldResultWarning(self, test, failures):
+        with catch_warnings(record=True) as log:
+            result = OldTestResult()
+            test.run(result)
+            self.assertEqual(len(result.failures), failures)
+            warning, = log
+            self.assertIs(warning.category, DeprecationWarning)
+
+    def test_old_testresult(self):
+        class Test(unittest2.TestCase):
+            def testSkip(self):
+                self.skipTest('foobar')
+            @unittest2.expectedFailure
+            def testExpectedFail(self):
+                raise TypeError
+            @unittest2.expectedFailure
+            def testUnexpectedSuccess(self):
+                pass
+        
+        for test_name, should_pass in (('testSkip', True), 
+                                       ('testExpectedFail', True), 
+                                       ('testUnexpectedSuccess', False)):
+            test = Test(test_name)
+            self.assertOldResultWarning(test, int(not should_pass))
+        
+    def test_old_testresult_setup(self):
+        class Test(unittest2.TestCase):
+            def setUp(self):
+                self.skipTest('no reason')
+            def testFoo(self):
+                pass
+        self.assertOldResultWarning(Test('testFoo'), 0)
+        
+    def test_old_testresult_class(self):
+        class Test(unittest2.TestCase):
+            def testFoo(self):
+                pass
+        Test = unittest2.skip('no reason')(Test)
+        self.assertOldResultWarning(Test('testFoo'), 0)
+
+    def testPendingDeprecationMethodNames(self):
+        """Test fail* methods pending deprecation, they will warn in 3.2.
+
+        Do not use these methods.  They will go away in 3.3.
+        """
+        with catch_warnings(record=True):
+            self.failIfEqual(3, 5)
+            self.failUnlessEqual(3, 3)
+            self.failUnlessAlmostEqual(2.0, 2.0)
+            self.failIfAlmostEqual(3.0, 5.0)
+            self.failUnless(True)
+            self.failUnlessRaises(TypeError, lambda _: 3.14 + u'spam')
+            self.failIf(False)
+
+
+if __name__ == '__main__':
+    unittest2.main()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/util.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/util.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/util.py
new file mode 100644
index 0000000..c45d008
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/util.py
@@ -0,0 +1,99 @@
+"""Various utility functions."""
+
+__unittest = True
+
+
+_MAX_LENGTH = 80
+def safe_repr(obj, short=False):
+    try:
+        result = repr(obj)
+    except Exception:
+        result = object.__repr__(obj)
+    if not short or len(result) < _MAX_LENGTH:
+        return result
+    return result[:_MAX_LENGTH] + ' [truncated]...'
+
+def safe_str(obj):
+    try:
+        return str(obj)
+    except Exception:
+        return object.__str__(obj)
+
+def strclass(cls):
+    return "%s.%s" % (cls.__module__, cls.__name__)
+
+def sorted_list_difference(expected, actual):
+    """Finds elements in only one or the other of two, sorted input lists.
+
+    Returns a two-element tuple of lists.    The first list contains those
+    elements in the "expected" list but not in the "actual" list, and the
+    second contains those elements in the "actual" list but not in the
+    "expected" list.    Duplicate elements in either input list are ignored.
+    """
+    i = j = 0
+    missing = []
+    unexpected = []
+    while True:
+        try:
+            e = expected[i]
+            a = actual[j]
+            if e < a:
+                missing.append(e)
+                i += 1
+                while expected[i] == e:
+                    i += 1
+            elif e > a:
+                unexpected.append(a)
+                j += 1
+                while actual[j] == a:
+                    j += 1
+            else:
+                i += 1
+                try:
+                    while expected[i] == e:
+                        i += 1
+                finally:
+                    j += 1
+                    while actual[j] == a:
+                        j += 1
+        except IndexError:
+            missing.extend(expected[i:])
+            unexpected.extend(actual[j:])
+            break
+    return missing, unexpected
+
+def unorderable_list_difference(expected, actual, ignore_duplicate=False):
+    """Same behavior as sorted_list_difference but
+    for lists of unorderable items (like dicts).
+
+    As it does a linear search per item (remove) it
+    has O(n*n) performance.
+    """
+    missing = []
+    unexpected = []
+    while expected:
+        item = expected.pop()
+        try:
+            actual.remove(item)
+        except ValueError:
+            missing.append(item)
+        if ignore_duplicate:
+            for lst in expected, actual:
+                try:
+                    while True:
+                        lst.remove(item)
+                except ValueError:
+                    pass
+    if ignore_duplicate:
+        while actual:
+            item = actual.pop()
+            unexpected.append(item)
+            try:
+                while True:
+                    actual.remove(item)
+            except ValueError:
+                pass
+        return missing, unexpected
+
+    # anything left in actual is unexpected
+    return missing, actual


[23/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code

Posted by rl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/yaml/loader.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/yaml/loader.py b/tools/bin/ext/yaml/loader.py
new file mode 100644
index 0000000..29461f4
--- /dev/null
+++ b/tools/bin/ext/yaml/loader.py
@@ -0,0 +1,56 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+__all__ = ['BaseLoader', 'SafeLoader', 'Loader']
+
+from reader import *
+from scanner import *
+from parser import *
+from composer import *
+from constructor import *
+from resolver import *
+
+class BaseLoader(Reader, Scanner, Parser, Composer, BaseConstructor, BaseResolver):
+
+    def __init__(self, stream):
+        Reader.__init__(self, stream)
+        Scanner.__init__(self)
+        Parser.__init__(self)
+        Composer.__init__(self)
+        BaseConstructor.__init__(self)
+        BaseResolver.__init__(self)
+
+class SafeLoader(Reader, Scanner, Parser, Composer, SafeConstructor, Resolver):
+
+    def __init__(self, stream):
+        Reader.__init__(self, stream)
+        Scanner.__init__(self)
+        Parser.__init__(self)
+        Composer.__init__(self)
+        SafeConstructor.__init__(self)
+        Resolver.__init__(self)
+
+class Loader(Reader, Scanner, Parser, Composer, Constructor, Resolver):
+
+    def __init__(self, stream):
+        Reader.__init__(self, stream)
+        Scanner.__init__(self)
+        Parser.__init__(self)
+        Composer.__init__(self)
+        Constructor.__init__(self)
+        Resolver.__init__(self)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/yaml/nodes.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/yaml/nodes.py b/tools/bin/ext/yaml/nodes.py
new file mode 100644
index 0000000..3fdfbe6
--- /dev/null
+++ b/tools/bin/ext/yaml/nodes.py
@@ -0,0 +1,65 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class Node(object):
+    def __init__(self, tag, value, start_mark, end_mark):
+        self.tag = tag
+        self.value = value
+        self.start_mark = start_mark
+        self.end_mark = end_mark
+    def __repr__(self):
+        value = self.value
+        #if isinstance(value, list):
+        #    if len(value) == 0:
+        #        value = '<empty>'
+        #    elif len(value) == 1:
+        #        value = '<1 item>'
+        #    else:
+        #        value = '<%d items>' % len(value)
+        #else:
+        #    if len(value) > 75:
+        #        value = repr(value[:70]+u' ... ')
+        #    else:
+        #        value = repr(value)
+        value = repr(value)
+        return '%s(tag=%r, value=%s)' % (self.__class__.__name__, self.tag, value)
+
+class ScalarNode(Node):
+    id = 'scalar'
+    def __init__(self, tag, value,
+            start_mark=None, end_mark=None, style=None):
+        self.tag = tag
+        self.value = value
+        self.start_mark = start_mark
+        self.end_mark = end_mark
+        self.style = style
+
+class CollectionNode(Node):
+    def __init__(self, tag, value,
+            start_mark=None, end_mark=None, flow_style=None):
+        self.tag = tag
+        self.value = value
+        self.start_mark = start_mark
+        self.end_mark = end_mark
+        self.flow_style = flow_style
+
+class SequenceNode(CollectionNode):
+    id = 'sequence'
+
+class MappingNode(CollectionNode):
+    id = 'mapping'
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/yaml/parser.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/yaml/parser.py b/tools/bin/ext/yaml/parser.py
new file mode 100644
index 0000000..a1228f6
--- /dev/null
+++ b/tools/bin/ext/yaml/parser.py
@@ -0,0 +1,602 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# The following YAML grammar is LL(1) and is parsed by a recursive descent
+# parser.
+#
+# stream            ::= STREAM-START implicit_document? explicit_document* STREAM-END
+# implicit_document ::= block_node DOCUMENT-END*
+# explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*
+# block_node_or_indentless_sequence ::=
+#                       ALIAS
+#                       | properties (block_content | indentless_block_sequence)?
+#                       | block_content
+#                       | indentless_block_sequence
+# block_node        ::= ALIAS
+#                       | properties block_content?
+#                       | block_content
+# flow_node         ::= ALIAS
+#                       | properties flow_content?
+#                       | flow_content
+# properties        ::= TAG ANCHOR? | ANCHOR TAG?
+# block_content     ::= block_collection | flow_collection | SCALAR
+# flow_content      ::= flow_collection | SCALAR
+# block_collection  ::= block_sequence | block_mapping
+# flow_collection   ::= flow_sequence | flow_mapping
+# block_sequence    ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END
+# indentless_sequence   ::= (BLOCK-ENTRY block_node?)+
+# block_mapping     ::= BLOCK-MAPPING_START
+#                       ((KEY block_node_or_indentless_sequence?)?
+#                       (VALUE block_node_or_indentless_sequence?)?)*
+#                       BLOCK-END
+# flow_sequence     ::= FLOW-SEQUENCE-START
+#                       (flow_sequence_entry FLOW-ENTRY)*
+#                       flow_sequence_entry?
+#                       FLOW-SEQUENCE-END
+# flow_sequence_entry   ::= flow_node | KEY flow_node? (VALUE flow_node?)?
+# flow_mapping      ::= FLOW-MAPPING-START
+#                       (flow_mapping_entry FLOW-ENTRY)*
+#                       flow_mapping_entry?
+#                       FLOW-MAPPING-END
+# flow_mapping_entry    ::= flow_node | KEY flow_node? (VALUE flow_node?)?
+#
+# FIRST sets:
+#
+# stream: { STREAM-START }
+# explicit_document: { DIRECTIVE DOCUMENT-START }
+# implicit_document: FIRST(block_node)
+# block_node: { ALIAS TAG ANCHOR SCALAR BLOCK-SEQUENCE-START BLOCK-MAPPING-START FLOW-SEQUENCE-START FLOW-MAPPING-START }
+# flow_node: { ALIAS ANCHOR TAG SCALAR FLOW-SEQUENCE-START FLOW-MAPPING-START }
+# block_content: { BLOCK-SEQUENCE-START BLOCK-MAPPING-START FLOW-SEQUENCE-START FLOW-MAPPING-START SCALAR }
+# flow_content: { FLOW-SEQUENCE-START FLOW-MAPPING-START SCALAR }
+# block_collection: { BLOCK-SEQUENCE-START BLOCK-MAPPING-START }
+# flow_collection: { FLOW-SEQUENCE-START FLOW-MAPPING-START }
+# block_sequence: { BLOCK-SEQUENCE-START }
+# block_mapping: { BLOCK-MAPPING-START }
+# block_node_or_indentless_sequence: { ALIAS ANCHOR TAG SCALAR BLOCK-SEQUENCE-START BLOCK-MAPPING-START FLOW-SEQUENCE-START FLOW-MAPPING-START BLOCK-ENTRY }
+# indentless_sequence: { ENTRY }
+# flow_collection: { FLOW-SEQUENCE-START FLOW-MAPPING-START }
+# flow_sequence: { FLOW-SEQUENCE-START }
+# flow_mapping: { FLOW-MAPPING-START }
+# flow_sequence_entry: { ALIAS ANCHOR TAG SCALAR FLOW-SEQUENCE-START FLOW-MAPPING-START KEY }
+# flow_mapping_entry: { ALIAS ANCHOR TAG SCALAR FLOW-SEQUENCE-START FLOW-MAPPING-START KEY }
+
+__all__ = ['Parser', 'ParserError']
+
+from error import MarkedYAMLError
+from tokens import *
+from events import *
+from scanner import *
+
+class ParserError(MarkedYAMLError):
+    pass
+
+class Parser(object):
+    # Since writing a recursive-descendant parser is a straightforward task, we
+    # do not give many comments here.
+    # Note that we use Python generators. If you rewrite the parser in another
+    # language, you may replace all 'yield'-s with event handler calls.
+
+    DEFAULT_TAGS = {
+        u'!':   u'!',
+        u'!!':  u'tag:yaml.org,2002:',
+    }
+
+    def __init__(self):
+        self.current_event = None
+        self.yaml_version = None
+        self.tag_handles = {}
+        self.states = []
+        self.marks = []
+        self.state = self.parse_stream_start
+
+    def check_event(self, *choices):
+        # Check the type of the next event.
+        if self.current_event is None:
+            if self.state:
+                self.current_event = self.state()
+        if self.current_event is not None:
+            if not choices:
+                return True
+            for choice in choices:
+                if isinstance(self.current_event, choice):
+                    return True
+        return False
+
+    def peek_event(self):
+        # Get the next event.
+        if self.current_event is None:
+            if self.state:
+                self.current_event = self.state()
+        return self.current_event
+
+    def get_event(self):
+        # Get the next event and proceed further.
+        if self.current_event is None:
+            if self.state:
+                self.current_event = self.state()
+        value = self.current_event
+        self.current_event = None
+        return value
+
+    # stream    ::= STREAM-START implicit_document? explicit_document* STREAM-END
+    # implicit_document ::= block_node DOCUMENT-END*
+    # explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*
+
+    def parse_stream_start(self):
+
+        # Parse the stream start.
+        token = self.get_token()
+        event = StreamStartEvent(token.start_mark, token.end_mark,
+                encoding=token.encoding)
+
+        # Prepare the next state.
+        self.state = self.parse_implicit_document_start
+
+        return event
+
+    def parse_implicit_document_start(self):
+
+        # Parse an implicit document.
+        if not self.check_token(DirectiveToken, DocumentStartToken,
+                StreamEndToken):
+            self.tag_handles = self.DEFAULT_TAGS
+            token = self.peek_token()
+            start_mark = end_mark = token.start_mark
+            event = DocumentStartEvent(start_mark, end_mark,
+                    explicit=False)
+
+            # Prepare the next state.
+            self.states.append(self.parse_document_end)
+            self.state = self.parse_block_node
+
+            return event
+
+        else:
+            return self.parse_document_start()
+
+    def parse_document_start(self):
+
+        # Parse any extra document end indicators.
+        while self.check_token(DocumentEndToken):
+            self.get_token()
+
+        # Parse an explicit document.
+        if not self.check_token(StreamEndToken):
+            token = self.peek_token()
+            start_mark = token.start_mark
+            version, tags = self.process_directives()
+            if not self.check_token(DocumentStartToken):
+                raise ParserError(None, None,
+                        "expected '<document start>', but found %r"
+                        % self.peek_token().id,
+                        self.peek_token().start_mark)
+            token = self.get_token()
+            end_mark = token.end_mark
+            event = DocumentStartEvent(start_mark, end_mark,
+                    explicit=True, version=version, tags=tags)
+            self.states.append(self.parse_document_end)
+            self.state = self.parse_document_content
+        else:
+            # Parse the end of the stream.
+            token = self.get_token()
+            event = StreamEndEvent(token.start_mark, token.end_mark)
+            assert not self.states
+            assert not self.marks
+            self.state = None
+        return event
+
+    def parse_document_end(self):
+
+        # Parse the document end.
+        token = self.peek_token()
+        start_mark = end_mark = token.start_mark
+        explicit = False
+        if self.check_token(DocumentEndToken):
+            token = self.get_token()
+            end_mark = token.end_mark
+            explicit = True
+        event = DocumentEndEvent(start_mark, end_mark,
+                explicit=explicit)
+
+        # Prepare the next state.
+        self.state = self.parse_document_start
+
+        return event
+
+    def parse_document_content(self):
+        if self.check_token(DirectiveToken,
+                DocumentStartToken, DocumentEndToken, StreamEndToken):
+            event = self.process_empty_scalar(self.peek_token().start_mark)
+            self.state = self.states.pop()
+            return event
+        else:
+            return self.parse_block_node()
+
+    def process_directives(self):
+        self.yaml_version = None
+        self.tag_handles = {}
+        while self.check_token(DirectiveToken):
+            token = self.get_token()
+            if token.name == u'YAML':
+                if self.yaml_version is not None:
+                    raise ParserError(None, None,
+                            "found duplicate YAML directive", token.start_mark)
+                major, minor = token.value
+                if major != 1:
+                    raise ParserError(None, None,
+                            "found incompatible YAML document (version 1.* is required)",
+                            token.start_mark)
+                self.yaml_version = token.value
+            elif token.name == u'TAG':
+                handle, prefix = token.value
+                if handle in self.tag_handles:
+                    raise ParserError(None, None,
+                            "duplicate tag handle %r" % handle.encode('utf-8'),
+                            token.start_mark)
+                self.tag_handles[handle] = prefix
+        if self.tag_handles:
+            value = self.yaml_version, self.tag_handles.copy()
+        else:
+            value = self.yaml_version, None
+        for key in self.DEFAULT_TAGS:
+            if key not in self.tag_handles:
+                self.tag_handles[key] = self.DEFAULT_TAGS[key]
+        return value
+
+    # block_node_or_indentless_sequence ::= ALIAS
+    #               | properties (block_content | indentless_block_sequence)?
+    #               | block_content
+    #               | indentless_block_sequence
+    # block_node    ::= ALIAS
+    #                   | properties block_content?
+    #                   | block_content
+    # flow_node     ::= ALIAS
+    #                   | properties flow_content?
+    #                   | flow_content
+    # properties    ::= TAG ANCHOR? | ANCHOR TAG?
+    # block_content     ::= block_collection | flow_collection | SCALAR
+    # flow_content      ::= flow_collection | SCALAR
+    # block_collection  ::= block_sequence | block_mapping
+    # flow_collection   ::= flow_sequence | flow_mapping
+
+    def parse_block_node(self):
+        return self.parse_node(block=True)
+
+    def parse_flow_node(self):
+        return self.parse_node()
+
+    def parse_block_node_or_indentless_sequence(self):
+        return self.parse_node(block=True, indentless_sequence=True)
+
+    def parse_node(self, block=False, indentless_sequence=False):
+        if self.check_token(AliasToken):
+            token = self.get_token()
+            event = AliasEvent(token.value, token.start_mark, token.end_mark)
+            self.state = self.states.pop()
+        else:
+            anchor = None
+            tag = None
+            start_mark = end_mark = tag_mark = None
+            if self.check_token(AnchorToken):
+                token = self.get_token()
+                start_mark = token.start_mark
+                end_mark = token.end_mark
+                anchor = token.value
+                if self.check_token(TagToken):
+                    token = self.get_token()
+                    tag_mark = token.start_mark
+                    end_mark = token.end_mark
+                    tag = token.value
+            elif self.check_token(TagToken):
+                token = self.get_token()
+                start_mark = tag_mark = token.start_mark
+                end_mark = token.end_mark
+                tag = token.value
+                if self.check_token(AnchorToken):
+                    token = self.get_token()
+                    end_mark = token.end_mark
+                    anchor = token.value
+            if tag is not None:
+                handle, suffix = tag
+                if handle is not None:
+                    if handle not in self.tag_handles:
+                        raise ParserError("while parsing a node", start_mark,
+                                "found undefined tag handle %r" % handle.encode('utf-8'),
+                                tag_mark)
+                    tag = self.tag_handles[handle]+suffix
+                else:
+                    tag = suffix
+            #if tag == u'!':
+            #    raise ParserError("while parsing a node", start_mark,
+            #            "found non-specific tag '!'", tag_mark,
+            #            "Please check 'http://pyyaml.org/wiki/YAMLNonSpecificTag' and share your opinion.")
+            if start_mark is None:
+                start_mark = end_mark = self.peek_token().start_mark
+            event = None
+            implicit = (tag is None or tag == u'!')
+            if indentless_sequence and self.check_token(BlockEntryToken):
+                end_mark = self.peek_token().end_mark
+                event = SequenceStartEvent(anchor, tag, implicit,
+                        start_mark, end_mark)
+                self.state = self.parse_indentless_sequence_entry
+            else:
+                if self.check_token(ScalarToken):
+                    token = self.get_token()
+                    end_mark = token.end_mark
+                    if (token.plain and tag is None) or tag == u'!':
+                        implicit = (True, False)
+                    elif tag is None:
+                        implicit = (False, True)
+                    else:
+                        implicit = (False, False)
+                    event = ScalarEvent(anchor, tag, implicit, token.value,
+                            start_mark, end_mark, style=token.style)
+                    self.state = self.states.pop()
+                elif self.check_token(FlowSequenceStartToken):
+                    end_mark = self.peek_token().end_mark
+                    event = SequenceStartEvent(anchor, tag, implicit,
+                            start_mark, end_mark, flow_style=True)
+                    self.state = self.parse_flow_sequence_first_entry
+                elif self.check_token(FlowMappingStartToken):
+                    end_mark = self.peek_token().end_mark
+                    event = MappingStartEvent(anchor, tag, implicit,
+                            start_mark, end_mark, flow_style=True)
+                    self.state = self.parse_flow_mapping_first_key
+                elif block and self.check_token(BlockSequenceStartToken):
+                    end_mark = self.peek_token().start_mark
+                    event = SequenceStartEvent(anchor, tag, implicit,
+                            start_mark, end_mark, flow_style=False)
+                    self.state = self.parse_block_sequence_first_entry
+                elif block and self.check_token(BlockMappingStartToken):
+                    end_mark = self.peek_token().start_mark
+                    event = MappingStartEvent(anchor, tag, implicit,
+                            start_mark, end_mark, flow_style=False)
+                    self.state = self.parse_block_mapping_first_key
+                elif anchor is not None or tag is not None:
+                    # Empty scalars are allowed even if a tag or an anchor is
+                    # specified.
+                    event = ScalarEvent(anchor, tag, (implicit, False), u'',
+                            start_mark, end_mark)
+                    self.state = self.states.pop()
+                else:
+                    if block:
+                        node = 'block'
+                    else:
+                        node = 'flow'
+                    token = self.peek_token()
+                    raise ParserError("while parsing a %s node" % node, start_mark,
+                            "expected the node content, but found %r" % token.id,
+                            token.start_mark)
+        return event
+
+    # block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END
+
+    def parse_block_sequence_first_entry(self):
+        token = self.get_token()
+        self.marks.append(token.start_mark)
+        return self.parse_block_sequence_entry()
+
+    def parse_block_sequence_entry(self):
+        if self.check_token(BlockEntryToken):
+            token = self.get_token()
+            if not self.check_token(BlockEntryToken, BlockEndToken):
+                self.states.append(self.parse_block_sequence_entry)
+                return self.parse_block_node()
+            else:
+                self.state = self.parse_block_sequence_entry
+                return self.process_empty_scalar(token.end_mark)
+        if not self.check_token(BlockEndToken):
+            token = self.peek_token()
+            raise ParserError("while parsing a block collection", self.marks[-1],
+                    "expected <block end>, but found %r" % token.id, token.start_mark)
+        token = self.get_token()
+        event = SequenceEndEvent(token.start_mark, token.end_mark)
+        self.state = self.states.pop()
+        self.marks.pop()
+        return event
+
+    # indentless_sequence ::= (BLOCK-ENTRY block_node?)+
+
+    def parse_indentless_sequence_entry(self):
+        if self.check_token(BlockEntryToken):
+            token = self.get_token()
+            if not self.check_token(BlockEntryToken,
+                    KeyToken, ValueToken, BlockEndToken):
+                self.states.append(self.parse_indentless_sequence_entry)
+                return self.parse_block_node()
+            else:
+                self.state = self.parse_indentless_sequence_entry
+                return self.process_empty_scalar(token.end_mark)
+        token = self.peek_token()
+        event = SequenceEndEvent(token.start_mark, token.start_mark)
+        self.state = self.states.pop()
+        return event
+
+    # block_mapping     ::= BLOCK-MAPPING_START
+    #                       ((KEY block_node_or_indentless_sequence?)?
+    #                       (VALUE block_node_or_indentless_sequence?)?)*
+    #                       BLOCK-END
+
+    def parse_block_mapping_first_key(self):
+        token = self.get_token()
+        self.marks.append(token.start_mark)
+        return self.parse_block_mapping_key()
+
+    def parse_block_mapping_key(self):
+        if self.check_token(KeyToken):
+            token = self.get_token()
+            if not self.check_token(KeyToken, ValueToken, BlockEndToken):
+                self.states.append(self.parse_block_mapping_value)
+                return self.parse_block_node_or_indentless_sequence()
+            else:
+                self.state = self.parse_block_mapping_value
+                return self.process_empty_scalar(token.end_mark)
+        if not self.check_token(BlockEndToken):
+            token = self.peek_token()
+            raise ParserError("while parsing a block mapping", self.marks[-1],
+                    "expected <block end>, but found %r" % token.id, token.start_mark)
+        token = self.get_token()
+        event = MappingEndEvent(token.start_mark, token.end_mark)
+        self.state = self.states.pop()
+        self.marks.pop()
+        return event
+
+    def parse_block_mapping_value(self):
+        if self.check_token(ValueToken):
+            token = self.get_token()
+            if not self.check_token(KeyToken, ValueToken, BlockEndToken):
+                self.states.append(self.parse_block_mapping_key)
+                return self.parse_block_node_or_indentless_sequence()
+            else:
+                self.state = self.parse_block_mapping_key
+                return self.process_empty_scalar(token.end_mark)
+        else:
+            self.state = self.parse_block_mapping_key
+            token = self.peek_token()
+            return self.process_empty_scalar(token.start_mark)
+
+    # flow_sequence     ::= FLOW-SEQUENCE-START
+    #                       (flow_sequence_entry FLOW-ENTRY)*
+    #                       flow_sequence_entry?
+    #                       FLOW-SEQUENCE-END
+    # flow_sequence_entry   ::= flow_node | KEY flow_node? (VALUE flow_node?)?
+    #
+    # Note that while production rules for both flow_sequence_entry and
+    # flow_mapping_entry are equal, their interpretations are different.
+    # For `flow_sequence_entry`, the part `KEY flow_node? (VALUE flow_node?)?`
+    # generate an inline mapping (set syntax).
+
+    def parse_flow_sequence_first_entry(self):
+        token = self.get_token()
+        self.marks.append(token.start_mark)
+        return self.parse_flow_sequence_entry(first=True)
+
+    def parse_flow_sequence_entry(self, first=False):
+        if not self.check_token(FlowSequenceEndToken):
+            if not first:
+                if self.check_token(FlowEntryToken):
+                    self.get_token()
+                else:
+                    token = self.peek_token()
+                    raise ParserError("while parsing a flow sequence", self.marks[-1],
+                            "expected ',' or ']', but got %r" % token.id, token.start_mark)
+            
+            if self.check_token(KeyToken):
+                token = self.peek_token()
+                event = MappingStartEvent(None, None, True,
+                        token.start_mark, token.end_mark,
+                        flow_style=True)
+                self.state = self.parse_flow_sequence_entry_mapping_key
+                return event
+            elif not self.check_token(FlowSequenceEndToken):
+                self.states.append(self.parse_flow_sequence_entry)
+                return self.parse_flow_node()
+        token = self.get_token()
+        event = SequenceEndEvent(token.start_mark, token.end_mark)
+        self.state = self.states.pop()
+        self.marks.pop()
+        return event
+
+    def parse_flow_sequence_entry_mapping_key(self):
+        token = self.get_token()
+        if not self.check_token(ValueToken,
+                FlowEntryToken, FlowSequenceEndToken):
+            self.states.append(self.parse_flow_sequence_entry_mapping_value)
+            return self.parse_flow_node()
+        else:
+            self.state = self.parse_flow_sequence_entry_mapping_value
+            return self.process_empty_scalar(token.end_mark)
+
+    def parse_flow_sequence_entry_mapping_value(self):
+        if self.check_token(ValueToken):
+            token = self.get_token()
+            if not self.check_token(FlowEntryToken, FlowSequenceEndToken):
+                self.states.append(self.parse_flow_sequence_entry_mapping_end)
+                return self.parse_flow_node()
+            else:
+                self.state = self.parse_flow_sequence_entry_mapping_end
+                return self.process_empty_scalar(token.end_mark)
+        else:
+            self.state = self.parse_flow_sequence_entry_mapping_end
+            token = self.peek_token()
+            return self.process_empty_scalar(token.start_mark)
+
+    def parse_flow_sequence_entry_mapping_end(self):
+        self.state = self.parse_flow_sequence_entry
+        token = self.peek_token()
+        return MappingEndEvent(token.start_mark, token.start_mark)
+
+    # flow_mapping  ::= FLOW-MAPPING-START
+    #                   (flow_mapping_entry FLOW-ENTRY)*
+    #                   flow_mapping_entry?
+    #                   FLOW-MAPPING-END
+    # flow_mapping_entry    ::= flow_node | KEY flow_node? (VALUE flow_node?)?
+
+    def parse_flow_mapping_first_key(self):
+        token = self.get_token()
+        self.marks.append(token.start_mark)
+        return self.parse_flow_mapping_key(first=True)
+
+    def parse_flow_mapping_key(self, first=False):
+        if not self.check_token(FlowMappingEndToken):
+            if not first:
+                if self.check_token(FlowEntryToken):
+                    self.get_token()
+                else:
+                    token = self.peek_token()
+                    raise ParserError("while parsing a flow mapping", self.marks[-1],
+                            "expected ',' or '}', but got %r" % token.id, token.start_mark)
+            if self.check_token(KeyToken):
+                token = self.get_token()
+                if not self.check_token(ValueToken,
+                        FlowEntryToken, FlowMappingEndToken):
+                    self.states.append(self.parse_flow_mapping_value)
+                    return self.parse_flow_node()
+                else:
+                    self.state = self.parse_flow_mapping_value
+                    return self.process_empty_scalar(token.end_mark)
+            elif not self.check_token(FlowMappingEndToken):
+                self.states.append(self.parse_flow_mapping_empty_value)
+                return self.parse_flow_node()
+        token = self.get_token()
+        event = MappingEndEvent(token.start_mark, token.end_mark)
+        self.state = self.states.pop()
+        self.marks.pop()
+        return event
+
+    def parse_flow_mapping_value(self):
+        if self.check_token(ValueToken):
+            token = self.get_token()
+            if not self.check_token(FlowEntryToken, FlowMappingEndToken):
+                self.states.append(self.parse_flow_mapping_key)
+                return self.parse_flow_node()
+            else:
+                self.state = self.parse_flow_mapping_key
+                return self.process_empty_scalar(token.end_mark)
+        else:
+            self.state = self.parse_flow_mapping_key
+            token = self.peek_token()
+            return self.process_empty_scalar(token.start_mark)
+
+    def parse_flow_mapping_empty_value(self):
+        self.state = self.parse_flow_mapping_key
+        return self.process_empty_scalar(self.peek_token().start_mark)
+
+    def process_empty_scalar(self, mark):
+        return ScalarEvent(None, None, (True, False), u'', mark, mark)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/yaml/reader.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/yaml/reader.py b/tools/bin/ext/yaml/reader.py
new file mode 100644
index 0000000..f36e647
--- /dev/null
+++ b/tools/bin/ext/yaml/reader.py
@@ -0,0 +1,241 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# This module contains abstractions for the input stream. You don't have to
+# looks further, there are no pretty code.
+#
+# We define two classes here.
+#
+#   Mark(source, line, column)
+# It's just a record and its only use is producing nice error messages.
+# Parser does not use it for any other purposes.
+#
+#   Reader(source, data)
+# Reader determines the encoding of `data` and converts it to unicode.
+# Reader provides the following methods and attributes:
+#   reader.peek(length=1) - return the next `length` characters
+#   reader.forward(length=1) - move the current position to `length` characters.
+#   reader.index - the number of the current character.
+#   reader.line, stream.column - the line and the column of the current character.
+
+__all__ = ['Reader', 'ReaderError']
+
+from error import YAMLError, Mark
+
+import codecs, re
+
+# Unfortunately, codec functions in Python 2.3 does not support the `finish`
+# arguments, so we have to write our own wrappers.
+
+try:
+    codecs.utf_8_decode('', 'strict', False)
+    from codecs import utf_8_decode, utf_16_le_decode, utf_16_be_decode
+
+except TypeError:
+
+    def utf_16_le_decode(data, errors, finish=False):
+        if not finish and len(data) % 2 == 1:
+            data = data[:-1]
+        return codecs.utf_16_le_decode(data, errors)
+
+    def utf_16_be_decode(data, errors, finish=False):
+        if not finish and len(data) % 2 == 1:
+            data = data[:-1]
+        return codecs.utf_16_be_decode(data, errors)
+
+    def utf_8_decode(data, errors, finish=False):
+        if not finish:
+            # We are trying to remove a possible incomplete multibyte character
+            # from the suffix of the data.
+            # The first byte of a multi-byte sequence is in the range 0xc0 to 0xfd.
+            # All further bytes are in the range 0x80 to 0xbf.
+            # UTF-8 encoded UCS characters may be up to six bytes long.
+            count = 0
+            while count < 5 and count < len(data)   \
+                    and '\x80' <= data[-count-1] <= '\xBF':
+                count -= 1
+            if count < 5 and count < len(data)  \
+                    and '\xC0' <= data[-count-1] <= '\xFD':
+                data = data[:-count-1]
+        return codecs.utf_8_decode(data, errors)
+
+class ReaderError(YAMLError):
+
+    def __init__(self, name, position, character, encoding, reason):
+        self.name = name
+        self.character = character
+        self.position = position
+        self.encoding = encoding
+        self.reason = reason
+
+    def __str__(self):
+        if isinstance(self.character, str):
+            return "'%s' codec can't decode byte #x%02x: %s\n"  \
+                    "  in \"%s\", position %d"    \
+                    % (self.encoding, ord(self.character), self.reason,
+                            self.name, self.position)
+        else:
+            return "unacceptable character #x%04x: %s\n"    \
+                    "  in \"%s\", position %d"    \
+                    % (ord(self.character), self.reason,
+                            self.name, self.position)
+
+class Reader(object):
+    # Reader:
+    # - determines the data encoding and converts it to unicode,
+    # - checks if characters are in allowed range,
+    # - adds '\0' to the end.
+
+    # Reader accepts
+    #  - a `str` object,
+    #  - a `unicode` object,
+    #  - a file-like object with its `read` method returning `str`,
+    #  - a file-like object with its `read` method returning `unicode`.
+
+    # Yeah, it's ugly and slow.
+
+    def __init__(self, stream):
+        self.name = None
+        self.stream = None
+        self.stream_pointer = 0
+        self.eof = True
+        self.buffer = u''
+        self.pointer = 0
+        self.raw_buffer = None
+        self.raw_decode = None
+        self.encoding = None
+        self.index = 0
+        self.line = 0
+        self.column = 0
+        if isinstance(stream, unicode):
+            self.name = "<unicode string>"
+            self.check_printable(stream)
+            self.buffer = stream+u'\0'
+        elif isinstance(stream, str):
+            self.name = "<string>"
+            self.raw_buffer = stream
+            self.determine_encoding()
+        else:
+            self.stream = stream
+            self.name = getattr(stream, 'name', "<file>")
+            self.eof = False
+            self.raw_buffer = ''
+            self.determine_encoding()
+
+    def peek(self, index=0):
+        try:
+            return self.buffer[self.pointer+index]
+        except IndexError:
+            self.update(index+1)
+            return self.buffer[self.pointer+index]
+
+    def prefix(self, length=1):
+        if self.pointer+length >= len(self.buffer):
+            self.update(length)
+        return self.buffer[self.pointer:self.pointer+length]
+
+    def forward(self, length=1):
+        if self.pointer+length+1 >= len(self.buffer):
+            self.update(length+1)
+        while length:
+            ch = self.buffer[self.pointer]
+            self.pointer += 1
+            self.index += 1
+            if ch in u'\n\x85\u2028\u2029'  \
+                    or (ch == u'\r' and self.buffer[self.pointer] != u'\n'):
+                self.line += 1
+                self.column = 0
+            elif ch != u'\uFEFF':
+                self.column += 1
+            length -= 1
+
+    def get_mark(self):
+        if self.stream is None:
+            return Mark(self.name, self.index, self.line, self.column,
+                    self.buffer, self.pointer)
+        else:
+            return Mark(self.name, self.index, self.line, self.column,
+                    None, None)
+
+    def determine_encoding(self):
+        while not self.eof and len(self.raw_buffer) < 2:
+            self.update_raw()
+        if not isinstance(self.raw_buffer, unicode):
+            if self.raw_buffer.startswith(codecs.BOM_UTF16_LE):
+                self.raw_decode = utf_16_le_decode
+                self.encoding = 'utf-16-le'
+            elif self.raw_buffer.startswith(codecs.BOM_UTF16_BE):
+                self.raw_decode = utf_16_be_decode
+                self.encoding = 'utf-16-be'
+            else:
+                self.raw_decode = utf_8_decode
+                self.encoding = 'utf-8'
+        self.update(1)
+
+    NON_PRINTABLE = re.compile(u'[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD]')
+    def check_printable(self, data):
+        match = self.NON_PRINTABLE.search(data)
+        if match:
+            character = match.group()
+            position = self.index+(len(self.buffer)-self.pointer)+match.start()
+            raise ReaderError(self.name, position, character,
+                    'unicode', "special characters are not allowed")
+
+    def update(self, length):
+        if self.raw_buffer is None:
+            return
+        self.buffer = self.buffer[self.pointer:]
+        self.pointer = 0
+        while len(self.buffer) < length:
+            if not self.eof:
+                self.update_raw()
+            if self.raw_decode is not None:
+                try:
+                    data, converted = self.raw_decode(self.raw_buffer,
+                            'strict', self.eof)
+                except UnicodeDecodeError, exc:
+                    character = exc.object[exc.start]
+                    if self.stream is not None:
+                        position = self.stream_pointer-len(self.raw_buffer)+exc.start
+                    else:
+                        position = exc.start
+                    raise ReaderError(self.name, position, character,
+                            exc.encoding, exc.reason)
+            else:
+                data = self.raw_buffer
+                converted = len(data)
+            self.check_printable(data)
+            self.buffer += data
+            self.raw_buffer = self.raw_buffer[converted:]
+            if self.eof:
+                self.buffer += u'\0'
+                self.raw_buffer = None
+                break
+
+    def update_raw(self, size=1024):
+        data = self.stream.read(size)
+        if data:
+            self.raw_buffer += data
+            self.stream_pointer += len(data)
+        else:
+            self.eof = True
+
+#try:
+#    import psyco
+#    psyco.bind(Reader)
+#except ImportError:
+#    pass
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/yaml/representer.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/yaml/representer.py b/tools/bin/ext/yaml/representer.py
new file mode 100644
index 0000000..b83cc4b
--- /dev/null
+++ b/tools/bin/ext/yaml/representer.py
@@ -0,0 +1,504 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+__all__ = ['BaseRepresenter', 'SafeRepresenter', 'Representer',
+    'RepresenterError']
+
+from error import *
+from nodes import *
+
+import datetime
+
+try:
+    set
+except NameError:
+    from sets import Set as set
+
+import sys, copy_reg, types
+
+class RepresenterError(YAMLError):
+    pass
+
+class BaseRepresenter(object):
+
+    yaml_representers = {}
+    yaml_multi_representers = {}
+
+    def __init__(self, default_style=None, default_flow_style=None):
+        self.default_style = default_style
+        self.default_flow_style = default_flow_style
+        self.represented_objects = {}
+        self.object_keeper = []
+        self.alias_key = None
+
+    def represent(self, data):
+        node = self.represent_data(data)
+        self.serialize(node)
+        self.represented_objects = {}
+        self.object_keeper = []
+        self.alias_key = None
+
+    def get_classobj_bases(self, cls):
+        bases = [cls]
+        for base in cls.__bases__:
+            bases.extend(self.get_classobj_bases(base))
+        return bases
+
+    def represent_data(self, data):
+        if self.ignore_aliases(data):
+            self.alias_key = None
+        else:
+            self.alias_key = id(data)
+        if self.alias_key is not None:
+            if self.alias_key in self.represented_objects:
+                node = self.represented_objects[self.alias_key]
+                #if node is None:
+                #    raise RepresenterError("recursive objects are not allowed: %r" % data)
+                return node
+            #self.represented_objects[alias_key] = None
+            self.object_keeper.append(data)
+        data_types = type(data).__mro__
+        if type(data) is types.InstanceType:
+            data_types = self.get_classobj_bases(data.__class__)+list(data_types)
+        if data_types[0] in self.yaml_representers:
+            node = self.yaml_representers[data_types[0]](self, data)
+        else:
+            for data_type in data_types:
+                if data_type in self.yaml_multi_representers:
+                    node = self.yaml_multi_representers[data_type](self, data)
+                    break
+            else:
+                if None in self.yaml_multi_representers:
+                    node = self.yaml_multi_representers[None](self, data)
+                elif None in self.yaml_representers:
+                    node = self.yaml_representers[None](self, data)
+                else:
+                    node = ScalarNode(None, unicode(data))
+        #if alias_key is not None:
+        #    self.represented_objects[alias_key] = node
+        return node
+
+    def add_representer(cls, data_type, representer):
+        if not 'yaml_representers' in cls.__dict__:
+            cls.yaml_representers = cls.yaml_representers.copy()
+        cls.yaml_representers[data_type] = representer
+    add_representer = classmethod(add_representer)
+
+    def add_multi_representer(cls, data_type, representer):
+        if not 'yaml_multi_representers' in cls.__dict__:
+            cls.yaml_multi_representers = cls.yaml_multi_representers.copy()
+        cls.yaml_multi_representers[data_type] = representer
+    add_multi_representer = classmethod(add_multi_representer)
+
+    def represent_scalar(self, tag, value, style=None):
+        if style is None:
+            style = self.default_style
+        node = ScalarNode(tag, value, style=style)
+        if self.alias_key is not None:
+            self.represented_objects[self.alias_key] = node
+        return node
+
+    def represent_sequence(self, tag, sequence, flow_style=None):
+        value = []
+        node = SequenceNode(tag, value, flow_style=flow_style)
+        if self.alias_key is not None:
+            self.represented_objects[self.alias_key] = node
+        best_style = True
+        for item in sequence:
+            node_item = self.represent_data(item)
+            if not (isinstance(node_item, ScalarNode) and not node_item.style):
+                best_style = False
+            value.append(node_item)
+        if flow_style is None:
+            if self.default_flow_style is not None:
+                node.flow_style = self.default_flow_style
+            else:
+                node.flow_style = best_style
+        return node
+
+    def represent_mapping(self, tag, mapping, flow_style=None):
+        value = []
+        node = MappingNode(tag, value, flow_style=flow_style)
+        if self.alias_key is not None:
+            self.represented_objects[self.alias_key] = node
+        best_style = True
+        if hasattr(mapping, 'items'):
+            mapping = mapping.items()
+            mapping.sort()
+        for item_key, item_value in mapping:
+            node_key = self.represent_data(item_key)
+            node_value = self.represent_data(item_value)
+            if not (isinstance(node_key, ScalarNode) and not node_key.style):
+                best_style = False
+            if not (isinstance(node_value, ScalarNode) and not node_value.style):
+                best_style = False
+            value.append((node_key, node_value))
+        if flow_style is None:
+            if self.default_flow_style is not None:
+                node.flow_style = self.default_flow_style
+            else:
+                node.flow_style = best_style
+        return node
+
+    def ignore_aliases(self, data):
+        return False
+
+class SafeRepresenter(BaseRepresenter):
+
+    def ignore_aliases(self, data):
+        if data in [None, ()]:
+            return True
+        if isinstance(data, (str, unicode, bool, int, float)):
+            return True
+
+    def represent_none(self, data):
+        return self.represent_scalar(u'tag:yaml.org,2002:null',
+                u'null')
+
+    def represent_str(self, data):
+        tag = None
+        style = None
+        try:
+            data = unicode(data, 'ascii')
+            tag = u'tag:yaml.org,2002:str'
+        except UnicodeDecodeError:
+            try:
+                data = unicode(data, 'utf-8')
+                tag = u'tag:yaml.org,2002:str'
+            except UnicodeDecodeError:
+                data = data.encode('base64')
+                tag = u'tag:yaml.org,2002:binary'
+                style = '|'
+        return self.represent_scalar(tag, data, style=style)
+
+    def represent_unicode(self, data):
+        return self.represent_scalar(u'tag:yaml.org,2002:str', data)
+
+    def represent_bool(self, data):
+        if data:
+            value = u'true'
+        else:
+            value = u'false'
+        return self.represent_scalar(u'tag:yaml.org,2002:bool', value)
+
+    def represent_int(self, data):
+        return self.represent_scalar(u'tag:yaml.org,2002:int', unicode(data))
+
+    def represent_long(self, data):
+        return self.represent_scalar(u'tag:yaml.org,2002:int', unicode(data))
+
+    inf_value = 1e300
+    while repr(inf_value) != repr(inf_value*inf_value):
+        inf_value *= inf_value
+
+    def represent_float(self, data):
+        if data != data or (data == 0.0 and data == 1.0):
+            value = u'.nan'
+        elif data == self.inf_value:
+            value = u'.inf'
+        elif data == -self.inf_value:
+            value = u'-.inf'
+        else:
+            value = unicode(repr(data)).lower()
+            # Note that in some cases `repr(data)` represents a float number
+            # without the decimal parts.  For instance:
+            #   >>> repr(1e17)
+            #   '1e17'
+            # Unfortunately, this is not a valid float representation according
+            # to the definition of the `!!float` tag.  We fix this by adding
+            # '.0' before the 'e' symbol.
+            if u'.' not in value and u'e' in value:
+                value = value.replace(u'e', u'.0e', 1)
+        return self.represent_scalar(u'tag:yaml.org,2002:float', value)
+
+    def represent_list(self, data):
+        #pairs = (len(data) > 0 and isinstance(data, list))
+        #if pairs:
+        #    for item in data:
+        #        if not isinstance(item, tuple) or len(item) != 2:
+        #            pairs = False
+        #            break
+        #if not pairs:
+            return self.represent_sequence(u'tag:yaml.org,2002:seq', data)
+        #value = []
+        #for item_key, item_value in data:
+        #    value.append(self.represent_mapping(u'tag:yaml.org,2002:map',
+        #        [(item_key, item_value)]))
+        #return SequenceNode(u'tag:yaml.org,2002:pairs', value)
+
+    def represent_dict(self, data):
+        return self.represent_mapping(u'tag:yaml.org,2002:map', data)
+
+    def represent_set(self, data):
+        value = {}
+        for key in data:
+            value[key] = None
+        return self.represent_mapping(u'tag:yaml.org,2002:set', value)
+
+    def represent_date(self, data):
+        value = unicode(data.isoformat())
+        return self.represent_scalar(u'tag:yaml.org,2002:timestamp', value)
+
+    def represent_datetime(self, data):
+        value = unicode(data.isoformat(' '))
+        return self.represent_scalar(u'tag:yaml.org,2002:timestamp', value)
+
+    def represent_yaml_object(self, tag, data, cls, flow_style=None):
+        if hasattr(data, '__getstate__'):
+            state = data.__getstate__()
+        else:
+            state = data.__dict__.copy()
+        return self.represent_mapping(tag, state, flow_style=flow_style)
+
+    def represent_undefined(self, data):
+        raise RepresenterError("cannot represent an object: %s" % data)
+
+SafeRepresenter.add_representer(type(None),
+        SafeRepresenter.represent_none)
+
+SafeRepresenter.add_representer(str,
+        SafeRepresenter.represent_str)
+
+SafeRepresenter.add_representer(unicode,
+        SafeRepresenter.represent_unicode)
+
+SafeRepresenter.add_representer(bool,
+        SafeRepresenter.represent_bool)
+
+SafeRepresenter.add_representer(int,
+        SafeRepresenter.represent_int)
+
+SafeRepresenter.add_representer(long,
+        SafeRepresenter.represent_long)
+
+SafeRepresenter.add_representer(float,
+        SafeRepresenter.represent_float)
+
+SafeRepresenter.add_representer(list,
+        SafeRepresenter.represent_list)
+
+SafeRepresenter.add_representer(tuple,
+        SafeRepresenter.represent_list)
+
+SafeRepresenter.add_representer(dict,
+        SafeRepresenter.represent_dict)
+
+SafeRepresenter.add_representer(set,
+        SafeRepresenter.represent_set)
+
+SafeRepresenter.add_representer(datetime.date,
+        SafeRepresenter.represent_date)
+SafeRepresenter.add_representer(datetime.datetime,
+        SafeRepresenter.represent_datetime)
+
+SafeRepresenter.add_representer(None,
+        SafeRepresenter.represent_undefined)
+
+class Representer(SafeRepresenter):
+
+    def represent_str(self, data):
+        tag = None
+        style = None
+        try:
+            data = unicode(data, 'ascii')
+            tag = u'tag:yaml.org,2002:str'
+        except UnicodeDecodeError:
+            try:
+                data = unicode(data, 'utf-8')
+                tag = u'tag:yaml.org,2002:python/str'
+            except UnicodeDecodeError:
+                data = data.encode('base64')
+                tag = u'tag:yaml.org,2002:binary'
+                style = '|'
+        return self.represent_scalar(tag, data, style=style)
+
+    def represent_unicode(self, data):
+        tag = None
+        try:
+            data.encode('ascii')
+            tag = u'tag:yaml.org,2002:python/unicode'
+        except UnicodeEncodeError:
+            tag = u'tag:yaml.org,2002:str'
+        return self.represent_scalar(tag, data)
+
+    def represent_long(self, data):
+        tag = u'tag:yaml.org,2002:int'
+        if int(data) is not data:
+            tag = u'tag:yaml.org,2002:python/long'
+        return self.represent_scalar(tag, unicode(data))
+
+    def represent_complex(self, data):
+        if data.imag == 0.0:
+            data = u'%r' % data.real
+        elif data.real == 0.0:
+            data = u'%rj' % data.imag
+        elif data.imag > 0:
+            data = u'%r+%rj' % (data.real, data.imag)
+        else:
+            data = u'%r%rj' % (data.real, data.imag)
+        return self.represent_scalar(u'tag:yaml.org,2002:python/complex', data)
+
+    def represent_tuple(self, data):
+        return self.represent_sequence(u'tag:yaml.org,2002:python/tuple', data)
+
+    def represent_name(self, data):
+        name = u'%s.%s' % (data.__module__, data.__name__)
+        return self.represent_scalar(u'tag:yaml.org,2002:python/name:'+name, u'')
+
+    def represent_module(self, data):
+        return self.represent_scalar(
+                u'tag:yaml.org,2002:python/module:'+data.__name__, u'')
+
+    def represent_instance(self, data):
+        # For instances of classic classes, we use __getinitargs__ and
+        # __getstate__ to serialize the data.
+
+        # If data.__getinitargs__ exists, the object must be reconstructed by
+        # calling cls(**args), where args is a tuple returned by
+        # __getinitargs__. Otherwise, the cls.__init__ method should never be
+        # called and the class instance is created by instantiating a trivial
+        # class and assigning to the instance's __class__ variable.
+
+        # If data.__getstate__ exists, it returns the state of the object.
+        # Otherwise, the state of the object is data.__dict__.
+
+        # We produce either a !!python/object or !!python/object/new node.
+        # If data.__getinitargs__ does not exist and state is a dictionary, we
+        # produce a !!python/object node . Otherwise we produce a
+        # !!python/object/new node.
+
+        cls = data.__class__
+        class_name = u'%s.%s' % (cls.__module__, cls.__name__)
+        args = None
+        state = None
+        if hasattr(data, '__getinitargs__'):
+            args = list(data.__getinitargs__())
+        if hasattr(data, '__getstate__'):
+            state = data.__getstate__()
+        else:
+            state = data.__dict__
+        if args is None and isinstance(state, dict):
+            return self.represent_mapping(
+                    u'tag:yaml.org,2002:python/object:'+class_name, state)
+        if isinstance(state, dict) and not state:
+            return self.represent_sequence(
+                    u'tag:yaml.org,2002:python/object/new:'+class_name, args)
+        value = {}
+        if args:
+            value['args'] = args
+        value['state'] = state
+        return self.represent_mapping(
+                u'tag:yaml.org,2002:python/object/new:'+class_name, value)
+
+    def represent_object(self, data):
+        # We use __reduce__ API to save the data. data.__reduce__ returns
+        # a tuple of length 2-5:
+        #   (function, args, state, listitems, dictitems)
+
+        # For reconstructing, we calls function(*args), then set its state,
+        # listitems, and dictitems if they are not None.
+
+        # A special case is when function.__name__ == '__newobj__'. In this
+        # case we create the object with args[0].__new__(*args).
+
+        # Another special case is when __reduce__ returns a string - we don't
+        # support it.
+
+        # We produce a !!python/object, !!python/object/new or
+        # !!python/object/apply node.
+
+        cls = type(data)
+        if cls in copy_reg.dispatch_table:
+            reduce = copy_reg.dispatch_table[cls](data)
+        elif hasattr(data, '__reduce_ex__'):
+            reduce = data.__reduce_ex__(2)
+        elif hasattr(data, '__reduce__'):
+            reduce = data.__reduce__()
+        else:
+            raise RepresenterError("cannot represent object: %r" % data)
+        reduce = (list(reduce)+[None]*5)[:5]
+        function, args, state, listitems, dictitems = reduce
+        args = list(args)
+        if state is None:
+            state = {}
+        if listitems is not None:
+            listitems = list(listitems)
+        if dictitems is not None:
+            dictitems = dict(dictitems)
+        if function.__name__ == '__newobj__':
+            function = args[0]
+            args = args[1:]
+            tag = u'tag:yaml.org,2002:python/object/new:'
+            newobj = True
+        else:
+            tag = u'tag:yaml.org,2002:python/object/apply:'
+            newobj = False
+        function_name = u'%s.%s' % (function.__module__, function.__name__)
+        if not args and not listitems and not dictitems \
+                and isinstance(state, dict) and newobj:
+            return self.represent_mapping(
+                    u'tag:yaml.org,2002:python/object:'+function_name, state)
+        if not listitems and not dictitems  \
+                and isinstance(state, dict) and not state:
+            return self.represent_sequence(tag+function_name, args)
+        value = {}
+        if args:
+            value['args'] = args
+        if state or not isinstance(state, dict):
+            value['state'] = state
+        if listitems:
+            value['listitems'] = listitems
+        if dictitems:
+            value['dictitems'] = dictitems
+        return self.represent_mapping(tag+function_name, value)
+
+Representer.add_representer(str,
+        Representer.represent_str)
+
+Representer.add_representer(unicode,
+        Representer.represent_unicode)
+
+Representer.add_representer(long,
+        Representer.represent_long)
+
+Representer.add_representer(complex,
+        Representer.represent_complex)
+
+Representer.add_representer(tuple,
+        Representer.represent_tuple)
+
+Representer.add_representer(type,
+        Representer.represent_name)
+
+Representer.add_representer(types.ClassType,
+        Representer.represent_name)
+
+Representer.add_representer(types.FunctionType,
+        Representer.represent_name)
+
+Representer.add_representer(types.BuiltinFunctionType,
+        Representer.represent_name)
+
+Representer.add_representer(types.ModuleType,
+        Representer.represent_module)
+
+Representer.add_multi_representer(types.InstanceType,
+        Representer.represent_instance)
+
+Representer.add_multi_representer(object,
+        Representer.represent_object)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/yaml/resolver.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/yaml/resolver.py b/tools/bin/ext/yaml/resolver.py
new file mode 100644
index 0000000..0feb12b
--- /dev/null
+++ b/tools/bin/ext/yaml/resolver.py
@@ -0,0 +1,239 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+__all__ = ['BaseResolver', 'Resolver']
+
+from error import *
+from nodes import *
+
+import re
+
+class ResolverError(YAMLError):
+    pass
+
+class BaseResolver(object):
+
+    DEFAULT_SCALAR_TAG = u'tag:yaml.org,2002:str'
+    DEFAULT_SEQUENCE_TAG = u'tag:yaml.org,2002:seq'
+    DEFAULT_MAPPING_TAG = u'tag:yaml.org,2002:map'
+
+    yaml_implicit_resolvers = {}
+    yaml_path_resolvers = {}
+
+    def __init__(self):
+        self.resolver_exact_paths = []
+        self.resolver_prefix_paths = []
+
+    def add_implicit_resolver(cls, tag, regexp, first):
+        if not 'yaml_implicit_resolvers' in cls.__dict__:
+            cls.yaml_implicit_resolvers = cls.yaml_implicit_resolvers.copy()
+        if first is None:
+            first = [None]
+        for ch in first:
+            cls.yaml_implicit_resolvers.setdefault(ch, []).append((tag, regexp))
+    add_implicit_resolver = classmethod(add_implicit_resolver)
+
+    def add_path_resolver(cls, tag, path, kind=None):
+        # Note: `add_path_resolver` is experimental.  The API could be changed.
+        # `new_path` is a pattern that is matched against the path from the
+        # root to the node that is being considered.  `node_path` elements are
+        # tuples `(node_check, index_check)`.  `node_check` is a node class:
+        # `ScalarNode`, `SequenceNode`, `MappingNode` or `None`.  `None`
+        # matches any kind of a node.  `index_check` could be `None`, a boolean
+        # value, a string value, or a number.  `None` and `False` match against
+        # any _value_ of sequence and mapping nodes.  `True` matches against
+        # any _key_ of a mapping node.  A string `index_check` matches against
+        # a mapping value that corresponds to a scalar key which content is
+        # equal to the `index_check` value.  An integer `index_check` matches
+        # against a sequence value with the index equal to `index_check`.
+        if not 'yaml_path_resolvers' in cls.__dict__:
+            cls.yaml_path_resolvers = cls.yaml_path_resolvers.copy()
+        new_path = []
+        for element in path:
+            if isinstance(element, (list, tuple)):
+                if len(element) == 2:
+                    node_check, index_check = element
+                elif len(element) == 1:
+                    node_check = element[0]
+                    index_check = True
+                else:
+                    raise ResolverError("Invalid path element: %s" % element)
+            else:
+                node_check = None
+                index_check = element
+            if node_check is str:
+                node_check = ScalarNode
+            elif node_check is list:
+                node_check = SequenceNode
+            elif node_check is dict:
+                node_check = MappingNode
+            elif node_check not in [ScalarNode, SequenceNode, MappingNode]  \
+                    and not isinstance(node_check, basestring)  \
+                    and node_check is not None:
+                raise ResolverError("Invalid node checker: %s" % node_check)
+            if not isinstance(index_check, (basestring, int))   \
+                    and index_check is not None:
+                raise ResolverError("Invalid index checker: %s" % index_check)
+            new_path.append((node_check, index_check))
+        if kind is str:
+            kind = ScalarNode
+        elif kind is list:
+            kind = SequenceNode
+        elif kind is dict:
+            kind = MappingNode
+        elif kind not in [ScalarNode, SequenceNode, MappingNode]    \
+                and kind is not None:
+            raise ResolverError("Invalid node kind: %s" % kind)
+        cls.yaml_path_resolvers[tuple(new_path), kind] = tag
+    add_path_resolver = classmethod(add_path_resolver)
+
+    def descend_resolver(self, current_node, current_index):
+        if not self.yaml_path_resolvers:
+            return
+        exact_paths = {}
+        prefix_paths = []
+        if current_node:
+            depth = len(self.resolver_prefix_paths)
+            for path, kind in self.resolver_prefix_paths[-1]:
+                if self.check_resolver_prefix(depth, path, kind,
+                        current_node, current_index):
+                    if len(path) > depth:
+                        prefix_paths.append((path, kind))
+                    else:
+                        exact_paths[kind] = self.yaml_path_resolvers[path, kind]
+        else:
+            for path, kind in self.yaml_path_resolvers:
+                if not path:
+                    exact_paths[kind] = self.yaml_path_resolvers[path, kind]
+                else:
+                    prefix_paths.append((path, kind))
+        self.resolver_exact_paths.append(exact_paths)
+        self.resolver_prefix_paths.append(prefix_paths)
+
+    def ascend_resolver(self):
+        if not self.yaml_path_resolvers:
+            return
+        self.resolver_exact_paths.pop()
+        self.resolver_prefix_paths.pop()
+
+    def check_resolver_prefix(self, depth, path, kind,
+            current_node, current_index):
+        node_check, index_check = path[depth-1]
+        if isinstance(node_check, basestring):
+            if current_node.tag != node_check:
+                return
+        elif node_check is not None:
+            if not isinstance(current_node, node_check):
+                return
+        if index_check is True and current_index is not None:
+            return
+        if (index_check is False or index_check is None)    \
+                and current_index is None:
+            return
+        if isinstance(index_check, basestring):
+            if not (isinstance(current_index, ScalarNode)
+                    and index_check == current_index.value):
+                return
+        elif isinstance(index_check, int) and not isinstance(index_check, bool):
+            if index_check != current_index:
+                return
+        return True
+
+    def resolve(self, kind, value, implicit):
+        if kind is ScalarNode and implicit[0]:
+            if value == u'':
+                resolvers = self.yaml_implicit_resolvers.get(u'', [])
+            else:
+                resolvers = self.yaml_implicit_resolvers.get(value[0], [])
+            resolvers += self.yaml_implicit_resolvers.get(None, [])
+            for tag, regexp in resolvers:
+                if regexp.match(value):
+                    return tag
+            implicit = implicit[1]
+        if self.yaml_path_resolvers:
+            exact_paths = self.resolver_exact_paths[-1]
+            if kind in exact_paths:
+                return exact_paths[kind]
+            if None in exact_paths:
+                return exact_paths[None]
+        if kind is ScalarNode:
+            return self.DEFAULT_SCALAR_TAG
+        elif kind is SequenceNode:
+            return self.DEFAULT_SEQUENCE_TAG
+        elif kind is MappingNode:
+            return self.DEFAULT_MAPPING_TAG
+
+class Resolver(BaseResolver):
+    pass
+
+Resolver.add_implicit_resolver(
+        u'tag:yaml.org,2002:bool',
+        re.compile(ur'''^(?:yes|Yes|YES|no|No|NO
+                    |true|True|TRUE|false|False|FALSE
+                    |on|On|ON|off|Off|OFF)$''', re.X),
+        list(u'yYnNtTfFoO'))
+
+Resolver.add_implicit_resolver(
+        u'tag:yaml.org,2002:float',
+        re.compile(ur'''^(?:[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*(?:[eE][-+][0-9]+)?
+                    |[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*
+                    |[-+]?\.(?:inf|Inf|INF)
+                    |\.(?:nan|NaN|NAN))$''', re.X),
+        list(u'-+0123456789.'))
+
+Resolver.add_implicit_resolver(
+        u'tag:yaml.org,2002:int',
+        re.compile(ur'''^(?:[-+]?0b[0-1_]+
+                    |[-+]?0[0-7_]+
+                    |[-+]?(?:0|[1-9][0-9_]*)
+                    |[-+]?0x[0-9a-fA-F_]+
+                    |[-+]?[1-9][0-9_]*(?::[0-5]?[0-9])+)$''', re.X),
+        list(u'-+0123456789'))
+
+Resolver.add_implicit_resolver(
+        u'tag:yaml.org,2002:merge',
+        re.compile(ur'^(?:<<)$'),
+        ['<'])
+
+Resolver.add_implicit_resolver(
+        u'tag:yaml.org,2002:null',
+        re.compile(ur'''^(?: ~
+                    |null|Null|NULL
+                    | )$''', re.X),
+        [u'~', u'n', u'N', u''])
+
+Resolver.add_implicit_resolver(
+        u'tag:yaml.org,2002:timestamp',
+        re.compile(ur'''^(?:[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]
+                    |[0-9][0-9][0-9][0-9] -[0-9][0-9]? -[0-9][0-9]?
+                     (?:[Tt]|[ \t]+)[0-9][0-9]?
+                     :[0-9][0-9] :[0-9][0-9] (?:\.[0-9]*)?
+                     (?:[ \t]*(?:Z|[-+][0-9][0-9]?(?::[0-9][0-9])?))?)$''', re.X),
+        list(u'0123456789'))
+
+Resolver.add_implicit_resolver(
+        u'tag:yaml.org,2002:value',
+        re.compile(ur'^(?:=)$'),
+        ['='])
+
+# The following resolver is only for documentation purposes. It cannot work
+# because plain scalars cannot start with '!', '&', or '*'.
+Resolver.add_implicit_resolver(
+        u'tag:yaml.org,2002:yaml',
+        re.compile(ur'^(?:!|&|\*)$'),
+        list(u'!&*'))
+


[24/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code

Posted by rl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/yaml/constructor.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/yaml/constructor.py b/tools/bin/ext/yaml/constructor.py
new file mode 100644
index 0000000..e66dd2c
--- /dev/null
+++ b/tools/bin/ext/yaml/constructor.py
@@ -0,0 +1,691 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+__all__ = ['BaseConstructor', 'SafeConstructor', 'Constructor',
+    'ConstructorError']
+
+from error import *
+from nodes import *
+
+import datetime
+
+try:
+    set
+except NameError:
+    from sets import Set as set
+
+import binascii, re, sys, types
+
+class ConstructorError(MarkedYAMLError):
+    pass
+
+class BaseConstructor(object):
+
+    yaml_constructors = {}
+    yaml_multi_constructors = {}
+
+    def __init__(self):
+        self.constructed_objects = {}
+        self.recursive_objects = {}
+        self.state_generators = []
+        self.deep_construct = False
+
+    def check_data(self):
+        # If there are more documents available?
+        return self.check_node()
+
+    def get_data(self):
+        # Construct and return the next document.
+        if self.check_node():
+            return self.construct_document(self.get_node())
+
+    def construct_document(self, node):
+        data = self.construct_object(node)
+        while self.state_generators:
+            state_generators = self.state_generators
+            self.state_generators = []
+            for generator in state_generators:
+                for dummy in generator:
+                    pass
+        self.constructed_objects = {}
+        self.recursive_objects = {}
+        self.deep_construct = False
+        return data
+
+    def construct_object(self, node, deep=False):
+        if deep:
+            old_deep = self.deep_construct
+            self.deep_construct = True
+        if node in self.constructed_objects:
+            return self.constructed_objects[node]
+        if node in self.recursive_objects:
+            raise ConstructorError(None, None,
+                    "found unconstructable recursive node", node.start_mark)
+        self.recursive_objects[node] = None
+        constructor = None
+        state_constructor = None
+        tag_suffix = None
+        if node.tag in self.yaml_constructors:
+            constructor = self.yaml_constructors[node.tag]
+        else:
+            for tag_prefix in self.yaml_multi_constructors:
+                if node.tag.startswith(tag_prefix):
+                    tag_suffix = node.tag[len(tag_prefix):]
+                    constructor = self.yaml_multi_constructors[tag_prefix]
+                    break
+            else:
+                if None in self.yaml_multi_constructors:
+                    tag_suffix = node.tag
+                    constructor = self.yaml_multi_constructors[None]
+                elif None in self.yaml_constructors:
+                    constructor = self.yaml_constructors[None]
+                elif isinstance(node, ScalarNode):
+                    constructor = self.__class__.construct_scalar
+                elif isinstance(node, SequenceNode):
+                    constructor = self.__class__.construct_sequence
+                elif isinstance(node, MappingNode):
+                    constructor = self.__class__.construct_mapping
+        if tag_suffix is None:
+            data = constructor(self, node)
+        else:
+            data = constructor(self, tag_suffix, node)
+        if isinstance(data, types.GeneratorType):
+            generator = data
+            data = generator.next()
+            if self.deep_construct:
+                for dummy in generator:
+                    pass
+            else:
+                self.state_generators.append(generator)
+        self.constructed_objects[node] = data
+        del self.recursive_objects[node]
+        if deep:
+            self.deep_construct = old_deep
+        return data
+
+    def construct_scalar(self, node):
+        if not isinstance(node, ScalarNode):
+            raise ConstructorError(None, None,
+                    "expected a scalar node, but found %s" % node.id,
+                    node.start_mark)
+        return node.value
+
+    def construct_sequence(self, node, deep=False):
+        if not isinstance(node, SequenceNode):
+            raise ConstructorError(None, None,
+                    "expected a sequence node, but found %s" % node.id,
+                    node.start_mark)
+        return [self.construct_object(child, deep=deep)
+                for child in node.value]
+
+    def construct_mapping(self, node, deep=False):
+        if not isinstance(node, MappingNode):
+            raise ConstructorError(None, None,
+                    "expected a mapping node, but found %s" % node.id,
+                    node.start_mark)
+        mapping = {}
+        for key_node, value_node in node.value:
+            key = self.construct_object(key_node, deep=deep)
+            try:
+                hash(key)
+            except TypeError, exc:
+                raise ConstructorError("while constructing a mapping", node.start_mark,
+                        "found unacceptable key (%s)" % exc, key_node.start_mark)
+            value = self.construct_object(value_node, deep=deep)
+            mapping[key] = value
+        return mapping
+
+    def construct_pairs(self, node, deep=False):
+        if not isinstance(node, MappingNode):
+            raise ConstructorError(None, None,
+                    "expected a mapping node, but found %s" % node.id,
+                    node.start_mark)
+        pairs = []
+        for key_node, value_node in node.value:
+            key = self.construct_object(key_node, deep=deep)
+            value = self.construct_object(value_node, deep=deep)
+            pairs.append((key, value))
+        return pairs
+
+    def add_constructor(cls, tag, constructor):
+        if not 'yaml_constructors' in cls.__dict__:
+            cls.yaml_constructors = cls.yaml_constructors.copy()
+        cls.yaml_constructors[tag] = constructor
+    add_constructor = classmethod(add_constructor)
+
+    def add_multi_constructor(cls, tag_prefix, multi_constructor):
+        if not 'yaml_multi_constructors' in cls.__dict__:
+            cls.yaml_multi_constructors = cls.yaml_multi_constructors.copy()
+        cls.yaml_multi_constructors[tag_prefix] = multi_constructor
+    add_multi_constructor = classmethod(add_multi_constructor)
+
+class SafeConstructor(BaseConstructor):
+
+    def construct_scalar(self, node):
+        if isinstance(node, MappingNode):
+            for key_node, value_node in node.value:
+                if key_node.tag == u'tag:yaml.org,2002:value':
+                    return self.construct_scalar(value_node)
+        return BaseConstructor.construct_scalar(self, node)
+
+    def flatten_mapping(self, node):
+        merge = []
+        index = 0
+        while index < len(node.value):
+            key_node, value_node = node.value[index]
+            if key_node.tag == u'tag:yaml.org,2002:merge':
+                del node.value[index]
+                if isinstance(value_node, MappingNode):
+                    self.flatten_mapping(value_node)
+                    merge.extend(value_node.value)
+                elif isinstance(value_node, SequenceNode):
+                    submerge = []
+                    for subnode in value_node.value:
+                        if not isinstance(subnode, MappingNode):
+                            raise ConstructorError("while constructing a mapping",
+                                    node.start_mark,
+                                    "expected a mapping for merging, but found %s"
+                                    % subnode.id, subnode.start_mark)
+                        self.flatten_mapping(subnode)
+                        submerge.append(subnode.value)
+                    submerge.reverse()
+                    for value in submerge:
+                        merge.extend(value)
+                else:
+                    raise ConstructorError("while constructing a mapping", node.start_mark,
+                            "expected a mapping or list of mappings for merging, but found %s"
+                            % value_node.id, value_node.start_mark)
+            elif key_node.tag == u'tag:yaml.org,2002:value':
+                key_node.tag = u'tag:yaml.org,2002:str'
+                index += 1
+            else:
+                index += 1
+        if merge:
+            node.value = merge + node.value
+
+    def construct_mapping(self, node, deep=False):
+        if isinstance(node, MappingNode):
+            self.flatten_mapping(node)
+        return BaseConstructor.construct_mapping(self, node, deep=deep)
+
+    def construct_yaml_null(self, node):
+        self.construct_scalar(node)
+        return None
+
+    bool_values = {
+        u'yes':     True,
+        u'no':      False,
+        u'true':    True,
+        u'false':   False,
+        u'on':      True,
+        u'off':     False,
+    }
+
+    def construct_yaml_bool(self, node):
+        value = self.construct_scalar(node)
+        return self.bool_values[value.lower()]
+
+    def construct_yaml_int(self, node):
+        value = str(self.construct_scalar(node))
+        value = value.replace('_', '')
+        sign = +1
+        if value[0] == '-':
+            sign = -1
+        if value[0] in '+-':
+            value = value[1:]
+        if value == '0':
+            return 0
+        elif value.startswith('0b'):
+            return sign*int(value[2:], 2)
+        elif value.startswith('0x'):
+            return sign*int(value[2:], 16)
+        elif value[0] == '0':
+            return sign*int(value, 8)
+        elif ':' in value:
+            digits = [int(part) for part in value.split(':')]
+            digits.reverse()
+            base = 1
+            value = 0
+            for digit in digits:
+                value += digit*base
+                base *= 60
+            return sign*value
+        else:
+            return sign*int(value)
+
+    inf_value = 1e300
+    while inf_value != inf_value*inf_value:
+        inf_value *= inf_value
+    nan_value = -inf_value/inf_value   # Trying to make a quiet NaN (like C99).
+
+    def construct_yaml_float(self, node):
+        value = str(self.construct_scalar(node))
+        value = value.replace('_', '').lower()
+        sign = +1
+        if value[0] == '-':
+            sign = -1
+        if value[0] in '+-':
+            value = value[1:]
+        if value == '.inf':
+            return sign*self.inf_value
+        elif value == '.nan':
+            return self.nan_value
+        elif ':' in value:
+            digits = [float(part) for part in value.split(':')]
+            digits.reverse()
+            base = 1
+            value = 0.0
+            for digit in digits:
+                value += digit*base
+                base *= 60
+            return sign*value
+        else:
+            return sign*float(value)
+
+    def construct_yaml_binary(self, node):
+        value = self.construct_scalar(node)
+        try:
+            return str(value).decode('base64')
+        except (binascii.Error, UnicodeEncodeError), exc:
+            raise ConstructorError(None, None,
+                    "failed to decode base64 data: %s" % exc, node.start_mark) 
+
+    timestamp_regexp = re.compile(
+            ur'''^(?P<year>[0-9][0-9][0-9][0-9])
+                -(?P<month>[0-9][0-9]?)
+                -(?P<day>[0-9][0-9]?)
+                (?:(?:[Tt]|[ \t]+)
+                (?P<hour>[0-9][0-9]?)
+                :(?P<minute>[0-9][0-9])
+                :(?P<second>[0-9][0-9])
+                (?:\.(?P<fraction>[0-9]*))?
+                (?:[ \t]*(?P<tz>Z|(?P<tz_sign>[-+])(?P<tz_hour>[0-9][0-9]?)
+                (?::(?P<tz_minute>[0-9][0-9]))?))?)?$''', re.X)
+
+    def construct_yaml_timestamp(self, node):
+        value = self.construct_scalar(node)
+        match = self.timestamp_regexp.match(node.value)
+        values = match.groupdict()
+        year = int(values['year'])
+        month = int(values['month'])
+        day = int(values['day'])
+        if not values['hour']:
+            return datetime.date(year, month, day)
+        hour = int(values['hour'])
+        minute = int(values['minute'])
+        second = int(values['second'])
+        fraction = 0
+        if values['fraction']:
+            fraction = int(values['fraction'][:6].ljust(6, '0'))
+        delta = None
+        if values['tz_sign']:
+            tz_hour = int(values['tz_hour'])
+            tz_minute = int(values['tz_minute'] or 0)
+            delta = datetime.timedelta(hours=tz_hour, minutes=tz_minute)
+            if values['tz_sign'] == '-':
+                delta = -delta
+        data = datetime.datetime(year, month, day, hour, minute, second, fraction)
+        if delta:
+            data -= delta
+        return data
+
+    def construct_yaml_omap(self, node):
+        # Note: we do not check for duplicate keys, because it's too
+        # CPU-expensive.
+        omap = []
+        yield omap
+        if not isinstance(node, SequenceNode):
+            raise ConstructorError("while constructing an ordered map", node.start_mark,
+                    "expected a sequence, but found %s" % node.id, node.start_mark)
+        for subnode in node.value:
+            if not isinstance(subnode, MappingNode):
+                raise ConstructorError("while constructing an ordered map", node.start_mark,
+                        "expected a mapping of length 1, but found %s" % subnode.id,
+                        subnode.start_mark)
+            if len(subnode.value) != 1:
+                raise ConstructorError("while constructing an ordered map", node.start_mark,
+                        "expected a single mapping item, but found %d items" % len(subnode.value),
+                        subnode.start_mark)
+            key_node, value_node = subnode.value[0]
+            key = self.construct_object(key_node)
+            value = self.construct_object(value_node)
+            omap.append((key, value))
+
+    def construct_yaml_pairs(self, node):
+        # Note: the same code as `construct_yaml_omap`.
+        pairs = []
+        yield pairs
+        if not isinstance(node, SequenceNode):
+            raise ConstructorError("while constructing pairs", node.start_mark,
+                    "expected a sequence, but found %s" % node.id, node.start_mark)
+        for subnode in node.value:
+            if not isinstance(subnode, MappingNode):
+                raise ConstructorError("while constructing pairs", node.start_mark,
+                        "expected a mapping of length 1, but found %s" % subnode.id,
+                        subnode.start_mark)
+            if len(subnode.value) != 1:
+                raise ConstructorError("while constructing pairs", node.start_mark,
+                        "expected a single mapping item, but found %d items" % len(subnode.value),
+                        subnode.start_mark)
+            key_node, value_node = subnode.value[0]
+            key = self.construct_object(key_node)
+            value = self.construct_object(value_node)
+            pairs.append((key, value))
+
+    def construct_yaml_set(self, node):
+        data = set()
+        yield data
+        value = self.construct_mapping(node)
+        data.update(value)
+
+    def construct_yaml_str(self, node):
+        value = self.construct_scalar(node)
+        try:
+            return value.encode('ascii')
+        except UnicodeEncodeError:
+            return value
+
+    def construct_yaml_seq(self, node):
+        data = []
+        yield data
+        data.extend(self.construct_sequence(node))
+
+    def construct_yaml_map(self, node):
+        data = {}
+        yield data
+        value = self.construct_mapping(node)
+        data.update(value)
+
+    def construct_yaml_object(self, node, cls):
+        data = cls.__new__(cls)
+        yield data
+        if hasattr(data, '__setstate__'):
+            state = self.construct_mapping(node, deep=True)
+            data.__setstate__(state)
+        else:
+            state = self.construct_mapping(node)
+            data.__dict__.update(state)
+
+    def construct_undefined(self, node):
+        raise ConstructorError(None, None,
+                "could not determine a constructor for the tag %r" % node.tag.encode('utf-8'),
+                node.start_mark)
+
+SafeConstructor.add_constructor(
+        u'tag:yaml.org,2002:null',
+        SafeConstructor.construct_yaml_null)
+
+SafeConstructor.add_constructor(
+        u'tag:yaml.org,2002:bool',
+        SafeConstructor.construct_yaml_bool)
+
+SafeConstructor.add_constructor(
+        u'tag:yaml.org,2002:int',
+        SafeConstructor.construct_yaml_int)
+
+SafeConstructor.add_constructor(
+        u'tag:yaml.org,2002:float',
+        SafeConstructor.construct_yaml_float)
+
+SafeConstructor.add_constructor(
+        u'tag:yaml.org,2002:binary',
+        SafeConstructor.construct_yaml_binary)
+
+SafeConstructor.add_constructor(
+        u'tag:yaml.org,2002:timestamp',
+        SafeConstructor.construct_yaml_timestamp)
+
+SafeConstructor.add_constructor(
+        u'tag:yaml.org,2002:omap',
+        SafeConstructor.construct_yaml_omap)
+
+SafeConstructor.add_constructor(
+        u'tag:yaml.org,2002:pairs',
+        SafeConstructor.construct_yaml_pairs)
+
+SafeConstructor.add_constructor(
+        u'tag:yaml.org,2002:set',
+        SafeConstructor.construct_yaml_set)
+
+SafeConstructor.add_constructor(
+        u'tag:yaml.org,2002:str',
+        SafeConstructor.construct_yaml_str)
+
+SafeConstructor.add_constructor(
+        u'tag:yaml.org,2002:seq',
+        SafeConstructor.construct_yaml_seq)
+
+SafeConstructor.add_constructor(
+        u'tag:yaml.org,2002:map',
+        SafeConstructor.construct_yaml_map)
+
+SafeConstructor.add_constructor(None,
+        SafeConstructor.construct_undefined)
+
+class Constructor(SafeConstructor):
+
+    def construct_python_str(self, node):
+        return self.construct_scalar(node).encode('utf-8')
+
+    def construct_python_unicode(self, node):
+        return self.construct_scalar(node)
+
+    def construct_python_long(self, node):
+        return long(self.construct_yaml_int(node))
+
+    def construct_python_complex(self, node):
+       return complex(self.construct_scalar(node))
+
+    def construct_python_tuple(self, node):
+        return tuple(self.construct_sequence(node))
+
+    def find_python_module(self, name, mark):
+        if not name:
+            raise ConstructorError("while constructing a Python module", mark,
+                    "expected non-empty name appended to the tag", mark)
+        try:
+            __import__(name)
+        except ImportError, exc:
+            raise ConstructorError("while constructing a Python module", mark,
+                    "cannot find module %r (%s)" % (name.encode('utf-8'), exc), mark)
+        return sys.modules[name]
+
+    def find_python_name(self, name, mark):
+        if not name:
+            raise ConstructorError("while constructing a Python object", mark,
+                    "expected non-empty name appended to the tag", mark)
+        if u'.' in name:
+            # Python 2.4 only
+            #module_name, object_name = name.rsplit('.', 1)
+            items = name.split('.')
+            object_name = items.pop()
+            module_name = '.'.join(items)
+        else:
+            module_name = '__builtin__'
+            object_name = name
+        try:
+            __import__(module_name)
+        except ImportError, exc:
+            raise ConstructorError("while constructing a Python object", mark,
+                    "cannot find module %r (%s)" % (module_name.encode('utf-8'), exc), mark)
+        module = sys.modules[module_name]
+        if not hasattr(module, object_name):
+            raise ConstructorError("while constructing a Python object", mark,
+                    "cannot find %r in the module %r" % (object_name.encode('utf-8'),
+                        module.__name__), mark)
+        return getattr(module, object_name)
+
+    def construct_python_name(self, suffix, node):
+        value = self.construct_scalar(node)
+        if value:
+            raise ConstructorError("while constructing a Python name", node.start_mark,
+                    "expected the empty value, but found %r" % value.encode('utf-8'),
+                    node.start_mark)
+        return self.find_python_name(suffix, node.start_mark)
+
+    def construct_python_module(self, suffix, node):
+        value = self.construct_scalar(node)
+        if value:
+            raise ConstructorError("while constructing a Python module", node.start_mark,
+                    "expected the empty value, but found %r" % value.encode('utf-8'),
+                    node.start_mark)
+        return self.find_python_module(suffix, node.start_mark)
+
+    class classobj: pass
+
+    def make_python_instance(self, suffix, node,
+            args=None, kwds=None, newobj=False):
+        if not args:
+            args = []
+        if not kwds:
+            kwds = {}
+        cls = self.find_python_name(suffix, node.start_mark)
+        if newobj and isinstance(cls, type(self.classobj))  \
+                and not args and not kwds:
+            instance = self.classobj()
+            instance.__class__ = cls
+            return instance
+        elif newobj and isinstance(cls, type):
+            return cls.__new__(cls, *args, **kwds)
+        else:
+            return cls(*args, **kwds)
+
+    def set_python_instance_state(self, instance, state):
+        if hasattr(instance, '__setstate__'):
+            instance.__setstate__(state)
+        else:
+            slotstate = {}
+            if isinstance(state, tuple) and len(state) == 2:
+                state, slotstate = state
+            if hasattr(instance, '__dict__'):
+                instance.__dict__.update(state)
+            elif state:
+                slotstate.update(state)
+            for key, value in slotstate.items():
+                setattr(object, key, value)
+
+    def construct_python_object(self, suffix, node):
+        # Format:
+        #   !!python/object:module.name { ... state ... }
+        instance = self.make_python_instance(suffix, node, newobj=True)
+        yield instance
+        deep = hasattr(instance, '__setstate__')
+        state = self.construct_mapping(node, deep=deep)
+        self.set_python_instance_state(instance, state)
+
+    def construct_python_object_apply(self, suffix, node, newobj=False):
+        # Format:
+        #   !!python/object/apply       # (or !!python/object/new)
+        #   args: [ ... arguments ... ]
+        #   kwds: { ... keywords ... }
+        #   state: ... state ...
+        #   listitems: [ ... listitems ... ]
+        #   dictitems: { ... dictitems ... }
+        # or short format:
+        #   !!python/object/apply [ ... arguments ... ]
+        # The difference between !!python/object/apply and !!python/object/new
+        # is how an object is created, check make_python_instance for details.
+        if isinstance(node, SequenceNode):
+            args = self.construct_sequence(node, deep=True)
+            kwds = {}
+            state = {}
+            listitems = []
+            dictitems = {}
+        else:
+            value = self.construct_mapping(node, deep=True)
+            args = value.get('args', [])
+            kwds = value.get('kwds', {})
+            state = value.get('state', {})
+            listitems = value.get('listitems', [])
+            dictitems = value.get('dictitems', {})
+        instance = self.make_python_instance(suffix, node, args, kwds, newobj)
+        if state:
+            self.set_python_instance_state(instance, state)
+        if listitems:
+            instance.extend(listitems)
+        if dictitems:
+            for key in dictitems:
+                instance[key] = dictitems[key]
+        return instance
+
+    def construct_python_object_new(self, suffix, node):
+        return self.construct_python_object_apply(suffix, node, newobj=True)
+
+Constructor.add_constructor(
+    u'tag:yaml.org,2002:python/none',
+    Constructor.construct_yaml_null)
+
+Constructor.add_constructor(
+    u'tag:yaml.org,2002:python/bool',
+    Constructor.construct_yaml_bool)
+
+Constructor.add_constructor(
+    u'tag:yaml.org,2002:python/str',
+    Constructor.construct_python_str)
+
+Constructor.add_constructor(
+    u'tag:yaml.org,2002:python/unicode',
+    Constructor.construct_python_unicode)
+
+Constructor.add_constructor(
+    u'tag:yaml.org,2002:python/int',
+    Constructor.construct_yaml_int)
+
+Constructor.add_constructor(
+    u'tag:yaml.org,2002:python/long',
+    Constructor.construct_python_long)
+
+Constructor.add_constructor(
+    u'tag:yaml.org,2002:python/float',
+    Constructor.construct_yaml_float)
+
+Constructor.add_constructor(
+    u'tag:yaml.org,2002:python/complex',
+    Constructor.construct_python_complex)
+
+Constructor.add_constructor(
+    u'tag:yaml.org,2002:python/list',
+    Constructor.construct_yaml_seq)
+
+Constructor.add_constructor(
+    u'tag:yaml.org,2002:python/tuple',
+    Constructor.construct_python_tuple)
+
+Constructor.add_constructor(
+    u'tag:yaml.org,2002:python/dict',
+    Constructor.construct_yaml_map)
+
+Constructor.add_multi_constructor(
+    u'tag:yaml.org,2002:python/name:',
+    Constructor.construct_python_name)
+
+Constructor.add_multi_constructor(
+    u'tag:yaml.org,2002:python/module:',
+    Constructor.construct_python_module)
+
+Constructor.add_multi_constructor(
+    u'tag:yaml.org,2002:python/object:',
+    Constructor.construct_python_object)
+
+Constructor.add_multi_constructor(
+    u'tag:yaml.org,2002:python/object/apply:',
+    Constructor.construct_python_object_apply)
+
+Constructor.add_multi_constructor(
+    u'tag:yaml.org,2002:python/object/new:',
+    Constructor.construct_python_object_new)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/yaml/cyaml.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/yaml/cyaml.py b/tools/bin/ext/yaml/cyaml.py
new file mode 100644
index 0000000..c3eaf77
--- /dev/null
+++ b/tools/bin/ext/yaml/cyaml.py
@@ -0,0 +1,101 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+__all__ = ['CBaseLoader', 'CSafeLoader', 'CLoader',
+        'CBaseDumper', 'CSafeDumper', 'CDumper']
+
+from _yaml import CParser, CEmitter
+
+from constructor import *
+
+from serializer import *
+from representer import *
+
+from resolver import *
+
+class CBaseLoader(CParser, BaseConstructor, BaseResolver):
+
+    def __init__(self, stream):
+        CParser.__init__(self, stream)
+        BaseConstructor.__init__(self)
+        BaseResolver.__init__(self)
+
+class CSafeLoader(CParser, SafeConstructor, Resolver):
+
+    def __init__(self, stream):
+        CParser.__init__(self, stream)
+        SafeConstructor.__init__(self)
+        Resolver.__init__(self)
+
+class CLoader(CParser, Constructor, Resolver):
+
+    def __init__(self, stream):
+        CParser.__init__(self, stream)
+        Constructor.__init__(self)
+        Resolver.__init__(self)
+
+class CBaseDumper(CEmitter, BaseRepresenter, BaseResolver):
+
+    def __init__(self, stream,
+            default_style=None, default_flow_style=None,
+            canonical=None, indent=None, width=None,
+            allow_unicode=None, line_break=None,
+            encoding=None, explicit_start=None, explicit_end=None,
+            version=None, tags=None):
+        CEmitter.__init__(self, stream, canonical=canonical,
+                indent=indent, width=width,
+                allow_unicode=allow_unicode, line_break=line_break,
+                explicit_start=explicit_start, explicit_end=explicit_end,
+                version=version, tags=tags)
+        Representer.__init__(self, default_style=default_style,
+                default_flow_style=default_flow_style)
+        Resolver.__init__(self)
+
+class CSafeDumper(CEmitter, SafeRepresenter, Resolver):
+
+    def __init__(self, stream,
+            default_style=None, default_flow_style=None,
+            canonical=None, indent=None, width=None,
+            allow_unicode=None, line_break=None,
+            encoding=None, explicit_start=None, explicit_end=None,
+            version=None, tags=None):
+        CEmitter.__init__(self, stream, canonical=canonical,
+                indent=indent, width=width,
+                allow_unicode=allow_unicode, line_break=line_break,
+                explicit_start=explicit_start, explicit_end=explicit_end,
+                version=version, tags=tags)
+        SafeRepresenter.__init__(self, default_style=default_style,
+                default_flow_style=default_flow_style)
+        Resolver.__init__(self)
+
+class CDumper(CEmitter, Serializer, Representer, Resolver):
+
+    def __init__(self, stream,
+            default_style=None, default_flow_style=None,
+            canonical=None, indent=None, width=None,
+            allow_unicode=None, line_break=None,
+            encoding=None, explicit_start=None, explicit_end=None,
+            version=None, tags=None):
+        CEmitter.__init__(self, stream, canonical=canonical,
+                indent=indent, width=width,
+                allow_unicode=allow_unicode, line_break=line_break,
+                explicit_start=explicit_start, explicit_end=explicit_end,
+                version=version, tags=tags)
+        Representer.__init__(self, default_style=default_style,
+                default_flow_style=default_flow_style)
+        Resolver.__init__(self)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/yaml/dumper.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/yaml/dumper.py b/tools/bin/ext/yaml/dumper.py
new file mode 100644
index 0000000..a955200
--- /dev/null
+++ b/tools/bin/ext/yaml/dumper.py
@@ -0,0 +1,78 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+__all__ = ['BaseDumper', 'SafeDumper', 'Dumper']
+
+from emitter import *
+from serializer import *
+from representer import *
+from resolver import *
+
+class BaseDumper(Emitter, Serializer, BaseRepresenter, BaseResolver):
+
+    def __init__(self, stream,
+            default_style=None, default_flow_style=None,
+            canonical=None, indent=None, width=None,
+            allow_unicode=None, line_break=None,
+            encoding=None, explicit_start=None, explicit_end=None,
+            version=None, tags=None):
+        Emitter.__init__(self, stream, canonical=canonical,
+                indent=indent, width=width,
+                allow_uncode=allow_unicode, line_break=line_break)
+        Serializer.__init__(self, encoding=encoding,
+                explicit_start=explicit_start, explicit_end=explicit_end,
+                version=version, tags=tags)
+        Representer.__init__(self, default_style=default_style,
+                default_flow_style=default_flow_style)
+        Resolver.__init__(self)
+
+class SafeDumper(Emitter, Serializer, SafeRepresenter, Resolver):
+
+    def __init__(self, stream,
+            default_style=None, default_flow_style=None,
+            canonical=None, indent=None, width=None,
+            allow_unicode=None, line_break=None,
+            encoding=None, explicit_start=None, explicit_end=None,
+            version=None, tags=None):
+        Emitter.__init__(self, stream, canonical=canonical,
+                indent=indent, width=width,
+                allow_unicode=allow_unicode, line_break=line_break)
+        Serializer.__init__(self, encoding=encoding,
+                explicit_start=explicit_start, explicit_end=explicit_end,
+                version=version, tags=tags)
+        SafeRepresenter.__init__(self, default_style=default_style,
+                default_flow_style=default_flow_style)
+        Resolver.__init__(self)
+
+class Dumper(Emitter, Serializer, Representer, Resolver):
+
+    def __init__(self, stream,
+            default_style=None, default_flow_style=None,
+            canonical=None, indent=None, width=None,
+            allow_unicode=None, line_break=None,
+            encoding=None, explicit_start=None, explicit_end=None,
+            version=None, tags=None):
+        Emitter.__init__(self, stream, canonical=canonical,
+                indent=indent, width=width,
+                allow_unicode=allow_unicode, line_break=line_break)
+        Serializer.__init__(self, encoding=encoding,
+                explicit_start=explicit_start, explicit_end=explicit_end,
+                version=version, tags=tags)
+        Representer.__init__(self, default_style=default_style,
+                default_flow_style=default_flow_style)
+        Resolver.__init__(self)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/yaml/emitter.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/yaml/emitter.py b/tools/bin/ext/yaml/emitter.py
new file mode 100644
index 0000000..23730d8
--- /dev/null
+++ b/tools/bin/ext/yaml/emitter.py
@@ -0,0 +1,1179 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Emitter expects events obeying the following grammar:
+# stream ::= STREAM-START document* STREAM-END
+# document ::= DOCUMENT-START node DOCUMENT-END
+# node ::= SCALAR | sequence | mapping
+# sequence ::= SEQUENCE-START node* SEQUENCE-END
+# mapping ::= MAPPING-START (node node)* MAPPING-END
+
+__all__ = ['Emitter', 'EmitterError']
+
+from error import YAMLError
+from events import *
+
+import re
+
+class EmitterError(YAMLError):
+    pass
+
+class ScalarAnalysis(object):
+    def __init__(self, scalar, empty, multiline,
+            allow_flow_plain, allow_block_plain,
+            allow_single_quoted, allow_double_quoted,
+            allow_block):
+        self.scalar = scalar
+        self.empty = empty
+        self.multiline = multiline
+        self.allow_flow_plain = allow_flow_plain
+        self.allow_block_plain = allow_block_plain
+        self.allow_single_quoted = allow_single_quoted
+        self.allow_double_quoted = allow_double_quoted
+        self.allow_block = allow_block
+
+class Emitter(object):
+
+    DEFAULT_TAG_PREFIXES = {
+        u'!' : u'!',
+        u'tag:yaml.org,2002:' : u'!!',
+    }
+
+    def __init__(self, stream, canonical=None, indent=None, width=None,
+            allow_unicode=None, line_break=None):
+
+        # The stream should have the methods `write` and possibly `flush`.
+        self.stream = stream
+
+        # Encoding can be overriden by STREAM-START.
+        self.encoding = None
+
+        # Emitter is a state machine with a stack of states to handle nested
+        # structures.
+        self.states = []
+        self.state = self.expect_stream_start
+
+        # Current event and the event queue.
+        self.events = []
+        self.event = None
+
+        # The current indentation level and the stack of previous indents.
+        self.indents = []
+        self.indent = None
+
+        # Flow level.
+        self.flow_level = 0
+
+        # Contexts.
+        self.root_context = False
+        self.sequence_context = False
+        self.mapping_context = False
+        self.simple_key_context = False
+
+        # Characteristics of the last emitted character:
+        #  - current position.
+        #  - is it a whitespace?
+        #  - is it an indention character
+        #    (indentation space, '-', '?', or ':')?
+        self.line = 0
+        self.column = 0
+        self.whitespace = True
+        self.indention = True
+
+        # Formatting details.
+        self.canonical = canonical
+        self.allow_unicode = allow_unicode
+        self.best_indent = 2
+        if indent and 1 < indent < 10:
+            self.best_indent = indent
+        self.best_width = 80
+        if width and width > self.best_indent*2:
+            self.best_width = width
+        self.best_line_break = u'\n'
+        if line_break in [u'\r', u'\n', u'\r\n']:
+            self.best_line_break = line_break
+
+        # Tag prefixes.
+        self.tag_prefixes = None
+
+        # Prepared anchor and tag.
+        self.prepared_anchor = None
+        self.prepared_tag = None
+
+        # Scalar analysis and style.
+        self.analysis = None
+        self.style = None
+
+    def emit(self, event):
+        self.events.append(event)
+        while not self.need_more_events():
+            self.event = self.events.pop(0)
+            self.state()
+            self.event = None
+
+    # In some cases, we wait for a few next events before emitting.
+
+    def need_more_events(self):
+        if not self.events:
+            return True
+        event = self.events[0]
+        if isinstance(event, DocumentStartEvent):
+            return self.need_events(1)
+        elif isinstance(event, SequenceStartEvent):
+            return self.need_events(2)
+        elif isinstance(event, MappingStartEvent):
+            return self.need_events(3)
+        else:
+            return False
+
+    def need_events(self, count):
+        level = 0
+        for event in self.events[1:]:
+            if isinstance(event, (DocumentStartEvent, CollectionStartEvent)):
+                level += 1
+            elif isinstance(event, (DocumentEndEvent, CollectionEndEvent)):
+                level -= 1
+            elif isinstance(event, StreamEndEvent):
+                level = -1
+            if level < 0:
+                return False
+        return (len(self.events) < count+1)
+
+    def increase_indent(self, flow=False, indentless=False):
+        self.indents.append(self.indent)
+        if self.indent is None:
+            if flow:
+                self.indent = self.best_indent
+            else:
+                self.indent = 0
+        elif not indentless:
+            self.indent += self.best_indent
+
+    # States.
+
+    # Stream handlers.
+
+    def expect_stream_start(self):
+        if isinstance(self.event, StreamStartEvent):
+            if self.event.encoding:
+                self.encoding = self.event.encoding
+            self.write_stream_start()
+            self.state = self.expect_first_document_start
+        else:
+            raise EmitterError("expected StreamStartEvent, but got %s"
+                    % self.event)
+
+    def expect_nothing(self):
+        raise EmitterError("expected nothing, but got %s" % self.event)
+
+    # Document handlers.
+
+    def expect_first_document_start(self):
+        return self.expect_document_start(first=True)
+
+    def expect_document_start(self, first=False):
+        if isinstance(self.event, DocumentStartEvent):
+            if self.event.version:
+                version_text = self.prepare_version(self.event.version)
+                self.write_version_directive(version_text)
+            self.tag_prefixes = self.DEFAULT_TAG_PREFIXES.copy()
+            if self.event.tags:
+                handles = self.event.tags.keys()
+                handles.sort()
+                for handle in handles:
+                    prefix = self.event.tags[handle]
+                    self.tag_prefixes[prefix] = handle
+                    handle_text = self.prepare_tag_handle(handle)
+                    prefix_text = self.prepare_tag_prefix(prefix)
+                    self.write_tag_directive(handle_text, prefix_text)
+            implicit = (first and not self.event.explicit and not self.canonical
+                    and not self.event.version and not self.event.tags
+                    and not self.check_empty_document())
+            if not implicit:
+                self.write_indent()
+                self.write_indicator(u'---', True)
+                if self.canonical:
+                    self.write_indent()
+            self.state = self.expect_document_root
+        elif isinstance(self.event, StreamEndEvent):
+            self.write_stream_end()
+            self.state = self.expect_nothing
+        else:
+            raise EmitterError("expected DocumentStartEvent, but got %s"
+                    % self.event)
+
+    def expect_document_end(self):
+        if isinstance(self.event, DocumentEndEvent):
+            self.write_indent()
+            if self.event.explicit:
+                self.write_indicator(u'...', True)
+                self.write_indent()
+            self.flush_stream()
+            self.state = self.expect_document_start
+        else:
+            raise EmitterError("expected DocumentEndEvent, but got %s"
+                    % self.event)
+
+    def expect_document_root(self):
+        self.states.append(self.expect_document_end)
+        self.expect_node(root=True)
+
+    # Node handlers.
+
+    def expect_node(self, root=False, sequence=False, mapping=False,
+            simple_key=False):
+        self.root_context = root
+        self.sequence_context = sequence
+        self.mapping_context = mapping
+        self.simple_key_context = simple_key
+        if isinstance(self.event, AliasEvent):
+            self.expect_alias()
+        elif isinstance(self.event, (ScalarEvent, CollectionStartEvent)):
+            self.process_anchor(u'&')
+            self.process_tag()
+            if isinstance(self.event, ScalarEvent):
+                self.expect_scalar()
+            elif isinstance(self.event, SequenceStartEvent):
+                if self.flow_level or self.canonical or self.event.flow_style   \
+                        or self.check_empty_sequence():
+                    self.expect_flow_sequence()
+                else:
+                    self.expect_block_sequence()
+            elif isinstance(self.event, MappingStartEvent):
+                if self.flow_level or self.canonical or self.event.flow_style   \
+                        or self.check_empty_mapping():
+                    self.expect_flow_mapping()
+                else:
+                    self.expect_block_mapping()
+        else:
+            raise EmitterError("expected NodeEvent, but got %s" % self.event)
+
+    def expect_alias(self):
+        if self.event.anchor is None:
+            raise EmitterError("anchor is not specified for alias")
+        self.process_anchor(u'*')
+        self.state = self.states.pop()
+
+    def expect_scalar(self):
+        self.increase_indent(flow=True)
+        self.process_scalar()
+        self.indent = self.indents.pop()
+        self.state = self.states.pop()
+
+    # Flow sequence handlers.
+
+    def expect_flow_sequence(self):
+        self.write_indicator(u'[', True, whitespace=True)
+        self.flow_level += 1
+        self.increase_indent(flow=True)
+        self.state = self.expect_first_flow_sequence_item
+
+    def expect_first_flow_sequence_item(self):
+        if isinstance(self.event, SequenceEndEvent):
+            self.indent = self.indents.pop()
+            self.flow_level -= 1
+            self.write_indicator(u']', False)
+            self.state = self.states.pop()
+        else:
+            if self.canonical or self.column > self.best_width:
+                self.write_indent()
+            self.states.append(self.expect_flow_sequence_item)
+            self.expect_node(sequence=True)
+
+    def expect_flow_sequence_item(self):
+        if isinstance(self.event, SequenceEndEvent):
+            self.indent = self.indents.pop()
+            self.flow_level -= 1
+            if self.canonical:
+                self.write_indicator(u',', False)
+                self.write_indent()
+            self.write_indicator(u']', False)
+            self.state = self.states.pop()
+        else:
+            self.write_indicator(u',', False)
+            if self.canonical or self.column > self.best_width:
+                self.write_indent()
+            self.states.append(self.expect_flow_sequence_item)
+            self.expect_node(sequence=True)
+
+    # Flow mapping handlers.
+
+    def expect_flow_mapping(self):
+        self.write_indicator(u'{', True, whitespace=True)
+        self.flow_level += 1
+        self.increase_indent(flow=True)
+        self.state = self.expect_first_flow_mapping_key
+
+    def expect_first_flow_mapping_key(self):
+        if isinstance(self.event, MappingEndEvent):
+            self.indent = self.indents.pop()
+            self.flow_level -= 1
+            self.write_indicator(u'}', False)
+            self.state = self.states.pop()
+        else:
+            if self.canonical or self.column > self.best_width:
+                self.write_indent()
+            if not self.canonical and self.check_simple_key():
+                self.states.append(self.expect_flow_mapping_simple_value)
+                self.expect_node(mapping=True, simple_key=True)
+            else:
+                self.write_indicator(u'?', True)
+                self.states.append(self.expect_flow_mapping_value)
+                self.expect_node(mapping=True)
+
+    def expect_flow_mapping_key(self):
+        if isinstance(self.event, MappingEndEvent):
+            self.indent = self.indents.pop()
+            self.flow_level -= 1
+            if self.canonical:
+                self.write_indicator(u',', False)
+                self.write_indent()
+            self.write_indicator(u'}', False)
+            self.state = self.states.pop()
+        else:
+            self.write_indicator(u',', False)
+            if self.canonical or self.column > self.best_width:
+                self.write_indent()
+            if not self.canonical and self.check_simple_key():
+                self.states.append(self.expect_flow_mapping_simple_value)
+                self.expect_node(mapping=True, simple_key=True)
+            else:
+                self.write_indicator(u'?', True)
+                self.states.append(self.expect_flow_mapping_value)
+                self.expect_node(mapping=True)
+
+    def expect_flow_mapping_simple_value(self):
+        self.write_indicator(u':', False)
+        self.states.append(self.expect_flow_mapping_key)
+        self.expect_node(mapping=True)
+
+    def expect_flow_mapping_value(self):
+        if self.canonical or self.column > self.best_width:
+            self.write_indent()
+        self.write_indicator(u':', True)
+        self.states.append(self.expect_flow_mapping_key)
+        self.expect_node(mapping=True)
+
+    # Block sequence handlers.
+
+    def expect_block_sequence(self):
+        indentless = (self.mapping_context and not self.indention)
+        self.increase_indent(flow=False, indentless=indentless)
+        self.state = self.expect_first_block_sequence_item
+
+    def expect_first_block_sequence_item(self):
+        return self.expect_block_sequence_item(first=True)
+
+    def expect_block_sequence_item(self, first=False):
+        if not first and isinstance(self.event, SequenceEndEvent):
+            self.indent = self.indents.pop()
+            self.state = self.states.pop()
+        else:
+            self.write_indent()
+            self.write_indicator(u'-', True, indention=True)
+            self.states.append(self.expect_block_sequence_item)
+            self.expect_node(sequence=True)
+
+    # Block mapping handlers.
+
+    def expect_block_mapping(self):
+        self.increase_indent(flow=False)
+        self.state = self.expect_first_block_mapping_key
+
+    def expect_first_block_mapping_key(self):
+        return self.expect_block_mapping_key(first=True)
+
+    def expect_block_mapping_key(self, first=False):
+        if not first and isinstance(self.event, MappingEndEvent):
+            self.indent = self.indents.pop()
+            self.state = self.states.pop()
+        else:
+            self.write_indent()
+            if self.check_simple_key():
+                self.states.append(self.expect_block_mapping_simple_value)
+                self.expect_node(mapping=True, simple_key=True)
+            else:
+                self.write_indicator(u'?', True, indention=True)
+                self.states.append(self.expect_block_mapping_value)
+                self.expect_node(mapping=True)
+
+    def expect_block_mapping_simple_value(self):
+        self.write_indicator(u':', False)
+        self.states.append(self.expect_block_mapping_key)
+        self.expect_node(mapping=True)
+
+    def expect_block_mapping_value(self):
+        self.write_indent()
+        self.write_indicator(u':', True, indention=True)
+        self.states.append(self.expect_block_mapping_key)
+        self.expect_node(mapping=True)
+
+    # Checkers.
+
+    def check_empty_sequence(self):
+        return (isinstance(self.event, SequenceStartEvent) and self.events
+                and isinstance(self.events[0], SequenceEndEvent))
+
+    def check_empty_mapping(self):
+        return (isinstance(self.event, MappingStartEvent) and self.events
+                and isinstance(self.events[0], MappingEndEvent))
+
+    def check_empty_document(self):
+        if not isinstance(self.event, DocumentStartEvent) or not self.events:
+            return False
+        event = self.events[0]
+        return (isinstance(event, ScalarEvent) and event.anchor is None
+                and event.tag is None and event.implicit and event.value == u'')
+
+    def check_simple_key(self):
+        length = 0
+        if isinstance(self.event, NodeEvent) and self.event.anchor is not None:
+            if self.prepared_anchor is None:
+                self.prepared_anchor = self.prepare_anchor(self.event.anchor)
+            length += len(self.prepared_anchor)
+        if isinstance(self.event, (ScalarEvent, CollectionStartEvent))  \
+                and self.event.tag is not None:
+            if self.prepared_tag is None:
+                self.prepared_tag = self.prepare_tag(self.event.tag)
+            length += len(self.prepared_tag)
+        if isinstance(self.event, ScalarEvent):
+            if self.analysis is None:
+                self.analysis = self.analyze_scalar(self.event.value)
+            length += len(self.analysis.scalar)
+        return (length < 128 and (isinstance(self.event, AliasEvent)
+            or (isinstance(self.event, ScalarEvent)
+                    and not self.analysis.empty and not self.analysis.multiline)
+            or self.check_empty_sequence() or self.check_empty_mapping()))
+
+    # Anchor, Tag, and Scalar processors.
+
+    def process_anchor(self, indicator):
+        if self.event.anchor is None:
+            self.prepared_anchor = None
+            return
+        if self.prepared_anchor is None:
+            self.prepared_anchor = self.prepare_anchor(self.event.anchor)
+        if self.prepared_anchor:
+            self.write_indicator(indicator+self.prepared_anchor, True)
+        self.prepared_anchor = None
+
+    def process_tag(self):
+        tag = self.event.tag
+        if isinstance(self.event, ScalarEvent):
+            if self.style is None:
+                self.style = self.choose_scalar_style()
+            if ((not self.canonical or tag is None) and
+                ((self.style == '' and self.event.implicit[0])
+                        or (self.style != '' and self.event.implicit[1]))):
+                self.prepared_tag = None
+                return
+            if self.event.implicit[0] and tag is None:
+                tag = u'!'
+                self.prepared_tag = None
+        else:
+            if (not self.canonical or tag is None) and self.event.implicit:
+                self.prepared_tag = None
+                return
+        if tag is None:
+            raise EmitterError("tag is not specified")
+        if self.prepared_tag is None:
+            self.prepared_tag = self.prepare_tag(tag)
+        if self.prepared_tag:
+            self.write_indicator(self.prepared_tag, True)
+        self.prepared_tag = None
+
+    def choose_scalar_style(self):
+        if self.analysis is None:
+            self.analysis = self.analyze_scalar(self.event.value)
+        if self.event.style == '"' or self.canonical:
+            return '"'
+        if not self.event.style and self.event.implicit[0]:
+            if (not (self.simple_key_context and
+                    (self.analysis.empty or self.analysis.multiline))
+                and (self.flow_level and self.analysis.allow_flow_plain
+                    or (not self.flow_level and self.analysis.allow_block_plain))):
+                return ''
+        if self.event.style and self.event.style in '|>':
+            if (not self.flow_level and not self.simple_key_context
+                    and self.analysis.allow_block):
+                return self.event.style
+        if not self.event.style or self.event.style == '\'':
+            if (self.analysis.allow_single_quoted and
+                    not (self.simple_key_context and self.analysis.multiline)):
+                return '\''
+        return '"'
+
+    def process_scalar(self):
+        if self.analysis is None:
+            self.analysis = self.analyze_scalar(self.event.value)
+        if self.style is None:
+            self.style = self.choose_scalar_style()
+        split = (not self.simple_key_context)
+        #if self.analysis.multiline and split    \
+        #        and (not self.style or self.style in '\'\"'):
+        #    self.write_indent()
+        if self.style == '"':
+            self.write_double_quoted(self.analysis.scalar, split)
+        elif self.style == '\'':
+            self.write_single_quoted(self.analysis.scalar, split)
+        elif self.style == '>':
+            self.write_folded(self.analysis.scalar)
+        elif self.style == '|':
+            self.write_literal(self.analysis.scalar)
+        else:
+            self.write_plain(self.analysis.scalar, split)
+        self.analysis = None
+        self.style = None
+
+    # Analyzers.
+
+    def prepare_version(self, version):
+        major, minor = version
+        if major != 1:
+            raise EmitterError("unsupported YAML version: %d.%d" % (major, minor))
+        return u'%d.%d' % (major, minor)
+
+    def prepare_tag_handle(self, handle):
+        if not handle:
+            raise EmitterError("tag handle must not be empty")
+        if handle[0] != u'!' or handle[-1] != u'!':
+            raise EmitterError("tag handle must start and end with '!': %r"
+                    % (handle.encode('utf-8')))
+        for ch in handle[1:-1]:
+            if not (u'0' <= ch <= u'9' or u'A' <= ch <= 'Z' or u'a' <= ch <= 'z'    \
+                    or ch in u'-_'):
+                raise EmitterError("invalid character %r in the tag handle: %r"
+                        % (ch.encode('utf-8'), handle.encode('utf-8')))
+        return handle
+
+    def prepare_tag_prefix(self, prefix):
+        if not prefix:
+            raise EmitterError("tag prefix must not be empty")
+        chunks = []
+        start = end = 0
+        if prefix[0] == u'!':
+            end = 1
+        while end < len(prefix):
+            ch = prefix[end]
+            if u'0' <= ch <= u'9' or u'A' <= ch <= 'Z' or u'a' <= ch <= 'z'  \
+                    or ch in u'-;/?!:@&=+$,_.~*\'()[]':
+                end += 1
+            else:
+                if start < end:
+                    chunks.append(prefix[start:end])
+                start = end = end+1
+                data = ch.encode('utf-8')
+                for ch in data:
+                    chunks.append(u'%%%02X' % ord(ch))
+        if start < end:
+            chunks.append(prefix[start:end])
+        return u''.join(chunks)
+
+    def prepare_tag(self, tag):
+        if not tag:
+            raise EmitterError("tag must not be empty")
+        if tag == u'!':
+            return tag
+        handle = None
+        suffix = tag
+        for prefix in self.tag_prefixes:
+            if tag.startswith(prefix)   \
+                    and (prefix == u'!' or len(prefix) < len(tag)):
+                handle = self.tag_prefixes[prefix]
+                suffix = tag[len(prefix):]
+        chunks = []
+        start = end = 0
+        while end < len(suffix):
+            ch = suffix[end]
+            if u'0' <= ch <= u'9' or u'A' <= ch <= 'Z' or u'a' <= ch <= 'z'  \
+                    or ch in u'-;/?:@&=+$,_.~*\'()[]'   \
+                    or (ch == u'!' and handle != u'!'):
+                end += 1
+            else:
+                if start < end:
+                    chunks.append(suffix[start:end])
+                start = end = end+1
+                data = ch.encode('utf-8')
+                for ch in data:
+                    chunks.append(u'%%%02X' % ord(ch))
+        if start < end:
+            chunks.append(suffix[start:end])
+        suffix_text = u''.join(chunks)
+        if handle:
+            return u'%s%s' % (handle, suffix_text)
+        else:
+            return u'!<%s>' % suffix_text
+
+    def prepare_anchor(self, anchor):
+        if not anchor:
+            raise EmitterError("anchor must not be empty")
+        for ch in anchor:
+            if not (u'0' <= ch <= u'9' or u'A' <= ch <= 'Z' or u'a' <= ch <= 'z'    \
+                    or ch in u'-_'):
+                raise EmitterError("invalid character %r in the anchor: %r"
+                        % (ch.encode('utf-8'), anchor.encode('utf-8')))
+        return anchor
+
+    def analyze_scalar(self, scalar):
+
+        # Empty scalar is a special case.
+        if not scalar:
+            return ScalarAnalysis(scalar=scalar, empty=True, multiline=False,
+                    allow_flow_plain=False, allow_block_plain=True,
+                    allow_single_quoted=True, allow_double_quoted=True,
+                    allow_block=False)
+
+        # Indicators and special characters.
+        block_indicators = False
+        flow_indicators = False
+        line_breaks = False
+        special_characters = False
+
+        # Whitespaces.
+        inline_spaces = False          # non-space space+ non-space
+        inline_breaks = False          # non-space break+ non-space
+        leading_spaces = False         # ^ space+ (non-space | $)
+        leading_breaks = False         # ^ break+ (non-space | $)
+        trailing_spaces = False        # (^ | non-space) space+ $
+        trailing_breaks = False        # (^ | non-space) break+ $
+        inline_breaks_spaces = False   # non-space break+ space+ non-space
+        mixed_breaks_spaces = False    # anything else
+
+        # Check document indicators.
+        if scalar.startswith(u'---') or scalar.startswith(u'...'):
+            block_indicators = True
+            flow_indicators = True
+
+        # First character or preceded by a whitespace.
+        preceeded_by_space = True
+
+        # Last character or followed by a whitespace.
+        followed_by_space = (len(scalar) == 1 or
+                scalar[1] in u'\0 \t\r\n\x85\u2028\u2029')
+
+        # The current series of whitespaces contain plain spaces.
+        spaces = False
+
+        # The current series of whitespaces contain line breaks.
+        breaks = False
+
+        # The current series of whitespaces contain a space followed by a
+        # break.
+        mixed = False
+
+        # The current series of whitespaces start at the beginning of the
+        # scalar.
+        leading = False
+
+        index = 0
+        while index < len(scalar):
+            ch = scalar[index]
+
+            # Check for indicators.
+
+            if index == 0:
+                # Leading indicators are special characters.
+                if ch in u'#,[]{}&*!|>\'\"%@`': 
+                    flow_indicators = True
+                    block_indicators = True
+                if ch in u'?:':
+                    flow_indicators = True
+                    if followed_by_space:
+                        block_indicators = True
+                if ch == u'-' and followed_by_space:
+                    flow_indicators = True
+                    block_indicators = True
+            else:
+                # Some indicators cannot appear within a scalar as well.
+                if ch in u',?[]{}':
+                    flow_indicators = True
+                if ch == u':':
+                    flow_indicators = True
+                    if followed_by_space:
+                        block_indicators = True
+                if ch == u'#' and preceeded_by_space:
+                    flow_indicators = True
+                    block_indicators = True
+
+            # Check for line breaks, special, and unicode characters.
+
+            if ch in u'\n\x85\u2028\u2029':
+                line_breaks = True
+            if not (ch == u'\n' or u'\x20' <= ch <= u'\x7E'):
+                if (ch == u'\x85' or u'\xA0' <= ch <= u'\uD7FF'
+                        or u'\uE000' <= ch <= u'\uFFFD') and ch != u'\uFEFF':
+                    unicode_characters = True
+                    if not self.allow_unicode:
+                        special_characters = True
+                else:
+                    special_characters = True
+
+            # Spaces, line breaks, and how they are mixed. State machine.
+
+            # Start or continue series of whitespaces.
+            if ch in u' \n\x85\u2028\u2029':
+                if spaces and breaks:
+                    if ch != u' ':      # break+ (space+ break+)    => mixed
+                        mixed = True
+                elif spaces:
+                    if ch != u' ':      # (space+ break+)   => mixed
+                        breaks = True
+                        mixed = True
+                elif breaks:
+                    if ch == u' ':      # break+ space+
+                        spaces = True
+                else:
+                    leading = (index == 0)
+                    if ch == u' ':      # space+
+                        spaces = True
+                    else:               # break+
+                        breaks = True
+
+            # Series of whitespaces ended with a non-space.
+            elif spaces or breaks:
+                if leading:
+                    if spaces and breaks:
+                        mixed_breaks_spaces = True
+                    elif spaces:
+                        leading_spaces = True
+                    elif breaks:
+                        leading_breaks = True
+                else:
+                    if mixed:
+                        mixed_breaks_spaces = True
+                    elif spaces and breaks:
+                        inline_breaks_spaces = True
+                    elif spaces:
+                        inline_spaces = True
+                    elif breaks:
+                        inline_breaks = True
+                spaces = breaks = mixed = leading = False
+
+            # Series of whitespaces reach the end.
+            if (spaces or breaks) and (index == len(scalar)-1):
+                if spaces and breaks:
+                    mixed_breaks_spaces = True
+                elif spaces:
+                    trailing_spaces = True
+                    if leading:
+                        leading_spaces = True
+                elif breaks:
+                    trailing_breaks = True
+                    if leading:
+                        leading_breaks = True
+                spaces = breaks = mixed = leading = False
+
+            # Prepare for the next character.
+            index += 1
+            preceeded_by_space = (ch in u'\0 \t\r\n\x85\u2028\u2029')
+            followed_by_space = (index+1 >= len(scalar) or
+                    scalar[index+1] in u'\0 \t\r\n\x85\u2028\u2029')
+
+        # Let's decide what styles are allowed.
+        allow_flow_plain = True
+        allow_block_plain = True
+        allow_single_quoted = True
+        allow_double_quoted = True
+        allow_block = True
+
+        # Leading and trailing whitespace are bad for plain scalars. We also
+        # do not want to mess with leading whitespaces for block scalars.
+        if leading_spaces or leading_breaks or trailing_spaces:
+            allow_flow_plain = allow_block_plain = allow_block = False
+
+        # Trailing breaks are fine for block scalars, but unacceptable for
+        # plain scalars.
+        if trailing_breaks:
+            allow_flow_plain = allow_block_plain = False
+
+        # The combination of (space+ break+) is only acceptable for block
+        # scalars.
+        if inline_breaks_spaces:
+            allow_flow_plain = allow_block_plain = allow_single_quoted = False
+
+        # Mixed spaces and breaks, as well as special character are only
+        # allowed for double quoted scalars.
+        if mixed_breaks_spaces or special_characters:
+            allow_flow_plain = allow_block_plain =  \
+            allow_single_quoted = allow_block = False
+
+        # We don't emit multiline plain scalars.
+        if line_breaks:
+            allow_flow_plain = allow_block_plain = False
+
+        # Flow indicators are forbidden for flow plain scalars.
+        if flow_indicators:
+            allow_flow_plain = False
+
+        # Block indicators are forbidden for block plain scalars.
+        if block_indicators:
+            allow_block_plain = False
+
+        return ScalarAnalysis(scalar=scalar,
+                empty=False, multiline=line_breaks,
+                allow_flow_plain=allow_flow_plain,
+                allow_block_plain=allow_block_plain,
+                allow_single_quoted=allow_single_quoted,
+                allow_double_quoted=allow_double_quoted,
+                allow_block=allow_block)
+
+    # Writers.
+
+    def flush_stream(self):
+        if hasattr(self.stream, 'flush'):
+            self.stream.flush()
+
+    def write_stream_start(self):
+        # Write BOM if needed.
+        if self.encoding and self.encoding.startswith('utf-16'):
+            self.stream.write(u'\xFF\xFE'.encode(self.encoding))
+
+    def write_stream_end(self):
+        self.flush_stream()
+
+    def write_indicator(self, indicator, need_whitespace,
+            whitespace=False, indention=False):
+        if self.whitespace or not need_whitespace:
+            data = indicator
+        else:
+            data = u' '+indicator
+        self.whitespace = whitespace
+        self.indention = self.indention and indention
+        self.column += len(data)
+        if self.encoding:
+            data = data.encode(self.encoding)
+        self.stream.write(data)
+
+    def write_indent(self):
+        indent = self.indent or 0
+        if not self.indention or self.column > indent   \
+                or (self.column == indent and not self.whitespace):
+            self.write_line_break()
+        if self.column < indent:
+            self.whitespace = True
+            data = u' '*(indent-self.column)
+            self.column = indent
+            if self.encoding:
+                data = data.encode(self.encoding)
+            self.stream.write(data)
+
+    def write_line_break(self, data=None):
+        if data is None:
+            data = self.best_line_break
+        self.whitespace = True
+        self.indention = True
+        self.line += 1
+        self.column = 0
+        if self.encoding:
+            data = data.encode(self.encoding)
+        self.stream.write(data)
+
+    def write_version_directive(self, version_text):
+        data = u'%%YAML %s' % version_text
+        if self.encoding:
+            data = data.encode(self.encoding)
+        self.stream.write(data)
+        self.write_line_break()
+
+    def write_tag_directive(self, handle_text, prefix_text):
+        data = u'%%TAG %s %s' % (handle_text, prefix_text)
+        if self.encoding:
+            data = data.encode(self.encoding)
+        self.stream.write(data)
+        self.write_line_break()
+
+    # Scalar streams.
+
+    def write_single_quoted(self, text, split=True):
+        self.write_indicator(u'\'', True)
+        spaces = False
+        breaks = False
+        start = end = 0
+        while end <= len(text):
+            ch = None
+            if end < len(text):
+                ch = text[end]
+            if spaces:
+                if ch is None or ch != u' ':
+                    if start+1 == end and self.column > self.best_width and split   \
+                            and start != 0 and end != len(text):
+                        self.write_indent()
+                    else:
+                        data = text[start:end]
+                        self.column += len(data)
+                        if self.encoding:
+                            data = data.encode(self.encoding)
+                        self.stream.write(data)
+                    start = end
+            elif breaks:
+                if ch is None or ch not in u'\n\x85\u2028\u2029':
+                    if text[start] == u'\n':
+                        self.write_line_break()
+                    for br in text[start:end]:
+                        if br == u'\n':
+                            self.write_line_break()
+                        else:
+                            self.write_line_break(br)
+                    self.write_indent()
+                    start = end
+            else:
+                if ch is None or ch in u' \n\x85\u2028\u2029' or ch == u'\'':
+                    if start < end:
+                        data = text[start:end]
+                        self.column += len(data)
+                        if self.encoding:
+                            data = data.encode(self.encoding)
+                        self.stream.write(data)
+                        start = end
+            if ch == u'\'':
+                data = u'\'\''
+                self.column += 2
+                if self.encoding:
+                    data = data.encode(self.encoding)
+                self.stream.write(data)
+                start = end + 1
+            if ch is not None:
+                spaces = (ch == u' ')
+                breaks = (ch in u'\n\x85\u2028\u2029')
+            end += 1
+        self.write_indicator(u'\'', False)
+
+    ESCAPE_REPLACEMENTS = {
+        u'\0':      u'0',
+        u'\x07':    u'a',
+        u'\x08':    u'b',
+        u'\x09':    u't',
+        u'\x0A':    u'n',
+        u'\x0B':    u'v',
+        u'\x0C':    u'f',
+        u'\x0D':    u'r',
+        u'\x1B':    u'e',
+        u'\"':      u'\"',
+        u'\\':      u'\\',
+        u'\x85':    u'N',
+        u'\xA0':    u'_',
+        u'\u2028':  u'L',
+        u'\u2029':  u'P',
+    }
+
+    def write_double_quoted(self, text, split=True):
+        self.write_indicator(u'"', True)
+        start = end = 0
+        while end <= len(text):
+            ch = None
+            if end < len(text):
+                ch = text[end]
+            if ch is None or ch in u'"\\\x85\u2028\u2029\uFEFF' \
+                    or not (u'\x20' <= ch <= u'\x7E'
+                        or (self.allow_unicode
+                            and (u'\xA0' <= ch <= u'\uD7FF'
+                                or u'\uE000' <= ch <= u'\uFFFD'))):
+                if start < end:
+                    data = text[start:end]
+                    self.column += len(data)
+                    if self.encoding:
+                        data = data.encode(self.encoding)
+                    self.stream.write(data)
+                    start = end
+                if ch is not None:
+                    if ch in self.ESCAPE_REPLACEMENTS:
+                        data = u'\\'+self.ESCAPE_REPLACEMENTS[ch]
+                    elif ch <= u'\xFF':
+                        data = u'\\x%02X' % ord(ch)
+                    elif ch <= u'\uFFFF':
+                        data = u'\\u%04X' % ord(ch)
+                    else:
+                        data = u'\\U%08X' % ord(ch)
+                    self.column += len(data)
+                    if self.encoding:
+                        data = data.encode(self.encoding)
+                    self.stream.write(data)
+                    start = end+1
+            if 0 < end < len(text)-1 and (ch == u' ' or start >= end)   \
+                    and self.column+(end-start) > self.best_width and split:
+                data = text[start:end]+u'\\'
+                if start < end:
+                    start = end
+                self.column += len(data)
+                if self.encoding:
+                    data = data.encode(self.encoding)
+                self.stream.write(data)
+                self.write_indent()
+                self.whitespace = False
+                self.indention = False
+                if text[start] == u' ':
+                    data = u'\\'
+                    self.column += len(data)
+                    if self.encoding:
+                        data = data.encode(self.encoding)
+                    self.stream.write(data)
+            end += 1
+        self.write_indicator(u'"', False)
+
+    def determine_chomp(self, text):
+        tail = text[-2:]
+        while len(tail) < 2:
+            tail = u' '+tail
+        if tail[-1] in u'\n\x85\u2028\u2029':
+            if tail[-2] in u'\n\x85\u2028\u2029':
+                return u'+'
+            else:
+                return u''
+        else:
+            return u'-'
+
+    def write_folded(self, text):
+        chomp = self.determine_chomp(text)
+        self.write_indicator(u'>'+chomp, True)
+        self.write_indent()
+        leading_space = False
+        spaces = False
+        breaks = False
+        start = end = 0
+        while end <= len(text):
+            ch = None
+            if end < len(text):
+                ch = text[end]
+            if breaks:
+                if ch is None or ch not in u'\n\x85\u2028\u2029':
+                    if not leading_space and ch is not None and ch != u' '  \
+                            and text[start] == u'\n':
+                        self.write_line_break()
+                    leading_space = (ch == u' ')
+                    for br in text[start:end]:
+                        if br == u'\n':
+                            self.write_line_break()
+                        else:
+                            self.write_line_break(br)
+                    if ch is not None:
+                        self.write_indent()
+                    start = end
+            elif spaces:
+                if ch != u' ':
+                    if start+1 == end and self.column > self.best_width:
+                        self.write_indent()
+                    else:
+                        data = text[start:end]
+                        self.column += len(data)
+                        if self.encoding:
+                            data = data.encode(self.encoding)
+                        self.stream.write(data)
+                    start = end
+            else:
+                if ch is None or ch in u' \n\x85\u2028\u2029':
+                    data = text[start:end]
+                    if self.encoding:
+                        data = data.encode(self.encoding)
+                    self.stream.write(data)
+                    if ch is None:
+                        self.write_line_break()
+                    start = end
+            if ch is not None:
+                breaks = (ch in u'\n\x85\u2028\u2029')
+                spaces = (ch == u' ')
+            end += 1
+
+    def write_literal(self, text):
+        chomp = self.determine_chomp(text)
+        self.write_indicator(u'|'+chomp, True)
+        self.write_indent()
+        breaks = False
+        start = end = 0
+        while end <= len(text):
+            ch = None
+            if end < len(text):
+                ch = text[end]
+            if breaks:
+                if ch is None or ch not in u'\n\x85\u2028\u2029':
+                    for br in text[start:end]:
+                        if br == u'\n':
+                            self.write_line_break()
+                        else:
+                            self.write_line_break(br)
+                    if ch is not None:
+                        self.write_indent()
+                    start = end
+            else:
+                if ch is None or ch in u'\n\x85\u2028\u2029':
+                    data = text[start:end]
+                    if self.encoding:
+                        data = data.encode(self.encoding)
+                    self.stream.write(data)
+                    if ch is None:
+                        self.write_line_break()
+                    start = end
+            if ch is not None:
+                breaks = (ch in u'\n\x85\u2028\u2029')
+            end += 1
+
+    def write_plain(self, text, split=True):
+        if not text:
+            return
+        if not self.whitespace:
+            data = u' '
+            self.column += len(data)
+            if self.encoding:
+                data = data.encode(self.encoding)
+            self.stream.write(data)
+        self.writespace = False
+        self.indention = False
+        spaces = False
+        breaks = False
+        start = end = 0
+        while end <= len(text):
+            ch = None
+            if end < len(text):
+                ch = text[end]
+            if spaces:
+                if ch != u' ':
+                    if start+1 == end and self.column > self.best_width and split:
+                        self.write_indent()
+                        self.writespace = False
+                        self.indention = False
+                    else:
+                        data = text[start:end]
+                        self.column += len(data)
+                        if self.encoding:
+                            data = data.encode(self.encoding)
+                        self.stream.write(data)
+                    start = end
+            elif breaks:
+                if ch not in u'\n\x85\u2028\u2029':
+                    if text[start] == u'\n':
+                        self.write_line_break()
+                    for br in text[start:end]:
+                        if br == u'\n':
+                            self.write_line_break()
+                        else:
+                            self.write_line_break(br)
+                    self.write_indent()
+                    self.whitespace = False
+                    self.indention = False
+                    start = end
+            else:
+                if ch is None or ch in u' \n\x85\u2028\u2029':
+                    data = text[start:end]
+                    self.column += len(data)
+                    if self.encoding:
+                        data = data.encode(self.encoding)
+                    self.stream.write(data)
+                    start = end
+            if ch is not None:
+                spaces = (ch == u' ')
+                breaks = (ch in u'\n\x85\u2028\u2029')
+            end += 1
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/yaml/error.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/yaml/error.py b/tools/bin/ext/yaml/error.py
new file mode 100644
index 0000000..89e4a6a
--- /dev/null
+++ b/tools/bin/ext/yaml/error.py
@@ -0,0 +1,91 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+__all__ = ['Mark', 'YAMLError', 'MarkedYAMLError']
+
+class Mark(object):
+
+    def __init__(self, name, index, line, column, buffer, pointer):
+        self.name = name
+        self.index = index
+        self.line = line
+        self.column = column
+        self.buffer = buffer
+        self.pointer = pointer
+
+    def get_snippet(self, indent=4, max_length=75):
+        if self.buffer is None:
+            return None
+        head = ''
+        start = self.pointer
+        while start > 0 and self.buffer[start-1] not in u'\0\r\n\x85\u2028\u2029':
+            start -= 1
+            if self.pointer-start > max_length/2-1:
+                head = ' ... '
+                start += 5
+                break
+        tail = ''
+        end = self.pointer
+        while end < len(self.buffer) and self.buffer[end] not in u'\0\r\n\x85\u2028\u2029':
+            end += 1
+            if end-self.pointer > max_length/2-1:
+                tail = ' ... '
+                end -= 5
+                break
+        snippet = self.buffer[start:end].encode('utf-8')
+        return ' '*indent + head + snippet + tail + '\n'  \
+                + ' '*(indent+self.pointer-start+len(head)) + '^'
+
+    def __str__(self):
+        snippet = self.get_snippet()
+        where = "  in \"%s\", line %d, column %d"   \
+                % (self.name, self.line+1, self.column+1)
+        if snippet is not None:
+            where += ":\n"+snippet
+        return where
+
+class YAMLError(Exception):
+    pass
+
+class MarkedYAMLError(YAMLError):
+
+    def __init__(self, context=None, context_mark=None,
+            problem=None, problem_mark=None, note=None):
+        self.context = context
+        self.context_mark = context_mark
+        self.problem = problem
+        self.problem_mark = problem_mark
+        self.note = note
+
+    def __str__(self):
+        lines = []
+        if self.context is not None:
+            lines.append(self.context)
+        if self.context_mark is not None  \
+            and (self.problem is None or self.problem_mark is None
+                    or self.context_mark.name != self.problem_mark.name
+                    or self.context_mark.line != self.problem_mark.line
+                    or self.context_mark.column != self.problem_mark.column):
+            lines.append(str(self.context_mark))
+        if self.problem is not None:
+            lines.append(self.problem)
+        if self.problem_mark is not None:
+            lines.append(str(self.problem_mark))
+        if self.note is not None:
+            lines.append(self.note)
+        return '\n'.join(lines)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/yaml/events.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/yaml/events.py b/tools/bin/ext/yaml/events.py
new file mode 100644
index 0000000..f57b773
--- /dev/null
+++ b/tools/bin/ext/yaml/events.py
@@ -0,0 +1,102 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Abstract classes.
+
+class Event(object):
+    def __init__(self, start_mark=None, end_mark=None):
+        self.start_mark = start_mark
+        self.end_mark = end_mark
+    def __repr__(self):
+        attributes = [key for key in ['anchor', 'tag', 'implicit', 'value']
+                if hasattr(self, key)]
+        arguments = ', '.join(['%s=%r' % (key, getattr(self, key))
+                for key in attributes])
+        return '%s(%s)' % (self.__class__.__name__, arguments)
+
+class NodeEvent(Event):
+    def __init__(self, anchor, start_mark=None, end_mark=None):
+        self.anchor = anchor
+        self.start_mark = start_mark
+        self.end_mark = end_mark
+
+class CollectionStartEvent(NodeEvent):
+    def __init__(self, anchor, tag, implicit, start_mark=None, end_mark=None,
+            flow_style=None):
+        self.anchor = anchor
+        self.tag = tag
+        self.implicit = implicit
+        self.start_mark = start_mark
+        self.end_mark = end_mark
+        self.flow_style = flow_style
+
+class CollectionEndEvent(Event):
+    pass
+
+# Implementations.
+
+class StreamStartEvent(Event):
+    def __init__(self, start_mark=None, end_mark=None, encoding=None):
+        self.start_mark = start_mark
+        self.end_mark = end_mark
+        self.encoding = encoding
+
+class StreamEndEvent(Event):
+    pass
+
+class DocumentStartEvent(Event):
+    def __init__(self, start_mark=None, end_mark=None,
+            explicit=None, version=None, tags=None):
+        self.start_mark = start_mark
+        self.end_mark = end_mark
+        self.explicit = explicit
+        self.version = version
+        self.tags = tags
+
+class DocumentEndEvent(Event):
+    def __init__(self, start_mark=None, end_mark=None,
+            explicit=None):
+        self.start_mark = start_mark
+        self.end_mark = end_mark
+        self.explicit = explicit
+
+class AliasEvent(NodeEvent):
+    pass
+
+class ScalarEvent(NodeEvent):
+    def __init__(self, anchor, tag, implicit, value,
+            start_mark=None, end_mark=None, style=None):
+        self.anchor = anchor
+        self.tag = tag
+        self.implicit = implicit
+        self.value = value
+        self.start_mark = start_mark
+        self.end_mark = end_mark
+        self.style = style
+
+class SequenceStartEvent(CollectionStartEvent):
+    pass
+
+class SequenceEndEvent(CollectionEndEvent):
+    pass
+
+class MappingStartEvent(CollectionStartEvent):
+    pass
+
+class MappingEndEvent(CollectionEndEvent):
+    pass
+



[15/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code

Posted by rl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/lockfile-0.9.1/doc/lockfile.rst
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/lockfile-0.9.1/doc/lockfile.rst b/tools/bin/pythonSrc/lockfile-0.9.1/doc/lockfile.rst
new file mode 100644
index 0000000..4bc0a3e
--- /dev/null
+++ b/tools/bin/pythonSrc/lockfile-0.9.1/doc/lockfile.rst
@@ -0,0 +1,257 @@
+
+:mod:`lockfile` --- Platform-independent file locking
+=====================================================
+
+.. module:: lockfile
+   :synopsis: Platform-independent file locking
+.. moduleauthor:: Skip Montanaro <sk...@pobox.com>
+.. sectionauthor:: Skip Montanaro <sk...@pobox.com>
+
+
+.. note::
+
+   This package is pre-release software.  Between versions 0.8 and 0.9 it
+   was changed from a module to a package.  It is quite possible that the
+   API and implementation will change again in important ways as people test
+   it and provide feedback and bug fixes.  In particular, if the mkdir-based
+   locking scheme is sufficient for both Windows and Unix platforms, the
+   link-based scheme may be deleted so that only a single locking scheme is
+   used, providing cross-platform lockfile cooperation.
+
+.. note::
+
+   The implementation uses the :keyword:`with` statement, both in the
+   tests and in the main code, so will only work out-of-the-box with Python
+   2.5 or later.  However, the use of the :keyword:`with` statement is
+   minimal, so if you apply the patch in the included 2.4.diff file you can
+   use it with Python 2.4.  It's possible that it will work in Python 2.3
+   with that patch applied as well, though the doctest code relies on APIs
+   new in 2.4, so will have to be rewritten somewhat to allow testing on
+   2.3.  As they say, patches welcome. ``;-)``
+
+The :mod:`lockfile` package exports a :class:`LockFile` class which provides
+a simple API for locking files.  Unlike the Windows :func:`msvcrt.locking`
+function, the Unix :func:`fcntl.flock`, :func:`fcntl.lockf` and the
+deprecated :mod:`posixfile` module, the API is identical across both Unix
+(including Linux and Mac) and Windows platforms.  The lock mechanism relies
+on the atomic nature of the :func:`link` (on Unix) and :func:`mkdir` (On
+Windows) system calls.  It also contains several lock-method-specific
+modules: :mod:`lockfile.linklockfile`, :mod:`lockfile.mkdirlockfile`, and
+:mod:`lockfile.sqlitelockfile`, each one exporting a single class.  For
+backwards compatibility with versions before 0.9 the :class:`LinkFileLock`,
+:class:`MkdirFileLock` and :class:`SQLiteFileLock` objects are exposed as
+attributes of the top-level lockfile package, though this use was deprecated
+starting with version 0.9 and will be removed in version 1.0.
+
+.. note::
+
+   The current implementation uses :func:`os.link` on Unix, but since that
+   function is unavailable on Windows it uses :func:`os.mkdir` there.  At
+   this point it's not clear that using the :func:`os.mkdir` method would be
+   insufficient on Unix systems.  If it proves to be adequate on Unix then
+   the implementation could be simplified and truly cross-platform locking
+   would be possible.
+
+.. note::
+
+   The current implementation doesn't provide for shared vs. exclusive
+   locks.  It should be possible for multiple reader processes to hold the
+   lock at the same time.
+
+The module defines the following exceptions:
+
+.. exception:: Error
+
+   This is the base class for all exceptions raised by the :class:`LockFile`
+   class.
+
+.. exception:: LockError
+
+   This is the base class for all exceptions raised when attempting to lock
+   a file.
+
+.. exception:: UnlockError
+
+   This is the base class for all exceptions raised when attempting to
+   unlock a file.
+
+.. exception:: LockTimeout
+
+   This exception is raised if the :func:`LockFile.acquire` method is
+   called with a timeout which expires before an existing lock is released.
+
+.. exception:: AlreadyLocked
+
+   This exception is raised if the :func:`LockFile.acquire` detects a
+   file is already locked when in non-blocking mode.
+
+.. exception:: LockFailed
+
+   This exception is raised if the :func:`LockFile.acquire` detects some
+   other condition (such as a non-writable directory) which prevents it from
+   creating its lock file.
+
+.. exception:: NotLocked
+
+   This exception is raised if the file is not locked when
+   :func:`LockFile.release` is called.
+
+.. exception:: NotMyLock
+
+   This exception is raised if the file is locked by another thread or
+   process when :func:`LockFile.release` is called.
+
+The following classes are provided:
+
+.. class:: linklockfile.LinkLockFile(path, threaded=True)
+
+   This class uses the :func:`link(2)` system call as the basic lock
+   mechanism.  *path* is an object in the file system to be locked.  It need
+   not exist, but its directory must exist and be writable at the time the
+   :func:`acquire` and :func:`release` methods are called.  *threaded* is
+   optional, but when set to :const:`True` locks will be distinguished
+   between threads in the same process.
+
+.. class:: mkdirlockfile.MkdirLockFile(path, threaded=True)
+
+   This class uses the :func:`mkdir(2)` system call as the basic lock
+   mechanism.  The parameters have the same meaning as for the
+   :class:`LinkLockFile` class.
+
+.. class:: sqlitelockfile.SQLiteLockFile(path, threaded=True)
+
+   This class uses the :mod:`sqlite3` module to implement the lock
+   mechanism.  The parameters have the same meaning as for the
+   :class:`LinkLockFile` class.
+
+.. class:: LockBase(path, threaded=True)
+
+   This is the base class for all concrete implementations and is available
+   at the lockfile package level so programmers can implement other locking
+   schemes.
+
+By default, the :const:`LockFile` object refers to the
+:class:`mkdirlockfile.MkdirLockFile` class on Windows.  On all other
+platforms it refers to the :class:`linklockfile.LinkLockFile` class.
+
+When locking a file the :class:`linklockfile.LinkLockFile` class creates a
+uniquely named hard link to an empty lock file.  That hard link contains the
+hostname, process id, and if locks between threads are distinguished, the
+thread identifier.  For example, if you want to lock access to a file named
+"README", the lock file is named "README.lock".  With per-thread locks
+enabled the hard link is named HOSTNAME-THREADID-PID.  With only per-process
+locks enabled the hard link is named HOSTNAME--PID.
+
+When using the :class:`mkdirlockfile.MkdirLockFile` class the lock file is a
+directory.  Referring to the example above, README.lock will be a directory
+and HOSTNAME-THREADID-PID will be an empty file within that directory.
+
+.. seealso::
+
+   Module :mod:`msvcrt`
+      Provides the :func:`locking` function, the standard Windows way of
+      locking (parts of) a file.
+
+   Module :mod:`posixfile`
+      The deprecated (since Python 1.5) way of locking files on Posix systems.
+
+   Module :mod:`fcntl`
+      Provides the current best way to lock files on Unix systems
+      (:func:`lockf` and :func:`flock`).
+
+LockFile Objects
+----------------
+
+:class:`LockFile` objects support the :term:`context manager` protocol used
+by the statement:`with` statement.  The timeout option is not supported when
+used in this fashion.  While support for timeouts could be implemented,
+there is no support for handling the eventual :exc:`Timeout` exceptions
+raised by the :func:`__enter__` method, so you would have to protect the
+:keyword:`with` statement with a :keyword:`try` statement.  The resulting
+construct would not be any simpler than just using a :keyword:`try`
+statement in the first place.
+
+:class:`LockFile` has the following user-visible methods:
+
+.. method:: LockFile.acquire(timeout=None)
+
+   Lock the file associated with the :class:`LockFile` object.  If the
+   *timeout* is omitted or :const:`None` the caller will block until the
+   file is unlocked by the object currently holding the lock.  If the
+   *timeout* is zero or a negative number the :exc:`AlreadyLocked` exception
+   will be raised if the file is currently locked by another process or
+   thread.  If the *timeout* is positive, the caller will block for that
+   many seconds waiting for the lock to be released.  If the lock is not
+   released within that period the :exc:`LockTimeout` exception will be
+   raised.
+
+.. method:: LockFile.release()
+
+   Unlock the file associated with the :class:`LockFile` object.  If the
+   file is not currently locked, the :exc:`NotLocked` exception is raised.
+   If the file is locked by another thread or process the :exc:`NotMyLock`
+   exception is raised.
+
+.. method:: is_locked()
+
+   Return the status of the lock on the current file.  If any process or
+   thread (including the current one) is locking the file, :const:`True` is
+   returned, otherwise :const:`False` is returned.
+
+.. method:: break_lock()
+
+   If the file is currently locked, break it.
+
+.. method:: i_am_locking()
+
+   Returns true if the caller holds the lock.
+
+Examples
+--------
+
+This example is the "hello world" for the :mod:`lockfile` package::
+
+    from lockfile import LockFile
+    lock = LockFile("/some/file/or/other")
+    with lock:
+        print lock.path, 'is locked.'
+
+To use this with Python 2.4, you can execute::
+
+    frm lockfile import LockFile
+    lock = LockFile("/some/file/or/other")
+    lock.acquire()
+    print lock.path, 'is locked.'
+    lock.release()
+
+If you don't want to wait forever, you might try::	
+
+    from lockfile import LockFile
+    lock = LockFile("/some/file/or/other")
+    while not lock.i_am_locking():
+	try:
+	    lock.acquire(timeout=60)    # wait up to 60 seconds
+	except LockTimeout:
+	    lock.break_lock()
+	    lock.acquire()
+    print "I locked", lock.path
+    lock.release()
+
+Other Libraries
+---------------
+
+The idea of implementing advisory locking with a standard API is not new
+with :mod:`lockfile`.  There are a number of other libraries available:
+
+* locknix - http://pypi.python.org/pypi/locknix - Unix only
+* mx.MiscLockFile - from Marc Andr� Lemburg, part of the mx.Base
+  distribution - cross-platform.
+* Twisted - http://twistedmatrix.com/trac/browser/trunk/twisted/python/lockfile.py
+* zc.lockfile - http://pypi.python.org/pypi/zc.lockfile
+
+
+Contacting the Author
+---------------------
+
+If you encounter any problems with ``lockfile``, would like help or want to
+submit a patch, contact me directly: Skip Montanaro (skip@pobox.com).

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/lockfile-0.9.1/lockfile/__init__.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/lockfile-0.9.1/lockfile/__init__.py b/tools/bin/pythonSrc/lockfile-0.9.1/lockfile/__init__.py
new file mode 100644
index 0000000..a167cd8
--- /dev/null
+++ b/tools/bin/pythonSrc/lockfile-0.9.1/lockfile/__init__.py
@@ -0,0 +1,286 @@
+
+"""
+lockfile.py - Platform-independent advisory file locks.
+
+Requires Python 2.5 unless you apply 2.4.diff
+Locking is done on a per-thread basis instead of a per-process basis.
+
+Usage:
+
+>>> lock = LockFile('somefile')
+>>> try:
+...     lock.acquire()
+... except AlreadyLocked:
+...     print 'somefile', 'is locked already.'
+... except LockFailed:
+...     print 'somefile', 'can\\'t be locked.'
+... else:
+...     print 'got lock'
+got lock
+>>> print lock.is_locked()
+True
+>>> lock.release()
+
+>>> lock = LockFile('somefile')
+>>> print lock.is_locked()
+False
+>>> with lock:
+...    print lock.is_locked()
+True
+>>> print lock.is_locked()
+False
+
+>>> lock = LockFile('somefile')
+>>> # It is okay to lock twice from the same thread...
+>>> with lock:
+...     lock.acquire()
+...
+>>> # Though no counter is kept, so you can't unlock multiple times...
+>>> print lock.is_locked()
+False
+
+Exceptions:
+
+    Error - base class for other exceptions
+        LockError - base class for all locking exceptions
+            AlreadyLocked - Another thread or process already holds the lock
+            LockFailed - Lock failed for some other reason
+        UnlockError - base class for all unlocking exceptions
+            AlreadyUnlocked - File was not locked.
+            NotMyLock - File was locked but not by the current thread/process
+"""
+
+import sys
+import socket
+import os
+import threading
+import time
+import urllib
+import warnings
+
+# Work with PEP8 and non-PEP8 versions of threading module.
+if not hasattr(threading, "current_thread"):
+    threading.current_thread = threading.currentThread
+if not hasattr(threading.Thread, "get_name"):
+    threading.Thread.get_name = threading.Thread.getName
+
+__all__ = ['Error', 'LockError', 'LockTimeout', 'AlreadyLocked',
+           'LockFailed', 'UnlockError', 'NotLocked', 'NotMyLock',
+           'LinkLockFile', 'MkdirLockFile', 'SQLiteLockFile',
+           'LockBase']
+
+class Error(Exception):
+    """
+    Base class for other exceptions.
+
+    >>> try:
+    ...   raise Error
+    ... except Exception:
+    ...   pass
+    """
+    pass
+
+class LockError(Error):
+    """
+    Base class for error arising from attempts to acquire the lock.
+
+    >>> try:
+    ...   raise LockError
+    ... except Error:
+    ...   pass
+    """
+    pass
+
+class LockTimeout(LockError):
+    """Raised when lock creation fails within a user-defined period of time.
+
+    >>> try:
+    ...   raise LockTimeout
+    ... except LockError:
+    ...   pass
+    """
+    pass
+
+class AlreadyLocked(LockError):
+    """Some other thread/process is locking the file.
+
+    >>> try:
+    ...   raise AlreadyLocked
+    ... except LockError:
+    ...   pass
+    """
+    pass
+
+class LockFailed(LockError):
+    """Lock file creation failed for some other reason.
+
+    >>> try:
+    ...   raise LockFailed
+    ... except LockError:
+    ...   pass
+    """
+    pass
+
+class UnlockError(Error):
+    """
+    Base class for errors arising from attempts to release the lock.
+
+    >>> try:
+    ...   raise UnlockError
+    ... except Error:
+    ...   pass
+    """
+    pass
+
+class NotLocked(UnlockError):
+    """Raised when an attempt is made to unlock an unlocked file.
+
+    >>> try:
+    ...   raise NotLocked
+    ... except UnlockError:
+    ...   pass
+    """
+    pass
+
+class NotMyLock(UnlockError):
+    """Raised when an attempt is made to unlock a file someone else locked.
+
+    >>> try:
+    ...   raise NotMyLock
+    ... except UnlockError:
+    ...   pass
+    """
+    pass
+
+class LockBase:
+    """Base class for platform-specific lock classes."""
+    def __init__(self, path, threaded=True):
+        """
+        >>> lock = LockBase('somefile')
+        >>> lock = LockBase('somefile', threaded=False)
+        """
+        self.path = path
+        self.lock_file = os.path.abspath(path) + ".lock"
+        self.hostname = socket.gethostname()
+        self.pid = os.getpid()
+        if threaded:
+            t = threading.current_thread()
+            # Thread objects in Python 2.4 and earlier do not have ident
+            # attrs.  Worm around that.
+            ident = getattr(t, "ident", hash(t))
+            self.tname = "-%x" % (ident & 0xffffffff)
+        else:
+            self.tname = ""
+        dirname = os.path.dirname(self.lock_file)
+        self.unique_name = os.path.join(dirname,
+                                        "%s%s.%s" % (self.hostname,
+                                                     self.tname,
+                                                     self.pid))
+
+    def acquire(self, timeout=None):
+        """
+        Acquire the lock.
+
+        * If timeout is omitted (or None), wait forever trying to lock the
+          file.
+
+        * If timeout > 0, try to acquire the lock for that many seconds.  If
+          the lock period expires and the file is still locked, raise
+          LockTimeout.
+
+        * If timeout <= 0, raise AlreadyLocked immediately if the file is
+          already locked.
+        """
+        raise NotImplemented("implement in subclass")
+
+    def release(self):
+        """
+        Release the lock.
+
+        If the file is not locked, raise NotLocked.
+        """
+        raise NotImplemented("implement in subclass")
+
+    def is_locked(self):
+        """
+        Tell whether or not the file is locked.
+        """
+        raise NotImplemented("implement in subclass")
+
+    def i_am_locking(self):
+        """
+        Return True if this object is locking the file.
+        """
+        raise NotImplemented("implement in subclass")
+
+    def break_lock(self):
+        """
+        Remove a lock.  Useful if a locking thread failed to unlock.
+        """
+        raise NotImplemented("implement in subclass")
+
+    def __enter__(self):
+        """
+        Context manager support.
+        """
+        self.acquire()
+        return self
+
+    def __exit__(self, *_exc):
+        """
+        Context manager support.
+        """
+        self.release()
+
+def _fl_helper(cls, mod, *args, **kwds):
+    warnings.warn("Import from %s module instead of lockfile package" % mod,
+                  DeprecationWarning, stacklevel=2)
+    # This is a bit funky, but it's only for awhile.  The way the unit tests
+    # are constructed this function winds up as an unbound method, so it
+    # actually takes three args, not two.  We want to toss out self.
+    if not isinstance(args[0], str):
+        # We are testing, avoid the first arg
+        args = args[1:]
+    if len(args) == 1 and not kwds:
+        kwds["threaded"] = True
+    return cls(*args, **kwds)
+
+def LinkFileLock(*args, **kwds):
+    """Factory function provided for backwards compatibility.
+
+    Do not use in new code.  Instead, import LinkLockFile from the
+    lockfile.linklockfile module.
+    """
+    import linklockfile
+    return _fl_helper(linklockfile.LinkLockFile, "lockfile.linklockfile",
+                      *args, **kwds)
+
+def MkdirFileLock(*args, **kwds):
+    """Factory function provided for backwards compatibility.
+
+    Do not use in new code.  Instead, import MkdirLockFile from the
+    lockfile.mkdirlockfile module.
+    """
+    import mkdirlockfile
+    return _fl_helper(mkdirlockfile.MkdirLockFile, "lockfile.mkdirlockfile",
+                      *args, **kwds)
+
+def SQLiteFileLock(*args, **kwds):
+    """Factory function provided for backwards compatibility.
+
+    Do not use in new code.  Instead, import SQLiteLockFile from the
+    lockfile.mkdirlockfile module.
+    """
+    import sqlitelockfile
+    return _fl_helper(sqlitelockfile.SQLiteLockFile, "lockfile.sqlitelockfile",
+                      *args, **kwds)
+
+if hasattr(os, "link"):
+    import linklockfile as _llf
+    LockFile = _llf.LinkLockFile
+else:
+    import mkdirlockfile as _mlf
+    LockFile = _mlf.MkdirLockFile
+
+FileLock = LockFile
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/lockfile-0.9.1/lockfile/linklockfile.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/lockfile-0.9.1/lockfile/linklockfile.py b/tools/bin/pythonSrc/lockfile-0.9.1/lockfile/linklockfile.py
new file mode 100644
index 0000000..737fd08
--- /dev/null
+++ b/tools/bin/pythonSrc/lockfile-0.9.1/lockfile/linklockfile.py
@@ -0,0 +1,69 @@
+from __future__ import absolute_import
+
+import time
+import os
+
+from . import (LockBase, LockFailed, NotLocked, NotMyLock, LockTimeout,
+               AlreadyLocked)
+
+class LinkLockFile(LockBase):
+    """Lock access to a file using atomic property of link(2).
+
+    >>> lock = LinkLockFile('somefile')
+    >>> lock = LinkLockFile('somefile', threaded=False)
+    """
+
+    def acquire(self, timeout=None):
+        try:
+            open(self.unique_name, "wb").close()
+        except IOError:
+            raise LockFailed("failed to create %s" % self.unique_name)
+
+        end_time = time.time()
+        if timeout is not None and timeout > 0:
+            end_time += timeout
+
+        while True:
+            # Try and create a hard link to it.
+            try:
+                os.link(self.unique_name, self.lock_file)
+            except OSError:
+                # Link creation failed.  Maybe we've double-locked?
+                nlinks = os.stat(self.unique_name).st_nlink
+                if nlinks == 2:
+                    # The original link plus the one I created == 2.  We're
+                    # good to go.
+                    return
+                else:
+                    # Otherwise the lock creation failed.
+                    if timeout is not None and time.time() > end_time:
+                        os.unlink(self.unique_name)
+                        if timeout > 0:
+                            raise LockTimeout
+                        else:
+                            raise AlreadyLocked
+                    time.sleep(timeout is not None and timeout/10 or 0.1)
+            else:
+                # Link creation succeeded.  We're good to go.
+                return
+
+    def release(self):
+        if not self.is_locked():
+            raise NotLocked
+        elif not os.path.exists(self.unique_name):
+            raise NotMyLock
+        os.unlink(self.unique_name)
+        os.unlink(self.lock_file)
+
+    def is_locked(self):
+        return os.path.exists(self.lock_file)
+
+    def i_am_locking(self):
+        return (self.is_locked() and
+                os.path.exists(self.unique_name) and
+                os.stat(self.unique_name).st_nlink == 2)
+
+    def break_lock(self):
+        if os.path.exists(self.lock_file):
+            os.unlink(self.lock_file)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/lockfile-0.9.1/lockfile/mkdirlockfile.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/lockfile-0.9.1/lockfile/mkdirlockfile.py b/tools/bin/pythonSrc/lockfile-0.9.1/lockfile/mkdirlockfile.py
new file mode 100644
index 0000000..fb78902
--- /dev/null
+++ b/tools/bin/pythonSrc/lockfile-0.9.1/lockfile/mkdirlockfile.py
@@ -0,0 +1,79 @@
+from __future__ import absolute_import, division
+
+import time
+import os
+import sys
+import errno
+
+from . import (LockBase, LockFailed, NotLocked, NotMyLock, LockTimeout,
+               AlreadyLocked)
+
+class MkdirLockFile(LockBase):
+    """Lock file by creating a directory."""
+    def __init__(self, path, threaded=True):
+        """
+        >>> lock = MkdirLockFile('somefile')
+        >>> lock = MkdirLockFile('somefile', threaded=False)
+        """
+        LockBase.__init__(self, path, threaded)
+        # Lock file itself is a directory.  Place the unique file name into
+        # it.
+        self.unique_name  = os.path.join(self.lock_file,
+                                         "%s.%s%s" % (self.hostname,
+                                                      self.tname,
+                                                      self.pid))
+
+    def acquire(self, timeout=None):
+        end_time = time.time()
+        if timeout is not None and timeout > 0:
+            end_time += timeout
+
+        if timeout is None:
+            wait = 0.1
+        else:
+            wait = max(0, timeout / 10)
+
+        while True:
+            try:
+                os.mkdir(self.lock_file)
+            except OSError:
+                err = sys.exc_info()[1]
+                if err.errno == errno.EEXIST:
+                    # Already locked.
+                    if os.path.exists(self.unique_name):
+                        # Already locked by me.
+                        return
+                    if timeout is not None and time.time() > end_time:
+                        if timeout > 0:
+                            raise LockTimeout
+                        else:
+                            # Someone else has the lock.
+                            raise AlreadyLocked
+                    time.sleep(wait)
+                else:
+                    # Couldn't create the lock for some other reason
+                    raise LockFailed("failed to create %s" % self.lock_file)
+            else:
+                open(self.unique_name, "wb").close()
+                return
+
+    def release(self):
+        if not self.is_locked():
+            raise NotLocked
+        elif not os.path.exists(self.unique_name):
+            raise NotMyLock
+        os.unlink(self.unique_name)
+        os.rmdir(self.lock_file)
+
+    def is_locked(self):
+        return os.path.exists(self.lock_file)
+
+    def i_am_locking(self):
+        return (self.is_locked() and
+                os.path.exists(self.unique_name))
+
+    def break_lock(self):
+        if os.path.exists(self.lock_file):
+            for name in os.listdir(self.lock_file):
+                os.unlink(os.path.join(self.lock_file, name))
+            os.rmdir(self.lock_file)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/lockfile-0.9.1/lockfile/pidlockfile.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/lockfile-0.9.1/lockfile/pidlockfile.py b/tools/bin/pythonSrc/lockfile-0.9.1/lockfile/pidlockfile.py
new file mode 100644
index 0000000..10dcb31
--- /dev/null
+++ b/tools/bin/pythonSrc/lockfile-0.9.1/lockfile/pidlockfile.py
@@ -0,0 +1,189 @@
+# -*- coding: utf-8 -*-
+
+# pidlockfile.py
+#
+# Copyright � 2008\u20132009 Ben Finney <be...@benfinney.id.au>
+#
+# This is free software: you may copy, modify, and/or distribute this work
+# under the terms of the Python Software Foundation License, version 2 or
+# later as published by the Python Software Foundation.
+# No warranty expressed or implied. See the file LICENSE.PSF-2 for details.
+
+""" Lockfile behaviour implemented via Unix PID files.
+    """
+
+from __future__ import absolute_import
+
+import os
+import sys
+import errno
+import time
+
+from . import (LockBase, AlreadyLocked, LockFailed, NotLocked, NotMyLock,
+               LockTimeout)
+
+
+class PIDLockFile(LockBase):
+    """ Lockfile implemented as a Unix PID file.
+
+    The lock file is a normal file named by the attribute `path`.
+    A lock's PID file contains a single line of text, containing
+    the process ID (PID) of the process that acquired the lock.
+
+    >>> lock = PIDLockFile('somefile')
+    >>> lock = PIDLockFile('somefile')
+    """
+
+    def __init__(self, path, threaded=False):
+        # pid lockfiles don't support threaded operation, so always force
+        # False as the threaded arg.
+        LockBase.__init__(self, path, False)
+        dirname = os.path.dirname(self.lock_file)
+        basename = os.path.split(self.path)[-1]
+        self.unique_name = self.path
+
+    def read_pid(self):
+        """ Get the PID from the lock file.
+            """
+        return read_pid_from_pidfile(self.path)
+
+    def is_locked(self):
+        """ Test if the lock is currently held.
+
+            The lock is held if the PID file for this lock exists.
+
+            """
+        return os.path.exists(self.path)
+
+    def i_am_locking(self):
+        """ Test if the lock is held by the current process.
+
+        Returns ``True`` if the current process ID matches the
+        number stored in the PID file.
+        """
+        return self.is_locked() and os.getpid() == self.read_pid()
+
+    def acquire(self, timeout=None):
+        """ Acquire the lock.
+
+        Creates the PID file for this lock, or raises an error if
+        the lock could not be acquired.
+        """
+
+        end_time = time.time()
+        if timeout is not None and timeout > 0:
+            end_time += timeout
+
+        while True:
+            try:
+                write_pid_to_pidfile(self.path)
+            except OSError, exc:
+                if exc.errno == errno.EEXIST:
+                    # The lock creation failed.  Maybe sleep a bit.
+                    if timeout is not None and time.time() > end_time:
+                        if timeout > 0:
+                            raise LockTimeout
+                        else:
+                            raise AlreadyLocked
+                    time.sleep(timeout is not None and timeout/10 or 0.1)
+                else:
+                    raise LockFailed
+            else:
+                return
+
+    def release(self):
+        """ Release the lock.
+
+            Removes the PID file to release the lock, or raises an
+            error if the current process does not hold the lock.
+
+            """
+        if not self.is_locked():
+            raise NotLocked
+        if not self.i_am_locking():
+            raise NotMyLock
+        remove_existing_pidfile(self.path)
+
+    def break_lock(self):
+        """ Break an existing lock.
+
+            Removes the PID file if it already exists, otherwise does
+            nothing.
+
+            """
+        remove_existing_pidfile(self.path)
+
+def read_pid_from_pidfile(pidfile_path):
+    """ Read the PID recorded in the named PID file.
+
+        Read and return the numeric PID recorded as text in the named
+        PID file. If the PID file cannot be read, or if the content is
+        not a valid PID, return ``None``.
+
+        """
+    pid = None
+    try:
+        pidfile = open(pidfile_path, 'r')
+    except IOError:
+        pass
+    else:
+        # According to the FHS 2.3 section on PID files in /var/run:
+        # 
+        #   The file must consist of the process identifier in
+        #   ASCII-encoded decimal, followed by a newline character.
+        # 
+        #   Programs that read PID files should be somewhat flexible
+        #   in what they accept; i.e., they should ignore extra
+        #   whitespace, leading zeroes, absence of the trailing
+        #   newline, or additional lines in the PID file.
+
+        line = pidfile.readline().strip()
+        try:
+            pid = int(line)
+        except ValueError:
+            pass
+        pidfile.close()
+
+    return pid
+
+
+def write_pid_to_pidfile(pidfile_path):
+    """ Write the PID in the named PID file.
+
+        Get the numeric process ID (\u201cPID\u201d) of the current process
+        and write it to the named file as a line of text.
+
+        """
+    open_flags = (os.O_CREAT | os.O_EXCL | os.O_WRONLY)
+    open_mode = 0644
+    pidfile_fd = os.open(pidfile_path, open_flags, open_mode)
+    pidfile = os.fdopen(pidfile_fd, 'w')
+
+    # According to the FHS 2.3 section on PID files in /var/run:
+    #
+    #   The file must consist of the process identifier in
+    #   ASCII-encoded decimal, followed by a newline character. For
+    #   example, if crond was process number 25, /var/run/crond.pid
+    #   would contain three characters: two, five, and newline.
+
+    pid = os.getpid()
+    line = "%(pid)d\n" % vars()
+    pidfile.write(line)
+    pidfile.close()
+
+
+def remove_existing_pidfile(pidfile_path):
+    """ Remove the named PID file if it exists.
+
+        Removing a PID file that doesn't already exist puts us in the
+        desired state, so we ignore the condition if the file does not
+        exist.
+
+        """
+    try:
+        os.remove(pidfile_path)
+    except OSError, exc:
+        if exc.errno == errno.ENOENT:
+            pass
+        else:
+            raise

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/lockfile-0.9.1/lockfile/sqlitelockfile.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/lockfile-0.9.1/lockfile/sqlitelockfile.py b/tools/bin/pythonSrc/lockfile-0.9.1/lockfile/sqlitelockfile.py
new file mode 100644
index 0000000..d044d2a
--- /dev/null
+++ b/tools/bin/pythonSrc/lockfile-0.9.1/lockfile/sqlitelockfile.py
@@ -0,0 +1,146 @@
+from __future__ import absolute_import, division
+
+import time
+import os
+
+from . import LockBase, NotLocked, NotMyLock, LockTimeout, AlreadyLocked
+
+class SQLiteLockFile(LockBase):
+    "Demonstrate SQL-based locking."
+
+    testdb = None
+
+    def __init__(self, path, threaded=True):
+        """
+        >>> lock = SQLiteLockFile('somefile')
+        >>> lock = SQLiteLockFile('somefile', threaded=False)
+        """
+        LockBase.__init__(self, path, threaded)
+        self.lock_file = unicode(self.lock_file)
+        self.unique_name = unicode(self.unique_name)
+
+        if SQLiteLockFile.testdb is None:
+            import tempfile
+            _fd, testdb = tempfile.mkstemp()
+            os.close(_fd)
+            os.unlink(testdb)
+            del _fd, tempfile
+            SQLiteLockFile.testdb = testdb
+
+        import sqlite3
+        self.connection = sqlite3.connect(SQLiteLockFile.testdb)
+        
+        c = self.connection.cursor()
+        try:
+            c.execute("create table locks"
+                      "("
+                      "   lock_file varchar(32),"
+                      "   unique_name varchar(32)"
+                      ")")
+        except sqlite3.OperationalError:
+            pass
+        else:
+            self.connection.commit()
+            import atexit
+            atexit.register(os.unlink, SQLiteLockFile.testdb)
+
+    def acquire(self, timeout=None):
+        end_time = time.time()
+        if timeout is not None and timeout > 0:
+            end_time += timeout
+
+        if timeout is None:
+            wait = 0.1
+        elif timeout <= 0:
+            wait = 0
+        else:
+            wait = timeout / 10
+
+        cursor = self.connection.cursor()
+
+        while True:
+            if not self.is_locked():
+                # Not locked.  Try to lock it.
+                cursor.execute("insert into locks"
+                               "  (lock_file, unique_name)"
+                               "  values"
+                               "  (?, ?)",
+                               (self.lock_file, self.unique_name))
+                self.connection.commit()
+
+                # Check to see if we are the only lock holder.
+                cursor.execute("select * from locks"
+                               "  where unique_name = ?",
+                               (self.unique_name,))
+                rows = cursor.fetchall()
+                if len(rows) > 1:
+                    # Nope.  Someone else got there.  Remove our lock.
+                    cursor.execute("delete from locks"
+                                   "  where unique_name = ?",
+                                   (self.unique_name,))
+                    self.connection.commit()
+                else:
+                    # Yup.  We're done, so go home.
+                    return
+            else:
+                # Check to see if we are the only lock holder.
+                cursor.execute("select * from locks"
+                               "  where unique_name = ?",
+                               (self.unique_name,))
+                rows = cursor.fetchall()
+                if len(rows) == 1:
+                    # We're the locker, so go home.
+                    return
+                    
+            # Maybe we should wait a bit longer.
+            if timeout is not None and time.time() > end_time:
+                if timeout > 0:
+                    # No more waiting.
+                    raise LockTimeout
+                else:
+                    # Someone else has the lock and we are impatient..
+                    raise AlreadyLocked
+
+            # Well, okay.  We'll give it a bit longer.
+            time.sleep(wait)
+
+    def release(self):
+        if not self.is_locked():
+            raise NotLocked
+        if not self.i_am_locking():
+            raise NotMyLock((self._who_is_locking(), self.unique_name))
+        cursor = self.connection.cursor()
+        cursor.execute("delete from locks"
+                       "  where unique_name = ?",
+                       (self.unique_name,))
+        self.connection.commit()
+
+    def _who_is_locking(self):
+        cursor = self.connection.cursor()
+        cursor.execute("select unique_name from locks"
+                       "  where lock_file = ?",
+                       (self.lock_file,))
+        return cursor.fetchone()[0]
+        
+    def is_locked(self):
+        cursor = self.connection.cursor()
+        cursor.execute("select * from locks"
+                       "  where lock_file = ?",
+                       (self.lock_file,))
+        rows = cursor.fetchall()
+        return not not rows
+
+    def i_am_locking(self):
+        cursor = self.connection.cursor()
+        cursor.execute("select * from locks"
+                       "  where lock_file = ?"
+                       "    and unique_name = ?",
+                       (self.lock_file, self.unique_name))
+        return not not cursor.fetchall()
+
+    def break_lock(self):
+        cursor = self.connection.cursor()
+        cursor.execute("delete from locks"
+                       "  where lock_file = ?",
+                       (self.lock_file,))
+        self.connection.commit()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/lockfile-0.9.1/setup.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/lockfile-0.9.1/setup.py b/tools/bin/pythonSrc/lockfile-0.9.1/setup.py
new file mode 100644
index 0000000..14735b7
--- /dev/null
+++ b/tools/bin/pythonSrc/lockfile-0.9.1/setup.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+
+V = "0.9.1"
+
+from distutils.core import setup
+setup(name='lockfile',
+      author='Skip Montanaro',
+      author_email='skip@pobox.com',
+      url='http://code.google.com/p/pylockfile/',
+      download_url=('http://code.google.com/p/pylockfile/downloads/'
+                    'detail?name=lockfile-%s.tar.gz' % V),
+      version=V,
+      description="Platform-independent file locking module",
+      long_description=open("README").read(),
+      packages=['lockfile'],
+      license='MIT License',
+      classifiers=[
+          'Development Status :: 4 - Beta',
+          'Intended Audience :: Developers',
+          'License :: OSI Approved :: MIT License',
+          'Operating System :: MacOS',
+          'Operating System :: Microsoft :: Windows :: Windows NT/2000',
+          'Operating System :: POSIX',
+          'Programming Language :: Python',
+          'Programming Language :: Python :: 2.4',
+          'Programming Language :: Python :: 2.5',
+          'Programming Language :: Python :: 2.6',
+          'Programming Language :: Python :: 2.7',
+          'Programming Language :: Python :: 3.0',
+          'Topic :: Software Development :: Libraries :: Python Modules',
+          ]
+      )

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/lockfile-0.9.1/test/compliancetest.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/lockfile-0.9.1/test/compliancetest.py b/tools/bin/pythonSrc/lockfile-0.9.1/test/compliancetest.py
new file mode 100644
index 0000000..1cc5c99
--- /dev/null
+++ b/tools/bin/pythonSrc/lockfile-0.9.1/test/compliancetest.py
@@ -0,0 +1,222 @@
+import os
+import threading
+import shutil
+
+import lockfile
+
+class ComplianceTest(object):
+    def __init__(self):
+        self.saved_class = lockfile.LockFile
+
+    def _testfile(self):
+        """Return platform-appropriate file.  Helper for tests."""
+        import tempfile
+        return os.path.join(tempfile.gettempdir(), 'trash-%s' % os.getpid())
+
+    def setup(self):
+        lockfile.LockFile = self.class_to_test
+
+    def teardown(self):
+        try:
+            tf = self._testfile()
+            if os.path.isdir(tf):
+                shutil.rmtree(tf)
+            elif os.path.isfile(tf):
+                os.unlink(tf)
+            elif not os.path.exists(tf):
+                pass
+            else:
+                raise SystemError("unrecognized file: %s" % tf)
+        finally:
+            lockfile.LockFile = self.saved_class
+
+    def _test_acquire_helper(self, tbool):
+        # As simple as it gets.
+        lock = lockfile.LockFile(self._testfile(), threaded=tbool)
+        lock.acquire()
+        assert lock.i_am_locking()
+        lock.release()
+        assert not lock.is_locked()
+
+##    def test_acquire_basic_threaded(self):
+##        self._test_acquire_helper(True)
+
+    def test_acquire_basic_unthreaded(self):
+        self._test_acquire_helper(False)
+
+    def _test_acquire_no_timeout_helper(self, tbool):
+        # No timeout test
+        e1, e2 = threading.Event(), threading.Event()
+        t = _in_thread(self._lock_wait_unlock, e1, e2)
+        e1.wait()         # wait for thread t to acquire lock
+        lock2 = lockfile.LockFile(self._testfile(), threaded=tbool)
+        assert lock2.is_locked()
+        if tbool:
+            assert not lock2.i_am_locking()
+        else:
+            assert lock2.i_am_locking()
+
+        try:
+            lock2.acquire(timeout=-1)
+        except lockfile.AlreadyLocked:
+            pass
+        else:
+            lock2.release()
+            raise AssertionError("did not raise AlreadyLocked in"
+                                 " thread %s" %
+                                 threading.current_thread().get_name())
+
+        e2.set()          # tell thread t to release lock
+        t.join()
+
+##    def test_acquire_no_timeout_threaded(self):
+##        self._test_acquire_no_timeout_helper(True)
+
+##    def test_acquire_no_timeout_unthreaded(self):
+##        self._test_acquire_no_timeout_helper(False)
+
+    def _test_acquire_timeout_helper(self, tbool):
+        # Timeout test
+        e1, e2 = threading.Event(), threading.Event()
+        t = _in_thread(self._lock_wait_unlock, e1, e2)
+        e1.wait()                # wait for thread t to acquire lock
+        lock2 = lockfile.LockFile(self._testfile(), threaded=tbool)
+        assert lock2.is_locked()
+        try:
+            lock2.acquire(timeout=0.1)
+        except lockfile.LockTimeout:
+            pass
+        else:
+            lock2.release()
+            raise AssertionError("did not raise LockTimeout in thread %s" %
+                                 threading.current_thread().get_name())
+
+        e2.set()
+        t.join()
+
+##    def test_acquire_timeout_threaded(self):
+##        self._test_acquire_timeout_helper(True)
+
+    def test_acquire_timeout_unthreaded(self):
+        self._test_acquire_timeout_helper(False)
+
+    def _test_release_basic_helper(self, tbool):
+        lock = lockfile.LockFile(self._testfile(), threaded=tbool)
+        lock.acquire()
+        assert lock.is_locked()
+        lock.release()
+        assert not lock.is_locked()
+        assert not lock.i_am_locking()
+        try:
+            lock.release()
+        except lockfile.NotLocked:
+            pass
+        except lockfile.NotMyLock:
+            raise AssertionError('unexpected exception: %s' %
+                                 lockfile.NotMyLock)
+        else:
+            raise AssertionError('erroneously unlocked file')
+
+##    def test_release_basic_threaded(self):
+##        self._test_release_basic_helper(True)
+
+    def test_release_basic_unthreaded(self):
+        self._test_release_basic_helper(False)
+
+##    def test_release_from_thread(self):
+##        e1, e2 = threading.Event(), threading.Event()
+##        t = _in_thread(self._lock_wait_unlock, e1, e2)
+##        e1.wait()
+##        lock2 = lockfile.LockFile(self._testfile(), threaded=False)
+##        assert not lock2.i_am_locking()
+##        try:
+##            lock2.release()
+##        except lockfile.NotMyLock:
+##            pass
+##        else:
+##            raise AssertionError('erroneously unlocked a file locked'
+##                                 ' by another thread.')
+##        e2.set()
+##        t.join()
+
+    def _test_is_locked_helper(self, tbool):
+        lock = lockfile.LockFile(self._testfile(), threaded=tbool)
+        lock.acquire(timeout=2)
+        assert lock.is_locked()
+        lock.release()
+        assert not lock.is_locked(), "still locked after release!"
+
+##    def test_is_locked_threaded(self):
+##        self._test_is_locked_helper(True)
+
+    def test_is_locked_unthreaded(self):
+        self._test_is_locked_helper(False)
+
+##    def test_i_am_locking_threaded(self):
+##        self._test_i_am_locking_helper(True)
+
+    def test_i_am_locking_unthreaded(self):
+        self._test_i_am_locking_helper(False)
+
+    def _test_i_am_locking_helper(self, tbool):
+        lock1 = lockfile.LockFile(self._testfile(), threaded=tbool)
+        assert not lock1.is_locked()
+        lock1.acquire()
+        try:
+            assert lock1.i_am_locking()
+            lock2 = lockfile.LockFile(self._testfile(), threaded=tbool)
+            assert lock2.is_locked()
+            if tbool:
+                assert not lock2.i_am_locking()
+        finally:
+            lock1.release()
+
+    def _test_break_lock_helper(self, tbool):
+        lock = lockfile.LockFile(self._testfile(), threaded=tbool)
+        lock.acquire()
+        assert lock.is_locked()
+        lock2 = lockfile.LockFile(self._testfile(), threaded=tbool)
+        assert lock2.is_locked()
+        lock2.break_lock()
+        assert not lock2.is_locked()
+        try:
+            lock.release()
+        except lockfile.NotLocked:
+            pass
+        else:
+            raise AssertionError('break lock failed')
+
+##    def test_break_lock_threaded(self):
+##        self._test_break_lock_helper(True)
+
+    def test_break_lock_unthreaded(self):
+        self._test_break_lock_helper(False)
+
+    def _lock_wait_unlock(self, event1, event2):
+        """Lock from another thread.  Helper for tests."""
+        l = lockfile.LockFile(self._testfile())
+        l.acquire()
+        try:
+            event1.set()  # we're in,
+            event2.wait() # wait for boss's permission to leave
+        finally:
+            l.release()
+
+    def test_enter(self):
+        lock = lockfile.LockFile(self._testfile())
+        lock.acquire()
+        try:
+            assert lock.is_locked(), "Not locked after acquire!"
+        finally:
+            lock.release()
+        assert not lock.is_locked(), "still locked after release!"
+
+def _in_thread(func, *args, **kwargs):
+    """Execute func(*args, **kwargs) after dt seconds. Helper for tests."""
+    def _f():
+        func(*args, **kwargs)
+    t = threading.Thread(target=_f, name='/*/*')
+    t.setDaemon(True)
+    t.start()
+    return t
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/lockfile-0.9.1/test/test_lockfile.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/lockfile-0.9.1/test/test_lockfile.py b/tools/bin/pythonSrc/lockfile-0.9.1/test/test_lockfile.py
new file mode 100644
index 0000000..3b70cdd
--- /dev/null
+++ b/tools/bin/pythonSrc/lockfile-0.9.1/test/test_lockfile.py
@@ -0,0 +1,30 @@
+import sys
+
+import lockfile.linklockfile, lockfile.mkdirlockfile, lockfile.pidlockfile
+
+from compliancetest import ComplianceTest
+    
+class TestLinkLockFile(ComplianceTest):
+    class_to_test = lockfile.linklockfile.LinkLockFile
+
+class TestMkdirLockFile(ComplianceTest):
+    class_to_test = lockfile.mkdirlockfile.MkdirLockFile
+
+class TestPIDLockFile(ComplianceTest):
+    class_to_test = lockfile.pidlockfile.PIDLockFile
+
+# Check backwards compatibility
+class TestLinkFileLock(ComplianceTest):
+    class_to_test = lockfile.LinkFileLock
+
+class TestMkdirFileLock(ComplianceTest):
+    class_to_test = lockfile.MkdirFileLock
+
+try:
+    import sqlite3
+except ImportError:
+    pass
+else:
+    import lockfile.sqlitelockfile
+    class TestSQLiteLockFile(ComplianceTest):
+        class_to_test = lockfile.sqlitelockfile.SQLiteLockFile

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/COPYRIGHT
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/COPYRIGHT b/tools/bin/pythonSrc/pychecker-0.8.18/COPYRIGHT
new file mode 100644
index 0000000..59e9b2f
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/COPYRIGHT
@@ -0,0 +1,31 @@
+Copyright (c) 2000-2001, MetaSlash Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the
+   distribution.
+
+ - Neither name of MetaSlash Inc. nor the names of contributors
+   may be used to endorse or promote products derived
+   from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/ChangeLog
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/ChangeLog b/tools/bin/pythonSrc/pychecker-0.8.18/ChangeLog
new file mode 100644
index 0000000..8284bfa
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/ChangeLog
@@ -0,0 +1,349 @@
+2008-07-29  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+	* test/common.py:
+	* test/test_module.py:
+	* test/test_stdlib.py:
+	  Switch to mixedCase as Neil prefers.
+
+2008-07-14  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+	* pychecker/checker.py:
+	  Don't pollute sys.path by inserting every moduleDir into it.
+	  This allows projects to have for example a gtk.py file in a
+	  package that does not conflict with the gtk system library.
+	  Instead, pollute it right before loading the module, then clean up
+	  immediately after.
+
+2008-07-14  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+	* setup.py:
+	  If installing to a staging root, don't include this path in the
+	  install_lib dir.
+	* setup.cfg:
+	  Set optimize = 1 to make rpm not complain about installed but
+	  missing .pyo files.
+	  Fixes python setup.py bdist_rpm
+
+2008-07-14  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+	* pychecker/checker.py:
+	  Make sure args passed for checking now create PyCheckerModule
+	  instances with moduleDir set properly.  This triggers the new
+	  code behaviour where modules are stored as a moduleName, moduleDir
+	  tuple in pcmodules.py, making sure same-named modules get treated
+	  separately.
+	  New test suite now passes again.
+	  Fixes #1563572.
+
+2008-07-14  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+	* test/input/getmodule/A/C.py:
+	* test/input/getmodule/A/__init__.py:
+	* test/input/getmodule/B/C.py:
+	* test/input/getmodule/B/__init__.py:
+	* test/input/getmodule/__init__.py:
+	* test/input/test_getmodule.py:
+	* test/test_module.py:
+	* test/main.py:
+	  Add a test that shows how warnings in modules with the same name,
+	  but different directories, shadow each other. See
+	  http://sourceforge.net/tracker/index.php?func=detail&aid=1563572&group_id=24686&atid=382217
+
+2008-07-14  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+	* test/common.py:
+	  add check_multiple test method that allows checking more than one
+	  argument.
+	* test/expected/test_zope_interface:
+	  update expected string
+
+2008-07-14  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+	* pychecker/pcmodules.py:
+	  New module; replaces checker._allModules
+	  Allows us to track and differentiate between modules with the same
+	  name but from different paths.
+	* pychecker/checker.py:
+	  Use it instead of _allModules
+	* pychecker/warn.py:
+	  Also use it in the code that checks if a base class's __init__ was
+	  called, instead of only checking sys.modules, which only works
+	  if we pollute sys.modules (which is what we're trying to fix)
+
+2008-07-13  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+	* pychecker/checker.py:
+	  Instantiate Class with the PycheckerModule instance instead of the
+	  real module; this allows us to see and act on presence of moduleDir.
+
+2008-07-13  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+	* pychecker/checker.py:
+	  Change _findModule to take an optional moduleDir keyword argument.
+	  Use it in setupMainCode
+	  Make sibling imports work by temporarily putting moduleDir on
+	  sys.path
+
+2008-07-13  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+	* pychecker/checker.py:
+	  Add self.moduleDir to filename() for PyCheckerModule.
+
+2008-07-13  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+	* pychecker/checker.py:
+	  Refactor code such that we can pass a moduleDir keyword argument to
+	  PyCheckerModule.  This will allow us to discern between modules
+	  with the same name, but in a different directory.
+	  Change allModules to be a dict of (moduleName, moduleDir) -> module
+	  No behaviour change yet.
+
+2008-07-13  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+	* pychecker/checker.py:
+	  When showing what we're processing, show module name and file name.
+	* test_expected/test1:
+	* test_expected/test1-2.3:
+	* test_expected/test1-2.4:
+	* test_expected/test1-2.5:
+	* test_expected/test10:
+	* test_expected/test100:
+	* test_expected/test101:
+	* test_expected/test11:
+	* test_expected/test12:
+	* test_expected/test13:
+	* test_expected/test14:
+	* test_expected/test15:
+	* test_expected/test16:
+	* test_expected/test17:
+	* test_expected/test17-2.4:
+	* test_expected/test18:
+	* test_expected/test19:
+	* test_expected/test2:
+	* test_expected/test20:
+	* test_expected/test20-2.4:
+	* test_expected/test20-2.5:
+	* test_expected/test21:
+	* test_expected/test22:
+	* test_expected/test23:
+	* test_expected/test24:
+	* test_expected/test25:
+	* test_expected/test26:
+	* test_expected/test27:
+	* test_expected/test27-2.2:
+	* test_expected/test27-2.3:
+	* test_expected/test27-2.4:
+	* test_expected/test27-2.5:
+	* test_expected/test28:
+	* test_expected/test29:
+	* test_expected/test3:
+	* test_expected/test3-2.2:
+	* test_expected/test3-2.3:
+	* test_expected/test3-2.4:
+	* test_expected/test3-2.5:
+	* test_expected/test30:
+	* test_expected/test31:
+	* test_expected/test32:
+	* test_expected/test33:
+	* test_expected/test34:
+	* test_expected/test34-2.2:
+	* test_expected/test34-2.3:
+	* test_expected/test34-2.4:
+	* test_expected/test34-2.5:
+	* test_expected/test35:
+	* test_expected/test36:
+	* test_expected/test37:
+	* test_expected/test38:
+	* test_expected/test39:
+	* test_expected/test39-2.2:
+	* test_expected/test39-2.3:
+	* test_expected/test39-2.4:
+	* test_expected/test39-2.5:
+	* test_expected/test4:
+	* test_expected/test40:
+	* test_expected/test41:
+	* test_expected/test42:
+	* test_expected/test43:
+	* test_expected/test44:
+	* test_expected/test45:
+	* test_expected/test46:
+	* test_expected/test47:
+	* test_expected/test48:
+	* test_expected/test49:
+	* test_expected/test5:
+	* test_expected/test50:
+	* test_expected/test51:
+	* test_expected/test52:
+	* test_expected/test53:
+	* test_expected/test54:
+	* test_expected/test55:
+	* test_expected/test56:
+	* test_expected/test57:
+	* test_expected/test58:
+	* test_expected/test58-2.2:
+	* test_expected/test58-2.3:
+	* test_expected/test58-2.4:
+	* test_expected/test58-2.5:
+	* test_expected/test59:
+	* test_expected/test6:
+	* test_expected/test60:
+	* test_expected/test61:
+	* test_expected/test62:
+	* test_expected/test63:
+	* test_expected/test64:
+	* test_expected/test65:
+	* test_expected/test66:
+	* test_expected/test67:
+	* test_expected/test68:
+	* test_expected/test68-2.4:
+	* test_expected/test68-2.5:
+	* test_expected/test69:
+	* test_expected/test7:
+	* test_expected/test70:
+	* test_expected/test71:
+	* test_expected/test71-2.4:
+	* test_expected/test71-2.5:
+	* test_expected/test72:
+	* test_expected/test73:
+	* test_expected/test74:
+	* test_expected/test74-2.4:
+	* test_expected/test74-2.5:
+	* test_expected/test75:
+	* test_expected/test75-2.2:
+	* test_expected/test75-2.3:
+	* test_expected/test75-2.4:
+	* test_expected/test75-2.5:
+	* test_expected/test76:
+	* test_expected/test77:
+	* test_expected/test78:
+	* test_expected/test79:
+	* test_expected/test8:
+	* test_expected/test80:
+	* test_expected/test80-2.2:
+	* test_expected/test80-2.3:
+	* test_expected/test80-2.4:
+	* test_expected/test80-2.5:
+	* test_expected/test81:
+	* test_expected/test82:
+	* test_expected/test83:
+	* test_expected/test84:
+	* test_expected/test85:
+	* test_expected/test86:
+	* test_expected/test87:
+	* test_expected/test88:
+	* test_expected/test88-2.4:
+	* test_expected/test89:
+	* test_expected/test89-2.2:
+	* test_expected/test89-2.3:
+	* test_expected/test89-2.4:
+	* test_expected/test89-2.5:
+	* test_expected/test9:
+	* test_expected/test90:
+	* test_expected/test92:
+	* test_expected/test93:
+	* test_expected/test94:
+	* test_expected/test95:
+	* test_expected/test96:
+	* test_expected/test97:
+	* test_expected/test98:
+	* test_expected/test99:
+	  Fix all expected test output for this change, without any
+	  regressions.
+
+2008-07-13  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+	* pychecker/checker.py:
+	  Document and change getModules such that, for each argument
+	  that is a file, it returns a moduleName, moduleDir tuple
+	  so that modules with the same name can still be treated separately.
+	  Change callers to follow.
+	  First step towards fixing the bug where modules with the same name
+	  shadow each other's pychecker warnings.
+
+2008-07-13  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+	* test/common.py:
+	  Document method.
+
+2008-07-12  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+	* pychecker/warn.py:
+	  Change getStandardLibrary to getStandardLibraries (a list),
+	  so we can handle both the arch-invariant and arch-specific python
+	  site-packages.
+	  This makes sure that -q/--stdlib works the same way on 32-bit and
+	  64-bit systems.
+	  Fixes #1564614, and makes the new test suite pass.
+	  (Try it with python test/main.py)
+
+2008-07-12  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+	* test/test_stdlib.py:
+	  Rename and document test.
+
+2008-07-12  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+	* test/common.py:
+	* test/expected/test_zope_interface:
+	* test/input/test_zope_interface.py:
+	* test/main.py:
+	* test/test_stdlib.py:
+	  Add a first stab at a unittest-based testsuite.
+	  Add a test for bug #382217 that I wanted to fix that can't
+	  be tested in the current test suite.
+
+2008-07-04  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+	* test_input/test86.py:
+	  Add a test for except KeyboardInterrupt, which was fixed by Neil
+	  in pychecker/CodeChecks.py: 1.170 on 23-Apr-07.
+
+2008-07-02  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+	* pychecker/CodeChecks.py:
+	  Allow using setattr with a static argument inside lambda calls,
+	  where the alternative is a syntax error since you're not allowed to
+	  do an assignment expression.
+	  Fixes #1565876.
+
+2008-07-01  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+	* pychecker/checker.py:
+	  Revert IDLE patch which breaks test42.py
+	  See #2007203.
+
+2008-07-01  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+	* pychecker/checker.py:
+	* pychecker/warn.py:
+	  Respect the blacklist of modules when warning about classes for
+	  which the module cannot be found.
+	* test_check.sh:
+	* test_expected/test101:
+	* test_input/test101.py:
+	  Add a test for it.
+	  Fixes #1563495.
+
+2008-07-01  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+	* test_expected/test100:
+	* test_input/test100.py:
+	  Actually add the tests.
+
+2008-06-30  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+	* pychecker/checker.py:
+	  If an object looks like a class object because it has __bases__
+	  but it does not have __names__, make up a name.
+	  Fixes #1563494.
+	* test_check.sh:
+	  Add a test that previously failed.
+
+2008-06-30  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+	* MANIFEST.in:
+	* CHANGELOG:
+	* NEWS:
+	  Moved CHANGELOG to NEWS since it really contains release news.
+	  Created real ChangeLog.
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/KNOWN_BUGS
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/KNOWN_BUGS b/tools/bin/pythonSrc/pychecker-0.8.18/KNOWN_BUGS
new file mode 100644
index 0000000..36f05d3
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/KNOWN_BUGS
@@ -0,0 +1,100 @@
+
+Crash when running on code that does:
+
+	from wxPython.wx import *
+
+The problem is in wxGTK-2.2.6 and earlier versions.
+
+Below is a patch to wxGTK 2.2.6 that fixes the problem.
+
+This problem has been reported:  
+http://sourceforge.net/tracker/?func=detail&atid=109863&aid=417923&group_id=9863
+
+-----------
+
+*** src/gtk/app.cpp.orig	Sat Apr 21 17:12:35 2001
+--- src/gtk/app.cpp	Sat Apr 21 17:14:46 2001
+***************
+*** 582,597 ****
+--- 582,600 ----
+  
+      // GL: I'm annoyed ... I don't know where to put this and I don't want to
+      // create a module for that as it's part of the core.
+  #if wxUSE_THREADS
+      delete wxPendingEvents;
++     wxPendingEvents = 0;
+      delete wxPendingEventsLocker;
++     wxPendingEventsLocker = 0;
+  #endif
+  
+      wxSystemSettings::Done();
+  
+      delete[] wxBuffer;
++     wxBuffer = 0;
+  
+      wxClassInfo::CleanUpClasses();
+  
+      // check for memory leaks
+  #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
+*** src/common/resource.cpp.orig	Sat Apr 21 17:10:23 2001
+--- src/common/resource.cpp	Sat Apr 21 17:06:42 2001
+***************
+*** 110,121 ****
+--- 110,125 ----
+  }
+  
+  void wxCleanUpResourceSystem()
+  {
+      delete wxDefaultResourceTable;
++     wxDefaultResourceTable = 0;
+      if (wxResourceBuffer)
++     {
+          delete[] wxResourceBuffer;
++         wxResourceBuffer = 0;
++     }
+  }
+  
+  void wxLogWarning(char *msg)
+  {
+      wxMessageBox(msg, _("Warning"), wxOK);
+
+---------------------------------------------------------------------
+
+exec statements are not checked.  Therefore, variables and modules used in 
+exec statements may cause spurious warnings.  To avoid the warnings,
+consider rewriting your code to use eval() or getattr().
+
+For example, consider rewriting this code:
+
+	exec 'var = object.' + member
+	print var
+
+to:
+
+	var = eval('object.' + member)
+	print var
+
+or:
+
+	var = getattr(object, member)
+	print var
+
+---------------------------------------------------------------------
+
+The following code generates a spurious warning:
+
+	from XXX import *
+
+	class SameName:
+	    def __init__(self): pass
+
+And in the file XXX:
+
+	class SameName:
+	    def __init__(self, c): pass
+
+	class Anyname:
+	    def __init__(self):
+	        self.xxx = SameName(1)
+
+---------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/MAINTAINERS
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/MAINTAINERS b/tools/bin/pythonSrc/pychecker-0.8.18/MAINTAINERS
new file mode 100644
index 0000000..61b901d
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/MAINTAINERS
@@ -0,0 +1,81 @@
+
+Neal Norwitz            nnorwitz@gmail.com
+Eric C. Newton          ecn@metaslash.com
+
+
+Other Contributors:
+
+Barry Scott             barry@scottb.demon.co.uk
+                                Fix Base class not init spurious warning
+                                Other misc suggestions and fixes
+
+Shakeeb Alireza                 bug reports
+Andy Anderson                   many bug reports and fixes
+Erwin S. Andreasen              bug reports
+Anthony Baxter                  bug reports
+Alexander Belchenko             bug reports and fixes
+Jeff Bellegarde                 bug reports and fixes
+Andrew Bennetts                 suggestion: check for modifying def arg values
+Riaan Booysen                   bug reports, suggestions, etc.
+John Bowe                       bug reports, suggestions, etc.
+Mike Brown                      bug report
+Gary Capell                     bug reports and refactoring suggestions
+Loris Caren                     testing, etc.
+Charles Cazabon                 bug report
+Nicolas Chauvat                 setup.py
+Allan Crooks                    bug reports
+Jeff Collins                    checker.findModule
+Tom Culliton                    bug reports and suggestions
+Andr\ufffd Dahlqvist                 bug reports
+Walter Doerwald                 bug reports and fixes
+Mika Eloranta                   bug reports
+Jeff Epler                      bug reports
+Mark Favas                      bug reports
+Erik Max Francis                bug reports and suggestions
+Dan Fandrich                    bug reports
+Alexandre Fayolle               bug reports
+Jeremy Fincher                  bug reports
+Horst Gassner                   bug reports and suggestions
+Stuart D. Gathman               bug reports and suggestions
+Geoff Gerrietts                 bug reports
+Johannes Gijsbers               bug reports
+Hartmut Goebel                  patches
+Joel Gould                      bug reports
+greep                           bug reports
+John-Mark Gurney                bug reports
+Thomas Heller                   bug reports and suggestions
+Raymond Hettinger               suggestions
+Tim Hochberg                    bug reports
+Eric Huss                       bug reports
+Ben Hutchings                   bug reports
+Jeremy Hylton                   bug reports and suggestions
+Garth T Kidd                    bug reports and suggestions
+Bastian Kleineidam              patches
+Brad Knotwell                   bug reports
+John Machin                     bug reports
+Jonathan Mark                   bug reports and suggestions
+Evelyn Mitchell                 bug reports
+Skip Montanaro                  bug reports and suggestions
+Michele Moore                   many suggestions
+Jon Nelson                      fix setup.py, add MANIFEST.in
+Jason Orendorff                 suggestions
+Ian Parker                      suggestions
+Fernando P\ufffdrez                  bug reports
+Kenneth Pronovici               debian maintainer, bug reports, patches, setup.py
+Eric S. Raymond                 bug reports and suggestions
+Terry Reedy                     suggestions
+Jon Ribbens                     bugs, bugs, bugs
+Guido van Rossum                bug reports and suggestions
+Jim Rutledge                    bug reports and suggestions
+Rich Salz                       bug reports and suggestions
+John Shue                       patches, etc.
+Stephan A. Terre                bug reports
+Lucio Torre                     suggestions
+Miloslav Trmac                  bug reports and patches
+Sheng-Te Tsao                   bug reports and suggestions
+Kevin Turner                    bug report
+Joe VanAndel                    bug reports
+Greg Ward                       bug reports, patches, etc
+Barry Warsaw                    bug reports
+Matt Wilson                     bug reports and fixes
+Andy Wingo                      bug reports and fixes

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/MANIFEST.in
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/MANIFEST.in b/tools/bin/pythonSrc/pychecker-0.8.18/MANIFEST.in
new file mode 100644
index 0000000..f4c77a2
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/MANIFEST.in
@@ -0,0 +1,2 @@
+include COPYRIGHT VERSION ChangeLog KNOWN_BUGS MAINTAINERS NEWS TODO 
+include README pycheckrc 


[02/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code

Posted by rl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_discovery.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_discovery.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_discovery.py
new file mode 100644
index 0000000..f78c4d8
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_discovery.py
@@ -0,0 +1,371 @@
+import os
+import re
+import sys
+
+import unittest2
+
+
+class TestDiscovery(unittest2.TestCase):
+
+    # Heavily mocked tests so I can avoid hitting the filesystem
+    def test_get_name_from_path(self):
+        loader = unittest2.TestLoader()
+
+        loader._top_level_dir = '/foo'
+        name = loader._get_name_from_path('/foo/bar/baz.py')
+        self.assertEqual(name, 'bar.baz')
+
+        if not __debug__:
+            # asserts are off
+            return
+
+        self.assertRaises(AssertionError,
+                          loader._get_name_from_path,
+                          '/bar/baz.py')
+
+    def test_find_tests(self):
+        loader = unittest2.TestLoader()
+
+        original_listdir = os.listdir
+        def restore_listdir():
+            os.listdir = original_listdir
+        original_isfile = os.path.isfile
+        def restore_isfile():
+            os.path.isfile = original_isfile
+        original_isdir = os.path.isdir
+        def restore_isdir():
+            os.path.isdir = original_isdir
+
+        path_lists = [['test1.py', 'test2.py', 'not_a_test.py', 'test_dir',
+                       'test.foo', 'test-not-a-module.py', 'another_dir'],
+                      ['test3.py', 'test4.py', ]]
+        os.listdir = lambda path: path_lists.pop(0)
+        self.addCleanup(restore_listdir)
+
+        def isdir(path):
+            return path.endswith('dir')
+        os.path.isdir = isdir
+        self.addCleanup(restore_isdir)
+
+        def isfile(path):
+            # another_dir is not a package and so shouldn't be recursed into
+            return not path.endswith('dir') and not 'another_dir' in path
+        os.path.isfile = isfile
+        self.addCleanup(restore_isfile)
+
+        loader._get_module_from_name = lambda path: path + ' module'
+        loader.loadTestsFromModule = lambda module: module + ' tests'
+
+        top_level = os.path.abspath('/foo')
+        loader._top_level_dir = top_level
+        suite = list(loader._find_tests(top_level, 'test*.py'))
+
+        expected = [name + ' module tests' for name in
+                    ('test1', 'test2')]
+        expected.extend([('test_dir.%s' % name) + ' module tests' for name in
+                    ('test3', 'test4')])
+        self.assertEqual(suite, expected)
+
+    def test_find_tests_with_package(self):
+        loader = unittest2.TestLoader()
+
+        original_listdir = os.listdir
+        def restore_listdir():
+            os.listdir = original_listdir
+        original_isfile = os.path.isfile
+        def restore_isfile():
+            os.path.isfile = original_isfile
+        original_isdir = os.path.isdir
+        def restore_isdir():
+            os.path.isdir = original_isdir
+
+        directories = ['a_directory', 'test_directory', 'test_directory2']
+        path_lists = [directories, [], [], []]
+        os.listdir = lambda path: path_lists.pop(0)
+        self.addCleanup(restore_listdir)
+
+        os.path.isdir = lambda path: True
+        self.addCleanup(restore_isdir)
+
+        os.path.isfile = lambda path: os.path.basename(path) not in directories
+        self.addCleanup(restore_isfile)
+
+        class Module(object):
+            paths = []
+            load_tests_args = []
+
+            def __init__(self, path):
+                self.path = path
+                self.paths.append(path)
+                if os.path.basename(path) == 'test_directory':
+                    def load_tests(loader, tests, pattern):
+                        self.load_tests_args.append((loader, tests, pattern))
+                        return 'load_tests'
+                    self.load_tests = load_tests
+
+            def __eq__(self, other):
+                return self.path == other.path
+
+            # Silence py3k warning
+            __hash__ = None
+
+        loader._get_module_from_name = lambda name: Module(name)
+        def loadTestsFromModule(module, use_load_tests):
+            if use_load_tests:
+                raise self.failureException('use_load_tests should be False for packages')
+            return module.path + ' module tests'
+        loader.loadTestsFromModule = loadTestsFromModule
+
+        loader._top_level_dir = '/foo'
+        # this time no '.py' on the pattern so that it can match
+        # a test package
+        suite = list(loader._find_tests('/foo', 'test*'))
+
+        # We should have loaded tests from the test_directory package by calling load_tests
+        # and directly from the test_directory2 package
+        self.assertEqual(suite,
+                         ['load_tests', 'test_directory2' + ' module tests'])
+        self.assertEqual(Module.paths, ['test_directory', 'test_directory2'])
+
+        # load_tests should have been called once with loader, tests and pattern
+        self.assertEqual(Module.load_tests_args,
+                         [(loader, 'test_directory' + ' module tests', 'test*')])
+
+    def test_discover(self):
+        loader = unittest2.TestLoader()
+
+        original_isfile = os.path.isfile
+        original_isdir = os.path.isdir
+        def restore_isfile():
+            os.path.isfile = original_isfile
+
+        os.path.isfile = lambda path: False
+        self.addCleanup(restore_isfile)
+
+        orig_sys_path = sys.path[:]
+        def restore_path():
+            sys.path[:] = orig_sys_path
+        self.addCleanup(restore_path)
+
+        full_path = os.path.abspath(os.path.normpath('/foo'))
+        self.assertRaises(ImportError,
+                          loader.discover,
+                          '/foo/bar', top_level_dir='/foo')
+
+        self.assertEqual(loader._top_level_dir, full_path)
+        self.assertIn(full_path, sys.path)
+
+        os.path.isfile = lambda path: True
+        os.path.isdir = lambda path: True
+
+        def restore_isdir():
+            os.path.isdir = original_isdir
+        self.addCleanup(restore_isdir)
+
+        _find_tests_args = []
+        def _find_tests(start_dir, pattern):
+            _find_tests_args.append((start_dir, pattern))
+            return ['tests']
+        loader._find_tests = _find_tests
+        loader.suiteClass = str
+
+        suite = loader.discover('/foo/bar/baz', 'pattern', '/foo/bar')
+
+        top_level_dir = os.path.abspath(os.path.normpath('/foo/bar'))
+        start_dir = os.path.abspath(os.path.normpath('/foo/bar/baz'))
+        self.assertEqual(suite, "['tests']")
+        self.assertEqual(loader._top_level_dir, top_level_dir)
+        self.assertEqual(_find_tests_args, [(start_dir, 'pattern')])
+        self.assertIn(top_level_dir, sys.path)
+
+    def test_discover_with_modules_that_fail_to_import(self):
+        loader = unittest2.TestLoader()
+
+        listdir = os.listdir
+        os.listdir = lambda _: ['test_this_does_not_exist.py']
+        isfile = os.path.isfile
+        os.path.isfile = lambda _: True
+        orig_sys_path = sys.path[:]
+        def restore():
+            os.path.isfile = isfile
+            os.listdir = listdir
+            sys.path[:] = orig_sys_path
+        self.addCleanup(restore)
+
+        suite = loader.discover('.')
+        self.assertIn(os.getcwd(), sys.path)
+        self.assertEqual(suite.countTestCases(), 1)
+        test = list(list(suite)[0])[0] # extract test from suite
+
+        self.assertRaises(ImportError,
+            lambda: test.test_this_does_not_exist())
+
+    def test_command_line_handling_parseArgs(self):
+        # Haha - take that uninstantiable class
+        program = object.__new__(unittest2.TestProgram)
+
+        args = []
+        def do_discovery(argv):
+            args.extend(argv)
+        program._do_discovery = do_discovery
+        program.parseArgs(['something', 'discover'])
+        self.assertEqual(args, [])
+
+        program.parseArgs(['something', 'discover', 'foo', 'bar'])
+        self.assertEqual(args, ['foo', 'bar'])
+
+    def test_command_line_handling_do_discovery_too_many_arguments(self):
+        class Stop(Exception):
+            pass
+        def usageExit():
+            raise Stop
+
+        program = object.__new__(unittest2.TestProgram)
+        program.usageExit = usageExit
+
+        self.assertRaises(Stop,
+            # too many args
+            lambda: program._do_discovery(['one', 'two', 'three', 'four']))
+
+
+    def test_command_line_handling_do_discovery_calls_loader(self):
+        program = object.__new__(unittest2.TestProgram)
+
+        class Loader(object):
+            args = []
+            def discover(self, start_dir, pattern, top_level_dir):
+                self.args.append((start_dir, pattern, top_level_dir))
+                return 'tests'
+
+        program._do_discovery(['-v'], Loader=Loader)
+        self.assertEqual(program.verbosity, 2)
+        self.assertEqual(program.test, 'tests')
+        self.assertEqual(Loader.args, [('.', 'test*.py', None)])
+
+        Loader.args = []
+        program = object.__new__(unittest2.TestProgram)
+        program._do_discovery(['--verbose'], Loader=Loader)
+        self.assertEqual(program.test, 'tests')
+        self.assertEqual(Loader.args, [('.', 'test*.py', None)])
+
+        Loader.args = []
+        program = object.__new__(unittest2.TestProgram)
+        program._do_discovery([], Loader=Loader)
+        self.assertEqual(program.test, 'tests')
+        self.assertEqual(Loader.args, [('.', 'test*.py', None)])
+
+        Loader.args = []
+        program = object.__new__(unittest2.TestProgram)
+        program._do_discovery(['fish'], Loader=Loader)
+        self.assertEqual(program.test, 'tests')
+        self.assertEqual(Loader.args, [('fish', 'test*.py', None)])
+
+        Loader.args = []
+        program = object.__new__(unittest2.TestProgram)
+        program._do_discovery(['fish', 'eggs'], Loader=Loader)
+        self.assertEqual(program.test, 'tests')
+        self.assertEqual(Loader.args, [('fish', 'eggs', None)])
+
+        Loader.args = []
+        program = object.__new__(unittest2.TestProgram)
+        program._do_discovery(['fish', 'eggs', 'ham'], Loader=Loader)
+        self.assertEqual(program.test, 'tests')
+        self.assertEqual(Loader.args, [('fish', 'eggs', 'ham')])
+
+        Loader.args = []
+        program = object.__new__(unittest2.TestProgram)
+        program._do_discovery(['-s', 'fish'], Loader=Loader)
+        self.assertEqual(program.test, 'tests')
+        self.assertEqual(Loader.args, [('fish', 'test*.py', None)])
+
+        Loader.args = []
+        program = object.__new__(unittest2.TestProgram)
+        program._do_discovery(['-t', 'fish'], Loader=Loader)
+        self.assertEqual(program.test, 'tests')
+        self.assertEqual(Loader.args, [('.', 'test*.py', 'fish')])
+
+        Loader.args = []
+        program = object.__new__(unittest2.TestProgram)
+        program._do_discovery(['-p', 'fish'], Loader=Loader)
+        self.assertEqual(program.test, 'tests')
+        self.assertEqual(Loader.args, [('.', 'fish', None)])
+        self.assertFalse(program.failfast)
+        self.assertFalse(program.catchbreak)
+
+        args = ['-p', 'eggs', '-s', 'fish', '-v', '-f']
+        try:
+            import signal
+        except ImportError:
+            signal = None
+        else:
+            args.append('-c')
+        Loader.args = []
+        program = object.__new__(unittest2.TestProgram)
+        program._do_discovery(args, Loader=Loader)
+        self.assertEqual(program.test, 'tests')
+        self.assertEqual(Loader.args, [('fish', 'eggs', None)])
+        self.assertEqual(program.verbosity, 2)
+        self.assertTrue(program.failfast)
+        if signal is not None:
+            self.assertTrue(program.catchbreak)
+
+    def test_detect_module_clash(self):
+        class Module(object):
+            __file__ = 'bar/foo.py'
+        sys.modules['foo'] = Module
+        full_path = os.path.abspath('foo')
+        original_listdir = os.listdir
+        original_isfile = os.path.isfile
+        original_isdir = os.path.isdir
+        
+        def cleanup():
+            os.listdir = original_listdir
+            os.path.isfile = original_isfile
+            os.path.isdir = original_isdir
+            del sys.modules['foo']
+            if full_path in sys.path:
+                sys.path.remove(full_path)
+        self.addCleanup(cleanup)
+        
+        def listdir(_):
+            return ['foo.py']
+        def isfile(_):
+            return True
+        def isdir(_):
+            return True
+        os.listdir = listdir
+        os.path.isfile = isfile
+        os.path.isdir = isdir
+        
+        loader = unittest2.TestLoader()
+        
+        mod_dir = os.path.abspath('bar')
+        expected_dir = os.path.abspath('foo')
+        msg = re.escape(r"'foo' module incorrectly imported from %r. Expected %r. "
+                "Is this module globally installed?" % (mod_dir, expected_dir))
+        self.assertRaisesRegexp(
+            ImportError, '^%s$' % msg, loader.discover,
+            start_dir='foo', pattern='foo.py'
+        )
+        self.assertEqual(sys.path[0], full_path)
+
+        
+    def test_discovery_from_dotted_path(self):
+        loader = unittest2.TestLoader()
+        
+        tests = [self]
+        expectedPath = os.path.abspath(os.path.dirname(unittest2.test.__file__))
+
+        self.wasRun = False
+        def _find_tests(start_dir, pattern):
+            self.wasRun = True
+            self.assertEqual(start_dir, expectedPath)
+            return tests
+        loader._find_tests = _find_tests
+        suite = loader.discover('unittest2.test')
+        self.assertTrue(self.wasRun)
+        self.assertEqual(suite._tests, tests)
+
+
+if __name__ == '__main__':
+    unittest2.main()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_functiontestcase.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_functiontestcase.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_functiontestcase.py
new file mode 100644
index 0000000..295aec3
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_functiontestcase.py
@@ -0,0 +1,149 @@
+import unittest2
+
+from unittest2.test.support import LoggingResult
+
+
+class Test_FunctionTestCase(unittest2.TestCase):
+
+    # "Return the number of tests represented by the this test object. For
+    # unittest2.TestCase instances, this will always be 1"
+    def test_countTestCases(self):
+        test = unittest2.FunctionTestCase(lambda: None)
+
+        self.assertEqual(test.countTestCases(), 1)
+
+    # "When a setUp() method is defined, the test runner will run that method
+    # prior to each test. Likewise, if a tearDown() method is defined, the
+    # test runner will invoke that method after each test. In the example,
+    # setUp() was used to create a fresh sequence for each test."
+    #
+    # Make sure the proper call order is maintained, even if setUp() raises
+    # an exception.
+    def test_run_call_order__error_in_setUp(self):
+        events = []
+        result = LoggingResult(events)
+
+        def setUp():
+            events.append('setUp')
+            raise RuntimeError('raised by setUp')
+
+        def test():
+            events.append('test')
+
+        def tearDown():
+            events.append('tearDown')
+
+        expected = ['startTest', 'setUp', 'addError', 'stopTest']
+        unittest2.FunctionTestCase(test, setUp, tearDown).run(result)
+        self.assertEqual(events, expected)
+
+    # "When a setUp() method is defined, the test runner will run that method
+    # prior to each test. Likewise, if a tearDown() method is defined, the
+    # test runner will invoke that method after each test. In the example,
+    # setUp() was used to create a fresh sequence for each test."
+    #
+    # Make sure the proper call order is maintained, even if the test raises
+    # an error (as opposed to a failure).
+    def test_run_call_order__error_in_test(self):
+        events = []
+        result = LoggingResult(events)
+
+        def setUp():
+            events.append('setUp')
+
+        def test():
+            events.append('test')
+            raise RuntimeError('raised by test')
+
+        def tearDown():
+            events.append('tearDown')
+
+        expected = ['startTest', 'setUp', 'test', 'addError', 'tearDown',
+                    'stopTest']
+        unittest2.FunctionTestCase(test, setUp, tearDown).run(result)
+        self.assertEqual(events, expected)
+
+    # "When a setUp() method is defined, the test runner will run that method
+    # prior to each test. Likewise, if a tearDown() method is defined, the
+    # test runner will invoke that method after each test. In the example,
+    # setUp() was used to create a fresh sequence for each test."
+    #
+    # Make sure the proper call order is maintained, even if the test signals
+    # a failure (as opposed to an error).
+    def test_run_call_order__failure_in_test(self):
+        events = []
+        result = LoggingResult(events)
+
+        def setUp():
+            events.append('setUp')
+
+        def test():
+            events.append('test')
+            self.fail('raised by test')
+
+        def tearDown():
+            events.append('tearDown')
+
+        expected = ['startTest', 'setUp', 'test', 'addFailure', 'tearDown',
+                    'stopTest']
+        unittest2.FunctionTestCase(test, setUp, tearDown).run(result)
+        self.assertEqual(events, expected)
+
+    # "When a setUp() method is defined, the test runner will run that method
+    # prior to each test. Likewise, if a tearDown() method is defined, the
+    # test runner will invoke that method after each test. In the example,
+    # setUp() was used to create a fresh sequence for each test."
+    #
+    # Make sure the proper call order is maintained, even if tearDown() raises
+    # an exception.
+    def test_run_call_order__error_in_tearDown(self):
+        events = []
+        result = LoggingResult(events)
+
+        def setUp():
+            events.append('setUp')
+
+        def test():
+            events.append('test')
+
+        def tearDown():
+            events.append('tearDown')
+            raise RuntimeError('raised by tearDown')
+
+        expected = ['startTest', 'setUp', 'test', 'tearDown', 'addError',
+                    'stopTest']
+        unittest2.FunctionTestCase(test, setUp, tearDown).run(result)
+        self.assertEqual(events, expected)
+
+    # "Return a string identifying the specific test case."
+    #
+    # Because of the vague nature of the docs, I'm not going to lock this
+    # test down too much. Really all that can be asserted is that the id()
+    # will be a string (either 8-byte or unicode -- again, because the docs
+    # just say "string")
+    def test_id(self):
+        test = unittest2.FunctionTestCase(lambda: None)
+
+        self.assertIsInstance(test.id(), basestring)
+
+    # "Returns a one-line description of the test, or None if no description
+    # has been provided. The default implementation of this method returns
+    # the first line of the test method's docstring, if available, or None."
+    def test_shortDescription__no_docstring(self):
+        test = unittest2.FunctionTestCase(lambda: None)
+
+        self.assertEqual(test.shortDescription(), None)
+
+    # "Returns a one-line description of the test, or None if no description
+    # has been provided. The default implementation of this method returns
+    # the first line of the test method's docstring, if available, or None."
+    def test_shortDescription__singleline_docstring(self):
+        desc = "this tests foo"
+        test = unittest2.FunctionTestCase(lambda: None, description=desc)
+
+        self.assertEqual(test.shortDescription(), "this tests foo")
+
+
+
+if __name__ == '__main__':
+    unittest2.main()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_loader.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_loader.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_loader.py
new file mode 100644
index 0000000..7ff63be
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_loader.py
@@ -0,0 +1,1286 @@
+import sys
+import types
+
+import unittest2
+
+
+class Test_TestLoader(unittest2.TestCase):
+
+    ### Tests for TestLoader.loadTestsFromTestCase
+    ################################################################
+
+    # "Return a suite of all tests cases contained in the TestCase-derived
+    # class testCaseClass"
+    def test_loadTestsFromTestCase(self):
+        class Foo(unittest2.TestCase):
+            def test_1(self): pass
+            def test_2(self): pass
+            def foo_bar(self): pass
+
+        tests = unittest2.TestSuite([Foo('test_1'), Foo('test_2')])
+
+        loader = unittest2.TestLoader()
+        self.assertEqual(loader.loadTestsFromTestCase(Foo), tests)
+
+    # "Return a suite of all tests cases contained in the TestCase-derived
+    # class testCaseClass"
+    #
+    # Make sure it does the right thing even if no tests were found
+    def test_loadTestsFromTestCase__no_matches(self):
+        class Foo(unittest2.TestCase):
+            def foo_bar(self): pass
+
+        empty_suite = unittest2.TestSuite()
+
+        loader = unittest2.TestLoader()
+        self.assertEqual(loader.loadTestsFromTestCase(Foo), empty_suite)
+
+    # "Return a suite of all tests cases contained in the TestCase-derived
+    # class testCaseClass"
+    #
+    # What happens if loadTestsFromTestCase() is given an object
+    # that isn't a subclass of TestCase? Specifically, what happens
+    # if testCaseClass is a subclass of TestSuite?
+    #
+    # This is checked for specifically in the code, so we better add a
+    # test for it.
+    def test_loadTestsFromTestCase__TestSuite_subclass(self):
+        class NotATestCase(unittest2.TestSuite):
+            pass
+
+        loader = unittest2.TestLoader()
+        try:
+            loader.loadTestsFromTestCase(NotATestCase)
+        except TypeError:
+            pass
+        else:
+            self.fail('Should raise TypeError')
+
+    # "Return a suite of all tests cases contained in the TestCase-derived
+    # class testCaseClass"
+    #
+    # Make sure loadTestsFromTestCase() picks up the default test method
+    # name (as specified by TestCase), even though the method name does
+    # not match the default TestLoader.testMethodPrefix string
+    def test_loadTestsFromTestCase__default_method_name(self):
+        class Foo(unittest2.TestCase):
+            def runTest(self):
+                pass
+
+        loader = unittest2.TestLoader()
+        # This has to be false for the test to succeed
+        self.assertFalse('runTest'.startswith(loader.testMethodPrefix))
+
+        suite = loader.loadTestsFromTestCase(Foo)
+        self.assertIsInstance(suite, loader.suiteClass)
+        self.assertEqual(list(suite), [Foo('runTest')])
+
+    ################################################################
+    ### /Tests for TestLoader.loadTestsFromTestCase
+
+    ### Tests for TestLoader.loadTestsFromModule
+    ################################################################
+
+    # "This method searches `module` for classes derived from TestCase"
+    def test_loadTestsFromModule__TestCase_subclass(self):
+        m = types.ModuleType('m')
+        class MyTestCase(unittest2.TestCase):
+            def test(self):
+                pass
+        m.testcase_1 = MyTestCase
+
+        loader = unittest2.TestLoader()
+        suite = loader.loadTestsFromModule(m)
+        self.assertIsInstance(suite, loader.suiteClass)
+
+        expected = [loader.suiteClass([MyTestCase('test')])]
+        self.assertEqual(list(suite), expected)
+
+    # "This method searches `module` for classes derived from TestCase"
+    #
+    # What happens if no tests are found (no TestCase instances)?
+    def test_loadTestsFromModule__no_TestCase_instances(self):
+        m = types.ModuleType('m')
+
+        loader = unittest2.TestLoader()
+        suite = loader.loadTestsFromModule(m)
+        self.assertIsInstance(suite, loader.suiteClass)
+        self.assertEqual(list(suite), [])
+
+    # "This method searches `module` for classes derived from TestCase"
+    #
+    # What happens if no tests are found (TestCases instances, but no tests)?
+    def test_loadTestsFromModule__no_TestCase_tests(self):
+        m = types.ModuleType('m')
+        class MyTestCase(unittest2.TestCase):
+            pass
+        m.testcase_1 = MyTestCase
+
+        loader = unittest2.TestLoader()
+        suite = loader.loadTestsFromModule(m)
+        self.assertIsInstance(suite, loader.suiteClass)
+
+        self.assertEqual(list(suite), [loader.suiteClass()])
+
+    # "This method searches `module` for classes derived from TestCase"s
+    #
+    # What happens if loadTestsFromModule() is given something other
+    # than a module?
+    #
+    # XXX Currently, it succeeds anyway. This flexibility
+    # should either be documented or loadTestsFromModule() should
+    # raise a TypeError
+    #
+    # XXX Certain people are using this behaviour. We'll add a test for it
+    def test_loadTestsFromModule__not_a_module(self):
+        class MyTestCase(unittest2.TestCase):
+            def test(self):
+                pass
+
+        class NotAModule(object):
+            test_2 = MyTestCase
+
+        loader = unittest2.TestLoader()
+        suite = loader.loadTestsFromModule(NotAModule)
+
+        reference = [unittest2.TestSuite([MyTestCase('test')])]
+        self.assertEqual(list(suite), reference)
+
+
+    # Check that loadTestsFromModule honors (or not) a module
+    # with a load_tests function.
+    def test_loadTestsFromModule__load_tests(self):
+        m = types.ModuleType('m')
+        class MyTestCase(unittest2.TestCase):
+            def test(self):
+                pass
+        m.testcase_1 = MyTestCase
+
+        load_tests_args = []
+        def load_tests(loader, tests, pattern):
+            self.assertIsInstance(tests, unittest2.TestSuite)
+            load_tests_args.extend((loader, tests, pattern))
+            return tests
+        m.load_tests = load_tests
+
+        loader = unittest2.TestLoader()
+        suite = loader.loadTestsFromModule(m)
+        self.assertIsInstance(suite, unittest2.TestSuite)
+        self.assertEquals(load_tests_args, [loader, suite, None])
+
+        load_tests_args = []
+        suite = loader.loadTestsFromModule(m, use_load_tests=False)
+        self.assertEquals(load_tests_args, [])
+
+    def test_loadTestsFromModule__faulty_load_tests(self):
+        m = types.ModuleType('m')
+
+        def load_tests(loader, tests, pattern):
+            raise TypeError('some failure')
+        m.load_tests = load_tests
+
+        loader = unittest2.TestLoader()
+        suite = loader.loadTestsFromModule(m)
+        self.assertIsInstance(suite, unittest2.TestSuite)
+        self.assertEqual(suite.countTestCases(), 1)
+        test = list(suite)[0]
+        
+        self.assertRaisesRegexp(TypeError, "some failure", test.m)
+        
+
+    ################################################################
+    ### /Tests for TestLoader.loadTestsFromModule()
+
+    ### Tests for TestLoader.loadTestsFromName()
+    ################################################################
+
+    # "The specifier name is a ``dotted name'' that may resolve either to
+    # a module, a test case class, a TestSuite instance, a test method
+    # within a test case class, or a callable object which returns a
+    # TestCase or TestSuite instance."
+    #
+    # Is ValueError raised in response to an empty name?
+    def test_loadTestsFromName__empty_name(self):
+        loader = unittest2.TestLoader()
+
+        try:
+            loader.loadTestsFromName('')
+        except ValueError, e:
+            self.assertEqual(str(e), "Empty module name")
+        else:
+            self.fail("TestLoader.loadTestsFromName failed to raise ValueError")
+
+    # "The specifier name is a ``dotted name'' that may resolve either to
+    # a module, a test case class, a TestSuite instance, a test method
+    # within a test case class, or a callable object which returns a
+    # TestCase or TestSuite instance."
+    #
+    # What happens when the name contains invalid characters?
+    def test_loadTestsFromName__malformed_name(self):
+        loader = unittest2.TestLoader()
+
+        # XXX Should this raise ValueError or ImportError?
+        try:
+            loader.loadTestsFromName('abc () //')
+        except ValueError:
+            pass
+        except ImportError:
+            pass
+        else:
+            self.fail("TestLoader.loadTestsFromName failed to raise ValueError")
+
+    # "The specifier name is a ``dotted name'' that may resolve ... to a
+    # module"
+    #
+    # What happens when a module by that name can't be found?
+    def test_loadTestsFromName__unknown_module_name(self):
+        loader = unittest2.TestLoader()
+
+        try:
+            loader.loadTestsFromName('sdasfasfasdf')
+        except ImportError, e:
+            self.assertEqual(str(e), "No module named sdasfasfasdf")
+        else:
+            self.fail("TestLoader.loadTestsFromName failed to raise ImportError")
+
+    # "The specifier name is a ``dotted name'' that may resolve either to
+    # a module, a test case class, a TestSuite instance, a test method
+    # within a test case class, or a callable object which returns a
+    # TestCase or TestSuite instance."
+    #
+    # What happens when the module is found, but the attribute can't?
+    def test_loadTestsFromName__unknown_attr_name(self):
+        loader = unittest2.TestLoader()
+
+        try:
+            loader.loadTestsFromName('unittest2.sdasfasfasdf')
+        except AttributeError, e:
+            self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'")
+        else:
+            self.fail("TestLoader.loadTestsFromName failed to raise AttributeError")
+
+    # "The specifier name is a ``dotted name'' that may resolve either to
+    # a module, a test case class, a TestSuite instance, a test method
+    # within a test case class, or a callable object which returns a
+    # TestCase or TestSuite instance."
+    #
+    # What happens when we provide the module, but the attribute can't be
+    # found?
+    def test_loadTestsFromName__relative_unknown_name(self):
+        loader = unittest2.TestLoader()
+
+        try:
+            loader.loadTestsFromName('sdasfasfasdf', unittest2)
+        except AttributeError, e:
+            self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'")
+        else:
+            self.fail("TestLoader.loadTestsFromName failed to raise AttributeError")
+
+    # "The specifier name is a ``dotted name'' that may resolve either to
+    # a module, a test case class, a TestSuite instance, a test method
+    # within a test case class, or a callable object which returns a
+    # TestCase or TestSuite instance."
+    # ...
+    # "The method optionally resolves name relative to the given module"
+    #
+    # Does loadTestsFromName raise ValueError when passed an empty
+    # name relative to a provided module?
+    #
+    # XXX Should probably raise a ValueError instead of an AttributeError
+    def test_loadTestsFromName__relative_empty_name(self):
+        loader = unittest2.TestLoader()
+
+        try:
+            loader.loadTestsFromName('', unittest2)
+        except AttributeError:
+            pass
+        else:
+            self.fail("Failed to raise AttributeError")
+
+    # "The specifier name is a ``dotted name'' that may resolve either to
+    # a module, a test case class, a TestSuite instance, a test method
+    # within a test case class, or a callable object which returns a
+    # TestCase or TestSuite instance."
+    # ...
+    # "The method optionally resolves name relative to the given module"
+    #
+    # What happens when an impossible name is given, relative to the provided
+    # `module`?
+    def test_loadTestsFromName__relative_malformed_name(self):
+        loader = unittest2.TestLoader()
+
+        # XXX Should this raise AttributeError or ValueError?
+        try:
+            loader.loadTestsFromName('abc () //', unittest2)
+        except ValueError:
+            pass
+        except AttributeError:
+            pass
+        else:
+            self.fail("TestLoader.loadTestsFromName failed to raise ValueError")
+
+    # "The method optionally resolves name relative to the given module"
+    #
+    # Does loadTestsFromName raise TypeError when the `module` argument
+    # isn't a module object?
+    #
+    # XXX Accepts the not-a-module object, ignorning the object's type
+    # This should raise an exception or the method name should be changed
+    #
+    # XXX Some people are relying on this, so keep it for now
+    def test_loadTestsFromName__relative_not_a_module(self):
+        class MyTestCase(unittest2.TestCase):
+            def test(self):
+                pass
+
+        class NotAModule(object):
+            test_2 = MyTestCase
+
+        loader = unittest2.TestLoader()
+        suite = loader.loadTestsFromName('test_2', NotAModule)
+
+        reference = [MyTestCase('test')]
+        self.assertEqual(list(suite), reference)
+
+    # "The specifier name is a ``dotted name'' that may resolve either to
+    # a module, a test case class, a TestSuite instance, a test method
+    # within a test case class, or a callable object which returns a
+    # TestCase or TestSuite instance."
+    #
+    # Does it raise an exception if the name resolves to an invalid
+    # object?
+    def test_loadTestsFromName__relative_bad_object(self):
+        m = types.ModuleType('m')
+        m.testcase_1 = object()
+
+        loader = unittest2.TestLoader()
+        try:
+            loader.loadTestsFromName('testcase_1', m)
+        except TypeError:
+            pass
+        else:
+            self.fail("Should have raised TypeError")
+
+    # "The specifier name is a ``dotted name'' that may
+    # resolve either to ... a test case class"
+    def test_loadTestsFromName__relative_TestCase_subclass(self):
+        m = types.ModuleType('m')
+        class MyTestCase(unittest2.TestCase):
+            def test(self):
+                pass
+        m.testcase_1 = MyTestCase
+
+        loader = unittest2.TestLoader()
+        suite = loader.loadTestsFromName('testcase_1', m)
+        self.assertIsInstance(suite, loader.suiteClass)
+        self.assertEqual(list(suite), [MyTestCase('test')])
+
+    # "The specifier name is a ``dotted name'' that may resolve either to
+    # a module, a test case class, a TestSuite instance, a test method
+    # within a test case class, or a callable object which returns a
+    # TestCase or TestSuite instance."
+    def test_loadTestsFromName__relative_TestSuite(self):
+        m = types.ModuleType('m')
+        class MyTestCase(unittest2.TestCase):
+            def test(self):
+                pass
+        m.testsuite = unittest2.TestSuite([MyTestCase('test')])
+
+        loader = unittest2.TestLoader()
+        suite = loader.loadTestsFromName('testsuite', m)
+        self.assertIsInstance(suite, loader.suiteClass)
+
+        self.assertEqual(list(suite), [MyTestCase('test')])
+
+    # "The specifier name is a ``dotted name'' that may resolve ... to
+    # ... a test method within a test case class"
+    def test_loadTestsFromName__relative_testmethod(self):
+        m = types.ModuleType('m')
+        class MyTestCase(unittest2.TestCase):
+            def test(self):
+                pass
+        m.testcase_1 = MyTestCase
+
+        loader = unittest2.TestLoader()
+        suite = loader.loadTestsFromName('testcase_1.test', m)
+        self.assertIsInstance(suite, loader.suiteClass)
+
+        self.assertEqual(list(suite), [MyTestCase('test')])
+
+    # "The specifier name is a ``dotted name'' that may resolve either to
+    # a module, a test case class, a TestSuite instance, a test method
+    # within a test case class, or a callable object which returns a
+    # TestCase or TestSuite instance."
+    #
+    # Does loadTestsFromName() raise the proper exception when trying to
+    # resolve "a test method within a test case class" that doesn't exist
+    # for the given name (relative to a provided module)?
+    def test_loadTestsFromName__relative_invalid_testmethod(self):
+        m = types.ModuleType('m')
+        class MyTestCase(unittest2.TestCase):
+            def test(self):
+                pass
+        m.testcase_1 = MyTestCase
+
+        loader = unittest2.TestLoader()
+        try:
+            loader.loadTestsFromName('testcase_1.testfoo', m)
+        except AttributeError, e:
+            self.assertEqual(str(e), "type object 'MyTestCase' has no attribute 'testfoo'")
+        else:
+            self.fail("Failed to raise AttributeError")
+
+    # "The specifier name is a ``dotted name'' that may resolve ... to
+    # ... a callable object which returns a ... TestSuite instance"
+    def test_loadTestsFromName__callable__TestSuite(self):
+        m = types.ModuleType('m')
+        testcase_1 = unittest2.FunctionTestCase(lambda: None)
+        testcase_2 = unittest2.FunctionTestCase(lambda: None)
+        def return_TestSuite():
+            return unittest2.TestSuite([testcase_1, testcase_2])
+        m.return_TestSuite = return_TestSuite
+
+        loader = unittest2.TestLoader()
+        suite = loader.loadTestsFromName('return_TestSuite', m)
+        self.assertIsInstance(suite, loader.suiteClass)
+        self.assertEqual(list(suite), [testcase_1, testcase_2])
+
+    # "The specifier name is a ``dotted name'' that may resolve ... to
+    # ... a callable object which returns a TestCase ... instance"
+    def test_loadTestsFromName__callable__TestCase_instance(self):
+        m = types.ModuleType('m')
+        testcase_1 = unittest2.FunctionTestCase(lambda: None)
+        def return_TestCase():
+            return testcase_1
+        m.return_TestCase = return_TestCase
+
+        loader = unittest2.TestLoader()
+        suite = loader.loadTestsFromName('return_TestCase', m)
+        self.assertIsInstance(suite, loader.suiteClass)
+        self.assertEqual(list(suite), [testcase_1])
+
+    # "The specifier name is a ``dotted name'' that may resolve ... to
+    # ... a callable object which returns a TestCase ... instance"
+    #*****************************************************************
+    #Override the suiteClass attribute to ensure that the suiteClass
+    #attribute is used
+    def test_loadTestsFromName__callable__TestCase_instance_ProperSuiteClass(self):
+        class SubTestSuite(unittest2.TestSuite):
+            pass
+        m = types.ModuleType('m')
+        testcase_1 = unittest2.FunctionTestCase(lambda: None)
+        def return_TestCase():
+            return testcase_1
+        m.return_TestCase = return_TestCase
+
+        loader = unittest2.TestLoader()
+        loader.suiteClass = SubTestSuite
+        suite = loader.loadTestsFromName('return_TestCase', m)
+        self.assertIsInstance(suite, loader.suiteClass)
+        self.assertEqual(list(suite), [testcase_1])
+
+    # "The specifier name is a ``dotted name'' that may resolve ... to
+    # ... a test method within a test case class"
+    #*****************************************************************
+    #Override the suiteClass attribute to ensure that the suiteClass
+    #attribute is used
+    def test_loadTestsFromName__relative_testmethod_ProperSuiteClass(self):
+        class SubTestSuite(unittest2.TestSuite):
+            pass
+        m = types.ModuleType('m')
+        class MyTestCase(unittest2.TestCase):
+            def test(self):
+                pass
+        m.testcase_1 = MyTestCase
+
+        loader = unittest2.TestLoader()
+        loader.suiteClass=SubTestSuite
+        suite = loader.loadTestsFromName('testcase_1.test', m)
+        self.assertIsInstance(suite, loader.suiteClass)
+
+        self.assertEqual(list(suite), [MyTestCase('test')])
+
+    # "The specifier name is a ``dotted name'' that may resolve ... to
+    # ... a callable object which returns a TestCase or TestSuite instance"
+    #
+    # What happens if the callable returns something else?
+    def test_loadTestsFromName__callable__wrong_type(self):
+        m = types.ModuleType('m')
+        def return_wrong():
+            return 6
+        m.return_wrong = return_wrong
+
+        loader = unittest2.TestLoader()
+        try:
+            loader.loadTestsFromName('return_wrong', m)
+        except TypeError:
+            pass
+        else:
+            self.fail("TestLoader.loadTestsFromName failed to raise TypeError")
+
+    # "The specifier can refer to modules and packages which have not been
+    # imported; they will be imported as a side-effect"
+    def test_loadTestsFromName__module_not_loaded(self):
+        # We're going to try to load this module as a side-effect, so it
+        # better not be loaded before we try.
+        #
+        module_name = 'unittest2.test.dummy'
+        sys.modules.pop(module_name, None)
+
+        loader = unittest2.TestLoader()
+        try:
+            suite = loader.loadTestsFromName(module_name)
+
+            self.assertIsInstance(suite, loader.suiteClass)
+            self.assertEqual(list(suite), [])
+
+            # module should now be loaded, thanks to loadTestsFromName()
+            self.assertIn(module_name, sys.modules)
+        finally:
+            if module_name in sys.modules:
+                del sys.modules[module_name]
+
+    ################################################################
+    ### Tests for TestLoader.loadTestsFromName()
+
+    ### Tests for TestLoader.loadTestsFromNames()
+    ################################################################
+
+    # "Similar to loadTestsFromName(), but takes a sequence of names rather
+    # than a single name."
+    #
+    # What happens if that sequence of names is empty?
+    def test_loadTestsFromNames__empty_name_list(self):
+        loader = unittest2.TestLoader()
+
+        suite = loader.loadTestsFromNames([])
+        self.assertIsInstance(suite, loader.suiteClass)
+        self.assertEqual(list(suite), [])
+
+    # "Similar to loadTestsFromName(), but takes a sequence of names rather
+    # than a single name."
+    # ...
+    # "The method optionally resolves name relative to the given module"
+    #
+    # What happens if that sequence of names is empty?
+    #
+    # XXX Should this raise a ValueError or just return an empty TestSuite?
+    def test_loadTestsFromNames__relative_empty_name_list(self):
+        loader = unittest2.TestLoader()
+
+        suite = loader.loadTestsFromNames([], unittest2)
+        self.assertIsInstance(suite, loader.suiteClass)
+        self.assertEqual(list(suite), [])
+
+    # "The specifier name is a ``dotted name'' that may resolve either to
+    # a module, a test case class, a TestSuite instance, a test method
+    # within a test case class, or a callable object which returns a
+    # TestCase or TestSuite instance."
+    #
+    # Is ValueError raised in response to an empty name?
+    def test_loadTestsFromNames__empty_name(self):
+        loader = unittest2.TestLoader()
+
+        try:
+            loader.loadTestsFromNames([''])
+        except ValueError, e:
+            self.assertEqual(str(e), "Empty module name")
+        else:
+            self.fail("TestLoader.loadTestsFromNames failed to raise ValueError")
+
+    # "The specifier name is a ``dotted name'' that may resolve either to
+    # a module, a test case class, a TestSuite instance, a test method
+    # within a test case class, or a callable object which returns a
+    # TestCase or TestSuite instance."
+    #
+    # What happens when presented with an impossible module name?
+    def test_loadTestsFromNames__malformed_name(self):
+        loader = unittest2.TestLoader()
+
+        # XXX Should this raise ValueError or ImportError?
+        try:
+            loader.loadTestsFromNames(['abc () //'])
+        except ValueError:
+            pass
+        except ImportError:
+            pass
+        else:
+            self.fail("TestLoader.loadTestsFromNames failed to raise ValueError")
+
+    # "The specifier name is a ``dotted name'' that may resolve either to
+    # a module, a test case class, a TestSuite instance, a test method
+    # within a test case class, or a callable object which returns a
+    # TestCase or TestSuite instance."
+    #
+    # What happens when no module can be found for the given name?
+    def test_loadTestsFromNames__unknown_module_name(self):
+        loader = unittest2.TestLoader()
+
+        try:
+            loader.loadTestsFromNames(['sdasfasfasdf'])
+        except ImportError, e:
+            self.assertEqual(str(e), "No module named sdasfasfasdf")
+        else:
+            self.fail("TestLoader.loadTestsFromNames failed to raise ImportError")
+
+    # "The specifier name is a ``dotted name'' that may resolve either to
+    # a module, a test case class, a TestSuite instance, a test method
+    # within a test case class, or a callable object which returns a
+    # TestCase or TestSuite instance."
+    #
+    # What happens when the module can be found, but not the attribute?
+    def test_loadTestsFromNames__unknown_attr_name(self):
+        loader = unittest2.TestLoader()
+
+        try:
+            loader.loadTestsFromNames(['unittest2.sdasfasfasdf', 'unittest2'])
+        except AttributeError, e:
+            self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'")
+        else:
+            self.fail("TestLoader.loadTestsFromNames failed to raise AttributeError")
+
+    # "The specifier name is a ``dotted name'' that may resolve either to
+    # a module, a test case class, a TestSuite instance, a test method
+    # within a test case class, or a callable object which returns a
+    # TestCase or TestSuite instance."
+    # ...
+    # "The method optionally resolves name relative to the given module"
+    #
+    # What happens when given an unknown attribute on a specified `module`
+    # argument?
+    def test_loadTestsFromNames__unknown_name_relative_1(self):
+        loader = unittest2.TestLoader()
+
+        try:
+            loader.loadTestsFromNames(['sdasfasfasdf'], unittest2)
+        except AttributeError, e:
+            self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'")
+        else:
+            self.fail("TestLoader.loadTestsFromName failed to raise AttributeError")
+
+    # "The specifier name is a ``dotted name'' that may resolve either to
+    # a module, a test case class, a TestSuite instance, a test method
+    # within a test case class, or a callable object which returns a
+    # TestCase or TestSuite instance."
+    # ...
+    # "The method optionally resolves name relative to the given module"
+    #
+    # Do unknown attributes (relative to a provided module) still raise an
+    # exception even in the presence of valid attribute names?
+    def test_loadTestsFromNames__unknown_name_relative_2(self):
+        loader = unittest2.TestLoader()
+
+        try:
+            loader.loadTestsFromNames(['TestCase', 'sdasfasfasdf'], unittest2)
+        except AttributeError, e:
+            self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'")
+        else:
+            self.fail("TestLoader.loadTestsFromName failed to raise AttributeError")
+
+    # "The specifier name is a ``dotted name'' that may resolve either to
+    # a module, a test case class, a TestSuite instance, a test method
+    # within a test case class, or a callable object which returns a
+    # TestCase or TestSuite instance."
+    # ...
+    # "The method optionally resolves name relative to the given module"
+    #
+    # What happens when faced with the empty string?
+    #
+    # XXX This currently raises AttributeError, though ValueError is probably
+    # more appropriate
+    def test_loadTestsFromNames__relative_empty_name(self):
+        loader = unittest2.TestLoader()
+
+        try:
+            loader.loadTestsFromNames([''], unittest2)
+        except AttributeError:
+            pass
+        else:
+            self.fail("Failed to raise ValueError")
+
+    # "The specifier name is a ``dotted name'' that may resolve either to
+    # a module, a test case class, a TestSuite instance, a test method
+    # within a test case class, or a callable object which returns a
+    # TestCase or TestSuite instance."
+    # ...
+    # "The method optionally resolves name relative to the given module"
+    #
+    # What happens when presented with an impossible attribute name?
+    def test_loadTestsFromNames__relative_malformed_name(self):
+        loader = unittest2.TestLoader()
+
+        # XXX Should this raise AttributeError or ValueError?
+        try:
+            loader.loadTestsFromNames(['abc () //'], unittest2)
+        except AttributeError:
+            pass
+        except ValueError:
+            pass
+        else:
+            self.fail("TestLoader.loadTestsFromNames failed to raise ValueError")
+
+    # "The method optionally resolves name relative to the given module"
+    #
+    # Does loadTestsFromNames() make sure the provided `module` is in fact
+    # a module?
+    #
+    # XXX This validation is currently not done. This flexibility should
+    # either be documented or a TypeError should be raised.
+    def test_loadTestsFromNames__relative_not_a_module(self):
+        class MyTestCase(unittest2.TestCase):
+            def test(self):
+                pass
+
+        class NotAModule(object):
+            test_2 = MyTestCase
+
+        loader = unittest2.TestLoader()
+        suite = loader.loadTestsFromNames(['test_2'], NotAModule)
+
+        reference = [unittest2.TestSuite([MyTestCase('test')])]
+        self.assertEqual(list(suite), reference)
+
+    # "The specifier name is a ``dotted name'' that may resolve either to
+    # a module, a test case class, a TestSuite instance, a test method
+    # within a test case class, or a callable object which returns a
+    # TestCase or TestSuite instance."
+    #
+    # Does it raise an exception if the name resolves to an invalid
+    # object?
+    def test_loadTestsFromNames__relative_bad_object(self):
+        m = types.ModuleType('m')
+        m.testcase_1 = object()
+
+        loader = unittest2.TestLoader()
+        try:
+            loader.loadTestsFromNames(['testcase_1'], m)
+        except TypeError:
+            pass
+        else:
+            self.fail("Should have raised TypeError")
+
+    # "The specifier name is a ``dotted name'' that may resolve ... to
+    # ... a test case class"
+    def test_loadTestsFromNames__relative_TestCase_subclass(self):
+        m = types.ModuleType('m')
+        class MyTestCase(unittest2.TestCase):
+            def test(self):
+                pass
+        m.testcase_1 = MyTestCase
+
+        loader = unittest2.TestLoader()
+        suite = loader.loadTestsFromNames(['testcase_1'], m)
+        self.assertIsInstance(suite, loader.suiteClass)
+
+        expected = loader.suiteClass([MyTestCase('test')])
+        self.assertEqual(list(suite), [expected])
+
+    # "The specifier name is a ``dotted name'' that may resolve ... to
+    # ... a TestSuite instance"
+    def test_loadTestsFromNames__relative_TestSuite(self):
+        m = types.ModuleType('m')
+        class MyTestCase(unittest2.TestCase):
+            def test(self):
+                pass
+        m.testsuite = unittest2.TestSuite([MyTestCase('test')])
+
+        loader = unittest2.TestLoader()
+        suite = loader.loadTestsFromNames(['testsuite'], m)
+        self.assertIsInstance(suite, loader.suiteClass)
+
+        self.assertEqual(list(suite), [m.testsuite])
+
+    # "The specifier name is a ``dotted name'' that may resolve ... to ... a
+    # test method within a test case class"
+    def test_loadTestsFromNames__relative_testmethod(self):
+        m = types.ModuleType('m')
+        class MyTestCase(unittest2.TestCase):
+            def test(self):
+                pass
+        m.testcase_1 = MyTestCase
+
+        loader = unittest2.TestLoader()
+        suite = loader.loadTestsFromNames(['testcase_1.test'], m)
+        self.assertIsInstance(suite, loader.suiteClass)
+
+        ref_suite = unittest2.TestSuite([MyTestCase('test')])
+        self.assertEqual(list(suite), [ref_suite])
+
+    # "The specifier name is a ``dotted name'' that may resolve ... to ... a
+    # test method within a test case class"
+    #
+    # Does the method gracefully handle names that initially look like they
+    # resolve to "a test method within a test case class" but don't?
+    def test_loadTestsFromNames__relative_invalid_testmethod(self):
+        m = types.ModuleType('m')
+        class MyTestCase(unittest2.TestCase):
+            def test(self):
+                pass
+        m.testcase_1 = MyTestCase
+
+        loader = unittest2.TestLoader()
+        try:
+            loader.loadTestsFromNames(['testcase_1.testfoo'], m)
+        except AttributeError, e:
+            self.assertEqual(str(e), "type object 'MyTestCase' has no attribute 'testfoo'")
+        else:
+            self.fail("Failed to raise AttributeError")
+
+    # "The specifier name is a ``dotted name'' that may resolve ... to
+    # ... a callable object which returns a ... TestSuite instance"
+    def test_loadTestsFromNames__callable__TestSuite(self):
+        m = types.ModuleType('m')
+        testcase_1 = unittest2.FunctionTestCase(lambda: None)
+        testcase_2 = unittest2.FunctionTestCase(lambda: None)
+        def return_TestSuite():
+            return unittest2.TestSuite([testcase_1, testcase_2])
+        m.return_TestSuite = return_TestSuite
+
+        loader = unittest2.TestLoader()
+        suite = loader.loadTestsFromNames(['return_TestSuite'], m)
+        self.assertIsInstance(suite, loader.suiteClass)
+
+        expected = unittest2.TestSuite([testcase_1, testcase_2])
+        self.assertEqual(list(suite), [expected])
+
+    # "The specifier name is a ``dotted name'' that may resolve ... to
+    # ... a callable object which returns a TestCase ... instance"
+    def test_loadTestsFromNames__callable__TestCase_instance(self):
+        m = types.ModuleType('m')
+        testcase_1 = unittest2.FunctionTestCase(lambda: None)
+        def return_TestCase():
+            return testcase_1
+        m.return_TestCase = return_TestCase
+
+        loader = unittest2.TestLoader()
+        suite = loader.loadTestsFromNames(['return_TestCase'], m)
+        self.assertIsInstance(suite, loader.suiteClass)
+
+        ref_suite = unittest2.TestSuite([testcase_1])
+        self.assertEqual(list(suite), [ref_suite])
+
+    # "The specifier name is a ``dotted name'' that may resolve ... to
+    # ... a callable object which returns a TestCase or TestSuite instance"
+    #
+    # Are staticmethods handled correctly?
+    def test_loadTestsFromNames__callable__call_staticmethod(self):
+        m = types.ModuleType('m')
+        class Test1(unittest2.TestCase):
+            def test(self):
+                pass
+
+        testcase_1 = Test1('test')
+        class Foo(unittest2.TestCase):
+            @staticmethod
+            def foo():
+                return testcase_1
+        m.Foo = Foo
+
+        loader = unittest2.TestLoader()
+        suite = loader.loadTestsFromNames(['Foo.foo'], m)
+        self.assertIsInstance(suite, loader.suiteClass)
+
+        ref_suite = unittest2.TestSuite([testcase_1])
+        self.assertEqual(list(suite), [ref_suite])
+
+    # "The specifier name is a ``dotted name'' that may resolve ... to
+    # ... a callable object which returns a TestCase or TestSuite instance"
+    #
+    # What happens when the callable returns something else?
+    def test_loadTestsFromNames__callable__wrong_type(self):
+        m = types.ModuleType('m')
+        def return_wrong():
+            return 6
+        m.return_wrong = return_wrong
+
+        loader = unittest2.TestLoader()
+        try:
+            loader.loadTestsFromNames(['return_wrong'], m)
+        except TypeError:
+            pass
+        else:
+            self.fail("TestLoader.loadTestsFromNames failed to raise TypeError")
+
+    # "The specifier can refer to modules and packages which have not been
+    # imported; they will be imported as a side-effect"
+    def test_loadTestsFromNames__module_not_loaded(self):
+        # We're going to try to load this module as a side-effect, so it
+        # better not be loaded before we try.
+        #
+        module_name = 'unittest2.test.dummy'
+        sys.modules.pop(module_name, None)
+
+        loader = unittest2.TestLoader()
+        try:
+            suite = loader.loadTestsFromNames([module_name])
+
+            self.assertIsInstance(suite, loader.suiteClass)
+            self.assertEqual(list(suite), [unittest2.TestSuite()])
+
+            # module should now be loaded, thanks to loadTestsFromName()
+            self.assertIn(module_name, sys.modules)
+        finally:
+            if module_name in sys.modules:
+                del sys.modules[module_name]
+
+    ################################################################
+    ### /Tests for TestLoader.loadTestsFromNames()
+
+    ### Tests for TestLoader.getTestCaseNames()
+    ################################################################
+
+    # "Return a sorted sequence of method names found within testCaseClass"
+    #
+    # Test.foobar is defined to make sure getTestCaseNames() respects
+    # loader.testMethodPrefix
+    def test_getTestCaseNames(self):
+        class Test(unittest2.TestCase):
+            def test_1(self): pass
+            def test_2(self): pass
+            def foobar(self): pass
+
+        loader = unittest2.TestLoader()
+
+        self.assertEqual(loader.getTestCaseNames(Test), ['test_1', 'test_2'])
+
+    # "Return a sorted sequence of method names found within testCaseClass"
+    #
+    # Does getTestCaseNames() behave appropriately if no tests are found?
+    def test_getTestCaseNames__no_tests(self):
+        class Test(unittest2.TestCase):
+            def foobar(self): pass
+
+        loader = unittest2.TestLoader()
+
+        self.assertEqual(loader.getTestCaseNames(Test), [])
+
+    # "Return a sorted sequence of method names found within testCaseClass"
+    #
+    # Are not-TestCases handled gracefully?
+    #
+    # XXX This should raise a TypeError, not return a list
+    #
+    # XXX It's too late in the 2.5 release cycle to fix this, but it should
+    # probably be revisited for 2.6
+    def test_getTestCaseNames__not_a_TestCase(self):
+        class BadCase(int):
+            def test_foo(self):
+                pass
+
+        loader = unittest2.TestLoader()
+        names = loader.getTestCaseNames(BadCase)
+
+        self.assertEqual(names, ['test_foo'])
+
+    # "Return a sorted sequence of method names found within testCaseClass"
+    #
+    # Make sure inherited names are handled.
+    #
+    # TestP.foobar is defined to make sure getTestCaseNames() respects
+    # loader.testMethodPrefix
+    def test_getTestCaseNames__inheritance(self):
+        class TestP(unittest2.TestCase):
+            def test_1(self): pass
+            def test_2(self): pass
+            def foobar(self): pass
+
+        class TestC(TestP):
+            def test_1(self): pass
+            def test_3(self): pass
+
+        loader = unittest2.TestLoader()
+
+        names = ['test_1', 'test_2', 'test_3']
+        self.assertEqual(loader.getTestCaseNames(TestC), names)
+
+    ################################################################
+    ### /Tests for TestLoader.getTestCaseNames()
+
+    ### Tests for TestLoader.testMethodPrefix
+    ################################################################
+
+    # "String giving the prefix of method names which will be interpreted as
+    # test methods"
+    #
+    # Implicit in the documentation is that testMethodPrefix is respected by
+    # all loadTestsFrom* methods.
+    def test_testMethodPrefix__loadTestsFromTestCase(self):
+        class Foo(unittest2.TestCase):
+            def test_1(self): pass
+            def test_2(self): pass
+            def foo_bar(self): pass
+
+        tests_1 = unittest2.TestSuite([Foo('foo_bar')])
+        tests_2 = unittest2.TestSuite([Foo('test_1'), Foo('test_2')])
+
+        loader = unittest2.TestLoader()
+        loader.testMethodPrefix = 'foo'
+        self.assertEqual(loader.loadTestsFromTestCase(Foo), tests_1)
+
+        loader.testMethodPrefix = 'test'
+        self.assertEqual(loader.loadTestsFromTestCase(Foo), tests_2)
+
+    # "String giving the prefix of method names which will be interpreted as
+    # test methods"
+    #
+    # Implicit in the documentation is that testMethodPrefix is respected by
+    # all loadTestsFrom* methods.
+    def test_testMethodPrefix__loadTestsFromModule(self):
+        m = types.ModuleType('m')
+        class Foo(unittest2.TestCase):
+            def test_1(self): pass
+            def test_2(self): pass
+            def foo_bar(self): pass
+        m.Foo = Foo
+
+        tests_1 = [unittest2.TestSuite([Foo('foo_bar')])]
+        tests_2 = [unittest2.TestSuite([Foo('test_1'), Foo('test_2')])]
+
+        loader = unittest2.TestLoader()
+        loader.testMethodPrefix = 'foo'
+        self.assertEqual(list(loader.loadTestsFromModule(m)), tests_1)
+
+        loader.testMethodPrefix = 'test'
+        self.assertEqual(list(loader.loadTestsFromModule(m)), tests_2)
+
+    # "String giving the prefix of method names which will be interpreted as
+    # test methods"
+    #
+    # Implicit in the documentation is that testMethodPrefix is respected by
+    # all loadTestsFrom* methods.
+    def test_testMethodPrefix__loadTestsFromName(self):
+        m = types.ModuleType('m')
+        class Foo(unittest2.TestCase):
+            def test_1(self): pass
+            def test_2(self): pass
+            def foo_bar(self): pass
+        m.Foo = Foo
+
+        tests_1 = unittest2.TestSuite([Foo('foo_bar')])
+        tests_2 = unittest2.TestSuite([Foo('test_1'), Foo('test_2')])
+
+        loader = unittest2.TestLoader()
+        loader.testMethodPrefix = 'foo'
+        self.assertEqual(loader.loadTestsFromName('Foo', m), tests_1)
+
+        loader.testMethodPrefix = 'test'
+        self.assertEqual(loader.loadTestsFromName('Foo', m), tests_2)
+
+    # "String giving the prefix of method names which will be interpreted as
+    # test methods"
+    #
+    # Implicit in the documentation is that testMethodPrefix is respected by
+    # all loadTestsFrom* methods.
+    def test_testMethodPrefix__loadTestsFromNames(self):
+        m = types.ModuleType('m')
+        class Foo(unittest2.TestCase):
+            def test_1(self): pass
+            def test_2(self): pass
+            def foo_bar(self): pass
+        m.Foo = Foo
+
+        tests_1 = unittest2.TestSuite([unittest2.TestSuite([Foo('foo_bar')])])
+        tests_2 = unittest2.TestSuite([Foo('test_1'), Foo('test_2')])
+        tests_2 = unittest2.TestSuite([tests_2])
+
+        loader = unittest2.TestLoader()
+        loader.testMethodPrefix = 'foo'
+        self.assertEqual(loader.loadTestsFromNames(['Foo'], m), tests_1)
+
+        loader.testMethodPrefix = 'test'
+        self.assertEqual(loader.loadTestsFromNames(['Foo'], m), tests_2)
+
+    # "The default value is 'test'"
+    def test_testMethodPrefix__default_value(self):
+        loader = unittest2.TestLoader()
+        self.assertTrue(loader.testMethodPrefix == 'test')
+
+    ################################################################
+    ### /Tests for TestLoader.testMethodPrefix
+
+    ### Tests for TestLoader.sortTestMethodsUsing
+    ################################################################
+
+    # "Function to be used to compare method names when sorting them in
+    # getTestCaseNames() and all the loadTestsFromX() methods"
+    def test_sortTestMethodsUsing__loadTestsFromTestCase(self):
+        def reversed_cmp(x, y):
+            return -cmp(x, y)
+
+        class Foo(unittest2.TestCase):
+            def test_1(self): pass
+            def test_2(self): pass
+
+        loader = unittest2.TestLoader()
+        loader.sortTestMethodsUsing = reversed_cmp
+
+        tests = loader.suiteClass([Foo('test_2'), Foo('test_1')])
+        self.assertEqual(loader.loadTestsFromTestCase(Foo), tests)
+
+    # "Function to be used to compare method names when sorting them in
+    # getTestCaseNames() and all the loadTestsFromX() methods"
+    def test_sortTestMethodsUsing__loadTestsFromModule(self):
+        def reversed_cmp(x, y):
+            return -cmp(x, y)
+
+        m = types.ModuleType('m')
+        class Foo(unittest2.TestCase):
+            def test_1(self): pass
+            def test_2(self): pass
+        m.Foo = Foo
+
+        loader = unittest2.TestLoader()
+        loader.sortTestMethodsUsing = reversed_cmp
+
+        tests = [loader.suiteClass([Foo('test_2'), Foo('test_1')])]
+        self.assertEqual(list(loader.loadTestsFromModule(m)), tests)
+
+    # "Function to be used to compare method names when sorting them in
+    # getTestCaseNames() and all the loadTestsFromX() methods"
+    def test_sortTestMethodsUsing__loadTestsFromName(self):
+        def reversed_cmp(x, y):
+            return -cmp(x, y)
+
+        m = types.ModuleType('m')
+        class Foo(unittest2.TestCase):
+            def test_1(self): pass
+            def test_2(self): pass
+        m.Foo = Foo
+
+        loader = unittest2.TestLoader()
+        loader.sortTestMethodsUsing = reversed_cmp
+
+        tests = loader.suiteClass([Foo('test_2'), Foo('test_1')])
+        self.assertEqual(loader.loadTestsFromName('Foo', m), tests)
+
+    # "Function to be used to compare method names when sorting them in
+    # getTestCaseNames() and all the loadTestsFromX() methods"
+    def test_sortTestMethodsUsing__loadTestsFromNames(self):
+        def reversed_cmp(x, y):
+            return -cmp(x, y)
+
+        m = types.ModuleType('m')
+        class Foo(unittest2.TestCase):
+            def test_1(self): pass
+            def test_2(self): pass
+        m.Foo = Foo
+
+        loader = unittest2.TestLoader()
+        loader.sortTestMethodsUsing = reversed_cmp
+
+        tests = [loader.suiteClass([Foo('test_2'), Foo('test_1')])]
+        self.assertEqual(list(loader.loadTestsFromNames(['Foo'], m)), tests)
+
+    # "Function to be used to compare method names when sorting them in
+    # getTestCaseNames()"
+    #
+    # Does it actually affect getTestCaseNames()?
+    def test_sortTestMethodsUsing__getTestCaseNames(self):
+        def reversed_cmp(x, y):
+            return -cmp(x, y)
+
+        class Foo(unittest2.TestCase):
+            def test_1(self): pass
+            def test_2(self): pass
+
+        loader = unittest2.TestLoader()
+        loader.sortTestMethodsUsing = reversed_cmp
+
+        test_names = ['test_2', 'test_1']
+        self.assertEqual(loader.getTestCaseNames(Foo), test_names)
+
+    # "The default value is the built-in cmp() function"
+    def test_sortTestMethodsUsing__default_value(self):
+        loader = unittest2.TestLoader()
+        self.assertTrue(loader.sortTestMethodsUsing is cmp)
+
+    # "it can be set to None to disable the sort."
+    #
+    # XXX How is this different from reassigning cmp? Are the tests returned
+    # in a random order or something? This behaviour should die
+    def test_sortTestMethodsUsing__None(self):
+        class Foo(unittest2.TestCase):
+            def test_1(self): pass
+            def test_2(self): pass
+
+        loader = unittest2.TestLoader()
+        loader.sortTestMethodsUsing = None
+
+        test_names = ['test_2', 'test_1']
+        self.assertEqual(set(loader.getTestCaseNames(Foo)), set(test_names))
+
+    ################################################################
+    ### /Tests for TestLoader.sortTestMethodsUsing
+
+    ### Tests for TestLoader.suiteClass
+    ################################################################
+
+    # "Callable object that constructs a test suite from a list of tests."
+    def test_suiteClass__loadTestsFromTestCase(self):
+        class Foo(unittest2.TestCase):
+            def test_1(self): pass
+            def test_2(self): pass
+            def foo_bar(self): pass
+
+        tests = [Foo('test_1'), Foo('test_2')]
+
+        loader = unittest2.TestLoader()
+        loader.suiteClass = list
+        self.assertEqual(loader.loadTestsFromTestCase(Foo), tests)
+
+    # It is implicit in the documentation for TestLoader.suiteClass that
+    # all TestLoader.loadTestsFrom* methods respect it. Let's make sure
+    def test_suiteClass__loadTestsFromModule(self):
+        m = types.ModuleType('m')
+        class Foo(unittest2.TestCase):
+            def test_1(self): pass
+            def test_2(self): pass
+            def foo_bar(self): pass
+        m.Foo = Foo
+
+        tests = [[Foo('test_1'), Foo('test_2')]]
+
+        loader = unittest2.TestLoader()
+        loader.suiteClass = list
+        self.assertEqual(loader.loadTestsFromModule(m), tests)
+
+    # It is implicit in the documentation for TestLoader.suiteClass that
+    # all TestLoader.loadTestsFrom* methods respect it. Let's make sure
+    def test_suiteClass__loadTestsFromName(self):
+        m = types.ModuleType('m')
+        class Foo(unittest2.TestCase):
+            def test_1(self): pass
+            def test_2(self): pass
+            def foo_bar(self): pass
+        m.Foo = Foo
+
+        tests = [Foo('test_1'), Foo('test_2')]
+
+        loader = unittest2.TestLoader()
+        loader.suiteClass = list
+        self.assertEqual(loader.loadTestsFromName('Foo', m), tests)
+
+    # It is implicit in the documentation for TestLoader.suiteClass that
+    # all TestLoader.loadTestsFrom* methods respect it. Let's make sure
+    def test_suiteClass__loadTestsFromNames(self):
+        m = types.ModuleType('m')
+        class Foo(unittest2.TestCase):
+            def test_1(self): pass
+            def test_2(self): pass
+            def foo_bar(self): pass
+        m.Foo = Foo
+
+        tests = [[Foo('test_1'), Foo('test_2')]]
+
+        loader = unittest2.TestLoader()
+        loader.suiteClass = list
+        self.assertEqual(loader.loadTestsFromNames(['Foo'], m), tests)
+
+    # "The default value is the TestSuite class"
+    def test_suiteClass__default_value(self):
+        loader = unittest2.TestLoader()
+        self.assertTrue(loader.suiteClass is unittest2.TestSuite)
+
+
+if __name__ == '__main__':
+    unittest2.main()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_new_tests.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_new_tests.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_new_tests.py
new file mode 100644
index 0000000..cc96bcb
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_new_tests.py
@@ -0,0 +1,46 @@
+from cStringIO import StringIO
+
+import unittest
+import unittest2
+
+from unittest2.test.support import resultFactory
+
+
+class TestUnittest(unittest2.TestCase):
+    
+    def assertIsSubclass(self, actual, klass):
+        self.assertTrue(issubclass(actual, klass), "Not a subclass.")
+    
+    def testInheritance(self):
+        self.assertIsSubclass(unittest2.TestCase, unittest.TestCase)
+        self.assertIsSubclass(unittest2.TestResult, unittest.TestResult)
+        self.assertIsSubclass(unittest2.TestSuite, unittest.TestSuite)
+        self.assertIsSubclass(unittest2.TextTestRunner, unittest.TextTestRunner)
+        self.assertIsSubclass(unittest2.TestLoader, unittest.TestLoader)
+        self.assertIsSubclass(unittest2.TextTestResult, unittest.TestResult)
+    
+    def test_new_runner_old_case(self):
+        runner = unittest2.TextTestRunner(resultclass=resultFactory,
+                                          stream=StringIO())
+        class Test(unittest.TestCase):
+            def testOne(self):
+                pass
+        suite = unittest2.TestSuite((Test('testOne'),))
+        result = runner.run(suite)
+        self.assertEqual(result.testsRun, 1)
+        self.assertEqual(len(result.errors), 0)
+    
+    def test_old_runner_new_case(self):
+        runner = unittest.TextTestRunner(stream=StringIO())
+        class Test(unittest2.TestCase):
+            def testOne(self):
+                self.assertDictEqual({}, {})
+                
+        suite = unittest.TestSuite((Test('testOne'),))
+        result = runner.run(suite)
+        self.assertEqual(result.testsRun, 1)
+        self.assertEqual(len(result.errors), 0)
+        
+        
+if __name__ == '__main__':
+    unittest2.main()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_program.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_program.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_program.py
new file mode 100644
index 0000000..56077a6
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_program.py
@@ -0,0 +1,239 @@
+from cStringIO import StringIO
+
+import sys
+import unittest2
+
+hasInstallHandler = hasattr(unittest2, 'installHandler')
+
+class Test_TestProgram(unittest2.TestCase):
+
+    # Horrible white box test
+    def testNoExit(self):
+        result = object()
+        test = object()
+
+        class FakeRunner(object):
+            def run(self, test):
+                self.test = test
+                return result
+
+        runner = FakeRunner()
+
+        oldParseArgs = unittest2.TestProgram.parseArgs
+        def restoreParseArgs():
+            unittest2.TestProgram.parseArgs = oldParseArgs
+        unittest2.TestProgram.parseArgs = lambda *args: None
+        self.addCleanup(restoreParseArgs)
+
+        def removeTest():
+            del unittest2.TestProgram.test
+        unittest2.TestProgram.test = test
+        self.addCleanup(removeTest)
+
+        program = unittest2.TestProgram(testRunner=runner, exit=False, verbosity=2)
+
+        self.assertEqual(program.result, result)
+        self.assertEqual(runner.test, test)
+        self.assertEqual(program.verbosity, 2)
+
+    class FooBar(unittest2.TestCase):
+        def testPass(self):
+            assert True
+        def testFail(self):
+            assert False
+
+    class FooBarLoader(unittest2.TestLoader):
+        """Test loader that returns a suite containing FooBar."""
+        def loadTestsFromModule(self, module):
+            return self.suiteClass(
+                [self.loadTestsFromTestCase(Test_TestProgram.FooBar)])
+
+
+    def test_NonExit(self):
+        program = unittest2.main(exit=False,
+                                argv=["foobar"],
+                                testRunner=unittest2.TextTestRunner(stream=StringIO()),
+                                testLoader=self.FooBarLoader())
+        self.assertTrue(hasattr(program, 'result'))
+
+
+    def test_Exit(self):
+        self.assertRaises(
+            SystemExit,
+            unittest2.main,
+            argv=["foobar"],
+            testRunner=unittest2.TextTestRunner(stream=StringIO()),
+            exit=True,
+            testLoader=self.FooBarLoader())
+
+
+    def test_ExitAsDefault(self):
+        self.assertRaises(
+            SystemExit,
+            unittest2.main,
+            argv=["foobar"],
+            testRunner=unittest2.TextTestRunner(stream=StringIO()),
+            testLoader=self.FooBarLoader())
+
+
+class InitialisableProgram(unittest2.TestProgram):
+    exit = False
+    result = None
+    verbosity = 1
+    defaultTest = None
+    testRunner = None
+    testLoader = unittest2.defaultTestLoader
+    progName = 'test'
+    test = 'test'
+    def __init__(self, *args):
+        pass
+
+RESULT = object()
+
+class FakeRunner(object):
+    initArgs = None
+    test = None
+    raiseError = False
+
+    def __init__(self, **kwargs):
+        FakeRunner.initArgs = kwargs
+        if FakeRunner.raiseError:
+            FakeRunner.raiseError = False
+            raise TypeError
+
+    def run(self, test):
+        FakeRunner.test = test
+        return RESULT
+
+class TestCommandLineArgs(unittest2.TestCase):
+    
+    def setUp(self):
+        self.program = InitialisableProgram()
+        self.program.createTests = lambda: None
+        FakeRunner.initArgs = None
+        FakeRunner.test = None
+        FakeRunner.raiseError = False
+    
+    def testHelpAndUnknown(self):
+        program = self.program
+        def usageExit(msg=None):
+            program.msg = msg
+            program.exit = True
+        program.usageExit = usageExit
+        
+        for opt in '-h', '-H', '--help':
+            program.exit = False
+            program.parseArgs([None, opt])
+            self.assertTrue(program.exit)
+            self.assertIsNone(program.msg)
+    
+        program.parseArgs([None, '-$'])
+        self.assertTrue(program.exit)
+        self.assertIsNotNone(program.msg)
+    
+    def testVerbosity(self):
+        program = self.program
+        
+        for opt in '-q', '--quiet':
+            program.verbosity = 1
+            program.parseArgs([None, opt])
+            self.assertEqual(program.verbosity, 0)
+
+        for opt in '-v', '--verbose':
+            program.verbosity = 1
+            program.parseArgs([None, opt])
+            self.assertEqual(program.verbosity, 2)
+
+    def testBufferCatchFailfast(self):
+        program = self.program
+        for arg, attr in (('buffer', 'buffer'), ('failfast', 'failfast'),
+                      ('catch', 'catchbreak')):
+            if attr == 'catch' and not hasInstallHandler:
+                continue
+            
+            short_opt = '-%s' % arg[0]
+            long_opt = '--%s' % arg
+            for opt in short_opt, long_opt:
+                setattr(program, attr, None)
+                
+                program.parseArgs([None, opt])
+                self.assertTrue(getattr(program, attr))
+
+            for opt in short_opt, long_opt:
+                not_none = object()
+                setattr(program, attr, not_none)
+                
+                program.parseArgs([None, opt])
+                self.assertEqual(getattr(program, attr), not_none)
+
+    def testRunTestsRunnerClass(self):
+        program = self.program
+        
+        program.testRunner = FakeRunner
+        program.verbosity = 'verbosity'
+        program.failfast = 'failfast'
+        program.buffer = 'buffer'
+        
+        program.runTests()
+        
+        self.assertEqual(FakeRunner.initArgs, {'verbosity': 'verbosity', 
+                                                'failfast': 'failfast',
+                                                'buffer': 'buffer'})
+        self.assertEqual(FakeRunner.test, 'test')
+        self.assertIs(program.result, RESULT)
+
+    def testRunTestsRunnerInstance(self):
+        program = self.program
+        
+        program.testRunner = FakeRunner()
+        FakeRunner.initArgs = None
+        
+        program.runTests()
+
+        # A new FakeRunner should not have been instantiated
+        self.assertIsNone(FakeRunner.initArgs)
+        
+        self.assertEqual(FakeRunner.test, 'test')
+        self.assertIs(program.result, RESULT)
+
+    def testRunTestsOldRunnerClass(self):
+        program = self.program
+        
+        FakeRunner.raiseError = True
+        program.testRunner = FakeRunner
+        program.verbosity = 'verbosity'
+        program.failfast = 'failfast'
+        program.buffer = 'buffer'
+        program.test = 'test'
+        
+        program.runTests()
+        
+        # If initialising raises a type error it should be retried
+        # without the new keyword arguments
+        self.assertEqual(FakeRunner.initArgs, {})
+        self.assertEqual(FakeRunner.test, 'test')
+        self.assertIs(program.result, RESULT)
+    
+    def testCatchBreakInstallsHandler(self):
+        module = sys.modules['unittest2.main']
+        original = module.installHandler
+        def restore():
+            module.installHandler = original
+        self.addCleanup(restore)
+
+        self.installed = False
+        def fakeInstallHandler():
+            self.installed = True
+        module.installHandler = fakeInstallHandler
+        
+        program = self.program
+        program.catchbreak = True
+        
+        program.testRunner = FakeRunner
+        
+        program.runTests()
+        self.assertTrue(self.installed)
+
+
+if __name__ == '__main__':
+    unittest2.main()


[20/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code

Posted by rl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/_psimodule.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/_psimodule.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/_psimodule.c
new file mode 100644
index 0000000..2979103
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/_psimodule.c
@@ -0,0 +1,389 @@
+/* The MIT License
+ *
+ * Copyright (C) 2008-2009 Floris Bruynooghe
+ *
+ * Copyright (C) 2008-2009 Abilisoft Ltd.
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/** The _psi module
+ *
+ * This module contains the PsiExc_* exceptions.
+ *
+ * Additionally it currently holds the loadavg() function.
+ */
+
+
+#include <Python.h>
+
+#if defined(SUNOS5) && SUNOS5_MINOR >= 10
+#include <zone.h>
+#endif
+
+#include "psi.h"
+#include "psifuncs.h"
+
+
+/* Declarations (we need these since we use -Wmissing-declarations) */
+#ifdef PY3K
+PyMODINIT_FUNC PyInit__psi(void);
+#else
+PyMODINIT_FUNC init_psi(void);
+#endif
+
+/* Re-declare these as non-extern since we're providing the symbols */
+PyObject *PsiExc_AttrNotAvailableError = NULL;
+PyObject *PsiExc_AttrInsufficientPrivsError = NULL;
+PyObject *PsiExc_AttrNotImplementedError = NULL;
+PyObject *PsiExc_MissingResourceError = NULL;
+PyObject *PsiExc_InsufficientPrivsError = NULL;
+
+
+/* More constants */
+static char MODULE_NAME[] = "psi._psi";
+
+
+/* Module functions */
+
+
+PyDoc_STRVAR(psi_boottime__doc, "\
+boottime() -> float\n\
+\n\
+Return the boot time of the of the machine as a datetime.datetime object.\n\
+");
+static PyObject *
+psi_boottime(PyObject *self, PyObject *args)
+{
+    struct timespec boottime;
+
+    if (arch_boottime(&boottime) < 0)
+        return NULL;
+    return PsiTimeSpec_New(&boottime);
+}
+
+
+PyDoc_STRVAR(psi_loadavg__doc, "\
+loadavg() -> (float, float, float)\n\
+\n\
+Return the number of processes in the system run queue\n\
+averaged over the last 1, 5, and 15 minutes.\n\
+");
+static PyObject *
+psi_loadavg(PyObject *self, PyObject *args)
+{
+    struct loadavginfo* loadi;
+    PyObject *tuple = NULL;
+    PyObject *l = NULL;
+
+    loadi = arch_loadavginfo();
+    if (loadi == NULL)
+        return NULL;
+    if (psi_checkattr("loadavg()", loadi->loadavg_status) == -1)
+        goto cleanup;
+    tuple = PyTuple_New(3);
+    if (tuple == NULL)
+        goto cleanup;
+    l = PyFloat_FromDouble(loadi->one);
+    if (l == NULL)
+        goto cleanup;
+    if (PyTuple_SetItem(tuple, 0, l) == -1)
+        goto cleanup;
+    l = PyFloat_FromDouble(loadi->five);
+    if (l == NULL)
+        goto cleanup;
+    if (PyTuple_SetItem(tuple, 1, l) == -1)
+        goto cleanup;
+    l = PyFloat_FromDouble(loadi->fifteen);
+    if (l == NULL)
+        goto cleanup;
+    if (PyTuple_SetItem(tuple, 2, l) == -1)
+        goto cleanup;
+    psi_free(loadi);
+    return tuple;
+
+  cleanup:
+    psi_free(loadi);
+    Py_XDECREF(tuple);
+    Py_XDECREF(l);
+    return NULL;
+}
+
+
+PyDoc_STRVAR(psi_uptime__doc, "\
+uptime() -> float\n\
+\n\
+Return the system uptime as a datetime.timedelta object.\n\
+");
+static PyObject *
+psi_uptime(PyObject *self, PyObject *args)
+{
+    struct timespec uptime;
+
+    if (arch_uptime(&uptime) < 0)
+        return NULL;
+    return PsiTimeSpec_New(&uptime);
+}
+
+
+#if defined(SUNOS5) && SUNOS5_MINOR >= 10
+PyDoc_STRVAR(psi_getzoneid__doc, "\
+getzoneid() -> int\n\
+\n\
+Return the zone ID of the current python process.\n\
+");
+static PyObject *
+psi_getzoneid(PyObject *self, PyObject *args)
+{
+    zoneid_t id;
+
+    id = getzoneid();
+    if (id < 0)
+        return PyErr_SetFromErrno(PyExc_OSError);
+    return PyLong_FromLong(id);
+}
+
+
+PyDoc_STRVAR(psi_getzoneidbyname__doc, "\
+getzoneidbyname(string) -> int\n\
+\n\
+Return the zone ID from a zone name, raise a ValueError in\n\
+case of an invalid name.\n\
+");
+static PyObject *
+psi_getzoneidbyname(PyObject *self, PyObject *args)
+{
+    zoneid_t id;
+    char *name;
+
+    if (!PyArg_ParseTuple(args, "s", &name))
+        return NULL;
+    id = getzoneidbyname(name);
+    if (id < 0)
+        return PyErr_SetFromErrno(PyExc_ValueError);
+    return PyLong_FromLong(id);
+}
+
+
+PyDoc_STRVAR(psi_getzonenamebyid__doc, "\
+getzonenamebyid(int) -> string\n\
+\n\
+Return the zone name from a zone ID, raise a ValueError in\n\
+case of an invalid ID.\n\
+");
+static PyObject *
+psi_getzonenamebyid(PyObject *self, PyObject *args)
+{
+    zoneid_t id;
+    char name[ZONENAME_MAX];
+
+    if (!PyArg_ParseTuple(args, "i", &id))
+        return NULL;
+    if (getzonenamebyid(id, name, ZONENAME_MAX) < 0)
+        return PyErr_SetFromErrno(PyExc_ValueError);
+    return PyStr_FromString(name);
+}
+#endif  /* defined(SUNOS5 && SUNOS5_MINOR >= 10 */
+
+
+
+/***** Module creation functions *****/
+
+
+/** Create a new exception class with __doc__ set.
+ *
+ * If successful, the new exception class is returned.  Otherwise NULL is
+ * returned.
+*/
+static PyObject *
+create_exception(char *name, PyObject *base, const char *doc)
+{
+    PyObject *dict;
+    PyObject *docstr;
+    PyObject *error;
+    int r;
+
+    docstr = PyStr_FromString(doc);
+    if (docstr == NULL)
+        return NULL;
+    dict = PyDict_New();
+    if (dict == NULL) {
+        Py_DECREF(docstr);
+        return NULL;
+    }
+    r = PyDict_SetItemString(dict, "__doc__", docstr);
+    Py_DECREF(docstr);
+    if (r == -1) {
+        Py_DECREF(dict);
+        return NULL;
+    }
+    error = PyErr_NewException(name, base, dict);
+    Py_DECREF(dict);
+    return error;
+}
+
+
+/** Initialise the global exceptions
+ *
+ * If this function fails the modinit function will Py_XDECREF the exceptions,
+ * so no need to do that here.
+ */
+static int
+init_exceptions(void)
+{
+    PsiExc_AttrNotAvailableError = create_exception(
+        "psi.AttrNotAvailableError",
+        PyExc_AttributeError,
+        "Requested attribute is not available for this process\n\n"
+        "This is a subclass of AttributeError.");
+    if (PsiExc_AttrNotAvailableError == NULL)
+        return -1;
+    PsiExc_AttrInsufficientPrivsError = create_exception(
+        "psi.AttrInsufficientPrivsError",
+        PyExc_AttributeError,
+        "Insufficient privileges for requested attribute\n\n"
+        "This is a subclass of AttributeError.");
+    if (PsiExc_AttrInsufficientPrivsError == NULL)
+        return -1;
+    PsiExc_AttrNotImplementedError = create_exception(
+        "psi.AttrNotImplementedError",
+        PyExc_AttributeError,
+        "Attribute has not been implemented on this system\n\n"
+        "This is a subclass of AttributeError.");
+    if (PsiExc_AttrNotImplementedError == NULL)
+        return -1;
+    PsiExc_MissingResourceError = create_exception(
+        "psi.MissingResourceError",
+        NULL,
+        "A resource is missing, base exception within psi.");
+    if (PsiExc_MissingResourceError == NULL)
+        return -1;
+    PsiExc_InsufficientPrivsError = create_exception(
+        "psi.InsufficientPrivsError",
+        NULL,
+        "Insufficient privileges for requested operation.");
+    if (PsiExc_InsufficientPrivsError == NULL)
+        return -1;
+    return 0;
+}
+
+
+static int
+add_module_objects(PyObject *mod)
+{
+    if (PyModule_AddObject(mod, "AttrNotAvailableError",
+                           PsiExc_AttrNotAvailableError) < 0)
+        return -1;
+    if (PyModule_AddObject(mod, "AttrInsufficientPrivsError",
+                           PsiExc_AttrInsufficientPrivsError) < 0)
+        return -1;
+    if (PyModule_AddObject(mod, "AttrNotImplementedError",
+                           PsiExc_AttrNotImplementedError) < 0)
+        return -1;
+    if (PyModule_AddObject(mod, "MissingResourceError",
+                           PsiExc_MissingResourceError) < 0)
+        return -1;
+    if (PyModule_AddObject(mod, "InsufficientPrivsError",
+                           PsiExc_InsufficientPrivsError) < 0)
+        return -1;
+    if (PyModule_AddObject(mod, "TimeSpec", (PyObject *)&PsiTimeSpec_Type) < 0)
+        return -1;
+    return 0;
+}
+
+
+static PyMethodDef psi_methods[] = {
+    {"boottime", psi_boottime, METH_NOARGS, psi_boottime__doc},
+    {"loadavg", psi_loadavg, METH_NOARGS, psi_loadavg__doc},
+    {"uptime", psi_uptime, METH_NOARGS, psi_uptime__doc},
+#if defined(SUNOS5) && SUNOS5_MINOR >= 10
+    {"getzoneid", psi_getzoneid, METH_NOARGS, psi_getzoneid__doc},
+    {"getzoneidbyname", psi_getzoneidbyname, METH_VARARGS,
+     psi_getzoneidbyname__doc},
+    {"getzonenamebyid", psi_getzonenamebyid, METH_VARARGS,
+     psi_getzonenamebyid__doc},
+#endif
+    {NULL, NULL, 0, NULL}        /* Sentinel */
+};
+
+
+#ifdef PY3K
+static struct PyModuleDef moduledef = {
+        PyModuleDef_HEAD_INIT,  /* m_base */
+        MODULE_NAME,            /* m_name */
+        0,                      /* m_doc */
+        -1,                     /* m_size */
+        psi_methods,            /* m_methods */
+        NULL,                   /* m_reload */
+        NULL,                   /* m_traverse */
+        NULL,                   /* m_clear */
+        NULL                    /* m_free */
+};
+#endif
+
+
+/* Some defines to make the module init function readable */
+#ifdef PY3K
+#define MODFUNC PyInit__psi
+#define RETURN(VAR) return VAR
+#else
+#define MODFUNC init_psi
+#define RETURN(VAR) return
+#endif
+
+
+/* Returns the psi._psi module */
+PyMODINIT_FUNC
+MODFUNC(void)
+{
+    PyObject *c_api = NULL;
+    PyObject *mod = NULL;
+
+    if (PyType_Ready(&PsiTimeSpec_Type) < 0)
+        RETURN(NULL);
+    Py_INCREF(&PsiTimeSpec_Type);
+    if (init_exceptions() < 0)
+        goto error;
+#ifdef PY3K
+    mod = PyModule_Create(&moduledef);
+#else
+    mod = Py_InitModule(MODULE_NAME, psi_methods);
+#endif
+    if (mod == NULL)
+        goto error;
+    if (add_module_objects(mod) < 0)
+        goto error;
+    c_api = PyCObject_FromVoidPtr((void*)PsiTimeSpec_InternalNew, NULL);
+    if (c_api == NULL)
+        goto error;
+    if (PyModule_AddObject(mod, "_C_API", c_api) < 0)
+        goto error;
+    RETURN(mod);
+
+  error:
+    Py_DECREF(&PsiTimeSpec_Type);
+    Py_XDECREF(mod);
+    Py_XDECREF(PsiExc_AttrNotAvailableError);
+    Py_XDECREF(PsiExc_AttrInsufficientPrivsError);
+    Py_XDECREF(PsiExc_AttrNotImplementedError);
+    Py_XDECREF(PsiExc_MissingResourceError);
+    Py_XDECREF(c_api);
+    RETURN(NULL);
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch.c
new file mode 100644
index 0000000..12e6f80
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch.c
@@ -0,0 +1,561 @@
+/* The MIT License
+ *
+ * Copyright (C) 2007 Chris Miles
+ *
+ * Copyright (C) 2008-2009 Floris Bruynooghe
+ *
+ * Copyright (C) 2008-2009 Abilisoft Ltd.
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/** psi.arch.Arch* classes
+ *
+ * This file contains the common support for the psi.arch.Arch classes and
+ * factory functions.
+ */
+
+
+#include <Python.h>
+
+#include <errno.h>
+#include <stdlib.h>
+
+#include "psi.h"
+#include "arch.h"
+
+
+#define RELEASE_INFO_SIZE 5
+
+
+/***** The Python ArchBase object *****/
+typedef struct {
+    PyObject_HEAD
+    struct psi_archinfo *archi;
+    int release_info[RELEASE_INFO_SIZE]; /* release_info tuple */
+    int release_info_size;               /* number of entries in release_info */
+} PsiArchBaseObject;
+
+
+/***** Helper functions *****/
+
+
+void *
+psi_free_archinfo(struct psi_archinfo *archi)
+{
+    psi_FREE(archi->sysname);
+    psi_FREE(archi->release);
+    psi_FREE(archi->version);
+    psi_FREE(archi->machine);
+    psi_FREE(archi->nodename);
+    psi_free(archi);
+    return NULL;
+}
+
+
+/** Parse a relase string into a release_info tuple
+ *
+ * This function will try to parse the release string into an array of
+ * integers.  Roughly equivalent to this python code: [int(i) for i in
+ * release.split('-')[0].split('.')]
+ *
+ * @param release_info: The array to store the result into.
+ * @param size: The size of the array.
+ * @param release: The release string.
+ *
+ * @returns The number of items set in `release_info', -1 on failure.
+ */
+static int
+set_release_info(int *release_info, const int size, const char *release)
+{
+    char *reldup;
+    char *relpart;
+    char *p;
+    int i = 0;
+
+    reldup = psi_strdup(release);
+    relpart = reldup;
+    if (relpart == NULL) {
+        psi_free(reldup);
+        return -1;
+    }
+    p = strchr(relpart, '-');
+    if (p != NULL)
+        *p = '\0';
+    p = strchr(relpart, '.');
+    while (p != NULL) {
+        *p++ = '\0';
+        errno = 0;
+        release_info[i] = (int)strtol(relpart, (char**)NULL, 10);
+        if (errno != 0) {
+            PyErr_Format(PyExc_ValueError,
+                         "Failed to parse release string '%s' into a tuple: %s",
+                         release, strerror(errno));
+            psi_free(reldup);
+            return -1;
+        }
+        relpart = p;
+        p = strchr(relpart, '.');
+        i++;
+        if (i == size) {
+            PyErr_Format(PyExc_OverflowError,
+                         "More then %d parts in release string '%s'",
+                         size, release);
+            psi_free(reldup);
+            return -1;
+        }
+    }
+    errno = 0;
+    release_info[i] = (int)strtol(relpart, (char**)NULL, 10);
+    psi_free(reldup);
+    if (errno != 0) {
+        PyErr_Format(PyExc_ValueError,
+                     "Failed to parse '%s' into a tuple: %s",
+                     release, strerror(errno));
+        return -1;
+    }
+    return i + 1;
+}
+
+
+/***** ArchBase methods *****/
+
+
+/** ArchBase .__new__() method
+ *
+ * This method implements singleton support by always returning the same
+ * object.
+ *
+ * The Py_XINCREF() each time may seem wrong but when checking the reference
+ * counts in a debug Python build they appear correct (and if you don't do
+ * this you get a negative reference count at some point).
+ */
+static PyObject *
+ArchBase_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+    static PsiArchBaseObject *self = NULL;
+
+    if (args != NULL && PySequence_Length(args) > 0) {
+        PyErr_Format(PyExc_TypeError,
+                     "__new__() takes no arguments (%d given)",
+                     (int)PySequence_Length(args));
+        return NULL;
+    }
+    if (kwds != NULL && PyMapping_Length(kwds) > 0) {
+        PyErr_SetString(PyExc_TypeError,
+                        "__new__() takes no keyword arguments");
+        return NULL;
+    }
+    if (self == NULL) {
+        self = (PsiArchBaseObject *)type->tp_alloc(type, 0);
+        self->archi = psi_arch_archinfo();
+        if (self->archi == NULL)
+            return NULL;
+        if (self->archi->release_status == PSI_STATUS_OK) {
+            self->release_info_size = set_release_info(self->release_info,
+                                                       RELEASE_INFO_SIZE,
+                                                       self->archi->release);
+            if (self->release_info_size < 0)
+                PyErr_Clear();
+        }
+    }
+    Py_XINCREF(self);
+    return (PyObject *)self;
+}
+
+
+static void
+ArchBase_dealloc(PsiArchBaseObject *self)
+{
+    if (self->archi != NULL)
+        psi_free_archinfo(self->archi);
+    Py_TYPE(self)->tp_free((PyObject*)self);
+}
+
+
+static PyObject *
+ArchBase_repr(PsiArchBaseObject *self)
+{
+    return PyStr_FromFormat("%s()", Py_TYPE(self)->tp_name);
+}
+
+
+static PyObject *
+ArchBase_get_sysname(PsiArchBaseObject *self, void *closure)
+{
+    if (self->archi == NULL) {
+        PyErr_SetString(PyExc_RuntimeError,
+                        "Instance has not been initialised properly");
+        return NULL;
+    }
+    if (psi_checkattr("Arch.sysname", self->archi->sysname_status) == -1)
+        return NULL;
+    return PyStr_FromString(self->archi->sysname);
+}
+
+
+static PyObject *
+ArchBase_get_release(PsiArchBaseObject *self, void *closure)
+{
+    if (self->archi == NULL) {
+        PyErr_SetString(PyExc_RuntimeError,
+                        "Instance has not been initialised properly");
+        return NULL;
+    }
+    if (psi_checkattr("Arch.release", self->archi->release_status) == -1)
+        return NULL;
+    return PyStr_FromString(self->archi->release);
+}
+
+
+static PyObject *
+ArchBase_get_release_info(PsiArchBaseObject *self, void *closure)
+{
+    PyObject *tuple;
+    PyObject *item;
+    Py_ssize_t i = (Py_ssize_t)self->release_info_size;
+    Py_ssize_t j;
+
+    if (self->archi == NULL) {
+        PyErr_SetString(PyExc_RuntimeError,
+                        "Instance has not been initialised properly");
+        return NULL;
+    }
+    if (psi_checkattr("Arch.release_info", self->archi->release_status) < 0)
+        return NULL;
+    if (self->release_info_size < 0) {
+        PyErr_SetString(PsiExc_AttrNotAvailableError,
+                        "release_info not available on this platform");
+        return NULL;
+    }
+    tuple = PyTuple_New(i);
+    if (tuple == NULL)
+        return NULL;
+    for (j = 0; j < i; j++) {
+        item = PyLong_FromLong((long)self->release_info[j]);
+        if (item == NULL) {
+            Py_DECREF(tuple);
+            return NULL;
+        }
+        PyTuple_SET_ITEM(tuple, j, item);
+    }
+    return tuple;
+}
+
+
+static PyObject *
+ArchBase_get_version(PsiArchBaseObject *self, void *closure)
+{
+    if (self->archi == NULL) {
+        PyErr_SetString(PyExc_RuntimeError,
+                        "Instance has not been initialised properly");
+        return NULL;
+    }
+    if (psi_checkattr("Arch.version", self->archi->version_status) == -1)
+        return NULL;
+    return PyStr_FromString(self->archi->version);
+}
+
+
+static PyObject *
+ArchBase_get_machine(PsiArchBaseObject *self, void *closure)
+{
+    if (self->archi == NULL) {
+        PyErr_SetString(PyExc_RuntimeError,
+                        "Instance has not been initialised properly");
+        return NULL;
+    }
+    if (psi_checkattr("Arch.machine", self->archi->machine_status) == -1)
+        return NULL;
+    return PyStr_FromString(self->archi->machine);
+}
+
+
+static PyObject *
+ArchBase_get_nodename(PsiArchBaseObject *self, void *closure)
+{
+    if (self->archi == NULL) {
+        PyErr_SetString(PyExc_RuntimeError,
+                        "Instance has not been initialised properly");
+        return NULL;
+    }
+    if (psi_checkattr("Arch.nodename", self->archi->nodename_status) == -1)
+        return NULL;
+    return PyStr_FromString(self->archi->nodename);
+}
+
+
+static PyGetSetDef ArchBase_getseters[] = {
+    {"sysname", (getter)ArchBase_get_sysname, (setter)NULL,
+     "Name of the operating system implementation", NULL},
+    {"release", (getter)ArchBase_get_release, (setter)NULL,
+     "Release level of the operating system", NULL},
+    {"release_info", (getter)ArchBase_get_release_info, (setter)NULL,
+     "Tuple representation of the operating system release level", NULL},
+    {"version", (getter)ArchBase_get_version, (setter)NULL,
+     "Version level of the operating system", NULL},
+    {"machine", (getter)ArchBase_get_machine, (setter)NULL,
+     "Machine hardware platform", NULL},
+    {"nodename", (getter)ArchBase_get_nodename, (setter)NULL,
+     "Network name of the machine", NULL},
+    {NULL}                      /* Sentinel */
+};
+
+
+PyTypeObject PsiArchBase_Type = {
+    PyVarObject_HEAD_INIT(NULL, 0)
+    "psi.arch.ArchBase",                      /* tp_name */
+    sizeof(PsiArchBaseObject),                /* tp_basicsize */
+    0,                                        /* tp_itemsize */
+    /* methods */
+    (destructor)ArchBase_dealloc,             /* tp_dealloc */
+    0,                                        /* tp_print */
+    0,                                        /* tp_getattr */
+    0,                                        /* tp_setattr */
+    0,                                        /* tp_compare */
+    (reprfunc)ArchBase_repr,                  /* tp_repr */
+    0,                                        /* tp_as_number */
+    0,                                        /* tp_as_sequence */
+    0,                                        /* tp_as_mapping */
+    0,                                        /* tp_hash */
+    0,                                        /* tp_call */
+    0,                                        /* tp_str */
+    0,                                        /* tp_getattro */
+    0,                                        /* tp_setattro */
+    0,                                        /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+    "Base object for all arch classes",       /* tp_doc */
+    0,                                        /* tp_traverse */
+    0,                                        /* tp_clear */
+    0,                                        /* tp_richcompare */
+    0,                                        /* tp_weaklistoffset */
+    0,                                        /* tp_iter */
+    0,                                        /* tp_iternext */
+    0,                                        /* tp_methods */
+    0,                                        /* tp_members */
+    ArchBase_getseters,                       /* tp_getset */
+    0,                                        /* tp_base */
+    0,                                        /* tp_dict */
+    0,                                        /* tp_descr_get */
+    0,                                        /* tp_descr_set */
+    0,                                        /* tp_dictoffset */
+    0,                                        /* tp_init */
+    0,                                        /* tp_alloc */
+    (newfunc)ArchBase_new,                    /* tp_new */
+};
+
+
+PyTypeObject PsiArchDarwin_Type = {
+    PyVarObject_HEAD_INIT(NULL, 0)
+    "psi.arch.ArchDarwin",                    /* tp_name */
+    sizeof(PsiArchBaseObject),                /* tp_basicsize */
+    0,                                        /* tp_itemsize */
+    /* methods */
+    0,                                        /* tp_dealloc */
+    0,                                        /* tp_print */
+    0,                                        /* tp_getattr */
+    0,                                        /* tp_setattr */
+    0,                                        /* tp_compare */
+    0,                                        /* tp_repr */
+    0,                                        /* tp_as_number */
+    0,                                        /* tp_as_sequence */
+    0,                                        /* tp_as_mapping */
+    0,                                        /* tp_hash */
+    0,                                        /* tp_call */
+    0,                                        /* tp_str */
+    0,                                        /* tp_getattro */
+    0,                                        /* tp_setattro */
+    0,                                        /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+    "This object represents a Darwin system", /* tp_doc */
+    0,                                        /* tp_traverse */
+    0,                                        /* tp_clear */
+    0,                                        /* tp_richcompare */
+    0,                                        /* tp_weaklistoffset */
+    0,                                        /* tp_iter */
+    0,                                        /* tp_iternext */
+    0,                                        /* tp_methods */
+    0,                                        /* tp_members */
+    0,                                        /* tp_getset */
+    &PsiArchBase_Type,                        /* tp_base */
+    0,                                        /* tp_dict */
+    0,                                        /* tp_descr_get */
+    0,                                        /* tp_descr_set */
+    0,                                        /* tp_dictoffset */
+    0,                                        /* tp_init */
+    0,                                        /* tp_alloc */
+    0,                                        /* tp_new */
+};
+
+
+PyTypeObject PsiArchSunOS_Type = {
+    PyVarObject_HEAD_INIT(NULL, 0)
+    "psi.arch.ArchSunOS",                     /* tp_name */
+    sizeof(PsiArchBaseObject),                /* tp_basicsize */
+    0,                                        /* tp_itemsize */
+    /* methods */
+    0,                                        /* tp_dealloc */
+    0,                                        /* tp_print */
+    0,                                        /* tp_getattr */
+    0,                                        /* tp_setattr */
+    0,                                        /* tp_compare */
+    0,                                        /* tp_repr */
+    0,                                        /* tp_as_number */
+    0,                                        /* tp_as_sequence */
+    0,                                        /* tp_as_mapping */
+    0,                                        /* tp_hash */
+    0,                                        /* tp_call */
+    0,                                        /* tp_str */
+    0,                                        /* tp_getattro */
+    0,                                        /* tp_setattro */
+    0,                                        /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+    "This object represnets a SunOS system",  /* tp_doc */
+    0,                                        /* tp_traverse */
+    0,                                        /* tp_clear */
+    0,                                        /* tp_richcompare */
+    0,                                        /* tp_weaklistoffset */
+    0,                                        /* tp_iter */
+    0,                                        /* tp_iternext */
+    0,                                        /* tp_methods */
+    0,                                        /* tp_members */
+    0,                                        /* tp_getset */
+    &PsiArchBase_Type,                        /* tp_base */
+    0,                                        /* tp_dict */
+    0,                                        /* tp_descr_get */
+    0,                                        /* tp_descr_set */
+    0,                                        /* tp_dictoffset */
+    0,                                        /* tp_init */
+    0,                                        /* tp_alloc */
+    0,                                        /* tp_new */
+};
+
+
+PyTypeObject PsiArchLinux_Type = {
+    PyVarObject_HEAD_INIT(NULL, 0)
+    "psi.arch.ArchLinux",                     /* tp_name */
+    sizeof(PsiArchBaseObject),                /* tp_basicsize */
+    0,                                        /* tp_itemsize */
+    /* methods */
+    0,                                        /* tp_dealloc */
+    0,                                        /* tp_print */
+    0,                                        /* tp_getattr */
+    0,                                        /* tp_setattr */
+    0,                                        /* tp_compare */
+    0,                                        /* tp_repr */
+    0,                                        /* tp_as_number */
+    0,                                        /* tp_as_sequence */
+    0,                                        /* tp_as_mapping */
+    0,                                        /* tp_hash */
+    0,                                        /* tp_call */
+    0,                                        /* tp_str */
+    0,                                        /* tp_getattro */
+    0,                                        /* tp_setattro */
+    0,                                        /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+    "This object represents a Linux system",  /* tp_doc */
+    0,                                        /* tp_traverse */
+    0,                                        /* tp_clear */
+    0,                                        /* tp_richcompare */
+    0,                                        /* tp_weaklistoffset */
+    0,                                        /* tp_iter */
+    0,                                        /* tp_iternext */
+    0,                                        /* tp_methods */
+    0,                                        /* tp_members */
+    0,                                        /* tp_getset */
+    &PsiArchBase_Type,                        /* tp_base */
+    0,                                        /* tp_dict */
+    0,                                        /* tp_descr_get */
+    0,                                        /* tp_descr_set */
+    0,                                        /* tp_dictoffset */
+    0,                                        /* tp_init */
+    0,                                        /* tp_alloc */
+    0,                                        /* tp_new */
+};
+
+
+PyTypeObject PsiArchAIX_Type = {
+    PyVarObject_HEAD_INIT(NULL, 0)
+    "psi.arch.ArchAIX",                       /* tp_name */
+    sizeof(PsiArchBaseObject),                /* tp_basicsize */
+    0,                                        /* tp_itemsize */
+    /* methods */
+    0,                                        /* tp_dealloc */
+    0,                                        /* tp_print */
+    0,                                        /* tp_getattr */
+    0,                                        /* tp_setattr */
+    0,                                        /* tp_compare */
+    0,                                        /* tp_repr */
+    0,                                        /* tp_as_number */
+    0,                                        /* tp_as_sequence */
+    0,                                        /* tp_as_mapping */
+    0,                                        /* tp_hash */
+    0,                                        /* tp_call */
+    0,                                        /* tp_str */
+    0,                                        /* tp_getattro */
+    0,                                        /* tp_setattro */
+    0,                                        /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+    "This object represents an AIX system",   /* tp_doc */
+    0,                                        /* tp_traverse */
+    0,                                        /* tp_clear */
+    0,                                        /* tp_richcompare */
+    0,                                        /* tp_weaklistoffset */
+    0,                                        /* tp_iter */
+    0,                                        /* tp_iternext */
+    0,                                        /* tp_methods */
+    0,                                        /* tp_members */
+    0,                                        /* tp_getset */
+    &PsiArchBase_Type,                        /* tp_base */
+    0,                                        /* tp_dict */
+    0,                                        /* tp_descr_get */
+    0,                                        /* tp_descr_set */
+    0,                                        /* tp_dictoffset */
+    0,                                        /* tp_init */
+    0,                                        /* tp_alloc */
+    0,                                        /* tp_new */
+};
+
+
+/* Object Creation Functions */
+
+
+PyObject *
+PsiArchBase_New(void)
+{
+    return ArchBase_new(&PsiArchBase_Type, NULL, NULL);
+}
+
+
+PyObject *
+PsiArch_New(void)
+{
+#ifdef DARWIN
+    return ArchBase_new(&PsiArchDarwin_Type, NULL, NULL);
+#elif SUNOS
+    return ArchBase_new(&PsiArchSunOS_Type, NULL, NULL);
+#elif LINUX
+    return ArchBase_new(&PsiArchLinux_Type, NULL, NULL);
+#elif AIX
+    return ArchBase_new(&PsiArchAIX_Type, NULL, NULL);
+#else
+#   error "Unknown system, can't compile"
+#endif
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/aix_mount.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/aix_mount.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/aix_mount.c
new file mode 100644
index 0000000..f6b6693
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/aix_mount.c
@@ -0,0 +1,189 @@
+/* The MIT License
+ *
+ * Copyright (C) 2009 Floris Bruynooghe
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include <Python.h>
+
+#include <string.h>
+#include <sys/types.h>
+#include <sys/mntctl.h>
+#include <sys/vmount.h>
+
+#include "psi.h"
+#include "mount.h"
+#include "posix_mount.h"
+
+
+/***** Local declarations *****/
+
+static int set_vmount(psi_mountinfo_t *mounti, const struct vmount *mnt);
+static char *map_fstype(const int gfstype);
+
+
+/***** Public functions *****/
+
+psi_mountlist_t *
+psi_arch_mountlist(const int remote)
+{
+    psi_mountlist_t *ml;
+    psi_mountinfo_t *mounti;
+    struct vmount *mnt;
+    char *vmounts;
+    int vmounts_size = sizeof(struct vmount);
+    int nmounts;
+    int offset = 0;
+    int i;
+
+    vmounts = psi_malloc(vmounts_size);
+    if (vmounts == NULL)
+        return NULL;
+    nmounts = mntctl(MCTL_QUERY, vmounts_size, vmounts);
+    if (nmounts == 0) {
+        mnt = (struct vmount *)vmounts;
+        vmounts_size = mnt->vmt_revision;
+        psi_free(vmounts);
+        vmounts = psi_malloc(vmounts_size);
+        if (vmounts == NULL)
+            return NULL;
+        nmounts = mntctl(MCTL_QUERY, vmounts_size, vmounts);
+    }
+    if (nmounts == -1) {
+        psi_free(vmounts);
+        PyErr_SetFromErrno(PyExc_OSError);
+        return NULL;
+    } else if (nmounts == 0) {
+        psi_free(vmounts);
+        PyErr_SetString(PyExc_OSError, "Internal race condition");
+        return NULL;
+    }
+    ml = (psi_mountlist_t *)psi_calloc(sizeof(psi_mountlist_t));
+    if (ml == NULL) {
+        psi_free(vmounts);
+        return NULL;
+    }
+    ml->mounts = (psi_mountinfo_t **)psi_calloc(
+        nmounts*sizeof(psi_mountinfo_t *));
+    if (ml->mounts == NULL) {
+        psi_free(vmounts);
+        psi_free(ml);
+        return NULL;
+    }
+    ml->count = 0;
+    for (i = 0; i < nmounts; i++) {
+        mnt = (struct vmount *)(vmounts + offset);
+        if (!remote && strcmp(vmt2dataptr(mnt, VMT_HOST), "-") != 0)
+            continue;
+        mounti = psi_calloc(sizeof(psi_mountinfo_t));
+        ml->mounts[ml->count] = mounti;
+        ml->count += 1;
+        if (set_vmount(mounti, mnt) < 0) {
+            psi_free(vmounts);
+            psi_free_mountlist(ml);
+            return NULL;
+        }
+        if (posix_set_vfs(mounti) < 0) {
+            psi_free(vmounts);
+            psi_free_mountlist(ml);
+            return NULL;
+        }
+    }
+    return ml;
+}
+
+
+/***** Local Functions *****/
+
+
+#define STRDUP(dst, src)                    \
+    if ((dst = psi_strdup(src)) == NULL)    \
+        return -1;                          \
+    dst ## _status = PSI_STATUS_OK
+
+
+static int
+set_vmount(psi_mountinfo_t *mounti, const struct vmount *mnt)
+{
+    mounti->mount_type = map_fstype(mnt->vmt_gfstype);
+    if (mounti->mount_type == NULL)
+        return -1;
+    mounti->mount_type_status = PSI_STATUS_OK;
+
+    /* XXX Debatable, options should maybe be flags instead of args. */
+    STRDUP(mounti->mount_options, vmt2dataptr(mnt, VMT_ARGS));
+    STRDUP(mounti->mount_path, vmt2dataptr(mnt, VMT_STUB));
+    if (strcmp(vmt2dataptr(mnt, VMT_HOST), "-") != 0)
+        STRDUP(mounti->filesystem_host, vmt2dataptr(mnt, VMT_HOST));
+    STRDUP(mounti->filesystem_path, vmt2dataptr(mnt, VMT_OBJECT));
+    return 0;
+}
+
+
+/** Convert struct vmount member vmt_gfstype into string
+ *
+ * This is a hardcoded list currently, that seems to be the only way it's
+ * defined/available on AIX.
+ */
+static char *
+map_fstype(const int gfstype)
+{
+    char *type;
+
+    switch (gfstype) {
+    case MNT_J2:
+        return psi_strdup("jfs2");
+    case MNT_NAMEFS:
+        return psi_strdup("namefs");
+    case MNT_NFS:
+        return psi_strdup("nfs");
+    case MNT_JFS:
+        return psi_strdup("jfs");
+    case MNT_CDROM:
+        return psi_strdup("cdrom");
+    case MNT_PROCFS:
+        return psi_strdup("proc");
+    case MNT_SFS:
+        return psi_strdup("STREAM");
+    case MNT_CACHEFS:
+        return psi_strdup("cachefs");
+    case MNT_NFS3:
+        return psi_strdup("NFSv3");
+    case MNT_AUTOFS:
+        return psi_strdup("automount");
+    case MNT_VXFS:
+        return psi_strdup("vxfs");
+    case MNT_VXODM:
+        return psi_strdup("veritas");
+    case MNT_UDF:
+        return psi_strdup("UDFS");
+    case MNT_NFS4:
+        return psi_strdup("NFSv4");
+    case MNT_RFS4:
+        return psi_strdup("NFSv4-pseudo");
+    case MNT_CIFS:
+        return psi_strdup("SMBFS");
+    default:
+        psi_asprintf(&type, "%d", gfstype);
+        return type;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/aix_process.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/aix_process.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/aix_process.c
new file mode 100644
index 0000000..8e64150
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/aix_process.c
@@ -0,0 +1,597 @@
+/* The MIT License
+ *
+ * Copyright (C) 2009 Floris Bruynooghe
+ *
+ * Copyright (C) 2009 Abilisoft Ltd.
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/* AIX implementation of the Process classes */
+
+
+/* Note: On AIX if __64BIT__ is defined the LP64 data model is used, otherwise
+ *       ILP23 is used.
+ *
+ * Note2: We use large file APIs to read the core files of processes (aka
+ *        address space, /proc/<pid>/as), read up on large file support:
+ *        http://publib.boulder.ibm.com/infocenter/systems/index.jsp?topic=/com.ibm.aix.genprogc/doc/genprogc/prg_lrg_files.htm */
+
+
+#include <Python.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <paths.h>
+#include <procinfo.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/dir.h>
+#include <sys/proc.h>
+#include <sys/procfs.h>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
+#include <sys/types.h>
+#include <time.h>
+#include <unistd.h>
+
+#include "psi.h"
+#include "process.h"
+#include "posix_utils.h"
+#include "procfs_utils.h"
+
+
+/***** Local declarations *****/
+static int getprocent(struct procentry64 *procbuff, const pid_t pid);
+static int set_bulk(struct psi_process *proci,
+                    const struct procentry64 *procent);
+static int set_args(struct psi_process *proci,
+                    struct procentry64 *procent);
+static int set_env(struct psi_process *proci,
+                   struct procentry64 *procent);
+static int set_cwd(struct psi_process *proci,
+                   const struct procentry64 *procent);
+
+static int get_terminal(const dev64_t ttydev, char **name);
+static int is_tty_file(struct dirent *dirp);
+static void free_dentlist(struct dirent **dentlist, const int ndirs);
+static int mygetargs(struct procentry64 *procbuff, char **args);
+static int args_complete(char *args, const int size);
+static int mygetevars(struct procentry64 *procent, char **evnp);
+
+
+/***** Declare undeclared functions from <procinfo.h> *****/
+/* IMHO <procinfo.h> should declare these, see getprocs(3) and getargs(3) */
+extern int getprocs64(struct procentry64*, int,
+                      struct fdsinfo64*, int, pid32_t*, int);
+extern int getargs(struct procentry64*, int, char*, int);
+extern int getevars(struct procentry64*, int, char*, int);
+
+
+/***** Public interfaces from process.h. *****/
+
+
+/* The process status flags, defined in proc.h. */
+/* XXX Might have to use lwpsinfo.sname instead */
+#define addsflag(CONST) {"PROC_STATUS_"#CONST, CONST}
+struct psi_flag psi_arch_proc_status_flags[] = {
+    addsflag(SNONE),
+    addsflag(SIDL),
+    addsflag(SZOMB),
+    addsflag(SSTOP),
+    addsflag(SACTIVE),
+    addsflag(SSWAP),
+    {NULL, 0}
+};
+
+
+/** Collect all information about a process
+ *
+ * The psinfo variable is so that /proc/<pid>/psinfo only needs to be read
+ * once.
+ */
+struct psi_process *
+psi_arch_process(const pid_t pid)
+{
+    struct psi_process *proci;
+    struct procentry64 procent;
+    int r;
+
+    r = getprocent(&procent, pid);
+    if (r < 0)
+        return NULL;
+    proci = psi_calloc(sizeof(struct psi_process));
+    if (proci == NULL)
+        return NULL;
+    if (set_bulk(proci, &procent) < 0)
+        return psi_free_process(proci);
+    if (set_args(proci, &procent) < 0)
+        return psi_free_process(proci);
+    if (set_env(proci, &procent) < 0)
+        return psi_free_process(proci);
+    if (set_cwd(proci, &procent) < 0)
+        return psi_free_process(proci);
+    return proci;
+}
+
+
+/***** Local functions *****/
+
+
+/** Call getprocs64(3) for exactly 1 PID
+ *
+ * This takes care of boring details and handles errors properly.
+ *
+ * @param procbuff: the procentry64 structure the result will be stored in.
+ * @param pid: the PID of the process to get.
+ *
+ * @return -1 in case of an error, 0 if successful.
+ **/
+static int
+getprocent(struct procentry64 *procbuff, const pid_t pid)
+{
+    pid32_t pid32;
+    int r;
+
+    pid32 = (pid32_t)pid;
+    r = getprocs64(procbuff, sizeof(struct procentry64),
+                   (struct fdsinfo64 *)NULL, 0,
+                   &pid32, 1);
+    if (r < 0) {
+        if (errno == EINVAL)
+            PyErr_Format(PsiExc_NoSuchProcessError,
+                         "No such PID: %lu", (unsigned long)pid);
+        else
+            PyErr_SetFromErrnoWithFilename(PyExc_OSError, "getprocs64()");
+        return -1;
+    }
+    return 0;
+}
+
+
+/** Get all data from the procentry64 structure
+ *
+ * This is a poorly named function.  It gets as much data out of the
+ * procentry64 structure as possible and places it in the psi_process
+ * structure.
+ */
+static int
+set_bulk(struct psi_process *proci, const struct procentry64 *procent)
+{
+    int pagesize;
+    int r;
+
+    proci->name = psi_strdup(procent->pi_comm);
+    if (proci->name == NULL)
+        return -1;
+    proci->name_status = PSI_STATUS_OK;
+    proci->exe = proci->name;
+    proci->exe_status = PSI_STATUS_OK;
+
+    proci->euid = procent->pi_cred.crx_uid;
+    proci->euid_status = PSI_STATUS_OK;
+    proci->ruid = procent->pi_cred.crx_ruid;
+    proci->ruid_status = PSI_STATUS_OK;
+    proci->egid = procent->pi_cred.crx_gid;
+    proci->egid_status = PSI_STATUS_OK;
+    proci->rgid = procent->pi_cred.crx_rgid;
+    proci->rgid_status = PSI_STATUS_OK;
+
+    proci->ppid = procent->pi_ppid;
+    proci->ppid_status = PSI_STATUS_OK;
+    proci->pgrp = procent->pi_pgrp;
+    proci->pgrp_status = PSI_STATUS_OK;
+    proci->sid = procent->pi_sid;
+    proci->sid_status = PSI_STATUS_OK;
+
+    proci->priority = procent->pi_ppri;
+    proci->priority_status = PSI_STATUS_OK;
+    proci->nice = procent->pi_nice;
+    proci->nice_status = PSI_STATUS_OK;
+    proci->start_time.tv_sec = procent->pi_start;
+    proci->start_time.tv_nsec = 0;
+    proci->start_time_status = PSI_STATUS_OK;
+    proci->status = procent->pi_state;
+    proci->status_status = PSI_STATUS_OK;
+    proci->nthreads = procent->pi_thcount;
+    proci->nthreads_status = PSI_STATUS_OK;
+
+    r = get_terminal(procent->pi_ttyd, &proci->terminal);
+    if (r == -1)
+        return -1;
+    else if (r == -2)
+        proci->terminal_status = PSI_STATUS_PRIVS;
+    else
+        proci->terminal_status = PSI_STATUS_OK;
+
+    /* The ru_utime and ru_stime members are `struct timeval64' which claims
+     * to contain microseconds in `tv_usec'.  However all evidence suggests
+     * that it really is nanoseconds: (i) the values stored in it are larger
+     * then 1e6 and (ii) the results do match with ps(1) when treated as
+     * nanoseconds, but not when treated as micoseconds. */
+    proci->utime.tv_sec = procent->pi_ru.ru_utime.tv_sec;
+    proci->utime.tv_nsec = procent->pi_ru.ru_utime.tv_usec;
+    proci->utime_status = PSI_STATUS_OK;
+    proci->stime.tv_sec = procent->pi_ru.ru_stime.tv_sec;
+    proci->stime.tv_nsec = procent->pi_ru.ru_stime.tv_usec;
+    proci->stime_status = PSI_STATUS_OK;
+
+    /* There is a procent.pi_cpu which claims to be a tick count for the first
+     * thread, but I trust this more. */
+    proci->cputime.tv_sec = proci->utime.tv_sec + proci->stime.tv_sec;
+    proci->cputime.tv_sec +=
+        (proci->utime.tv_nsec + proci->stime.tv_nsec)/1000000000;
+    proci->cputime.tv_nsec =
+        (proci->utime.tv_nsec + proci->stime.tv_nsec)%1000000000;
+    proci->cputime_status = PSI_STATUS_OK;
+
+    pagesize = getpagesize();
+    proci->rss = (procent->pi_drss + procent->pi_trss) * pagesize;
+    proci->rss_status = PSI_STATUS_OK;
+    /* This is the same size as returned by ps(1) for VSZ.  I don't believe
+     * it's correct however, it only contains the data sections of the virtual
+     * memory and omits the text size.  None of the other values seem to give
+     * something useful either tho and there is something to be said for
+     * showing what ps shows.  You can see the real value (in pagesizes) by
+     * using "svmon -P <pid>" and look in the "Virtual" column. */
+    proci->vsz = procent->pi_dvm * pagesize;
+    proci->vsz_status = PSI_STATUS_OK;
+
+    return 0;
+}
+
+
+static int
+set_args(struct psi_process *proci, struct procentry64 *procent)
+{
+    char *ptr;
+    int i;
+
+    proci->argc = mygetargs(procent, &proci->command);
+    if (proci->argc == -1)
+        return -1;
+    if (proci->argc == -2) {    /* proc gone walkies */
+        proci->argc_status = PSI_STATUS_NA;
+        proci->argv_status = PSI_STATUS_NA;
+        return 0;
+    }
+    proci->argv = psi_strings_to_array(proci->command, proci->argc);
+    if (proci->argv == NULL)
+        return -1;
+    ptr = proci->command;
+    for (i = 0; i < proci->argc - 1; i++) {
+        while (*ptr != '\0')
+            ptr++;
+        *ptr = ' ';
+    }
+    proci->argc_status = PSI_STATUS_OK;
+    proci->argv_status = PSI_STATUS_OK;
+    proci->command_status = PSI_STATUS_OK;
+    return 0;
+}
+
+
+static int
+set_env(struct psi_process *proci, struct procentry64 *procent)
+{
+    char *envp;
+
+    proci->envc = mygetevars(procent, &envp);
+    if (proci->envc == -1)
+        return -1;
+    if (proci->envc == -2) {    /* proc gone walkies */
+        proci->envc_status = PSI_STATUS_NA;
+        proci->envv_status = PSI_STATUS_NA;
+        return 0;
+    }
+    proci->envv = psi_strings_to_array(envp, proci->envc);
+    psi_free(envp);
+    if (proci->envv == NULL)
+        return -1;
+    proci->envc_status = PSI_STATUS_OK;
+    proci->envv_status = PSI_STATUS_OK;
+    return 0;
+}
+
+
+/** Set the cwd and cwd_status fields of the procinfo structure
+ *
+ * Returns -1 on failure, 0 on success.
+ */
+static int
+set_cwd(struct psi_process *proci, const struct procentry64 *procent)
+{
+    char *fname;
+    char *link;
+    int r;
+
+    r = psi_asprintf(&fname, "/proc/%d/cwd", procent->pi_pid);
+    if (r == -1)
+        return -1;
+    r = psi_readlink(&link, fname);
+    psi_free(fname);
+    if (r == -2) {
+        PyErr_Clear();
+        proci->cwd_status = PSI_STATUS_PRIVS;
+        return 0;
+    } else if (r < 0) {
+        PyErr_Clear();
+        if (procfs_check_pid(procent->pi_pid) < 0)
+            return -1;
+        else {
+            proci->cwd_status = PSI_STATUS_NA;
+            return 0;
+        }
+    } else {
+        proci->cwd = link;
+        proci->cwd_status = PSI_STATUS_OK;
+        return 0;
+    }
+}
+
+
+/** Find the name of a terminal
+ *
+ * This function will look at all files in /dev to find the matching device
+ * number.  When found the `name' parameter will be pointed to a newly
+ * allocated name of the terminal, otherwise it will be set to point to NULL.
+ *
+ * Return 0 if successful, -1 in case of an error and -2 in case of a
+ * permission problem.
+ */
+/* XXX Split this off in two functions. */
+static int
+get_terminal(const dev64_t ttydev, char **name)
+{
+    struct stat64x stat_buff;
+    struct dirent **dentlist;
+    struct dirent *dentp;
+    char ttyname[15] = _PATH_DEV; /* "/dev/console\0" is longest expected */
+    int nfiles;
+    int i;
+    int r;
+
+    *name = NULL;
+
+    /* Check /dev/pts/ files */
+    r = stat64x("/dev/pts/0", &stat_buff);
+    if (r < 0) {
+        PyErr_SetFromErrnoWithFilename(PyExc_OSError, "/dev/pts/0");
+        return -1;
+    }
+    if (major64(ttydev) == major64(stat_buff.st_rdev)) {
+        if (minor64(ttydev) > 99) {
+            PyErr_SetString(PyExc_RuntimeError,
+                            "Minor number can be no larger then 99");
+            return -1;
+        }
+        sprintf(ttyname, "/dev/pts/%d", minor64(ttydev));
+        *name = psi_strdup(ttyname);
+        if (*name == NULL)
+            return -1;
+        return 0;
+    }
+
+    /* Scan for /dev/console and /dev/tty* */
+    nfiles = scandir(_PATH_DEV, &dentlist, &is_tty_file, NULL);
+    if (nfiles < 0) {
+        PyErr_SetString(PyExc_OSError, "Failed to list /dev entries");
+        return -1;
+    }
+    if (nfiles == 0) {
+        free_dentlist(dentlist, nfiles);
+        return 0;
+    }
+    for (i = 0; i < nfiles; i++) {
+        dentp = dentlist[i];
+        if (strlen(ttyname) + strlen(dentp->d_name) + 1 > 15) {
+            PyErr_SetString(PyExc_RuntimeError, "ttyname larger then 14 chars");
+            free_dentlist(dentlist, nfiles);
+            return -1;
+        }
+        strcat(ttyname, dentp->d_name);
+        r = stat64x(ttyname, &stat_buff);
+        if (r < 0) {
+            free_dentlist(dentlist, nfiles);
+            if (errno == EACCES)
+                return -2;
+            else {
+                PyErr_SetFromErrnoWithFilename(PyExc_OSError, ttyname);
+                return -1;
+            }
+        }
+        if (ttydev == stat_buff.st_dev) {
+            free_dentlist(dentlist, nfiles);
+            *name = psi_strdup(ttyname);
+            if (*name == NULL)
+                return -1;
+            return 0;
+        }
+    }
+    free_dentlist(dentlist, nfiles);
+    return 0;
+}
+
+
+static int
+is_tty_file(struct dirent *dirp)
+{
+    if (strncmp(_PATH_TTY, dirp->d_name, strlen(_PATH_TTY)) == 0)
+        return 1;
+    else if (strcmp(_PATH_CONSOLE, dirp->d_name) == 0)
+        return 1;
+    else
+        return 0;
+}
+
+
+static void
+free_dentlist(struct dirent **dentlist, const int ndirs)
+{
+    int i;
+
+    for (i = 0; i < ndirs; i++)
+        free(dentlist[i]);
+    free(dentlist);
+}
+
+
+/** Return list of process arguments, ending in `\0\0'
+ *
+ * This wraps getargs(3) but allocates the string automatically using
+ * psi_malloc() and guarantees the complete argument list is returned.
+ *
+ * Returns -1 in case of an error and -2 if the process is gone.  On success
+ * the number of arguments in the argument list is returned.
+ */
+static int
+mygetargs(struct procentry64 *procbuff, char **args)
+{
+/* XXX nargs should be `usigned int' and args_sz & i `ssize_t' but getargs()
+ * uses int for args_sz bizzarly enough.  --flub */
+    char *ptr;
+    int size = 250;             /* size of `args' */
+    int nargs;
+    int r;
+
+    *args = (char*)psi_malloc(size);
+    if (*args == NULL)
+        return -1;
+    r = getargs(procbuff, sizeof(struct procentry64), *args, size);
+    if (r < 0) {
+        psi_free(*args);
+        if (errno == ESRCH)     /* proc gone walkies */
+            return -2;
+        else {
+            PyErr_SetFromErrnoWithFilename(PyExc_OSError, "getargs()");
+            return -1;
+        }
+    }
+    nargs = args_complete(*args, size);
+    while (nargs < 0) {
+        size += 250;
+        ptr = (char*)psi_realloc(*args, size);
+        if (ptr == NULL) {
+            psi_free(*args);
+            return -1;
+        }
+        *args = ptr;
+        r = getargs(procbuff, sizeof(struct procentry64), *args, size);
+        if (r < 0) {
+            psi_free(*args);
+            if (errno == ESRCH) /* proc gone walkies */
+                return -2;
+            else {
+                PyErr_SetFromErrnoWithFilename(PyExc_OSError, "getargs()");
+                return -1;
+            }
+        }
+        nargs = args_complete(*args, size);
+    }
+    return nargs;
+}
+
+
+/** Check if an argument list is complete
+ *
+ * This function looks for a `\0\0' in the string `args' (which is up too
+ * `size' characters long).  If found it returns the number of `\0'-terminated
+ * strings, excluding the last empty one, otherwise -1 is returned.
+ *
+ * This is useful to check if a getargs(3) call returned the complete argument
+ * list.
+ */
+static int
+args_complete(char *args, const int size)
+{
+    int complete = 0;
+    int nargs = 0;
+    int i;
+
+    for (i = 1; i < size; i++) {
+        if (args[i] == '\0') {
+            if (args[i-1] == '\0') {
+                complete = 1;
+                break;
+            } else
+                nargs++;
+        }
+    }
+    if (!complete)
+        return -1;
+    else
+        return nargs;
+}
+
+
+/** Return list of process environment variables, ending in `\0\0'
+ *
+ * This wraps getevars(3) but allocates the string automatically using
+ * psi_malloc() and guarantees the complete environment is returned.
+ *
+ * Returns -1 in case of an error and -2 if the process is gone.  On success
+ * the number of environment variables in the argument list is returned.
+ */
+static int
+mygetevars(struct procentry64 *procent, char **envp)
+{
+/* XXX `n' should be `usigned int' and args_sz & i `ssize_t' but getargs()
+ * uses `int' for `args_sz' bizzarly enough.  --flub */
+    char *ptr;
+    int size = 250;             /* size of `envp' */
+    int n;                      /* number of environment variables */
+    int r;
+
+    *envp = (char*)psi_malloc(size);
+    if (*envp == NULL)
+        return -1;
+    r = getevars(procent, sizeof(struct procentry64), *envp, size);
+    if (r < 0) {
+        psi_free(*envp);
+        if (errno == ESRCH)     /* proc gone walkies */
+            return -2;
+        else {
+            PyErr_SetFromErrnoWithFilename(PyExc_OSError, "getevars()");
+            return -1;
+        }
+    }
+    n = args_complete(*envp, size);
+    while (n < 0) {
+        size += 250;
+        ptr = (char*)psi_realloc(*envp, size);
+        if (ptr == NULL) {
+            psi_free(*envp);
+            return -1;
+        }
+        *envp = ptr;
+        r = getevars(procent, sizeof(struct procentry64), *envp, size);
+        if (r < 0) {
+            psi_free(*envp);
+            if (errno == ESRCH) /* proc gone walkies */
+                return -2;
+            else {
+                PyErr_SetFromErrnoWithFilename(PyExc_OSError, "getevars()");
+                return -1;
+            }
+        }
+        n = args_complete(*envp, size);
+    }
+    return n;
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/aix_psi.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/aix_psi.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/aix_psi.c
new file mode 100644
index 0000000..09fcb15
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/aix_psi.c
@@ -0,0 +1,89 @@
+/* The MIT License
+ *
+ * Copyright (C) 2009 Floris Bruynooghe
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/* AIX implementation of the _psi functions */
+
+
+#include <Python.h>
+
+#include <libperfstat.h>
+#include <sys/proc.h>
+#include <sys/types.h>
+#include <time.h>
+#include <utmpx.h>
+
+#include "psi.h"
+#include "psifuncs.h"
+#include "posix_utils.h"
+
+
+/***** Public functions *****/
+
+
+int
+arch_boottime(struct timespec *boottime)
+{
+    return posix_utmpx_boottime(boottime);
+}
+
+
+struct loadavginfo *
+arch_loadavginfo(void)
+{
+    struct loadavginfo *loadi;
+    perfstat_cpu_total_t cpu_stats;
+    int r;
+
+    r = perfstat_cpu_total(NULL, &cpu_stats, sizeof(perfstat_cpu_total_t), 1);
+    if (r < 0)
+        return (struct loadavginfo*)PyErr_SetFromErrno(PyExc_OSError);
+    loadi = psi_calloc(sizeof(struct loadavginfo));
+    if (loadi == NULL)
+        return NULL;
+    loadi->one = cpu_stats.loadavg[0] / (double)(1 << SBITS);
+    loadi->five = cpu_stats.loadavg[0] / (double)(1 << SBITS);
+    loadi->fifteen = cpu_stats.loadavg[0] / (double)(1 << SBITS);
+    loadi->loadavg_status = PSI_STATUS_OK;
+    return loadi;
+}
+
+
+int
+arch_uptime(struct timespec *uptime)
+{
+    struct timespec utbt;
+    struct timespec now;
+    struct timeval tvnow;
+
+    if (posix_utmpx_boottime(&utbt) < 0)
+        return -1;
+    if (gettimeofday(&tvnow, NULL) < 0) {
+        PyErr_SetFromErrno(PyExc_OSError);
+        return -1;
+    }
+    now.tv_sec = tvnow.tv_sec;
+    now.tv_nsec = tvnow.tv_usec * 1000;
+    *uptime = posix_timespec_subtract(&now, &utbt);
+    return 0;
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/darwin_mount.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/darwin_mount.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/darwin_mount.c
new file mode 100644
index 0000000..4f965a9
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/darwin_mount.c
@@ -0,0 +1,170 @@
+/* The MIT License
+ *
+ * Copyright (C) 2009 Erick Tryzelaar
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include <Python.h>
+
+#include <sys/param.h>
+#include <sys/ucred.h>
+#include <sys/mount.h>
+
+#include "psi.h"
+#include "mount.h"
+#include "posix_mount.h"
+
+
+/* Pulled from Apple's mount.c */
+static struct opt {
+    int o_opt;
+    const char *o_name;
+} optnames[] = {
+	{ MNT_ASYNC,		"asynchronous" },
+	{ MNT_EXPORTED,		"NFS exported" },
+	{ MNT_LOCAL,		"local" },
+	{ MNT_NODEV,		"nodev" },
+	{ MNT_NOEXEC,		"noexec" },
+	{ MNT_NOSUID,		"nosuid" },
+	{ MNT_QUOTA,		"with quotas" },
+	{ MNT_RDONLY,		"read-only" },
+	{ MNT_SYNCHRONOUS,	"synchronous" },
+	{ MNT_UNION,		"union" },
+	{ MNT_AUTOMOUNTED,	"automounted" },
+	{ MNT_JOURNALED,	"journaled" },
+	{ MNT_DEFWRITE, 	"defwrite" },
+	{ MNT_IGNORE_OWNERSHIP,	"noowners" },
+#ifdef MNT_NOATIME
+	{ MNT_NOATIME,		"noatime" },
+#endif
+#ifdef MNT_QUARANTINE
+	{ MNT_QUARANTINE,	"quarantine" },
+#endif
+	{ 0, 				NULL }
+};
+
+
+#define STRDUP(dst, src)                    \
+{                                           \
+    if ((dst = psi_strdup(src)) == NULL) {  \
+        psi_free_mountlist(ml);             \
+    }                                       \
+    dst ## _status = PSI_STATUS_OK;         \
+}
+
+
+psi_mountlist_t *
+psi_arch_mountlist(const int remote)
+{
+    struct statfs *mp;
+    int count;
+    psi_mountlist_t *ml = NULL;
+    psi_mountinfo_t *mounti, **mounts;
+    char *p;
+
+    /* Get the mount info from the kernel */
+    if ((count = getmntinfo(&mp, MNT_NOWAIT)) == 0) {
+        return (psi_mountlist_t*) PyErr_SetFromErrnoWithFilename(
+            PyExc_OSError, "getmntinfo failed");
+    }
+
+    /* Create our mountlist */
+    ml = (psi_mountlist_t *)psi_calloc(sizeof(psi_mountlist_t));
+    if (ml == NULL) {
+        return NULL;
+    }
+
+    /* Step through each line in the mount data */
+    while (--count >= 0) {
+        struct opt *o;
+        int flags;
+        char options[1024];
+
+        /* Ignore mount type autofs since that filesystem may not actually be
+         * mounted */
+        if (strcmp(mp->f_fstypename, "autofs") == 0) {
+            ++mp;
+            continue;
+        }
+
+	/* Only include a remote fs if asked for */
+	if (!remote && strchr(mp->f_mntfromname, ':') != NULL) {
+		++mp;
+		continue;
+	}
+
+        /* Allocate space for the mount information */
+        if ((mounti = psi_calloc(sizeof(psi_mountinfo_t))) == NULL) {
+            psi_free_mountlist(ml);
+            return NULL;
+        }
+        
+        /* And then allocate more space for the mount list */
+        mounts = (psi_mountinfo_t **)psi_realloc(
+            ml->mounts,
+            (ml->count + 1) * sizeof(psi_mountinfo_t *));
+        if (mounts == NULL) {
+            psi_free_mountinfo(mounti);
+            psi_free_mountlist(ml);
+            return NULL;
+        }
+        ml->mounts = mounts;
+        ml->mounts[ml->count] = mounti;
+        ml->count += 1;
+
+        /* Finally, add all the mntent information to mounti */
+        p = strchr(mp->f_mntfromname, ':');
+        if (p == NULL) {
+            mounti->filesystem_host_status = PSI_STATUS_OK;
+            STRDUP(mounti->filesystem_path, mp->f_mntfromname);
+        } else {
+            *p = '\0';
+
+            STRDUP(mounti->filesystem_host, mp->f_mntfromname);
+            STRDUP(mounti->filesystem_path, p + 1);
+        }
+
+        STRDUP(mounti->mount_type, mp->f_fstypename);
+        STRDUP(mounti->mount_path, mp->f_mntonname);
+
+        /* Convert the flags into a string */
+        flags = mp->f_flags & MNT_VISFLAGMASK;
+        p = options;
+        for (o = optnames; flags && o->o_opt; ++o) {
+            if (flags & o->o_opt) {
+                int i = snprintf(p, 1024 - (p-options),
+                                 "%s%s", p == options ? "" : ",", o->o_name);
+                flags &= ~o->o_opt;
+                p += i;
+            }
+        }
+        STRDUP(mounti->mount_options, options);
+
+	/* Set the statvfs items */
+	posix_set_vfs(mounti);
+
+        /* Advance the mount pointer */
+        ++mp;
+    }
+
+    return ml;
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/darwin_process.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/darwin_process.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/darwin_process.c
new file mode 100644
index 0000000..6fe6dc6
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/darwin_process.c
@@ -0,0 +1,562 @@
+/* The MIT License
+ *
+ * Copyright (C) 2007 Chris Miles
+ *
+ * Copyright (C) 2009 Erick Tryzelaar
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/* Process functions for arch: Mac OS X */
+
+#include <Python.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/sysctl.h>
+#include <sys/fcntl.h>
+#include <pwd.h>
+#include <grp.h>
+#include <mach/shared_memory_server.h>
+#include <mach/mach_init.h>
+#include <mach/mach_interface.h>
+#include <pwd.h>
+#include <grp.h>
+#include <sys/proc.h>
+
+#include "psi.h"
+#include "psifuncs.h"
+#include "process.h"
+
+
+/***** Local declarations *****/
+
+static int get_kinfo_proc(const pid_t pid, struct kinfo_proc *p);
+static int set_exe(struct psi_process *proci, struct kinfo_proc *p);
+static int set_cwd(struct psi_process *proci, struct kinfo_proc *p);
+static int set_kp_proc(struct psi_process *proci, struct kinfo_proc *p);
+static int set_kp_eproc(struct psi_process *proci, struct kinfo_proc *p);
+static int set_task(struct psi_process *proci, struct kinfo_proc *p);
+static int command_from_argv(char **command, char **argv, int argc);
+static struct timespec calc_cputime(const struct timespec utime,
+                                    const struct timespec stime);
+
+
+/***** Public interfaces from process.h. *****/
+
+struct psi_flag psi_arch_proc_status_flags[] = {
+    {"PROC_STATUS_SIDL", SIDL},
+    {"PROC_STATUS_SRUN", SRUN},
+    {"PROC_STATUS_SSLEEP", SSLEEP},
+    {"PROC_STATUS_SSTOP", SSTOP},
+    {"PROC_STATUS_SZOMB", SZOMB},
+    {NULL, 0}};             /* sentinel */
+
+
+struct psi_process *
+psi_arch_process(const pid_t pid)
+{
+    struct kinfo_proc p;
+    struct psi_process *proci;
+
+    if (get_kinfo_proc(pid, &p) == -1) {
+        return NULL;
+    }
+
+    proci = psi_calloc(sizeof(struct psi_process));
+    if (proci == NULL) {
+        return NULL;
+    }
+
+    if (set_exe(proci, &p) == -1) goto cleanup;
+    if (set_cwd(proci, &p) == -1) goto cleanup;
+    if (set_kp_proc(proci, &p) == -1) goto cleanup;
+    if (set_kp_eproc(proci, &p) == -1) goto cleanup;
+    if (set_task(proci, &p) == -1) goto cleanup;
+
+    if (proci->utime_status == PSI_STATUS_PRIVS ||
+                proci->stime_status == PSI_STATUS_PRIVS)
+        proci->cputime_status = PSI_STATUS_PRIVS;
+    else {
+        proci->cputime = calc_cputime(proci->utime, proci->stime);
+        proci->cputime_status = PSI_STATUS_OK;
+    }
+
+    if (proci->command_status == PSI_STATUS_PRIVS) {
+        /* Ensure Process.command always has a value, as per our
+         * contract with the user.
+         */
+        proci->command = psi_strdup("");
+        proci->command_status = PSI_STATUS_OK;
+    }
+    
+    return proci;
+
+  cleanup:
+    psi_free_process(proci);
+    return NULL;
+}
+
+
+/***** Local functions *****/
+
+
+static int
+get_kinfo_proc(const pid_t pid, struct kinfo_proc *proc)
+{
+    int name[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, pid };
+    size_t size;
+
+    size = sizeof(struct kinfo_proc);
+
+    /* We use sysctl here instead of psi_sysctl because we know the size of
+     * the destination already so we don't need to malloc anything. */
+    if (sysctl((int*)name, 4, proc, &size, NULL, 0) == -1) {
+        PyErr_SetFromErrno(PyExc_OSError);
+        return -1;
+    }
+
+    /* sysctl stores 0 in the size if we can't find the process information */
+    if (size == 0) {
+        PyErr_Format(PsiExc_NoSuchProcessError, "No such PID: %ld", (long)pid);
+        return -1;
+    }
+
+    return 0;
+}
+
+
+/** Find the executable, argument list and environment
+ *
+ * This will also fill in the command attribute.
+ *
+ * The sysctl calls here don't use a wrapper as in darwin_prcesstable.c since
+ * they know the size of the returned structure already.
+ *
+ * The layout of the raw argument space is documented in start.s, which is
+ * part of the Csu project.  In summary, it looks like:
+ *
+ * XXX: This layout does not match whith what the code does.  The code seems
+ * to think exec_path is in between the first argc and arg[0], also the data
+ * returned by ssyctl() seems to be starting at the first argc according to
+ * the code.
+ *
+ * /---------------\ 0x00000000
+ * :               :
+ * :               :
+ * |---------------|
+ * | argc          |
+ * |---------------|
+ * | arg[0]        |
+ * |---------------|
+ * :               :
+ * :               :
+ * |---------------|
+ * | arg[argc - 1] |
+ * |---------------|
+ * | 0             |
+ * |---------------|
+ * | env[0]        |
+ * |---------------|
+ * :               :
+ * :               :
+ * |---------------|
+ * | env[n]        |
+ * |---------------|
+ * | 0             |
+ * |---------------| <-- Beginning of data returned by sysctl() is here.
+ * | argc          |
+ * |---------------|
+ * | exec_path     |
+ * |:::::::::::::::|
+ * |               |
+ * | String area.  |
+ * |               |
+ * |---------------| <-- Top of stack.
+ * :               :
+ * :               :
+ * \---------------/ 0xffffffff
+ */
+static int
+set_exe(struct psi_process *proci, struct kinfo_proc *p)
+{
+    int mib[3], argmax, nargs;
+    size_t size;
+    char *procargs, *cp;
+    int i;
+    int env_start = 0;
+
+    /* Get the maximum process arguments size. */
+    mib[0] = CTL_KERN;
+    mib[1] = KERN_ARGMAX;
+    size = sizeof(argmax);
+
+    if (sysctl(mib, 2, &argmax, &size, NULL, 0) == -1) {
+        PyErr_SetFromErrnoWithFilename(PyExc_OSError, "sysctl() argmax");
+        return -1;
+    }
+
+    /* Allocate space for the arguments. */
+    procargs = (char *)psi_malloc(argmax);
+    if (procargs == NULL)
+        return -1;
+
+    /* Make a sysctl() call to get the raw argument space of the process. */
+    mib[0] = CTL_KERN;
+    mib[1] = KERN_PROCARGS2;
+    mib[2] = p->kp_proc.p_pid;
+
+    size = (size_t)argmax;
+
+    if (sysctl(mib, 3, procargs, &size, NULL, 0) == -1) {
+        /* We failed to get the exe info, but it's not fatal. We probably just
+         * didn't have permission to access the KERN_PROCARGS2 for this
+         * process. */
+        psi_free(procargs);
+        proci->exe_status  = PSI_STATUS_PRIVS;
+        proci->argc_status = PSI_STATUS_PRIVS;
+        proci->argv_status = PSI_STATUS_PRIVS;
+        proci->envc_status = PSI_STATUS_PRIVS;
+        proci->envv_status = PSI_STATUS_PRIVS;
+        proci->command_status = PSI_STATUS_PRIVS;
+        return 0;
+    }
+
+    memcpy(&nargs, procargs, sizeof(nargs));
+    cp = procargs + sizeof(nargs);
+
+    /* Save the exe */
+    proci->exe = psi_strdup(cp);
+    if (proci->exe == NULL) {
+        psi_free(procargs);
+        return -1;
+    }
+    proci->exe_status = PSI_STATUS_OK;
+
+    /* Skip over the exe. */
+    cp += strlen(cp);
+    if (cp == &procargs[size]) {
+        psi_free(procargs);
+        PyErr_SetString(PyExc_OSError, "Did not find args and env");
+        return -1;
+    }
+
+    /* Skip trailing '\0' characters. */
+    for (; cp < &procargs[size]; cp++) {
+        if (*cp != '\0') {
+            /* Beginning of first argument reached. */
+            break;
+        }
+    }
+    if (cp == &procargs[size]) {
+        psi_free(procargs);
+        /* We dont' have any arguments or environment */
+        if (nargs == 0) {
+            proci->argc = 0;
+            proci->argc_status = PSI_STATUS_OK;
+            proci->argv = NULL;
+            proci->argv_status = PSI_STATUS_OK;
+            proci->envc = 0;
+            proci->envc_status = PSI_STATUS_OK;
+            proci->envv = NULL;
+            proci->envv_status = PSI_STATUS_OK;
+            /* Update proci->command */
+            if (command_from_argv(&proci->command, proci->argv, proci->argc) < 0) {
+                psi_free(procargs);
+                return -1;
+            }
+            proci->command_status = PSI_STATUS_OK;
+            return 0;
+        } else {
+            PyErr_SetString(PyExc_OSError, "Did not find args and env");
+            return -1;
+        }
+    }
+
+    /* The argument list */
+    proci->argc = nargs;
+    proci->argc_status = PSI_STATUS_OK;
+    proci->argv = psi_strings_to_array(cp, nargs);
+    if (proci->argv == NULL) {
+        psi_free(procargs);
+        return -1;
+    }
+    proci->argv_status = PSI_STATUS_OK;
+    if (command_from_argv(&proci->command, proci->argv, proci->argc) < 0) {
+        psi_free(procargs);
+        return -1;
+    }
+    proci->command_status = PSI_STATUS_OK;
+
+    /* The environment */
+    for (i = 0; i < nargs; i++) {
+        env_start += strlen(proci->argv[i])+1;
+    }
+    env_start--;
+    proci->envc = 0;
+    for (i = 0; ; i++) {
+        if (*(cp+env_start + i) == '\0') {
+            if (*(cp+env_start + i + 1) == '\0')
+                break;
+            else
+                proci->envc++;
+        }
+    }
+    proci->envc_status = PSI_STATUS_OK;
+    proci->envv = psi_strings_to_array(cp+env_start+1, proci->envc);
+    psi_free(procargs);
+    if (proci->envv == NULL)
+        return -1;
+    proci->envv_status = PSI_STATUS_OK;
+
+    return 0;
+}
+
+
+static int
+command_from_argv(char **command, char **argv, int argc){
+    int i;
+    int command_len = 0;
+    int offset=0;
+    
+    for (i=0; i<argc; i++)
+        command_len += strlen(argv[i]) + 1;
+    *command = psi_malloc(command_len);
+    if (*command == NULL) {
+        return -1;
+    }
+    for (i=0; i<argc; i++) {
+        strcpy(*command+offset, argv[i]);
+        *(*command + offset + strlen(argv[i])) = ' ';
+        offset = offset + strlen(argv[i]) + 1;
+    }
+    *(*command + offset - 1) = '\0';
+    
+    return 0;
+}
+
+
+static int
+set_cwd(struct psi_process *proci, struct kinfo_proc *p)
+{
+    /*
+     * Current working directory of a process is not available on the mac...
+     * Ref http://bitbucket.org/chrismiles/psi/issue/4/implement-processcwd-for-darwin
+     */
+    proci->cwd_status = PSI_STATUS_NA;
+    return 0;
+}
+
+
+static int
+set_kp_proc(struct psi_process *proci, struct kinfo_proc *p)
+{
+    proci->name = psi_strdup(p->kp_proc.p_comm);
+    if (proci->name == NULL)
+        return -1;
+    proci->name_status = PSI_STATUS_OK;
+
+    proci->nice = p->kp_proc.p_nice;
+    proci->nice_status = PSI_STATUS_OK;
+
+    proci->priority = p->kp_proc.p_priority;
+    proci->priority_status = PSI_STATUS_OK;
+
+    proci->status = p->kp_proc.p_stat;
+    proci->status_status = PSI_STATUS_OK;
+
+    proci->start_time.tv_sec = p->kp_proc.p_starttime.tv_sec;
+    proci->start_time.tv_nsec = p->kp_proc.p_starttime.tv_usec * 1000;
+    proci->start_time_status = PSI_STATUS_OK;
+
+    return 0;
+}
+
+
+static int
+set_kp_eproc(struct psi_process *proci, struct kinfo_proc *p)
+{
+    dev_t tdev;
+    char *ttname;
+
+    proci->egid = p->kp_eproc.e_pcred.p_svgid;
+    proci->egid_status = PSI_STATUS_OK;
+
+    proci->euid = p->kp_eproc.e_pcred.p_svuid;
+    proci->euid_status = PSI_STATUS_OK;
+
+    proci->pgrp = p->kp_eproc.e_pgid;
+    proci->pgrp_status = PSI_STATUS_OK;
+
+    proci->ppid = p->kp_eproc.e_ppid;
+    proci->ppid_status = PSI_STATUS_OK;
+
+    proci->rgid = p->kp_eproc.e_pcred.p_rgid;
+    proci->rgid_status = PSI_STATUS_OK;
+
+    proci->ruid = p->kp_eproc.e_pcred.p_ruid;
+    proci->ruid_status = PSI_STATUS_OK;
+
+    proci->sid = (int)p->kp_eproc.e_sess;
+    proci->sid_status = PSI_STATUS_OK;
+
+    tdev = p->kp_eproc.e_tdev;
+    if (tdev != NODEV && (ttname = devname(tdev, S_IFCHR)) != NULL) {
+        /* Prepend with "/dev/" for compatibility with other architectures */
+        char terminaldev[64] = "/dev/";
+        strncat(terminaldev, ttname, 64);
+
+        proci->terminal = psi_strdup(terminaldev);
+        proci->terminal_status = PSI_STATUS_OK;
+    } else {
+        proci->terminal = psi_strdup("");
+        proci->terminal_status = PSI_STATUS_OK;
+    }
+
+    return 0;
+}
+
+
+static int
+set_task(struct psi_process *proci, struct kinfo_proc *p)
+{
+    task_port_t task;
+    unsigned int info_count;
+    struct task_basic_info tasks_info;
+    thread_array_t thread_list;
+    unsigned int thread_count;
+
+
+    if (task_for_pid(mach_task_self(),
+                     p->kp_proc.p_pid, &task) != KERN_SUCCESS) {
+        proci->pcpu_status     = PSI_STATUS_PRIVS;
+        proci->utime_status    = PSI_STATUS_PRIVS;
+        proci->stime_status    = PSI_STATUS_PRIVS;
+        proci->nthreads_status = PSI_STATUS_PRIVS;
+        proci->rss_status      = PSI_STATUS_PRIVS;
+        proci->vsz_status      = PSI_STATUS_PRIVS;
+        return 0;
+    }
+
+    if (task_threads(task, &thread_list, &thread_count) == KERN_SUCCESS) {
+        int i;
+        struct timespec utime = { 0, 0 };
+        struct timespec stime = { 0, 0 };
+        int t_cpu = 0;
+        int failed = 0;
+
+        proci->nthreads = thread_count;
+        proci->nthreads_status = PSI_STATUS_OK;
+
+        for (i = 0; i < thread_count; ++i) {
+            struct thread_basic_info t_info;
+            unsigned int             icount = THREAD_BASIC_INFO_COUNT;
+
+            if (thread_info(thread_list[i], THREAD_BASIC_INFO,
+                            (thread_info_t)&t_info, &icount) == KERN_SUCCESS) {
+                utime.tv_sec  += t_info.user_time.seconds;
+                utime.tv_nsec += t_info.user_time.microseconds * 1000;
+                stime.tv_sec  += t_info.system_time.seconds;
+                stime.tv_nsec += t_info.system_time.microseconds * 1000;
+                t_cpu         += t_info.cpu_usage;
+            } else {
+                failed = 1;
+            }
+        }
+
+        if (failed) {
+            proci->pcpu_status  = PSI_STATUS_PRIVS;
+            proci->utime_status = PSI_STATUS_PRIVS;
+            proci->stime_status = PSI_STATUS_PRIVS;
+        } else {
+            proci->pcpu = 100.0 * (double)(t_cpu) / TH_USAGE_SCALE;
+            proci->pcpu_status = PSI_STATUS_OK;
+
+            proci->utime = utime;
+            proci->utime_status = PSI_STATUS_OK;
+
+            proci->stime = stime;
+            proci->stime_status = PSI_STATUS_OK;
+        }
+    } else {
+        proci->pcpu_status     = PSI_STATUS_PRIVS;
+        proci->utime_status    = PSI_STATUS_PRIVS;
+        proci->stime_status    = PSI_STATUS_PRIVS;
+        proci->nthreads_status = PSI_STATUS_PRIVS;
+    }
+    vm_deallocate(mach_task_self(),
+        (vm_address_t)thread_list, sizeof(thread_array_t)*(thread_count));
+
+    info_count = TASK_BASIC_INFO_COUNT;
+    if (task_info(task, TASK_BASIC_INFO,
+                  (task_info_t)&tasks_info, &info_count) == KERN_SUCCESS) {
+        vm_region_basic_info_data_64_t  b_info;
+        vm_address_t                    address = GLOBAL_SHARED_TEXT_SEGMENT;
+        vm_size_t                       size;
+        mach_port_t                     object_name;
+
+        /*
+         * try to determine if this task has the split libraries mapped in... if
+         * so, adjust its virtual size down by the 2 segments that are used for
+         * split libraries
+         */
+        info_count = VM_REGION_BASIC_INFO_COUNT_64;
+        if (vm_region_64(task, &address, &size, VM_REGION_BASIC_INFO,
+                        (vm_region_info_t)&b_info, &info_count,
+                        &object_name) == KERN_SUCCESS) {
+            if (b_info.reserved && size == (SHARED_TEXT_REGION_SIZE) &&
+                    tasks_info.virtual_size >
+                    (SHARED_TEXT_REGION_SIZE + SHARED_DATA_REGION_SIZE)) {
+                tasks_info.virtual_size -=
+                    (SHARED_TEXT_REGION_SIZE + SHARED_DATA_REGION_SIZE);
+            }
+        }
+
+        proci->rss        = tasks_info.resident_size;
+        proci->rss_status = PSI_STATUS_OK;
+        proci->vsz        = tasks_info.virtual_size;
+        proci->vsz_status = PSI_STATUS_OK;
+    } else {
+        proci->rss_status = PSI_STATUS_PRIVS;
+        proci->vsz_status = PSI_STATUS_PRIVS;
+    }
+
+    return 0;
+}
+
+/** Calculate the cputime from utime and stime
+ *
+ * This really just adds two struct timespec values together.
+ */
+static struct timespec
+calc_cputime(const struct timespec utime, const struct timespec stime)
+{
+    struct timespec cputime;
+
+    cputime.tv_sec = utime.tv_sec + stime.tv_sec;
+    cputime.tv_nsec = (utime.tv_nsec + stime.tv_nsec) % 1000000000;
+    cputime.tv_sec += (utime.tv_nsec + stime.tv_nsec) / 1000000000;
+    return cputime;
+}
+


[27/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code

Posted by rl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/figleaf/internals.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/figleaf/internals.py b/tools/bin/ext/figleaf/internals.py
new file mode 100644
index 0000000..6a25c0e
--- /dev/null
+++ b/tools/bin/ext/figleaf/internals.py
@@ -0,0 +1,257 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""
+Coverage tracking internals.
+"""
+
+import sys
+import threading
+
+err = sys.stderr
+
+import types, symbol
+
+# use builtin sets if in >= 2.4, otherwise use 'sets' module.
+try:
+    set()
+except NameError:
+    from sets import Set as set
+
+def get_interesting_lines(code):
+    """
+    Count 'interesting' lines of Python in a code object, where
+    'interesting' is defined as 'lines that could possibly be
+    executed'.
+
+    This is done by dissassembling the code objecte and returning
+    line numbers.
+    """
+
+    # clean up weird end-of-file issues
+
+    lines = set([ l for (o, l) in findlinestarts(code) ])
+    for const in code.co_consts:
+        if type(const) == types.CodeType:
+            lines.update(get_interesting_lines(const))
+
+    return lines
+
+def findlinestarts(code):
+    """Find the offsets in a byte code which are start of lines in the source.
+
+    Generate pairs (offset, lineno) as described in Python/compile.c.
+
+    CTB -- swiped from Python 2.5, module 'dis', so that earlier versions
+    of Python could use the function, too.
+    """
+    byte_increments = [ord(c) for c in code.co_lnotab[0::2]]
+    line_increments = [ord(c) for c in code.co_lnotab[1::2]]
+
+    lastlineno = None
+    lineno = code.co_firstlineno
+    addr = 0
+    for byte_incr, line_incr in zip(byte_increments, line_increments):
+        if byte_incr:
+            if lineno != lastlineno:
+                yield (addr, lineno)
+                lastlineno = lineno
+            addr += byte_incr
+        lineno += line_incr
+    if lineno != lastlineno:
+        yield (addr, lineno)
+
+class CodeTracer:
+    """
+    Basic mechanisms for code coverage tracking, using sys.settrace.  
+    """
+    def __init__(self, exclude_prefix, include_only_prefix):
+        self.common = self.c = set()
+        self.section_name = None
+        self.sections = {}
+        
+        self.started = False
+
+        assert not (exclude_prefix and include_only_prefix), \
+               "mutually exclusive"
+        
+        self.excl = exclude_prefix
+        self.incl = include_only_prefix
+
+    def start(self):
+        """
+        Start recording.
+        """
+        if not self.started:
+            self.started = True
+
+            if self.excl and not self.incl:
+                global_trace_fn = self.g1
+            elif self.incl and not self.excl:
+                global_trace_fn = self.g2
+            else:
+                global_trace_fn = self.g0
+
+            sys.settrace(global_trace_fn)
+
+            if hasattr(threading, 'settrace'):
+                threading.settrace(global_trace_fn)
+
+    def stop(self):
+        if self.started:
+            sys.settrace(None)
+            
+            if hasattr(threading, 'settrace'):
+                threading.settrace(None)
+
+            self.started = False
+            self.stop_section()
+
+    def g0(self, f, e, a):
+        """
+        global trace function, no exclude/include info.
+
+        f == frame, e == event, a == arg        .
+        """
+        if e == 'call':
+            return self.t
+
+    def g1(self, f, e, a):
+        """
+        global trace function like g0, but ignores files starting with
+        'self.excl'.
+        """
+        if e == 'call':
+            excl = self.excl
+            path = f.f_globals.get('__file__')
+            if path is None:
+                path = f.f_code.co_filename
+
+            if excl and path.startswith(excl):
+                return
+
+            return self.t
+
+    def g2(self, f, e, a):
+        """
+        global trace function like g0, but only records files starting with
+        'self.incl'.
+        """
+        if e == 'call':
+            incl = self.incl
+            if incl and f.f_code.co_filename.startswith(incl):
+                return self.t
+
+    def t(self, f, e, a):
+        """
+        local trace function.
+        """
+        if e is 'line':
+            self.c.add((f.f_code.co_filename, f.f_lineno))
+        return self.t
+
+    def clear(self):
+        """
+        wipe out coverage info
+        """
+
+        self.c = {}
+
+    def start_section(self, name):
+        self.stop_section()
+
+        self.section_name = name
+        self.c = self.sections.get(name, set())
+        
+    def stop_section(self):
+        if self.section_name:
+            self.sections[self.section_name] = self.c
+            self.section_name = None
+            self.c = self.common
+
+class CoverageData:
+    """
+    A class to manipulate and combine data from the CodeTracer object.
+
+    In general, do not pickle this object; it's simpler and more
+    straightforward to just pass the basic Python objects around
+    (e.g. CoverageData.common, a set, and CoverageData.sections, a
+    dictionary of sets).
+    """
+    def __init__(self, trace_obj=None):
+        self.common = set()
+        self.sections = {}
+        
+        if trace_obj:
+            self.update(trace_obj)
+            
+    def update(self, trace_obj):
+        # transfer common-block code coverage -- if no sections are set,
+        # this will be all of the code coverage info.
+        self.common.update(trace_obj.common)
+
+        # update our internal section dictionary with the (filename, line_no)
+        # pairs from the section coverage as well.
+        
+        for section_name, section_d in trace_obj.sections.items():
+            section_set = self.sections.get(section_name, set())
+            section_set.update(section_d)
+            self.sections[section_name] = section_set
+
+    def gather_files(self, name=None):
+        """
+        Return the dictionary of lines of executed code; the dict
+        keys are filenames and values are sets containing individual
+        (integer) line numbers.
+        
+        'name', if set, is the desired section name from which to gather
+        coverage info.
+        """
+        cov = set()
+        cov.update(self.common)
+
+        if name is None:
+            for section_name, coverage_set in self.sections.items():
+                cov.update(coverage_set)
+        else:
+            coverage_set = self.sections.get(name, set())
+            cov.update(coverage_set)
+            
+#        cov = list(cov)
+#        cov.sort()
+
+        files = {}
+        for (filename, line) in cov:    # @CTB could optimize
+            d = files.get(filename, set())
+            d.add(line)
+            files[filename] = d
+
+        return files
+
+    def gather_sections(self, file):
+        """
+        Return a dictionary of sets containing section coverage information for
+        a specific file.  Dict keys are sections, and the dict values are
+        sets containing (integer) line numbers.
+        """
+        sections = {}
+        for k, c in self.sections.items():
+            s = set()
+            for (filename, line) in c.keys():
+                if filename == file:
+                    s.add(line)
+            sections[k] = s
+        return sections

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/figleaf/nose_sections.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/figleaf/nose_sections.py b/tools/bin/ext/figleaf/nose_sections.py
new file mode 100644
index 0000000..09654a5
--- /dev/null
+++ b/tools/bin/ext/figleaf/nose_sections.py
@@ -0,0 +1,133 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""
+figleafsections plugin for nose.
+
+Automatically records coverage info for Python tests and connects it with
+with test was being run at the time.  Can be used to produce a "barcode"
+of code execution.
+"""
+
+DEFAULT_COVERAGE_FILE='.figleaf_sections'
+import pkg_resources
+
+try:
+    pkg_resources.require('figleaf>=0.6.1')
+    import figleaf
+except ImportError:
+    figleaf = None
+
+import sys
+err = sys.stderr
+
+import nose.case
+from nose.plugins.base import Plugin
+
+import logging
+import os
+
+log = logging.getLogger(__name__)
+
+def calc_testname(test):
+    """
+    Build a reasonably human-readable testname from each test.
+    """
+    name = str(test)
+    if ' ' in name:
+        name = name.split(' ')[1]
+
+    return name
+
+class FigleafSections(Plugin):
+    def __init__(self):
+        self.name = 'figleafsections'
+        Plugin.__init__(self)
+        self.testname = None
+
+    def add_options(self, parser, env=os.environ):
+        env_opt = 'NOSE_WITH_%s' % self.name.upper()
+        env_opt.replace('-', '_')
+        parser.add_option("--with-%s" % self.name,
+                          action="store_true",
+                          dest=self.enableOpt,
+                          default=env.get(env_opt),
+                          help="Enable plugin %s: %s [%s]" %
+                          (self.__class__.__name__, self.help(), env_opt))
+
+        parser.add_option("--figleaf-file",
+                          action="store",
+                          dest="figleaf_file",
+                          default=None,
+                          help="Store figleaf section coverage in this file")
+        
+    def configure(self, options, config):
+        """
+        Configure: enable plugin?  And if so, where should the coverage
+        info be placed?
+        """
+        self.conf = config
+
+        # enable?
+        if hasattr(options, self.enableOpt):
+            self.enabled = getattr(options, self.enableOpt)
+
+        ### save coverage file name, if given.
+        if options.figleaf_file:
+            self.figleaf_file = options.figleaf_file
+        else:
+            self.figleaf_file = DEFAULT_COVERAGE_FILE
+
+        if self.enabled and figleaf is None:
+                raise Exception("You must install figleaf 0.6.1 before you can use the figleafsections plugin! See http://darcs.idyll.org/~t/projects/figleaf/doc/")
+
+    def begin(self):
+        """
+        Initialize: start recording coverage info.
+        """
+        figleaf.start()
+
+    def finalize(self, result):
+        """
+        Finalize: stop recording coverage info, save & exit.
+        """
+        figleaf.stop()
+        
+        fp = open(self.figleaf_file, 'w')
+        figleaf.dump_pickled_coverage(fp)
+        fp.close()
+
+    def startTest(self, test):
+        """
+        Run at the beginning of each test, before per-test fixtures.
+
+        One weakness is that this is only run for specific kinds of
+        nose testcases.
+        """
+        if isinstance(test, nose.case.Test):
+           
+            self.testname = calc_testname(test)
+            assert self.testname
+
+            figleaf.start_section(self.testname)
+
+    def stopTest(self, test):
+        """
+        Run at the end of each test, after per-test fixtures.
+        """
+        if self.testname:
+            figleaf.stop_section()
+            self.testname = None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/pg8000/__init__.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/pg8000/__init__.py b/tools/bin/ext/pg8000/__init__.py
new file mode 100644
index 0000000..57de8e8
--- /dev/null
+++ b/tools/bin/ext/pg8000/__init__.py
@@ -0,0 +1,37 @@
+# vim: sw=4:expandtab:foldmethod=marker
+#
+# Copyright (c) 2007-2009, Mathieu Fenniak
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+# * The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+__author__ = "Mathieu Fenniak"
+
+import dbapi as DBAPI
+pg8000_dbapi = DBAPI
+
+from interface import *
+from types import Bytea
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/pg8000/dbapi.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/pg8000/dbapi.py b/tools/bin/ext/pg8000/dbapi.py
new file mode 100644
index 0000000..3f90188
--- /dev/null
+++ b/tools/bin/ext/pg8000/dbapi.py
@@ -0,0 +1,621 @@
+# vim: sw=4:expandtab:foldmethod=marker
+#
+# Copyright (c) 2007-2009, Mathieu Fenniak
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+# * The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+__author__ = "Mathieu Fenniak"
+
+import datetime
+import time
+import interface
+import types
+import threading
+from errors import *
+
+from warnings import warn
+
+##
+# The DBAPI level supported.  Currently 2.0.  This property is part of the
+# DBAPI 2.0 specification.
+apilevel = "2.0"
+
+##
+# Integer constant stating the level of thread safety the DBAPI interface
+# supports.  This DBAPI interface supports sharing of the module, connections,
+# and cursors.  This property is part of the DBAPI 2.0 specification.
+threadsafety = 3
+
+##
+# String property stating the type of parameter marker formatting expected by
+# the interface.  This value defaults to "format".  This property is part of
+# the DBAPI 2.0 specification.
+# <p>
+# Unlike the DBAPI specification, this value is not constant.  It can be
+# changed to any standard paramstyle value (ie. qmark, numeric, named, format,
+# and pyformat).
+paramstyle = 'format' # paramstyle can be changed to any DB-API paramstyle
+
+def convert_paramstyle(src_style, query, args):
+    # I don't see any way to avoid scanning the query string char by char,
+    # so we might as well take that careful approach and create a
+    # state-based scanner.  We'll use int variables for the state.
+    #  0 -- outside quoted string
+    #  1 -- inside single-quote string '...'
+    #  2 -- inside quoted identifier   "..."
+    #  3 -- inside escaped single-quote string, E'...'
+    
+    if args is None:
+        return  query, args
+    
+    state = 0
+    output_query = ""
+    output_args = []
+    if src_style == "numeric":
+        output_args = args
+    elif src_style in ("pyformat", "named"):
+        mapping_to_idx = {}
+    i = 0
+    while 1:
+        if i == len(query):
+            break
+        c = query[i]
+        # print "begin loop", repr(i), repr(c), repr(state)
+        if state == 0:
+            if c == "'":
+                i += 1
+                output_query += c
+                state = 1
+            elif c == '"':
+                i += 1
+                output_query += c
+                state = 2
+            elif c == 'E':
+                # check for escaped single-quote string
+                i += 1
+                if i < len(query) and i > 1 and query[i] == "'":
+                    i += 1
+                    output_query += "E'"
+                    state = 3
+                else:
+                    output_query += c
+            elif src_style == "qmark" and c == "?":
+                i += 1
+                param_idx = len(output_args)
+                if param_idx == len(args):
+                    raise QueryParameterIndexError("too many parameter fields, not enough parameters")
+                output_args.append(args[param_idx])
+                output_query += "$" + str(param_idx + 1)
+            elif src_style == "numeric" and c == ":":
+                i += 1
+                if i < len(query) and i > 1 and query[i].isdigit():
+                    output_query += "$" + query[i]
+                    i += 1
+                else:
+                    raise QueryParameterParseError("numeric parameter : does not have numeric arg")
+            elif src_style == "named" and c == ":":
+                name = ""
+                while 1:
+                    i += 1
+                    if i == len(query):
+                        break
+                    c = query[i]
+                    if c.isalnum() or c == '_':
+                        name += c
+                    else:
+                        break
+                if name == "":
+                    raise QueryParameterParseError("empty name of named parameter")
+                idx = mapping_to_idx.get(name)
+                if idx == None:
+                    idx = len(output_args)
+                    output_args.append(args[name])
+                    idx += 1
+                    mapping_to_idx[name] = idx
+                output_query += "$" + str(idx)
+            elif src_style == "format" and c == "%":
+                i += 1
+                if i < len(query) and i > 1:
+                    if query[i] == "s":
+                        param_idx = len(output_args)
+                        if param_idx == len(args):
+                            raise QueryParameterIndexError("too many parameter fields, not enough parameters")
+                        output_args.append(args[param_idx])
+                        output_query += "$" + str(param_idx + 1)
+                    elif query[i] == "%":
+                        output_query += "%"
+                    else:
+                        raise QueryParameterParseError("Only %s and %% are supported")
+                    i += 1
+                else:
+                    raise QueryParameterParseError("format parameter % does not have format code")
+            elif src_style == "pyformat" and c == "%":
+                i += 1
+                if i < len(query) and i > 1:
+                    if query[i] == "(":
+                        i += 1
+                        # begin mapping name
+                        end_idx = query.find(')', i)
+                        if end_idx == -1:
+                            raise QueryParameterParseError("began pyformat dict read, but couldn't find end of name")
+                        else:
+                            name = query[i:end_idx]
+                            i = end_idx + 1
+                            if i < len(query) and query[i] == "s":
+                                i += 1
+                                idx = mapping_to_idx.get(name)
+                                if idx == None:
+                                    idx = len(output_args)
+                                    output_args.append(args[name])
+                                    idx += 1
+                                    mapping_to_idx[name] = idx
+                                output_query += "$" + str(idx)
+                            else:
+                                raise QueryParameterParseError("format not specified or not supported (only %(...)s supported)")
+                    elif query[i] == "%":
+                        output_query += "%"
+                    elif query[i] == "s":
+                        # we have a %s in a pyformat query string.  Assume
+                        # support for format instead.
+                        i -= 1
+                        src_style = "format"
+                    else:
+                        raise QueryParameterParseError("Only %(name)s, %s and %% are supported")
+            else:
+                i += 1
+                output_query += c
+        elif state == 1:
+            output_query += c
+            i += 1
+            if c == "'":
+                # Could be a double ''
+                if i < len(query) and query[i] == "'":
+                    # is a double quote.
+                    output_query += query[i]
+                    i += 1
+                else:
+                    state = 0
+            elif src_style in ("pyformat","format") and c == "%":
+                # hm... we're only going to support an escaped percent sign
+                if i < len(query):
+                    if query[i] == "%":
+                        # good.  We already output the first percent sign.
+                        i += 1
+                    else:
+                        raise QueryParameterParseError("'%" + query[i] + "' not supported in quoted string")
+        elif state == 2:
+            output_query += c
+            i += 1
+            if c == '"':
+                state = 0
+            elif src_style in ("pyformat","format") and c == "%":
+                # hm... we're only going to support an escaped percent sign
+                if i < len(query):
+                    if query[i] == "%":
+                        # good.  We already output the first percent sign.
+                        i += 1
+                    else:
+                        raise QueryParameterParseError("'%" + query[i] + "' not supported in quoted string")
+        elif state == 3:
+            output_query += c
+            i += 1
+            if c == "\\":
+                # check for escaped single-quote
+                if i < len(query) and query[i] == "'":
+                    output_query += "'"
+                    i += 1
+            elif c == "'":
+                state = 0
+            elif src_style in ("pyformat","format") and c == "%":
+                # hm... we're only going to support an escaped percent sign
+                if i < len(query):
+                    if query[i] == "%":
+                        # good.  We already output the first percent sign.
+                        i += 1
+                    else:
+                        raise QueryParameterParseError("'%" + query[i] + "' not supported in quoted string")
+
+    return output_query, tuple(output_args)
+
+def require_open_cursor(fn):
+    def _fn(self, *args, **kwargs):
+        if self.cursor == None:
+            raise CursorClosedError()
+        return fn(self, *args, **kwargs)
+    return _fn
+
+##
+# The class of object returned by the {@link #ConnectionWrapper.cursor cursor method}.
+class CursorWrapper(object):
+    def __init__(self, conn, connection):
+        self.cursor = interface.Cursor(conn)
+        self.arraysize = 1
+        self._connection = connection
+        self._override_rowcount = None
+
+    ##
+    # This read-only attribute returns a reference to the connection object on
+    # which the cursor was created.
+    # <p>
+    # Stability: Part of a DBAPI 2.0 extension.  A warning "DB-API extension
+    # cursor.connection used" will be fired.
+    connection = property(lambda self: self._getConnection())
+
+    def _getConnection(self):
+        warn("DB-API extension cursor.connection used", stacklevel=3)
+        return self._connection
+
+    ##
+    # This read-only attribute specifies the number of rows that the last
+    # .execute*() produced (for DQL statements like 'select') or affected (for
+    # DML statements like 'update' or 'insert').
+    # <p>
+    # The attribute is -1 in case no .execute*() has been performed on the
+    # cursor or the rowcount of the last operation is cannot be determined by
+    # the interface.
+    # <p>
+    # Stability: Part of the DBAPI 2.0 specification.
+    rowcount = property(lambda self: self._getRowCount())
+
+    @require_open_cursor
+    def _getRowCount(self):
+        if self._override_rowcount != None:
+            return self._override_rowcount
+        return self.cursor.row_count
+
+    ##
+    # This read-only attribute is a sequence of 7-item sequences.  Each value
+    # contains information describing one result column.  The 7 items returned
+    # for each column are (name, type_code, display_size, internal_size,
+    # precision, scale, null_ok).  Only the first two values are provided by
+    # this interface implementation.
+    # <p>
+    # Stability: Part of the DBAPI 2.0 specification.
+    description = property(lambda self: self._getDescription())
+
+    @require_open_cursor
+    def _getDescription(self):
+        if self.cursor.row_description == None:
+            return None
+        columns = []
+        for col in self.cursor.row_description:
+            columns.append((col["name"], col["type_oid"], None, None, None, None, None))
+        return columns
+
+    ##
+    # Executes a database operation.  Parameters may be provided as a sequence
+    # or mapping and will be bound to variables in the operation.
+    # <p>
+    # Stability: Part of the DBAPI 2.0 specification.
+    @require_open_cursor
+    def execute(self, operation, args=()):
+        self._override_rowcount = None
+        self._execute(operation, args)
+
+    def _execute(self, operation, args=()):
+        new_query, new_args = convert_paramstyle(paramstyle, operation, args)
+        try:
+            self.cursor.execute(new_query, *new_args)
+        except ConnectionClosedError:
+            # can't rollback in this case
+            raise
+        except:
+            # any error will rollback the transaction to-date
+            self._connection.rollback()
+            raise
+
+    def copy_from(self, fileobj, table=None, sep='\t', null=None, query=None):
+        if query == None:
+            if table == None:
+                raise CopyQueryOrTableRequiredError()
+            query = "COPY %s FROM stdout DELIMITER '%s'" % (table, sep)
+            if null is not None:
+                query += " NULL '%s'" % (null,)
+        self.copy_execute(fileobj, query)
+
+    def copy_to(self, fileobj, table=None, sep='\t', null=None, query=None):
+        if query == None:
+            if table == None:
+                raise CopyQueryOrTableRequiredError()
+            query = "COPY %s TO stdout DELIMITER '%s'" % (table, sep)
+            if null is not None:
+                query += " NULL '%s'" % (null,)
+        self.copy_execute(fileobj, query)
+    
+    @require_open_cursor
+    def copy_execute(self, fileobj, query):
+        try:
+            self.cursor.execute(query, stream=fileobj)
+        except ConnectionClosedError:
+            # can't rollback in this case
+            raise
+        except:
+            # any error will rollback the transaction to-date
+            import traceback; traceback.print_exc()
+            self._connection.rollback()
+            raise
+
+    ##
+    # Prepare a database operation and then execute it against all parameter
+    # sequences or mappings provided.
+    # <p>
+    # Stability: Part of the DBAPI 2.0 specification.
+    @require_open_cursor
+    def executemany(self, operation, parameter_sets):
+        self._override_rowcount = 0
+        for parameters in parameter_sets:
+            self._execute(operation, parameters)
+            if self.cursor.row_count == -1 or self._override_rowcount == -1:
+                self._override_rowcount = -1
+            else:
+                self._override_rowcount += self.cursor.row_count
+
+    ##
+    # Fetch the next row of a query result set, returning a single sequence, or
+    # None when no more data is available.
+    # <p>
+    # Stability: Part of the DBAPI 2.0 specification.
+    @require_open_cursor
+    def fetchone(self):
+        return self.cursor.read_tuple()
+
+    ##
+    # Fetch the next set of rows of a query result, returning a sequence of
+    # sequences.  An empty sequence is returned when no more rows are
+    # available.
+    # <p>
+    # Stability: Part of the DBAPI 2.0 specification.
+    # @param size   The number of rows to fetch when called.  If not provided,
+    #               the arraysize property value is used instead.
+    def fetchmany(self, size=None):
+        if size == None:
+            size = self.arraysize
+        rows = []
+        for i in range(size):
+            value = self.fetchone()
+            if value == None:
+                break
+            rows.append(value)
+        return rows
+
+    ##
+    # Fetch all remaining rows of a query result, returning them as a sequence
+    # of sequences.
+    # <p>
+    # Stability: Part of the DBAPI 2.0 specification.
+    @require_open_cursor
+    def fetchall(self):
+        return tuple(self.cursor.iterate_tuple())
+
+    ##
+    # Close the cursor.
+    # <p>
+    # Stability: Part of the DBAPI 2.0 specification.
+    @require_open_cursor
+    def close(self):
+        self.cursor.close()
+        self.cursor = None
+        self._override_rowcount = None
+
+    def next(self):
+        warn("DB-API extension cursor.next() used", stacklevel=2)
+        retval = self.fetchone()
+        if retval == None:
+            raise StopIteration()
+        return retval
+
+    def __iter__(self):
+        warn("DB-API extension cursor.__iter__() used", stacklevel=2)
+        return self
+
+    def setinputsizes(self, sizes):
+        pass
+
+    def setoutputsize(self, size, column=None):
+        pass
+
+    @require_open_cursor
+    def fileno(self):
+        return self.cursor.fileno()
+    
+    @require_open_cursor
+    def isready(self):
+        return self.cursor.isready()
+
+def require_open_connection(fn):
+    def _fn(self, *args, **kwargs):
+        if self.conn == None:
+            raise ConnectionClosedError()
+        return fn(self, *args, **kwargs)
+    return _fn
+
+##
+# The class of object returned by the {@link #connect connect method}.
+class ConnectionWrapper(object):
+    # DBAPI Extension: supply exceptions as attributes on the connection
+    Warning = property(lambda self: self._getError(Warning))
+    Error = property(lambda self: self._getError(Error))
+    InterfaceError = property(lambda self: self._getError(InterfaceError))
+    DatabaseError = property(lambda self: self._getError(DatabaseError))
+    OperationalError = property(lambda self: self._getError(OperationalError))
+    IntegrityError = property(lambda self: self._getError(IntegrityError))
+    InternalError = property(lambda self: self._getError(InternalError))
+    ProgrammingError = property(lambda self: self._getError(ProgrammingError))
+    NotSupportedError = property(lambda self: self._getError(NotSupportedError))
+
+    def _getError(self, error):
+        warn("DB-API extension connection.%s used" % error.__name__, stacklevel=3)
+        return error
+
+    def __init__(self, **kwargs):
+        self.conn = interface.Connection(**kwargs)
+        self.notifies = []
+        self.notifies_lock = threading.Lock()
+        self.conn.NotificationReceived += self._notificationReceived
+        self.conn.begin()
+
+    def _notificationReceived(self, notice):
+        try:
+        # psycopg2 compatible notification interface
+            self.notifies_lock.acquire()
+            self.notifies.append((notice.backend_pid, notice.condition))
+        finally:
+            self.notifies_lock.release()
+
+    ##
+    # Creates a {@link #CursorWrapper CursorWrapper} object bound to this
+    # connection.
+    # <p>
+    # Stability: Part of the DBAPI 2.0 specification.
+    @require_open_connection
+    def cursor(self):
+        return CursorWrapper(self.conn, self)
+
+    ##
+    # Commits the current database transaction.
+    # <p>
+    # Stability: Part of the DBAPI 2.0 specification.
+    @require_open_connection
+    def commit(self):
+        # There's a threading bug here.  If a query is sent after the
+        # commit, but before the begin, it will be executed immediately
+        # without a surrounding transaction.  Like all threading bugs -- it
+        # sounds unlikely, until it happens every time in one
+        # application...  however, to fix this, we need to lock the
+        # database connection entirely, so that no cursors can execute
+        # statements on other threads.  Support for that type of lock will
+        # be done later.
+        self.conn.commit()
+        self.conn.begin()
+
+    ##
+    # Rolls back the current database transaction.
+    # <p>
+    # Stability: Part of the DBAPI 2.0 specification.
+    @require_open_connection
+    def rollback(self):
+        # see bug description in commit.
+        self.conn.rollback()
+        self.conn.begin()
+
+    ##
+    # Closes the database connection.
+    # <p>
+    # Stability: Part of the DBAPI 2.0 specification.
+    @require_open_connection
+    def close(self):
+        self.conn.close()
+        self.conn = None
+
+    @require_open_connection
+    def recache_record_types(self):
+        self.conn.recache_record_types()
+
+
+##
+# Creates a DBAPI 2.0 compatible interface to a PostgreSQL database.
+# <p>
+# Stability: Part of the DBAPI 2.0 specification.
+#
+# @param user   The username to connect to the PostgreSQL server with.  This
+# parameter is required.
+#
+# @keyparam host   The hostname of the PostgreSQL server to connect with.
+# Providing this parameter is necessary for TCP/IP connections.  One of either
+# host, or unix_sock, must be provided.
+#
+# @keyparam unix_sock   The path to the UNIX socket to access the database
+# through, for example, '/tmp/.s.PGSQL.5432'.  One of either unix_sock or host
+# must be provided.  The port parameter will have no affect if unix_sock is
+# provided.
+#
+# @keyparam port   The TCP/IP port of the PostgreSQL server instance.  This
+# parameter defaults to 5432, the registered and common port of PostgreSQL
+# TCP/IP servers.
+#
+# @keyparam database   The name of the database instance to connect with.  This
+# parameter is optional, if omitted the PostgreSQL server will assume the
+# database name is the same as the username.
+#
+# @keyparam password   The user password to connect to the server with.  This
+# parameter is optional.  If omitted, and the database server requests password
+# based authentication, the connection will fail.  On the other hand, if this
+# parameter is provided and the database does not request password
+# authentication, then the password will not be used.
+#
+# @keyparam socket_timeout  Socket connect timeout measured in seconds.
+# Defaults to 60 seconds.
+#
+# @keyparam ssl     Use SSL encryption for TCP/IP socket.  Defaults to False.
+#
+# @return An instance of {@link #ConnectionWrapper ConnectionWrapper}.
+def connect(user, host=None, unix_sock=None, port=5432, database=None, password=None, socket_timeout=60, ssl=False, options=None):
+    return ConnectionWrapper(user=user, host=host,
+            unix_sock=unix_sock, port=port, database=database,
+            password=password, socket_timeout=socket_timeout, ssl=ssl, options=options)
+
+def Date(year, month, day):
+    return datetime.date(year, month, day)
+
+def Time(hour, minute, second):
+    return datetime.time(hour, minute, second)
+
+def Timestamp(year, month, day, hour, minute, second):
+    return datetime.datetime(year, month, day, hour, minute, second)
+
+def DateFromTicks(ticks):
+    return Date(*time.localtime(ticks)[:3])
+
+def TimeFromTicks(ticks):
+    return Time(*time.localtime(ticks)[3:6])
+
+def TimestampFromTicks(ticks):
+    return Timestamp(*time.localtime(ticks)[:6])
+
+##
+# Construct an object holding binary data.
+def Binary(value):
+    return types.Bytea(value)
+
+# I have no idea what this would be used for by a client app.  Should it be
+# TEXT, VARCHAR, CHAR?  It will only compare against row_description's
+# type_code if it is this one type.  It is the varchar type oid for now, this
+# appears to match expectations in the DB API 2.0 compliance test suite.
+STRING = 1043
+
+# bytea type_oid
+BINARY = 17
+
+# numeric type_oid
+NUMBER = 1700
+
+# timestamp type_oid
+DATETIME = 1114
+
+# oid type_oid
+ROWID = 26
+
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/pg8000/errors.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/pg8000/errors.py b/tools/bin/ext/pg8000/errors.py
new file mode 100644
index 0000000..b8b5acf
--- /dev/null
+++ b/tools/bin/ext/pg8000/errors.py
@@ -0,0 +1,115 @@
+# vim: sw=4:expandtab:foldmethod=marker
+#
+# Copyright (c) 2007-2009, Mathieu Fenniak
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+# * The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+__author__ = "Mathieu Fenniak"
+
+class Warning(StandardError):
+    pass
+
+class Error(StandardError):
+    pass
+
+class InterfaceError(Error):
+    pass
+
+class ConnectionClosedError(InterfaceError):
+    def __init__(self):
+        InterfaceError.__init__(self, "connection is closed")
+
+class CursorClosedError(InterfaceError):
+    def __init__(self):
+        InterfaceError.__init__(self, "cursor is closed")
+
+class DatabaseError(Error):
+    pass
+
+class DataError(DatabaseError):
+    pass
+
+class OperationalError(DatabaseError):
+    pass
+
+class IntegrityError(DatabaseError):
+    pass
+
+class InternalError(DatabaseError):
+    pass
+
+class ProgrammingError(DatabaseError):
+    pass
+
+class NotSupportedError(DatabaseError):
+    pass
+
+##
+# An exception that is thrown when an internal error occurs trying to
+# decode binary array data from the server.
+class ArrayDataParseError(InternalError):
+    pass
+
+##
+# Thrown when attempting to transmit an array of unsupported data types.
+class ArrayContentNotSupportedError(NotSupportedError):
+    pass
+
+##
+# Thrown when attempting to send an array that doesn't contain all the same
+# type of objects (eg. some floats, some ints).
+class ArrayContentNotHomogenousError(ProgrammingError):
+    pass
+
+##
+# Attempted to pass an empty array in, but it's not possible to determine the
+# data type for an empty array.
+class ArrayContentEmptyError(ProgrammingError):
+    pass
+
+##
+# Attempted to use a multidimensional array with inconsistent array sizes.
+class ArrayDimensionsNotConsistentError(ProgrammingError):
+    pass
+
+# A cursor's copy_to or copy_from argument was not provided a table or query
+# to operate on.
+class CopyQueryOrTableRequiredError(ProgrammingError):
+    pass
+
+# Raised if a COPY query is executed without using copy_to or copy_from
+# functions to provide a data stream.
+class CopyQueryWithoutStreamError(ProgrammingError):
+    pass
+
+# When query parameters don't match up with query args.
+class QueryParameterIndexError(ProgrammingError):
+    pass
+
+# Some sort of parse error occured during query parameterization.
+class QueryParameterParseError(ProgrammingError):
+    pass
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/pg8000/interface.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/pg8000/interface.py b/tools/bin/ext/pg8000/interface.py
new file mode 100644
index 0000000..d2f70fa
--- /dev/null
+++ b/tools/bin/ext/pg8000/interface.py
@@ -0,0 +1,542 @@
+# vim: sw=4:expandtab:foldmethod=marker
+#
+# Copyright (c) 2007-2009, Mathieu Fenniak
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+# * The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+__author__ = "Mathieu Fenniak"
+
+import socket
+import protocol
+import threading
+from errors import *
+
+class DataIterator(object):
+    def __init__(self, obj, func):
+        self.obj = obj
+        self.func = func
+
+    def __iter__(self):
+        return self
+
+    def next(self):
+        retval = self.func(self.obj)
+        if retval == None:
+            raise StopIteration()
+        return retval
+
+statement_number_lock = threading.Lock()
+statement_number = 0
+
+##
+# This class represents a prepared statement.  A prepared statement is
+# pre-parsed on the server, which reduces the need to parse the query every
+# time it is run.  The statement can have parameters in the form of $1, $2, $3,
+# etc.  When parameters are used, the types of the parameters need to be
+# specified when creating the prepared statement.
+# <p>
+# As of v1.01, instances of this class are thread-safe.  This means that a
+# single PreparedStatement can be accessed by multiple threads without the
+# internal consistency of the statement being altered.  However, the
+# responsibility is on the client application to ensure that one thread reading
+# from a statement isn't affected by another thread starting a new query with
+# the same statement.
+# <p>
+# Stability: Added in v1.00, stability guaranteed for v1.xx.
+#
+# @param connection     An instance of {@link Connection Connection}.
+#
+# @param statement      The SQL statement to be represented, often containing
+# parameters in the form of $1, $2, $3, etc.
+#
+# @param types          Python type objects for each parameter in the SQL
+# statement.  For example, int, float, str.
+class PreparedStatement(object):
+
+    ##
+    # Determines the number of rows to read from the database server at once.
+    # Reading more rows increases performance at the cost of memory.  The
+    # default value is 100 rows.  The affect of this parameter is transparent.
+    # That is, the library reads more rows when the cache is empty
+    # automatically.
+    # <p>
+    # Stability: Added in v1.00, stability guaranteed for v1.xx.  It is
+    # possible that implementation changes in the future could cause this
+    # parameter to be ignored.
+    row_cache_size = 100
+
+    def __init__(self, connection, statement, *types, **kwargs):
+        global statement_number
+        if connection == None or connection.c == None:
+            raise InterfaceError("connection not provided")
+        try:
+            statement_number_lock.acquire()
+            self._statement_number = statement_number
+            statement_number += 1
+        finally:
+            statement_number_lock.release()
+        self.c = connection.c
+        self._portal_name = None
+        self._statement_name = kwargs.get("statement_name", "pg8000_statement_%s" % self._statement_number)
+        self._row_desc = None
+        self._cached_rows = []
+        self._ongoing_row_count = 0
+        self._command_complete = True
+        self._parse_row_desc = self.c.parse(self._statement_name, statement, types)
+        self._lock = threading.RLock()
+
+    def close(self):
+        if self._statement_name != "": # don't close unnamed statement
+            self.c.close_statement(self._statement_name)
+        if self._portal_name != None:
+            self.c.close_portal(self._portal_name)
+            self._portal_name = None
+
+    row_description = property(lambda self: self._getRowDescription())
+    def _getRowDescription(self):
+        if self._row_desc == None:
+            return None
+        return self._row_desc.fields
+
+    ##
+    # Run the SQL prepared statement with the given parameters.
+    # <p>
+    # Stability: Added in v1.00, stability guaranteed for v1.xx.
+    def execute(self, *args, **kwargs):
+        self._lock.acquire()
+        try:
+            if not self._command_complete:
+                # cleanup last execute
+                self._cached_rows = []
+                self._ongoing_row_count = 0
+            if self._portal_name != None:
+                self.c.close_portal(self._portal_name)
+            self._command_complete = False
+            self._portal_name = "pg8000_portal_%s" % self._statement_number
+            self._row_desc, cmd = self.c.bind(self._portal_name, self._statement_name, args, self._parse_row_desc, kwargs.get("stream"))
+            if self._row_desc:
+                # We execute our cursor right away to fill up our cache.  This
+                # prevents the cursor from being destroyed, apparently, by a rogue
+                # Sync between Bind and Execute.  Since it is quite likely that
+                # data will be read from us right away anyways, this seems a safe
+                # move for now.
+                self._fill_cache()
+            else:
+                self._command_complete = True
+                self._ongoing_row_count = -1
+                if cmd != None and cmd.rows != None:
+                    self._ongoing_row_count = cmd.rows
+        finally:
+            self._lock.release()
+
+    def _fill_cache(self):
+        self._lock.acquire()
+        try:
+            if self._cached_rows:
+                raise InternalError("attempt to fill cache that isn't empty")
+            end_of_data, rows = self.c.fetch_rows(self._portal_name, self.row_cache_size, self._row_desc)
+            self._cached_rows = rows
+            if end_of_data:
+                self._command_complete = True
+        finally:
+            self._lock.release()
+
+    def _fetch(self):
+        if not self._row_desc:
+            raise ProgrammingError("no result set")
+        self._lock.acquire()
+        try:
+            if not self._cached_rows:
+                if self._command_complete:
+                    return None
+                self._fill_cache()
+                if self._command_complete and not self._cached_rows:
+                    # fill cache tells us the command is complete, but yet we have
+                    # no rows after filling our cache.  This is a special case when
+                    # a query returns no rows.
+                    return None
+            row = self._cached_rows.pop(0)
+            self._ongoing_row_count += 1
+            return tuple(row)
+        finally:
+            self._lock.release()
+
+    ##
+    # Return a count of the number of rows relevant to the executed statement.
+    # For a SELECT, this is the number of rows returned.  For UPDATE or DELETE,
+    # this the number of rows affected.  For INSERT, the number of rows
+    # inserted.  This property may have a value of -1 to indicate that there
+    # was no row count.
+    # <p>
+    # During a result-set query (eg. SELECT, or INSERT ... RETURNING ...),
+    # accessing this property requires reading the entire result-set into
+    # memory, as reading the data to completion is the only way to determine
+    # the total number of rows.  Avoid using this property in with
+    # result-set queries, as it may cause unexpected memory usage.
+    # <p>
+    # Stability: Added in v1.03, stability guaranteed for v1.xx.
+    row_count = property(lambda self: self._get_row_count())
+    def _get_row_count(self):
+        self._lock.acquire()
+        try:
+            if not self._command_complete:
+                end_of_data, rows = self.c.fetch_rows(self._portal_name, 0, self._row_desc)
+                self._cached_rows += rows
+                if end_of_data:
+                    self._command_complete = True
+                else:
+                    raise InternalError("fetch_rows(0) did not hit end of data")
+            return self._ongoing_row_count + len(self._cached_rows)
+        finally:
+            self._lock.release()
+
+    ##
+    # Read a row from the database server, and return it in a dictionary
+    # indexed by column name/alias.  This method will raise an error if two
+    # columns have the same name.  Returns None after the last row.
+    # <p>
+    # Stability: Added in v1.00, stability guaranteed for v1.xx.
+    def read_dict(self):
+        row = self._fetch()
+        if row == None:
+            return row
+        retval = {}
+        for i in range(len(self._row_desc.fields)):
+            col_name = self._row_desc.fields[i]['name']
+            if retval.has_key(col_name):
+                raise InterfaceError("cannot return dict of row when two columns have the same name (%r)" % (col_name,))
+            retval[col_name] = row[i]
+        return retval
+
+    ##
+    # Read a row from the database server, and return it as a tuple of values.
+    # Returns None after the last row.
+    # <p>
+    # Stability: Added in v1.00, stability guaranteed for v1.xx.
+    def read_tuple(self):
+        return self._fetch()
+
+    ##
+    # Return an iterator for the output of this statement.  The iterator will
+    # return a tuple for each row, in the same manner as {@link
+    # #PreparedStatement.read_tuple read_tuple}.
+    # <p>
+    # Stability: Added in v1.00, stability guaranteed for v1.xx.
+    def iterate_tuple(self):
+        return DataIterator(self, PreparedStatement.read_tuple)
+
+    ##
+    # Return an iterator for the output of this statement.  The iterator will
+    # return a dict for each row, in the same manner as {@link
+    # #PreparedStatement.read_dict read_dict}.
+    # <p>
+    # Stability: Added in v1.00, stability guaranteed for v1.xx.
+    def iterate_dict(self):
+        return DataIterator(self, PreparedStatement.read_dict)
+
+##
+# The Cursor class allows multiple queries to be performed concurrently with a
+# single PostgreSQL connection.  The Cursor object is implemented internally by
+# using a {@link PreparedStatement PreparedStatement} object, so if you plan to
+# use a statement multiple times, you might as well create a PreparedStatement
+# and save a small amount of reparsing time.
+# <p>
+# As of v1.01, instances of this class are thread-safe.  See {@link
+# PreparedStatement PreparedStatement} for more information.
+# <p>
+# Stability: Added in v1.00, stability guaranteed for v1.xx.
+#
+# @param connection     An instance of {@link Connection Connection}.
+class Cursor(object):
+    def __init__(self, connection):
+        self.connection = connection
+        self._stmt = None
+
+    def require_stmt(func):
+        def retval(self, *args, **kwargs):
+            if self._stmt == None:
+                raise ProgrammingError("attempting to use unexecuted cursor")
+            return func(self, *args, **kwargs)
+        return retval
+
+    row_description = property(lambda self: self._getRowDescription())
+    def _getRowDescription(self):
+        if self._stmt == None:
+            return None
+        return self._stmt.row_description
+
+    ##
+    # Run an SQL statement using this cursor.  The SQL statement can have
+    # parameters in the form of $1, $2, $3, etc., which will be filled in by
+    # the additional arguments passed to this function.
+    # <p>
+    # Stability: Added in v1.00, stability guaranteed for v1.xx.
+    # @param query      The SQL statement to execute.
+    def execute(self, query, *args, **kwargs):
+        if self.connection.is_closed:
+            raise ConnectionClosedError()
+        self.connection._unnamed_prepared_statement_lock.acquire()
+        try:
+            self._stmt = PreparedStatement(self.connection, query, statement_name="", *[{"type": type(x), "value": x} for x in args])
+            self._stmt.execute(*args, **kwargs)
+        finally:
+            self.connection._unnamed_prepared_statement_lock.release()
+
+    ##
+    # Return a count of the number of rows currently being read.  If possible,
+    # please avoid using this function.  It requires reading the entire result
+    # set from the database to determine the number of rows being returned.
+    # <p>
+    # Stability: Added in v1.03, stability guaranteed for v1.xx.
+    # Implementation currently requires caching entire result set into memory,
+    # avoid using this property.
+    row_count = property(lambda self: self._get_row_count())
+
+    @require_stmt
+    def _get_row_count(self):
+        return self._stmt.row_count
+
+    ##
+    # Read a row from the database server, and return it in a dictionary
+    # indexed by column name/alias.  This method will raise an error if two
+    # columns have the same name.  Returns None after the last row.
+    # <p>
+    # Stability: Added in v1.00, stability guaranteed for v1.xx.
+    @require_stmt
+    def read_dict(self):
+        return self._stmt.read_dict()
+
+    ##
+    # Read a row from the database server, and return it as a tuple of values.
+    # Returns None after the last row.
+    # <p>
+    # Stability: Added in v1.00, stability guaranteed for v1.xx.
+    @require_stmt
+    def read_tuple(self):
+        return self._stmt.read_tuple()
+
+    ##
+    # Return an iterator for the output of this statement.  The iterator will
+    # return a tuple for each row, in the same manner as {@link
+    # #PreparedStatement.read_tuple read_tuple}.
+    # <p>
+    # Stability: Added in v1.00, stability guaranteed for v1.xx.
+    @require_stmt
+    def iterate_tuple(self):
+        return self._stmt.iterate_tuple()
+
+    ##
+    # Return an iterator for the output of this statement.  The iterator will
+    # return a dict for each row, in the same manner as {@link
+    # #PreparedStatement.read_dict read_dict}.
+    # <p>
+    # Stability: Added in v1.00, stability guaranteed for v1.xx.
+    @require_stmt
+    def iterate_dict(self):
+        return self._stmt.iterate_dict()
+
+    def close(self):
+        if self._stmt != None:
+            self._stmt.close()
+            self._stmt = None
+
+
+    ##
+    # Return the fileno of the underlying socket for this cursor's connection.
+    # <p>
+    # Stability: Added in v1.07, stability guaranteed for v1.xx.
+    def fileno(self):
+        return self.connection.fileno()
+
+    ##
+    # Poll the underlying socket for this cursor and sync if there is data waiting
+    # to be read. This has the effect of flushing asynchronous messages from the
+    # backend. Returns True if messages were read, False otherwise.
+    # <p>
+    # Stability: Added in v1.07, stability guaranteed for v1.xx.
+    def isready(self):
+        return self.connection.isready()
+    
+
+##
+# This class represents a connection to a PostgreSQL database.
+# <p>
+# The database connection is derived from the {@link #Cursor Cursor} class,
+# which provides a default cursor for running queries.  It also provides
+# transaction control via the 'begin', 'commit', and 'rollback' methods.
+# Without beginning a transaction explicitly, all statements will autocommit to
+# the database.
+# <p>
+# As of v1.01, instances of this class are thread-safe.  See {@link
+# PreparedStatement PreparedStatement} for more information.
+# <p>
+# Stability: Added in v1.00, stability guaranteed for v1.xx.
+#
+# @param user   The username to connect to the PostgreSQL server with.  This
+# parameter is required.
+#
+# @keyparam host   The hostname of the PostgreSQL server to connect with.
+# Providing this parameter is necessary for TCP/IP connections.  One of either
+# host, or unix_sock, must be provided.
+#
+# @keyparam unix_sock   The path to the UNIX socket to access the database
+# through, for example, '/tmp/.s.PGSQL.5432'.  One of either unix_sock or host
+# must be provided.  The port parameter will have no affect if unix_sock is
+# provided.
+#
+# @keyparam port   The TCP/IP port of the PostgreSQL server instance.  This
+# parameter defaults to 5432, the registered and common port of PostgreSQL
+# TCP/IP servers.
+#
+# @keyparam database   The name of the database instance to connect with.  This
+# parameter is optional, if omitted the PostgreSQL server will assume the
+# database name is the same as the username.
+#
+# @keyparam password   The user password to connect to the server with.  This
+# parameter is optional.  If omitted, and the database server requests password
+# based authentication, the connection will fail.  On the other hand, if this
+# parameter is provided and the database does not request password
+# authentication, then the password will not be used.
+#
+# @keyparam socket_timeout  Socket connect timeout measured in seconds.
+# Defaults to 60 seconds.
+#
+# @keyparam ssl     Use SSL encryption for TCP/IP socket.  Defaults to False.
+class Connection(Cursor):
+    def __init__(self, user, host=None, unix_sock=None, port=5432, database=None, password=None, socket_timeout=60, ssl=False, options=None):
+        self._row_desc = None
+        try:
+            self.c = protocol.Connection(unix_sock=unix_sock, host=host, port=port, socket_timeout=socket_timeout, ssl=ssl)
+            self.c.authenticate(user, password=password, database=database, options=options)
+        except socket.error, e:
+            raise InterfaceError("communication error", e)
+        Cursor.__init__(self, self)
+        self._begin = PreparedStatement(self, "BEGIN TRANSACTION")
+        self._commit = PreparedStatement(self, "COMMIT TRANSACTION")
+        self._rollback = PreparedStatement(self, "ROLLBACK TRANSACTION")
+        self._unnamed_prepared_statement_lock = threading.RLock()
+
+    ##
+    # An event handler that is fired when NOTIFY occurs for a notification that
+    # has been LISTEN'd for.  The value of this property is a
+    # util.MulticastDelegate.  A callback can be added by using
+    # connection.NotificationReceived += SomeMethod.  The method will be called
+    # with a single argument, an object that has properties: backend_pid,
+    # condition, and additional_info.  Callbacks can be removed with the -=
+    # operator.
+    # <p>
+    # Stability: Added in v1.03, stability guaranteed for v1.xx.
+    NotificationReceived = property(
+            lambda self: getattr(self.c, "NotificationReceived"),
+            lambda self, value: setattr(self.c, "NotificationReceived", value)
+    )
+
+    ##
+    # An event handler that is fired when the database server issues a notice.
+    # The value of this property is a util.MulticastDelegate.  A callback can
+    # be added by using connection.NotificationReceived += SomeMethod.  The
+    # method will be called with a single argument, an object that has
+    # properties: severity, code, msg, and possibly others (detail, hint,
+    # position, where, file, line, and routine).  Callbacks can be removed with
+    # the -= operator.
+    # <p>
+    # Stability: Added in v1.03, stability guaranteed for v1.xx.
+    NoticeReceived = property(
+            lambda self: getattr(self.c, "NoticeReceived"),
+            lambda self, value: setattr(self.c, "NoticeReceived", value)
+    )
+
+    ##
+    # An event handler that is fired when a runtime configuration option is
+    # changed on the server.  The value of this property is a
+    # util.MulticastDelegate.  A callback can be added by using
+    # connection.NotificationReceived += SomeMethod.  Callbacks can be removed
+    # with the -= operator.  The method will be called with a single argument,
+    # an object that has properties "key" and "value".
+    # <p>
+    # Stability: Added in v1.03, stability guaranteed for v1.xx.
+    ParameterStatusReceived = property(
+            lambda self: getattr(self.c, "ParameterStatusReceived"),
+            lambda self, value: setattr(self.c, "ParameterStatusReceived", value)
+    )
+
+    ##
+    # Begins a new transaction.
+    # <p>
+    # Stability: Added in v1.00, stability guaranteed for v1.xx.
+    def begin(self):
+        if self.is_closed:
+            raise ConnectionClosedError()
+        self._begin.execute()
+
+    ##
+    # Commits the running transaction.
+    # <p>
+    # Stability: Added in v1.00, stability guaranteed for v1.xx.
+    def commit(self):
+        if self.is_closed:
+            raise ConnectionClosedError()
+        self._commit.execute()
+
+    ##
+    # Rolls back the running transaction.
+    # <p>
+    # Stability: Added in v1.00, stability guaranteed for v1.xx.
+    def rollback(self):
+        if self.is_closed:
+            raise ConnectionClosedError()
+        self._rollback.execute()
+
+    ##
+    # Closes an open connection.
+    def close(self):
+        if self.is_closed:
+            raise ConnectionClosedError()
+        self.c.close()
+        self.c = None
+
+    is_closed = property(lambda self: self.c == None)
+
+    def recache_record_types(self):
+        self.c._cache_record_attnames()
+
+    ##
+    # Return the fileno of the underlying socket for this connection.
+    # <p>
+    # Stability: Added in v1.07, stability guaranteed for v1.xx.
+    def fileno(self):
+        return self.c.fileno()
+
+    ##
+    # Poll the underlying socket for this connection and sync if there is data
+    # waiting to be read. This has the effect of flushing asynchronous
+    # messages from the backend. Returns True if messages were read, False
+    # otherwise.
+    # <p>
+    # Stability: Added in v1.07, stability guaranteed for v1.xx.
+    def isready(self):
+        return self.c.isready()
+


[16/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code

Posted by rl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/_psi_test.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/_psi_test.py b/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/_psi_test.py
new file mode 100644
index 0000000..c89935a
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/_psi_test.py
@@ -0,0 +1,145 @@
+# The MIT License
+#
+# Copyright (C) 2008-2009 Floris Bruynooghe
+#
+# Copyright (C) 2008-2009 Abilisoft Ltd.
+#
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation files
+# (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge,
+# publish, distribute, sublicense, and/or sell copies of the Software,
+# and to permit persons to whom the Software is furnished to do so,
+# subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+
+import os
+import time
+import unittest
+
+import psi
+
+
+class ExceptionsTests(unittest.TestCase):
+    def test_attr_subclass(self):
+        self.assert_(issubclass(psi.AttrNotAvailableError, AttributeError))
+        self.assert_(issubclass(psi.AttrInsufficientPrivsError, AttributeError))
+        self.assert_(issubclass(psi.AttrNotImplementedError, AttributeError))
+
+    def test_attr_instances(self):
+        na = psi.AttrNotAvailableError()
+        ip = psi.AttrInsufficientPrivsError()
+        ni = psi.AttrNotImplementedError()
+        self.assert_(isinstance(na, AttributeError))
+        self.assert_(isinstance(ip, AttributeError))
+        self.assert_(isinstance(ni, AttributeError))
+
+    def test_resource_subclass(self):
+        self.assert_(issubclass(psi.MissingResourceError, Exception))
+
+    def test_resource_instance(self):
+        mr = psi.MissingResourceError()
+        self.assert_(isinstance(mr, Exception))
+
+
+class LoadavgTests(unittest.TestCase):
+    def test_type(self):
+        loadavg = psi.loadavg()
+        self.failUnless(isinstance(loadavg, tuple))
+
+    def test_len(self):
+        loadavg = psi.loadavg()
+        self.assertEqual(len(loadavg), 3)
+
+    def test_value_types(self):
+        loadavg = psi.loadavg()
+        for v in loadavg:
+            self.failUnless(isinstance(v, float))
+
+    def test_values(self):
+        psiavg = psi.loadavg()
+        if hasattr(os, 'getloadavg'):
+            osavg = os.getloadavg()
+            for i, j in zip(psiavg, osavg):
+                self.assertAlmostEqual(i, j)
+        else:
+            for l in psiavg:
+                self.assert_(0.0 <= l < 1000.0, '0.0 < %f < 1000.0'%l)
+
+
+class BoottimeTests(unittest.TestCase):
+    def test_timespec(self):
+        self.assert_(isinstance(psi.boottime(), psi.TimeSpec))
+
+    def test_gt_epoch(self):
+        bt = psi.boottime()
+        self.assert_(bt.timestamp() > 0, '%s > 0' % bt.timestamp())
+
+    def test_lt_now(self):
+        bt = psi.boottime()
+        now = time.time()
+        self.assert_(bt.timestamp() < now, '%s < %s' % (bt.timestamp(), now))
+
+    def test_boottime_calc(self):
+        psi_bt = psi.boottime()
+        calc_bt = time.time() - psi.uptime().timestamp()
+        calc_min = calc_bt - 2
+        calc_max = calc_bt + 2
+        self.assert_(calc_min < psi_bt.timestamp() < calc_max,
+                     '%s < %s < %s' % (calc_min, psi_bt.timestamp(), calc_max))
+
+
+class UptimeTests(unittest.TestCase):
+    def test_timedelta(self):
+        ut = psi.uptime()
+        self.assert_(isinstance(ut, psi.TimeSpec))
+
+    def test_uptime_gt_null(self):
+        self.assert_(psi.uptime().timestamp() > 0)
+
+    def test_uptime_calc(self):
+        psi_uptime = psi.uptime().timestamp()
+        calc_uptime = time.time() - psi.boottime().timestamp()
+        calc_min = calc_uptime - 2
+        calc_max = calc_uptime + 2
+        self.assert_(calc_min < psi_uptime < calc_max,
+                     "%s < %s < %s" % (calc_min, psi_uptime, calc_max))
+
+
+if hasattr(psi, 'getzoneid'):
+    class SolarisZonesTests(unittest.TestCase):
+        def test_getzoneid(self):
+            id = psi.getzoneid()
+            self.assert_(0 >= id)
+
+        def test_getzonenamebyid(self):
+            name = psi.getzonenamebyid(0)
+            self.assertEqual(name, 'global')
+
+        def test_getzonenamebyid_exception(self):
+            self.assertRaises(ValueError, psi.getzonenamebyid, -1)
+
+        def test_getzoneidbyname(self):
+            id = psi.getzoneidbyname('global')
+            self.assertEqual(id, 0)
+
+        def test_getzoneidbyname_exception(self):
+            # XXX This is brittle.
+            self.assertRaises(ValueError, psi.getzoneidbyname, 'foobar')
+
+
+if __name__ == '__main__':
+    unittest.main()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/aixapp.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/aixapp.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/aixapp.c
new file mode 100644
index 0000000..6396975
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/aixapp.c
@@ -0,0 +1,34 @@
+/** Program to test AIX priority values
+ *
+ * This program will schedule itself on the SCHED_RR scheduler and set it's
+ * priority to 42.  Then it will print it's pid and do nothing for 10 minutes.
+ * You can finish it earlier by sending a SIGTERM.
+ 
+ * Since it changes the scheduler it will have to run as root and it will only
+ * run on AIX due to the AIX specific setpri() system call. */
+
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/sched.h>
+#include <unistd.h>
+
+
+int
+main(int argc, char **argv)
+{
+    int i;
+
+    if (setpri(0, 42) < 0) {
+        printf("%d: %s\nAre you root?\n", errno, strerror(errno));
+        return 1;
+    }
+
+    printf("%ld\n", (long)getpid());
+    fflush(stdout);
+
+    for (i = 0; i < 60; i++)
+        sleep(10);
+    return 0;
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/app.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/app.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/app.c
new file mode 100644
index 0000000..ee538c4
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/app.c
@@ -0,0 +1,19 @@
+/* Simple executable that will print it's pid and then do nothing for 10
+ * minutes.  You can finish it earlier by sending a SIGTERM. */
+
+#include <stdio.h>
+#include <unistd.h>
+
+
+int
+main(int argc, char **argv)
+{
+    int i;
+
+    printf("%ld\n", (long)getpid());
+    fflush(stdout);
+
+    for (i = 0; i < 60; i++)
+        sleep(10);
+    return 0;
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/apphelper.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/apphelper.py b/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/apphelper.py
new file mode 100644
index 0000000..ecff9ea
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/apphelper.py
@@ -0,0 +1,225 @@
+# The MIT License
+#
+# Copyright (C) 2009 Floris Bruynooghe
+#
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation files
+# (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge,
+# publish, distribute, sublicense, and/or sell copies of the Software,
+# and to permit persons to whom the Software is furnished to do so,
+# subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+"""Helper module for running test appllications"""
+
+
+import os
+import signal
+import sys
+
+try:
+    import subprocess
+except ImportError:
+    HAVE_SUBPROCESS = False
+    import popen2
+    import select
+else:
+    HAVE_SUBPROCESS = True
+
+
+__all__ = ['APP32', 'APP64', 'pscmd', 'TestApp']
+
+
+def can_run(file):
+    """Check if we can run a test application
+
+    Returns the filename if so, False otherwise.
+    """
+    if not os.path.exists(file):
+        return False
+    if HAVE_SUBPROCESS:
+        try:
+            p = subprocess.Popen([file], stdout=subprocess.PIPE)
+            p.stdout.read(1)
+        except OSError:
+            pass
+        else:
+            os.kill(p.pid, signal.SIGTERM)
+            p.wait()
+            return file
+    else:
+        p = popen2.Popen3(file, True)
+        rlist, wlist, xlist = select.select([p.fromchild, p.childerr], [], [])
+        if p.poll() == -1:
+            os.kill(p.pid, signal.SIGTERM)
+            p.wait()
+        stdout = p.fromchild.read()
+        stderr = p.childerr.read()
+        if stdout:
+            return file
+#     sys.stdout.write('%s not runnable, some tests will be skipped'
+#                      % os.path.basename(file))
+    return False
+
+
+APP32 = can_run(os.path.join(os.path.dirname(__file__), 'app32'))
+APP64 = can_run(os.path.join(os.path.dirname(__file__), 'app64'))
+
+
+def run(cmd):
+    """Invoke a command, return stdout
+
+    This is a small helper that runs on all supported Python versions.
+    `cmd` is a list of the command line arguments.
+    """
+    if HAVE_SUBPROCESS:
+        val = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]
+    else:
+        val = os.popen(' '.join(cmdl)).read()
+    val = val.decode()
+    return val.strip()
+
+
+# Find the ps command.
+if os.path.exists('/bin/ps'):
+    PSCMD = '/bin/ps'
+elif os.path.exists('/usr/bin/ps'):
+    PSCMD = '/usr/bin/ps'
+else:
+    PSCMD = None
+
+
+def pscmd(item, pid=os.getpid()):
+    """Invoke ps -o %(item)s -p %(pid)d and return the result"""
+    pscmd = PSCMD
+    if item == 'sid' and os.uname()[0] == 'AIX':
+        pscmd = '/usr/sysv/bin/ps'
+    if item == 'sid' and os.uname()[0] == 'Darwin':
+        item = 'sess'
+    assert pscmd, 'ps command not found (%s), can not run test' % pscmd
+    if item == 'ni' and os.uname()[0] == 'SunOS':
+        item = 'nice'
+    if item == 'rssize' and os.uname()[0] in ['SunOS', 'Darwin']:
+        item = 'rss'
+    if item == 'pgrp' and os.uname()[0] in ['SunOS', 'AIX', 'Darwin']:
+        item = 'pgid'
+    cmdl = [pscmd, '-o', item, '-p', str(pid)]
+    if HAVE_SUBPROCESS:
+        val = subprocess.Popen(cmdl, stdout=subprocess.PIPE).communicate()[0]
+    else:
+        val = os.popen(' '.join(cmdl)).read()
+    val = val.decode()
+    val = val.strip().split()[-1]
+    if item == 'sess' and os.uname()[0] == 'Darwin':
+        # 'ps -o sess' on Darwin returns a hex value
+        val = int(val, 16)
+    return val
+
+
+class TestApp:
+    """Simple class to run test apps as subprocesses
+
+    This will work on all supported python versions (as opposed to the
+    subprocess module).  It will also ensure that the process is
+    actually running when the constructor returns.
+    """
+    def __init__(self, args, env=None):
+        """Create the instance
+
+        args:: Argument list as a Python list.
+        env:: Environment to run in.
+        """
+        self.args = args
+        self.env = env
+        self.pid = None
+        if HAVE_SUBPROCESS:
+            self.app = self._run_subprocess()
+        else:
+            self.app = self._run_fork()
+
+    def kill(self):
+        """Kill the process
+
+        Calling this more then once or on an already killed process
+        does not do any harm.
+        """
+        self.kill_to_zombie()
+        self.wait()
+
+    def kill_to_zombie(self):
+        """Kill the process, leaving it in a zombie state
+
+        This does not guarantee the process is in zombie state, it
+        might have been waited on somewhere else.
+        """
+        try:
+            os.kill(self.pid, signal.SIGTERM)
+        except OSError:
+            e = sys.exc_info()[1]
+            if not e.errno == 3:
+                raise
+
+    def wait(self):
+        """Wait for the process
+
+        If the process in no longer waitable, i.e. does no longer
+        exist, this will return immediately.
+        """
+        try:
+            if hasattr(self.app, 'wait'):
+                self.app.wait()
+            else:
+                os.waitpid(self.pid, 0)
+        except OSError:
+            e = sys.exc_info()[1]
+            if not e.errno == 10:
+                raise
+        self.pid = None
+
+    def _run_subprocess(self):
+        app =  subprocess.Popen(self.args, env=self.env, stdout=subprocess.PIPE)
+        self.pid = app.pid
+        app.stdout.read(1)
+        return app
+
+    def _run_fork(self):
+        # Based on popen2.Popen3 but simplified.
+        try:
+            MAXFD = os.sysconf('SC_OPEN_MAX')
+        except (AttributeError, ValueError):
+            MAXFD = 256
+        c2pread, c2pwrite = os.pipe()
+        pid = os.fork()
+        if pid == 0:            # child
+            os.dup2(c2pwrite, 1)
+            for i in xrange(3, MAXFD):
+                try:
+                    os.close(i)
+                except OSError:
+                    pass
+            try:
+                if self.env is not None:
+                    os.execve(self.args[0], self.args, self.env)
+                else:
+                    os.execv(self.args[0], self.args)
+            finally:
+                os._exit(1)
+        else:                   # parent
+            self.pid = pid
+            os.close(c2pwrite)
+            fromchild = os.fdopen(c2pread, 'r')
+            fromchild.read(1)
+            return None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/arch_test.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/arch_test.py b/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/arch_test.py
new file mode 100644
index 0000000..bb21020
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/arch_test.py
@@ -0,0 +1,68 @@
+# The MIT License
+#
+# Copyright (C) 2008-2009 Floris Bruynooghe
+#
+# Copyright (C) 2008-2009 Abilisoft Ltd.
+#
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation files
+# (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge,
+# publish, distribute, sublicense, and/or sell copies of the Software,
+# and to permit persons to whom the Software is furnished to do so,
+# subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+
+import os
+import unittest
+
+import psi
+
+
+class ArchTests(unittest.TestCase):
+    def setUp(self):
+        self.arch = psi.arch.arch_type()
+
+    def test_type(self):
+        self.failUnless(isinstance(self.arch, psi.arch.ArchBase))
+
+    def test_singleton(self):
+        base = psi.arch.ArchBase()
+        self.assertEqual(id(self.arch), id(base))
+
+    def test_sysname(self):
+        self.assertEqual(self.arch.sysname, os.uname()[0])
+
+    def test_nodename(self):
+        self.assertEqual(self.arch.nodename, os.uname()[1])
+
+    def test_release(self):
+        self.assertEqual(self.arch.release, os.uname()[2])
+
+    def test_release_info(self):
+        rel = os.uname()[2].split('-')[0]
+        rel_info = tuple([int(i) for i in rel.split('.')])
+        self.assertEqual(self.arch.release_info, rel_info)
+
+    def test_version(self):
+        self.assertEqual(self.arch.version, os.uname()[3])
+
+    def test_machine(self):
+        self.assertEqual(self.arch.machine, os.uname()[4])
+
+
+if __name__ == '__main__':
+    unittest.main()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/mount_test.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/mount_test.py b/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/mount_test.py
new file mode 100644
index 0000000..51e1469
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/mount_test.py
@@ -0,0 +1,169 @@
+# The MIT License
+#
+# Copyright (C) 2009 Erick Tryzelaar
+#
+# Copyright (C) 2008-2009 Abilisoft Ltd.
+#
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation files
+# (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge,
+# publish, distribute, sublicense, and/or sell copies of the Software,
+# and to permit persons to whom the Software is furnished to do so,
+# subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+
+import os
+import unittest
+
+import apphelper
+import psi.arch
+
+import psi.mount
+
+
+class MountAttrTests(unittest.TestCase):
+    def setUp(self):
+        self.mounts = psi.mount.mounts()
+        for mount in psi.mount.mounts():
+            if mount.mountpoint == '/':
+                break
+        self.m = mount
+        if isinstance(psi.arch.arch_type(), psi.arch.ArchLinux):
+            fd = open('/etc/mtab')
+            mtab = fd.readlines()
+            fd.close()
+            for line in mtab:
+                if line.split()[1] == '/':
+                    break
+            mount = line.split()
+            self.device = mount[0]
+            self.mountpoint = mount[1]
+            self.fstype = mount[2]
+            self.options = mount[3]
+        elif isinstance(psi.arch.arch_type(), psi.arch.ArchSunOS):
+            mounts = apphelper.run(['/usr/sbin/mount', '-p']).split('\n')
+            for line in mounts:
+                if line.split()[2] == '/':
+                    break
+            mount = line.split()
+            self.device = mount[0]
+            self.mountpoint = mount[2]
+            self.fstype = mount[3]
+            if len(mount) >= 7:
+                self.options = mount[6]
+            else:
+                self.options = ''
+            # Special case to find dev=XXXXX option
+            if psi.arch.arch_type().release_info > (5, 8):
+                mounts = apphelper.run(['/usr/sbin/mount', '-v']).split('\n')
+                for line in mounts:
+                    if line.split()[2] == '/':
+                        break
+                opts = line.split()[5]
+                opts = opts.split('/')
+                for o in opts:
+                    if o[:4] == 'dev=':
+                        break
+                self.options += ',' + o
+                self.options = self.options.strip(',')
+        elif isinstance(psi.arch.arch_type(), psi.arch.ArchAIX):
+            mounts = apphelper.run(['/usr/sbin/mount']).split('\n')[2:]
+            for line in mounts:
+                if line.split()[1] == '/':
+                    break
+            mount = line.split()
+            self.device = mount[0]
+            self.mountpoint = mount[1]
+            self.fstype = mount[2]
+            self.options = mount[-1]
+        elif isinstance(psi.arch.arch_type(), psi.arch.ArchDarwin):
+            mounts = apphelper.run(['/sbin/mount']).split('\n')
+            for line in mounts:
+                if line.split()[2] == '/':
+                    break
+            mount = line.split()
+            self.device = mount[0]
+            self.mountpoint = mount[2]
+            self.fstype = mount[3][1:-1]
+            self.options = ','.join(line[line.find('('):line.find(')')].split(', ')[1:])
+
+    def test_enumerate(self):
+        self.assert_(hasattr(self.mounts, '__iter__'))
+
+    def test_len(self):
+        self.assert_(len(list(self.mounts)) > 0)
+
+    def test_type(self):
+        for m in self.mounts:
+            self.assert_(isinstance(m, psi.mount.MountBase))
+
+    def test_remote(self):
+        local = len(list(psi.mount.mounts()))
+        remote = len(list(psi.mount.mounts(True)))
+        self.assert_(remote >= local, '%d >= %d' % (remote, local))
+
+    def test_device(self):
+        self.assertEqual(self.m.device, self.device)
+
+    def test_fstype(self):
+        self.assertEqual(self.m.fstype, self.fstype)
+
+    def test_options(self):
+        self.assertEqual(self.m.options, self.options)
+
+    def test_mountpoint(self):
+        self.assertEqual(self.m.mountpoint, self.mountpoint)
+
+    def test_total(self):
+        self.assert_(self.m.total > 0)
+
+    def test_free(self):
+        self.assert_(self.m.free > 0)
+        self.assert_(self.m.total > self.m.free)
+
+    def test_available(self):
+        self.assert_(self.m.available > 0)
+        self.assert_(self.m.free >= self.m.available,
+                     '%d > %d' % (self.m.free, self.m.available))
+
+    def test_inodes(self):
+        self.assert_(self.m.inodes > 0)
+
+    def test_free_inodes(self):
+        self.assert_(self.m.free_inodes > 0)
+        self.assert_(self.m.inodes > self.m.free_inodes)
+
+    def test_available_inodes(self):
+        self.assert_(self.m.available_inodes > 0)
+        self.assert_(self.m.free_inodes >= self.m.available_inodes,
+                     '%d > %d' % (self.m.free_inodes, self.m.available_inodes))
+
+
+class MountMethodsTests(unittest.TestCase):
+    def setUp(self):
+        for mount in psi.mount.mounts():
+            break
+        self.m = mount
+
+    def test_refresh(self):
+        mp = self.m.mountpoint
+        self.m.refresh()
+        self.assertEqual(mp, self.m.mountpoint)
+
+
+if __name__ == '__main__':
+    unittest.main()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/process_test.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/process_test.py b/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/process_test.py
new file mode 100644
index 0000000..bf09340
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/process_test.py
@@ -0,0 +1,673 @@
+# The MIT License
+#
+# Copyright (C) 2007 Chris Miles
+#
+# Copyright (C) 2008-2009 Floris Bruynooghe
+#
+# Copyright (C) 2008-2009 Abilisoft Ltd.
+#
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation files
+# (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge,
+# publish, distribute, sublicense, and/or sell copies of the Software,
+# and to permit persons to whom the Software is furnished to do so,
+# subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+"""Tests for the psi.process.Process class"""
+
+
+import grp
+import math
+import os
+import pwd
+import signal
+import sys
+import time
+import unittest
+import warnings
+
+from apphelper import *
+
+try:
+    import subprocess
+except ImportError:
+    HAVE_SUBPROCESS = False
+else:
+    HAVE_SUBPROCESS = True
+
+import psi
+import psi.arch
+import psi.process
+
+
+# Ignore FutureWarnings, we test those bits
+if sys.hexversion >= 0x02030000: # >= 2.3
+    warnings.simplefilter('ignore', FutureWarning)
+
+
+# Patch old versions of unittest
+if not hasattr(unittest.TestCase, 'assertTrue'):
+    unittest.TestCase.assertTrue = unittest.TestCase.failUnless
+if not hasattr(unittest.TestCase, 'assertFalse'):
+    unittest.TestCase.assertFalse = unittest.TestCase.failIf
+if not hasattr(unittest.TestCase, 'assertAlmostEqual'):
+    def assertAlmostEqual(self, first, second, places=7, msg=None):
+        """Stolen from Python 2.5"""
+        if round(second-first, places) != 0:
+            raise self.failureException(
+                msg or '%r != %r within %r places'
+                % (first, second, places))
+    unittest.TestCase.assertAlmostEqual = assertAlmostEqual
+
+
+def do_work():
+    """Make sure total CPU time of our process increases"""
+    t = 0
+    e = time.clock() + 0.05
+    if isinstance(psi.arch.arch_type(), psi.arch.ArchAIX):
+        e += 0.8
+    while t < e:
+        for i in range(100):
+            math.sin(i)
+        t = time.clock()
+
+
+class ExceptionTest(unittest.TestCase):
+    def test_class(self):
+        self.assert_(issubclass(psi.process.NoSuchProcessError,
+                                psi.MissingResourceError))
+
+    def test_instance(self):
+        np = psi.process.NoSuchProcessError('foo')
+        self.assert_(isinstance(np, psi.MissingResourceError))
+
+
+class ProcessInitTest(unittest.TestCase):
+    def setUp(self):
+        self.pid = os.getpid()
+        self.p = psi.process.Process(self.pid)
+
+    def test_type(self):
+        self.assert_(isinstance(self.p, psi.process.Process))
+
+    def test_bad_kw_arg(self):
+        self.assertRaises(TypeError, psi.process.Process, foo=1)
+
+    def test_bad_pos_arg(self):
+        self.assertRaises(TypeError, psi.process.Process, 'foo')
+
+    def test_no_such_pid(self):
+        # may not work in rare circumstances ... see how we go
+        self.assertRaises(psi.process.NoSuchProcessError,
+                          psi.process.Process, pid=-1)
+
+    def test_pid(self):
+        self.assertEqual(self.p.pid, self.pid)
+
+
+class ProcessSpecialMethods(unittest.TestCase):
+    def setUp(self):
+        self.pid = os.getpid()
+        self.p = psi.process.Process(self.pid)
+
+    def test_repr(self):
+        self.assertEqual('psi.process.Process(pid=%d)'%self.pid, repr(self.p))
+
+    def test_hash_works(self):
+        self.assertTrue(hash(self.p))
+
+    def test_hash_compare(self):
+        p = psi.process.Process(self.pid)
+        self.assertEqual(hash(self.p), hash(p))
+
+
+class RichCompareTest(unittest.TestCase):
+    def setUp(self):
+        self.pid = os.getpid()
+        self.p = psi.process.Process(self.pid)
+        self.init = psi.process.Process(1)
+
+    def test_eq(self):
+        self.assertEqual(self.p, self.p)
+        self.assertEqual(self.p, psi.process.Process(self.pid))
+
+    def test_ne(self):
+        self.assertNotEqual(self.p, self.pid)
+        self.assertNotEqual(self.p, self.init)
+
+    def test_lt(self):
+        self.assertTrue(self.init < self.p)
+        self.assertFalse(self.p < self.p)
+        self.assertFalse(self.p < self.init)
+
+    def test_le(self):
+        self.assertTrue(self.init <= self.p)
+        self.assertTrue(self.p <= self.p)
+        self.assertFalse(self.p <= self.init)
+
+    def test_gt(self):
+        self.assertFalse(self.init > self.p)
+        self.assertFalse(self.p > self.p)
+        self.assertTrue(self.p > self.init)
+
+    def test_ge(self):
+        self.assertFalse(self.init >= self.p)
+        self.assertTrue(self.p >= self.p)
+        self.assertTrue(self.p >= self.init)
+
+
+class ProcessExeArgsEnvTest(unittest.TestCase):
+    def setUp(self):
+        self.pid = os.getpid()
+        self.p = psi.process.Process(self.pid)
+        self.arch = psi.arch.arch_type()
+        self.args_short = ['abcdefghijklmnopqrtstuvw']
+        self.args_long = 50 * self.args_short
+        self.env = {'foo': 'fooenv',
+                    'bar': 'barenv',
+                    'baz': 'bazenv'}
+        self.app = None
+
+    def tearDown(self):
+        if self.app is not None:
+            self.app.kill()
+
+    def test_name(self):
+        # Lets assume that 'python' will at least appear inside our name
+        if isinstance(self.arch, psi.arch.ArchDarwin):
+            python_name = 'Python'  # OS X
+        else:
+            python_name = 'python'
+        self.assert_(self.p.name.find(python_name) >= 0)
+
+    def test_exe(self):
+        if (isinstance(self.arch, psi.arch.ArchLinux) or
+            (isinstance(self.arch, psi.arch.ArchSunOS) and
+             self.arch.release_info >= (5, 10))):
+            self.assertTrue(os.path.isabs(self.p.exe), self.p.exe)
+        elif isinstance(self.arch, psi.arch.ArchDarwin):
+            self.assertTrue(self.p.exe.endswith('Python'))
+        else:
+            self.assertTrue(self.p.exe.find('python') >= 0)
+
+    def test_args_simple(self):
+        self.assert_('python' ' '.join(self.p.args).lower())
+
+    def test_argc_simple(self):
+        self.assertTrue(self.p.argc > len(sys.argv))
+
+    def test_command(self):
+        calc_comm = ' '.join(self.p.args)
+        psi_comm = self.p.command
+        self.assertEqual(psi_comm, calc_comm[:len(psi_comm)])
+
+    def test_env_simple(self):
+        self.assertEqual(self.p.env['HOME'], os.path.expanduser('~'))
+
+
+    if APP32:
+        def test_env_32bit(self):
+            self.app = TestApp([APP32], env=self.env)
+            p = psi.process.Process(self.app.pid)
+            self.assertEqual(p.env, self.env)
+
+        def test_args_32bit_short(self):
+            self.app = TestApp([APP32] + self.args_short)
+            p = psi.process.Process(self.app.pid)
+            self.assertEqual(p.args, tuple([APP32] + self.args_short))
+
+        def test_args_32bit_long(self):
+            self.app = TestApp([APP32] + self.args_long)
+            p = psi.process.Process(self.app.pid)
+            self.assertEqual(p.args, tuple([APP32] + self.args_long))
+
+        def test_args_32bit_longarg(self):
+            args = [APP32, 'arg_longer_then_fifty_characters'*2]
+            self.app = TestApp(args)
+            p = psi.process.Process(self.app.pid)
+            self.assertEqual(p.args[1], args[1])
+
+        def test_argc_32bit(self):
+            self.app = TestApp([APP32, 'foo', 'bar'])
+            p = psi.process.Process(self.app.pid)
+            self.assertEqual(p.argc, 3)
+
+    if APP64:
+        def test_env_64bit(self):
+            self.app = TestApp([APP64], env=self.env)
+            p = psi.process.Process(self.app.pid)
+            self.assertEqual(p.env, self.env)
+
+        def test_args_64bit_short(self):
+            self.app = TestApp([APP64] + self.args_short)
+            p = psi.process.Process(self.app.pid)
+            self.assertEqual(p.args, tuple([APP64] + self.args_short))
+
+        def test_args_64bit_long(self):
+            self.app = TestApp([APP64] + self.args_long)
+            p = psi.process.Process(self.app.pid)
+            self.assertEqual(p.args, tuple([APP64] + self.args_long))
+
+        def test_args_64bit_longarg(self):
+            args = [APP64, 'arg_longer_then_fifty_characters'*2]
+            self.app = TestApp(args)
+            p = psi.process.Process(self.app.pid)
+            self.assertEqual(p.args[1], args[1])
+
+        def test_argc_64bit(self):
+            self.app = TestApp([APP64] + ['foo', 'bar'])
+            p = psi.process.Process(self.app.pid)
+            self.assertEqual(p.argc, 3)
+
+
+class ProcessIdsTest(unittest.TestCase):
+    def setUp(self):
+        self.pid = os.getpid()
+        self.p = psi.process.Process(self.pid)
+
+    def test_euid(self):
+        self.assertEqual(self.p.euid, os.geteuid())
+
+    def test_egid(self):
+        self.assertEqual(self.p.egid, os.getegid())
+
+    def test_ruid(self):
+        self.assertEqual(self.p.ruid, os.getuid())
+
+    def test_rgid(self):
+        self.assertEqual(self.p.rgid, os.getgid())
+
+
+class ProcessAttrsTest(unittest.TestCase):
+    def setUp(self):
+        self.arch = psi.arch.arch_type()
+        self.pid = os.getpid()
+        self.p = psi.process.Process(self.pid)
+
+    def test_cwd(self):
+        if isinstance(self.arch, psi.arch.ArchDarwin):
+            self.assertRaises(psi.AttrNotAvailableError, getattr, self.p, 'cwd')
+        else:
+            self.assertEqual(os.path.normpath(self.p.cwd), os.getcwd())
+
+    def test_ppid(self):
+        self.assert_(self.p.ppid > 1)
+        self.assertEqual(type(self.p.ppid), type(self.p.pid))
+
+    def test_pgrp(self):
+        pgrp = pscmd('pgrp')
+        self.assertEqual(self.p.pgrp, int(pgrp))
+
+    def test_sid(self):
+        sid = pscmd('sid')
+        self.assertEqual(self.p.sid, int(sid))
+
+    def test_nthreads(self):
+        if isinstance(self.arch, psi.arch.ArchLinux) \
+                and self.arch.release[:3] == '2.4':
+            return
+        if isinstance(self.arch, psi.arch.ArchSunOS):
+            nlwp = pscmd('nlwp')
+            self.assertEqual(self.p.nthreads, int(nlwp))
+        else:
+            self.assertEqual(self.p.nthreads, 1)
+
+    def test_terminal(self):
+        if isinstance(self.arch, psi.arch.ArchSunOS) \
+                and self.arch.release in ['5.8', '5.9']:
+            return
+        if not HAVE_SUBPROCESS:
+            return
+
+        terminal = subprocess.Popen(['/usr/bin/tty'],
+                                    stdout=subprocess.PIPE).communicate()[0]
+        terminal = terminal.decode()
+        self.assertEqual(self.p.terminal, terminal.strip())
+
+    def test_status(self):
+        if isinstance(self.arch, psi.arch.ArchLinux):
+            self.assertEqual(self.p.status, psi.process.PROC_STATUS_RUNNING)
+        elif isinstance(self.arch, psi.arch.ArchSunOS):
+            if hasattr(psi.process, 'PROC_STATUS_SONPROC'):
+                self.assertEqual(self.p.status, psi.process.PROC_STATUS_SONPROC)
+            else:
+                self.assertEqual(self.p.status, psi.process.PROC_STATUS_SRUN)
+        elif isinstance(self.arch, psi.arch.ArchAIX):
+            self.assertEqual(self.p.status, psi.process.PROC_STATUS_SACTIVE)
+
+    def test_nice(self):
+        # XXX Also need to test non-default nice values.
+        ni = pscmd('ni')
+        self.assertEqual(self.p.nice, int(ni))
+
+
+class ProcessPriorityTest(unittest.TestCase):
+    if os.uname()[0] == 'AIX':
+        def test_range(self):
+            p = psi.process.Process(os.getpid())
+            self.assertTrue(0 <= p.priority <= 255)
+
+    # XXX Add tests_range like tests for Linux and SunOS.
+
+
+class ProcessTimeTest(unittest.TestCase):
+    def setUp(self):
+        self.pid = os.getpid()
+        self.p = psi.process.Process(self.pid)
+        self.arch = psi.arch.arch_type()
+
+    def test_start_time(self):
+        self.assert_(isinstance(self.p.start_time, psi.TimeSpec))
+
+        # Due to rounding errors and CPUs being able to do lots within
+        # just one jiffie/tick it can appear that we started after
+        # now, at least on Linux.
+        # By assuming we haven't been running for more then 20 minutes
+        # we can more accurately detect if the timezone handling is correct
+
+        now = time.time() + 1
+        before_start = now - 20*60
+        self.assert_(before_start < self.p.start_time.timestamp() <= now,
+                     '%s < %s <= %s' %
+                     (before_start, self.p.start_time.timestamp(), now))
+
+        localnow = time.time() + time.timezone + 1
+        if time.daylight:
+            localnow += time.altzone
+        before_start = localnow - 20*60
+        self.assert_(before_start < self.p.start_time.mktime() <= localnow,
+                     '%s < %s <= %s' %
+                     (before_start, self.p.start_time.mktime(), localnow))
+
+    def test_jiffies(self):
+        if isinstance(self.arch, psi.arch.ArchLinux):
+            f = open('/proc/%d/stat' % self.pid)
+            try:
+                stat = f.read().split()
+            finally:
+                f.close()
+            self.assertEqual(self.p.jiffies, int(stat[21]))
+
+
+class ProcessCpuTest(unittest.TestCase):
+    def setUp(self):
+        self.pid = os.getpid()
+        self.p = psi.process.Process(self.pid)
+
+    def test_cputime(self):
+        self.assert_(isinstance(self.p.cputime, psi.TimeSpec))
+        self.assert_(self.p.cputime >= (0, 0))
+
+    def test_utime(self):
+        self.assert_(isinstance(self.p.utime, psi.TimeSpec))
+        self.assert_(self.p.utime >= (0, 0))
+
+    def test_stime(self):
+        self.assert_(isinstance(self.p.stime, psi.TimeSpec))
+        self.assert_(self.p.stime >= (0, 0))
+
+    def test_cputime_sum(self):
+        variance = psi.TimeSpec(1, 0)
+        min = self.p.cputime - variance
+        max = self.p.cputime + variance
+        self.assert_(min < self.p.utime+self.p.stime < max,
+                     '%s < %s < %s' % (min, self.p.utime+self.p.stime, max))
+
+    def test_cputime_increases(self):
+        do_work()
+        p = psi.process.Process(self.pid)
+        assert self.p.cputime < p.cputime
+
+
+    if hasattr(psi.process.Process, 'pcpu'):
+        def test_pcpu(self):
+            self.assertTrue(0 <= self.p.pcpu <= 100)
+
+
+class ProcessMemTest(unittest.TestCase):
+    def setUp(self):
+        self.pid = os.getpid()
+        self.p = psi.process.Process(self.pid)
+        self.arch = psi.arch.arch_type()
+
+    def test_rss(self):
+        self.assert_(self.p.rss > 0)
+
+    def test_vsz(self):
+        self.assert_(self.p.vsz > 0)
+
+    def test_rss_vs_vsz(self):
+        if isinstance(self.arch, psi.arch.ArchAIX):
+            # On AIX the VSZ is only the data section of the virtual
+            # size since that's what ps(1) does there.  This means
+            # that often (but not always) the RSS value will be larger
+            # then the VSZ value, depending on the amount of data in
+            # the shared libraries.
+            return
+        self.assert_(self.p.rss < self.p.vsz,
+                     "%d < %d" % (self.p.rss, self.p.vsz))
+
+    def test_rss_ps(self):
+        rss = int(pscmd('rssize'))
+        rss_min = rss - rss*0.1
+        rss_max = rss + rss*0.1
+        self.assert_(rss_min < self.p.rss/1024 < rss_max,
+                     '%s < %s < %s' % (rss_min, self.p.rss/1024, rss_max))
+
+    def test_vsz_ps(self):
+        vsz = int(pscmd('vsz'))
+        self.assert_(vsz*0.8 < self.p.vsz/1024 < vsz*1.2,
+                     '%s < %s < %s' % (vsz*0.8, self.p.vsz/1024, vsz*1.2))
+
+
+class ConstantsTest(unittest.TestCase):
+    def test_status_codes(self):
+        stat_names = [s for s in dir(psi.process)
+                      if s.startswith('PROC_STATUS_')]
+        self.assert_(len(stat_names) > 0)
+        for name in stat_names:
+            attr = getattr(psi.process, name)
+            self.assert_(isinstance(attr, int))
+
+
+class ProcessPrivsTest(unittest.TestCase):
+    def test_init_works(self):
+        p = psi.process.Process(1)
+        self.assertEqual(p.euid, 0)
+
+
+if os.geteuid() == 0 and (APP32 or APP64):
+    class ProcessPriorityTest(unittest.TestCase):
+        def setUp(self):
+            self.appname = APP32 or APP64
+            self.app = None
+
+        def tearDown(self):
+            if self.app is not None:
+                self.app.kill()
+
+        if os.uname()[0] == 'Linux':
+            def test_sched_other(self):
+                self.app = TestApp(['/usr/bin/chrt',
+                                    '--other', '0', self.appname])
+                p = psi.process.Process(self.app.pid)
+                self.assertEqual(p.priority, 0)
+
+            def test_sched_fifo(self):
+                self.app = TestApp(['/usr/bin/chrt',
+                                    '--fifo', '42', self.appname])
+                p = psi.process.Process(self.app.pid)
+                self.assertEqual(p.priority, 42)
+
+            def test_sched_rr(self):
+                self.app = TestApp(['/usr/bin/chrt',
+                                    '--rr', '42', self.appname])
+                p = psi.process.Process(self.app.pid)
+                self.assertEqual(p.priority, 42)
+
+        if os.uname()[0] == 'SunOS':
+            def test_class_ts(self):
+                # This is a very bad class to test, we can't really
+                # assert anything since psi gets the real priority and
+                # not the user priority.  But on SunOS 8 the FX class
+                # is not available, so better have this test then none.
+                self.app = TestApp(['/usr/bin/priocntl', '-e',
+                                    '-c', 'TS', self.appname])
+                p = psi.process.Process(self.app.pid)
+                self.assertTrue(-60 <= p.priority <= 60,
+                                '-60 <= %d <= 60' % p.priority)
+
+            if psi.arch.arch_type().release_info > (5,8):
+                def test_class_fx(self):
+                    self.app = TestApp(['/usr/bin/priocntl', '-e',
+                                        '-c', 'FX', '-m', '60',
+                                        '-p', '42', self.appname])
+                    p = psi.process.Process(self.app.pid)
+                    self.assertEqual(p.priority, 42)
+
+        if os.uname()[0] == 'AIX':
+            def test_aixapp(self):
+                # aixapp runs under SCHED_RR at priority 42.
+                aixapp = os.path.join(os.path.dirname(__file__), 'aixapp')
+                self.app = TestApp([aixapp])
+                p = psi.process.Process(self.app.pid)
+                self.assertEqual(p.priority, 42)
+
+
+class RefreshTests(unittest.TestCase):
+    def test_refresh(self):
+        p = psi.process.Process(os.getpid())
+        pid = p.pid
+        ct = p.cputime
+        do_work()
+        p.refresh()
+        self.assertEqual(pid, p.pid)
+        self.assert_(ct < p.cputime, '%s < %s' % (ct, p.cputime))
+
+    def test_proc_gone(self):
+        app = TestApp(APP32 or APP64)
+        try:
+            p = psi.process.Process(app.pid)
+            app.kill()
+            app = None
+            self.assertRaises(psi.process.NoSuchProcessError, p.refresh)
+        finally:
+            if app is not None:
+                app.kill()
+
+
+class ChildrenTests(unittest.TestCase):
+    def setUp(self):
+        self.p = psi.process.Process(os.getpid())
+
+    def test_no_child(self):
+        children = self.p.children()
+        self.assertEqual(len(children), 0)
+
+    def test_one_child(self):
+        app = TestApp(APP32 or APP64)
+        try:
+            child = psi.process.Process(app.pid)
+            children = self.p.children()
+            self.assertEqual(len(children), 1)
+            self.assertEqual(children[0], child)
+        finally:
+            app.kill()
+
+
+class ExistsTests(unittest.TestCase):
+    def test_exists(self):
+        p = psi.process.Process(os.getpid())
+        self.assertEqual(p.exists(), True)
+
+    def test_dead(self):
+        app = TestApp(APP32 or APP64)
+        try:
+            p = psi.process.Process(app.pid)
+            app.kill()
+            app = None
+            self.assertEqual(p.exists(), False)
+        finally:
+            if app is not None:
+                app.kill()
+
+
+class KillTests(unittest.TestCase):
+    def setUp(self):
+        self.app = TestApp(APP32 or APP64)
+        self.p = psi.process.Process(self.app.pid)
+
+    def tearDown(self):
+        if self.app.pid:
+            self.app.kill()
+
+    def test_default(self):
+        self.p.kill()
+        t = 5.0
+        while t > 0:
+            os.waitpid(self.p.pid, os.WNOHANG)
+            if not self.p.exists():
+                break
+            time.sleep(0.05)
+            t -= 0.05
+        self.assertEqual(self.p.exists(), False)
+
+    def test_stop(self):
+        if isinstance(psi.arch.arch_type(), psi.arch.ArchLinux):
+            stop_status = psi.process.PROC_STATUS_STOPPED
+        else:
+            stop_status = psi.process.PROC_STATUS_SSTOP
+        self.p.kill(signal.SIGSTOP)
+        t = 5.0
+        while t > 0:
+            self.p.refresh()
+            if self.p.status == stop_status:
+                break
+            time.sleep(0.05)
+            t -= 0.05
+        self.assertEqual(self.p.status, stop_status)
+        self.p.kill(signal.SIGCONT)
+        self.p.refresh()
+        self.assertNotEqual(self.p.status, stop_status)
+        self.assertEqual(self.p.exists(), True)
+
+
+class ZombieTests(unittest.TestCase):
+    def setUp(self):
+        self.app = TestApp(APP32 or APP64)
+        self.app.kill_to_zombie()
+        a = psi.arch.arch_type()
+        if isinstance(a, psi.arch.ArchLinux):
+            self.zombie_stat = psi.process.PROC_STATUS_ZOMBIE
+        else:
+            self.zombie_stat = psi.process.PROC_STATUS_SZOMB
+
+    def tearDown(self):
+        if self.app.pid:
+            self.app.kill()
+
+    def test_zombie_no_err(self):
+        # Ensure no error during init when looking at a zombie
+        if isinstance(psi.arch.arch_type(), psi.arch.ArchDarwin):
+            # pause to allow process status to update
+            time.sleep(1)
+        p = psi.process.Process(self.app.pid)
+        self.assertEqual(p.status, self.zombie_stat)
+
+
+if __name__ == '__main__':
+    unittest.main()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/processtable_test.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/processtable_test.py b/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/processtable_test.py
new file mode 100644
index 0000000..ee38154
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/processtable_test.py
@@ -0,0 +1,90 @@
+# The MIT License
+#
+# Copyright (C) 2008-2009 Floris Bruynooghe
+#
+# Copyright (C) 2008-2009 Abilisoft Ltd.
+#
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation files
+# (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge,
+# publish, distribute, sublicense, and/or sell copies of the Software,
+# and to permit persons to whom the Software is furnished to do so,
+# subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+
+import os
+import unittest
+
+import psi
+
+
+class ProcessTableTests(unittest.TestCase):
+    def setUp(self):
+        self.archtype = psi.arch.arch_type()
+        self.pt = psi.process.ProcessTable()
+
+    def test_type(self):
+        self.assert_(isinstance(self.pt, psi.process.ProcessTable))
+        self.assert_(isinstance(self.pt, dict))
+
+    def test_len_nonzero(self):
+        self.assert_(len(self.pt) > 0)
+
+    def test_keys(self):
+        self.assert_(1 in self.pt)
+
+    def test_vals(self):
+        init = self.pt[1]
+        self.assert_(isinstance(init, psi.process.Process))
+
+    def test_setitem(self):
+        self.assertRaises(TypeError, self.pt.__setitem__, 123, 'dummy')
+
+    def test_delitem(self):
+        self.assertRaises(TypeError, self.pt.__delitem__, 1)
+
+
+class ProcessAttributeTests(unittest.TestCase):
+    """Check the bahaviour of some process attributes
+
+    Some process attributes must be present on all processes, these
+    tests check for this.
+    """
+    def setUp(self):
+        self.archtype = psi.arch.arch_type()
+
+    def test_name(self):
+        for p in psi.process.ProcessTable().values():
+            self.assert_(p.name, str(p))
+
+    def test_argc(self):
+        for p in psi.process.ProcessTable().values():
+            try:
+                self.assert_(p.argc >= 0, '%s, argc=%s' % (p, p.argc))
+            except psi.AttrInsufficientPrivsError:
+                if isinstance(self.archtype, psi.arch.ArchDarwin):
+                    self.assert_(p.euid != os.geteuid())
+                else:
+                    raise
+    
+    def test_command(self):
+        for p in psi.process.ProcessTable().values():
+            self.assert_(p.command, str(p))
+
+
+if __name__ == '__main__':
+    unittest.main()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/timespec_test.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/timespec_test.py b/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/timespec_test.py
new file mode 100644
index 0000000..3cf9839
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/tests/timespec_test.py
@@ -0,0 +1,233 @@
+# The MIT License
+#
+# Copyright (C) 2009 Erick Tryzelaar
+#
+# Copyright (C) 2009 Floris Bruynooghe
+#
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation files
+# (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge,
+# publish, distribute, sublicense, and/or sell copies of the Software,
+# and to permit persons to whom the Software is furnished to do so,
+# subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+
+import sys
+import time
+import unittest
+
+import psi
+
+try:
+    import datetime
+except ImportError:
+    HAVE_DATETIME = False
+else:
+    HAVE_DATETIME = True
+
+
+class TimeSpecTests(unittest.TestCase):
+    def setUp(self):
+        self.tv = psi.TimeSpec(5, 10)
+
+    def test_type(self):
+        self.assert_(isinstance(self.tv, psi.TimeSpec))
+
+    def test_init(self):
+        tv = psi.TimeSpec(5, 10)
+        self.assertEqual(tv.tv_sec, 5)
+        self.assertEqual(tv.tv_nsec, 10)
+        tv = psi.TimeSpec(tv_sec=6, tv_nsec=11)
+        self.assertEqual(tv.tv_sec, 6)
+        self.assertEqual(tv.tv_nsec, 11)
+
+    def test_init_normalise(self):
+        t = psi.TimeSpec(0, 1000000001)
+        self.assertEqual(t.tv_sec, 1)
+        self.assertEqual(t.tv_nsec, 1)
+        t = psi.TimeSpec(-1, -1000000001)
+        self.assertEqual(t.tv_sec, -1)
+        self.assertEqual(t.tv_nsec, -999999999)
+        t = psi.TimeSpec(0, -2000000000)
+        self.assertEqual(t.tv_sec, -2)
+        self.assertEqual(t.tv_nsec, 0)
+        t = psi.TimeSpec(-1, 500000000)
+        self.assertEqual(t.tv_sec, 0)
+        self.assertEqual(t.tv_nsec, -500000000)
+        t = psi.TimeSpec(1, -500000000)
+        self.assertEqual(t.tv_sec, 0)
+        self.assertEqual(t.tv_nsec, 500000000)
+
+    def test_tuple(self):
+        self.assertEqual(self.tv[0], 5)
+        self.assertEqual(self.tv[1], 10)
+        self.assertRaises(IndexError, self.tv.__getitem__, -1)
+        self.assertRaises(IndexError, self.tv.__getitem__, 2)
+
+    def test_hash(self):
+        self.assertEqual(hash(self.tv), hash(psi.TimeSpec(5, 10)))
+
+    def test_eq(self):
+        self.assertEqual(self.tv, psi.TimeSpec(5, 10))
+
+    def test_ne(self):
+        self.assertNotEqual(self.tv, psi.TimeSpec(5, 11))
+        self.assertNotEqual(self.tv, psi.TimeSpec(4, 10))
+        self.assertNotEqual(self.tv, psi.TimeSpec(4, 11))
+
+    def test_lt(self):
+        self.assert_(self.tv < psi.TimeSpec(5, 11))
+        self.assert_(self.tv < psi.TimeSpec(6, 10))
+        self.assert_(not self.tv < psi.TimeSpec(5, 9))
+        self.assert_(not self.tv < psi.TimeSpec(5, 10))
+
+    def test_lt_distorted(self):
+        self.assert_(self.tv < psi.TimeSpec(4, 1000000015))
+
+    def test_le(self):
+        self.assert_(self.tv <= psi.TimeSpec(5, 11))
+        self.assert_(self.tv <= psi.TimeSpec(5, 10))
+        self.assert_(not self.tv <= psi.TimeSpec(5, 9))
+
+    def test_gt(self):
+        self.assert_(self.tv > psi.TimeSpec(5, 9))
+        self.assert_(not self.tv > psi.TimeSpec(5, 10))
+
+    def test_gt_distorted(self):
+        self.assert_(psi.TimeSpec(4, 1000000015) > self.tv)
+
+    def test_ge(self):
+        self.assert_(self.tv >= psi.TimeSpec(5, 10))
+        self.assert_(self.tv >= psi.TimeSpec(5, 9))
+        self.assert_(not self.tv >= psi.TimeSpec(5, 11))
+
+    def test_compare_tuple(self):
+        self.assert_(self.tv > (5, 9))
+        self.assert_(self.tv >= (5, 9))
+        self.assert_(self.tv == (5, 10))
+        self.assert_((5, 10) == self.tv)
+        self.assert_(self.tv <= (5, 11))
+        self.assert_(self.tv < (5, 11))
+
+    def test_compare_int(self):
+        self.assert_(self.tv > 5)
+        self.assert_(self.tv != 5)
+        self.assert_(self.tv < 6)
+
+    def test_compare_float(self):
+        self.assert_(self.tv > 5.0)
+        self.assert_(self.tv != 5.0)
+        self.assert_(self.tv < 5.1)
+
+    if sys.version_info[0] < 3:
+        def test_compare_tuple_long(self):
+            self.assert_(self.tv == (long(5), long(10)))
+
+    def test_add(self):
+        self.assertEqual(self.tv + psi.TimeSpec(5, 10), psi.TimeSpec(10, 20))
+
+    def test_add_rollover(self):
+        sum = self.tv + psi.TimeSpec(0, 999999995)
+        self.assertEqual(sum, psi.TimeSpec(6, 5))
+
+    def test_add_tuple(self):
+        self.assertEqual(self.tv + (5, 10), psi.TimeSpec(10, 20))
+
+    def test_add_tuple_bad(self):
+        self.assertEqual(self.tv.__add__((5, 10, 0)), NotImplemented)
+
+    def test_add_int(self):
+        self.assertEqual(self.tv + 5, psi.TimeSpec(10, 10))
+
+    def test_add_float(self):
+        self.assertEqual(self.tv + 5.5, psi.TimeSpec(10, 500000010))
+
+    def test_sub(self):
+        self.assertEqual(self.tv - psi.TimeSpec(1, 5), psi.TimeSpec(4, 5))
+
+    def test_sub_rollover(self):
+        self.assertEqual(self.tv - psi.TimeSpec(0, 15),
+                         psi.TimeSpec(4, 999999995))
+
+    def test_sub_tuple(self):
+        self.assertEqual(self.tv - (1, 5), psi.TimeSpec(4, 5))
+
+    def test_sub_tuple_bad(self):
+        self.assertEqual(self.tv.__sub__((1, 5, 0)), NotImplemented)
+
+    def test_sub_int(self):
+        self.assertEqual(self.tv - 1, psi.TimeSpec(4, 10))
+
+    def test_sub_float(self):
+        self.assertEqual(self.tv - 1.5, psi.TimeSpec(3, 500000010))
+
+    def test_bool(self):
+        self.assertEqual(bool(self.tv), True)
+        self.assertEqual(bool(psi.TimeSpec(0, 0)), False)
+        self.assertEqual(bool(psi.TimeSpec(-1, -1)), True)
+
+
+class TimeSpecMethodsTests(unittest.TestCase):
+    def setUp(self):
+        self.tv = psi.TimeSpec(5, 500000000)
+
+    def test_timestamp(self):
+        self.assertEqual(self.tv.timestamp(), 5.5)
+
+    def test_float(self):
+        self.assertEqual(self.tv.float(), 5.5)
+
+    def test_mktime(self):
+        if time.daylight:
+            t = 5.5 + time.timezone + time.altzone
+        else:
+            t = 5.5 + time.timezone
+        self.assertEqual(self.tv.mktime(), t)
+
+    def test_timetuple(self):
+        self.assertEqual(self.tv.timetuple(), time.gmtime(5.5))
+
+    def test_gmtime(self):
+        self.assertEqual(self.tv.gmtime(), time.gmtime(5.5))
+
+    def test_localtime(self):
+        self.assertEqual(self.tv.localtime(), time.localtime(5.5))
+
+    def test_utcdatetime(self):
+        if HAVE_DATETIME:
+            self.assertEqual(self.tv.utcdatetime(),
+                             datetime.datetime.utcfromtimestamp(5.5))
+        else:
+            self.assert_(not hasattr(self.tv, 'utcdatetime'))
+
+    def test_datetime(self):
+        if HAVE_DATETIME:
+            self.assertEqual(self.tv.datetime(),
+                             datetime.datetime.fromtimestamp(5.5))
+        else:
+            self.assert_(not hasattr(self.tv, 'datetime'))
+
+    def test_timedelta(self):
+        if HAVE_DATETIME:
+            self.assertEqual(self.tv.timedelta(),
+                             datetime.timedelta(seconds=5, microseconds=500000))
+        else:
+            self.assert_(not hasattr(self.tv, 'timedelta'))
+
+
+if __name__ == '__main__':
+    unittest.main()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/lockfile-0.9.1/2.4.diff
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/lockfile-0.9.1/2.4.diff b/tools/bin/pythonSrc/lockfile-0.9.1/2.4.diff
new file mode 100644
index 0000000..72318d5
--- /dev/null
+++ b/tools/bin/pythonSrc/lockfile-0.9.1/2.4.diff
@@ -0,0 +1,99 @@
+Index: lockfile/sqlitelockfile.py
+===================================================================
+--- lockfile/sqlitelockfile.py	(revision 93)
++++ lockfile/sqlitelockfile.py	(working copy)
+@@ -1,9 +1,7 @@
+-from __future__ import absolute_import, division
+-
+ import time
+ import os
+ 
+-from . import LockBase, NotLocked, NotMyLock, LockTimeout, AlreadyLocked
++from lockfile import LockBase, NotLocked, NotMyLock, LockTimeout, AlreadyLocked
+ 
+ class SQLiteLockFile(LockBase):
+     "Demonstrate SQL-based locking."
+Index: lockfile/__init__.py
+===================================================================
+--- lockfile/__init__.py	(revision 93)
++++ lockfile/__init__.py	(working copy)
+@@ -24,16 +24,14 @@
+ >>> lock = LockFile('somefile')
+ >>> print lock.is_locked()
+ False
+->>> with lock:
+-...    print lock.is_locked()
+-True
+->>> print lock.is_locked()
+-False
+ 
+ >>> lock = LockFile('somefile')
+ >>> # It is okay to lock twice from the same thread...
+->>> with lock:
+-...     lock.acquire()
++>>> lock.acquire()
++>>> try:
++...   lock.acquire()
++... finally:
++...   lock.release()
+ ...
+ >>> # Though no counter is kept, so you can't unlock multiple times...
+ >>> print lock.is_locked()
+Index: lockfile/mkdirlockfile.py
+===================================================================
+--- lockfile/mkdirlockfile.py	(revision 93)
++++ lockfile/mkdirlockfile.py	(working copy)
+@@ -1,12 +1,10 @@
+-from __future__ import absolute_import, division
+-
+ import time
+ import os
+ import sys
+ import errno
+ 
+-from . import (LockBase, LockFailed, NotLocked, NotMyLock, LockTimeout,
+-               AlreadyLocked)
++from lockfile import (LockBase, LockFailed, NotLocked, NotMyLock, LockTimeout,
++                      AlreadyLocked)
+ 
+ class MkdirLockFile(LockBase):
+     """Lock file by creating a directory."""
+Index: lockfile/pidlockfile.py
+===================================================================
+--- lockfile/pidlockfile.py	(revision 96)
++++ lockfile/pidlockfile.py	(working copy)
+@@ -12,15 +12,13 @@
+ """ Lockfile behaviour implemented via Unix PID files.
+     """
+ 
+-from __future__ import absolute_import
+-
+ import os
+ import sys
+ import errno
+ import time
+ 
+-from . import (LockBase, AlreadyLocked, LockFailed, NotLocked, NotMyLock,
+-               LockTimeout)
++from lockfile import (LockBase, AlreadyLocked, LockFailed, NotLocked,
++                      NotMyLock, LockTimeout)
+ 
+ 
+ class PIDLockFile(LockBase):
+Index: lockfile/linklockfile.py
+===================================================================
+--- lockfile/linklockfile.py	(revision 93)
++++ lockfile/linklockfile.py	(working copy)
+@@ -1,10 +1,8 @@
+-from __future__ import absolute_import
+-
+ import time
+ import os
+ 
+-from . import (LockBase, LockFailed, NotLocked, NotMyLock, LockTimeout,
+-               AlreadyLocked)
++from lockfile import (LockBase, LockFailed, NotLocked, NotMyLock, LockTimeout,
++                      AlreadyLocked)
+ 
+ class LinkLockFile(LockBase):
+     """Lock access to a file using atomic property of link(2).

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/lockfile-0.9.1/ACKS
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/lockfile-0.9.1/ACKS b/tools/bin/pythonSrc/lockfile-0.9.1/ACKS
new file mode 100644
index 0000000..44519d1
--- /dev/null
+++ b/tools/bin/pythonSrc/lockfile-0.9.1/ACKS
@@ -0,0 +1,6 @@
+Thanks to the following people for help with lockfile.
+
+  Scott Dial
+  Ben Finney
+  Frank Niessink
+  Konstantin Veretennicov

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/lockfile-0.9.1/LICENSE
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/lockfile-0.9.1/LICENSE b/tools/bin/pythonSrc/lockfile-0.9.1/LICENSE
new file mode 100644
index 0000000..610c079
--- /dev/null
+++ b/tools/bin/pythonSrc/lockfile-0.9.1/LICENSE
@@ -0,0 +1,21 @@
+This is the MIT license: http://www.opensource.org/licenses/mit-license.php
+
+Copyright (c) 2007 Skip Montanaro.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to
+deal in the Software without restriction, including without limitation the
+rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+IN THE SOFTWARE.

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/lockfile-0.9.1/MANIFEST
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/lockfile-0.9.1/MANIFEST b/tools/bin/pythonSrc/lockfile-0.9.1/MANIFEST
new file mode 100644
index 0000000..d302eef
--- /dev/null
+++ b/tools/bin/pythonSrc/lockfile-0.9.1/MANIFEST
@@ -0,0 +1,19 @@
+2.4.diff
+ACKS
+LICENSE
+MANIFEST
+README
+RELEASE-NOTES
+setup.py
+doc/Makefile
+doc/conf.py
+doc/glossary.rst
+doc/index.rst
+doc/lockfile.rst
+lockfile/__init__.py
+lockfile/linklockfile.py
+lockfile/mkdirlockfile.py
+lockfile/pidlockfile.py
+lockfile/sqlitelockfile.py
+test/compliancetest.py
+test/test_lockfile.py

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/lockfile-0.9.1/PKG-INFO
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/lockfile-0.9.1/PKG-INFO b/tools/bin/pythonSrc/lockfile-0.9.1/PKG-INFO
new file mode 100644
index 0000000..7d897e8
--- /dev/null
+++ b/tools/bin/pythonSrc/lockfile-0.9.1/PKG-INFO
@@ -0,0 +1,51 @@
+Metadata-Version: 1.0
+Name: lockfile
+Version: 0.9.1
+Summary: Platform-independent file locking module
+Home-page: http://code.google.com/p/pylockfile/
+Author: Skip Montanaro
+Author-email: skip@pobox.com
+License: MIT License
+Download-URL: http://code.google.com/p/pylockfile/downloads/detail?name=lockfile-0.9.1.tar.gz
+Description: The lockfile package exports a LockFile class which provides a simple API for
+        locking files.  Unlike the Windows msvcrt.locking function, the fcntl.lockf
+        and flock functions, and the deprecated posixfile module, the API is
+        identical across both Unix (including Linux and Mac) and Windows platforms.
+        The lock mechanism relies on the atomic nature of the link (on Unix) and
+        mkdir (on Windows) system calls.  An implementation based on SQLite is also
+        provided, more as a demonstration of the possibilities it provides than as
+        production-quality code.
+        
+        Note: In version 0.9 the API changed in two significant ways:
+        
+         * It changed from a module defining several classes to a package containing
+           several modules, each defining a single class.
+        
+         * Where classes had been named SomethingFileLock before the last two words
+           have been reversed, so that class is now SomethingLockFile.
+        
+        The previous module-level definitions of LinkFileLock, MkdirFileLock and
+        SQLiteFileLock will be retained until the 1.0 release.
+        
+        Download from:
+        
+            http://code.google.com/p/pylockfile/
+        
+        To install:
+        
+            python setup.py install
+        
+Platform: UNKNOWN
+Classifier: Development Status :: 4 - Beta
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Operating System :: MacOS
+Classifier: Operating System :: Microsoft :: Windows :: Windows NT/2000
+Classifier: Operating System :: POSIX
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2.4
+Classifier: Programming Language :: Python :: 2.5
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3.0
+Classifier: Topic :: Software Development :: Libraries :: Python Modules

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/lockfile-0.9.1/README
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/lockfile-0.9.1/README b/tools/bin/pythonSrc/lockfile-0.9.1/README
new file mode 100644
index 0000000..128b1f3
--- /dev/null
+++ b/tools/bin/pythonSrc/lockfile-0.9.1/README
@@ -0,0 +1,27 @@
+The lockfile package exports a LockFile class which provides a simple API for
+locking files.  Unlike the Windows msvcrt.locking function, the fcntl.lockf
+and flock functions, and the deprecated posixfile module, the API is
+identical across both Unix (including Linux and Mac) and Windows platforms.
+The lock mechanism relies on the atomic nature of the link (on Unix) and
+mkdir (on Windows) system calls.  An implementation based on SQLite is also
+provided, more as a demonstration of the possibilities it provides than as
+production-quality code.
+
+Note: In version 0.9 the API changed in two significant ways:
+
+ * It changed from a module defining several classes to a package containing
+   several modules, each defining a single class.
+
+ * Where classes had been named SomethingFileLock before the last two words
+   have been reversed, so that class is now SomethingLockFile.
+
+The previous module-level definitions of LinkFileLock, MkdirFileLock and
+SQLiteFileLock will be retained until the 1.0 release.
+
+Download from:
+
+    http://code.google.com/p/pylockfile/
+
+To install:
+
+    python setup.py install

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/lockfile-0.9.1/RELEASE-NOTES
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/lockfile-0.9.1/RELEASE-NOTES b/tools/bin/pythonSrc/lockfile-0.9.1/RELEASE-NOTES
new file mode 100644
index 0000000..8b452ed
--- /dev/null
+++ b/tools/bin/pythonSrc/lockfile-0.9.1/RELEASE-NOTES
@@ -0,0 +1,50 @@
+Version 0.9.1
+=============
+
+* This release moves the source location to Google Code.
+
+* Threaded support is currently broken.  (It might not actually be broken.
+  It might just be the tests which are broken.)
+
+Version 0.9
+===========
+
+* The lockfile module was reorganized into a package.
+
+* The names of the three main classes have changed as follows:
+
+    LinkFileLock -> LinkLockFile
+    MkdirFileLock -> MkdirLockFile
+    SQLiteFileLock -> SQLiteLockFile
+
+* A PIDLockFile class was added.
+
+Version 0.3
+===========
+
+* Fix 2.4.diff file error.
+
+* More documentation updates.
+
+Version 0.2
+===========
+
+* Added 2.4.diff file to patch lockfile to work with Python 2.4 (removes use
+  of with statement).
+
+* Renamed _FileLock base class to LockBase to expose it (and its docstrings)
+  to pydoc.
+
+* Got rid of time.sleep() calls in tests (thanks to Konstantin
+  Veretennicov).
+
+* Use thread.get_ident() as the thread discriminator.
+
+* Updated documentation a bit.
+
+* Added RELEASE-NOTES.
+
+Version 0.1
+===========
+
+* First release - All basic functionality there.

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/lockfile-0.9.1/doc/Makefile
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/lockfile-0.9.1/doc/Makefile b/tools/bin/pythonSrc/lockfile-0.9.1/doc/Makefile
new file mode 100644
index 0000000..1b1e8d2
--- /dev/null
+++ b/tools/bin/pythonSrc/lockfile-0.9.1/doc/Makefile
@@ -0,0 +1,73 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS    =
+SPHINXBUILD   = sphinx-build
+PAPER         =
+
+# Internal variables.
+PAPEROPT_a4     = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS   = -d .build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html web pickle htmlhelp latex changes linkcheck
+
+help:
+	@echo "Please use \`make <target>' where <target> is one of"
+	@echo "  html      to make standalone HTML files"
+	@echo "  pickle    to make pickle files (usable by e.g. sphinx-web)"
+	@echo "  htmlhelp  to make HTML files and a HTML help project"
+	@echo "  latex     to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+	@echo "  changes   to make an overview over all changed/added/deprecated items"
+	@echo "  linkcheck to check all external links for integrity"
+
+clean:
+	-rm -rf .build/*
+
+html:
+	mkdir -p .build/html .build/doctrees
+	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) .build/html
+	@echo
+	@echo "Build finished. The HTML pages are in .build/html."
+
+pickle:
+	mkdir -p .build/pickle .build/doctrees
+	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) .build/pickle
+	@echo
+	@echo "Build finished; now you can process the pickle files or run"
+	@echo "  sphinx-web .build/pickle"
+	@echo "to start the sphinx-web server."
+
+web: pickle
+
+htmlhelp:
+	mkdir -p .build/htmlhelp .build/doctrees
+	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) .build/htmlhelp
+	@echo
+	@echo "Build finished; now you can run HTML Help Workshop with the" \
+	      ".hhp project file in .build/htmlhelp."
+
+latex:
+	mkdir -p .build/latex .build/doctrees
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) .build/latex
+	@echo
+	@echo "Build finished; the LaTeX files are in .build/latex."
+	@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
+	      "run these through (pdf)latex."
+
+changes:
+	mkdir -p .build/changes .build/doctrees
+	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) .build/changes
+	@echo
+	@echo "The overview file is in .build/changes."
+
+linkcheck:
+	mkdir -p .build/linkcheck .build/doctrees
+	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) .build/linkcheck
+	@echo
+	@echo "Link check complete; look for any errors in the above output " \
+	      "or in .build/linkcheck/output.txt."
+
+html.zip: html
+	(cd .build/html ; zip -r ../../$@ *)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/lockfile-0.9.1/doc/conf.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/lockfile-0.9.1/doc/conf.py b/tools/bin/pythonSrc/lockfile-0.9.1/doc/conf.py
new file mode 100644
index 0000000..64678e9
--- /dev/null
+++ b/tools/bin/pythonSrc/lockfile-0.9.1/doc/conf.py
@@ -0,0 +1,179 @@
+# -*- coding: utf-8 -*-
+#
+# lockfile documentation build configuration file, created by
+# sphinx-quickstart on Sat Sep 13 17:54:17 2008.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# The contents of this file are pickled, so don't put values in the namespace
+# that aren't pickleable (module imports are okay, they're removed automatically).
+#
+# All configuration values have a default value; values that are commented out
+# serve to show the default value.
+
+import sys, os
+
+# If your extensions are in another directory, add it here. If the directory
+# is relative to the documentation root, use os.path.abspath to make it
+# absolute, like shown here.
+#sys.path.append(os.path.abspath('some/directory'))
+
+# General configuration
+# ---------------------
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = []
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['.templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The master toctree document.
+master_doc = 'lockfile'
+
+# General substitutions.
+project = 'lockfile'
+copyright = '2008, Skip Montanaro'
+
+# The default replacements for |version| and |release|, also used in various
+# other places throughout the built documents.
+#
+# The short X.Y version.
+version = '0.3'
+# The full version, including alpha/beta/rc tags.
+release = '0.3'
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+today_fmt = '%B %d, %Y'
+
+# List of documents that shouldn't be included in the build.
+#unused_docs = []
+
+# List of directories, relative to source directories, that shouldn't be searched
+# for source files.
+#exclude_dirs = []
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+
+# Options for HTML output
+# -----------------------
+
+# The style sheet to use for HTML and HTML Help pages. A file of that name
+# must exist either in Sphinx' static/ path, or in one of the custom paths
+# given in html_static_path.
+html_style = 'default.css'
+
+# The name for this set of Sphinx documents.  If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar.  Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (within the static path) to place at the top of
+# the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['.static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_use_modindex = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, the reST sources are included in the HTML build as _sources/<name>.
+#html_copy_source = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it.  The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = ''
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'lockfiledoc'
+
+
+# Options for LaTeX output
+# ------------------------
+
+# The paper size ('letter' or 'a4').
+#latex_paper_size = 'letter'
+
+# The font size ('10pt', '11pt' or '12pt').
+#latex_font_size = '10pt'
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, document class [howto/manual]).
+latex_documents = [
+  ('lockfile', 'lockfile.tex', 'lockfile Documentation',
+   'Skip Montanaro', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# Additional stuff for the LaTeX preamble.
+#latex_preamble = ''
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_use_modindex = True

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/lockfile-0.9.1/doc/glossary.rst
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/lockfile-0.9.1/doc/glossary.rst b/tools/bin/pythonSrc/lockfile-0.9.1/doc/glossary.rst
new file mode 100644
index 0000000..9401d48
--- /dev/null
+++ b/tools/bin/pythonSrc/lockfile-0.9.1/doc/glossary.rst
@@ -0,0 +1,15 @@
+.. _glossary:
+
+********
+Glossary
+********
+
+.. if you add new entries, keep the alphabetical sorting!
+
+.. glossary::
+
+   context manager
+      An object which controls the environment seen in a :keyword:`with`
+      statement by defining :meth:`__enter__` and :meth:`__exit__` methods.
+      See :pep:`343`.
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/lockfile-0.9.1/doc/index.rst
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/lockfile-0.9.1/doc/index.rst b/tools/bin/pythonSrc/lockfile-0.9.1/doc/index.rst
new file mode 100644
index 0000000..9718a68
--- /dev/null
+++ b/tools/bin/pythonSrc/lockfile-0.9.1/doc/index.rst
@@ -0,0 +1,22 @@
+.. lockfile documentation master file, created by sphinx-quickstart on Sat Sep 13 17:54:17 2008.
+   You can adapt this file completely to your liking, but it should at least
+   contain the root `toctree` directive.
+
+Welcome to lockfile's documentation!
+====================================
+
+Contents:
+
+.. toctree::
+   :maxdepth: 2
+
+   lockfile.rst
+   glossary.rst
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+


[03/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code

Posted by rl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/suite.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/suite.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/suite.py
new file mode 100644
index 0000000..370ca5f
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/suite.py
@@ -0,0 +1,287 @@
+"""TestSuite"""
+
+import sys
+import unittest
+from unittest2 import case, util
+
+__unittest = True
+
+
+class BaseTestSuite(unittest.TestSuite):
+    """A simple test suite that doesn't provide class or module shared fixtures.
+    """
+    def __init__(self, tests=()):
+        self._tests = []
+        self.addTests(tests)
+
+    def __repr__(self):
+        return "<%s tests=%s>" % (util.strclass(self.__class__), list(self))
+
+    def __eq__(self, other):
+        if not isinstance(other, self.__class__):
+            return NotImplemented
+        return list(self) == list(other)
+
+    def __ne__(self, other):
+        return not self == other
+
+    # Can't guarantee hash invariant, so flag as unhashable
+    __hash__ = None
+
+    def __iter__(self):
+        return iter(self._tests)
+
+    def countTestCases(self):
+        cases = 0
+        for test in self:
+            cases += test.countTestCases()
+        return cases
+
+    def addTest(self, test):
+        # sanity checks
+        if not hasattr(test, '__call__'):
+            raise TypeError("%r is not callable" % (repr(test),))
+        if isinstance(test, type) and issubclass(test,
+                                                 (case.TestCase, TestSuite)):
+            raise TypeError("TestCases and TestSuites must be instantiated "
+                            "before passing them to addTest()")
+        self._tests.append(test)
+
+    def addTests(self, tests):
+        if isinstance(tests, basestring):
+            raise TypeError("tests must be an iterable of tests, not a string")
+        for test in tests:
+            self.addTest(test)
+
+    def run(self, result):
+        for test in self:
+            if result.shouldStop:
+                break
+            test(result)
+        return result
+
+    def __call__(self, *args, **kwds):
+        return self.run(*args, **kwds)
+
+    def debug(self):
+        """Run the tests without collecting errors in a TestResult"""
+        for test in self:
+            test.debug()
+
+
+class TestSuite(BaseTestSuite):
+    """A test suite is a composite test consisting of a number of TestCases.
+
+    For use, create an instance of TestSuite, then add test case instances.
+    When all tests have been added, the suite can be passed to a test
+    runner, such as TextTestRunner. It will run the individual test cases
+    in the order in which they were added, aggregating the results. When
+    subclassing, do not forget to call the base class constructor.
+    """
+    
+
+    def run(self, result):
+        self._wrapped_run(result)
+        self._tearDownPreviousClass(None, result)
+        self._handleModuleTearDown(result)
+        return result
+
+    def debug(self):
+        """Run the tests without collecting errors in a TestResult"""
+        debug = _DebugResult()
+        self._wrapped_run(debug, True)
+        self._tearDownPreviousClass(None, debug)
+        self._handleModuleTearDown(debug)
+
+    ################################
+    # private methods
+    def _wrapped_run(self, result, debug=False):
+        for test in self:
+            if result.shouldStop:
+                break
+            
+            if _isnotsuite(test):
+                self._tearDownPreviousClass(test, result)
+                self._handleModuleFixture(test, result)
+                self._handleClassSetUp(test, result)
+                result._previousTestClass = test.__class__
+                
+                if (getattr(test.__class__, '_classSetupFailed', False) or 
+                    getattr(result, '_moduleSetUpFailed', False)):
+                    continue
+            
+            if hasattr(test, '_wrapped_run'):
+                test._wrapped_run(result, debug)
+            elif not debug:
+                test(result)
+            else:
+                test.debug()
+    
+    def _handleClassSetUp(self, test, result):
+        previousClass = getattr(result, '_previousTestClass', None)
+        currentClass = test.__class__
+        if currentClass == previousClass:
+            return
+        if result._moduleSetUpFailed:
+            return
+        if getattr(currentClass, "__unittest_skip__", False):
+            return
+        
+        try:
+            currentClass._classSetupFailed = False
+        except TypeError:
+            # test may actually be a function
+            # so its class will be a builtin-type
+            pass
+            
+        setUpClass = getattr(currentClass, 'setUpClass', None)
+        if setUpClass is not None:
+            try:
+                setUpClass()
+            except Exception, e:
+                if isinstance(result, _DebugResult):
+                    raise
+                currentClass._classSetupFailed = True
+                className = util.strclass(currentClass)
+                errorName = 'setUpClass (%s)' % className
+                self._addClassOrModuleLevelException(result, e, errorName)
+    
+    def _get_previous_module(self, result):
+        previousModule = None
+        previousClass = getattr(result, '_previousTestClass', None)
+        if previousClass is not None:
+            previousModule = previousClass.__module__
+        return previousModule
+        
+        
+    def _handleModuleFixture(self, test, result):
+        previousModule = self._get_previous_module(result)
+        currentModule = test.__class__.__module__
+        if currentModule == previousModule:
+            return
+        
+        self._handleModuleTearDown(result)
+
+        
+        result._moduleSetUpFailed = False
+        try:
+            module = sys.modules[currentModule]
+        except KeyError:
+            return
+        setUpModule = getattr(module, 'setUpModule', None)
+        if setUpModule is not None:
+            try:
+                setUpModule()
+            except Exception, e:
+                if isinstance(result, _DebugResult):
+                    raise
+                result._moduleSetUpFailed = True
+                errorName = 'setUpModule (%s)' % currentModule
+                self._addClassOrModuleLevelException(result, e, errorName)
+
+    def _addClassOrModuleLevelException(self, result, exception, errorName):
+        error = _ErrorHolder(errorName)
+        addSkip = getattr(result, 'addSkip', None)
+        if addSkip is not None and isinstance(exception, case.SkipTest):
+            addSkip(error, str(exception))
+        else:
+            result.addError(error, sys.exc_info())
+    
+    def _handleModuleTearDown(self, result):
+        previousModule = self._get_previous_module(result)
+        if previousModule is None:
+            return
+        if result._moduleSetUpFailed:
+            return
+            
+        try:
+            module = sys.modules[previousModule]
+        except KeyError:
+            return
+
+        tearDownModule = getattr(module, 'tearDownModule', None)
+        if tearDownModule is not None:
+            try:
+                tearDownModule()
+            except Exception, e:
+                if isinstance(result, _DebugResult):
+                    raise
+                errorName = 'tearDownModule (%s)' % previousModule
+                self._addClassOrModuleLevelException(result, e, errorName)
+    
+    def _tearDownPreviousClass(self, test, result):
+        previousClass = getattr(result, '_previousTestClass', None)
+        currentClass = test.__class__
+        if currentClass == previousClass:
+            return
+        if getattr(previousClass, '_classSetupFailed', False):
+            return
+        if getattr(result, '_moduleSetUpFailed', False):
+            return
+        if getattr(previousClass, "__unittest_skip__", False):
+            return
+        
+        tearDownClass = getattr(previousClass, 'tearDownClass', None)
+        if tearDownClass is not None:
+            try:
+                tearDownClass()
+            except Exception, e:
+                if isinstance(result, _DebugResult):
+                    raise
+                className = util.strclass(previousClass)
+                errorName = 'tearDownClass (%s)' % className
+                self._addClassOrModuleLevelException(result, e, errorName)
+
+
+class _ErrorHolder(object):
+    """
+    Placeholder for a TestCase inside a result. As far as a TestResult
+    is concerned, this looks exactly like a unit test. Used to insert
+    arbitrary errors into a test suite run.
+    """
+    # Inspired by the ErrorHolder from Twisted:
+    # http://twistedmatrix.com/trac/browser/trunk/twisted/trial/runner.py
+
+    # attribute used by TestResult._exc_info_to_string
+    failureException = None
+
+    def __init__(self, description):
+        self.description = description
+
+    def id(self):
+        return self.description
+
+    def shortDescription(self):
+        return None
+
+    def __repr__(self):
+        return "<ErrorHolder description=%r>" % (self.description,)
+
+    def __str__(self):
+        return self.id()
+
+    def run(self, result):
+        # could call result.addError(...) - but this test-like object
+        # shouldn't be run anyway
+        pass
+
+    def __call__(self, result):
+        return self.run(result)
+
+    def countTestCases(self):
+        return 0
+
+def _isnotsuite(test):
+    "A crude way to tell apart testcases and suites with duck-typing"
+    try:
+        iter(test)
+    except TypeError:
+        return True
+    return False
+
+
+class _DebugResult(object):
+    "Used by the TestSuite to hold previous class when running in debug."
+    _previousTestClass = None
+    _moduleSetUpFailed = False
+    shouldStop = False

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/__init__.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/__init__.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/__init__.py
new file mode 100644
index 0000000..4287ca8
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/__init__.py
@@ -0,0 +1 @@
+#
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/dummy.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/dummy.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/dummy.py
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/support.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/support.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/support.py
new file mode 100644
index 0000000..a006b45
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/support.py
@@ -0,0 +1,177 @@
+import sys
+import warnings
+
+import unittest2
+
+
+def resultFactory(*_):
+    return unittest2.TestResult()
+
+class OldTestResult(object):
+    """An object honouring TestResult before startTestRun/stopTestRun."""
+
+    def __init__(self, *_):
+        self.failures = []
+        self.errors = []
+        self.testsRun = 0
+        self.shouldStop = False
+
+    def startTest(self, test):
+        pass
+
+    def stopTest(self, test):
+        pass
+
+    def addError(self, test, err):
+        self.errors.append((test, err))
+
+    def addFailure(self, test, err):
+        self.failures.append((test, err))
+
+    def addSuccess(self, test):
+        pass
+
+    def wasSuccessful(self):
+        return True
+
+    def printErrors(self):
+        pass
+
+class LoggingResult(unittest2.TestResult):
+    def __init__(self, log):
+        self._events = log
+        super(LoggingResult, self).__init__()
+
+    def startTest(self, test):
+        self._events.append('startTest')
+        super(LoggingResult, self).startTest(test)
+
+    def startTestRun(self):
+        self._events.append('startTestRun')
+        super(LoggingResult, self).startTestRun()
+
+    def stopTest(self, test):
+        self._events.append('stopTest')
+        super(LoggingResult, self).stopTest(test)
+
+    def stopTestRun(self):
+        self._events.append('stopTestRun')
+        super(LoggingResult, self).stopTestRun()
+
+    def addFailure(self, *args):
+        self._events.append('addFailure')
+        super(LoggingResult, self).addFailure(*args)
+
+    def addSuccess(self, *args):
+        self._events.append('addSuccess')
+        super(LoggingResult, self).addSuccess(*args)
+
+    def addError(self, *args):
+        self._events.append('addError')
+        super(LoggingResult, self).addError(*args)
+
+    def addSkip(self, *args):
+        self._events.append('addSkip')
+        super(LoggingResult, self).addSkip(*args)
+
+    def addExpectedFailure(self, *args):
+        self._events.append('addExpectedFailure')
+        super(LoggingResult, self).addExpectedFailure(*args)
+
+    def addUnexpectedSuccess(self, *args):
+        self._events.append('addUnexpectedSuccess')
+        super(LoggingResult, self).addUnexpectedSuccess(*args)
+
+
+class EqualityMixin(object):
+    """Used as a mixin for TestCase"""
+
+    # Check for a valid __eq__ implementation
+    def test_eq(self):
+        for obj_1, obj_2 in self.eq_pairs:
+            self.assertEqual(obj_1, obj_2)
+            self.assertEqual(obj_2, obj_1)
+
+    # Check for a valid __ne__ implementation
+    def test_ne(self):
+        for obj_1, obj_2 in self.ne_pairs:
+            self.assertNotEqual(obj_1, obj_2)
+            self.assertNotEqual(obj_2, obj_1)
+
+class HashingMixin(object):
+    """Used as a mixin for TestCase"""
+
+    # Check for a valid __hash__ implementation
+    def test_hash(self):
+        for obj_1, obj_2 in self.eq_pairs:
+            try:
+                if not hash(obj_1) == hash(obj_2):
+                    self.fail("%r and %r do not hash equal" % (obj_1, obj_2))
+            except KeyboardInterrupt:
+                raise
+            except Exception, e:
+                self.fail("Problem hashing %r and %r: %s" % (obj_1, obj_2, e))
+
+        for obj_1, obj_2 in self.ne_pairs:
+            try:
+                if hash(obj_1) == hash(obj_2):
+                    self.fail("%s and %s hash equal, but shouldn't" %
+                              (obj_1, obj_2))
+            except KeyboardInterrupt:
+                raise
+            except Exception, e:
+                self.fail("Problem hashing %s and %s: %s" % (obj_1, obj_2, e))
+
+
+
+# copied from Python 2.6
+try:
+    from warnings import catch_warnings
+except ImportError:
+    class catch_warnings(object):
+        def __init__(self, record=False, module=None):
+            self._record = record
+            self._module = sys.modules['warnings']
+            self._entered = False
+    
+        def __repr__(self):
+            args = []
+            if self._record:
+                args.append("record=True")
+            name = type(self).__name__
+            return "%s(%s)" % (name, ", ".join(args))
+    
+        def __enter__(self):
+            if self._entered:
+                raise RuntimeError("Cannot enter %r twice" % self)
+            self._entered = True
+            self._filters = self._module.filters
+            self._module.filters = self._filters[:]
+            self._showwarning = self._module.showwarning
+            if self._record:
+                log = []
+                def showwarning(*args, **kwargs):
+                    log.append(WarningMessage(*args, **kwargs))
+                self._module.showwarning = showwarning
+                return log
+            else:
+                return None
+    
+        def __exit__(self, *exc_info):
+            if not self._entered:
+                raise RuntimeError("Cannot exit %r without entering first" % self)
+            self._module.filters = self._filters
+            self._module.showwarning = self._showwarning
+
+    class WarningMessage(object):
+        _WARNING_DETAILS = ("message", "category", "filename", "lineno", "file",
+                            "line")
+        def __init__(self, message, category, filename, lineno, file=None,
+                        line=None):
+            local_values = locals()
+            for attr in self._WARNING_DETAILS:
+                setattr(self, attr, local_values[attr])
+            self._category_name = None
+            if category.__name__:
+                self._category_name = category.__name__
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_assertions.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_assertions.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_assertions.py
new file mode 100644
index 0000000..02bdc86
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_assertions.py
@@ -0,0 +1,254 @@
+import datetime
+
+import unittest2
+
+
+class Test_Assertions(unittest2.TestCase):
+    def test_AlmostEqual(self):
+        self.assertAlmostEqual(1.00000001, 1.0)
+        self.assertNotAlmostEqual(1.0000001, 1.0)
+        self.assertRaises(self.failureException,
+                          self.assertAlmostEqual, 1.0000001, 1.0)
+        self.assertRaises(self.failureException,
+                          self.assertNotAlmostEqual, 1.00000001, 1.0)
+
+        self.assertAlmostEqual(1.1, 1.0, places=0)
+        self.assertRaises(self.failureException,
+                          self.assertAlmostEqual, 1.1, 1.0, places=1)
+
+        self.assertAlmostEqual(0, .1+.1j, places=0)
+        self.assertNotAlmostEqual(0, .1+.1j, places=1)
+        self.assertRaises(self.failureException,
+                          self.assertAlmostEqual, 0, .1+.1j, places=1)
+        self.assertRaises(self.failureException,
+                          self.assertNotAlmostEqual, 0, .1+.1j, places=0)
+
+        try:
+            self.assertAlmostEqual(float('inf'), float('inf'))
+            self.assertRaises(self.failureException, self.assertNotAlmostEqual,
+                              float('inf'), float('inf'))
+        except ValueError:
+            # float('inf') is invalid on Windows in Python 2.4 / 2.5
+            x = object()
+            self.assertAlmostEqual(x, x)
+            self.assertRaises(self.failureException, self.assertNotAlmostEqual,
+                              x, x)
+            
+            
+    def test_AmostEqualWithDelta(self):
+        self.assertAlmostEqual(1.1, 1.0, delta=0.5)
+        self.assertAlmostEqual(1.0, 1.1, delta=0.5)
+        self.assertNotAlmostEqual(1.1, 1.0, delta=0.05)
+        self.assertNotAlmostEqual(1.0, 1.1, delta=0.05)
+        
+        self.assertRaises(self.failureException, self.assertAlmostEqual,
+                          1.1, 1.0, delta=0.05)
+        self.assertRaises(self.failureException, self.assertNotAlmostEqual,
+                          1.1, 1.0, delta=0.5)
+        
+        self.assertRaises(TypeError, self.assertAlmostEqual,
+                          1.1, 1.0, places=2, delta=2)
+        self.assertRaises(TypeError, self.assertNotAlmostEqual,
+                          1.1, 1.0, places=2, delta=2)
+        
+        first = datetime.datetime.now()
+        second = first + datetime.timedelta(seconds=10)
+        self.assertAlmostEqual(first, second,
+                               delta=datetime.timedelta(seconds=20))
+        self.assertNotAlmostEqual(first, second,
+                                  delta=datetime.timedelta(seconds=5))
+
+    def testAssertNotRegexpMatches(self):
+        self.assertNotRegexpMatches('Ala ma kota', r'r+')
+        try:
+            self.assertNotRegexpMatches('Ala ma kota', r'k.t', 'Message')
+        except self.failureException, e:
+            self.assertIn("'kot'", e.args[0])
+            self.assertIn('Message', e.args[0])
+        else:
+            self.fail('assertNotRegexpMatches should have failed.')
+
+
+class TestLongMessage(unittest2.TestCase):
+    """Test that the individual asserts honour longMessage.
+    This actually tests all the message behaviour for
+    asserts that use longMessage."""
+
+    def setUp(self):
+        class TestableTestFalse(unittest2.TestCase):
+            longMessage = False
+            failureException = self.failureException
+
+            def testTest(self):
+                pass
+
+        class TestableTestTrue(unittest2.TestCase):
+            longMessage = True
+            failureException = self.failureException
+
+            def testTest(self):
+                pass
+
+        self.testableTrue = TestableTestTrue('testTest')
+        self.testableFalse = TestableTestFalse('testTest')
+
+    def testDefault(self):
+        self.assertTrue(unittest2.TestCase.longMessage)
+
+    def test_formatMsg(self):
+        self.assertEquals(self.testableFalse._formatMessage(None, "foo"), "foo")
+        self.assertEquals(self.testableFalse._formatMessage("foo", "bar"), "foo")
+
+        self.assertEquals(self.testableTrue._formatMessage(None, "foo"), "foo")
+        self.assertEquals(self.testableTrue._formatMessage("foo", "bar"), "bar : foo")
+        
+        # This blows up if _formatMessage uses string concatenation
+        self.testableTrue._formatMessage(object(), 'foo')
+
+    def assertMessages(self, methodName, args, errors):
+        def getMethod(i):
+            useTestableFalse  = i < 2
+            if useTestableFalse:
+                test = self.testableFalse
+            else:
+                test = self.testableTrue
+            return getattr(test, methodName)
+
+        for i, expected_regexp in enumerate(errors):
+            testMethod = getMethod(i)
+            kwargs = {}
+            withMsg = i % 2
+            if withMsg:
+                kwargs = {"msg": "oops"}
+
+            self.assertRaisesRegexp(self.failureException,
+                                    expected_regexp,
+                                    lambda: testMethod(*args, **kwargs))
+            
+    def testAssertTrue(self):
+        self.assertMessages('assertTrue', (False,),
+                            ["^False is not True$", "^oops$", "^False is not True$",
+                             "^False is not True : oops$"])
+
+    def testAssertFalse(self):
+        self.assertMessages('assertFalse', (True,),
+                            ["^True is not False$", "^oops$", "^True is not False$",
+                             "^True is not False : oops$"])
+
+    def testNotEqual(self):
+        self.assertMessages('assertNotEqual', (1, 1),
+                            ["^1 == 1$", "^oops$", "^1 == 1$",
+                             "^1 == 1 : oops$"])
+
+    def testAlmostEqual(self):
+        self.assertMessages('assertAlmostEqual', (1, 2),
+                            ["^1 != 2 within 7 places$", "^oops$",
+                             "^1 != 2 within 7 places$", "^1 != 2 within 7 places : oops$"])
+
+    def testNotAlmostEqual(self):
+        self.assertMessages('assertNotAlmostEqual', (1, 1),
+                            ["^1 == 1 within 7 places$", "^oops$",
+                             "^1 == 1 within 7 places$", "^1 == 1 within 7 places : oops$"])
+
+    def test_baseAssertEqual(self):
+        self.assertMessages('_baseAssertEqual', (1, 2),
+                            ["^1 != 2$", "^oops$", "^1 != 2$", "^1 != 2 : oops$"])
+
+    def testAssertSequenceEqual(self):
+        # Error messages are multiline so not testing on full message
+        # assertTupleEqual and assertListEqual delegate to this method
+        self.assertMessages('assertSequenceEqual', ([], [None]),
+                            ["\+ \[None\]$", "^oops$", r"\+ \[None\]$",
+                             r"\+ \[None\] : oops$"])
+
+    def testAssertSetEqual(self):
+        self.assertMessages('assertSetEqual', (set(), set([None])),
+                            ["None$", "^oops$", "None$",
+                             "None : oops$"])
+
+    def testAssertIn(self):
+        self.assertMessages('assertIn', (None, []),
+                            ['^None not found in \[\]$', "^oops$",
+                             '^None not found in \[\]$',
+                             '^None not found in \[\] : oops$'])
+
+    def testAssertNotIn(self):
+        self.assertMessages('assertNotIn', (None, [None]),
+                            ['^None unexpectedly found in \[None\]$', "^oops$",
+                             '^None unexpectedly found in \[None\]$',
+                             '^None unexpectedly found in \[None\] : oops$'])
+
+    def testAssertDictEqual(self):
+        self.assertMessages('assertDictEqual', ({}, {'key': 'value'}),
+                            [r"\+ \{'key': 'value'\}$", "^oops$",
+                             "\+ \{'key': 'value'\}$",
+                             "\+ \{'key': 'value'\} : oops$"])
+
+    def testAssertDictContainsSubset(self):
+        self.assertMessages('assertDictContainsSubset', ({'key': 'value'}, {}),
+                            ["^Missing: 'key'$", "^oops$",
+                             "^Missing: 'key'$",
+                             "^Missing: 'key' : oops$"])
+
+    def testAssertItemsEqual(self):
+        self.assertMessages('assertItemsEqual', ([], [None]),
+                            [r"\[None\]$", "^oops$",
+                             r"\[None\]$",
+                             r"\[None\] : oops$"])
+
+    def testAssertMultiLineEqual(self):
+        self.assertMessages('assertMultiLineEqual', ("", "foo"),
+                            [r"\+ foo$", "^oops$",
+                             r"\+ foo$",
+                             r"\+ foo : oops$"])
+
+    def testAssertLess(self):
+        self.assertMessages('assertLess', (2, 1),
+                            ["^2 not less than 1$", "^oops$",
+                             "^2 not less than 1$", "^2 not less than 1 : oops$"])
+
+    def testAssertLessEqual(self):
+        self.assertMessages('assertLessEqual', (2, 1),
+                            ["^2 not less than or equal to 1$", "^oops$",
+                             "^2 not less than or equal to 1$",
+                             "^2 not less than or equal to 1 : oops$"])
+
+    def testAssertGreater(self):
+        self.assertMessages('assertGreater', (1, 2),
+                            ["^1 not greater than 2$", "^oops$",
+                             "^1 not greater than 2$",
+                             "^1 not greater than 2 : oops$"])
+
+    def testAssertGreaterEqual(self):
+        self.assertMessages('assertGreaterEqual', (1, 2),
+                            ["^1 not greater than or equal to 2$", "^oops$",
+                             "^1 not greater than or equal to 2$",
+                             "^1 not greater than or equal to 2 : oops$"])
+
+    def testAssertIsNone(self):
+        self.assertMessages('assertIsNone', ('not None',),
+                            ["^'not None' is not None$", "^oops$",
+                             "^'not None' is not None$",
+                             "^'not None' is not None : oops$"])
+
+    def testAssertIsNotNone(self):
+        self.assertMessages('assertIsNotNone', (None,),
+                            ["^unexpectedly None$", "^oops$",
+                             "^unexpectedly None$",
+                             "^unexpectedly None : oops$"])
+
+    def testAssertIs(self):
+        self.assertMessages('assertIs', (None, 'foo'),
+                            ["^None is not 'foo'$", "^oops$",
+                             "^None is not 'foo'$",
+                             "^None is not 'foo' : oops$"])
+
+    def testAssertIsNot(self):
+        self.assertMessages('assertIsNot', (None, None),
+                            ["^unexpectedly identical: None$", "^oops$",
+                             "^unexpectedly identical: None$",
+                             "^unexpectedly identical: None : oops$"])
+
+
+if __name__ == '__main__':
+    unittest2.main()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_break.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_break.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_break.py
new file mode 100644
index 0000000..1f7864b
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_break.py
@@ -0,0 +1,260 @@
+import gc
+import os
+import weakref
+
+from cStringIO import StringIO
+
+try:
+    import signal
+except ImportError:
+    signal = None
+
+import unittest2
+
+
+class TestBreak(unittest2.TestCase):
+    
+    def setUp(self):
+        self._default_handler = signal.getsignal(signal.SIGINT)
+        
+    def tearDown(self):
+        signal.signal(signal.SIGINT, self._default_handler)
+        unittest2.signals._results = weakref.WeakKeyDictionary()
+        unittest2.signals._interrupt_handler = None
+
+        
+    def testInstallHandler(self):
+        default_handler = signal.getsignal(signal.SIGINT)
+        unittest2.installHandler()
+        self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler)
+        
+        try:
+            pid = os.getpid()
+            os.kill(pid, signal.SIGINT)
+        except KeyboardInterrupt:
+            self.fail("KeyboardInterrupt not handled")
+            
+        self.assertTrue(unittest2.signals._interrupt_handler.called)
+    
+    def testRegisterResult(self):
+        result = unittest2.TestResult()
+        unittest2.registerResult(result)
+        
+        for ref in unittest2.signals._results:
+            if ref is result:
+                break
+            elif ref is not result:
+                self.fail("odd object in result set")
+        else:
+            self.fail("result not found")
+        
+        
+    def testInterruptCaught(self):
+        default_handler = signal.getsignal(signal.SIGINT)
+        
+        result = unittest2.TestResult()
+        unittest2.installHandler()
+        unittest2.registerResult(result)
+        
+        self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler)
+        
+        def test(result):
+            pid = os.getpid()
+            os.kill(pid, signal.SIGINT)
+            result.breakCaught = True
+            self.assertTrue(result.shouldStop)
+        
+        try:
+            test(result)
+        except KeyboardInterrupt:
+            self.fail("KeyboardInterrupt not handled")
+        self.assertTrue(result.breakCaught)
+    
+    
+    def testSecondInterrupt(self):
+        result = unittest2.TestResult()
+        unittest2.installHandler()
+        unittest2.registerResult(result)
+        
+        def test(result):
+            pid = os.getpid()
+            os.kill(pid, signal.SIGINT)
+            result.breakCaught = True
+            self.assertTrue(result.shouldStop)
+            os.kill(pid, signal.SIGINT)
+            self.fail("Second KeyboardInterrupt not raised")
+        
+        try:
+            test(result)
+        except KeyboardInterrupt:
+            pass
+        else:
+            self.fail("Second KeyboardInterrupt not raised")
+        self.assertTrue(result.breakCaught)
+
+    
+    def testTwoResults(self):
+        unittest2.installHandler()
+        
+        result = unittest2.TestResult()
+        unittest2.registerResult(result)
+        new_handler = signal.getsignal(signal.SIGINT)
+        
+        result2 = unittest2.TestResult()
+        unittest2.registerResult(result2)
+        self.assertEqual(signal.getsignal(signal.SIGINT), new_handler)
+        
+        result3 = unittest2.TestResult()
+        
+        def test(result):
+            pid = os.getpid()
+            os.kill(pid, signal.SIGINT)
+        
+        try:
+            test(result)
+        except KeyboardInterrupt:
+            self.fail("KeyboardInterrupt not handled")
+        
+        self.assertTrue(result.shouldStop)
+        self.assertTrue(result2.shouldStop)
+        self.assertFalse(result3.shouldStop)
+    
+    
+    def testHandlerReplacedButCalled(self):
+        # If our handler has been replaced (is no longer installed) but is
+        # called by the *new* handler, then it isn't safe to delay the
+        # SIGINT and we should immediately delegate to the default handler
+        unittest2.installHandler()
+        
+        handler = signal.getsignal(signal.SIGINT)
+        def new_handler(frame, signum):
+            handler(frame, signum)
+        signal.signal(signal.SIGINT, new_handler)
+        
+        try:
+            pid = os.getpid()
+            os.kill(pid, signal.SIGINT)
+        except KeyboardInterrupt:
+            pass
+        else:
+            self.fail("replaced but delegated handler doesn't raise interrupt")
+    
+    def testRunner(self):
+        # Creating a TextTestRunner with the appropriate argument should
+        # register the TextTestResult it creates
+        runner = unittest2.TextTestRunner(stream=StringIO())
+        
+        result = runner.run(unittest2.TestSuite())
+        self.assertIn(result, unittest2.signals._results)
+    
+    def testWeakReferences(self):
+        # Calling registerResult on a result should not keep it alive
+        result = unittest2.TestResult()
+        unittest2.registerResult(result)
+        
+        ref = weakref.ref(result)
+        del result
+        
+        # For non-reference counting implementations
+        gc.collect();gc.collect()
+        self.assertIsNone(ref())
+        
+    
+    def testRemoveResult(self):
+        result = unittest2.TestResult()
+        unittest2.registerResult(result)
+        
+        unittest2.installHandler()
+        self.assertTrue(unittest2.removeResult(result))
+        
+        # Should this raise an error instead?
+        self.assertFalse(unittest2.removeResult(unittest2.TestResult()))
+
+        try:
+            pid = os.getpid()
+            os.kill(pid, signal.SIGINT)
+        except KeyboardInterrupt:
+            pass
+        
+        self.assertFalse(result.shouldStop)
+    
+    def testMainInstallsHandler(self):
+        failfast = object()
+        test = object()
+        verbosity = object()
+        result = object()
+        default_handler = signal.getsignal(signal.SIGINT)
+
+        class FakeRunner(object):
+            initArgs = []
+            runArgs = []
+            def __init__(self, *args, **kwargs):
+                self.initArgs.append((args, kwargs))
+            def run(self, test):
+                self.runArgs.append(test)
+                return result
+        
+        class Program(unittest2.TestProgram):
+            def __init__(self, catchbreak): 
+                self.exit = False
+                self.verbosity = verbosity
+                self.failfast = failfast
+                self.catchbreak = catchbreak
+                self.testRunner = FakeRunner
+                self.test = test
+                self.result = None
+        
+        p = Program(False)
+        p.runTests()
+        
+        self.assertEqual(FakeRunner.initArgs, [((), {'verbosity': verbosity, 
+                                                'failfast': failfast,
+                                                'buffer': None})])
+        self.assertEqual(FakeRunner.runArgs, [test])
+        self.assertEqual(p.result, result)
+        
+        self.assertEqual(signal.getsignal(signal.SIGINT), default_handler)
+        
+        FakeRunner.initArgs = []
+        FakeRunner.runArgs = []
+        p = Program(True)
+        p.runTests()
+        
+        self.assertEqual(FakeRunner.initArgs, [((), {'verbosity': verbosity, 
+                                                'failfast': failfast,
+                                                'buffer': None})])
+        self.assertEqual(FakeRunner.runArgs, [test])
+        self.assertEqual(p.result, result)
+        
+        self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler)
+
+
+    def testRemoveHandler(self):
+        default_handler = signal.getsignal(signal.SIGINT)
+        unittest2.installHandler()
+        unittest2.removeHandler()
+        self.assertEqual(signal.getsignal(signal.SIGINT), default_handler)
+
+        # check that calling removeHandler multiple times has no ill-effect
+        unittest2.removeHandler()
+        self.assertEqual(signal.getsignal(signal.SIGINT), default_handler)
+    
+    def testRemoveHandlerAsDecorator(self):
+        default_handler = signal.getsignal(signal.SIGINT)
+        unittest2.installHandler()
+        
+        @unittest2.removeHandler
+        def test():
+            self.assertEqual(signal.getsignal(signal.SIGINT), default_handler)
+        
+        test()
+        self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler)
+        
+
+# Should also skip some tests on Jython
+skipper = unittest2.skipUnless(hasattr(os, 'kill') and signal is not None, 
+                               "test uses os.kill(...) and the signal module")
+TestBreak = skipper(TestBreak)
+
+if __name__ == '__main__':
+    unittest2.main()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_case.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_case.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_case.py
new file mode 100644
index 0000000..2865c2e
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/test/test_case.py
@@ -0,0 +1,1065 @@
+import difflib
+import pprint
+import re
+
+from copy import deepcopy
+
+import unittest2
+
+from unittest2.test.support import (
+    OldTestResult, EqualityMixin, HashingMixin, LoggingResult
+)
+
+
+class MyException(Exception):
+    pass
+
+
+class Test(object):
+    "Keep these TestCase classes out of the main namespace"
+
+    class Foo(unittest2.TestCase):
+        def runTest(self): pass
+        def test1(self): pass
+
+    class Bar(Foo):
+        def test2(self): pass
+
+    class LoggingTestCase(unittest2.TestCase):
+        """A test case which logs its calls."""
+
+        def __init__(self, events):
+            super(Test.LoggingTestCase, self).__init__('test')
+            self.events = events
+
+        def setUp(self):
+            self.events.append('setUp')
+
+        def test(self):
+            self.events.append('test')
+
+        def tearDown(self):
+            self.events.append('tearDown')
+
+
+
+class TestCleanUp(unittest2.TestCase):
+
+    def testCleanUp(self):
+        class TestableTest(unittest2.TestCase):
+            def testNothing(self):
+                pass
+
+        test = TestableTest('testNothing')
+        self.assertEqual(test._cleanups, [])
+
+        cleanups = []
+
+        def cleanup1(*args, **kwargs):
+            cleanups.append((1, args, kwargs))
+
+        def cleanup2(*args, **kwargs):
+            cleanups.append((2, args, kwargs))
+
+        test.addCleanup(cleanup1, 1, 2, 3, four='hello', five='goodbye')
+        test.addCleanup(cleanup2)
+
+        self.assertEqual(test._cleanups,
+                         [(cleanup1, (1, 2, 3), dict(four='hello', five='goodbye')),
+                          (cleanup2, (), {})])
+
+        result = test.doCleanups()
+        self.assertTrue(result)
+
+        self.assertEqual(cleanups, [(2, (), {}), (1, (1, 2, 3), dict(four='hello', five='goodbye'))])
+
+    def testCleanUpWithErrors(self):
+        class TestableTest(unittest2.TestCase):
+            def testNothing(self):
+                pass
+
+        class MockResult(object):
+            errors = []
+            def addError(self, test, exc_info):
+                self.errors.append((test, exc_info))
+
+        result = MockResult()
+        test = TestableTest('testNothing')
+        test._resultForDoCleanups = result
+
+        exc1 = Exception('foo')
+        exc2 = Exception('bar')
+        def cleanup1():
+            raise exc1
+
+        def cleanup2():
+            raise exc2
+
+        test.addCleanup(cleanup1)
+        test.addCleanup(cleanup2)
+
+        self.assertFalse(test.doCleanups())
+
+        (test1, (Type1, instance1, _)), (test2, (Type2, instance2, _)) = reversed(MockResult.errors)
+        self.assertEqual((test1, Type1, instance1), (test, Exception, exc1))
+        self.assertEqual((test2, Type2, instance2), (test, Exception, exc2))
+
+    def testCleanupInRun(self):
+        blowUp = False
+        ordering = []
+
+        class TestableTest(unittest2.TestCase):
+            def setUp(self):
+                ordering.append('setUp')
+                if blowUp:
+                    raise Exception('foo')
+
+            def testNothing(self):
+                ordering.append('test')
+
+            def tearDown(self):
+                ordering.append('tearDown')
+
+        test = TestableTest('testNothing')
+
+        def cleanup1():
+            ordering.append('cleanup1')
+        def cleanup2():
+            ordering.append('cleanup2')
+        test.addCleanup(cleanup1)
+        test.addCleanup(cleanup2)
+
+        def success(some_test):
+            self.assertEqual(some_test, test)
+            ordering.append('success')
+
+        result = unittest2.TestResult()
+        result.addSuccess = success
+
+        test.run(result)
+        self.assertEqual(ordering, ['setUp', 'test', 'tearDown',
+                                    'cleanup2', 'cleanup1', 'success'])
+
+        blowUp = True
+        ordering = []
+        test = TestableTest('testNothing')
+        test.addCleanup(cleanup1)
+        test.run(result)
+        self.assertEqual(ordering, ['setUp', 'cleanup1'])
+
+    def testTestCaseDebugExecutesCleanups(self):
+        ordering = []
+
+        class TestableTest(unittest2.TestCase):
+            def setUp(self):
+                ordering.append('setUp')
+                self.addCleanup(cleanup1)
+
+            def testNothing(self):
+                ordering.append('test')
+
+            def tearDown(self):
+                ordering.append('tearDown')
+
+        test = TestableTest('testNothing')
+
+        def cleanup1():
+            ordering.append('cleanup1')
+            test.addCleanup(cleanup2)
+        def cleanup2():
+            ordering.append('cleanup2')
+
+        test.debug()
+        self.assertEqual(ordering, ['setUp', 'test', 'tearDown', 'cleanup1', 'cleanup2'])
+
+
+class Test_TestCase(unittest2.TestCase, EqualityMixin, HashingMixin):
+
+    ### Set up attributes used by inherited tests
+    ################################################################
+
+    # Used by HashingMixin.test_hash and EqualityMixin.test_eq
+    eq_pairs = [(Test.Foo('test1'), Test.Foo('test1'))]
+
+    # Used by EqualityMixin.test_ne
+    ne_pairs = [(Test.Foo('test1'), Test.Foo('runTest')),
+                (Test.Foo('test1'), Test.Bar('test1')),
+                (Test.Foo('test1'), Test.Bar('test2'))]
+
+    ################################################################
+    ### /Set up attributes used by inherited tests
+
+
+    # "class TestCase([methodName])"
+    # ...
+    # "Each instance of TestCase will run a single test method: the
+    # method named methodName."
+    # ...
+    # "methodName defaults to "runTest"."
+    #
+    # Make sure it really is optional, and that it defaults to the proper
+    # thing.
+    def test_init__no_test_name(self):
+        class Test(unittest2.TestCase):
+            def runTest(self): raise MyException()
+            def test(self): pass
+
+        self.assertEqual(Test().id()[-13:], '.Test.runTest')
+
+    # "class TestCase([methodName])"
+    # ...
+    # "Each instance of TestCase will run a single test method: the
+    # method named methodName."
+    def test_init__test_name__valid(self):
+        class Test(unittest2.TestCase):
+            def runTest(self): raise MyException()
+            def test(self): pass
+
+        self.assertEqual(Test('test').id()[-10:], '.Test.test')
+
+    # "class unittest2.TestCase([methodName])"
+    # ...
+    # "Each instance of TestCase will run a single test method: the
+    # method named methodName."
+    def test_init__test_name__invalid(self):
+        class Test(unittest2.TestCase):
+            def runTest(self): raise MyException()
+            def test(self): pass
+
+        try:
+            Test('testfoo')
+        except ValueError:
+            pass
+        else:
+            self.fail("Failed to raise ValueError")
+
+    # "Return the number of tests represented by the this test object. For
+    # TestCase instances, this will always be 1"
+    def test_countTestCases(self):
+        class Foo(unittest2.TestCase):
+            def test(self): pass
+
+        self.assertEqual(Foo('test').countTestCases(), 1)
+
+    # "Return the default type of test result object to be used to run this
+    # test. For TestCase instances, this will always be
+    # unittest2.TestResult;  subclasses of TestCase should
+    # override this as necessary."
+    def test_defaultTestResult(self):
+        class Foo(unittest2.TestCase):
+            def runTest(self):
+                pass
+
+        result = Foo().defaultTestResult()
+        self.assertEqual(type(result), unittest2.TestResult)
+
+    # "When a setUp() method is defined, the test runner will run that method
+    # prior to each test. Likewise, if a tearDown() method is defined, the
+    # test runner will invoke that method after each test. In the example,
+    # setUp() was used to create a fresh sequence for each test."
+    #
+    # Make sure the proper call order is maintained, even if setUp() raises
+    # an exception.
+    def test_run_call_order__error_in_setUp(self):
+        events = []
+        result = LoggingResult(events)
+
+        class Foo(Test.LoggingTestCase):
+            def setUp(self):
+                super(Foo, self).setUp()
+                raise RuntimeError('raised by Foo.setUp')
+
+        Foo(events).run(result)
+        expected = ['startTest', 'setUp', 'addError', 'stopTest']
+        self.assertEqual(events, expected)
+
+    # "With a temporary result stopTestRun is called when setUp errors.
+    def test_run_call_order__error_in_setUp_default_result(self):
+        events = []
+
+        class Foo(Test.LoggingTestCase):
+            def defaultTestResult(self):
+                return LoggingResult(self.events)
+
+            def setUp(self):
+                super(Foo, self).setUp()
+                raise RuntimeError('raised by Foo.setUp')
+
+        Foo(events).run()
+        expected = ['startTestRun', 'startTest', 'setUp', 'addError',
+                    'stopTest', 'stopTestRun']
+        self.assertEqual(events, expected)
+
+    # "When a setUp() method is defined, the test runner will run that method
+    # prior to each test. Likewise, if a tearDown() method is defined, the
+    # test runner will invoke that method after each test. In the example,
+    # setUp() was used to create a fresh sequence for each test."
+    #
+    # Make sure the proper call order is maintained, even if the test raises
+    # an error (as opposed to a failure).
+    def test_run_call_order__error_in_test(self):
+        events = []
+        result = LoggingResult(events)
+
+        class Foo(Test.LoggingTestCase):
+            def test(self):
+                super(Foo, self).test()
+                raise RuntimeError('raised by Foo.test')
+
+        expected = ['startTest', 'setUp', 'test', 'addError', 'tearDown',
+                    'stopTest']
+        Foo(events).run(result)
+        self.assertEqual(events, expected)
+
+    # "With a default result, an error in the test still results in stopTestRun
+    # being called."
+    def test_run_call_order__error_in_test_default_result(self):
+        events = []
+
+        class Foo(Test.LoggingTestCase):
+            def defaultTestResult(self):
+                return LoggingResult(self.events)
+
+            def test(self):
+                super(Foo, self).test()
+                raise RuntimeError('raised by Foo.test')
+
+        expected = ['startTestRun', 'startTest', 'setUp', 'test', 'addError',
+                    'tearDown', 'stopTest', 'stopTestRun']
+        Foo(events).run()
+        self.assertEqual(events, expected)
+
+    # "When a setUp() method is defined, the test runner will run that method
+    # prior to each test. Likewise, if a tearDown() method is defined, the
+    # test runner will invoke that method after each test. In the example,
+    # setUp() was used to create a fresh sequence for each test."
+    #
+    # Make sure the proper call order is maintained, even if the test signals
+    # a failure (as opposed to an error).
+    def test_run_call_order__failure_in_test(self):
+        events = []
+        result = LoggingResult(events)
+
+        class Foo(Test.LoggingTestCase):
+            def test(self):
+                super(Foo, self).test()
+                self.fail('raised by Foo.test')
+
+        expected = ['startTest', 'setUp', 'test', 'addFailure', 'tearDown',
+                    'stopTest']
+        Foo(events).run(result)
+        self.assertEqual(events, expected)
+
+    # "When a test fails with a default result stopTestRun is still called."
+    def test_run_call_order__failure_in_test_default_result(self):
+
+        class Foo(Test.LoggingTestCase):
+            def defaultTestResult(self):
+                return LoggingResult(self.events)
+            def test(self):
+                super(Foo, self).test()
+                self.fail('raised by Foo.test')
+
+        expected = ['startTestRun', 'startTest', 'setUp', 'test', 'addFailure',
+                    'tearDown', 'stopTest', 'stopTestRun']
+        events = []
+        Foo(events).run()
+        self.assertEqual(events, expected)
+
+    # "When a setUp() method is defined, the test runner will run that method
+    # prior to each test. Likewise, if a tearDown() method is defined, the
+    # test runner will invoke that method after each test. In the example,
+    # setUp() was used to create a fresh sequence for each test."
+    #
+    # Make sure the proper call order is maintained, even if tearDown() raises
+    # an exception.
+    def test_run_call_order__error_in_tearDown(self):
+        events = []
+        result = LoggingResult(events)
+
+        class Foo(Test.LoggingTestCase):
+            def tearDown(self):
+                super(Foo, self).tearDown()
+                raise RuntimeError('raised by Foo.tearDown')
+
+        Foo(events).run(result)
+        expected = ['startTest', 'setUp', 'test', 'tearDown', 'addError',
+                    'stopTest']
+        self.assertEqual(events, expected)
+
+    # "When tearDown errors with a default result stopTestRun is still called."
+    def test_run_call_order__error_in_tearDown_default_result(self):
+
+        class Foo(Test.LoggingTestCase):
+            def defaultTestResult(self):
+                return LoggingResult(self.events)
+            def tearDown(self):
+                super(Foo, self).tearDown()
+                raise RuntimeError('raised by Foo.tearDown')
+
+        events = []
+        Foo(events).run()
+        expected = ['startTestRun', 'startTest', 'setUp', 'test', 'tearDown',
+                    'addError', 'stopTest', 'stopTestRun']
+        self.assertEqual(events, expected)
+
+    # "TestCase.run() still works when the defaultTestResult is a TestResult
+    # that does not support startTestRun and stopTestRun.
+    def test_run_call_order_default_result(self):
+
+        class Foo(unittest2.TestCase):
+            def defaultTestResult(self):
+                return OldTestResult()
+            def test(self):
+                pass
+
+        Foo('test').run()
+
+    # "This class attribute gives the exception raised by the test() method.
+    # If a test framework needs to use a specialized exception, possibly to
+    # carry additional information, it must subclass this exception in
+    # order to ``play fair'' with the framework.  The initial value of this
+    # attribute is AssertionError"
+    def test_failureException__default(self):
+        class Foo(unittest2.TestCase):
+            def test(self):
+                pass
+
+        self.assertTrue(Foo('test').failureException is AssertionError)
+
+    # "This class attribute gives the exception raised by the test() method.
+    # If a test framework needs to use a specialized exception, possibly to
+    # carry additional information, it must subclass this exception in
+    # order to ``play fair'' with the framework."
+    #
+    # Make sure TestCase.run() respects the designated failureException
+    def test_failureException__subclassing__explicit_raise(self):
+        events = []
+        result = LoggingResult(events)
+
+        class Foo(unittest2.TestCase):
+            def test(self):
+                raise RuntimeError()
+
+            failureException = RuntimeError
+
+        self.assertTrue(Foo('test').failureException is RuntimeError)
+
+
+        Foo('test').run(result)
+        expected = ['startTest', 'addFailure', 'stopTest']
+        self.assertEqual(events, expected)
+
+    # "This class attribute gives the exception raised by the test() method.
+    # If a test framework needs to use a specialized exception, possibly to
+    # carry additional information, it must subclass this exception in
+    # order to ``play fair'' with the framework."
+    #
+    # Make sure TestCase.run() respects the designated failureException
+    def test_failureException__subclassing__implicit_raise(self):
+        events = []
+        result = LoggingResult(events)
+
+        class Foo(unittest2.TestCase):
+            def test(self):
+                self.fail("foo")
+
+            failureException = RuntimeError
+
+        self.assertTrue(Foo('test').failureException is RuntimeError)
+
+
+        Foo('test').run(result)
+        expected = ['startTest', 'addFailure', 'stopTest']
+        self.assertEqual(events, expected)
+
+    # "The default implementation does nothing."
+    def test_setUp(self):
+        class Foo(unittest2.TestCase):
+            def runTest(self):
+                pass
+
+        # ... and nothing should happen
+        Foo().setUp()
+
+    # "The default implementation does nothing."
+    def test_tearDown(self):
+        class Foo(unittest2.TestCase):
+            def runTest(self):
+                pass
+
+        # ... and nothing should happen
+        Foo().tearDown()
+
+    # "Return a string identifying the specific test case."
+    #
+    # Because of the vague nature of the docs, I'm not going to lock this
+    # test down too much. Really all that can be asserted is that the id()
+    # will be a string (either 8-byte or unicode -- again, because the docs
+    # just say "string")
+    def test_id(self):
+        class Foo(unittest2.TestCase):
+            def runTest(self):
+                pass
+
+        self.assertIsInstance(Foo().id(), basestring)
+
+    # "If result is omitted or None, a temporary result object is created
+    # and used, but is not made available to the caller. As TestCase owns the
+    # temporary result startTestRun and stopTestRun are called.
+
+    def test_run__uses_defaultTestResult(self):
+        events = []
+
+        class Foo(unittest2.TestCase):
+            def test(self):
+                events.append('test')
+
+            def defaultTestResult(self):
+                return LoggingResult(events)
+
+        # Make run() find a result object on its own
+        Foo('test').run()
+
+        expected = ['startTestRun', 'startTest', 'test', 'addSuccess',
+            'stopTest', 'stopTestRun']
+        self.assertEqual(events, expected)
+
+    def testShortDescriptionWithoutDocstring(self):
+        self.assertIsNone(self.shortDescription())
+
+    def testShortDescriptionWithOneLineDocstring(self):
+        """Tests shortDescription() for a method with a docstring."""
+        self.assertEqual(
+                self.shortDescription(),
+                'Tests shortDescription() for a method with a docstring.')
+
+    def testShortDescriptionWithMultiLineDocstring(self):
+        """Tests shortDescription() for a method with a longer docstring.
+
+        This method ensures that only the first line of a docstring is
+        returned used in the short description, no matter how long the
+        whole thing is.
+        """
+        self.assertEqual(
+                self.shortDescription(),
+                 'Tests shortDescription() for a method with a longer '
+                 'docstring.')
+
+    def testAddTypeEqualityFunc(self):
+        class SadSnake(object):
+            """Dummy class for test_addTypeEqualityFunc."""
+        s1, s2 = SadSnake(), SadSnake()
+        self.assertNotEqual(s1, s2)
+        def AllSnakesCreatedEqual(a, b, msg=None):
+            return type(a) is type(b) is SadSnake
+        self.addTypeEqualityFunc(SadSnake, AllSnakesCreatedEqual)
+        self.assertEqual(s1, s2)
+        # No this doesn't clean up and remove the SadSnake equality func
+        # from this TestCase instance but since its a local nothing else
+        # will ever notice that.
+
+    def testAssertIs(self):
+        thing = object()
+        self.assertIs(thing, thing)
+        self.assertRaises(self.failureException, self.assertIs, thing, object())
+
+    def testAssertIsNot(self):
+        thing = object()
+        self.assertIsNot(thing, object())
+        self.assertRaises(self.failureException, self.assertIsNot, thing, thing)
+
+    def testAssertIsInstance(self):
+        thing = []
+        self.assertIsInstance(thing, list)
+        self.assertRaises(self.failureException, self.assertIsInstance,
+                          thing, dict)
+
+    def testAssertNotIsInstance(self):
+        thing = []
+        self.assertNotIsInstance(thing, dict)
+        self.assertRaises(self.failureException, self.assertNotIsInstance,
+                          thing, list)
+
+    def testAssertIn(self):
+        animals = {'monkey': 'banana', 'cow': 'grass', 'seal': 'fish'}
+
+        self.assertIn('a', 'abc')
+        self.assertIn(2, [1, 2, 3])
+        self.assertIn('monkey', animals)
+
+        self.assertNotIn('d', 'abc')
+        self.assertNotIn(0, [1, 2, 3])
+        self.assertNotIn('otter', animals)
+
+        self.assertRaises(self.failureException, self.assertIn, 'x', 'abc')
+        self.assertRaises(self.failureException, self.assertIn, 4, [1, 2, 3])
+        self.assertRaises(self.failureException, self.assertIn, 'elephant',
+                          animals)
+
+        self.assertRaises(self.failureException, self.assertNotIn, 'c', 'abc')
+        self.assertRaises(self.failureException, self.assertNotIn, 1, [1, 2, 3])
+        self.assertRaises(self.failureException, self.assertNotIn, 'cow',
+                          animals)
+
+    def testAssertDictContainsSubset(self):
+        self.assertDictContainsSubset({}, {})
+        self.assertDictContainsSubset({}, {'a': 1})
+        self.assertDictContainsSubset({'a': 1}, {'a': 1})
+        self.assertDictContainsSubset({'a': 1}, {'a': 1, 'b': 2})
+        self.assertDictContainsSubset({'a': 1, 'b': 2}, {'a': 1, 'b': 2})
+
+        self.assertRaises(unittest2.TestCase.failureException,
+                          self.assertDictContainsSubset, {'a': 2}, {'a': 1},
+                          '.*Mismatched values:.*')
+
+        self.assertRaises(unittest2.TestCase.failureException,
+                          self.assertDictContainsSubset, {'c': 1}, {'a': 1},
+                          '.*Missing:.*')
+
+        self.assertRaises(unittest2.TestCase.failureException,
+                          self.assertDictContainsSubset, {'a': 1, 'c': 1},
+                          {'a': 1}, '.*Missing:.*')
+
+        self.assertRaises(unittest2.TestCase.failureException,
+                          self.assertDictContainsSubset, {'a': 1, 'c': 1},
+                          {'a': 1}, '.*Missing:.*Mismatched values:.*')
+        
+        self.assertRaises(self.failureException,
+                          self.assertDictContainsSubset, {1: "one"}, {})
+
+    def testAssertEqual(self):
+        equal_pairs = [
+                ((), ()),
+                ({}, {}),
+                ([], []),
+                (set(), set()),
+                (frozenset(), frozenset())]
+        for a, b in equal_pairs:
+            # This mess of try excepts is to test the assertEqual behavior
+            # itself.
+            try:
+                self.assertEqual(a, b)
+            except self.failureException:
+                self.fail('assertEqual(%r, %r) failed' % (a, b))
+            try:
+                self.assertEqual(a, b, msg='foo')
+            except self.failureException:
+                self.fail('assertEqual(%r, %r) with msg= failed' % (a, b))
+            try:
+                self.assertEqual(a, b, 'foo')
+            except self.failureException:
+                self.fail('assertEqual(%r, %r) with third parameter failed' %
+                          (a, b))
+
+        unequal_pairs = [
+               ((), []),
+               ({}, set()),
+               (set([4,1]), frozenset([4,2])),
+               (frozenset([4,5]), set([2,3])),
+               (set([3,4]), set([5,4]))]
+        for a, b in unequal_pairs:
+            self.assertRaises(self.failureException, self.assertEqual, a, b)
+            self.assertRaises(self.failureException, self.assertEqual, a, b,
+                              'foo')
+            self.assertRaises(self.failureException, self.assertEqual, a, b,
+                              msg='foo')
+
+    def testEquality(self):
+        self.assertListEqual([], [])
+        self.assertTupleEqual((), ())
+        self.assertSequenceEqual([], ())
+
+        a = [0, 'a', []]
+        b = []
+        self.assertRaises(unittest2.TestCase.failureException,
+                          self.assertListEqual, a, b)
+        self.assertRaises(unittest2.TestCase.failureException,
+                          self.assertListEqual, tuple(a), tuple(b))
+        self.assertRaises(unittest2.TestCase.failureException,
+                          self.assertSequenceEqual, a, tuple(b))
+
+        b.extend(a)
+        self.assertListEqual(a, b)
+        self.assertTupleEqual(tuple(a), tuple(b))
+        self.assertSequenceEqual(a, tuple(b))
+        self.assertSequenceEqual(tuple(a), b)
+
+        self.assertRaises(self.failureException, self.assertListEqual,
+                          a, tuple(b))
+        self.assertRaises(self.failureException, self.assertTupleEqual,
+                          tuple(a), b)
+        self.assertRaises(self.failureException, self.assertListEqual, None, b)
+        self.assertRaises(self.failureException, self.assertTupleEqual, None,
+                          tuple(b))
+        self.assertRaises(self.failureException, self.assertSequenceEqual,
+                          None, tuple(b))
+        self.assertRaises(self.failureException, self.assertListEqual, 1, 1)
+        self.assertRaises(self.failureException, self.assertTupleEqual, 1, 1)
+        self.assertRaises(self.failureException, self.assertSequenceEqual,
+                          1, 1)
+
+        self.assertDictEqual({}, {})
+
+        c = { 'x': 1 }
+        d = {}
+        self.assertRaises(unittest2.TestCase.failureException,
+                          self.assertDictEqual, c, d)
+
+        d.update(c)
+        self.assertDictEqual(c, d)
+
+        d['x'] = 0
+        self.assertRaises(unittest2.TestCase.failureException,
+                          self.assertDictEqual, c, d, 'These are unequal')
+
+        self.assertRaises(self.failureException, self.assertDictEqual, None, d)
+        self.assertRaises(self.failureException, self.assertDictEqual, [], d)
+        self.assertRaises(self.failureException, self.assertDictEqual, 1, 1)
+
+    def testAssertItemsEqual(self):
+        self.assertItemsEqual([1, 2, 3], [3, 2, 1])
+        self.assertItemsEqual(['foo', 'bar', 'baz'], ['bar', 'baz', 'foo'])
+        self.assertRaises(self.failureException, self.assertItemsEqual,
+                          [10], [10, 11])
+        self.assertRaises(self.failureException, self.assertItemsEqual,
+                          [10, 11], [10])
+        self.assertRaises(self.failureException, self.assertItemsEqual,
+                          [10, 11, 10], [10, 11])
+
+        # Test that sequences of unhashable objects can be tested for sameness:
+        self.assertItemsEqual([[1, 2], [3, 4]], [[3, 4], [1, 2]])
+
+        self.assertItemsEqual([{'a': 1}, {'b': 2}], [{'b': 2}, {'a': 1}])
+        self.assertRaises(self.failureException, self.assertItemsEqual,
+                          [[1]], [[2]])
+        
+        # Test unsortable objects
+        self.assertItemsEqual([2j, None], [None, 2j])
+        self.assertRaises(self.failureException, self.assertItemsEqual,
+                          [2j, None], [None, 3j])
+
+    def testAssertSetEqual(self):
+        set1 = set()
+        set2 = set()
+        self.assertSetEqual(set1, set2)
+
+        self.assertRaises(self.failureException, self.assertSetEqual, None, set2)
+        self.assertRaises(self.failureException, self.assertSetEqual, [], set2)
+        self.assertRaises(self.failureException, self.assertSetEqual, set1, None)
+        self.assertRaises(self.failureException, self.assertSetEqual, set1, [])
+
+        set1 = set(['a'])
+        set2 = set()
+        self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)
+
+        set1 = set(['a'])
+        set2 = set(['a'])
+        self.assertSetEqual(set1, set2)
+
+        set1 = set(['a'])
+        set2 = set(['a', 'b'])
+        self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)
+
+        set1 = set(['a'])
+        set2 = frozenset(['a', 'b'])
+        self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)
+
+        set1 = set(['a', 'b'])
+        set2 = frozenset(['a', 'b'])
+        self.assertSetEqual(set1, set2)
+
+        set1 = set()
+        set2 = "foo"
+        self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)
+        self.assertRaises(self.failureException, self.assertSetEqual, set2, set1)
+
+        # make sure any string formatting is tuple-safe
+        set1 = set([(0, 1), (2, 3)])
+        set2 = set([(4, 5)])
+        self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)
+
+    def testInequality(self):
+        # Try ints
+        self.assertGreater(2, 1)
+        self.assertGreaterEqual(2, 1)
+        self.assertGreaterEqual(1, 1)
+        self.assertLess(1, 2)
+        self.assertLessEqual(1, 2)
+        self.assertLessEqual(1, 1)
+        self.assertRaises(self.failureException, self.assertGreater, 1, 2)
+        self.assertRaises(self.failureException, self.assertGreater, 1, 1)
+        self.assertRaises(self.failureException, self.assertGreaterEqual, 1, 2)
+        self.assertRaises(self.failureException, self.assertLess, 2, 1)
+        self.assertRaises(self.failureException, self.assertLess, 1, 1)
+        self.assertRaises(self.failureException, self.assertLessEqual, 2, 1)
+
+        # Try Floats
+        self.assertGreater(1.1, 1.0)
+        self.assertGreaterEqual(1.1, 1.0)
+        self.assertGreaterEqual(1.0, 1.0)
+        self.assertLess(1.0, 1.1)
+        self.assertLessEqual(1.0, 1.1)
+        self.assertLessEqual(1.0, 1.0)
+        self.assertRaises(self.failureException, self.assertGreater, 1.0, 1.1)
+        self.assertRaises(self.failureException, self.assertGreater, 1.0, 1.0)
+        self.assertRaises(self.failureException, self.assertGreaterEqual, 1.0, 1.1)
+        self.assertRaises(self.failureException, self.assertLess, 1.1, 1.0)
+        self.assertRaises(self.failureException, self.assertLess, 1.0, 1.0)
+        self.assertRaises(self.failureException, self.assertLessEqual, 1.1, 1.0)
+
+        # Try Strings
+        self.assertGreater('bug', 'ant')
+        self.assertGreaterEqual('bug', 'ant')
+        self.assertGreaterEqual('ant', 'ant')
+        self.assertLess('ant', 'bug')
+        self.assertLessEqual('ant', 'bug')
+        self.assertLessEqual('ant', 'ant')
+        self.assertRaises(self.failureException, self.assertGreater, 'ant', 'bug')
+        self.assertRaises(self.failureException, self.assertGreater, 'ant', 'ant')
+        self.assertRaises(self.failureException, self.assertGreaterEqual, 'ant', 'bug')
+        self.assertRaises(self.failureException, self.assertLess, 'bug', 'ant')
+        self.assertRaises(self.failureException, self.assertLess, 'ant', 'ant')
+        self.assertRaises(self.failureException, self.assertLessEqual, 'bug', 'ant')
+
+        # Try Unicode
+        self.assertGreater(u'bug', u'ant')
+        self.assertGreaterEqual(u'bug', u'ant')
+        self.assertGreaterEqual(u'ant', u'ant')
+        self.assertLess(u'ant', u'bug')
+        self.assertLessEqual(u'ant', u'bug')
+        self.assertLessEqual(u'ant', u'ant')
+        self.assertRaises(self.failureException, self.assertGreater, u'ant', u'bug')
+        self.assertRaises(self.failureException, self.assertGreater, u'ant', u'ant')
+        self.assertRaises(self.failureException, self.assertGreaterEqual, u'ant',
+                          u'bug')
+        self.assertRaises(self.failureException, self.assertLess, u'bug', u'ant')
+        self.assertRaises(self.failureException, self.assertLess, u'ant', u'ant')
+        self.assertRaises(self.failureException, self.assertLessEqual, u'bug', u'ant')
+
+        # Try Mixed String/Unicode
+        self.assertGreater('bug', u'ant')
+        self.assertGreater(u'bug', 'ant')
+        self.assertGreaterEqual('bug', u'ant')
+        self.assertGreaterEqual(u'bug', 'ant')
+        self.assertGreaterEqual('ant', u'ant')
+        self.assertGreaterEqual(u'ant', 'ant')
+        self.assertLess('ant', u'bug')
+        self.assertLess(u'ant', 'bug')
+        self.assertLessEqual('ant', u'bug')
+        self.assertLessEqual(u'ant', 'bug')
+        self.assertLessEqual('ant', u'ant')
+        self.assertLessEqual(u'ant', 'ant')
+        self.assertRaises(self.failureException, self.assertGreater, 'ant', u'bug')
+        self.assertRaises(self.failureException, self.assertGreater, u'ant', 'bug')
+        self.assertRaises(self.failureException, self.assertGreater, 'ant', u'ant')
+        self.assertRaises(self.failureException, self.assertGreater, u'ant', 'ant')
+        self.assertRaises(self.failureException, self.assertGreaterEqual, 'ant',
+                          u'bug')
+        self.assertRaises(self.failureException, self.assertGreaterEqual, u'ant',
+                          'bug')
+        self.assertRaises(self.failureException, self.assertLess, 'bug', u'ant')
+        self.assertRaises(self.failureException, self.assertLess, u'bug', 'ant')
+        self.assertRaises(self.failureException, self.assertLess, 'ant', u'ant')
+        self.assertRaises(self.failureException, self.assertLess, u'ant', 'ant')
+        self.assertRaises(self.failureException, self.assertLessEqual, 'bug', u'ant')
+        self.assertRaises(self.failureException, self.assertLessEqual, u'bug', 'ant')
+
+    def testAssertMultiLineEqual(self):
+        sample_text = """\
+http://www.python.org/doc/2.3/lib/module-unittest.html
+test case
+    A test case is the smallest unit of testing. [...]
+"""
+        revised_sample_text = """\
+http://www.python.org/doc/2.4.1/lib/module-unittest.html
+test case
+    A test case is the smallest unit of testing. [...] You may provide your
+    own implementation that does not subclass from TestCase, of course.
+"""
+        sample_text_error = """\
+- http://www.python.org/doc/2.3/lib/module-unittest.html
+?                             ^
++ http://www.python.org/doc/2.4.1/lib/module-unittest.html
+?                             ^^^
+  test case
+-     A test case is the smallest unit of testing. [...]
++     A test case is the smallest unit of testing. [...] You may provide your
+?                                                       +++++++++++++++++++++
++     own implementation that does not subclass from TestCase, of course.
+"""
+        self.maxDiff = None
+        for type_changer in (lambda x: x, lambda x: x.decode('utf8')):
+            try:
+                self.assertMultiLineEqual(type_changer(sample_text),
+                                          type_changer(revised_sample_text))
+            except self.failureException, e:
+                # need to remove the first line of the error message
+                error = str(e).encode('utf8').split('\n', 1)[1]
+
+                # assertMultiLineEqual is hooked up as the default for
+                # unicode strings - so we can't use it for this check
+                self.assertTrue(sample_text_error == error)
+
+    def testAssertSequenceEqualMaxDiff(self):
+        self.assertEqual(self.maxDiff, 80*8)
+        seq1 = 'a' + 'x' * 80**2
+        seq2 = 'b' + 'x' * 80**2
+        diff = '\n'.join(difflib.ndiff(pprint.pformat(seq1).splitlines(),
+                                       pprint.pformat(seq2).splitlines()))
+        # the +1 is the leading \n added by assertSequenceEqual
+        omitted = unittest2.case.DIFF_OMITTED % (len(diff) + 1,)
+
+        self.maxDiff = len(diff)//2
+        try:
+            self.assertSequenceEqual(seq1, seq2)
+        except self.failureException, e:
+            msg = e.args[0]
+        else:
+            self.fail('assertSequenceEqual did not fail.')
+        self.assertTrue(len(msg) < len(diff))
+        self.assertIn(omitted, msg)
+
+        self.maxDiff = len(diff) * 2
+        try:
+            self.assertSequenceEqual(seq1, seq2)
+        except self.failureException, e:
+            msg = e.args[0]
+        else:
+            self.fail('assertSequenceEqual did not fail.')
+        self.assertTrue(len(msg) > len(diff))
+        self.assertNotIn(omitted, msg)
+
+        self.maxDiff = None
+        try:
+            self.assertSequenceEqual(seq1, seq2)
+        except self.failureException, e:
+            msg = e.args[0]
+        else:
+            self.fail('assertSequenceEqual did not fail.')
+        self.assertTrue(len(msg) > len(diff))
+        self.assertNotIn(omitted, msg)
+
+    def testTruncateMessage(self):
+        self.maxDiff = 1
+        message = self._truncateMessage('foo', 'bar')
+        omitted = unittest2.case.DIFF_OMITTED % len('bar')
+        self.assertEqual(message, 'foo' + omitted)
+
+        self.maxDiff = None
+        message = self._truncateMessage('foo', 'bar')
+        self.assertEqual(message, 'foobar')
+
+        self.maxDiff = 4
+        message = self._truncateMessage('foo', 'bar')
+        self.assertEqual(message, 'foobar')
+
+    def testAssertDictEqualTruncates(self):
+        test = unittest2.TestCase('assertEqual')
+        def truncate(msg, diff):
+            return 'foo'
+        test._truncateMessage = truncate
+        try:
+            test.assertDictEqual({}, {1: 0})
+        except self.failureException, e:
+            self.assertEqual(str(e), 'foo')
+        else:
+            self.fail('assertDictEqual did not fail')
+
+    def testAssertMultiLineEqualTruncates(self):
+        test = unittest2.TestCase('assertEqual')
+        def truncate(msg, diff):
+            return 'foo'
+        test._truncateMessage = truncate
+        try:
+            test.assertMultiLineEqual('foo', 'bar')
+        except self.failureException, e:
+            self.assertEqual(str(e), 'foo')
+        else:
+            self.fail('assertMultiLineEqual did not fail')
+
+    def testAssertIsNone(self):
+        self.assertIsNone(None)
+        self.assertRaises(self.failureException, self.assertIsNone, False)
+        self.assertIsNotNone('DjZoPloGears on Rails')
+        self.assertRaises(self.failureException, self.assertIsNotNone, None)
+
+    def testAssertRegexpMatches(self):
+        self.assertRegexpMatches('asdfabasdf', r'ab+')
+        self.assertRaises(self.failureException, self.assertRegexpMatches,
+                          'saaas', r'aaaa')
+
+    def testAssertRaisesRegexp(self):
+        class ExceptionMock(Exception):
+            pass
+
+        def Stub():
+            raise ExceptionMock('We expect')
+
+        self.assertRaisesRegexp(ExceptionMock, re.compile('expect$'), Stub)
+        self.assertRaisesRegexp(ExceptionMock, 'expect$', Stub)
+        self.assertRaisesRegexp(ExceptionMock, u'expect$', Stub)
+
+    def testAssertNotRaisesRegexp(self):
+        self.assertRaisesRegexp(
+                self.failureException, '^Exception not raised$',
+                self.assertRaisesRegexp, Exception, re.compile('x'),
+                lambda: None)
+        self.assertRaisesRegexp(
+                self.failureException, '^Exception not raised$',
+                self.assertRaisesRegexp, Exception, 'x',
+                lambda: None)
+        self.assertRaisesRegexp(
+                self.failureException, '^Exception not raised$',
+                self.assertRaisesRegexp, Exception, u'x',
+                lambda: None)
+
+    def testAssertRaisesRegexpMismatch(self):
+        def Stub():
+            raise Exception('Unexpected')
+
+        self.assertRaisesRegexp(
+                self.failureException,
+                r'"\^Expected\$" does not match "Unexpected"',
+                self.assertRaisesRegexp, Exception, '^Expected$',
+                Stub)
+        self.assertRaisesRegexp(
+                self.failureException,
+                r'"\^Expected\$" does not match "Unexpected"',
+                self.assertRaisesRegexp, Exception, u'^Expected$',
+                Stub)
+        self.assertRaisesRegexp(
+                self.failureException,
+                r'"\^Expected\$" does not match "Unexpected"',
+                self.assertRaisesRegexp, Exception,
+                re.compile('^Expected$'), Stub)
+
+
+    def testSynonymAssertMethodNames(self):
+        """Test undocumented method name synonyms.
+
+        Please do not use these methods names in your own code.
+
+        This test confirms their continued existence and functionality
+        in order to avoid breaking existing code.
+        """
+        self.assertNotEquals(3, 5)
+        self.assertEquals(3, 3)
+        self.assertAlmostEquals(2.0, 2.0)
+        self.assertNotAlmostEquals(3.0, 5.0)
+        self.assert_(True)
+
+    def testDeepcopy(self):
+        # Issue: 5660
+        class TestableTest(unittest2.TestCase):
+            def testNothing(self):
+                pass
+
+        test = TestableTest('testNothing')
+
+        # This shouldn't blow up
+        deepcopy(test)
+
+
+if __name__ == "__main__":
+    unittest2.main()


[11/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code

Posted by rl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/options.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/options.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/options.py
new file mode 100755
index 0000000..8712794
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/options.py
@@ -0,0 +1,275 @@
+"Main module for running pychecker a Tkinter GUI for all the options"
+
+import sys
+import os
+import Tkinter, tkFileDialog
+
+from OptionTypes import *
+from string import capitalize, strip, rstrip, split
+
+import Config
+
+MAX_SUBBOX_ROWS = 8
+MAX_BOX_COLS = 3
+PAD = 10
+EDITOR = "xterm -e vi -n +%(line)d %(file)s"
+if sys.platform == 'win32':
+    EDITOR = "notepad %(file)s"
+
+def col_weight(grid):
+    "Set column weights so that sticky grid settings actually work"
+    unused, col = grid.grid_size()
+    for c in range(col):
+        grid.columnconfigure(c, weight=1)
+
+def spawn(cmd_list):
+    try:
+        if os.fork():
+            try:
+                os.execvp(cmd_list[0], cmd_list)
+            finally:
+                sys.exit()
+    except AttributeError:
+        os.execvp(cmd_list[0], cmd_list)
+
+def edit(file, line):
+    "Fire up an external editor to see the file at the given line"
+    unused = file, line
+    list = split(EDITOR)
+    cmd_list = []
+    for word in list:
+        cmd_list.append(word % locals())
+    spawn(cmd_list)
+
+def closeCB():
+    sys.exit(0)
+
+class Results:
+    "Display the warnings produced by checker"
+
+    def __init__(self, w):
+        self.top = Tkinter.Toplevel(w, name="results")
+        self.top.transient(w)
+        self.top.bind('<Return>', self.hide)
+        self.top.bind('<Escape>', self.hide)
+        self.text = Tkinter.Text(self.top, name="text")
+        self.text.grid()
+        self.text.bind('<Double-Button-1>', self.showFile)
+        close = Tkinter.Button(self.top,
+                            name="close",
+                            default=Tkinter.ACTIVE,
+                            command=self.hide)
+        close.grid()
+        self.text.update_idletasks()
+
+    def show(self, text):
+        self.text.delete("0.1", "end")
+        self.text.insert("0.1", text)
+        self.top.deiconify()
+        self.top.lift()
+
+    def hide(self, *unused):
+        self.top.withdraw()
+
+    def line(self):
+        return split(self.text.index(Tkinter.CURRENT), ".")[0]
+
+    def showFile(self, unused):
+        import re
+        line = self.line()
+        text = self.text.get(line + ".0", line + ".end")
+        text = rstrip(text)
+        result = re.search("(.*):([0-9]+):", text)
+        if result:
+            file, line = result.groups()
+            edit(file, int(line))
+            self.text.after(0, self.selectLine)
+
+    def selectLine(self):
+        line = self.line()
+        self.text.tag_remove(Tkinter.SEL, "1.0", Tkinter.END)
+        self.text.tag_add(Tkinter.SEL, line + ".0", line + ".end")
+
+class ConfigDialog:
+    "Dialog for editing options"
+    
+    def __init__(self, tk):
+        self._tk = tk
+        self._cfg, _, _ = Config.setupFromArgs(sys.argv)
+
+        self._help = None
+        self._optMap = {}
+        self._opts = []
+        self._file = Tkinter.StringVar()
+        self._results = None
+
+	if len(sys.argv) > 1:
+            self._file.set(sys.argv[1])
+
+        for name, group in Config._OPTIONS:
+          opts = []
+          for _, useValue, longArg, member, description in group:
+              value = None
+              if member:
+                  value = getattr(self._cfg, member)
+                  description = member + ": " + capitalize(description)
+                  description = strip(description)
+              tk.option_add('*' + longArg + ".help", description)
+              if useValue:
+                  if type(value) == type([]):
+                      field = List(longArg, value)
+                  elif type(value) == type(1):
+                      field = Number(longArg, int(value))
+                  elif type(value) == type(''):
+                      field = Text(longArg, value)
+                  else:
+                      field = Boolean(longArg, value)
+              else:
+                  field = Boolean(longArg, value)
+              self._optMap[longArg] = field
+              opts.append(field)
+          self._opts.append( (name, opts))
+
+    def _add_fields(self, w, opts):
+        count = 0
+        for opt in opts:
+            f = opt.field(w)
+            c, r = divmod(count, MAX_SUBBOX_ROWS)
+            f.grid(row=r, column=c, sticky=Tkinter.NSEW)
+            count = count + 1
+
+    def _add_group(self, w, name, opts):
+        colFrame = Tkinter.Frame(w)
+        
+        label = Tkinter.Label(colFrame, text=name + ":")
+        label.grid(row=0, column=0, sticky=Tkinter.NSEW)
+        
+        gframe = Tkinter.Frame(colFrame, relief=Tkinter.GROOVE, borderwidth=2)
+        gframe.grid(row=1, column=0, sticky=Tkinter.NSEW)
+        self._add_fields(gframe, opts)
+        
+        label = Tkinter.Label(colFrame)
+        label.grid(row=2, column=0, sticky=Tkinter.NSEW)
+        colFrame.rowconfigure(2, weight=1)
+        return colFrame
+
+    def main(self):
+        frame = Tkinter.Frame(self._tk, name="opts")
+        frame.grid()
+        self._tk.option_readfile('Options.ad')
+        self._fields = {}
+        row, col = 0, 0
+        rowFrame = Tkinter.Frame(frame)
+        rowFrame.grid(row=row)
+        row = row + 1
+        for name, opts in self._opts:
+            w = self._add_group(rowFrame, name, opts)
+            w.grid(row=row, column=col, sticky=Tkinter.NSEW, padx=PAD)
+            col = col + 1
+            if col >= MAX_BOX_COLS:
+                col_weight(rowFrame)
+                rowFrame=Tkinter.Frame(frame)
+                rowFrame.grid(row=row, sticky=Tkinter.NSEW)
+                col = 0
+                row = row + 1
+        col_weight(rowFrame)
+
+        self._help = Tkinter.Label(self._tk, name="helpBox")
+        self._help.grid(row=row)
+        self._help.config(takefocus=0)
+        buttons = Tkinter.Frame(self._tk, name="buttons")
+        ok = Tkinter.Button(buttons, name="ok", command=self.ok, default=Tkinter.ACTIVE)
+        ok.grid(row=row, column=0)
+        default = Tkinter.Button(buttons, name="default", command=self.default)
+        default.grid(row=row, column=1)
+        close = Tkinter.Button(buttons, name="close", command=closeCB)
+        close.grid(row=row, column=2)
+        buttons.grid()
+
+        f = Tkinter.Frame(self._tk, name="fileStuff")
+        Tkinter.Button(f, name="getfile", command=self.file).grid(row=0, column=1)
+        fileEntry = Tkinter.Entry(f, name="fname", textvariable=self._file)
+	fileEntry.grid(row=0, column=2)
+        Tkinter.Button(f, name="check", command=self.check).grid(row=0, column=3)
+        f.grid(sticky=Tkinter.EW)
+        
+        self._tk.bind_all('<FocusIn>', self.focus)
+        self._tk.bind_all('<Enter>', self.focus)
+        self._tk.bind_all('<ButtonPress>', self.click)
+        fileEntry.bind('<Return>', self.check)
+        self._tk.mainloop()
+
+    #
+    # Callbacks
+    #
+
+    def help(self, w):
+        if type(w) == type(''):         # occurs with file dialog...
+            return
+        if self._help == w:             # ignore help events on help...
+            return
+        help = w.option_get("help", "help")
+        self._help.configure(text=help)
+
+    def focus(self, ev):
+        self.help(ev.widget)
+
+    def click(self, ev):
+        self.help(ev.widget)
+
+    def ok(self):
+        opts = []
+        # Pull command-line args
+        for _, group in self._opts:
+            for opt in group:
+                arg = opt.arg()
+                if arg:
+                    opts.append(arg)
+
+        # Calculate config
+        self._cfg, _, _ = Config.setupFromArgs(opts)
+
+        # Set controls based on new config
+        for _, group in Config._OPTIONS:
+            for _, _, longArg, member, _ in group:
+                if member:
+                    self._optMap[longArg].set(getattr(self._cfg, member))
+
+    def default(self):
+        self._cfg, _, _ = Config.setupFromArgs(sys.argv)
+        for _, group in Config._OPTIONS:
+            for _, _, longArg, member, _ in group:
+                if member:
+                    self._optMap[longArg].set(getattr(self._cfg, member))
+                else:
+                    self._optMap[longArg].set(0)
+
+    def file(self):
+        self._file.set(tkFileDialog.askopenfilename())
+
+    def check(self, *unused):
+        import checker
+        import StringIO
+        
+        self.ok()                       # show effect of all settings
+
+        checker._allModules = {}
+        warnings = checker.getWarnings([self._file.get()], self._cfg)
+        capture = StringIO.StringIO()
+        
+        if not self._results:
+            self._results = Results(self._help)
+        checker._printWarnings(warnings, capture)
+
+        value = strip(capture.getvalue())
+        if not value:
+            value = "None"
+        self._results.show(value)
+
+
+if __name__=='__main__':
+    dirs = os.path.join(os.path.split(os.getcwd())[:-1])
+    sys.path.append(dirs[0])
+    tk = Tkinter.Tk()
+    tk.title('PyChecker')
+    ConfigDialog(tk).main()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/pcmodules.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/pcmodules.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/pcmodules.py
new file mode 100644
index 0000000..81f3c22
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/pcmodules.py
@@ -0,0 +1,19 @@
+"""
+Track loaded PyCheckerModules together with the directory they were loaded from.
+This allows us to differentiate between loaded modules with the same name
+but from different paths, in a way that sys.modules doesn't do.
+"""
+
+__pcmodules = {}
+
+def getPCModule(moduleName, moduleDir=None):
+    global __pcmodules
+    return __pcmodules.get((moduleName, moduleDir), None)
+
+def getPCModules():
+    global __pcmodules
+    return __pcmodules.values()
+
+def addPCModule(pcmodule):
+    global __pcmodules
+    __pcmodules[(pcmodule.moduleName, pcmodule.moduleDir)] = pcmodule

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/printer.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/printer.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/printer.py
new file mode 100644
index 0000000..3b8e9b1
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/printer.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2001, MetaSlash Inc.  All rights reserved.
+
+"Helper functions for printing out info about objects"
+
+from pychecker import utils
+
+def printFunction(spaces, prefix, func, className = None) :
+    params = ''
+    argcount = func.func_code.co_argcount
+    defaultArgStart = argcount
+    if func.func_defaults != None :
+        defaultArgStart = argcount - len(func.func_defaults)
+    for i in range(0, argcount) :
+        arg = func.func_code.co_varnames[i]
+        if i >= defaultArgStart :
+            arg = arg + " = %s" % utils.safestr(func.func_defaults[i - defaultArgStart])
+        params = params + "%s, " % arg
+    params = "(%s)" % params[:-2]
+    if className == None :
+        className = ""
+    else :
+        className = className + "."
+    print "%s%s%s%s%s" % (spaces, prefix, className, func.func_name, params)
+
+
+def module(module) :
+    print "Module: ", module.moduleName
+    if module.module == None :
+        return
+
+    print "  Imports:  ", module.modules.keys()
+    print "  Variables:", module.variables.keys()
+    print ""
+    for function in module.functions.values() :
+        printFunction("  ", "Function:  ", function.function)
+    print ""
+    for c in module.classes.values() :
+        for method in c.methods.values() :
+            if method != None :
+                printFunction("  ", "", method.function, c.name)
+        print ""
+
+def attrs(object) :
+    for attr in dir(object) :
+        print " %s: %s" % (attr, `getattr(object, attr)`)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/python.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/python.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/python.py
new file mode 100644
index 0000000..6f9d6ab
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/python.py
@@ -0,0 +1,427 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2001-2004, MetaSlash Inc.  All rights reserved.
+# Portions Copyright (c) 2005, Google, Inc. All rights reserved.
+
+"""
+Setup a lot of info about Python builtin types, functions, methods, etc.
+"""
+
+import types
+import sys
+
+from pychecker import utils
+from pychecker import Stack
+from pychecker import Warning
+
+
+BOOL = types.IntType
+#                    name   (type,  args: min, max, kwArgs?
+GLOBAL_FUNC_INFO = { '__import__': (types.ModuleType, 1, 4),
+                     'abs': (Stack.TYPE_UNKNOWN, 1, 1),
+                     'apply': (Stack.TYPE_UNKNOWN, 2, 3),
+                     'buffer': (types.BufferType, 1, 3),
+                     'callable': (BOOL, 1, 1),
+                     'chr': (types.StringType, 1, 1),
+                     'cmp': (types.IntType, 2, 2),
+                     'coerce': ([ types.NoneType, types.TupleType ], 2, 2),
+                     'compile': (types.CodeType, 3, 3),
+                     'complex': (types.ComplexType, 1, 2, ['real', 'imag']),
+                     'delattr': (types.NoneType, 2, 2),
+                     'dir': (types.ListType, 0, 1),
+                     'divmod': (types.TupleType, 2, 2),
+                     'eval': (Stack.TYPE_UNKNOWN, 1, 3),
+                     'execfile': (types.NoneType, 1, 3),
+                     'filter': (types.ListType, 2, 2),
+                     'float': (types.FloatType, 1, 1),
+                     'getattr': (Stack.TYPE_UNKNOWN, 2, 3),
+                     'globals': (types.DictType, 0, 0),
+                     'hasattr': (BOOL, 2, 2),
+                     'hash': (types.IntType, 1, 1),
+                     'hex': (types.StringType, 1, 1),
+                     'id': (types.IntType, 1, 1),
+                     'input': (Stack.TYPE_UNKNOWN, 0, 1),
+                     'int': (types.IntType, 1, 2, ['x']),
+                     'intern': (types.StringType, 1, 1),
+                     'isinstance': (BOOL, 2, 2),
+                     'issubclass': (BOOL, 2, 2),
+                     'len': (types.IntType, 1, 1),
+                     'list': (types.ListType, 1, 1, ['sequence']),
+                     'locals': (types.DictType, 0, 0),
+                     'long': (types.LongType, 1, 2, ['x']),
+                     'map': (types.ListType, 2, None),
+                     'max': (Stack.TYPE_UNKNOWN, 1, None),
+                     'min': (Stack.TYPE_UNKNOWN, 1, None),
+                     'oct': (types.StringType, 1, 1),
+                     'open': (types.FileType, 1, 3, ['name', 'mode', 'buffering']),
+                     'ord': (types.IntType, 1, 1),
+                     'pow': (Stack.TYPE_UNKNOWN, 2, 3),
+                     'range': (types.ListType, 1, 3),
+                     'raw_input': (types.StringType, 0, 1),
+                     'reduce': (Stack.TYPE_UNKNOWN, 2, 3),
+                     'reload': (types.ModuleType, 1, 1),
+                     'repr': (types.StringType, 1, 1),
+                     'round': (types.FloatType, 1, 2),
+                     'setattr': (types.NoneType, 3, 3),
+                     'slice': (types.SliceType, 1, 3),
+                     'str': (types.StringType, 1, 1),
+                     'tuple': (types.TupleType, 1, 1),
+                     'type': (types.TypeType, 1, 1),
+                     'vars': (types.DictType, 0, 1),
+                     'xrange': (types.ListType, 1, 3),
+                   }
+
+if hasattr(types, 'UnicodeType') :
+    GLOBAL_FUNC_INFO['unichr'] = (types.UnicodeType, 1, 1)
+    GLOBAL_FUNC_INFO['unicode'] = (types.UnicodeType, 1, 3, ['string', 'encoding', 'errors'])
+
+if utils.pythonVersion() >= utils.PYTHON_2_2 :
+    GLOBAL_FUNC_INFO['compile'] = (types.CodeType, 3, 5)
+    GLOBAL_FUNC_INFO['dict'] = (types.DictType, 0, 1, ['items'])
+    GLOBAL_FUNC_INFO['file'] = GLOBAL_FUNC_INFO['open']
+    GLOBAL_FUNC_INFO['float'] = (types.FloatType, 0, 1, ['x'])
+    GLOBAL_FUNC_INFO['int'] = (types.IntType, 0, 2, ['x'])
+    GLOBAL_FUNC_INFO['list'] = (types.ListType, 0, 1, ['sequence'])
+    GLOBAL_FUNC_INFO['long'] = (types.LongType, 0, 2, ['x'])
+    GLOBAL_FUNC_INFO['str'] = (types.StringType, 0, 1, ['object'])
+    # FIXME: type doesn't take 2 args, only 1 or 3
+    GLOBAL_FUNC_INFO['type'] = (types.TypeType, 1, 3, ['name', 'bases', 'dict'])
+    GLOBAL_FUNC_INFO['tuple'] = (types.TupleType, 0, 1, ['sequence'])
+
+    GLOBAL_FUNC_INFO['classmethod'] = (types.MethodType, 1, 1)
+    GLOBAL_FUNC_INFO['iter'] = (Stack.TYPE_UNKNOWN, 1, 2)
+    GLOBAL_FUNC_INFO['property'] = (Stack.TYPE_UNKNOWN, 0, 4, ['fget', 'fset', 'fdel', 'doc'])
+    GLOBAL_FUNC_INFO['super'] = (Stack.TYPE_UNKNOWN, 1, 2)
+    GLOBAL_FUNC_INFO['staticmethod'] = (types.MethodType, 1, 1)
+    GLOBAL_FUNC_INFO['unicode'] = (types.UnicodeType, 0, 3, ['string', 'encoding', 'errors'])
+
+    GLOBAL_FUNC_INFO['bool'] = (BOOL, 1, 1, ['x'])
+
+if utils.pythonVersion() >= utils.PYTHON_2_3:
+    GLOBAL_FUNC_INFO['dict'] = (types.DictType, 0, 1, [])
+
+if utils.pythonVersion() >= utils.PYTHON_2_5:
+    GLOBAL_FUNC_INFO['max'] = (Stack.TYPE_UNKNOWN, 1, None, ['key'])
+    GLOBAL_FUNC_INFO['min'] = (Stack.TYPE_UNKNOWN, 1, None, ['key'])
+
+def tryAddGlobal(name, *args):
+    if globals().has_key(name):
+        GLOBAL_FUNC_INFO[name] = args
+
+zipMinArgs = 1
+if utils.pythonVersion() >= utils.PYTHON_2_4:
+    zipMinArgs = 0
+    
+tryAddGlobal('zip', types.ListType, zipMinArgs, None)
+
+tryAddGlobal('enumerate', types.TupleType, 1, 1, ['sequence'])
+# sum() could also return float/long
+tryAddGlobal('sum', types.IntType, 1, 2, ['start'])
+# sorted() and reversed() always return an iterator  (FIXME: support iterator)
+tryAddGlobal('sorted', Stack.TYPE_UNKNOWN, 1, 1)
+tryAddGlobal('reversed', Stack.TYPE_UNKNOWN, 1, 1)
+
+tryAddGlobal('all', BOOL, 1, 1)
+tryAddGlobal('any', BOOL, 1, 1)
+
+_STRING_METHODS = { 'capitalize': (types.StringType, 0, 0),
+                    'center': (types.StringType, 1, 1),
+                    'count': (types.IntType, 1, 1),
+                    'encode': (types.StringType, 0, 2),
+                    'endswith': (BOOL, 1, 3),
+                    'expandtabs': (types.StringType, 0, 1),
+                    'find': (types.IntType, 1, 3),
+                    'index': (types.IntType, 1, 3),
+                    'isalnum': (BOOL, 0, 0),
+                    'isalpha': (BOOL, 0, 0),
+                    'isdigit': (BOOL, 0, 0),
+                    'islower': (BOOL, 0, 0),
+                    'isspace': (BOOL, 0, 0),
+                    'istitle': (BOOL, 0, 0),
+                    'isupper': (BOOL, 0, 0),
+                    'join': (types.StringType, 1, 1),
+                    'ljust': (types.StringType, 1, 1),
+                    'lower': (types.StringType, 0, 0),
+                    'lstrip': (types.StringType, 0, 0),
+                    'replace': (types.StringType, 2, 3),
+                    'rfind': (types.IntType, 1, 3),
+                    'rindex': (types.IntType, 1, 3),
+                    'rjust': (types.StringType, 1, 1),
+                    'rstrip': (types.StringType, 0, 0),
+                    'split': (types.ListType, 0, 2),
+                    'splitlines': (types.ListType, 0, 1),
+                    'startswith': (BOOL, 1, 3),
+                    'strip': (types.StringType, 0, 0),
+                    'swapcase': (types.StringType, 0, 0),
+                    'title': (types.StringType, 0, 0),
+                    'translate': (types.StringType, 1, 2),
+                    'upper': (types.StringType, 0, 0),
+                  }
+
+if utils.pythonVersion() >= utils.PYTHON_2_2 :
+    _STRING_METHODS['decode'] = (types.UnicodeType, 0, 2)
+    _STRING_METHODS['zfill'] = (types.StringType, 1, 1)
+
+if utils.pythonVersion() >= utils.PYTHON_2_4:
+    _STRING_METHODS['rsplit'] = (types.StringType, 0, 2)
+    _STRING_METHODS['center'] = (types.StringType, 1, 2),
+    _STRING_METHODS['ljust'] = (types.StringType, 1, 2),
+    _STRING_METHODS['rjust'] = (types.StringType, 1, 2),
+
+BUILTIN_METHODS = { types.DictType :
+                    { 'clear': (types.NoneType, 0, 0),
+                      'copy': (types.DictType, 0, 0),
+                      'get': (Stack.TYPE_UNKNOWN, 1, 2),
+                      'has_key': (BOOL, 1, 1),
+                      'items': (types.ListType, 0, 0),
+                      'keys': (types.ListType, 0, 0),
+                      'popitem': (types.TupleType, 0, 0),
+                      'setdefault': (Stack.TYPE_UNKNOWN, 1, 2),
+                      'update': (types.NoneType, 1, 1),
+                      'values': (types.ListType, 0, 0),
+                    },
+                    types.ListType :
+                    { 'append': (types.NoneType, 1, 1),
+                      'count': (types.IntType, 1, 1),
+                      'extend': (types.NoneType, 1, 1),
+                      'index': (types.IntType, 1, 1),
+                      'insert': (types.NoneType, 2, 2),
+                      'pop': (Stack.TYPE_UNKNOWN, 0, 1),
+                      'remove': (types.NoneType, 1, 1),
+                      'reverse': (types.NoneType, 0, 0),
+                      'sort': (types.NoneType, 0, 1),
+                    },
+                    types.FileType :
+                    { 'close': (types.NoneType, 0, 0),
+                      'fileno': (types.IntType, 0, 0),
+                      'flush': (types.NoneType, 0, 0),
+                      'isatty': (BOOL, 0, 0),
+                      'read': (types.StringType, 0, 1),
+                      'readinto': (types.NoneType, 1, 1),
+                      'readline': (types.StringType, 0, 1),
+                      'readlines': (types.ListType, 0, 1),
+                      'seek': (types.NoneType, 1, 2),
+                      'tell': (types.IntType, 0, 0),
+                      'truncate': (types.NoneType, 0, 1),
+                      'write': (types.NoneType, 1, 1),
+                      'writelines': (types.NoneType, 1, 1),
+                      'xreadlines': (types.ListType, 0, 0),
+                    },
+                  }
+
+if utils.pythonVersion() >= utils.PYTHON_2_4:
+    GLOBAL_FUNC_INFO['set'] = (Stack.TYPE_UNKNOWN, 0, 1)
+    GLOBAL_FUNC_INFO['frozenset'] = (Stack.TYPE_UNKNOWN, 0, 1)
+
+    kwargs = ['cmp', 'key', 'reverse']
+    BUILTIN_METHODS[types.ListType]['sort'] = (types.NoneType, 0, 3, kwargs)
+    BUILTIN_METHODS[types.DictType]['update'] = (types.NoneType, 1, 1, [])
+
+if hasattr({}, 'pop'):
+    BUILTIN_METHODS[types.DictType]['pop'] = (Stack.TYPE_UNKNOWN, 1, 2)
+
+if utils.pythonVersion() >= utils.PYTHON_2_5:
+    _STRING_METHODS['partition'] = (types.TupleType, 1, 1)
+    _STRING_METHODS['rpartition'] = (types.TupleType, 1, 1)
+
+if utils.pythonVersion() >= utils.PYTHON_2_6:
+    GLOBAL_FUNC_INFO['bin'] = (types.StringType, 1, 1)
+    GLOBAL_FUNC_INFO['bytesarray'] = (bytearray, 0, 1)
+    GLOBAL_FUNC_INFO['bytes'] = (bytes, 0, 1)
+    GLOBAL_FUNC_INFO['format'] = (types.StringType, 1, 2)
+    GLOBAL_FUNC_INFO['next'] = (Stack.TYPE_UNKNOWN, 1, 2)
+    GLOBAL_FUNC_INFO['print'] = (types.NoneType, 0, None,
+                                 ['sep', 'end', 'file'])
+
+def _setupBuiltinMethods() :
+    if utils.pythonVersion() >= utils.PYTHON_2_2 :
+        PY22_DICT_METHODS = { 'iteritems': (types.ListType, 0, 0),
+                              'iterkeys': (types.ListType, 0, 0),
+                              'itervalues': (types.ListType, 0, 0),
+                            }
+
+        BUILTIN_METHODS[types.DictType].update(PY22_DICT_METHODS)
+
+    try :
+        BUILTIN_METHODS[types.ComplexType] = \
+                                  { 'conjugate': (types.ComplexType, 0, 0), }
+    except AttributeError :
+        pass
+
+    if len(dir('')) > 0 :
+        BUILTIN_METHODS[types.StringType] = _STRING_METHODS
+
+    try :
+        BUILTIN_METHODS[types.UnicodeType] = _STRING_METHODS
+    except AttributeError :
+        pass
+
+_setupBuiltinMethods()
+
+MUTABLE_TYPES = (types.ListType, types.DictType, types.InstanceType,)
+
+# identifiers which will become a keyword in a future version
+FUTURE_KEYWORDS = { 'yield': '2.2', 'with': '2.5', 'as': '2.5' }
+
+METHODLESS_OBJECTS = { types.NoneType : None, types.IntType : None,
+                       types.LongType : None, types.FloatType : None,
+                       types.BufferType : None, types.TupleType : None,
+                       types.EllipsisType : None,
+                     }
+
+def _setupBuiltinAttrs() :
+    item = Stack.Item(None, None)
+    BUILTIN_ATTRS[types.MethodType] = dir(item.__init__)
+    del item
+
+    if utils.pythonVersion() >= utils.PYTHON_2_2 :
+        # FIXME: I'm sure more types need to be added here
+        BUILTIN_ATTRS[types.StringType] = dir(''.__class__)
+        BUILTIN_ATTRS[types.ListType] = dir([].__class__)
+        BUILTIN_ATTRS[types.DictType] = dir({}.__class__)
+
+    try :
+        import warnings
+        _MSG = "xrange object's 'start', 'stop' and 'step' attributes are deprecated"
+        warnings.filterwarnings('ignore', _MSG)
+        del warnings, _MSG
+    except (ImportError, AssertionError):
+        pass
+    BUILTIN_ATTRS[types.XRangeType] = dir(xrange(0))
+
+    try: BUILTIN_ATTRS[types.ComplexType] = dir(complex(0, 1))
+    except: pass
+
+    try: BUILTIN_ATTRS[types.UnicodeType] = dir(unicode(''))
+    except: pass
+
+    try: BUILTIN_ATTRS[types.CodeType] = dir(_setupBuiltinAttrs.func_code)
+    except: pass
+
+    try: BUILTIN_ATTRS[types.FileType] = dir(sys.__stdin__)
+    except: pass
+
+    try:
+        raise TypeError
+    except TypeError :
+        try:
+            tb = sys.exc_info()[2]
+            BUILTIN_ATTRS[types.TracebackType] = dir(tb)
+            BUILTIN_ATTRS[types.FrameType] = dir(tb.tb_frame)
+        except:
+            pass
+        tb = None
+
+BUILTIN_ATTRS = { types.StringType : dir(''),
+                  types.TypeType : dir(type(type)),
+                  types.ListType : dir([]),
+                  types.DictType : dir({}),
+                  types.FunctionType : dir(_setupBuiltinAttrs),
+                  types.BuiltinFunctionType : dir(len),
+                  types.BuiltinMethodType : dir([].append),
+                  types.ClassType : dir(Stack.Item),
+                  types.UnboundMethodType : dir(Stack.Item.__init__),
+                  types.LambdaType : dir(lambda: None),
+                  types.SliceType : dir(slice(0)),
+                }
+
+# have to setup the rest this way to support different versions of Python
+_setupBuiltinAttrs()
+
+PENDING_DEPRECATED_MODULES = { 'string': None, 'types': None,
+                             }
+DEPRECATED_MODULES = { 'FCNTL': 'fcntl', 'gopherlib': None,
+                       'macfs': 'Carbon.File or Carbon.Folder',
+                       'posixfile': 'fcntl', 'pre': None, 'regsub': 're',
+                       'statcache': 'os.stat()',
+                       'stringold': None, 'tzparse': None,
+                       'TERMIOS': 'termios', 'whrandom':'random',
+                       'xmllib': 'xml.sax',
+
+                       # C Modules
+                       'mpz': None, 'pcre': None, 'pypcre': None,
+                       'rgbimg': None, 'strop': None, 'xreadlines': 'file',
+                     }
+DEPRECATED_ATTRS = { 'array.read': None, 'array.write': None,
+                     'operator.isCallable': None,
+                     'operator.sequenceIncludes': None,
+                     'pty.master_open': None, 'pty.slave_open': None,
+                     'random.stdgamma': 'random.gammavariate',
+                     'rfc822.AddrlistClass': 'rfc822.AddressList',
+                     'string.atof': None, 'string.atoi': None,
+                     'string.atol': None, 'string.zfill': None,
+                     'sys.exc_traceback': None, 'sys.exit_thread': None,
+                     'tempfile.mktemp': None, 'tempfile.template': None,
+                   }
+
+# FIXME: can't check these right now, maybe later
+DEPRECATED_METHODS = {
+                       'email.Message.get_type': 'email.Message.get_content_type',
+                       'email.Message.get_subtype': 'email.Message.get_content_subtype',
+                       'email.Message.get_main_type': 'email.Message.get_content_maintype',
+                       'htmllib.HTMLParser.do_nextid': None,
+                       'pstats.Stats.ignore': None,
+                       'random.Random.cunifvariate': None,
+                       'random.Random.stdgamma': 'Random.gammavariate',
+                     }
+
+_OS_AND_POSIX_FUNCS = { 'tempnam': None, 'tmpnam': None }
+SECURITY_FUNCS = { 'os' : _OS_AND_POSIX_FUNCS, 'posix': _OS_AND_POSIX_FUNCS }
+
+SPECIAL_METHODS = {
+    '__call__': None,                   # any number > 1
+    '__cmp__': 2,
+    '__coerce__': 2,
+    '__contains__': 2,
+    '__del__': 1,
+    '__hash__': 1,
+    '__iter__': 1,
+    '__len__': 1,
+    '__new__': None,			# new-style class constructor
+    '__nonzero__': 1,
+
+    '__hex__': 1,
+    '__oct__': 1,
+    '__repr__': 1,
+    '__str__': 1,
+
+    '__invert__': 1,	'__neg__': 1,	'__pos__': 1,     '__abs__': 1,     
+    '__complex__': 1,	'__int__': 1,	'__long__': 1,    '__float__': 1,
+
+    '__eq__': 2,	'__ne__': 2,
+    '__ge__': 2,	'__gt__': 2,
+    '__le__': 2,	'__lt__': 2,
+
+    '__getattribute__': 2,	# only in new-style classes
+    '__get__': 3,		'__set__': 3,		'__delete__': 2,
+    '__getattr__': 2,		'__setattr__': 3,	'__delattr__': 2,
+    '__getitem__': 2,		'__setitem__': 3,	'__delitem__': 2,
+    '__getslice__': 3,		'__setslice__': 4,	'__delslice__': 3,
+    # getslice is deprecated
+
+    '__add__': 2,	'__radd__': 2,		'__iadd__': 2,    
+    '__sub__': 2,	'__rsub__': 2,		'__isub__': 2,
+    '__mul__': 2,	'__rmul__': 2,		'__imul__': 2,    
+    '__div__': 2,	'__rdiv__': 2,		'__idiv__': 2,
+    #  __pow__: 2 or 3                           __ipow__: 2 or 3
+    '__pow__': 3,	'__rpow__': 2,		'__ipow__': 3,
+    '__truediv__': 2,	'__rtruediv__': 2,	'__itruediv__': 2,	
+    '__floordiv__': 2,	'__rfloordiv__': 2,	'__ifloordiv__': 2,	
+    '__mod__': 2,	'__rmod__': 2,		'__imod__': 2,    
+    '__divmod__': 2,	'__rdivmod__': 2,	# no inplace op for divmod()
+
+    '__lshift__': 2,	'__rlshift__': 2,	'__ilshift__': 2,
+    '__rshift__': 2,	'__rrshift__': 2,	'__irshift__': 2, 
+
+    '__and__': 2,	'__rand__': 2,		'__iand__': 2,
+    '__xor__': 2,	'__rxor__': 2,		'__ixor__': 2,
+    '__or__': 2,	'__ror__': 2,		'__ior__': 2,
+
+    # these are related to pickling 
+    '__getstate__': 1,		'__setstate__': 2,
+    '__copy__': 1,		'__deepcopy__': 2,
+    '__getinitargs__': 1,	'__getnewargs__': 1,
+    '__reduce__': 1,		'__reduce_ex__': 2,
+    }
+
+NEW_STYLE_CLASS_METHODS = ['__getattribute__', '__set__', '__get__', '__delete__']

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/utils.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/utils.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/utils.py
new file mode 100644
index 0000000..298174b
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/utils.py
@@ -0,0 +1,102 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2001-2004, MetaSlash Inc.  All rights reserved.
+
+"""
+Print out warnings from Python source files.
+"""
+
+import sys
+import string
+import copy
+
+from pychecker import msgs
+from pychecker import Config
+from pychecker.Warning import Warning
+
+
+VAR_ARGS_BITS = 8
+MAX_ARGS_MASK = ((1 << VAR_ARGS_BITS) - 1)
+
+INIT = '__init__'
+LAMBDA = '<lambda>'
+
+# number of instructions to check backwards if it was a return
+BACK_RETURN_INDEX = 4
+
+
+_cfg = []
+
+def cfg() :
+    return _cfg[-1]
+
+def initConfig(cfg) :
+    _cfg.append(cfg)
+
+def pushConfig() :
+    newCfg = copy.copy(cfg())
+    _cfg.append(newCfg)
+
+def popConfig() :
+    del _cfg[-1]
+
+
+def shouldUpdateArgs(operand) :
+    return operand == Config.CHECKER_VAR
+
+def updateCheckerArgs(argStr, func, lastLineNum, warnings) :
+    try :
+        argList = string.split(argStr)
+        # don't require long options to start w/--, we can add that for them
+        for i in range(0, len(argList)) :
+            if argList[i][0] != '-' :
+                argList[i] = '--' + argList[i]
+
+        cfg().processArgs(argList)
+        return 1
+    except Config.UsageError, detail :
+        warn = Warning(func, lastLineNum, msgs.INVALID_CHECKER_ARGS % detail)
+        warnings.append(warn)
+        return 0
+                       
+
+def debug(*args) :
+    if cfg().debug: print args
+
+
+PYTHON_1_5 = 0x10502
+PYTHON_2_0 = 0x20000
+PYTHON_2_1 = 0x20100
+PYTHON_2_2 = 0x20200
+PYTHON_2_3 = 0x20300
+PYTHON_2_4 = 0x20400
+PYTHON_2_5 = 0x20500
+PYTHON_2_6 = 0x20600
+PYTHON_3_0 = 0x30000
+
+def pythonVersion() :
+    return sys.hexversion >> 8
+
+def startswith(s, substr) :
+    "Ugh, supporting python 1.5 is a pain"
+    return s[0:len(substr)] == substr
+
+def endswith(s, substr) :
+    "Ugh, supporting python 1.5 is a pain"
+    return s[-len(substr):] == substr
+
+
+# generic method that can be slapped into any class, thus the self parameter
+def std_repr(self) :
+    return "<%s at 0x%x: %s>" % (self.__class__.__name__, id(self), safestr(self))
+
+try:
+    unicode, UnicodeError
+except NameError:
+    class UnicodeError(Exception): pass
+
+def safestr(value):
+   try:
+      return str(value)
+   except UnicodeError:
+      return unicode(value)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/warn.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/warn.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/warn.py
new file mode 100644
index 0000000..8126f2e
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/warn.py
@@ -0,0 +1,778 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2001-2002, MetaSlash Inc.  All rights reserved.
+# Portions Copyright (c) 2005, Google, Inc. All rights reserved.
+
+"""
+Print out warnings from Python source files.
+"""
+
+import os.path
+import sys
+import string
+import types
+import traceback
+import imp
+import re
+
+from pychecker import OP
+from pychecker import Stack
+from pychecker import function
+from pychecker import python
+from pychecker import pcmodules
+
+from pychecker import msgs
+from pychecker import utils
+from pychecker import CodeChecks
+from pychecker.Warning import Warning
+
+
+def cfg() :
+    return utils.cfg()
+
+def _checkSelfArg(method, warnings) :
+    """Return a Warning if there is no self parameter or
+       the first parameter to a method is not self."""
+
+    if not cfg().methodArgName:
+        return
+
+    code = method.function.func_code
+    err = None
+    if method.isStaticMethod():
+        if code.co_argcount > 0 and cfg().methodArgName == code.co_varnames[0]:
+            err = msgs.SELF_IS_ARG % 'staticmethod'
+    elif code.co_argcount < 1: 
+        err = msgs.NO_METHOD_ARGS % cfg().methodArgName
+    else:
+        if method.isClassMethod():
+            if code.co_varnames[0] not in cfg().classmethodArgNames:
+                err = msgs.SELF_NOT_FIRST_ARG % \
+                      (cfg().classmethodArgNames, 'class')
+        elif code.co_varnames[0] != cfg().methodArgName:
+            err = msgs.SELF_NOT_FIRST_ARG % (cfg().methodArgName, '')
+
+    if err is not None :
+        warnings.append(Warning(code, code, err))
+
+
+def _checkNoSelfArg(func, warnings) :
+    "Return a Warning if there is a self parameter to a function."
+
+    code = func.function.func_code
+    if code.co_argcount > 0 and cfg().methodArgName in code.co_varnames:
+        warnings.append(Warning(code, code, msgs.SELF_IS_ARG % 'function'))
+
+
+def _checkSubclass(c1, c2):
+    try:
+        return issubclass(c1.classObject, c2.classObject)
+    except (TypeError, AttributeError):
+        return 0
+
+
+_IGNORE_RETURN_TYPES = ( Stack.TYPE_FUNC_RETURN, Stack.TYPE_ATTRIBUTE,
+                         Stack.TYPE_GLOBAL, Stack.TYPE_COMPARISON,
+                         Stack.TYPE_UNKNOWN)
+
+def _checkReturnWarnings(code) :
+    is_getattr = code.func_code.co_name in ('__getattr__', '__getattribute__')
+    if is_getattr :
+        for line, retval, dummy in code.returnValues :
+            if retval.isNone() :
+                err = msgs.DONT_RETURN_NONE % code.func_code.co_name
+                code.addWarning(err, line+1)
+
+    # there must be at least 2 real return values to check for consistency
+    returnValuesLen = len(code.returnValues)
+    if returnValuesLen < 2 :
+        return
+
+    # if the last return is implicit, check if there are non None returns
+    lastReturn = code.returnValues[-1]
+
+    # Python 2.4 optimizes the dead implicit return out, so we can't
+    # distinguish implicit and explicit "return None"
+    if utils.pythonVersion() < utils.PYTHON_2_4 and \
+           not code.starts_and_ends_with_finally and \
+           cfg().checkImplicitReturns and lastReturn[1].isImplicitNone():
+        for line, retval, dummy in code.returnValues[:-1] :
+            if not retval.isNone() :
+                code.addWarning(msgs.IMPLICIT_AND_EXPLICIT_RETURNS,
+                                lastReturn[0]+1)
+                break
+
+    # __get*__ funcs can return different types, don't warn about inconsistency
+    if utils.startswith(code.func_code.co_name, '__get') and \
+       utils.endswith(code.func_code.co_name, '__') :
+        return
+
+    returnType, returnData = None, None
+    for line, value, dummy in code.returnValues :
+        if not value.isNone() :
+            valueType = value.getType(code.typeMap)
+            if returnType is None and valueType not in _IGNORE_RETURN_TYPES :
+                returnData = value
+                returnType = valueType
+                continue
+
+            # always ignore None, None can be returned w/any other type
+            # FIXME: if we stored func return values, we could do better
+            if returnType is not None and not value.isNone() and \
+               valueType not in _IGNORE_RETURN_TYPES and \
+               returnData.type not in _IGNORE_RETURN_TYPES :
+                ok = returnType in (type(value.data), valueType)
+                if ok :
+                    if returnType == types.TupleType :
+                        # FIXME: this isn't perfect, if len == 0
+                        # the length can really be 0 OR unknown
+                        # we shouldn't check the lengths for equality
+                        # ONLY IF one of the lengths is truly unknown
+                        if returnData.length > 0 and value.length > 0:
+                            ok = returnData.length == value.length
+                else :
+                    ok = _checkSubclass(returnType, valueType) or \
+                         _checkSubclass(valueType, returnType)
+                if not ok :
+                    code.addWarning(msgs.INCONSISTENT_RETURN_TYPE, line)
+
+
+def _checkComplex(code, maxValue, value, func, err) :
+    if maxValue and value > maxValue :
+        line = func.function.func_code.co_firstlineno
+        code.addWarning(err % (func.function.__name__, value), line)
+
+
+def _checkCode(code, codeSource) :
+    while code.index < code.maxCode :
+        op, oparg, operand = code.popNextOp()
+        dispatch_func = CodeChecks.DISPATCH[op]
+        if dispatch_func is not None :
+            dispatch_func(oparg, operand, codeSource, code)
+
+def _name_unused(var) :
+    if var in cfg().unusedNames :
+        return 0
+    for name in cfg().unusedNames :
+        if name != '_' and utils.startswith(var, name) :
+            return 0
+    return 1
+
+def _checkUnusedParam(var, line, func, code) :
+    if line is not None and line == 0 and _name_unused(var) :
+        if ((cfg().ignoreSelfUnused or var != cfg().methodArgName) and
+            (cfg().varArgumentsUsed or func.varArgName() != var)) :
+            code.addWarning(msgs.UNUSED_PARAMETER % var, code.func_code)
+
+def _handleNestedCode(func_code, code, codeSource):
+    nested = not (codeSource.main or codeSource.in_class)
+    if func_code.co_name == utils.LAMBDA or nested:
+        utils.debug(' handling nested code')
+        varnames = None
+        if nested and func_code.co_name != utils.LAMBDA:
+            varnames = func_code.co_varnames + \
+                     codeSource.calling_code[-1].function.func_code.co_varnames
+        # save the original return value and restore after checking
+        returnValues = code.returnValues
+        code.init(function.create_fake(func_code.co_name, func_code, {},
+                                       varnames))
+        _checkCode(code, codeSource)
+        code.returnValues = returnValues
+
+def _findUnreachableCode(code) :
+    # code after RETURN or RAISE is unreachable unless there's a branch to it
+    unreachable = {}
+    terminals = code.returnValues[:-1] + code.raiseValues
+    terminals.sort(lambda a, b: cmp(a[2], b[2]))
+    for line, dummy, i in terminals :
+        if not code.branches.has_key(i) :
+            unreachable[i] = line
+
+    # find the index of the last return
+    lastLine = lastItem = lastIndex = None
+    if code.returnValues:
+        lastLine, lastItem, lastIndex = code.returnValues[-1]
+    if len(code.returnValues) >= 2 :
+        lastIndex = code.returnValues[-2][2]
+    if code.raiseValues :
+        lastIndex = max(lastIndex, code.raiseValues[-1][2])
+
+    # remove last return if it's unreachable AND implicit
+    if unreachable.get(lastIndex) == lastLine and lastItem and \
+           lastItem.isImplicitNone():
+        del code.returnValues[-1]
+        del unreachable[lastIndex]
+
+    if cfg().unreachableCode :
+        for index in unreachable.keys() :
+            try :
+                if not OP.JUMP_FORWARD(ord(code.bytes[index])) :
+                    code.addWarning(msgs.CODE_UNREACHABLE, unreachable[index])
+            except IndexError :
+                pass
+
+
+def _checkFunction(module, func, c = None, main = 0, in_class = 0) :
+    "Return a list of Warnings found in a function/method."
+
+    # always push a new config object, so we can pop at end of function
+    utils.pushConfig()
+
+    code = CodeChecks.Code()
+    code.init(func)
+    if main:
+        for key in func.function.func_globals.keys():
+            code.unusedLocals[key] = -1
+    codeSource = CodeChecks.CodeSource(module, func, c, main, in_class, code)
+    try :
+        _checkCode(code, codeSource)
+        if not in_class :
+            _findUnreachableCode(code)
+
+        # handle lambdas and nested functions
+        codeSource.calling_code.append(func)
+        for func_code in code.codeObjects.values() :
+            _handleNestedCode(func_code, code, codeSource)
+        del codeSource.calling_code[-1]
+
+    except (SystemExit, KeyboardInterrupt) :
+        exc_type, exc_value, exc_tb = sys.exc_info()
+        raise exc_type, exc_value
+    except :
+        exc_type, exc_value, exc_tb = sys.exc_info()
+        exc_list = traceback.format_exception(exc_type, exc_value, exc_tb)
+        for index in range(0, len(exc_list)) :
+            exc_list[index] = string.replace(exc_list[index], "\n", "\n\t")
+        code.addWarning(msgs.CHECKER_BROKEN % string.join(exc_list, ""))
+
+    if cfg().checkReturnValues :
+        _checkReturnWarnings(code)
+
+    if cfg().localVariablesUsed :
+        for var, line in code.unusedLocals.items() :
+            if line is not None and line > 0 and _name_unused(var) :
+                code.addWarning(msgs.UNUSED_LOCAL % var, line)
+
+    if cfg().argumentsUsed :
+        op = code.getFirstOp()
+        if not (OP.RAISE_VARARGS(op) or OP.RETURN_VALUE(op)) :
+            for var, line in code.unusedLocals.items() :
+                _checkUnusedParam(var, line, func, code)
+
+    # Check code complexity:
+    #   loops should be counted as one branch, but there are typically 3
+    #   branches in byte code to setup a loop, so subtract off 2/3's of them
+    #    / 2 to approximate real branches
+    branches = (len(code.branches.keys()) - (2 * code.loops)) / 2
+    lines = (code.getLineNum() - code.func_code.co_firstlineno)
+    returns = len(code.returnValues)
+    if not main and not in_class :
+        args = code.func_code.co_argcount
+        locals = len(code.func_code.co_varnames) - args
+        _checkComplex(code, cfg().maxArgs, args, func, msgs.TOO_MANY_ARGS)
+        _checkComplex(code, cfg().maxLocals, locals, func, msgs.TOO_MANY_LOCALS)
+        _checkComplex(code, cfg().maxLines, lines, func, msgs.FUNC_TOO_LONG)
+    _checkComplex(code, cfg().maxReturns, returns, func, msgs.TOO_MANY_RETURNS)
+    _checkComplex(code, cfg().maxBranches, branches, func, msgs.TOO_MANY_BRANCHES)
+
+    if not (main or in_class) :
+        utils.popConfig()
+    func.returnValues = code.returnValues
+    return (code.warnings, code.globalRefs, code.functionsCalled,
+            code.codeObjects.values(), code.returnValues)
+
+
+def _getUnused(module, globalRefs, dict, msg, filterPrefix = None) :
+    "Return a list of warnings for unused globals"
+
+    warnings = []
+    for ref in dict.keys() :
+        check = not filterPrefix or utils.startswith(ref, filterPrefix)
+        if check and globalRefs.get(ref) == None :
+            lineInfo = module.moduleLineNums.get(ref)
+            if lineInfo:
+                warnings.append(Warning(lineInfo[0], lineInfo[1], msg % ref))
+    return warnings
+
+
+def _get_func_info(method) :
+    try:
+        fc = getattr(method.im_func, 'func_code', None)
+        if fc is not None :
+            return fc.co_filename, fc.co_firstlineno
+    except AttributeError:
+        # if the object derives from any object in 2.2,
+        # the builtin methods are wrapper_descriptors and
+        # have no im_func attr
+        pass
+    return None, None
+
+_DOT_INIT = '.' + utils.INIT
+
+def _baseInitCalled(classInitInfo, base, functionsCalled) :
+    baseInit = getattr(base, utils.INIT, None)
+    if baseInit is None or _get_func_info(baseInit) == classInitInfo :
+        return 1
+
+    initName = utils.safestr(base) + _DOT_INIT
+    if functionsCalled.has_key(initName) :
+        return 1
+
+    # ok, do this the hard way, there may be aliases, so check here
+    names = string.split(initName, '.')
+
+    # first look in our list of PyCheckerModules
+    moduleName = names[0]
+    moduleDir = os.path.dirname(classInitInfo[0])
+    pcmodule = pcmodules.getPCModule(moduleName, moduleDir)
+    if pcmodule:
+        obj = pcmodule.module
+    else:
+        # fall back to looking in sys.modules
+        try:
+            # i think this can raise an exception if the module is a library
+            # (.so)
+            obj = sys.modules[names[0]]
+        except KeyError:
+            return 1
+    for i in range(1, len(names)) :
+        obj = getattr(obj, names[i], None)
+        if obj is None:
+            return 0
+        if functionsCalled.has_key(string.join(names[i:], '.')) :
+            return 1
+
+    return 0
+
+def _checkBaseClassInit(moduleFilename, c, func_code, funcInfo) :
+    """Return a list of warnings that occur
+       for each base class whose __init__() is not called"""
+
+    warnings = []
+    functionsCalled, _, returnValues = funcInfo
+    for line, stackItem, dummy in returnValues :
+        if stackItem.data != None :
+            if not stackItem.isNone() or cfg().returnNoneFromInit :
+                warn = Warning(func_code, line, msgs.RETURN_FROM_INIT)
+                warnings.append(warn)
+
+    classInit = getattr(c.classObject, utils.INIT, None)
+    if cfg().baseClassInitted and classInit is not None :
+        classInitInfo = _get_func_info(classInit)
+        for base in getattr(c.classObject, '__bases__', None) or ():
+            if not _baseInitCalled(classInitInfo, base, functionsCalled):
+                warn = Warning(moduleFilename, func_code,
+                               msgs.BASE_CLASS_NOT_INIT % utils.safestr(base))
+                warnings.append(warn)
+    return warnings
+
+
+def _checkOverridenMethods(func, baseClasses, warnings) :
+    for baseClass in baseClasses :
+        if func.func_name != utils.INIT and \
+           not function.same_signature(func, baseClass) :
+            err = msgs.METHOD_SIGNATURE_MISMATCH % (func.func_name, utils.safestr(baseClass))
+            warnings.append(Warning(func.func_code, func.func_code, err))
+            break
+
+
+def _updateFunctionWarnings(module, func, c, warnings, globalRefs,
+                            main = 0, in_class = 0) :
+    "Update function warnings and global references"
+
+    newWarnings, newGlobalRefs, funcs, codeObjects, returnValues = \
+                 _checkFunction(module, func, c, main, in_class)
+    warnings.extend(newWarnings)
+    globalRefs.update(newGlobalRefs)
+
+    return funcs, codeObjects, returnValues
+
+
+def getBlackList(moduleList) :
+    blacklist = []
+    for badBoy in moduleList :
+        if badBoy[-3:] == ".py":
+            badBoy = badBoy[0:-3]
+        try :
+            file, path, flags = imp.find_module(badBoy)
+            if file :
+                file.close()
+            # apparently, imp.find_module can return None, path, (triple)
+            # This happened to me with twisted 2.2.0 in a separate path
+            if path:
+                blacklist.append(normalize_path(path))
+        except ImportError :
+            pass
+    return blacklist
+
+def getStandardLibraries() :
+    """
+    Return a list of standard libraries.
+
+    @rtype: list of str or None
+    """
+    if cfg().ignoreStandardLibrary :
+        try :
+            from distutils import sysconfig
+
+            std_libs = [
+                sysconfig.get_python_lib(plat_specific=0),
+                sysconfig.get_python_lib(plat_specific=1)
+            ]
+            ret = []
+            for std_lib in std_libs:
+                path = os.path.split(std_lib)
+                if path[1] == 'site-packages' :
+                    ret.append(path[0])
+            return ret
+        except ImportError :
+            return None
+
+def normalize_path(path):
+    return os.path.normpath(os.path.normcase(path))
+
+def removeWarnings(warnings, blacklist, std_lib, cfg):
+    """
+    @param blacklist: list of absolute paths not to warn for
+    @type  blacklist: str
+    @param std_lib:   list of standard library directories
+    @type  std_lib:   list of str or None
+    """
+    if std_lib is not None:
+        std_lib = [normalize_path(p) for p in std_lib]
+    for index in range(len(warnings)-1, -1, -1) :
+        filename = normalize_path(warnings[index].file)
+        # the blacklist contains paths to packages and modules we do not
+        # want warnings for
+        # when we find a match, make sure we continue the warnings for loop
+        found = False
+        for path in blacklist:
+            if not found and filename.startswith(path):
+                found = True
+                del warnings[index]
+        if found:
+            continue
+        if std_lib:
+            found = False
+            for path in std_lib:
+                if not found and utils.startswith(filename, path) :
+                    found = True
+                    del warnings[index]
+            if found:
+                continue
+        elif cfg.only:
+            # ignore files not specified on the cmd line if requested
+            if os.path.abspath(filename) not in cfg.files:
+                del warnings[index]
+                continue
+
+        # filter by warning/error level if requested
+        if cfg.level and warnings[index].level < cfg.level:
+            del warnings[index]
+
+    if cfg.limit:
+        # sort by severity first, then normal sort (by file/line)
+        warnings.sort(lambda a, b: cmp(a.level, b.level) or cmp(a, b))
+
+        # strip duplicates
+        lastWarning = None
+        for index in range(len(warnings)-1, -1, -1):
+            warning = warnings[index]
+
+            # remove duplicate warnings
+            if lastWarning is not None and cmp(lastWarning, warning) == 0:
+                del warnings[index]
+            else:
+                lastWarning = warning
+
+        num_ignored = len(warnings) - cfg.limit
+        if num_ignored > 0:
+            del warnings[:-cfg.limit]
+            msg = msgs.TOO_MANY_WARNINGS % num_ignored
+            warnings.append(Warning('', 0, msg))
+
+    return warnings
+
+
+class _SuppressionError(Exception) :
+    pass
+
+def _updateSuppressions(suppress, warnings) :
+    if not utils.updateCheckerArgs(suppress, 'suppressions', 0, warnings) :
+        utils.popConfig()
+        raise _SuppressionError
+
+_CLASS_NAME_RE = re.compile("<class '([A-Za-z0-9.]+)'>(\\..+)?")
+
+def getSuppression(name, suppressions, warnings) :
+    try :
+        utils.pushConfig()
+
+        # cheesy hack to deal with new-style classes.  i don't see a
+        # better way to get the name, '<' is an invalid identifier, so
+        # we can reliably check it and extract name from:
+        # <class 'class-name'>[.identifier[.identifier]...]
+        matches = _CLASS_NAME_RE.match(name)
+        if matches:
+            # pull out the names and make a complete identifier (ignore None)
+            name = string.join(filter(None, matches.groups()), '')
+
+        suppress = suppressions[0].get(name, None)
+        if suppress is not None :
+            _updateSuppressions(suppress, warnings)
+
+        regexList = suppressions[1].keys()
+        regexList.sort()
+        for regex in regexList :
+            match = regex.match(name)
+            if match and match.group() == name :
+                suppress = 1
+                _updateSuppressions(suppressions[1][regex], warnings)
+
+        if not suppress :
+            utils.popConfig()
+
+        return suppress
+    except _SuppressionError :
+        return None
+
+def _findFunctionWarnings(module, globalRefs, warnings, suppressions) :
+    for func in module.functions.values() :
+        func_code = func.function.func_code
+        utils.debug("function:", func_code)
+
+        name = '%s.%s' % (module.moduleName, func.function.__name__)
+        suppress = getSuppression(name, suppressions, warnings)
+        if cfg().noDocFunc and func.function.__doc__ == None :
+            err = msgs.NO_FUNC_DOC % func.function.__name__
+            warnings.append(Warning(module.filename(), func_code, err))
+
+        _checkNoSelfArg(func, warnings)
+        _updateFunctionWarnings(module, func, None, warnings, globalRefs)
+        if suppress is not None :
+            utils.popConfig()
+
+def _getModuleFromFilename(module, filename):
+    if module.filename() != filename:
+        for m in module.modules.values():
+            if m.filename() == filename:
+                return m
+    return module
+
+# Create object for non-2.2 interpreters, any class object will do
+try:
+    if object: pass
+except NameError:
+    object = _SuppressionError
+
+# Create property for pre-2.2 interpreters
+try :
+    if property: pass
+except NameError:
+    property = None
+
+def _findClassWarnings(module, c, class_code,
+                       globalRefs, warnings, suppressions) :
+    try:
+        className = utils.safestr(c.classObject)
+    except TypeError:
+        # goofy __getattr__
+        return
+    classSuppress = getSuppression(className, suppressions, warnings)
+    baseClasses = c.allBaseClasses()
+    for base in baseClasses :
+        baseModule = utils.safestr(base)
+        if '.' in baseModule :
+            # make sure we handle import x.y.z
+            packages = string.split(baseModule, '.')
+            baseModuleDir = string.join(packages[:-1], '.')
+            globalRefs[baseModuleDir] = baseModule
+
+    # handle class variables
+    if class_code is not None :
+        func = function.create_fake(c.name, class_code)
+        _updateFunctionWarnings(module, func, c, warnings, globalRefs, 0, 1)
+
+    filename = module.filename()
+    func_code = None
+    for method in c.methods.values() :
+        if method == None :
+            continue
+        func_code = method.function.func_code
+        utils.debug("method:", func_code)
+
+        try:
+            name = utils.safestr(c.classObject) + '.' + method.function.func_name
+        except AttributeError:
+            # func_name may not exist
+            continue
+        methodSuppress = getSuppression(name, suppressions, warnings)
+
+        if cfg().checkSpecialMethods:
+            funcname = method.function.func_name
+            if funcname[:2] == '__' == funcname[-2:] and \
+               funcname != '__init__':
+                err = None
+                argCount = python.SPECIAL_METHODS.get(funcname, -1)
+                if argCount != -1:
+                    # if the args are None, it can be any # of args
+                    if argCount is not None:
+                        minArgs = maxArgs = argCount
+                        err = CodeChecks.getFunctionArgErr(funcname,
+                                     func_code.co_argcount, minArgs, maxArgs)
+                else:
+                    err = msgs.NOT_SPECIAL_METHOD % funcname
+
+                if err is not None:
+                    warnings.append(Warning(filename, func_code, err))
+                
+        if cfg().checkOverridenMethods :
+            _checkOverridenMethods(method.function, baseClasses, warnings)
+
+        if cfg().noDocFunc and method.function.__doc__ == None :
+            err = msgs.NO_FUNC_DOC % method.function.__name__
+            warnings.append(Warning(filename, func_code, err))
+
+        _checkSelfArg(method, warnings)
+        tmpModule = _getModuleFromFilename(module, func_code.co_filename)
+        funcInfo = _updateFunctionWarnings(tmpModule, method, c, warnings, globalRefs)
+        if func_code.co_name == utils.INIT :
+            if utils.INIT in dir(c.classObject) :
+                warns = _checkBaseClassInit(filename, c, func_code, funcInfo)
+                warnings.extend(warns)
+            elif cfg().initDefinedInSubclass :
+                err = msgs.NO_INIT_IN_SUBCLASS % c.name
+                warnings.append(Warning(filename, c.getFirstLine(), err))
+        if methodSuppress is not None :
+            utils.popConfig()
+
+    if c.memberRefs and cfg().membersUsed :
+        memberList = c.memberRefs.keys()
+        memberList.sort()
+        err = msgs.UNUSED_MEMBERS % (string.join(memberList, ', '), c.name)
+        warnings.append(Warning(filename, c.getFirstLine(), err))
+
+    try:
+        newStyleClass = issubclass(c.classObject, object)
+    except TypeError:
+        # FIXME: perhaps this should warn b/c it may be a class???
+        newStyleClass = 0
+
+    slots = c.statics.get('__slots__')
+    if slots is not None and cfg().slots:
+        lineNum = c.lineNums['__slots__']
+        if not newStyleClass:
+            err = msgs.USING_SLOTS_IN_CLASSIC_CLASS % c.name
+            warnings.append(Warning(filename, lineNum, err))
+        elif cfg().emptySlots:
+            try:
+                if len(slots.data) == 0:
+                    err = msgs.EMPTY_SLOTS % c.name
+                    warnings.append(Warning(filename, lineNum, err))
+            except AttributeError:
+                # happens when slots is an instance of a class w/o __len__
+                pass
+
+    if not newStyleClass and property is not None and cfg().classicProperties:
+        for static in c.statics.keys():
+            if type(getattr(c.classObject, static, None)) == property:
+                err = msgs.USING_PROPERTIES_IN_CLASSIC_CLASS % (static, c.name)
+                warnings.append(Warning(filename, c.lineNums[static], err))
+
+    coerceMethod = c.methods.get('__coerce__')
+    if newStyleClass and coerceMethod:
+        lineNum = coerceMethod.function.func_code.co_firstlineno
+        err = msgs.USING_COERCE_IN_NEW_CLASS % c.name
+        warnings.append(Warning(filename, lineNum, err))
+
+    for newClassMethodName in python.NEW_STYLE_CLASS_METHODS:
+        newClassMethod = c.methods.get(newClassMethodName)
+        if not newStyleClass and newClassMethod:
+            lineNum = newClassMethod.function.func_code.co_firstlineno
+            err = msgs.USING_NEW_STYLE_METHOD_IN_OLD_CLASS % (newClassMethodName, c.name)
+            warnings.append(Warning(filename, lineNum, err))
+
+    if cfg().noDocClass and c.classObject.__doc__ == None :
+        method = c.methods.get(utils.INIT, None)
+        if method != None :
+            func_code = method.function.func_code
+        # FIXME: check to make sure this is in our file,
+        #        not a base class file???
+        err = msgs.NO_CLASS_DOC % c.classObject.__name__
+        warnings.append(Warning(filename, func_code, err))
+
+    # we have to do this here, b/c checkFunction doesn't popConfig for classes
+    # this allows us to have __pychecker__ apply to all methods
+    # when defined at class scope
+    if class_code is not None :
+        utils.popConfig()
+
+    if classSuppress is not None :
+        utils.popConfig()
+
+
+def find(moduleList, initialCfg, suppressions = None) :
+    "Return a list of warnings found in the module list"
+
+    if suppressions is None :
+        suppressions = {}, {}
+
+    utils.initConfig(initialCfg)
+
+    warnings = []
+    for module in moduleList :
+        if module.moduleName in cfg().blacklist :
+            continue
+
+        modSuppress = getSuppression(module.moduleName, suppressions, warnings)
+        globalRefs, classCodes = {}, {}
+
+        # main_code can be null if there was a syntax error
+        if module.main_code != None :
+            funcInfo = _updateFunctionWarnings(module, module.main_code,
+                                               None, warnings, globalRefs, 1)
+            for code in funcInfo[1] :
+                classCodes[code.co_name] = code
+
+        _findFunctionWarnings(module, globalRefs, warnings, suppressions)
+
+        for c in module.classes.values() :
+            _findClassWarnings(module, c, classCodes.get(c.name),
+                               globalRefs, warnings, suppressions)
+
+        if cfg().noDocModule and \
+           module.module != None and module.module.__doc__ == None :
+            warnings.append(Warning(module.filename(), 1, msgs.NO_MODULE_DOC))
+
+        if cfg().allVariablesUsed or cfg().privateVariableUsed :
+            prefix = None
+            if not cfg().allVariablesUsed :
+                prefix = "_"
+            for ignoreVar in cfg().variablesToIgnore + cfg().unusedNames :
+                globalRefs[ignoreVar] = ignoreVar
+            warnings.extend(_getUnused(module, globalRefs, module.variables,
+                                       msgs.VAR_NOT_USED, prefix))
+        if cfg().importUsed :
+            if module.moduleName != utils.INIT or cfg().packageImportUsed :
+                # always ignore readline module, if [raw_]input() is used
+                if globalRefs.has_key('input') or \
+                   globalRefs.has_key('raw_input'):
+                    globalRefs['readline'] = 0
+                warnings.extend(_getUnused(module, globalRefs, module.modules,
+                                           msgs.IMPORT_NOT_USED))
+
+        if module.main_code != None :
+            utils.popConfig()
+        if modSuppress is not None :
+            utils.popConfig()
+
+    std_lib = None
+    if cfg().ignoreStandardLibrary :
+        std_lib = getStandardLibraries()
+    return removeWarnings(warnings, getBlackList(cfg().blacklist), std_lib,
+                          cfg())
+
+if 0:
+    # if you want to test w/psyco, include this
+    import psyco
+    psyco.bind(_checkCode)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/Check.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/Check.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/Check.py
new file mode 100644
index 0000000..0cc5776
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/Check.py
@@ -0,0 +1,96 @@
+
+from pychecker2.Warning import Warning
+from pychecker2.File import File
+from pychecker2 import Options
+
+import time
+import os
+import stat
+
+class WarningOpt(Options.BoolOpt):
+    __pychecker__ = 'no-callinit'
+    
+    def __init__(self, longName, warning):
+        self.warning = warning
+        self.longName = longName
+        self.default = warning.value
+
+    def set_value(self, unused):
+        self.warning.value = not self.warning.value
+        
+    def get_value(self):
+        return self.warning.value
+
+    def get_description(self):
+        return self.warning.description
+
+    def reset(self):
+        self.warning.value = self.default
+
+class CheckList:
+
+    def __init__(self, checks):
+        self.checks = checks
+        self.modules = {}
+
+    def check_file(self, f):
+        for c in self.checks:
+            c.check(f, self)
+
+    def check_module(self, m):
+        f = None
+        try:
+            f = self.modules[m]
+        except KeyError:
+            import inspect
+            try:
+                fname = inspect.getsourcefile(m)
+                if fname:
+                    f = File(fname)
+            except TypeError:
+                pass
+            self.modules[m] = f
+            if f:
+                self.check_file(f)
+        return f
+
+    def __getstate__(self):
+        modules = []
+        for k, v in self.modules.items():
+            modules.append( (k.__name__, v) )
+        return (time.time(), self.checks, modules)
+
+    def __setstate__(self, data):
+        import inspect
+        cache_time, self.checks, modules = data
+        self.modules = {}
+        for k, v in modules:
+            module = __import__(k, globals(), {}, [''])
+            # Don't recover files that are newer than the save time
+            try:
+                fname = inspect.getsourcefile(module)
+                last_modified = os.stat(fname)[stat.ST_MTIME]
+            except TypeError:
+                last_modified = 0
+
+            if last_modified < cache_time:
+                self.modules[module] = v
+                
+class Check:
+
+    def __str__(self):
+        return self.__class__.__name__
+
+    def get_warnings(self, options):
+        for attr in vars(self.__class__):
+            object = getattr(self, attr)
+            if isinstance(object, Warning):
+                options.add(WarningOpt(attr, object))
+    
+    def get_options(self, options):
+        pass
+    
+    def check(self, file, checker):
+        pass
+
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/ClassChecks.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/ClassChecks.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/ClassChecks.py
new file mode 100644
index 0000000..4870094
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/ClassChecks.py
@@ -0,0 +1,364 @@
+from pychecker2.Check import Check
+from pychecker2.Check import Warning
+from pychecker2 import symbols
+from pychecker2.util import *
+
+from compiler.misc import mangle
+from compiler import ast, walk
+
+_ignorable = {}
+for ignore in ['repr', 'dict', 'class', 'doc', 'str']:
+    _ignorable['__%s__' % ignore] = 1
+
+class GetDefs(BaseVisitor):
+    "Record definitions of a attribute of self, who's name is provided"
+    def __init__(self, name):
+        self.selfname = name
+        self.result = {}
+
+    def visitAssAttr(self, node):
+        if isinstance(node.expr, ast.Name) and \
+           node.expr.name == self.selfname and \
+           isinstance(node.parent, (ast.Assign, ast.AssTuple)):
+            self.result[node.attrname] = node
+
+    def visitClass(self, node):         # ignore nested classes
+        pass
+
+class GetRefs(BaseVisitor):
+    "Record references to a attribute of self, who's name is provided"
+    def __init__(self, name):
+        self.selfname = name
+        self.result = {}
+
+    def visitAssAttr(self, node):
+        if isinstance(node.expr, ast.Name) and \
+           node.expr.name == self.selfname and \
+           not isinstance(node.parent, (ast.Assign, ast.AssTuple)):
+            self.result[node.attrname] = node
+        self.visitChildren(node)
+
+    def visitGetattr(self, node):
+        if isinstance(node.expr, ast.Name) and \
+           node.expr.name == self.selfname:
+            self.result[node.attrname] = node
+        self.visitChildren(node)
+
+    def visitClass(self, node):         # ignore nested classes
+        pass
+
+
+def _get_methods(class_scope):
+    return type_filter(class_scope.get_children(), symbols.FunctionScope)
+
+class NotSimpleName(Exception): pass
+
+# compress Getattr(Getattr(Name(x), y), z) -> "x.y.z"
+def get_name(node):
+    if isinstance(node, ast.Getattr):
+        return get_name(node.expr) + (node.attrname, )
+    elif isinstance(node, ast.Name):
+        return (node.name,)
+    else:
+        raise NotSimpleName
+
+def get_base_names(scope):
+    names = []
+    for b in scope.node.bases:
+        try:
+            names.append(get_name(b))
+        except NotSimpleName:       # FIXME: hiding expressions
+            pass
+    return names
+
+def find_in_module(package, remotename, names, checker):
+    # No other names, must be a name from the module
+    if not names:
+        f = checker.check_module(package)
+        if f:
+            return find_scope_going_down(f.root_scope, [remotename], checker)
+        return None
+
+    # complex name lookup
+    try:
+        #  first, get the real name of the package
+        name = package.__name__
+        module = __import__(name, globals(), {}, [''])
+    except AttributeError:
+        #  ok, so its a fake module... go with that
+        module = package
+    if remotename:
+        name += "." + remotename
+    #  now import it, and chase down any other modules
+    submodule = getattr(module, names[0], None)
+    if type(submodule) == type(symbols):
+        return find_in_module(submodule, None, names[1:], checker)
+
+    #  object in the module is not another module, so chase down the source
+    f = checker.check_module(submodule)
+    if f:
+        return find_scope_going_down(f.root_scope, names, checker)
+    return None
+                 
+def find_scope_going_down(scope, names, checker):
+    "Drill down scopes to find definition of x.y.z"
+    for c in scope.get_children():
+        if getattr(c, 'name', '') == names[0]:
+            if len(names) == 1:
+                return c
+            return find_scope_going_down(c, names[1:], checker)
+    # Not defined here, check for import
+    return find_imported_class(scope.imports, names, checker)
+
+def find_imported_class(imports, names, checker):
+    # may be defined by import
+    for i in range(1, len(names) + 1):
+        # try x, then x.y, then x.y.z as imported names
+        try:
+            name = ".".join(names[:i])
+            ref = imports[name]
+            # now look for the rest of the name
+            result = find_in_module(ref.module, ref.remotename, names[i:], checker)
+            if result:
+                return result
+        except (KeyError, ImportError):
+            pass
+    return None
+
+def find_scope_going_up(scope, names, checker):
+    "Search up to find scope defining x of x.y.z"
+    for p in parents(scope):
+        if p.defs.has_key(names[0]):
+            return find_scope_going_down(p, names, checker)
+    # name imported via 'from module import *'
+    try:
+        return find_in_module(p.imports[names[0]].module, None, names, checker)
+    except KeyError:
+        return None
+
+def get_base_classes(scope, checker):
+    result = []
+    for name in get_base_names(scope):
+        base = find_scope_going_up(scope, name, checker)
+        if base:
+            result.append(base)
+            result.extend(get_base_classes(base, checker))
+    return result
+
+def conformsTo(a, b):
+    alen = len(a.node.argnames)
+    blen = len(b.node.argnames)
+    # f(a, *args, **kw) conforms to f(a, b, *args, **kw)
+    # f(a, *args) conforms to f(a, b, *args)
+    # f(a, *args) conforms to f(a, b, c)
+    # f(a, b, c, *args) does not conform to f(a, b)
+    if alen == blen:
+        if a.node.kwargs == b.node.kwargs and a.node.varargs == b.node.varargs:
+            return 1
+    if a.node.varargs and alen - 1 <= blen:
+        return a.node.kwargs == b.node.kwargs
+    return None
+
+class AttributeCheck(Check):
+    "check `self.attr' expressions for attr"
+
+    unknownAttribute = Warning('Report unknown object attributes in methods',
+                           'Class %s has no attribute %s')
+    unusedAttribute = Warning('Report attributes unused in methods',
+                              'Attribute %s is not used in class %s')
+    methodRedefined = Warning('Report the redefinition of class methods',
+                              'Method %s in class %s redefined')
+    signatureChanged = Warning('Report methods whose signatures do not '
+                               'match base class methods',
+                               'Signature does not match method '
+                               '%s in base class %s')
+    attributeInitialized = \
+                 Warning('Report attributes not initialized in __init__',
+                         'Attribute %s is not initialized in __init__')
+                                   
+    def check(self, file, checker):
+        def visit_with_self(Visitor, method):
+            if not method.node.argnames:
+                return {}
+            return walk(method.node, Visitor(method.node.argnames[0])).result
+
+        # for all class scopes
+        for node, scope in file.class_scopes():
+            init_attributes = None      # attributes initilized in __init__
+            attributes = {}             # "self.foo = " kinda things
+            methods = {}                # methods -> scopes
+            
+            # get attributes defined on self
+            for m in _get_methods(scope):
+                defs = visit_with_self(GetDefs, m)
+                if m.name == '__init__':
+                    init_attributes = defs
+                attributes.update(defs)
+                methods[mangle(m.name, scope.name)] = m
+
+            # complain about attributes not initialized in __init__
+            if init_attributes is not None:
+                for name, node in dict_minus(attributes, init_attributes).items():
+                    file.warning(node, self.attributeInitialized, name)
+
+            # collect inherited gunk: methods and attributes
+            # check for non-conformant methods
+            inherited_methods = scope.defs.copy()
+            inherited_attributes = attributes.copy()
+            for base in get_base_classes(scope, checker):
+                for m in _get_methods(base):
+                    inherited_attributes.update(visit_with_self(GetDefs, m))
+                    mname = mangle(m.name, base.name)
+                    if m.name != "__init__" and \
+                       methods.has_key(mname) and \
+                       not conformsTo(methods[mname], m):
+                        file.warning(methods[mname].node,
+                                     self.signatureChanged, m.name, base.name)
+                    else:
+                        methods[mname] = m
+                inherited_methods.update(base.defs)
+
+            # complain about attributes with the same name as methods
+            both = dict_intersect(attributes, inherited_methods)
+            for name, node in both.items():
+                file.warning(node, self.methodRedefined, name, scope.name)
+
+            # find refs on self
+            refs = {}
+            for m in _get_methods(scope):
+                refs.update(visit_with_self(GetRefs, m))
+
+            # Now complain about refs on self that aren't known
+            unknown = dict_minus(refs, inherited_methods)
+            unknown = dict_minus(unknown, _ignorable)
+            unknown = dict_minus(unknown, scope.defs)
+            unknown = dict_minus(unknown, inherited_attributes)
+            for name, node in unknown.items():
+                file.warning(node, self.unknownAttribute, scope.name, name)
+
+            unused = dict_minus(attributes, refs)
+            for name, node in unused.items():
+                if name.startswith('__'):
+                    file.warning(node, self.unusedAttribute, name, scope.name)
+
+class GetReturns(BaseVisitor):
+
+    def __init__(self):
+        self.result = []
+
+    def visitReturn(self, node):
+        self.result.append(node)
+
+    def visitFunction(self, node): pass
+    visitClass = visitFunction
+
+class InitCheck(Check):
+
+    initReturnsValue = Warning('Report value returned from __init__',
+                               'Method __init__ should not return a value')
+
+    def check(self, file, unused_checker):
+
+        for node, scope in file.class_scopes():
+            for m in _get_methods(scope):
+                if m.name == '__init__':
+                    for r in walk(m.node.code, GetReturns()).result:
+                        if isinstance(r.value, ast.Const) and \
+                           r.value.value is None:
+                            continue
+                        if isinstance(r.value, ast.Name) and \
+                           r.value.name == 'None':
+                            continue
+                        file.warning(r, self.initReturnsValue)
+
+                            
+
+special = {
+    '__cmp__': 2,     '__del__': 1,     '__delitem__': 2, '__eq__': 2,
+    '__ge__': 2,      '__getitem__': 2, '__gt__': 2,      '__hash__': 1,
+    '__le__': 2,      '__len__': 1,     '__lt__': 2,      '__ne__': 2,
+    '__nonzero__': 1, '__repr__': 1,    '__setitem__': 3, '__str__': 1,
+    '__getattr__': 2, '__setattr__': 3,
+    '__delattr__': 2, '__len__': 1,     '__delitem__': 2, '__iter__': 1,
+    '__contains__': 2,'__setslice__': 4,'__delslice__': 3,
+    '__add__': 2,     '__sub__': 2,     '__mul__': 2,     '__floordiv__': 2,
+    '__mod__': 2,     '__divmod__': 2,  '__lshift__': 2,
+    '__rshift__': 2,  '__and__': 2,     '__xor__': 2,     '__or__': 2,
+    '__div__': 2,     '__truediv__': 2, '__radd__': 2,    '__rsub__': 2,
+    '__rmul__': 2,    '__rdiv__': 2,    '__rmod__': 2,    '__rdivmod__': 2,
+    '__rpow__': 2,    '__rlshift__': 2, '__rrshift__': 2, '__rand__': 2,
+    '__rxor__': 2,    '__ror__': 2,     '__iadd__': 2,    '__isub__': 2,
+    '__imul__': 2,    '__idiv__': 2,    '__imod__': 2,    '__ilshift__': 2,
+    '__irshift__': 2, '__iand__': 2,    '__ixor__': 2,    '__ior__': 2,
+    '__neg__': 1,     '__pos__': 1,     '__abs__': 1,     '__invert__': 1,
+    '__complex__': 1, '__int__': 1,     '__long__': 1,    '__float__': 1,
+    '__oct__': 1,     '__hex__': 1,     '__coerce__': 2,
+    '__new__': None,
+    '__getinitargs__': 1, '__reduce__': 1,
+    '__getstate__': 1,'__setstate__': 2,
+    '__copy__': 1,    '__deepcopy__': 1,
+    '__pow__': 2,     '__ipow__': 2,    # 2 or 3
+    '__call__': None,                   # any number > 1
+    '__getslice__': 3,                  # deprecated
+    '__getattribute__': 2,
+    }
+
+def check_special(scope):
+    try:
+        count = special[scope.name]
+        max_args = len(scope.node.argnames)
+        min_args = max_args - len(scope.node.defaults)
+        if min_args > count or max_args < count or \
+           scope.node.varargs or scope.node.kwargs:
+            return special[scope.name]
+    except KeyError:
+        pass
+    return None
+
+class SpecialCheck(Check):
+
+    specialMethod = Warning('Report special methods with incorrect '
+                            'number of arguments',
+                            'The %s method requires %d argument%s, '
+                            'including self')
+
+    notSpecial = Warning('Report methods with "__" prefix and suffix '
+                         'which are not defined as special methods',
+                         'The method %s is not a special method, '
+                         'but is reserved.')
+
+    def check(self, file, unused_checker):
+
+        for node, scope in file.class_scopes():
+            for m in _get_methods(scope):
+                n = check_special(m)
+                if n:
+                    file.warning(m.node, self.specialMethod, m.name, n,
+                                 n > 1 and "s" or "")
+                name = m.name
+                if name.startswith('__') and name.endswith('__') and \
+                   name != '__init__' and not special.has_key(name):
+                    file.warning(m.node, self.notSpecial, name)
+
+class BackQuote(BaseVisitor):
+
+    def __init__(self, selfname):
+        self.results = []
+        self.selfname = selfname
+
+    def visitBackquote(self, node):
+        if isinstance(node.expr, ast.Name) and node.expr.name == self.selfname:
+            self.results.append(node)
+
+class ReprCheck(Check):
+
+    backquoteSelf = Warning('Report use of `self` in __repr__ methods',
+                           'Using `self` in __repr__')
+    def check(self, file, unused_checker):
+        for node, scope in file.class_scopes():
+            for m in _get_methods(scope):
+                if m.name == '__repr__' and m.node.argnames:
+                    visitor = BackQuote(m.node.argnames[0])
+                    for n in walk(m.node.code, visitor).results:
+                        file.warning(n, self.backquoteSelf)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/ConditionalChecks.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/ConditionalChecks.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/ConditionalChecks.py
new file mode 100644
index 0000000..0271dfd
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/ConditionalChecks.py
@@ -0,0 +1,44 @@
+from pychecker2.Check import Check
+from pychecker2.util import BaseVisitor
+
+from compiler import ast, walk
+
+class ConstantFinder(BaseVisitor):
+
+    def __init__(self):
+        self.result = []
+
+    def visitConst(self, node):
+        if isinstance(node.parent, (ast.Or, ast.Not, ast.And)):
+            self.result.append((node, `node.value`))
+
+    def visitName(self, node):
+        if node.name == 'None':
+            if isinstance(node.parent, (ast.Or, ast.Not, ast.And)):
+                self.result.append((node, 'None'))
+
+class GetConditionalConstants(BaseVisitor):
+
+    def __init__(self):
+        self.result = []
+
+    def visitIf(self, node):
+        for test, code in node.tests:
+            self.result.extend(walk(test, ConstantFinder()).result)
+
+    def visitWhile(self, node):
+        self.result.extend(walk(node.test, ConstantFinder()).result)
+    visitListCompIf = visitWhile
+    visitAssert = visitWhile
+
+class ConstantCheck(Check):
+
+    constantInConditional = \
+                          Warning('Report constants used in conditionals',
+                                  'Constant used in conditional %s')
+
+    def check(self, file, unused_checker):
+        if file.parseTree:
+            v = GetConditionalConstants()
+            for n, value in walk(file.parseTree, v).result:
+                file.warning(n, self.constantInConditional, value)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/File.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/File.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/File.py
new file mode 100644
index 0000000..d277d31
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/File.py
@@ -0,0 +1,39 @@
+from pychecker2.util import parents
+
+from compiler import ast
+
+class File:
+    def __init__(self, name):
+        self.name = name
+        self.parseTree = None
+        self.scopes = {}
+        self.root_scope = None
+        self.warnings = []
+
+    def __cmp__(self, other):
+        return cmp(self.name, other.name)
+
+    def warning(self, line, warn, *args):
+        lineno = getattr(line, 'lineno', line)
+        if not lineno and hasattr(line, 'parent'):
+            for p in parents(line):
+                if p.lineno:
+                    lineno = p.lineno
+                    break
+        self.warnings.append( (lineno, warn, args) )
+
+    def scope_filter(self, type):
+        return [x for x in self.scopes.iteritems() if isinstance(x[0], type)]
+
+    def function_scopes(self):
+        return self.scope_filter(ast.Function)
+
+    def class_scopes(self):
+        return self.scope_filter(ast.Class)
+
+    def not_class_scopes(self):
+        result = []
+        for n, s in self.scopes.iteritems():
+            if not isinstance(n, ast.Class):
+                result.append( (n, s) )
+        return result


[07/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code

Posted by rl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test38
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test38 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test38
new file mode 100644
index 0000000..64142cc
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test38
@@ -0,0 +1,22 @@
+Processing module test38 (test_input/test38.py)...
+
+Warnings...
+
+test_input/test38.py:23: Overridden method (m1) doesn't match signature in class (test38.X)
+test_input/test38.py:24: Overridden method (m2) doesn't match signature in class (test38.X)
+test_input/test38.py:25: Overridden method (m3) doesn't match signature in class (test38.X)
+test_input/test38.py:26: Overridden method (m4) doesn't match signature in class (test38.X)
+test_input/test38.py:27: Overridden method (m5) doesn't match signature in class (test38.X)
+test_input/test38.py:28: Overridden method (m6) doesn't match signature in class (test38.X)
+test_input/test38.py:32: Overridden method (m3) doesn't match signature in class (test38.X)
+test_input/test38.py:33: Overridden method (m6) doesn't match signature in class (test38.X)
+test_input/test38.py:37: Overridden method (m3) doesn't match signature in class (test38.X)
+test_input/test38.py:38: Overridden method (m6) doesn't match signature in class (test38.X)
+test_input/test38.py:42: Overridden method (m1) doesn't match signature in class (test38.X)
+test_input/test38.py:43: Overridden method (m2) doesn't match signature in class (test38.X)
+test_input/test38.py:44: Overridden method (m3) doesn't match signature in class (test38.X)
+test_input/test38.py:45: Overridden method (m4) doesn't match signature in class (test38.X)
+test_input/test38.py:46: Overridden method (m5) doesn't match signature in class (test38.X)
+test_input/test38.py:47: Overridden method (m6) doesn't match signature in class (test38.X)
+test_input/test38.py:53: Using the exec statement
+test_input/test38.py:54: Using the exec statement in global namespace

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test39
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test39 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test39
new file mode 100644
index 0000000..4461f57
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test39
@@ -0,0 +1,14 @@
+Processing module test39 (test_input/test39.py)...
+
+Warnings...
+
+test_input/test39.py:3: No doc string for function func2
+test_input/test39.py:10: s is not first method argument
+test_input/test39.py:11: No doc string for class X2
+test_input/test39.py:14: No doc string for function a
+test_input/test39.py:19: No doc string for function a
+test_input/test39.py:29: No doc string for function x
+test_input/test39.py:31: No doc string for function y
+test_input/test39.py:33: No doc string for function z
+test_input/test39.py:33: Parameter (jjj) not used
+test_input/test39.py:34: Local variable (j) not used

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test39-2.2
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test39-2.2 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test39-2.2
new file mode 100644
index 0000000..9194236
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test39-2.2
@@ -0,0 +1,14 @@
+Processing module test39 (test_input/test39.py)...
+
+Warnings...
+
+test_input/test39.py:3: No doc string for function func2
+test_input/test39.py:10: No doc string for class X2
+test_input/test39.py:10: s is not first method argument
+test_input/test39.py:14: No doc string for function a
+test_input/test39.py:19: No doc string for function a
+test_input/test39.py:29: No doc string for function x
+test_input/test39.py:31: No doc string for function y
+test_input/test39.py:33: No doc string for function z
+test_input/test39.py:33: Parameter (jjj) not used
+test_input/test39.py:34: Local variable (j) not used

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test39-2.3
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test39-2.3 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test39-2.3
new file mode 100644
index 0000000..9194236
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test39-2.3
@@ -0,0 +1,14 @@
+Processing module test39 (test_input/test39.py)...
+
+Warnings...
+
+test_input/test39.py:3: No doc string for function func2
+test_input/test39.py:10: No doc string for class X2
+test_input/test39.py:10: s is not first method argument
+test_input/test39.py:14: No doc string for function a
+test_input/test39.py:19: No doc string for function a
+test_input/test39.py:29: No doc string for function x
+test_input/test39.py:31: No doc string for function y
+test_input/test39.py:33: No doc string for function z
+test_input/test39.py:33: Parameter (jjj) not used
+test_input/test39.py:34: Local variable (j) not used

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test39-2.4
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test39-2.4 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test39-2.4
new file mode 100644
index 0000000..9194236
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test39-2.4
@@ -0,0 +1,14 @@
+Processing module test39 (test_input/test39.py)...
+
+Warnings...
+
+test_input/test39.py:3: No doc string for function func2
+test_input/test39.py:10: No doc string for class X2
+test_input/test39.py:10: s is not first method argument
+test_input/test39.py:14: No doc string for function a
+test_input/test39.py:19: No doc string for function a
+test_input/test39.py:29: No doc string for function x
+test_input/test39.py:31: No doc string for function y
+test_input/test39.py:33: No doc string for function z
+test_input/test39.py:33: Parameter (jjj) not used
+test_input/test39.py:34: Local variable (j) not used

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test39-2.5
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test39-2.5 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test39-2.5
new file mode 100644
index 0000000..9194236
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test39-2.5
@@ -0,0 +1,14 @@
+Processing module test39 (test_input/test39.py)...
+
+Warnings...
+
+test_input/test39.py:3: No doc string for function func2
+test_input/test39.py:10: No doc string for class X2
+test_input/test39.py:10: s is not first method argument
+test_input/test39.py:14: No doc string for function a
+test_input/test39.py:19: No doc string for function a
+test_input/test39.py:29: No doc string for function x
+test_input/test39.py:31: No doc string for function y
+test_input/test39.py:33: No doc string for function z
+test_input/test39.py:33: Parameter (jjj) not used
+test_input/test39.py:34: Local variable (j) not used

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test39-2.6
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test39-2.6 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test39-2.6
new file mode 100644
index 0000000..9194236
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test39-2.6
@@ -0,0 +1,14 @@
+Processing module test39 (test_input/test39.py)...
+
+Warnings...
+
+test_input/test39.py:3: No doc string for function func2
+test_input/test39.py:10: No doc string for class X2
+test_input/test39.py:10: s is not first method argument
+test_input/test39.py:14: No doc string for function a
+test_input/test39.py:19: No doc string for function a
+test_input/test39.py:29: No doc string for function x
+test_input/test39.py:31: No doc string for function y
+test_input/test39.py:33: No doc string for function z
+test_input/test39.py:33: Parameter (jjj) not used
+test_input/test39.py:34: Local variable (j) not used

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test4
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test4 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test4
new file mode 100644
index 0000000..f29586e
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test4
@@ -0,0 +1,6 @@
+Processing module test4 (test_input/test4.py)...
+
+Warnings...
+
+test_input/test4.py:1: No module doc string
+test_input/test4.py:11: Base class (UserDict.UserDict) __init__() not called

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test40
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test40 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test40
new file mode 100644
index 0000000..cd89927
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test40
@@ -0,0 +1,15 @@
+Processing module test40 (test_input/test40.py)...
+
+Warnings...
+
+test_input/test40.py:8: Parameter (args) not used
+test_input/test40.py:8: Parameter (kw) not used
+test_input/test40.py:11: Parameter (kw) not used
+test_input/test40.py:17: Parameter (a) not used
+test_input/test40.py:17: Parameter (args) not used
+test_input/test40.py:17: Parameter (b) not used
+test_input/test40.py:17: Parameter (c) not used
+test_input/test40.py:17: Parameter (kw) not used
+test_input/test40.py:33: Parameter (a) not used
+test_input/test40.py:33: Parameter (args) not used
+test_input/test40.py:33: Parameter (kw) not used

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test41
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test41 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test41
new file mode 100644
index 0000000..d51c052
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test41
@@ -0,0 +1,7 @@
+Processing module test41 (test_input/test41.py)...
+
+Warnings...
+
+test_input/test41.py:4: Redefining attribute (x) original line (3)
+test_input/test41.py:8: Redefining attribute (X) original line (6)
+test_input/test41.py:14: Redefining attribute (x) original line (13)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test42
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test42 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test42
new file mode 100644
index 0000000..9b0912e
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test42
@@ -0,0 +1,5 @@
+Processing module test42 (test_input/test42.py)...
+
+Warnings...
+
+test_input/test42.py:11: sys.exc_traceback is deprecated

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test43
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test43 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test43
new file mode 100644
index 0000000..b798629
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test43
@@ -0,0 +1,5 @@
+Processing module test43 (test_input/test43.py)...
+
+Warnings...
+
+test_input/test43.py:11: No class attribute (isIntersecting) found

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test44
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test44 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test44
new file mode 100644
index 0000000..941ba82
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test44
@@ -0,0 +1,5 @@
+Processing module test44 (test_input/test44.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test45
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test45 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test45
new file mode 100644
index 0000000..9ee029f
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test45
@@ -0,0 +1,6 @@
+Processing module test45 (test_input/test45.py)...
+
+Warnings...
+
+test_input/test45.py:17: Parameter (other) not used
+test_input/test45.py:19: Parameter (other1) not used

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test46
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test46 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test46
new file mode 100644
index 0000000..8a20584
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test46
@@ -0,0 +1,10 @@
+Processing module test46 (test_input/test46.py)...
+
+Warnings...
+
+test_input/test46.py:5: Imported module (test46) not used
+test_input/test46.py:5: Module (test46) imports itself
+test_input/test46.py:6: Module (test46) imports itself
+test_input/test46.py:6: Using import and from ... import for (test46)
+test_input/test46.py:7: Module (test46) imports itself
+test_input/test46.py:7: Using import and from ... import for (test46)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test47
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test47 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test47
new file mode 100644
index 0000000..df0f931
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test47
@@ -0,0 +1,5 @@
+Processing module test47 (test_input/test47.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test48
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test48 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test48
new file mode 100644
index 0000000..9e5e184
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test48
@@ -0,0 +1,40 @@
+Processing module test48 (test_input/test48.py)...
+
+Warnings...
+
+test_input/test48.py:10: Object (i) has no attribute (has_no_method)
+test_input/test48.py:11: Object (l) has no attribute (has_no_method)
+test_input/test48.py:12: Object (d) has no attribute (has_no_method)
+test_input/test48.py:13: Object (s) has no attribute (has_no_method)
+test_input/test48.py:14: Object (n) has no attribute (has_no_method)
+test_input/test48.py:15: Object (e) has no attribute (has_no_method)
+test_input/test48.py:17: Object (i) has no attribute (has_no_attr)
+test_input/test48.py:18: Object (l) has no attribute (has_no_attr)
+test_input/test48.py:19: Object (d) has no attribute (has_no_attr)
+test_input/test48.py:20: Object (s) has no attribute (has_no_attr)
+test_input/test48.py:21: Object (n) has no attribute (has_no_attr)
+test_input/test48.py:22: Object (e) has no attribute (has_no_attr)
+test_input/test48.py:28: Object (jj) has no attribute (a)
+test_input/test48.py:29: Object (jj) has no attribute (b)
+test_input/test48.py:46: Object (tt) has no attribute (a)
+test_input/test48.py:47: Object (tt) has no attribute (b)
+test_input/test48.py:53: Statement appears to have no effect
+test_input/test48.py:54: Statement appears to have no effect
+test_input/test48.py:55: Statement appears to have no effect
+test_input/test48.py:56: Statement appears to have no effect
+test_input/test48.py:57: Statement appears to have no effect
+test_input/test48.py:58: Statement appears to have no effect
+test_input/test48.py:59: Statement appears to have no effect
+test_input/test48.py:63: Statement appears to have no effect
+test_input/test48.py:65: Statement appears to have no effect
+test_input/test48.py:66: Statement appears to have no effect
+test_input/test48.py:70: Statement appears to have no effect
+test_input/test48.py:71: Statement appears to have no effect
+test_input/test48.py:72: Statement appears to have no effect
+test_input/test48.py:73: Statement appears to have no effect
+test_input/test48.py:74: Statement appears to have no effect
+test_input/test48.py:75: Statement appears to have no effect
+test_input/test48.py:76: Statement appears to have no effect
+test_input/test48.py:77: Statement appears to have no effect
+test_input/test48.py:78: Statement appears to have no effect
+test_input/test48.py:79: Statement appears to have no effect

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test49
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test49 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test49
new file mode 100644
index 0000000..1130e92
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test49
@@ -0,0 +1,8 @@
+Processing module test49 (test_input/test49.py)...
+
+Warnings...
+
+test_input/test49.py:5: Using integer division (d / e) may return integer or float
+test_input/test49.py:6: Using integer division (d / 3) may return integer or float
+test_input/test49.py:7: Using integer division (7 / e) may return integer or float
+test_input/test49.py:8: Using integer division (5 / 6) may return integer or float

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test5
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test5 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test5
new file mode 100644
index 0000000..a3b8b5b
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test5
@@ -0,0 +1,5 @@
+Processing module test5 (test_input/test5.py)...
+
+Warnings...
+
+test_input/test5.py:8: Function (x) uses named arguments

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test50
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test50 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test50
new file mode 100644
index 0000000..3524bfd
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test50
@@ -0,0 +1,8 @@
+Processing module test50 (test_input/test50.py)...
+
+Warnings...
+
+test_input/test50.py:7: Function (C) has too many arguments (5)
+test_input/test50.py:8: Function (D) has too many arguments (6)
+test_input/test50.py:14: Function (F) has too many local variables (4)
+test_input/test50.py:18: Function (G) has too many local variables (5)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test51
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test51 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test51
new file mode 100644
index 0000000..6a5dc27
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test51
@@ -0,0 +1,6 @@
+Processing module test51 (test_input/test51.py)...
+
+Warnings...
+
+test_input/test51.py:7: Using a tuple instead of slice as list accessor for (n)
+test_input/test51.py:8: Using a tuple instead of slice as list accessor for (n)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test52
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test52 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test52
new file mode 100644
index 0000000..2eb410d
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test52
@@ -0,0 +1,5 @@
+Processing module test52 (test_input/test52.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test53
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test53 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test53
new file mode 100644
index 0000000..ce3b35a
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test53
@@ -0,0 +1,9 @@
+Processing module test53 (test_input/test53.py)...
+
+Warnings...
+
+test_input/test53.py:5: Operator (~~) doesn't exist, statement has no effect
+test_input/test53.py:7: Operator (--) doesn't exist, statement has no effect
+test_input/test53.py:9: Operator (++) doesn't exist, statement has no effect
+test_input/test53.py:22: Format string argument count (2) doesn't match arguments (3)
+test_input/test53.py:26: Unary positive (+) usually has no effect

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test54
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test54 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test54
new file mode 100644
index 0000000..e8e709b
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test54
@@ -0,0 +1,9 @@
+Processing module test54 (test_input/test54.py)...
+
+Warnings...
+
+test_input/test54.py:7: Variable (z) deleted before being set
+test_input/test54.py:9: Local variable (a) has already been deleted on line 6
+test_input/test54.py:12: (a) cannot be used after being deleted on line 9
+test_input/test54.py:15: No global (no_global) found
+test_input/test54.py:18: No global (another_non_existant_global) found

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test55
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test55 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test55
new file mode 100644
index 0000000..f49800a
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test55
@@ -0,0 +1,9 @@
+Processing module test55 (test_input/test55.py)...
+
+Warnings...
+
+test_input/test55.py:6: (RuntimeError) shadows builtin
+test_input/test55.py:6: Local variable (RuntimeError) not used
+test_input/test55.py:6: Setting exception to builtin (RuntimeError), consider () around exceptions
+test_input/test55.py:29: (RuntimeError) shadows builtin
+test_input/test55.py:29: Setting exception to builtin (RuntimeError), consider () around exceptions

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test56
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test56 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test56
new file mode 100644
index 0000000..2f482b7
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test56
@@ -0,0 +1,5 @@
+Processing module test56 (test_input/test56.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test57
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test57 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test57
new file mode 100644
index 0000000..fa25095
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test57
@@ -0,0 +1,5 @@
+Processing module test57 (test_input/test57.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test58
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test58 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test58
new file mode 100644
index 0000000..8bd6ab9
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test58
@@ -0,0 +1,10 @@
+Processing module test58 (test_input/test58.py)...
+
+Warnings...
+
+test_input/test58.py:3: Using identifier (yield) which will become a keyword in version 2.2
+test_input/test58.py:6: Local variable (yield) shadows global defined on line 3
+test_input/test58.py:6: Using identifier (yield) which will become a keyword in version 2.2
+test_input/test58.py:7: Local variable (yield) shadows global defined on line 3
+test_input/test58.py:7: Using identifier (yield) which will become a keyword in version 2.2
+test_input/test58.py:10: Using identifier (yield) which will become a keyword in version 2.2

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test58-2.2
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test58-2.2 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test58-2.2
new file mode 100644
index 0000000..c49a691
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test58-2.2
@@ -0,0 +1,14 @@
+Processing module test58 (test_input/test58.py)...
+<string>:3: Warning: 'yield' will become a reserved keyword in the future
+<string>:6: Warning: 'yield' will become a reserved keyword in the future
+<string>:7: Warning: 'yield' will become a reserved keyword in the future
+<string>:10: Warning: 'yield' will become a reserved keyword in the future
+
+Warnings...
+
+test_input/test58.py:3: Using identifier (yield) which will become a keyword in version 2.2
+test_input/test58.py:6: Local variable (yield) shadows global defined on line 3
+test_input/test58.py:6: Using identifier (yield) which will become a keyword in version 2.2
+test_input/test58.py:7: Local variable (yield) shadows global defined on line 3
+test_input/test58.py:7: Using identifier (yield) which will become a keyword in version 2.2
+test_input/test58.py:10: Using identifier (yield) which will become a keyword in version 2.2

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test58-2.3
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test58-2.3 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test58-2.3
new file mode 100644
index 0000000..ac8845c
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test58-2.3
@@ -0,0 +1,8 @@
+Processing module test58 (test_input/test58.py)...
+  SyntaxError: invalid syntax (test_input/test58.py, line 3)
+    yield = None
+          ^
+
+Warnings...
+
+test58:1: NOT PROCESSED UNABLE TO IMPORT

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test58-2.4
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test58-2.4 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test58-2.4
new file mode 100644
index 0000000..ac8845c
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test58-2.4
@@ -0,0 +1,8 @@
+Processing module test58 (test_input/test58.py)...
+  SyntaxError: invalid syntax (test_input/test58.py, line 3)
+    yield = None
+          ^
+
+Warnings...
+
+test58:1: NOT PROCESSED UNABLE TO IMPORT

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test58-2.5
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test58-2.5 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test58-2.5
new file mode 100644
index 0000000..ac8845c
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test58-2.5
@@ -0,0 +1,8 @@
+Processing module test58 (test_input/test58.py)...
+  SyntaxError: invalid syntax (test_input/test58.py, line 3)
+    yield = None
+          ^
+
+Warnings...
+
+test58:1: NOT PROCESSED UNABLE TO IMPORT

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test58-2.6
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test58-2.6 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test58-2.6
new file mode 100644
index 0000000..ac8845c
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test58-2.6
@@ -0,0 +1,8 @@
+Processing module test58 (test_input/test58.py)...
+  SyntaxError: invalid syntax (test_input/test58.py, line 3)
+    yield = None
+          ^
+
+Warnings...
+
+test58:1: NOT PROCESSED UNABLE TO IMPORT

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test59
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test59 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test59
new file mode 100644
index 0000000..8a5145a
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test59
@@ -0,0 +1,9 @@
+Processing module test59 (test_input/test59.py)...
+
+Warnings...
+
+test_input/test59.py:4: Modifying parameter (c) with a default value may have unexpected consequences
+test_input/test59.py:5: Modifying parameter (d) with a default value may have unexpected consequences
+test_input/test59.py:19: Modifying parameter (x) with a default value may have unexpected consequences
+test_input/test59.py:22: Modifying parameter (a) with a default value may have unexpected consequences
+test_input/test59.py:23: Modifying parameter (b) with a default value may have unexpected consequences

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test6
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test6 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test6
new file mode 100644
index 0000000..0ff7ba2
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test6
@@ -0,0 +1,5 @@
+Processing module test6 (test_input/test6.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test60
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test60 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test60
new file mode 100644
index 0000000..76ab4cf
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test60
@@ -0,0 +1,6 @@
+Processing module test60 (test_input/test60.py)...
+
+Warnings...
+
+test_input/test60.py:3: self is argument in function
+test_input/test60.py:9: Using `self` in __repr__ method

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test61
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test61 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test61
new file mode 100644
index 0000000..a3ace53
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test61
@@ -0,0 +1,12 @@
+Processing module test61 (test_input/test61.py)...
+
+Warnings...
+
+test_input/test61.py:9: Invalid arguments to (x), got 0, expected 2
+test_input/test61.py:18: Invalid arguments to (get), got 3, expected between 1 and 2
+test_input/test61.py:20: Invalid arguments to (keys), got 3, expected 0
+test_input/test61.py:21: Using the return value from (d.clear) which is always None
+test_input/test61.py:22: Using the return value from (d.clear) which is always None
+test_input/test61.py:23: Using the return value from (d.clear) which is always None
+test_input/test61.py:26: Passing a constant string to setattr, consider direct reference
+test_input/test61.py:26: Using the return value from (setattr) which is always None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test62
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test62 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test62
new file mode 100644
index 0000000..1758789
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test62
@@ -0,0 +1,5 @@
+Processing module test62 (test_input/test62.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test63
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test63 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test63
new file mode 100644
index 0000000..61e97ad
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test63
@@ -0,0 +1,5 @@
+Processing module test63 (test_input/test63.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test64
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test64 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test64
new file mode 100644
index 0000000..48210e5
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test64
@@ -0,0 +1,9 @@
+Processing module test64 (test_input/test64.py)...
+
+Warnings...
+
+test_input/test64.py:1: No doc string for class _Anything
+test_input/test64.py:4: Imported module (re) not used
+test_input/test64.py:4: Imported module (sys) not used
+test_input/test64.py:5: Imported module (array) not used
+test_input/test64.py:14: Local variable (y) not used

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test65
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test65 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test65
new file mode 100644
index 0000000..944d3e6
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test65
@@ -0,0 +1,5 @@
+Processing module test65 (test_input/test65.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test66
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test66 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test66
new file mode 100644
index 0000000..f428606
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test66
@@ -0,0 +1,5 @@
+Processing module test66 (test_input/test66.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test67
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test67 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test67
new file mode 100644
index 0000000..55aadb5
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test67
@@ -0,0 +1,5 @@
+Processing module test67 (test_input/test67.py)...
+
+Warnings...
+
+test_input/test67.py:8: Members (a, d) not used in class (X)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test68
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test68 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test68
new file mode 100644
index 0000000..4fead9f
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test68
@@ -0,0 +1,9 @@
+Processing module test68 (test_input/test68.py)...
+
+Warnings...
+
+test_input/test68.py:15: Function returns a value and also implicitly returns None
+test_input/test68.py:44: Function returns a value and also implicitly returns None
+test_input/test68.py:63: Function returns a value and also implicitly returns None
+test_input/test68.py:128: Function returns a value and also implicitly returns None
+test_input/test68.py:142: Function returns a value and also implicitly returns None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test68-2.4
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test68-2.4 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test68-2.4
new file mode 100644
index 0000000..1714e59
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test68-2.4
@@ -0,0 +1,5 @@
+Processing module test68 (test_input/test68.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test68-2.5
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test68-2.5 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test68-2.5
new file mode 100644
index 0000000..1714e59
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test68-2.5
@@ -0,0 +1,5 @@
+Processing module test68 (test_input/test68.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test68-2.6
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test68-2.6 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test68-2.6
new file mode 100644
index 0000000..1714e59
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test68-2.6
@@ -0,0 +1,5 @@
+Processing module test68 (test_input/test68.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test69
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test69 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test69
new file mode 100644
index 0000000..170fb1a
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test69
@@ -0,0 +1,5 @@
+Processing module test69 (test_input/test69.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test7
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test7 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test7
new file mode 100644
index 0000000..36ee55d
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test7
@@ -0,0 +1,5 @@
+Processing module test7 (test_input/test7.py)...
+
+Warnings...
+
+test_input/test7.py:18: No class attribute (y) found

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test70
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test70 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test70
new file mode 100644
index 0000000..a8bbee7
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test70
@@ -0,0 +1,12 @@
+Processing module test70 (test_input/test70.py)...
+
+Warnings...
+
+test_input/test70.py:18: Using a conditional statement with a constant value (1)
+test_input/test70.py:20: Using a conditional statement with a constant value (1)
+test_input/test70.py:27: Using a conditional statement with a constant value (21)
+test_input/test70.py:29: Using a conditional statement with a constant value (31)
+test_input/test70.py:31: Using a conditional statement with a constant value ((x, test))
+test_input/test70.py:32: Using a conditional statement with a constant value ((5, test))
+test_input/test70.py:33: Using a conditional statement with a constant value (5)
+test_input/test70.py:35: Using a conditional statement with a constant value (str)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test71
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test71 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test71
new file mode 100644
index 0000000..34a419d
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test71
@@ -0,0 +1,10 @@
+Processing module test71 (test_input/test71.py)...
+
+Warnings...
+
+test_input/test71.py:8: Code appears to be unreachable
+test_input/test71.py:10: Function returns a value and also implicitly returns None
+test_input/test71.py:14: Code appears to be unreachable
+test_input/test71.py:16: Function returns a value and also implicitly returns None
+test_input/test71.py:20: Code appears to be unreachable
+test_input/test71.py:26: Code appears to be unreachable

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test71-2.4
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test71-2.4 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test71-2.4
new file mode 100644
index 0000000..0ec9ce3
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test71-2.4
@@ -0,0 +1,8 @@
+Processing module test71 (test_input/test71.py)...
+
+Warnings...
+
+test_input/test71.py:8: Code appears to be unreachable
+test_input/test71.py:14: Code appears to be unreachable
+test_input/test71.py:20: Code appears to be unreachable
+test_input/test71.py:26: Code appears to be unreachable

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test71-2.5
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test71-2.5 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test71-2.5
new file mode 100644
index 0000000..0ec9ce3
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test71-2.5
@@ -0,0 +1,8 @@
+Processing module test71 (test_input/test71.py)...
+
+Warnings...
+
+test_input/test71.py:8: Code appears to be unreachable
+test_input/test71.py:14: Code appears to be unreachable
+test_input/test71.py:20: Code appears to be unreachable
+test_input/test71.py:26: Code appears to be unreachable

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test71-2.6
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test71-2.6 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test71-2.6
new file mode 100644
index 0000000..0ec9ce3
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test71-2.6
@@ -0,0 +1,8 @@
+Processing module test71 (test_input/test71.py)...
+
+Warnings...
+
+test_input/test71.py:8: Code appears to be unreachable
+test_input/test71.py:14: Code appears to be unreachable
+test_input/test71.py:20: Code appears to be unreachable
+test_input/test71.py:26: Code appears to be unreachable

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test72
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test72 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test72
new file mode 100644
index 0000000..54eadc5
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test72
@@ -0,0 +1,8 @@
+Processing module test72 (test_input/test72.py)...
+
+Warnings...
+
+test_input/test72.py:8: Setting class attribute (y) not set in __init__
+test_input/test72.py:13: Setting class attribute (z) not set in __init__
+test_input/test72.py:23: No class attribute (z) found
+test_input/test72.py:24: Setting class attribute (y) not set in __init__

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test73
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test73 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test73
new file mode 100644
index 0000000..4a5af02
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test73
@@ -0,0 +1,9 @@
+Processing module test73 (test_input/test73.py)...
+
+Warnings...
+
+test_input/test73.py:12: Methods (f, g) in Abstract need to be overridden in a subclass
+test_input/test73.py:13: Methods (f) in ConcreteBad need to be overridden in a subclass
+test_input/test73.py:22: Methods (f) in AbstractInst need to be overridden in a subclass
+test_input/test73.py:36: Methods (abstract) in import73.AbstractLib need to be overridden in a subclass
+test_input/test73.py:37: Methods (abstract) in ImplAbstract need to be overridden in a subclass

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test74
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test74 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test74
new file mode 100644
index 0000000..011fbe1
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test74
@@ -0,0 +1,11 @@
+Processing module test74 (test_input/test74.py)...
+
+Warnings...
+
+test_input/test74.py:10: Using __getattribute__ in old-style class (B) does not work
+test_input/test74.py:17: __getattr__ should not return None, raise an exception if not found
+test_input/test74.py:20: Using __getattribute__ in old-style class (D) does not work
+test_input/test74.py:22: __getattribute__ should not return None, raise an exception if not found
+test_input/test74.py:30: Function returns a value and also implicitly returns None
+test_input/test74.py:30: __getattr__ should not return None, raise an exception if not found
+test_input/test74.py:41: Passing a constant string to getattr, consider direct reference

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test74-2.4
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test74-2.4 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test74-2.4
new file mode 100644
index 0000000..af3f443
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test74-2.4
@@ -0,0 +1,10 @@
+Processing module test74 (test_input/test74.py)...
+
+Warnings...
+
+test_input/test74.py:10: Using __getattribute__ in old-style class (B) does not work
+test_input/test74.py:17: __getattr__ should not return None, raise an exception if not found
+test_input/test74.py:20: Using __getattribute__ in old-style class (D) does not work
+test_input/test74.py:22: __getattribute__ should not return None, raise an exception if not found
+test_input/test74.py:30: __getattr__ should not return None, raise an exception if not found
+test_input/test74.py:41: Passing a constant string to getattr, consider direct reference

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test74-2.5
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test74-2.5 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test74-2.5
new file mode 100644
index 0000000..af3f443
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test74-2.5
@@ -0,0 +1,10 @@
+Processing module test74 (test_input/test74.py)...
+
+Warnings...
+
+test_input/test74.py:10: Using __getattribute__ in old-style class (B) does not work
+test_input/test74.py:17: __getattr__ should not return None, raise an exception if not found
+test_input/test74.py:20: Using __getattribute__ in old-style class (D) does not work
+test_input/test74.py:22: __getattribute__ should not return None, raise an exception if not found
+test_input/test74.py:30: __getattr__ should not return None, raise an exception if not found
+test_input/test74.py:41: Passing a constant string to getattr, consider direct reference

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test74-2.6
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test74-2.6 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test74-2.6
new file mode 100644
index 0000000..af3f443
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test74-2.6
@@ -0,0 +1,10 @@
+Processing module test74 (test_input/test74.py)...
+
+Warnings...
+
+test_input/test74.py:10: Using __getattribute__ in old-style class (B) does not work
+test_input/test74.py:17: __getattr__ should not return None, raise an exception if not found
+test_input/test74.py:20: Using __getattribute__ in old-style class (D) does not work
+test_input/test74.py:22: __getattribute__ should not return None, raise an exception if not found
+test_input/test74.py:30: __getattr__ should not return None, raise an exception if not found
+test_input/test74.py:41: Passing a constant string to getattr, consider direct reference

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test75
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test75 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test75
new file mode 100644
index 0000000..acb4285
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test75
@@ -0,0 +1,6 @@
+Processing module test75 (test_input/test75.py)...
+
+Warnings...
+
+test_input/test75.py:5: Using __slots__ in classic class A has no effect, consider deriving from object
+test_input/test75.py:8: No global (object) found

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test75-2.2
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test75-2.2 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test75-2.2
new file mode 100644
index 0000000..bb01431
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test75-2.2
@@ -0,0 +1,9 @@
+Processing module test75 (test_input/test75.py)...
+
+Warnings...
+
+test_input/test75.py:5: Using __slots__ in classic class A has no effect, consider deriving from object
+test_input/test75.py:14: __slots__ are empty in C
+test_input/test75.py:26: Using property (x) in classic class E may not work
+test_input/test75.py:45: ['cls', 'klass'] is not first classmethod argument
+test_input/test75.py:49: self is argument in staticmethod

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test75-2.3
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test75-2.3 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test75-2.3
new file mode 100644
index 0000000..bb01431
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test75-2.3
@@ -0,0 +1,9 @@
+Processing module test75 (test_input/test75.py)...
+
+Warnings...
+
+test_input/test75.py:5: Using __slots__ in classic class A has no effect, consider deriving from object
+test_input/test75.py:14: __slots__ are empty in C
+test_input/test75.py:26: Using property (x) in classic class E may not work
+test_input/test75.py:45: ['cls', 'klass'] is not first classmethod argument
+test_input/test75.py:49: self is argument in staticmethod

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test75-2.4
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test75-2.4 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test75-2.4
new file mode 100644
index 0000000..bb01431
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test75-2.4
@@ -0,0 +1,9 @@
+Processing module test75 (test_input/test75.py)...
+
+Warnings...
+
+test_input/test75.py:5: Using __slots__ in classic class A has no effect, consider deriving from object
+test_input/test75.py:14: __slots__ are empty in C
+test_input/test75.py:26: Using property (x) in classic class E may not work
+test_input/test75.py:45: ['cls', 'klass'] is not first classmethod argument
+test_input/test75.py:49: self is argument in staticmethod

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test75-2.5
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test75-2.5 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test75-2.5
new file mode 100644
index 0000000..bb01431
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test75-2.5
@@ -0,0 +1,9 @@
+Processing module test75 (test_input/test75.py)...
+
+Warnings...
+
+test_input/test75.py:5: Using __slots__ in classic class A has no effect, consider deriving from object
+test_input/test75.py:14: __slots__ are empty in C
+test_input/test75.py:26: Using property (x) in classic class E may not work
+test_input/test75.py:45: ['cls', 'klass'] is not first classmethod argument
+test_input/test75.py:49: self is argument in staticmethod

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test75-2.6
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test75-2.6 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test75-2.6
new file mode 100644
index 0000000..bb01431
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test75-2.6
@@ -0,0 +1,9 @@
+Processing module test75 (test_input/test75.py)...
+
+Warnings...
+
+test_input/test75.py:5: Using __slots__ in classic class A has no effect, consider deriving from object
+test_input/test75.py:14: __slots__ are empty in C
+test_input/test75.py:26: Using property (x) in classic class E may not work
+test_input/test75.py:45: ['cls', 'klass'] is not first classmethod argument
+test_input/test75.py:49: self is argument in staticmethod

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test76
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test76 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test76
new file mode 100644
index 0000000..4d44cc4
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test76
@@ -0,0 +1,6 @@
+Processing module test76 (test_input/test76.py)...
+
+Warnings...
+
+test_input/test76.py:6: Parameter (a) not used
+test_input/test76.py:6: Parameter (d) not used

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test77
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test77 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test77
new file mode 100644
index 0000000..be708a6
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test77
@@ -0,0 +1,11 @@
+Processing module test77 (test_input/test77.py)...
+  Caught exception importing module test77:
+    File "./pychecker/checker.py", line 698, in setupMainCode()
+      module = imp.load_module(self.moduleName, file, filename, smt)
+    File "test_input/test77.py", line 8
+      raise MyError("FOO!")
+  MyError: **error formatting exception value**
+
+Warnings...
+
+test77:1: NOT PROCESSED UNABLE TO IMPORT

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test78
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test78 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test78
new file mode 100644
index 0000000..eb716bf
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test78
@@ -0,0 +1,5 @@
+Processing module test78 (test_input/test78.py)...
+
+Warnings...
+
+test_input/test78.py:6: Using input() is a security problem, consider using raw_input()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test79
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test79 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test79
new file mode 100644
index 0000000..7e057ff
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test79
@@ -0,0 +1,6 @@
+Processing module test79 (test_input/test79.py)...
+
+Warnings...
+
+test_input/test79.py:8: Iterating over a string (s)
+test_input/test79.py:15: Iterating over a string (s)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test8
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test8 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test8
new file mode 100644
index 0000000..96ddb6c
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test8
@@ -0,0 +1,8 @@
+Processing module test8 (test_input/test8.py)...
+  SyntaxError: invalid syntax (test_input/test8.py, line 4)
+        syntax error here
+                   ^
+
+Warnings...
+
+test8:1: NOT PROCESSED UNABLE TO IMPORT

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test80
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test80 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test80
new file mode 100644
index 0000000..b6a9e33
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test80
@@ -0,0 +1,6 @@
+Processing module test80 (test_input/test80.py)...
+
+Warnings...
+
+test_input/test80.py:8: Variable (x) already has types ['int'] and set to float
+test_input/test80.py:23: Variable (y) already has types ['list'] and set to dictionary

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test80-2.2
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test80-2.2 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test80-2.2
new file mode 100644
index 0000000..ca469e0
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test80-2.2
@@ -0,0 +1,6 @@
+Processing module test80 (test_input/test80.py)...
+
+Warnings...
+
+test_input/test80.py:8: Variable (x) already has types ['int'] and set to float
+test_input/test80.py:23: Variable (y) already has types ['list'] and set to dict

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test80-2.3
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test80-2.3 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test80-2.3
new file mode 100644
index 0000000..ca469e0
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test80-2.3
@@ -0,0 +1,6 @@
+Processing module test80 (test_input/test80.py)...
+
+Warnings...
+
+test_input/test80.py:8: Variable (x) already has types ['int'] and set to float
+test_input/test80.py:23: Variable (y) already has types ['list'] and set to dict

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test80-2.4
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test80-2.4 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test80-2.4
new file mode 100644
index 0000000..ca469e0
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test80-2.4
@@ -0,0 +1,6 @@
+Processing module test80 (test_input/test80.py)...
+
+Warnings...
+
+test_input/test80.py:8: Variable (x) already has types ['int'] and set to float
+test_input/test80.py:23: Variable (y) already has types ['list'] and set to dict

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test80-2.5
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test80-2.5 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test80-2.5
new file mode 100644
index 0000000..ca469e0
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test80-2.5
@@ -0,0 +1,6 @@
+Processing module test80 (test_input/test80.py)...
+
+Warnings...
+
+test_input/test80.py:8: Variable (x) already has types ['int'] and set to float
+test_input/test80.py:23: Variable (y) already has types ['list'] and set to dict

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test80-2.6
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test80-2.6 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test80-2.6
new file mode 100644
index 0000000..ca469e0
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test80-2.6
@@ -0,0 +1,6 @@
+Processing module test80 (test_input/test80.py)...
+
+Warnings...
+
+test_input/test80.py:8: Variable (x) already has types ['int'] and set to float
+test_input/test80.py:23: Variable (y) already has types ['list'] and set to dict

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test81
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test81 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test81
new file mode 100644
index 0000000..641749d
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test81
@@ -0,0 +1,5 @@
+Processing module test81 (test_input/test81.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test82
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test82 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test82
new file mode 100644
index 0000000..0b89a87
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test82
@@ -0,0 +1,5 @@
+Processing module test82 (test_input/test82.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test83
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test83 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test83
new file mode 100644
index 0000000..fc376d7
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test83
@@ -0,0 +1,9 @@
+Processing module test83 (test_input/test83.py)...
+
+Warnings...
+
+test_input/test83.py:9: Unpacking 2 values into 3 variables
+test_input/test83.py:14: Unpacking 2 values into 3 variables
+test_input/test83.py:18: Unpacking 2 values into 1 variables
+test_input/test83.py:22: Unpacking 1 values into 2 variables
+test_input/test83.py:26: Unpacking a non-sequence (5) of type int

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test84
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test84 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test84
new file mode 100644
index 0000000..b9891fd
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test84
@@ -0,0 +1,5 @@
+Processing module test84 (test_input/test84.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test85
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test85 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test85
new file mode 100644
index 0000000..489a3d6
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test85
@@ -0,0 +1,6 @@
+Processing module test85 (test_input/test85.py)...
+
+Warnings...
+
+test_input/test85.py:13: Using a conditional statement with a constant value (None)
+test_input/test85.py:17: Using a conditional statement with a constant value ([])

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test86
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test86 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test86
new file mode 100644
index 0000000..0661307
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test86
@@ -0,0 +1,13 @@
+Processing module test86 (test_input/test86.py)...
+
+Warnings...
+
+test_input/test86.py:34: Raising string exceptions are deprecated (strerr)
+test_input/test86.py:36: Raising string exceptions are deprecated (h)
+test_input/test86.py:38: Raising an exception on a non-Exception object (k)
+test_input/test86.py:70: Catching string exceptions are deprecated (strerr)
+test_input/test86.py:72: Catching string exceptions are deprecated (strerr1)
+test_input/test86.py:72: Catching string exceptions are deprecated (strerr2)
+test_input/test86.py:74: Catching string exceptions are deprecated (strerr1)
+test_input/test86.py:76: Catching string exceptions are deprecated (h)
+test_input/test86.py:78: Catching a non-Exception object (k)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test87
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test87 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test87
new file mode 100644
index 0000000..f1e6c43
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test87
@@ -0,0 +1,25 @@
+Processing module test87 (test_input/test87.py)...
+
+Warnings...
+
+test_input/test87.py:3: (True) shadows builtin
+test_input/test87.py:3: Should not assign to True, it is (or will be) a builtin
+test_input/test87.py:4: (False) shadows builtin
+test_input/test87.py:4: Should not assign to False, it is (or will be) a builtin
+test_input/test87.py:6: Should not assign to true, it is similar to builtin True
+test_input/test87.py:7: Should not assign to false, it is similar to builtin False
+test_input/test87.py:9: Should not assign to TRUE, it is similar to builtin True
+test_input/test87.py:10: Should not assign to FALSE, it is similar to builtin False
+test_input/test87.py:14: Comparisons with TRUE are not necessary and may not work as expected
+test_input/test87.py:16: Comparisons with TRUE are not necessary and may not work as expected
+test_input/test87.py:16: Comparisons with True are not necessary and may not work as expected
+test_input/test87.py:16: Comparisons with true are not necessary and may not work as expected
+test_input/test87.py:20: Comparisons with false are not necessary and may not work as expected
+test_input/test87.py:22: Using is false, may not always work
+test_input/test87.py:24: Using is True, may not always work
+test_input/test87.py:26: Using is 53343, may not always work
+test_input/test87.py:28: Using is 10000000.0, may not always work
+test_input/test87.py:30: Using is not false, may not always work
+test_input/test87.py:32: Using is not True, may not always work
+test_input/test87.py:34: Using is not 53343, may not always work
+test_input/test87.py:36: Using is not 10000000.0, may not always work

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test88
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test88 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test88
new file mode 100644
index 0000000..d2bcca4
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test88
@@ -0,0 +1,9 @@
+Processing module test88 (test_input/test88.py)...
+
+Warnings...
+
+test_input/test88.py:7: gopherlib module is deprecated
+test_input/test88.py:11: whrandom module is deprecated, consider using random
+test_input/test88.py:20: os.tempnam() is a security problem
+test_input/test88.py:21: os.tmpnam() is a security problem
+test_input/test88.py:23: string.atof is deprecated

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test88-2.4
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test88-2.4 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test88-2.4
new file mode 100644
index 0000000..b5e6e2a
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test88-2.4
@@ -0,0 +1,11 @@
+Processing module test88 (test_input/test88.py)...
+/usr/lib/python2.4/whrandom.py:38: DeprecationWarning: the whrandom module is deprecated; please use the random module
+  DeprecationWarning)
+
+Warnings...
+
+test_input/test88.py:7: gopherlib module is deprecated
+test_input/test88.py:11: whrandom module is deprecated, consider using random
+test_input/test88.py:20: os.tempnam() is a security problem
+test_input/test88.py:21: os.tmpnam() is a security problem
+test_input/test88.py:23: string.atof is deprecated

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test89
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test89 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test89
new file mode 100644
index 0000000..ed54d2b
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test89
@@ -0,0 +1,11 @@
+Processing module test89 (test_input/test89.py)...
+  Caught exception importing module test89:
+    File "./pychecker/checker.py", line 536, in setupMainCode()
+      module = imp.load_module(self.moduleName, file, filename, smt)
+    File "test_input/test89.py", line 3
+      class Newbie(object):
+  NameError: name 'object' is not defined
+
+Warnings...
+
+test89:1: NOT PROCESSED UNABLE TO IMPORT

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test89-2.2
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test89-2.2 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test89-2.2
new file mode 100644
index 0000000..65d361b
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test89-2.2
@@ -0,0 +1,5 @@
+Processing module test89 (test_input/test89.py)...
+
+Warnings...
+
+test_input/test89.py:7: Using __coerce__ in new-style class (Newbie) will not work for binary operations

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test89-2.3
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test89-2.3 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test89-2.3
new file mode 100644
index 0000000..65d361b
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test89-2.3
@@ -0,0 +1,5 @@
+Processing module test89 (test_input/test89.py)...
+
+Warnings...
+
+test_input/test89.py:7: Using __coerce__ in new-style class (Newbie) will not work for binary operations

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test89-2.4
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test89-2.4 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test89-2.4
new file mode 100644
index 0000000..65d361b
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test89-2.4
@@ -0,0 +1,5 @@
+Processing module test89 (test_input/test89.py)...
+
+Warnings...
+
+test_input/test89.py:7: Using __coerce__ in new-style class (Newbie) will not work for binary operations

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test89-2.5
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test89-2.5 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test89-2.5
new file mode 100644
index 0000000..65d361b
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test89-2.5
@@ -0,0 +1,5 @@
+Processing module test89 (test_input/test89.py)...
+
+Warnings...
+
+test_input/test89.py:7: Using __coerce__ in new-style class (Newbie) will not work for binary operations

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test89-2.6
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test89-2.6 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test89-2.6
new file mode 100644
index 0000000..65d361b
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test89-2.6
@@ -0,0 +1,5 @@
+Processing module test89 (test_input/test89.py)...
+
+Warnings...
+
+test_input/test89.py:7: Using __coerce__ in new-style class (Newbie) will not work for binary operations

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test9
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test9 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test9
new file mode 100644
index 0000000..c5488dc
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test9
@@ -0,0 +1,6 @@
+Processing module test9 (test_input/test9.py)...
+
+Warnings...
+
+test_input/test9.py:8: Module (getopt) re-imported
+test_input/test9.py:15: No module attribute (xyz) found

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test90
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test90 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test90
new file mode 100644
index 0000000..0b9765a
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test90
@@ -0,0 +1,16 @@
+Processing module test90 (test_input/test90.py)...
+
+Warnings...
+
+test_input/test90.py:4: Using is 1, may not always work
+test_input/test90.py:5: Using is s, may not always work
+test_input/test90.py:6: Using is 1.32, may not always work
+test_input/test90.py:7: Using is (), may not always work
+test_input/test90.py:8: Using is [], may not always work
+test_input/test90.py:9: Using is {}, may not always work
+test_input/test90.py:14: Using is not 1, may not always work
+test_input/test90.py:15: Using is not s, may not always work
+test_input/test90.py:16: Using is not 1.32, may not always work
+test_input/test90.py:17: Using is not (), may not always work
+test_input/test90.py:18: Using is not [], may not always work
+test_input/test90.py:19: Using is not {}, may not always work

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test92
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test92 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test92
new file mode 100644
index 0000000..b630b21
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test92
@@ -0,0 +1,5 @@
+Processing module test92 (test_input/test92.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test93
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test93 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test93
new file mode 100644
index 0000000..12c6b19
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test93
@@ -0,0 +1,6 @@
+Processing module test93 (test_input/test93.py)...
+
+Warnings...
+
+test_input/test93.py:6: Passing a constant string to getattr, consider direct reference
+test_input/test93.py:11: Passing a constant string to setattr, consider direct reference

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test94
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test94 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test94
new file mode 100644
index 0000000..aa56448
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test94
@@ -0,0 +1,16 @@
+Processing module test94 (test_input/test94.py)...
+
+Warnings...
+
+test_input/test94.py:4: Setting a to itself has no effect
+test_input/test94.py:5: Setting a.b to itself has no effect
+test_input/test94.py:6: Setting a.b.c to itself has no effect
+test_input/test94.py:7: Setting a.b.c.d to itself has no effect
+test_input/test94.py:8: a & a has no effect
+test_input/test94.py:9: a | a has no effect
+test_input/test94.py:10: a.b | a.b has no effect
+test_input/test94.py:11: a.b.c | a.b.c has no effect
+test_input/test94.py:12: a ^ a is always 0
+test_input/test94.py:13: a.b ^ a.b is always 0
+test_input/test94.py:14: a.b.c ^ a.b.c is always 0
+test_input/test94.py:15: a / a is always 1 or ZeroDivisionError

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test95
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test95 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test95
new file mode 100644
index 0000000..3a662f5
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test95
@@ -0,0 +1,5 @@
+Processing module test95 (test_input/test95.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test96
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test96 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test96
new file mode 100644
index 0000000..284a11a
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test96
@@ -0,0 +1,6 @@
+Processing module test96 (test_input/test96.py)...
+
+Warnings...
+
+test_input/test96.py:7: string.find() returns an integer, consider checking >= 0 or < 0 for not found
+test_input/test96.py:9: string.find() returns an integer, consider checking >= 0 or < 0 for not found

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test97
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test97 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test97
new file mode 100644
index 0000000..5041e71
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test97
@@ -0,0 +1,5 @@
+Processing module test97 (test_input/test97.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test98
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test98 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test98
new file mode 100644
index 0000000..1eddd01
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test98
@@ -0,0 +1,8 @@
+Processing module test98 (test_input/test98.py)...
+
+Warnings...
+
+test_input/import98.py:11: Cannot return a value from __init__
+
+test_input/test98.py:15: Cannot return a value from __init__
+test_input/test98.py:29: Cannot return a value from __init__

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test99
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test99 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test99
new file mode 100644
index 0000000..4c8d15f
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test99
@@ -0,0 +1,5 @@
+Processing module test99 (test_input/test99.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/__init__.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/__init__.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/__init__.py
new file mode 100644
index 0000000..e6a43bc
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/__init__.py
@@ -0,0 +1,3 @@
+"""
+Tests for PyChecker
+"""

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import24.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import24.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import24.py
new file mode 100644
index 0000000..2180f40
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import24.py
@@ -0,0 +1,14 @@
+'doc'
+
+class Aaa:
+    def __init__(self):
+        self.a = 1
+
+class Bbb(Aaa):
+    def __init__(self):
+        self.b = 1
+
+def func24():
+    return 53
+
+shadow = 5

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import37.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import37.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import37.py
new file mode 100644
index 0000000..26f4adf
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import37.py
@@ -0,0 +1,7 @@
+'d'
+
+class Test:
+    'doc'
+    def x(self):
+        import struct
+        print struct

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import44.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import44.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import44.py
new file mode 100644
index 0000000..22f42c8
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import44.py
@@ -0,0 +1,12 @@
+'d'
+
+class Ccc:
+  'd'
+  def __init__(self, c):
+    pass
+
+class Ddd:
+  'd'
+  def __init__(self):
+    self.ccc = Ccc(1)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import47.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import47.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import47.py
new file mode 100644
index 0000000..cdf25a5
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import47.py
@@ -0,0 +1,7 @@
+'d'
+
+class import47:
+  'this class must be named the same as the file to create a spurious warning'
+  v = 'n'
+  def print_version(self):
+    print import47.v

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import56a.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import56a.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import56a.py
new file mode 100644
index 0000000..ec655c2
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import56a.py
@@ -0,0 +1,9 @@
+'doc'
+
+from import56b import Bar
+
+class Foo(Bar):
+    'doc'
+    def __init__(self):
+    	Bar.__init__(self)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import56b.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import56b.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import56b.py
new file mode 100644
index 0000000..4c7148f
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import56b.py
@@ -0,0 +1,6 @@
+'doc'
+
+class Bar:
+    'doc'
+    def __init__(self): pass
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import69.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import69.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import69.py
new file mode 100644
index 0000000..d8dadb8
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import69.py
@@ -0,0 +1,8 @@
+'d'
+
+class Test:
+    'd'
+    def __init__(self): pass
+
+class Alias(Test):
+    'd'



[26/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code

Posted by rl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/pg8000/protocol.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/pg8000/protocol.py b/tools/bin/ext/pg8000/protocol.py
new file mode 100644
index 0000000..377074b
--- /dev/null
+++ b/tools/bin/ext/pg8000/protocol.py
@@ -0,0 +1,1340 @@
+# vim: sw=4:expandtab:foldmethod=marker
+#
+# Copyright (c) 2007-2009, Mathieu Fenniak
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+# * The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+__author__ = "Mathieu Fenniak"
+
+import socket
+import select
+import threading
+import struct
+import hashlib
+from cStringIO import StringIO
+
+from errors import *
+from util import MulticastDelegate
+import types
+
+##
+# An SSLRequest message.  To initiate an SSL-encrypted connection, an
+# SSLRequest message is used rather than a {@link StartupMessage
+# StartupMessage}.  A StartupMessage is still sent, but only after SSL
+# negotiation (if accepted).
+# <p>
+# Stability: This is an internal class.  No stability guarantee is made.
+class SSLRequest(object):
+    def __init__(self):
+        pass
+
+    # Int32(8) - Message length, including self.<br>
+    # Int32(80877103) - The SSL request code.<br>
+    def serialize(self):
+        return struct.pack("!ii", 8, 80877103)
+
+
+##
+# A StartupMessage message.  Begins a DB session, identifying the user to be
+# authenticated as and the database to connect to.
+# <p>
+# Stability: This is an internal class.  No stability guarantee is made.
+class StartupMessage(object):
+    # Greenplum utility mode
+    def __init__(self, user, database=None, options=None):
+        self.user = user
+        self.database = database
+        self.options = options
+
+    # Int32 - Message length, including self.
+    # Int32(196608) - Protocol version number.  Version 3.0.
+    # Any number of key/value pairs, terminated by a zero byte:
+    #   String - A parameter name (user, database, or options)
+    #   String - Parameter value
+    def serialize(self):
+        protocol = 196608
+        val = struct.pack("!i", protocol)
+        val += "user\x00" + self.user + "\x00"
+        if self.database:
+            val += "database\x00" + self.database + "\x00"
+        if self.options:
+            val += "options\x00" + self.options + "\x00"
+        val += "\x00"
+        val = struct.pack("!i", len(val) + 4) + val
+        return val
+
+
+##
+# Parse message.  Creates a prepared statement in the DB session.
+# <p>
+# Stability: This is an internal class.  No stability guarantee is made.
+#
+# @param ps         Name of the prepared statement to create.
+# @param qs         Query string.
+# @param type_oids  An iterable that contains the PostgreSQL type OIDs for
+#                   parameters in the query string.
+class Parse(object):
+    def __init__(self, ps, qs, type_oids):
+        self.ps = ps
+        self.qs = qs
+        self.type_oids = type_oids
+
+    def __repr__(self):
+        return "<Parse ps=%r qs=%r>" % (self.ps, self.qs)
+
+    # Byte1('P') - Identifies the message as a Parse command.
+    # Int32 -   Message length, including self.
+    # String -  Prepared statement name.  An empty string selects the unnamed
+    #           prepared statement.
+    # String -  The query string.
+    # Int16 -   Number of parameter data types specified (can be zero).
+    # For each parameter:
+    #   Int32 - The OID of the parameter data type.
+    def serialize(self):
+        val = self.ps + "\x00" + self.qs + "\x00"
+        val = val + struct.pack("!h", len(self.type_oids))
+        for oid in self.type_oids:
+            # Parse message doesn't seem to handle the -1 type_oid for NULL
+            # values that other messages handle.  So we'll provide type_oid 705,
+            # the PG "unknown" type.
+            if oid == -1: oid = 705
+            val = val + struct.pack("!i", oid)
+        val = struct.pack("!i", len(val) + 4) + val
+        val = "P" + val
+        return val
+
+
+##
+# Bind message.  Readies a prepared statement for execution.
+# <p>
+# Stability: This is an internal class.  No stability guarantee is made.
+#
+# @param portal     Name of the destination portal.
+# @param ps         Name of the source prepared statement.
+# @param in_fc      An iterable containing the format codes for input
+#                   parameters.  0 = Text, 1 = Binary.
+# @param params     The parameters.
+# @param out_fc     An iterable containing the format codes for output
+#                   parameters.  0 = Text, 1 = Binary.
+# @param kwargs     Additional arguments to pass to the type conversion
+#                   methods.
+class Bind(object):
+    def __init__(self, portal, ps, in_fc, params, out_fc, **kwargs):
+        self.portal = portal
+        self.ps = ps
+        self.in_fc = in_fc
+        self.params = []
+        for i in range(len(params)):
+            if len(self.in_fc) == 0:
+                fc = 0
+            elif len(self.in_fc) == 1:
+                fc = self.in_fc[0]
+            else:
+                fc = self.in_fc[i]
+            self.params.append(types.pg_value(params[i], fc, **kwargs))
+        self.out_fc = out_fc
+
+    def __repr__(self):
+        return "<Bind p=%r s=%r>" % (self.portal, self.ps)
+
+    # Byte1('B') - Identifies the Bind command.
+    # Int32 - Message length, including self.
+    # String - Name of the destination portal.
+    # String - Name of the source prepared statement.
+    # Int16 - Number of parameter format codes.
+    # For each parameter format code:
+    #   Int16 - The parameter format code.
+    # Int16 - Number of parameter values.
+    # For each parameter value:
+    #   Int32 - The length of the parameter value, in bytes, not including this
+    #           this length.  -1 indicates a NULL parameter value, in which no
+    #           value bytes follow.
+    #   Byte[n] - Value of the parameter.
+    # Int16 - The number of result-column format codes.
+    # For each result-column format code:
+    #   Int16 - The format code.
+    def serialize(self):
+        retval = StringIO()
+        retval.write(self.portal + "\x00")
+        retval.write(self.ps + "\x00")
+        retval.write(struct.pack("!h", len(self.in_fc)))
+        for fc in self.in_fc:
+            retval.write(struct.pack("!h", fc))
+        retval.write(struct.pack("!h", len(self.params)))
+        for param in self.params:
+            if param == None:
+                # special case, NULL value
+                retval.write(struct.pack("!i", -1))
+            else:
+                retval.write(struct.pack("!i", len(param)))
+                retval.write(param)
+        retval.write(struct.pack("!h", len(self.out_fc)))
+        for fc in self.out_fc:
+            retval.write(struct.pack("!h", fc))
+        val = retval.getvalue()
+        val = struct.pack("!i", len(val) + 4) + val
+        val = "B" + val
+        return val
+
+
+##
+# A Close message, used for closing prepared statements and portals.
+# <p>
+# Stability: This is an internal class.  No stability guarantee is made.
+#
+# @param typ    'S' for prepared statement, 'P' for portal.
+# @param name   The name of the item to close.
+class Close(object):
+    def __init__(self, typ, name):
+        if len(typ) != 1:
+            raise InternalError("Close typ must be 1 char")
+        self.typ = typ
+        self.name = name
+
+    # Byte1('C') - Identifies the message as a close command.
+    # Int32 - Message length, including self.
+    # Byte1 - 'S' for prepared statement, 'P' for portal.
+    # String - The name of the item to close.
+    def serialize(self):
+        val = self.typ + self.name + "\x00"
+        val = struct.pack("!i", len(val) + 4) + val
+        val = "C" + val
+        return val
+
+
+##
+# A specialized Close message for a portal.
+# <p>
+# Stability: This is an internal class.  No stability guarantee is made.
+class ClosePortal(Close):
+    def __init__(self, name):
+        Close.__init__(self, "P", name)
+
+
+##
+# A specialized Close message for a prepared statement.
+# <p>
+# Stability: This is an internal class.  No stability guarantee is made.
+class ClosePreparedStatement(Close):
+    def __init__(self, name):
+        Close.__init__(self, "S", name)
+
+
+##
+# A Describe message, used for obtaining information on prepared statements
+# and portals.
+# <p>
+# Stability: This is an internal class.  No stability guarantee is made.
+#
+# @param typ    'S' for prepared statement, 'P' for portal.
+# @param name   The name of the item to close.
+class Describe(object):
+    def __init__(self, typ, name):
+        if len(typ) != 1:
+            raise InternalError("Describe typ must be 1 char")
+        self.typ = typ
+        self.name = name
+
+    # Byte1('D') - Identifies the message as a describe command.
+    # Int32 - Message length, including self.
+    # Byte1 - 'S' for prepared statement, 'P' for portal.
+    # String - The name of the item to close.
+    def serialize(self):
+        val = self.typ + self.name + "\x00"
+        val = struct.pack("!i", len(val) + 4) + val
+        val = "D" + val
+        return val
+
+
+##
+# A specialized Describe message for a portal.
+# <p>
+# Stability: This is an internal class.  No stability guarantee is made.
+class DescribePortal(Describe):
+    def __init__(self, name):
+        Describe.__init__(self, "P", name)
+
+    def __repr__(self):
+        return "<DescribePortal %r>" % (self.name)
+
+
+##
+# A specialized Describe message for a prepared statement.
+# <p>
+# Stability: This is an internal class.  No stability guarantee is made.
+class DescribePreparedStatement(Describe):
+    def __init__(self, name):
+        Describe.__init__(self, "S", name)
+
+    def __repr__(self):
+        return "<DescribePreparedStatement %r>" % (self.name)
+
+
+##
+# A Flush message forces the backend to deliver any data pending in its
+# output buffers.
+# <p>
+# Stability: This is an internal class.  No stability guarantee is made.
+class Flush(object):
+    # Byte1('H') - Identifies the message as a flush command.
+    # Int32(4) - Length of message, including self.
+    def serialize(self):
+        return 'H\x00\x00\x00\x04'
+
+    def __repr__(self):
+        return "<Flush>"
+
+##
+# Causes the backend to close the current transaction (if not in a BEGIN/COMMIT
+# block), and issue ReadyForQuery.
+# <p>
+# Stability: This is an internal class.  No stability guarantee is made.
+class Sync(object):
+    # Byte1('S') - Identifies the message as a sync command.
+    # Int32(4) - Length of message, including self.
+    def serialize(self):
+        return 'S\x00\x00\x00\x04'
+
+    def __repr__(self):
+        return "<Sync>"
+
+
+##
+# Transmits a password.
+# <p>
+# Stability: This is an internal class.  No stability guarantee is made.
+class PasswordMessage(object):
+    def __init__(self, pwd):
+        self.pwd = pwd
+
+    # Byte1('p') - Identifies the message as a password message.
+    # Int32 - Message length including self.
+    # String - The password.  Password may be encrypted.
+    def serialize(self):
+        val = self.pwd + "\x00"
+        val = struct.pack("!i", len(val) + 4) + val
+        val = "p" + val
+        return val
+
+
+##
+# Requests that the backend execute a portal and retrieve any number of rows.
+# <p>
+# Stability: This is an internal class.  No stability guarantee is made.
+# @param row_count  The number of rows to return.  Can be zero to indicate the
+#                   backend should return all rows. If the portal represents a
+#                   query that does not return rows, no rows will be returned
+#                   no matter what the row_count.
+class Execute(object):
+    def __init__(self, portal, row_count):
+        self.portal = portal
+        self.row_count = row_count
+
+    # Byte1('E') - Identifies the message as an execute message.
+    # Int32 -   Message length, including self.
+    # String -  The name of the portal to execute.
+    # Int32 -   Maximum number of rows to return, if portal contains a query that
+    #           returns rows.  0 = no limit.
+    def serialize(self):
+        val = self.portal + "\x00" + struct.pack("!i", self.row_count)
+        val = struct.pack("!i", len(val) + 4) + val
+        val = "E" + val
+        return val
+
+
+##
+# Informs the backend that the connection is being closed.
+# <p>
+# Stability: This is an internal class.  No stability guarantee is made.
+class Terminate(object):
+    def __init__(self):
+        pass
+
+    # Byte1('X') - Identifies the message as a terminate message.
+    # Int32(4) - Message length, including self.
+    def serialize(self):
+        return 'X\x00\x00\x00\x04'
+
+##
+# Base class of all Authentication[*] messages.
+# <p>
+# Stability: This is an internal class.  No stability guarantee is made.
+class AuthenticationRequest(object):
+    def __init__(self, data):
+        pass
+
+    # Byte1('R') - Identifies the message as an authentication request.
+    # Int32(8) - Message length, including self.
+    # Int32 -   An authentication code that represents different
+    #           authentication messages:
+    #               0 = AuthenticationOk
+    #               5 = MD5 pwd
+    #               2 = Kerberos v5 (not supported by pg8000)
+    #               3 = Cleartext pwd (not supported by pg8000)
+    #               4 = crypt() pwd (not supported by pg8000)
+    #               6 = SCM credential (not supported by pg8000)
+    #               7 = GSSAPI (not supported by pg8000)
+    #               8 = GSSAPI data (not supported by pg8000)
+    #               9 = SSPI (not supported by pg8000)
+    # Some authentication messages have additional data following the
+    # authentication code.  That data is documented in the appropriate class.
+    def createFromData(data):
+        ident = struct.unpack("!i", data[:4])[0]
+        klass = authentication_codes.get(ident, None)
+        if klass != None:
+            return klass(data[4:])
+        else:
+            raise NotSupportedError("authentication method %r not supported" % (ident,))
+    createFromData = staticmethod(createFromData)
+
+    def ok(self, conn, user, **kwargs):
+        raise InternalError("ok method should be overridden on AuthenticationRequest instance")
+
+##
+# A message representing that the backend accepting the provided username
+# without any challenge.
+# <p>
+# Stability: This is an internal class.  No stability guarantee is made.
+class AuthenticationOk(AuthenticationRequest):
+    def ok(self, conn, user, **kwargs):
+        return True
+
+
+##
+# A message representing the backend requesting an MD5 hashed password
+# response.  The response will be sent as md5(md5(pwd + login) + salt).
+# <p>
+# Stability: This is an internal class.  No stability guarantee is made.
+class AuthenticationMD5Password(AuthenticationRequest):
+    # Additional message data:
+    #  Byte4 - Hash salt.
+    def __init__(self, data):
+        self.salt = "".join(struct.unpack("4c", data))
+
+    def ok(self, conn, user, password=None, **kwargs):
+        if password == None:
+            raise InterfaceError("server requesting MD5 password authentication, but no password was provided")
+        pwd = "md5" + hashlib.md5(hashlib.md5(password + user).hexdigest() + self.salt).hexdigest()
+        conn._send(PasswordMessage(pwd))
+        conn._flush()
+
+        reader = MessageReader(conn)
+        reader.add_message(AuthenticationRequest, lambda msg, reader: reader.return_value(msg.ok(conn, user)), reader)
+        reader.add_message(ErrorResponse, self._ok_error)
+        return reader.handle_messages()
+
+    def _ok_error(self, msg):
+        if msg.code == "28000":
+            raise InterfaceError("md5 password authentication failed")
+        else:
+            raise msg.createException()
+
+authentication_codes = {
+    0: AuthenticationOk,
+    5: AuthenticationMD5Password,
+}
+
+
+##
+# ParameterStatus message sent from backend, used to inform the frotnend of
+# runtime configuration parameter changes.
+# <p>
+# Stability: This is an internal class.  No stability guarantee is made.
+class ParameterStatus(object):
+    def __init__(self, key, value):
+        self.key = key
+        self.value = value
+
+    # Byte1('S') - Identifies ParameterStatus
+    # Int32 - Message length, including self.
+    # String - Runtime parameter name.
+    # String - Runtime parameter value.
+    def createFromData(data):
+        key = data[:data.find("\x00")]
+        value = data[data.find("\x00")+1:-1]
+        return ParameterStatus(key, value)
+    createFromData = staticmethod(createFromData)
+
+
+##
+# BackendKeyData message sent from backend.  Contains a connection's process
+# ID and a secret key.  Can be used to terminate the connection's current
+# actions, such as a long running query.  Not supported by pg8000 yet.
+# <p>
+# Stability: This is an internal class.  No stability guarantee is made.
+class BackendKeyData(object):
+    def __init__(self, process_id, secret_key):
+        self.process_id = process_id
+        self.secret_key = secret_key
+
+    # Byte1('K') - Identifier.
+    # Int32(12) - Message length, including self.
+    # Int32 - Process ID.
+    # Int32 - Secret key.
+    def createFromData(data):
+        process_id, secret_key = struct.unpack("!2i", data)
+        return BackendKeyData(process_id, secret_key)
+    createFromData = staticmethod(createFromData)
+
+
+##
+# Message representing a query with no data.
+# <p>
+# Stability: This is an internal class.  No stability guarantee is made.
+class NoData(object):
+    # Byte1('n') - Identifier.
+    # Int32(4) - Message length, including self.
+    def createFromData(data):
+        return NoData()
+    createFromData = staticmethod(createFromData)
+
+
+##
+# Message representing a successful Parse.
+# <p>
+# Stability: This is an internal class.  No stability guarantee is made.
+class ParseComplete(object):
+    # Byte1('1') - Identifier.
+    # Int32(4) - Message length, including self.
+    def createFromData(data):
+        return ParseComplete()
+    createFromData = staticmethod(createFromData)
+
+
+##
+# Message representing a successful Bind.
+# <p>
+# Stability: This is an internal class.  No stability guarantee is made.
+class BindComplete(object):
+    # Byte1('2') - Identifier.
+    # Int32(4) - Message length, including self.
+    def createFromData(data):
+        return BindComplete()
+    createFromData = staticmethod(createFromData)
+
+
+##
+# Message representing a successful Close.
+# <p>
+# Stability: This is an internal class.  No stability guarantee is made.
+class CloseComplete(object):
+    # Byte1('3') - Identifier.
+    # Int32(4) - Message length, including self.
+    def createFromData(data):
+        return CloseComplete()
+    createFromData = staticmethod(createFromData)
+
+
+##
+# Message representing data from an Execute has been received, but more data
+# exists in the portal.
+# <p>
+# Stability: This is an internal class.  No stability guarantee is made.
+class PortalSuspended(object):
+    # Byte1('s') - Identifier.
+    # Int32(4) - Message length, including self.
+    def createFromData(data):
+        return PortalSuspended()
+    createFromData = staticmethod(createFromData)
+
+
+##
+# Message representing the backend is ready to process a new query.
+# <p>
+# Stability: This is an internal class.  No stability guarantee is made.
+class ReadyForQuery(object):
+    def __init__(self, status):
+        self._status = status
+
+    ##
+    # I = Idle, T = Idle in Transaction, E = idle in failed transaction.
+    status = property(lambda self: self._status)
+
+    def __repr__(self):
+        return "<ReadyForQuery %s>" % \
+                {"I": "Idle", "T": "Idle in Transaction", "E": "Idle in Failed Transaction"}[self.status]
+
+    # Byte1('Z') - Identifier.
+    # Int32(5) - Message length, including self.
+    # Byte1 -   Status indicator.
+    def createFromData(data):
+        return ReadyForQuery(data)
+    createFromData = staticmethod(createFromData)
+
+
+##
+# Represents a notice sent from the server.  This is not the same as a
+# notification.  A notice is just additional information about a query, such
+# as a notice that a primary key has automatically been created for a table.
+# <p>
+# A NoticeResponse instance will have properties containing the data sent
+# from the server:
+# <ul>
+# <li>severity -- "ERROR", "FATAL', "PANIC", "WARNING", "NOTICE", "DEBUG",
+# "INFO", or "LOG".  Always present.</li>
+# <li>code -- the SQLSTATE code for the error.  See Appendix A of the
+# PostgreSQL documentation for specific error codes.  Always present.</li>
+# <li>msg -- human-readable error message.  Always present.</li>
+# <li>detail -- Optional additional information.</li>
+# <li>hint -- Optional suggestion about what to do about the issue.</li>
+# <li>position -- Optional index into the query string.</li>
+# <li>where -- Optional context.</li>
+# <li>file -- Source-code file.</li>
+# <li>line -- Source-code line.</li>
+# <li>routine -- Source-code routine.</li>
+# </ul>
+# <p>
+# Stability: Added in pg8000 v1.03.  Required properties severity, code, and
+# msg are guaranteed for v1.xx.  Other properties should be checked with
+# hasattr before accessing.
+class NoticeResponse(object):
+    responseKeys = {
+        "S": "severity",  # always present
+        "C": "code",      # always present
+        "M": "msg",       # always present
+        "D": "detail",
+        "H": "hint",
+        "P": "position",
+        "p": "_position",
+        "q": "_query",
+        "W": "where",
+        "F": "file",
+        "L": "line",
+        "R": "routine",
+    }
+
+    def __init__(self, **kwargs):
+        for arg, value in kwargs.items():
+            setattr(self, arg, value)
+
+    def __repr__(self):
+        return "<NoticeResponse %s %s %r>" % (self.severity, self.code, self.msg)
+
+    def dataIntoDict(data):
+        retval = {}
+        for s in data.split("\x00"):
+            if not s: continue
+            key, value = s[0], s[1:]
+            key = NoticeResponse.responseKeys.get(key, key)
+            retval[key] = value
+        return retval
+    dataIntoDict = staticmethod(dataIntoDict)
+
+    # Byte1('N') - Identifier
+    # Int32 - Message length
+    # Any number of these, followed by a zero byte:
+    #   Byte1 - code identifying the field type (see responseKeys)
+    #   String - field value
+    def createFromData(data):
+        return NoticeResponse(**NoticeResponse.dataIntoDict(data))
+    createFromData = staticmethod(createFromData)
+
+
+##
+# A message sent in case of a server-side error.  Contains the same properties
+# that {@link NoticeResponse NoticeResponse} contains.
+# <p>
+# Stability: Added in pg8000 v1.03.  Required properties severity, code, and
+# msg are guaranteed for v1.xx.  Other properties should be checked with
+# hasattr before accessing.
+class ErrorResponse(object):
+    def __init__(self, **kwargs):
+        for arg, value in kwargs.items():
+            setattr(self, arg, value)
+
+    def __repr__(self):
+        return "<ErrorResponse %s %s %r>" % (self.severity, self.code, self.msg)
+
+    def createException(self):
+        return ProgrammingError(self.severity, self.code, self.msg)
+
+    def createFromData(data):
+        return ErrorResponse(**NoticeResponse.dataIntoDict(data))
+    createFromData = staticmethod(createFromData)
+
+
+##
+# A message sent if this connection receives a NOTIFY that it was LISTENing for.
+# <p>
+# Stability: Added in pg8000 v1.03.  When limited to accessing properties from
+# a notification event dispatch, stability is guaranteed for v1.xx.
+class NotificationResponse(object):
+    def __init__(self, backend_pid, condition, additional_info):
+        self._backend_pid = backend_pid
+        self._condition = condition
+        self._additional_info = additional_info
+
+    ##
+    # An integer representing the process ID of the backend that triggered
+    # the NOTIFY.
+    # <p>
+    # Stability: Added in pg8000 v1.03, stability guaranteed for v1.xx.
+    backend_pid = property(lambda self: self._backend_pid)
+
+    ##
+    # The name of the notification fired.
+    # <p>
+    # Stability: Added in pg8000 v1.03, stability guaranteed for v1.xx.
+    condition = property(lambda self: self._condition)
+
+    ##
+    # Currently unspecified by the PostgreSQL documentation as of v8.3.1.
+    # <p>
+    # Stability: Added in pg8000 v1.03, stability guaranteed for v1.xx.
+    additional_info = property(lambda self: self._additional_info)
+
+    def __repr__(self):
+        return "<NotificationResponse %s %s %r>" % (self.backend_pid, self.condition, self.additional_info)
+
+    def createFromData(data):
+        backend_pid = struct.unpack("!i", data[:4])[0]
+        data = data[4:]
+        null = data.find("\x00")
+        condition = data[:null]
+        data = data[null+1:]
+        null = data.find("\x00")
+        additional_info = data[:null]
+        return NotificationResponse(backend_pid, condition, additional_info)
+    createFromData = staticmethod(createFromData)
+
+
+class ParameterDescription(object):
+    def __init__(self, type_oids):
+        self.type_oids = type_oids
+    def createFromData(data):
+        count = struct.unpack("!h", data[:2])[0]
+        type_oids = struct.unpack("!" + "i"*count, data[2:])
+        return ParameterDescription(type_oids)
+    createFromData = staticmethod(createFromData)
+
+
+class RowDescription(object):
+    def __init__(self, fields):
+        self.fields = fields
+
+    def createFromData(data):
+        count = struct.unpack("!h", data[:2])[0]
+        data = data[2:]
+        fields = []
+        for i in range(count):
+            null = data.find("\x00")
+            field = {"name": data[:null]}
+            data = data[null+1:]
+            field["table_oid"], field["column_attrnum"], field["type_oid"], field["type_size"], field["type_modifier"], field["format"] = struct.unpack("!ihihih", data[:18])
+            data = data[18:]
+            fields.append(field)
+        return RowDescription(fields)
+    createFromData = staticmethod(createFromData)
+
+class CommandComplete(object):
+    def __init__(self, command, rows=None, oid=None):
+        self.command = command
+        self.rows = rows
+        self.oid = oid
+
+    def createFromData(data):
+        values = data[:-1].split(" ")
+        args = {}
+        args['command'] = values[0]
+        if args['command'] in ("INSERT", "DELETE", "UPDATE", "MOVE", "FETCH", "COPY"):
+            args['rows'] = int(values[-1])
+            if args['command'] == "INSERT":
+                args['oid'] = int(values[1])
+        else:
+            args['command'] = data[:-1]
+        return CommandComplete(**args)
+    createFromData = staticmethod(createFromData)
+
+
+class DataRow(object):
+    def __init__(self, fields):
+        self.fields = fields
+
+    def createFromData(data):
+        count = struct.unpack("!h", data[:2])[0]
+        data = data[2:]
+        fields = []
+        for i in range(count):
+            val_len = struct.unpack("!i", data[:4])[0]
+            data = data[4:]
+            if val_len == -1:
+                fields.append(None)
+            else:
+                fields.append(data[:val_len])
+                data = data[val_len:]
+        return DataRow(fields)
+    createFromData = staticmethod(createFromData)
+
+
+class CopyData(object):
+    # "d": CopyData,
+    def __init__(self, data):
+        self.data = data
+
+    def createFromData(data):
+        return CopyData(data)
+    createFromData = staticmethod(createFromData)
+    
+    def serialize(self):
+        return 'd' + struct.pack('!i', len(self.data) + 4) + self.data
+
+
+class CopyDone(object):
+    # Byte1('c') - Identifier.
+    # Int32(4) - Message length, including self.
+
+    def createFromData(data):
+        return CopyDone()
+
+    createFromData = staticmethod(createFromData)
+    
+    def serialize(self):
+        return 'c\x00\x00\x00\x04'
+
+class CopyOutResponse(object):
+    # Byte1('H')
+    # Int32(4) - Length of message contents in bytes, including self.
+    # Int8(1) - 0 textual, 1 binary
+    # Int16(2) - Number of columns
+    # Int16(N) - Format codes for each column (0 text, 1 binary)
+
+    def __init__(self, is_binary, column_formats):
+        self.is_binary = is_binary
+        self.column_formats = column_formats
+    
+    def createFromData(data):
+        is_binary, num_cols = struct.unpack('!bh', data[:3])
+        column_formats = struct.unpack('!' + ('h' * num_cols), data[3:])
+        return CopyOutResponse(is_binary, column_formats)
+
+    createFromData = staticmethod(createFromData)
+
+
+class CopyInResponse(object):
+    # Byte1('G')
+    # Otherwise the same as CopyOutResponse
+    
+    def __init__(self, is_binary, column_formats):
+        self.is_binary = is_binary
+        self.column_formats = column_formats
+    
+    def createFromData(data):
+        is_binary, num_cols = struct.unpack('!bh', data[:3])
+        column_formats = struct.unpack('!' + ('h' * num_cols), data[3:])
+        return CopyInResponse(is_binary, column_formats)
+
+    createFromData = staticmethod(createFromData)
+
+class SSLWrapper(object):
+    def __init__(self, sslobj):
+        self.sslobj = sslobj
+    def send(self, data):
+        self.sslobj.write(data)
+    def recv(self, num):
+        return self.sslobj.read(num)
+
+
+class MessageReader(object):
+    def __init__(self, connection):
+        self._conn = connection
+        self._msgs = []
+
+        # If true, raise exception from an ErrorResponse after messages are
+        # processed.  This can be used to leave the connection in a usable
+        # state after an error response, rather than having unconsumed
+        # messages that won't be understood in another context.
+        self.delay_raising_exception = False
+
+        self.ignore_unhandled_messages = False
+
+    def add_message(self, msg_class, handler, *args, **kwargs):
+        self._msgs.append((msg_class, handler, args, kwargs))
+
+    def clear_messages(self):
+        self._msgs = []
+
+    def return_value(self, value):
+        self._retval = value
+    
+    def handle_messages(self):
+        exc = None
+        while 1:
+            msg = self._conn._read_message()
+            msg_handled = False
+            for (msg_class, handler, args, kwargs) in self._msgs:
+                if isinstance(msg, msg_class):
+                    msg_handled = True
+                    retval = handler(msg, *args, **kwargs)
+                    if retval:
+                        # The handler returned a true value, meaning that the
+                        # message loop should be aborted.
+                        if exc != None:
+                            raise exc
+                        return retval
+                    elif hasattr(self, "_retval"):
+                        # The handler told us to return -- used for non-true
+                        # return values
+                        if exc != None:
+                            raise exc
+                        return self._retval
+            if msg_handled:
+                continue
+            elif isinstance(msg, ErrorResponse):
+                exc = msg.createException()
+                if not self.delay_raising_exception:
+                    raise exc
+            elif isinstance(msg, NoticeResponse):
+                self._conn.handleNoticeResponse(msg)
+            elif isinstance(msg, ParameterStatus):
+                self._conn.handleParameterStatus(msg)
+            elif isinstance(msg, NotificationResponse):
+                self._conn.handleNotificationResponse(msg)
+            elif not self.ignore_unhandled_messages:
+                raise InternalError("Unexpected response msg %r" % (msg))
+
+def sync_on_error(fn):
+    def _fn(self, *args, **kwargs):
+        try:
+            self._sock_lock.acquire()
+            return fn(self, *args, **kwargs)
+        except:
+            self._sync()
+            raise
+        finally:
+            self._sock_lock.release()
+    return _fn
+
+class Connection(object):
+    def __init__(self, unix_sock=None, host=None, port=5432, socket_timeout=60, ssl=False, records=False):
+        self._client_encoding = "ascii"
+        self._integer_datetimes = False
+        self._record_field_names = {}
+        self._sock_buf = ""
+        self._sock_buf_pos = 0
+        self._send_sock_buf = []
+        self._block_size = 8192
+        self.user_wants_records = records
+        if unix_sock == None and host != None:
+            self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+        elif unix_sock != None:
+            if not hasattr(socket, "AF_UNIX"):
+                raise InterfaceError("attempt to connect to unix socket on unsupported platform")
+            self._sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+        else:
+            raise ProgrammingError("one of host or unix_sock must be provided")
+        if unix_sock == None and host != None:
+            self._sock.connect((host, port))
+        elif unix_sock != None:
+            self._sock.connect(unix_sock)
+        if ssl:
+            self._send(SSLRequest())
+            self._flush()
+            resp = self._sock.recv(1)
+            if resp == 'S':
+                self._sock = SSLWrapper(socket.ssl(self._sock))
+            else:
+                raise InterfaceError("server refuses SSL")
+        else:
+            # settimeout causes ssl failure, on windows.  Python bug 1462352.
+            self._sock.settimeout(socket_timeout)
+        self._state = "noauth"
+        self._backend_key_data = None
+        self._sock_lock = threading.Lock()
+
+        self.NoticeReceived = MulticastDelegate()
+        self.ParameterStatusReceived = MulticastDelegate()
+        self.NotificationReceived = MulticastDelegate()
+
+        self.ParameterStatusReceived += self._onParameterStatusReceived
+
+    def verifyState(self, state):
+        if self._state != state:
+            raise InternalError("connection state must be %s, is %s" % (state, self._state))
+
+    def _send(self, msg):
+        assert self._sock_lock.locked()
+        #print "_send(%r)" % msg
+        data = msg.serialize()
+        self._send_sock_buf.append(data)
+    
+    def _flush(self):
+        assert self._sock_lock.locked()
+        self._sock.sendall("".join(self._send_sock_buf))
+        del self._send_sock_buf[:]
+
+    def _read_bytes(self, byte_count):
+        retval = []
+        bytes_read = 0
+        while bytes_read < byte_count:
+            if self._sock_buf_pos == len(self._sock_buf):
+                self._sock_buf = self._sock.recv(1024)
+                self._sock_buf_pos = 0
+            rpos = min(len(self._sock_buf), self._sock_buf_pos + (byte_count - bytes_read))
+            addt_data = self._sock_buf[self._sock_buf_pos:rpos]
+            bytes_read += (rpos - self._sock_buf_pos)
+            assert bytes_read <= byte_count
+            self._sock_buf_pos = rpos
+            retval.append(addt_data)
+        return "".join(retval)
+
+    def _read_message(self):
+        assert self._sock_lock.locked()
+        bytes = self._read_bytes(5)
+        message_code = bytes[0]
+        data_len = struct.unpack("!i", bytes[1:])[0] - 4
+        bytes = self._read_bytes(data_len)
+        assert len(bytes) == data_len
+        msg = message_types[message_code].createFromData(bytes)
+        #print "_read_message() -> %r" % msg
+        return msg
+
+    def authenticate(self, user, **kwargs):
+        self.verifyState("noauth")
+        self._sock_lock.acquire()
+        try:
+            self._send(StartupMessage(user, database=kwargs.get("database",None), options=kwargs.get("options", None)))
+            self._flush()
+            msg = self._read_message()
+            if isinstance(msg, ErrorResponse):
+                raise msg.createException()
+            if not isinstance(msg, AuthenticationRequest):
+                raise InternalError("StartupMessage was responded to with non-AuthenticationRequest msg %r" % msg)
+            if not msg.ok(self, user, **kwargs):
+                raise InterfaceError("authentication method %s failed" % msg.__class__.__name__)
+
+            self._state = "auth"
+
+            reader = MessageReader(self)
+            reader.add_message(ReadyForQuery, self._ready_for_query)
+            reader.add_message(BackendKeyData, self._receive_backend_key_data)
+            reader.handle_messages()
+        finally:
+            self._sock_lock.release()
+
+        self._cache_record_attnames()
+
+    def _ready_for_query(self, msg):
+        self._state = "ready"
+        return True
+
+    def _receive_backend_key_data(self, msg):
+        self._backend_key_data = msg
+
+    def _cache_record_attnames(self):
+        if not self.user_wants_records:
+            return
+
+        parse_retval = self.parse("",
+            """SELECT
+                pg_type.oid, attname
+            FROM
+                pg_type
+                INNER JOIN pg_attribute ON (attrelid = pg_type.typrelid)
+                                  WHERE typreceive = 'record_recv'::regproc
+            ORDER BY pg_type.oid, attnum""",
+            [])
+        row_desc, cmd = self.bind("tmp", "", (), parse_retval, None)
+        eod, rows = self.fetch_rows("tmp", 0, row_desc)
+
+        self._record_field_names = {}
+        typoid, attnames = None, []
+        for row in rows:
+            new_typoid, attname = row
+            if new_typoid != typoid and typoid != None:
+                self._record_field_names[typoid] = attnames
+                attnames = []
+            typoid = new_typoid
+            attnames.append(attname)
+        self._record_field_names[typoid] = attnames
+
+    @sync_on_error
+    def parse(self, statement, qs, param_types):
+        self.verifyState("ready")
+
+        type_info = [types.pg_type_info(x) for x in param_types]
+        param_types, param_fc = [x[0] for x in type_info], [x[1] for x in type_info] # zip(*type_info) -- fails on empty arr
+        self._send(Parse(statement, qs, param_types))
+        self._send(DescribePreparedStatement(statement))
+        self._send(Flush())
+        self._flush()
+
+        reader = MessageReader(self)
+
+        # ParseComplete is good.
+        reader.add_message(ParseComplete, lambda msg: 0)
+
+        # Well, we don't really care -- we're going to send whatever we
+        # want and let the database deal with it.  But thanks anyways!
+        reader.add_message(ParameterDescription, lambda msg: 0)
+
+        # We're not waiting for a row description.  Return something
+        # destinctive to let bind know that there is no output.
+        reader.add_message(NoData, lambda msg: (None, param_fc))
+
+        # Common row description response
+        reader.add_message(RowDescription, lambda msg: (msg, param_fc))
+
+        return reader.handle_messages()
+
+    @sync_on_error
+    def bind(self, portal, statement, params, parse_data, copy_stream):
+        self.verifyState("ready")
+
+        row_desc, param_fc = parse_data
+        if row_desc == None:
+            # no data coming out
+            output_fc = ()
+        else:
+            # We've got row_desc that allows us to identify what we're going to
+            # get back from this statement.
+            output_fc = [types.py_type_info(f, self._record_field_names) for f in row_desc.fields]
+        self._send(Bind(portal, statement, param_fc, params, output_fc, client_encoding = self._client_encoding, integer_datetimes = self._integer_datetimes))
+        # We need to describe the portal after bind, since the return
+        # format codes will be different (hopefully, always what we
+        # requested).
+        self._send(DescribePortal(portal))
+        self._send(Flush())
+        self._flush()
+
+        # Read responses from server...
+        reader = MessageReader(self)
+
+        # BindComplete is good -- just ignore
+        reader.add_message(BindComplete, lambda msg: 0)
+
+        # NoData in this case means we're not executing a query.  As a
+        # result, we won't be fetching rows, so we'll never execute the
+        # portal we just created... unless we execute it right away, which
+        # we'll do.
+        reader.add_message(NoData, self._bind_nodata, portal, reader, copy_stream)
+
+        # Return the new row desc, since it will have the format types we
+        # asked the server for
+        reader.add_message(RowDescription, lambda msg: (msg, None))
+
+        return reader.handle_messages()
+
+    def _copy_in_response(self, copyin, fileobj, old_reader):
+        if fileobj == None:
+            raise CopyQueryWithoutStreamError()
+        while True:
+            data = fileobj.read(self._block_size)
+            if not data:
+                break
+            self._send(CopyData(data))
+            self._flush()
+        self._send(CopyDone())
+        self._send(Sync())
+        self._flush()
+
+    def _copy_out_response(self, copyout, fileobj, old_reader):
+        if fileobj == None:
+            raise CopyQueryWithoutStreamError()
+        reader = MessageReader(self)
+        reader.add_message(CopyData, self._copy_data, fileobj)
+        reader.add_message(CopyDone, lambda msg: 1)
+        reader.handle_messages()
+
+    def _copy_data(self, copydata, fileobj):
+        fileobj.write(copydata.data)
+
+    def _bind_nodata(self, msg, portal, old_reader, copy_stream):
+        # Bind message returned NoData, causing us to execute the command.
+        self._send(Execute(portal, 0))
+        self._send(Sync())
+        self._flush()
+
+        output = {}
+        reader = MessageReader(self)
+        reader.add_message(CopyOutResponse, self._copy_out_response, copy_stream, reader)
+        reader.add_message(CopyInResponse, self._copy_in_response, copy_stream, reader)
+        reader.add_message(CommandComplete, lambda msg, out: out.setdefault('msg', msg) and False, output)
+        reader.add_message(ReadyForQuery, lambda msg: 1)
+        reader.delay_raising_exception = True
+        reader.handle_messages()
+
+        old_reader.return_value((None, output['msg']))
+
+    @sync_on_error
+    def fetch_rows(self, portal, row_count, row_desc):
+        self.verifyState("ready")
+
+        self._send(Execute(portal, row_count))
+        self._send(Flush())
+        self._flush()
+        rows = []
+
+        reader = MessageReader(self)
+        reader.add_message(DataRow, self._fetch_datarow, rows, row_desc)
+        reader.add_message(PortalSuspended, lambda msg: 1)
+        reader.add_message(CommandComplete, self._fetch_commandcomplete, portal)
+        retval = reader.handle_messages()
+
+        # retval = 2 when command complete, indicating that we've hit the
+        # end of the available data for this command
+        return (retval == 2), rows
+
+    def _fetch_datarow(self, msg, rows, row_desc):
+        rows.append(
+            [
+                types.py_value(
+                    msg.fields[i],
+                    row_desc.fields[i],
+                    client_encoding=self._client_encoding,
+                    integer_datetimes=self._integer_datetimes,
+                    record_field_names=self._record_field_names
+                )
+                for i in range(len(msg.fields))
+            ]
+        )
+
+    def _fetch_commandcomplete(self, msg, portal):
+        self._send(ClosePortal(portal))
+        self._send(Sync())
+        self._flush()
+
+        reader = MessageReader(self)
+        reader.add_message(ReadyForQuery, self._fetch_commandcomplete_rfq)
+        reader.add_message(CloseComplete, lambda msg: False)
+        reader.handle_messages()
+
+        return 2  # signal end-of-data
+
+    def _fetch_commandcomplete_rfq(self, msg):
+        self._state = "ready"
+        return True
+
+    # Send a Sync message, then read and discard all messages until we
+    # receive a ReadyForQuery message.
+    def _sync(self):
+        # it is assumed _sync is called from sync_on_error, which holds
+        # a _sock_lock throughout the call
+        self._send(Sync())
+        self._flush()
+        reader = MessageReader(self)
+        reader.ignore_unhandled_messages = True
+        reader.add_message(ReadyForQuery, lambda msg: True)
+        reader.handle_messages()
+
+    def close_statement(self, statement):
+        if self._state == "closed":
+            return
+        self.verifyState("ready")
+        self._sock_lock.acquire()
+        try:
+            self._send(ClosePreparedStatement(statement))
+            self._send(Sync())
+            self._flush()
+
+            reader = MessageReader(self)
+            reader.add_message(CloseComplete, lambda msg: 0)
+            reader.add_message(ReadyForQuery, lambda msg: 1)
+            reader.handle_messages()
+        finally:
+            self._sock_lock.release()
+
+    def close_portal(self, portal):
+        if self._state == "closed":
+            return
+        self.verifyState("ready")
+        self._sock_lock.acquire()
+        try:
+            self._send(ClosePortal(portal))
+            self._send(Sync())
+            self._flush()
+
+            reader = MessageReader(self)
+            reader.add_message(CloseComplete, lambda msg: 0)
+            reader.add_message(ReadyForQuery, lambda msg: 1)
+            reader.handle_messages()
+        finally:
+            self._sock_lock.release()
+
+    def close(self):
+        self._sock_lock.acquire()
+        try:
+            self._send(Terminate())
+            self._flush()
+            self._sock.close()
+            self._state = "closed"
+        finally:
+            self._sock_lock.release()
+
+    def _onParameterStatusReceived(self, msg):
+        if msg.key == "client_encoding":
+            self._client_encoding = msg.value
+        elif msg.key == "integer_datetimes":
+            self._integer_datetimes = (msg.value == "on")
+
+    def handleNoticeResponse(self, msg):
+        self.NoticeReceived(msg)
+
+    def handleParameterStatus(self, msg):
+        self.ParameterStatusReceived(msg)
+
+    def handleNotificationResponse(self, msg):
+        self.NotificationReceived(msg)
+
+    def fileno(self):
+        # This should be safe to do without a lock
+        return self._sock.fileno()
+    
+    def isready(self):
+        self._sock_lock.acquire()
+        try:
+            rlst, _wlst, _xlst = select.select([self], [], [], 0)
+            if not rlst:
+                return False
+                
+            self._sync()
+            return True
+        finally:
+            self._sock_lock.release()
+
+message_types = {
+    "N": NoticeResponse,
+    "R": AuthenticationRequest,
+    "S": ParameterStatus,
+    "K": BackendKeyData,
+    "Z": ReadyForQuery,
+    "T": RowDescription,
+    "E": ErrorResponse,
+    "D": DataRow,
+    "C": CommandComplete,
+    "1": ParseComplete,
+    "2": BindComplete,
+    "3": CloseComplete,
+    "s": PortalSuspended,
+    "n": NoData,
+    "t": ParameterDescription,
+    "A": NotificationResponse,
+    "c": CopyDone,
+    "d": CopyData,
+    "G": CopyInResponse,
+    "H": CopyOutResponse,
+    }
+
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/pg8000/types.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/pg8000/types.py b/tools/bin/ext/pg8000/types.py
new file mode 100644
index 0000000..c622a7d
--- /dev/null
+++ b/tools/bin/ext/pg8000/types.py
@@ -0,0 +1,687 @@
+# vim: sw=4:expandtab:foldmethod=marker
+#
+# Copyright (c) 2007-2009, Mathieu Fenniak
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+# * The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+__author__ = "Mathieu Fenniak"
+
+import datetime
+import decimal
+import struct
+import math
+from errors import (NotSupportedError, ArrayDataParseError, InternalError,
+        ArrayContentEmptyError, ArrayContentNotHomogenousError,
+        ArrayContentNotSupportedError, ArrayDimensionsNotConsistentError)
+
+try:
+    from pytz import utc
+except ImportError:
+    ZERO = datetime.timedelta(0)
+    class UTC(datetime.tzinfo):
+        def utcoffset(self, dt):
+            return ZERO
+        def tzname(self, dt):
+            return "UTC"
+        def dst(self, dt):
+            return ZERO
+    utc = UTC()
+
+class Bytea(str):
+    pass
+
+class Interval(object):
+    def __init__(self, microseconds=0, days=0, months=0):
+        self.microseconds = microseconds
+        self.days = days
+        self.months = months
+
+    def _setMicroseconds(self, value):
+        if not isinstance(value, int) and not isinstance(value, long):
+            raise TypeError("microseconds must be an int or long")
+        elif not (min_int8 < value < max_int8):
+            raise OverflowError("microseconds must be representable as a 64-bit integer")
+        else:
+            self._microseconds = value
+
+    def _setDays(self, value):
+        if not isinstance(value, int) and not isinstance(value, long):
+            raise TypeError("days must be an int or long")
+        elif not (min_int4 < value < max_int4):
+            raise OverflowError("days must be representable as a 32-bit integer")
+        else:
+            self._days = value
+
+    def _setMonths(self, value):
+        if not isinstance(value, int) and not isinstance(value, long):
+            raise TypeError("months must be an int or long")
+        elif not (min_int4 < value < max_int4):
+            raise OverflowError("months must be representable as a 32-bit integer")
+        else:
+            self._months = value
+
+    microseconds = property(lambda self: self._microseconds, _setMicroseconds)
+    days = property(lambda self: self._days, _setDays)
+    months = property(lambda self: self._months, _setMonths)
+
+    def __repr__(self):
+        return "<Interval %s months %s days %s microseconds>" % (self.months, self.days, self.microseconds)
+
+    def __cmp__(self, other):
+        if other == None: return -1
+        c = cmp(self.months, other.months)
+        if c != 0: return c
+        c = cmp(self.days, other.days)
+        if c != 0: return c
+        return cmp(self.microseconds, other.microseconds)
+
+def pg_type_info(typ):
+    value = None
+    if isinstance(typ, dict):
+        value = typ["value"]
+        typ = typ["type"]
+
+    data = py_types.get(typ)
+    if data == None:
+        raise NotSupportedError("type %r not mapped to pg type" % typ)
+
+    # permit the type data to be determined by the value, if provided
+    inspect_func = data.get("inspect")
+    if value != None and inspect_func != None:
+        data = inspect_func(value)
+
+    type_oid = data.get("typeoid")
+    if type_oid == None:
+        raise InternalError("type %r has no type_oid" % typ)
+    elif type_oid == -1:
+        # special case: NULL values
+        return type_oid, 0
+
+    # prefer bin, but go with whatever exists
+    if data.get("bin_out"):
+        format = 1
+    elif data.get("txt_out"):
+        format = 0
+    else:
+        raise InternalError("no conversion fuction for type %r" % typ)
+
+    return type_oid, format
+
+def pg_value(value, fc, **kwargs):
+    typ = type(value)
+    data = py_types.get(typ)
+    if data == None:
+        raise NotSupportedError("type %r not mapped to pg type" % typ)
+
+    # permit the type conversion to be determined by the value, if provided
+    inspect_func = data.get("inspect")
+    if value != None and inspect_func != None:
+        data = inspect_func(value)
+
+    # special case: NULL values
+    if data.get("typeoid") == -1:
+        return None
+
+    if fc == 0:
+        func = data.get("txt_out")
+    elif fc == 1:
+        func = data.get("bin_out")
+    else:
+        raise InternalError("unrecognized format code %r" % fc)
+    if func == None:
+        raise NotSupportedError("type %r, format code %r not supported" % (typ, fc))
+    return func(value, **kwargs)
+
+def py_type_info(description, record_field_names):
+    type_oid = description['type_oid']
+    data = pg_types.get(type_oid)
+    if data == None:
+        record_data = record_field_names.get(type_oid)
+        if record_data != None:
+            # records are in bin format
+            return 1
+        raise NotSupportedError("type oid %r not mapped to py type" % type_oid)
+    # prefer bin, but go with whatever exists
+    if data.get("bin_in"):
+        format = 1
+    elif data.get("txt_in"):
+        format = 0
+    else:
+        raise InternalError("no conversion fuction for type oid %r" % type_oid)
+    return format
+
+def py_value(v, description, record_field_names, **kwargs):
+    if v == None:
+        # special case - NULL value
+        return None
+    type_oid = description['type_oid']
+    format = description['format']
+    data = pg_types.get(type_oid)
+    if data == None:
+        record_data = record_field_names.get(type_oid)
+        if record_data != None:
+            data = {"bin_in": record_recv(record_data)}
+    if data == None:
+        raise NotSupportedError("type oid %r not supported" % type_oid)
+    if format == 0:
+        func = data.get("txt_in")
+    elif format == 1:
+        func = data.get("bin_in")
+    else:
+        raise NotSupportedError("format code %r not supported" % format)
+    if func == None:
+        raise NotSupportedError("data response format %r, type %r not supported" % (format, type_oid))
+    return func(v, **kwargs)
+
+def voidrecv(data, **kwargs):
+    return None
+
+def voidsend(v, **kwargs):
+    return None
+
+def boolrecv(data, **kwargs):
+    return data == "\x01"
+
+def boolsend(v, **kwargs):
+    if v:
+        return "\x01"
+    else:
+        return "\x00"
+
+min_int2, max_int2 = -2 ** 15, 2 ** 15
+min_int4, max_int4 = -2 ** 31, 2 ** 31
+min_int8, max_int8 = -2 ** 63, 2 ** 63
+
+def int_inspect(value):
+    if min_int2 < value < max_int2:
+        return {"typeoid": 21, "bin_out": int2send}
+    elif min_int4 < value < max_int4:
+        return {"typeoid": 23, "bin_out": int4send}
+    elif min_int8 < value < max_int8:
+        return {"typeoid": 20, "bin_out": int8send}
+    else:
+        return {"typeoid": 1700, "bin_out": numeric_send}
+
+def int2recv(data, **kwargs):
+    return struct.unpack("!h", data)[0]
+
+def int2send(v, **kwargs):
+    return struct.pack("!h", v)
+
+def int4recv(data, **kwargs):
+    return struct.unpack("!i", data)[0]
+
+def int4send(v, **kwargs):
+    return struct.pack("!i", v)
+
+def int8recv(data, **kwargs):
+    return struct.unpack("!q", data)[0]
+
+def int8send(v, **kwargs):
+    return struct.pack("!q", v)
+
+def float4recv(data, **kwargs):
+    return struct.unpack("!f", data)[0]
+
+def float8recv(data, **kwargs):
+    return struct.unpack("!d", data)[0]
+
+def float8send(v, **kwargs):
+    return struct.pack("!d", v)
+
+def datetime_inspect(value):
+    if value.tzinfo != None:
+        # send as timestamptz if timezone is provided
+        return {"typeoid": 1184, "bin_out": timestamptz_send}
+    else:
+        # otherwise send as timestamp
+        return {"typeoid": 1114, "bin_out": timestamp_send}
+
+def timestamp_recv(data, integer_datetimes, **kwargs):
+    if integer_datetimes:
+        # data is 64-bit integer representing milliseconds since 2000-01-01
+        val = struct.unpack("!q", data)[0]
+        return datetime.datetime(2000, 1, 1) + datetime.timedelta(microseconds = val)
+    else:
+        # data is double-precision float representing seconds since 2000-01-01
+        val = struct.unpack("!d", data)[0]
+        return datetime.datetime(2000, 1, 1) + datetime.timedelta(seconds = val)
+
+# return a timezone-aware datetime instance if we're reading from a
+# "timestamp with timezone" type.  The timezone returned will always be UTC,
+# but providing that additional information can permit conversion to local.
+def timestamptz_recv(data, **kwargs):
+    return timestamp_recv(data, **kwargs).replace(tzinfo=utc)
+
+def timestamp_send(v, integer_datetimes, **kwargs):
+    delta = v - datetime.datetime(2000, 1, 1)
+    val = delta.microseconds + (delta.seconds * 1000000) + (delta.days * 86400000000)
+    if integer_datetimes:
+        # data is 64-bit integer representing milliseconds since 2000-01-01
+        return struct.pack("!q", val)
+    else:
+        # data is double-precision float representing seconds since 2000-01-01
+        return struct.pack("!d", val / 1000.0 / 1000.0)
+
+def timestamptz_send(v, **kwargs):
+    # timestamps should be sent as UTC.  If they have zone info,
+    # convert them.
+    return timestamp_send(v.astimezone(utc).replace(tzinfo=None), **kwargs)
+
+def date_in(data, **kwargs):
+    year = int(data[0:4])
+    month = int(data[5:7])
+    day = int(data[8:10])
+    return datetime.date(year, month, day)
+
+def date_out(v, **kwargs):
+    return v.isoformat()
+
+def time_in(data, **kwargs):
+    hour = int(data[0:2])
+    minute = int(data[3:5])
+    sec = decimal.Decimal(data[6:])
+    return datetime.time(hour, minute, int(sec), int((sec - int(sec)) * 1000000))
+
+def time_out(v, **kwargs):
+    return v.isoformat()
+
+def numeric_in(data, **kwargs):
+    if data.find(".") == -1:
+        return int(data)
+    else:
+        return decimal.Decimal(data)
+
+def numeric_recv(data, **kwargs):
+    num_digits, weight, sign, scale = struct.unpack("!hhhh", data[:8])
+    data = data[8:]
+    digits = struct.unpack("!" + ("h" * num_digits), data)
+    weight = decimal.Decimal(weight)
+    retval = 0
+    for d in digits:
+        d = decimal.Decimal(d)
+        retval += d * (10000 ** weight)
+        weight -= 1
+    if sign:
+        retval *= -1
+    return retval
+
+def numeric_send(v, **kwargs):
+    sign = 0
+    if v < 0:
+        sign = 16384
+        v *= -1
+    max_weight = decimal.Decimal(int(math.floor(math.log(v) / math.log(10000))))
+    weight = max_weight
+    digits = []
+    while v != 0:
+        digit = int(math.floor(v / (10000 ** weight)))
+        v = v - (digit * (10000 ** weight))
+        weight -= 1
+        digits.append(digit)
+    retval = struct.pack("!hhhh", len(digits), max_weight, sign, 0)
+    retval += struct.pack("!" + ("h" * len(digits)), *digits)
+    return retval
+
+def numeric_out(v, **kwargs):
+    return str(v)
+
+# PostgreSQL encodings:
+#   http://www.postgresql.org/docs/8.3/interactive/multibyte.html
+# Python encodings:
+#   http://www.python.org/doc/2.4/lib/standard-encodings.html
+#
+# Commented out encodings don't require a name change between PostgreSQL and
+# Python.  If the py side is None, then the encoding isn't supported.
+pg_to_py_encodings = {
+    # Not supported:
+    "mule_internal": None,
+    "euc_tw": None,
+
+    # Name fine as-is:
+    #"euc_jp",
+    #"euc_jis_2004",
+    #"euc_kr",
+    #"gb18030",
+    #"gbk",
+    #"johab",
+    #"sjis",
+    #"shift_jis_2004",
+    #"uhc",
+    #"utf8",
+
+    # Different name:
+    "euc_cn": "gb2312",
+    "iso_8859_5": "is8859_5",
+    "iso_8859_6": "is8859_6",
+    "iso_8859_7": "is8859_7",
+    "iso_8859_8": "is8859_8",
+    "koi8": "koi8_r",
+    "latin1": "iso8859-1",
+    "latin2": "iso8859_2",
+    "latin3": "iso8859_3",
+    "latin4": "iso8859_4",
+    "latin5": "iso8859_9",
+    "latin6": "iso8859_10",
+    "latin7": "iso8859_13",
+    "latin8": "iso8859_14",
+    "latin9": "iso8859_15",
+    "sql_ascii": "ascii",
+    "win866": "cp886",
+    "win874": "cp874",
+    "win1250": "cp1250",
+    "win1251": "cp1251",
+    "win1252": "cp1252",
+    "win1253": "cp1253",
+    "win1254": "cp1254",
+    "win1255": "cp1255",
+    "win1256": "cp1256",
+    "win1257": "cp1257",
+    "win1258": "cp1258",
+}
+
+def encoding_convert(encoding):
+    return pg_to_py_encodings.get(encoding.lower(), encoding)
+
+def varcharin(data, client_encoding, **kwargs):
+    return unicode(data, encoding_convert(client_encoding))
+
+def textout(v, client_encoding, **kwargs):
+    return v.encode(encoding_convert(client_encoding))
+
+def byteasend(v, **kwargs):
+    return str(v)
+
+def bytearecv(data, **kwargs):
+    return Bytea(data)
+
+# interval support does not provide a Python-usable interval object yet
+def interval_recv(data, integer_datetimes, **kwargs):
+    if integer_datetimes:
+        microseconds, days, months = struct.unpack("!qii", data)
+    else:
+        seconds, days, months = struct.unpack("!dii", data)
+        microseconds = int(seconds * 1000 * 1000)
+    return Interval(microseconds, days, months)
+
+def interval_send(data, integer_datetimes, **kwargs):
+    if integer_datetimes:
+        return struct.pack("!qii", data.microseconds, data.days, data.months)
+    else:
+        return struct.pack("!dii", data.microseconds / 1000.0 / 1000.0, data.days, data.months)
+
+def array_recv(data, **kwargs):
+    dim, hasnull, typeoid = struct.unpack("!iii", data[:12])
+    data = data[12:]
+
+    # get type conversion method for typeoid
+    conversion = pg_types[typeoid]["bin_in"]
+
+    # Read dimension info
+    dim_lengths = []
+    element_count = 1
+    for idim in range(dim):
+        dim_len, dim_lbound = struct.unpack("!ii", data[:8])
+        data = data[8:]
+        dim_lengths.append(dim_len)
+        element_count *= dim_len
+
+    # Read all array values
+    array_values = []
+    for i in range(element_count):
+        element_len, = struct.unpack("!i", data[:4])
+        data = data[4:]
+        if element_len == -1:
+            array_values.append(None)
+        else:
+            array_values.append(conversion(data[:element_len], **kwargs))
+            data = data[element_len:]
+    if data != "":
+        raise ArrayDataParseError("unexpected data left over after array read")
+
+    # at this point, {{1,2,3},{4,5,6}}::int[][] looks like [1,2,3,4,5,6].
+    # go through the dimensions and fix up the array contents to match
+    # expected dimensions
+    for dim_length in reversed(dim_lengths[1:]):
+        val = []
+        while array_values:
+            val.append(array_values[:dim_length])
+            array_values = array_values[dim_length:]
+        array_values = val
+
+    return array_values
+
+def array_inspect(value):
+    # Check if array has any values.  If not, we can't determine the proper
+    # array typeoid.
+    first_element = array_find_first_element(value)
+    if first_element == None:
+        raise ArrayContentEmptyError("array has no values")
+
+    # supported array output
+    typ = type(first_element)
+    if issubclass(typ, int) or issubclass(typ, long):
+        # special int array support -- send as smallest possible array type
+        special_int_support = True
+        int2_ok, int4_ok, int8_ok = True, True, True
+        for v in array_flatten(value):
+            if v == None:
+                continue
+            if min_int2 < v < max_int2:
+                continue
+            int2_ok = False
+            if min_int4 < v < max_int4:
+                continue
+            int4_ok = False
+            if min_int8 < v < max_int8:
+                continue
+            int8_ok = False
+        if int2_ok:
+            array_typeoid = 1005 # INT2[]
+        elif int4_ok:
+            array_typeoid = 1007 # INT4[]
+        elif int8_ok:
+            array_typeoid = 1016 # INT8[]
+        else:
+            raise ArrayContentNotSupportedError("numeric not supported as array contents")
+    else:
+        special_int_support = False
+        array_typeoid = py_array_types.get(typ)
+        if array_typeoid == None:
+            raise ArrayContentNotSupportedError("type %r not supported as array contents" % typ)
+
+    # check for homogenous array
+    for v in array_flatten(value):
+        if v != None and not (isinstance(v, typ) or (typ == long and isinstance(v, int)) or (typ == int and isinstance(v, long))):
+            raise ArrayContentNotHomogenousError("not all array elements are of type %r" % typ)
+
+    # check that all array dimensions are consistent
+    array_check_dimensions(value)
+
+    type_data = py_types[typ]
+    if special_int_support:
+        if array_typeoid == 1005:
+            type_data = {"typeoid": 21, "bin_out": int2send}
+        elif array_typeoid == 1007:
+            type_data = {"typeoid": 23, "bin_out": int4send}
+        elif array_typeoid == 1016:
+            type_data = {"typeoid": 20, "bin_out": int8send}
+    else:
+        type_data = py_types[typ]
+    return {
+        "typeoid": array_typeoid,
+        "bin_out": array_send(type_data["typeoid"], type_data["bin_out"])
+    }
+
+def array_find_first_element(arr):
+    for v in array_flatten(arr):
+        if v != None:
+            return v
+    return None
+
+def array_flatten(arr):
+    for v in arr:
+        if isinstance(v, list):
+            for v2 in array_flatten(v):
+                yield v2
+        else:
+            yield v
+
+def array_check_dimensions(arr):
+    v0 = arr[0]
+    if isinstance(v0, list):
+        req_len = len(v0)
+        req_inner_lengths = array_check_dimensions(v0)
+        for v in arr:
+            inner_lengths = array_check_dimensions(v)
+            if len(v) != req_len or inner_lengths != req_inner_lengths:
+                raise ArrayDimensionsNotConsistentError("array dimensions not consistent")
+        retval = [req_len]
+        retval.extend(req_inner_lengths)
+        return retval
+    else:
+        # make sure nothing else at this level is a list
+        for v in arr:
+            if isinstance(v, list):
+                raise ArrayDimensionsNotConsistentError("array dimensions not consistent")
+        return []
+
+def array_has_null(arr):
+    for v in array_flatten(arr):
+        if v == None:
+            return True
+    return False
+
+def array_dim_lengths(arr):
+    v0 = arr[0]
+    if isinstance(v0, list):
+        retval = [len(v0)]
+        retval.extend(array_dim_lengths(v0))
+    else:
+        return [len(arr)]
+
+class array_send(object):
+    def __init__(self, typeoid, bin_out_func):
+        self.typeoid = typeoid
+        self.bin_out_func = bin_out_func
+
+    def __call__(self, arr, **kwargs):
+        has_null = array_has_null(arr)
+        dim_lengths = array_dim_lengths(arr)
+        data = struct.pack("!iii", len(dim_lengths), has_null, self.typeoid)
+        for i in dim_lengths:
+            data += struct.pack("!ii", i, 1)
+        for v in array_flatten(arr):
+            if v == None:
+                data += struct.pack("!i", -1)
+            else:
+                inner_data = self.bin_out_func(v, **kwargs)
+                data += struct.pack("!i", len(inner_data))
+                data += inner_data
+        return data
+
+class record_recv(object):
+    def __init__(self, record_field_names):
+        self.record_field_names = record_field_names
+
+    def __call__(self, data, **kwargs):
+        num_fields, = struct.unpack("!i", data[:4])
+        data = data[4:]
+        retval = {}
+        for i in range(num_fields):
+            typeoid, size = struct.unpack("!ii", data[:8])
+            data = data[8:]
+            conversion = pg_types[typeoid]["bin_in"]
+            value = conversion(data[:size], **kwargs)
+            data = data[size:]
+            retval[self.record_field_names[i]] = value
+        return retval
+
+py_types = {
+    bool: {"typeoid": 16, "bin_out": boolsend},
+    int: {"inspect": int_inspect},
+    long: {"inspect": int_inspect},
+    str: {"typeoid": 25, "bin_out": textout},
+    unicode: {"typeoid": 25, "bin_out": textout},
+    float: {"typeoid": 701, "bin_out": float8send},
+    decimal.Decimal: {"typeoid": 1700, "bin_out": numeric_send},
+    Bytea: {"typeoid": 17, "bin_out": byteasend},
+    datetime.datetime: {"typeoid": 1114, "bin_out": timestamp_send, "inspect": datetime_inspect},
+    datetime.date: {"typeoid": 1082, "txt_out": date_out},
+    datetime.time: {"typeoid": 1083, "txt_out": time_out},
+    Interval: {"typeoid": 1186, "bin_out": interval_send},
+    type(None): {"typeoid": -1},
+    list: {"inspect": array_inspect},
+}
+
+# py type -> pg array typeoid
+py_array_types = {
+    float: 1022,
+    bool: 1000,
+    str: 1009,      # TEXT[]
+    unicode: 1009,  # TEXT[]
+    decimal.Decimal: 1231, # NUMERIC[]
+}
+
+pg_types = {
+    16: {"bin_in": boolrecv},
+    17: {"bin_in": bytearecv},
+    18: {"txt_in": varcharin}, # char type (Greenplum)
+    19: {"bin_in": varcharin}, # name type
+    20: {"bin_in": int8recv},
+    21: {"bin_in": int2recv},
+    23: {"bin_in": int4recv},
+    24: {"txt_in": varcharin}, # regproc    (Greenplum)
+    25: {"bin_in": varcharin}, # TEXT type
+    26: {"txt_in": numeric_in}, # oid type
+    28: {"txt_in": numeric_in}, # xid type  (Greenplum)
+    700: {"bin_in": float4recv},
+    701: {"bin_in": float8recv},
+    829: {"txt_in": varcharin}, # MACADDR type
+    1000: {"bin_in": array_recv}, # BOOL[]
+    1003: {"bin_in": array_recv}, # NAME[]
+    1005: {"bin_in": array_recv}, # INT2[]
+    1007: {"bin_in": array_recv}, # INT4[]
+    1009: {"bin_in": array_recv}, # TEXT[]
+    1014: {"bin_in": array_recv}, # CHAR[]
+    1015: {"bin_in": array_recv}, # VARCHAR[]
+    1016: {"bin_in": array_recv}, # INT8[]
+    1021: {"bin_in": array_recv}, # FLOAT4[]
+    1022: {"bin_in": array_recv}, # FLOAT8[]
+    1042: {"bin_in": varcharin}, # CHAR type
+    1043: {"bin_in": varcharin}, # VARCHAR type
+    1082: {"txt_in": date_in},
+    1083: {"txt_in": time_in},
+    1114: {"bin_in": timestamp_recv},
+    1184: {"bin_in": timestamptz_recv}, # timestamp w/ tz
+    1186: {"bin_in": interval_recv},
+    1231: {"bin_in": array_recv}, # NUMERIC[]
+    1263: {"bin_in": array_recv}, # cstring[]
+    1700: {"bin_in": numeric_recv},
+    2275: {"bin_in": varcharin}, # cstring
+    2278: {"txt_in": voidrecv}, # void - This is to allow the code to handle the situation where a SQL function returns void
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/pg8000/util.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/pg8000/util.py b/tools/bin/ext/pg8000/util.py
new file mode 100644
index 0000000..d99421e
--- /dev/null
+++ b/tools/bin/ext/pg8000/util.py
@@ -0,0 +1,20 @@
+
+class MulticastDelegate(object):
+    def __init__(self):
+        self.delegates = []
+
+    def __iadd__(self, delegate):
+        self.add(delegate)
+        return self
+
+    def add(self, delegate):
+        self.delegates.append(delegate)
+
+    def __isub__(self, delegate):
+        self.delegates.remove(delegate)
+        return self
+
+    def __call__(self, *args, **kwargs):
+        for d in self.delegates:
+            d(*args, **kwargs)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/simplejson/__init__.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/simplejson/__init__.py b/tools/bin/ext/simplejson/__init__.py
new file mode 100755
index 0000000..6f0f605
--- /dev/null
+++ b/tools/bin/ext/simplejson/__init__.py
@@ -0,0 +1,303 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+r"""
+A simple, fast, extensible JSON encoder and decoder
+
+JSON (JavaScript Object Notation) <http://json.org> is a subset of
+JavaScript syntax (ECMA-262 3rd edition) used as a lightweight data
+interchange format.
+
+simplejson exposes an API familiar to uses of the standard library
+marshal and pickle modules.
+
+Encoding basic Python object hierarchies::
+    
+    >>> import simplejson
+    >>> simplejson.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}])
+    '["foo", {"bar": ["baz", null, 1.0, 2]}]'
+    >>> print simplejson.dumps("\"foo\bar")
+    "\"foo\bar"
+    >>> print simplejson.dumps(u'\u1234')
+    "\u1234"
+    >>> print simplejson.dumps('\\')
+    "\\"
+    >>> print simplejson.dumps({"c": 0, "b": 0, "a": 0}, sort_keys=True)
+    {"a": 0, "b": 0, "c": 0}
+    >>> from StringIO import StringIO
+    >>> io = StringIO()
+    >>> simplejson.dump(['streaming API'], io)
+    >>> io.getvalue()
+    '["streaming API"]'
+
+Compact encoding::
+
+    >>> import simplejson
+    >>> simplejson.dumps([1,2,3,{'4': 5, '6': 7}], separators=(',',':'))
+    '[1,2,3,{"4":5,"6":7}]'
+
+Pretty printing::
+
+    >>> import simplejson
+    >>> print simplejson.dumps({'4': 5, '6': 7}, sort_keys=True, indent=4)
+    {
+        "4": 5, 
+        "6": 7
+    }
+
+Decoding JSON::
+    
+    >>> import simplejson
+    >>> simplejson.loads('["foo", {"bar":["baz", null, 1.0, 2]}]')
+    [u'foo', {u'bar': [u'baz', None, 1.0, 2]}]
+    >>> simplejson.loads('"\\"foo\\bar"')
+    u'"foo\x08ar'
+    >>> from StringIO import StringIO
+    >>> io = StringIO('["streaming API"]')
+    >>> simplejson.load(io)
+    [u'streaming API']
+
+Specializing JSON object decoding::
+
+    >>> import simplejson
+    >>> def as_complex(dct):
+    ...     if '__complex__' in dct:
+    ...         return complex(dct['real'], dct['imag'])
+    ...     return dct
+    ... 
+    >>> simplejson.loads('{"__complex__": true, "real": 1, "imag": 2}',
+    ...     object_hook=as_complex)
+    (1+2j)
+
+Extending JSONEncoder::
+    
+    >>> import simplejson
+    >>> class ComplexEncoder(simplejson.JSONEncoder):
+    ...     def default(self, obj):
+    ...         if isinstance(obj, complex):
+    ...             return [obj.real, obj.imag]
+    ...         return simplejson.JSONEncoder.default(self, obj)
+    ... 
+    >>> dumps(2 + 1j, cls=ComplexEncoder)
+    '[2.0, 1.0]'
+    >>> ComplexEncoder().encode(2 + 1j)
+    '[2.0, 1.0]'
+    >>> list(ComplexEncoder().iterencode(2 + 1j))
+    ['[', '2.0', ', ', '1.0', ']']
+    
+
+Note that the JSON produced by this module's default settings
+is a subset of YAML, so it may be used as a serializer for that as well.
+"""
+__version__ = '1.7.3'
+__all__ = [
+    'dump', 'dumps', 'load', 'loads',
+    'JSONDecoder', 'JSONEncoder',
+]
+
+from decoder import JSONDecoder
+from encoder import JSONEncoder
+
+_default_encoder = JSONEncoder(
+    skipkeys=False,
+    ensure_ascii=True,
+    check_circular=True,
+    allow_nan=True,
+    indent=None,
+    separators=None,
+    encoding='utf-8'
+)
+
+def dump(obj, fp, skipkeys=False, ensure_ascii=True, check_circular=True,
+        allow_nan=True, cls=None, indent=None, separators=None,
+        encoding='utf-8', **kw):
+    """
+    Serialize ``obj`` as a JSON formatted stream to ``fp`` (a
+    ``.write()``-supporting file-like object).
+
+    If ``skipkeys`` is ``True`` then ``dict`` keys that are not basic types
+    (``str``, ``unicode``, ``int``, ``long``, ``float``, ``bool``, ``None``) 
+    will be skipped instead of raising a ``TypeError``.
+
+    If ``ensure_ascii`` is ``False``, then the some chunks written to ``fp``
+    may be ``unicode`` instances, subject to normal Python ``str`` to
+    ``unicode`` coercion rules. Unless ``fp.write()`` explicitly
+    understands ``unicode`` (as in ``codecs.getwriter()``) this is likely
+    to cause an error.
+
+    If ``check_circular`` is ``False``, then the circular reference check
+    for container types will be skipped and a circular reference will
+    result in an ``OverflowError`` (or worse).
+
+    If ``allow_nan`` is ``False``, then it will be a ``ValueError`` to
+    serialize out of range ``float`` values (``nan``, ``inf``, ``-inf``)
+    in strict compliance of the JSON specification, instead of using the
+    JavaScript equivalents (``NaN``, ``Infinity``, ``-Infinity``).
+
+    If ``indent`` is a non-negative integer, then JSON array elements and object
+    members will be pretty-printed with that indent level. An indent level
+    of 0 will only insert newlines. ``None`` is the most compact representation.
+
+    If ``separators`` is an ``(item_separator, dict_separator)`` tuple
+    then it will be used instead of the default ``(', ', ': ')`` separators.
+    ``(',', ':')`` is the most compact JSON representation.
+
+    ``encoding`` is the character encoding for str instances, default is UTF-8.
+
+    To use a custom ``JSONEncoder`` subclass (e.g. one that overrides the
+    ``.default()`` method to serialize additional types), specify it with
+    the ``cls`` kwarg.
+    """
+    # cached encoder
+    if (skipkeys is False and ensure_ascii is True and
+        check_circular is True and allow_nan is True and
+        cls is None and indent is None and separators is None and
+        encoding == 'utf-8' and not kw):
+        iterable = _default_encoder.iterencode(obj)
+    else:
+        if cls is None:
+            cls = JSONEncoder
+        iterable = cls(skipkeys=skipkeys, ensure_ascii=ensure_ascii,
+            check_circular=check_circular, allow_nan=allow_nan, indent=indent,
+            separators=separators, encoding=encoding, **kw).iterencode(obj)
+    # could accelerate with writelines in some versions of Python, at
+    # a debuggability cost
+    for chunk in iterable:
+        fp.write(chunk)
+
+
+def dumps(obj, skipkeys=False, ensure_ascii=True, check_circular=True,
+        allow_nan=True, cls=None, indent=None, separators=None,
+        encoding='utf-8', **kw):
+    """
+    Serialize ``obj`` to a JSON formatted ``str``.
+
+    If ``skipkeys`` is ``True`` then ``dict`` keys that are not basic types
+    (``str``, ``unicode``, ``int``, ``long``, ``float``, ``bool``, ``None``) 
+    will be skipped instead of raising a ``TypeError``.
+
+    If ``ensure_ascii`` is ``False``, then the return value will be a
+    ``unicode`` instance subject to normal Python ``str`` to ``unicode``
+    coercion rules instead of being escaped to an ASCII ``str``.
+
+    If ``check_circular`` is ``False``, then the circular reference check
+    for container types will be skipped and a circular reference will
+    result in an ``OverflowError`` (or worse).
+
+    If ``allow_nan`` is ``False``, then it will be a ``ValueError`` to
+    serialize out of range ``float`` values (``nan``, ``inf``, ``-inf``) in
+    strict compliance of the JSON specification, instead of using the
+    JavaScript equivalents (``NaN``, ``Infinity``, ``-Infinity``).
+
+    If ``indent`` is a non-negative integer, then JSON array elements and
+    object members will be pretty-printed with that indent level. An indent
+    level of 0 will only insert newlines. ``None`` is the most compact
+    representation.
+
+    If ``separators`` is an ``(item_separator, dict_separator)`` tuple
+    then it will be used instead of the default ``(', ', ': ')`` separators.
+    ``(',', ':')`` is the most compact JSON representation.
+
+    ``encoding`` is the character encoding for str instances, default is UTF-8.
+
+    To use a custom ``JSONEncoder`` subclass (e.g. one that overrides the
+    ``.default()`` method to serialize additional types), specify it with
+    the ``cls`` kwarg.
+    """
+    # cached encoder
+    if (skipkeys is False and ensure_ascii is True and
+        check_circular is True and allow_nan is True and
+        cls is None and indent is None and separators is None and
+        encoding == 'utf-8' and not kw):
+        return _default_encoder.encode(obj)
+    if cls is None:
+        cls = JSONEncoder
+    return cls(
+        skipkeys=skipkeys, ensure_ascii=ensure_ascii,
+        check_circular=check_circular, allow_nan=allow_nan, indent=indent,
+        separators=separators, encoding=encoding,
+        **kw).encode(obj)
+
+_default_decoder = JSONDecoder(encoding=None, object_hook=None)
+
+def load(fp, encoding=None, cls=None, object_hook=None, **kw):
+    """
+    Deserialize ``fp`` (a ``.read()``-supporting file-like object containing
+    a JSON document) to a Python object.
+
+    If the contents of ``fp`` is encoded with an ASCII based encoding other
+    than utf-8 (e.g. latin-1), then an appropriate ``encoding`` name must
+    be specified. Encodings that are not ASCII based (such as UCS-2) are
+    not allowed, and should be wrapped with
+    ``codecs.getreader(fp)(encoding)``, or simply decoded to a ``unicode``
+    object and passed to ``loads()``
+
+    ``object_hook`` is an optional function that will be called with the
+    result of any object literal decode (a ``dict``). The return value of
+    ``object_hook`` will be used instead of the ``dict``. This feature
+    can be used to implement custom decoders (e.g. JSON-RPC class hinting).
+    
+    To use a custom ``JSONDecoder`` subclass, specify it with the ``cls``
+    kwarg.
+    """
+    return loads(fp.read(),
+        encoding=encoding, cls=cls, object_hook=object_hook, **kw)
+
+def loads(s, encoding=None, cls=None, object_hook=None, **kw):
+    """
+    Deserialize ``s`` (a ``str`` or ``unicode`` instance containing a JSON
+    document) to a Python object.
+
+    If ``s`` is a ``str`` instance and is encoded with an ASCII based encoding
+    other than utf-8 (e.g. latin-1) then an appropriate ``encoding`` name
+    must be specified. Encodings that are not ASCII based (such as UCS-2)
+    are not allowed and should be decoded to ``unicode`` first.
+
+    ``object_hook`` is an optional function that will be called with the
+    result of any object literal decode (a ``dict``). The return value of
+    ``object_hook`` will be used instead of the ``dict``. This feature
+    can be used to implement custom decoders (e.g. JSON-RPC class hinting).
+
+    To use a custom ``JSONDecoder`` subclass, specify it with the ``cls``
+    kwarg.
+    """
+    if cls is None and encoding is None and object_hook is None and not kw:
+        return _default_decoder.decode(s)
+    if cls is None:
+        cls = JSONDecoder
+    if object_hook is not None:
+        kw['object_hook'] = object_hook
+    return cls(encoding=encoding, **kw).decode(s)
+
+def read(s):
+    """
+    json-py API compatibility hook. Use loads(s) instead.
+    """
+    import warnings
+    warnings.warn("simplejson.loads(s) should be used instead of read(s)",
+        DeprecationWarning)
+    return loads(s)
+
+def write(obj):
+    """
+    json-py API compatibility hook. Use dumps(s) instead.
+    """
+    import warnings
+    warnings.warn("simplejson.dumps(s) should be used instead of write(s)",
+        DeprecationWarning)
+    return dumps(obj)
+
+


[06/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code

Posted by rl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import73.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import73.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import73.py
new file mode 100644
index 0000000..2a00c78
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import73.py
@@ -0,0 +1,9 @@
+class AbstractLib:
+    ""
+    def __init__(self):
+        pass
+
+    def abstract(self):
+        "This is doc"
+        "this is an expression, sneaky"
+        raise NotImplementedError("This method must be overridden")

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import98.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import98.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import98.py
new file mode 100644
index 0000000..99975c7
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/import98.py
@@ -0,0 +1,11 @@
+__doc__ = 'Auxiliary file for test98.py'
+
+class BaseGood:
+    'Nice base init'
+    def __init__(self):
+        return
+
+class BaseBad:
+    'Error should print as coming from this file'
+    def __init__(self):
+        return 42

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/pycheckrc
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/pycheckrc b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/pycheckrc
new file mode 100644
index 0000000..a242dbf
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/pycheckrc
@@ -0,0 +1,7 @@
+
+suppressions = { 'test39': 'no-moduledoc', 'test39.func2': 'funcdoc',
+		 'test39.X1': 'no-classdoc', 'test39.X2.x': 'self="s"' }
+
+suppressionRegexs = { 'test39.Y.': 'no-classdoc', 
+		      'test39.Y..a': 'funcdoc',
+		      'test39.NewStyle.f': 'no-local' }

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test1.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test1.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test1.py
new file mode 100644
index 0000000..d4df718
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test1.py
@@ -0,0 +1,75 @@
+
+import imp
+import re
+
+_NOT_USED1 = None
+NOT_USED2 = None
+
+def getModules(n = 0, j = 3) :
+    "Return list of modules by removing .py from each entry."
+    for m in unknownList :
+        pass
+
+def jjj(self) :
+    import sys
+    print sys.argv
+
+def jjj2(a, b = None, c = None) :
+    pass
+
+def ddd(a, *args):
+    jjj2()
+    jjj2(1)
+    jjj2(1, 2)
+    jjj2(1, 2, 3)
+    jjj2(1, 2, 3, 4)
+
+def ppp():
+   ddd()
+   ddd(1)
+   ddd(1, 2)
+   ddd(1, 2, 3)
+
+class X:
+    def __init__(self) :
+        print sys.argv
+        print self.__class__, self.__doc__, self.__dict__, self.__x__, self.x
+        self.y = 0
+        print self.y
+    def r(sf):
+        nofunc()
+        for i in range(0, len(self.a)) :
+            jjj(1, 2, 3, k=5)
+
+class Y(X):
+    def xxx(self, adf) :
+        asdf = adf
+        # jjjj doesn't exist
+        j = jjjj
+        # z() doesn't exist
+        self.z()
+        adf.mmm.kkk()
+        # j doesn't exist
+        self.j = 0
+        self.xxx(1, 2)
+
+def uuu():
+  a=1+2
+  return a[0], [['a', 'b'], [1,2,3,4]]
+
+def renderElement(a, b=2, c=3, **kw):
+    contents = kw
+    print contents
+
+def renderItem(text):
+    return renderElement(1, contents=text, z=1, y=2, x=3)
+
+def test_kw_lambda(a, b, c):
+    return renderElement(a, ff=lambda value: '=' + renderItem(b))
+
+str = '53'
+_ = "blah, don't care, shouldn't warn"
+
+def getOneImageFromPath(k, v):
+    d = []
+    d.append(id=k, original_flag=v)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test10.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test10.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test10.py
new file mode 100644
index 0000000..1546479
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test10.py
@@ -0,0 +1,8 @@
+"doc"
+
+from xml.sax import saxutils
+
+def afunc():
+    stuff = saxutils.escape.make_parser('junk')
+    return stuff
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test100.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test100.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test100.py
new file mode 100644
index 0000000..aced842
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test100.py
@@ -0,0 +1,15 @@
+# https://sourceforge.net/tracker/index.php?func=detail&aid=1563494&group_id=24686&atid=382217
+# see zope.interface.declarations.Declaration
+# for a real-world one line test, pycheck "import zope.interface.declarations"  
+
+'d'
+class D:
+    'd'
+    __bases__ = ()
+    
+    # this repr avoids getting the default repr, which shows an id
+    # which changes between test runs
+    __repr__ = classmethod(lambda cls: 'D')
+
+# instantiating triggers the bug
+d = D()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test101.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test101.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test101.py
new file mode 100644
index 0000000..fda76f3
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test101.py
@@ -0,0 +1,33 @@
+# -*- Mode: Python -*-
+# vi:si:et:sw=4:sts=4:ts=4
+
+# see https://sourceforge.net/tracker/index.php?func=detail&aid=1563495&group_id=24686&atid=382217
+
+'d'
+
+__pychecker__ = 'blacklist=wrongname'
+
+import os
+import imp
+import tempfile
+
+code = """
+class C:
+    pass
+
+c = C()
+"""
+
+# create a temporary file for the module
+(fd, path) = tempfile.mkstemp()
+os.write(fd, code)
+os.close(fd)
+
+temp = imp.load_source('temp', path)
+
+# change class's module to trigger the error
+temp.C.__module__ = 'wrongname'
+
+# clean up
+os.unlink(path)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test102.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test102.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test102.py
new file mode 100644
index 0000000..46c659c
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test102.py
@@ -0,0 +1,16 @@
+
+"""This used to be a problem for code that assumed __bases__ existed."""
+
+class GetattrReturnsNone(object):
+  """This requires a new-style class."""
+  def __getattr__(self, unused_name):
+    return None
+
+dummy1 = GetattrReturnsNone()
+
+class GetattrReturnsStr(object):
+  """This requires a new-style class."""
+  def __getattr__(self, unused_name):
+    return 'abc'
+
+dummy2 = GetattrReturnsStr()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test11.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test11.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test11.py
new file mode 100644
index 0000000..8ee8365
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test11.py
@@ -0,0 +1,20 @@
+"doc"
+
+class Test:
+    "'No attribute (alias) found' warning should not be generated"
+
+    def __init__(self):
+        self.alias()
+
+    def real(self):
+        pass
+
+    alias = real
+
+
+def rcParseTest(a = 10, b = 'ten', c = (5, 5)):
+    print '%s, %s, %s' % (a, b, str(c))
+
+def a(i):
+    [0, 1, 3].index(i)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test12.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test12.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test12.py
new file mode 100644
index 0000000..a5eae7d
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test12.py
@@ -0,0 +1,8 @@
+"shouldn't produce any warnings"
+
+from xml.sax import handler
+
+class GetGUI(handler.DTDHandler):
+  "shouldn't produce any warnings"
+  pass
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test13.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test13.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test13.py
new file mode 100644
index 0000000..c8a19a7
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test13.py
@@ -0,0 +1,30 @@
+
+"global test"
+
+def test1():
+  'without -g option, this should be the only warning for x'
+  global x
+  x = 90
+
+def test2():
+  'with -g option, this should be also generate a warning for x'
+  global x
+  x = 90
+
+def test3():
+  'with -g option, this should be also generate a warning for x'
+  global x
+  x = 90
+
+def test4():
+  'without -g option, this should be the only warning for xxx'
+  print xxx
+
+def test5():
+  'with -g option, this should be also generate a warning for xxx'
+  print xxx
+
+def test6():
+  'with -g option, this should be also generate a warning for xxx'
+  print xxx
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test14.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test14.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test14.py
new file mode 100644
index 0000000..65f3ba9
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test14.py
@@ -0,0 +1,24 @@
+"doesn't work in 1.5.2"
+
+import string
+import string as nn
+
+used = ''
+_unused = 0
+
+def yyy():
+    import string as jj
+
+if nn.lower('aa') == '':
+    pass
+if string.lower(used) == '':
+    pass
+
+if 1 :
+    _noglobal = 0
+
+import xml.sax as sax
+
+def zzz():
+    print sax
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test15.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test15.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test15.py
new file mode 100644
index 0000000..426e7bc
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test15.py
@@ -0,0 +1,39 @@
+"doc"
+
+def xx(**kw):
+    return None
+
+def yy():
+    c = yy
+    g, h = 1, 2
+    xx(a='', b=c.a.d.f, e=5, jj=xx(j=5), f=(g+h), k=("%s" % "df"))
+
+def zz():
+    b = zz
+    xx(b=(1, 2, 3), c={ 'a': b}, d=[1, 2, 3], k=(1 < 2))
+
+def aa(obj):
+    print obj.x.y
+    print obj.x.y.z
+    print obj.x.y.z.a
+    print obj.x.y.z.a.b
+    print obj.x.y.z.a.b.c
+
+class Obj:
+    'd'
+    def __init__(self, xx):
+        self.xx = xx
+        self.xx.y = 0
+        self.xx.y.z = 0
+        self.xx.y.z.a = 0
+        self.xx.y.z.a.b = 0
+        self.xx.y.z.a.b.c = 0
+
+    def prn(self):
+        print self.xx
+        print self.xx.y
+        print self.xx.y.z
+        print self.xx.y.z.a
+        print self.xx.y.z.a.b
+        print self.xx.y.z.a.b.c
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test16.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test16.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test16.py
new file mode 100644
index 0000000..1362c2c
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test16.py
@@ -0,0 +1,19 @@
+"doc"
+
+import re
+import sys
+import glob
+
+class X:
+    'doc'
+    global_var = re.compile('a')
+    def m(self, j = re.match):
+        print X.global_var
+
+    def xxx(self, j = glob.glob):
+      print j
+
+def xxx(j = sys.path):
+  print j
+
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test17.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test17.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test17.py
new file mode 100644
index 0000000..7c08df3
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test17.py
@@ -0,0 +1,35 @@
+'doc'
+
+class X:
+    'should get a warning for returning value from __init__'
+    def __init__(self):
+        print 'howdy'
+        return 1
+
+class Y:
+    'should get a warning for returning value from __init__'
+    def __init__(self, x):
+        if x == 0 :
+            return 0
+        if x == 1 :
+            return 53
+        return None
+
+class Z:
+    'should not get a warning'
+    def __init__(self, x):
+        return
+
+
+class Q(Z):
+    'd'
+    def __init__(self):
+        v = lambda : None
+        Z.__init__(self, v)
+
+
+class S(Z):
+   'd'
+   def __init__(self):
+       Z.__init__(self,lambda x: x in ['p','f'])
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test18.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test18.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test18.py
new file mode 100644
index 0000000..8a57eb1
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test18.py
@@ -0,0 +1,44 @@
+'d'
+
+class A:
+    "d"
+    def __init__(self): pass
+
+class X:
+    "d"
+    def __init__(self, x): pass
+
+class Y:
+    "d"
+    def __init__(self, x, y, z): pass
+
+class Z:
+    "d"
+    def __init__(self, x, y, z, *args, **kw): pass
+
+def j():
+    A()
+    A(1)
+
+    X()
+    X(1)
+    X(1, 2)
+    X(1, 2, 3)
+    X(1, 2, 3, 4)
+
+    Y()
+    Y(1)
+    Y(1, 2)
+    Y(1, 2, 3)
+    Y(1, 2, 3, 4)
+
+    Z()
+    Z(1)
+    Z(1, 2)
+    Z(1, 2, 3)
+    Z(1, 2, 3, 4)
+    Z(1, 2, 3, 4, 5)
+    Z(1, 2, 3, 4, 5, 6)
+    Z(1, 2, 3, 4, k=1, j=2, m=3, f=5)
+
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test19.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test19.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test19.py
new file mode 100644
index 0000000..e57bf55
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test19.py
@@ -0,0 +1,10 @@
+'d'
+
+import UserDict
+
+def y():
+  UserDict.UserDict()
+  UserDict.UserDict({})
+  UserDict.UserDict({}, 0)
+  UserDict.UserDict({}, 0, 1)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test2.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test2.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test2.py
new file mode 100644
index 0000000..e46c9f7
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test2.py
@@ -0,0 +1,20 @@
+
+"time module not used if write32u() line in X.uuu() is commented out"
+
+import time
+
+def write32u(a, b): pass
+
+class X:
+  def __init__(self):
+    self.fileobj = 0
+  def uuu(self): 
+    #write32u(self.fileobj, long(time.time()))
+    return None
+
+class Y(X):
+  def __init__(self) :
+    "ERROR: X.__init__() isn't called"
+    # X.__init__(self)
+    self.x = 0
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test20.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test20.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test20.py
new file mode 100644
index 0000000..21d2e6f
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test20.py
@@ -0,0 +1,41 @@
+'this test will fail unless -r/--returnvalues is used'
+
+def func0(x):
+    'should not be a warning'
+    return 0
+
+def func1(x):
+    'should be a warning implicit/explicit'
+    if x == 0 :
+        return 1
+
+def func2(x):
+    'should not be a warning'
+    if x == 0 :
+        return
+
+def func3(x):
+    'should be a warning'
+    if x == 0 :
+        return 1, 2
+    return 1
+
+def func4(x):
+    'should not be a warning, difficult to deal with'
+    c = (1, 2)
+    if x == 0 :
+        return c
+    return 9, 8
+
+def func5(x):
+    'should not be a warning'
+    if x == 0 :
+        return 1, 2
+    return 9, 8
+
+def func6(x):
+    'should be a warning'
+    if x == 0 :
+        return 1, 2
+    return 9, 8, 7
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test21.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test21.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test21.py
new file mode 100644
index 0000000..197d07c
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test21.py
@@ -0,0 +1,57 @@
+'test inconsistent return types'
+
+a, b = 0, 0
+
+def f(z):
+    'should be a warning'
+    if z:
+        return 1
+    return  []
+
+def g(z):
+    'should be a warning'
+    if z:
+        return (1, 2)
+    return  []
+
+def h(z):
+    'should be a warning'
+    if z:
+        return {}
+    return  []
+
+def y():
+    'should not be a warning'
+    if a: return 1
+    elif b: return 0
+    else : return cmp(a, b)
+
+def z():
+    'should not be a warning'
+    if b: return b, a, globals()
+    return 1, 2, 3
+
+class A:
+    'test returning base class'
+
+class B(A):
+    'test returning derived class'
+
+def x(num):
+    if num == 1:
+        return A()
+    if num == 2:
+        return B()
+    return None
+
+class C:
+    'test returning "inconsistent" types from __getattr__ which is allowed'
+    def __getattr__(self, attr):
+        if attr == 'a':
+            return 1
+        if attr == 'b':
+            return 3.1415926
+        if attr == 'b':
+            return 'string'
+        raise AttributeError, 'no attr ' + attr + ' is a bad attr'
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test22.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test22.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test22.py
new file mode 100644
index 0000000..868a8c6
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test22.py
@@ -0,0 +1,86 @@
+'d'
+
+def y():
+    print '%d %f %s' % (1, 2.2, 'sdf')
+
+    print '%d %f %s %d' % (1, 2.2, 'sdf')
+
+    aaa = bbb = 1
+    eee = 0
+    print '%(aaa)d %(bbb)f %(ccc)s %(ddd)s' % locals()
+
+    b = 0
+    print '%()s %(b)d' % locals()
+
+    print '%(b) %(aaa)d' % locals()
+    print '%(aaa)d %(b)' % locals()
+
+    print '%*d' % (2, 2)
+    print '%*d' % (2, 2, 3)
+
+    print '%*.*f' % (5, 2, 2.0)
+    print '%*.*f' % (5, 2, 2.0, 3)
+
+    print '%z %f %s' % (1, 2.2, 'sdf')
+    print '%d %J %s' % (1, 2.2, 'sdf')
+    print '%***f' % (5, 2, 2.0, 3)
+
+    print '%(aaa)d %d' % locals()
+    print '%(aaa)*d' % locals()
+    jjj = 1.0
+    print '%(jjj)*.*f' % locals()
+
+    fmt = '%d %s %d'
+    print fmt % (aaa, bbb)
+
+
+_F = '%d %d'
+
+def ZZ():
+    print _F % 5
+    print _F % (5, 5)
+    print _F % (5, 5, 5)
+
+    F = '%d'
+    print F % 5
+    print F % (5, 5, 5)
+
+    t1 = (1,)
+    t2 = (1,2)
+    print F % t1
+    print F % t2
+
+def YY(item):
+    print '%(a)s %(b)s' % { 'a': '5', 'b': '7' }
+    print '%(a)s %(b)s' % item
+    d = { 'a': '5', 'b': '7' }
+    print '%(a)s %(b)s' % d
+
+def string_multiply():
+    # these are right
+    print '%d ' * 3 % (1, 2, 3)
+    print ('%d ' * 3) % (1, 2, 3)
+
+    # these are wrong
+    print '%d ' * 2 % (1, 2, 3)
+    print '%d ' * 3 % (1, 2, 3, 4)
+    print ('%d ' * 4) % (1, 2)
+
+def check_vars1():
+    a = b = c = 5
+    print '%(a)d %(b)d' % vars()
+
+def check_vars2():
+    a = b = c = 5
+    print '%(a)d %(b)d' % vars(c)
+
+def check_modulo_1():
+  print '%s' % '1'
+  print '%s' % 1
+  print .55555 % 1
+  print 55555 % 1
+  f = 55555.55 
+  print f % 1
+
+def check_bad_format_end_percent(arg):
+  print 'ha, better not crash %' % arg

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test23.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test23.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test23.py
new file mode 100644
index 0000000..d88b1e0
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test23.py
@@ -0,0 +1,48 @@
+'doc'
+
+class X:
+    'doc'
+    def __init__(self):
+        self.fff = 0
+
+    def x(self):
+        pass
+
+    def y(self):
+        'should generate a warning'
+        if self.x:
+            pass
+        if self.x and globals():
+            pass
+        if globals() and self.x:
+            pass
+
+    def z(self):
+        'should NOT generate a warning'
+        if globals() :
+            pass
+        if self.x() and self.fff:
+            pass
+        if self.x() and globals():
+            pass
+        if globals() and self.x():
+            pass
+        if self.fff:
+            pass
+        print self.x
+        print self.fff
+
+class Y(X):
+    'doc'
+    def j(self):
+        'should generate a warning'
+        if self.x:
+            pass
+        print self.fff
+
+    def h(self):
+        'should NOT generate a warning'
+        if self.x():
+            pass
+        print self.x
+        print self.fff

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test24.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test24.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test24.py
new file mode 100644
index 0000000..0611926
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test24.py
@@ -0,0 +1,12 @@
+'doc'
+
+from import24 import *
+
+b = Bbb()
+
+def xxx():
+    print func24(1)
+
+def func(shadow):
+    print shadow
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test25.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test25.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test25.py
new file mode 100644
index 0000000..e5c871f
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test25.py
@@ -0,0 +1,16 @@
+'doc'
+
+import sys
+
+class A:
+    'doc'
+    z = 1
+    def x(self): pass
+
+def xxx():
+    print A.x()
+    print A.z
+    print A.a
+    print A.y()
+    print sys.lkjsdflksjasdlf
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test26.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test26.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test26.py
new file mode 100644
index 0000000..dba9bc2
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test26.py
@@ -0,0 +1,11 @@
+""
+class Foo:
+    ""
+    def __init__(self,q):
+        print q
+
+class Bar(Foo):
+    ""
+    def __init__(self):
+        Foo.__init__(self,{ 'a' : 1 })
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test27.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test27.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test27.py
new file mode 100644
index 0000000..dcf40d7
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test27.py
@@ -0,0 +1,15 @@
+'doc'
+
+import fnmatch
+
+x = []
+bfp = ''
+x = filter(lambda f, p = bfp : fnmatch.fnmatch(f, p), x)
+
+def y():
+    print x
+
+def d(lines):
+    import string
+    lines = map(lambda s: string.strip(s), lines)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test28.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test28.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test28.py
new file mode 100644
index 0000000..789a572
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test28.py
@@ -0,0 +1,8 @@
+'doc'
+
+import fnmatch
+
+class X:
+    'doc'
+    x = filter(lambda f, p = '' : fnmatch.fnmatch(f, p), [])
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test29.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test29.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test29.py
new file mode 100644
index 0000000..0ac3855
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test29.py
@@ -0,0 +1,14 @@
+'doc'
+
+import fnmatch
+
+class X:
+    'doc'
+    def x(self):
+        x = filter(lambda f, p = '' : fnmatch.fnmatch(f, p), [])
+        print x
+
+def x(cpu):
+    p = len(filter(lambda x: x.find('processor') > -1, cpu.items))
+    print p
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test3.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test3.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test3.py
new file mode 100644
index 0000000..c92bc05
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test3.py
@@ -0,0 +1,14 @@
+
+"Shouldn't be any warnings/errors"
+
+import string
+
+def describeSyntax(syntax):
+    return string.join(['<%s>' % x.Description])
+
+from UserDict import UserDict
+
+class jj(UserDict) :
+    def __init__(self):
+      UserDict.__init__(self)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test30.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test30.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test30.py
new file mode 100644
index 0000000..123db37
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test30.py
@@ -0,0 +1,8 @@
+'doc'
+
+import fnmatch
+
+def x():
+    x = filter(lambda f, p = '' : fnmatch.fnmatch(f, p), [])
+    print x
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test31.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test31.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test31.py
new file mode 100644
index 0000000..a3d040c
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test31.py
@@ -0,0 +1,38 @@
+'doc'
+
+class X:
+  'doc'
+
+class Y(X):
+  'doc'
+
+class Z(X):
+  'doc'
+  def __init__(self, arg):
+    pass
+
+def x():
+  'should not cause a warning'
+  print X()
+  print Y()
+  print Z('should create a warning since no __init__()')
+
+def y():
+  print X(a='should create a warning since no __init__()')
+  print X('should create a warning since no __init__()')
+  print Y(a='should create a warning since no __init__()')
+  print Y('should create a warning since no __init__()')
+  print Z(1, a='should create a warning since no __init__()')
+  print Z(1, 2)
+
+class A:
+  'd'
+  def a(self, a, b, c): pass
+  def x(self, a, b, c): pass
+
+class B(A):
+  'd'
+  def y(self):
+      A.x(self, 1, 2, 3)
+  def z(self):
+      A.a(self, 1, 2, 3)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test32.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test32.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test32.py
new file mode 100644
index 0000000..1ca2b82
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test32.py
@@ -0,0 +1,16 @@
+'doc'
+
+class X:
+  'doc'
+  def __init__(self): pass
+
+class Y(X):
+  'doc'
+  def __init__(self, s):
+    X.__init__(s)
+
+class Z(X):
+  'doc'
+  def __init__(self, s):
+    X.__init__()
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test33.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test33.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test33.py
new file mode 100644
index 0000000..739b736
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test33.py
@@ -0,0 +1,10 @@
+'d'
+
+def x():
+    print j
+    j = 0
+
+def y():
+    for x in []:
+        print x
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test34.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test34.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test34.py
new file mode 100644
index 0000000..9cea46a
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test34.py
@@ -0,0 +1,27 @@
+'d'
+
+from string import whitespace
+from string import digits
+from string import lowercase
+from string import *
+
+import locale
+from locale import LC_ALL
+from locale import *
+
+import getopt
+from getopt import *
+
+from copy import *
+import copy
+
+from re import sub
+from re import sub
+
+import ihooks
+import ihooks
+
+def x(a):
+    "just use the imported modules so we don't get an unused warning"
+    print ihooks, getopt, copy, locale
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test35.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test35.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test35.py
new file mode 100644
index 0000000..76e26d5
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test35.py
@@ -0,0 +1,13 @@
+
+__pychecker__ = '--no-namedargs --no-import --no-var --no-privatevar --no-moduledoc --funcdoc'
+
+import re
+
+_NOT_USED1 = None
+NOT_USED2 = None
+
+def x(a, b) : pass
+
+def y():
+  x(b=1, a=2)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test36.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test36.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test36.py
new file mode 100644
index 0000000..69b8a4f
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test36.py
@@ -0,0 +1,40 @@
+'d'
+
+from types import StringType, NoneType
+from string import upper
+
+def foo():
+    return map(lambda x: upper(x), 'testing')
+
+def func(a, b, *args, **kw):
+    'verify no warnings for variables (arguments) used before set'
+    print a, b, args, kw
+
+class E(Exception):
+    'doc'
+
+
+def x():
+    'instantiate a new E with many args, should not be a warning'
+    print E('test', 'test', 'test', 'test', 'test', 0)
+
+def y():
+    from string import lower
+    lower = lower('Unknown option')
+
+def foobar(x): return x
+
+def nn():
+    print map(lambda x, s=foobar: s(x), [1,2])
+
+def start() :
+    int(args=(lambda x=None: x,))
+
+def nn2():
+    n = []
+    n.append(1)
+    n.append(1, 2)
+    n.append((1, 2))
+
+def run():
+    foobar(x={0:5})

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test37.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test37.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test37.py
new file mode 100644
index 0000000..66cdd7d
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test37.py
@@ -0,0 +1,7 @@
+'d'
+
+import struct
+from import37 import Test
+
+def x():
+    print struct

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test38.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test38.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test38.py
new file mode 100644
index 0000000..6a0ec43
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test38.py
@@ -0,0 +1,54 @@
+'d'
+
+class X:
+    'd'
+    def m1(self, a, b, c, d): pass
+    def m2(self, a, b, c, d, *args): pass
+    def m3(self, a, b, c, d, *args, **kwArgs): pass
+    def m4(self, a, b=0, c=0, d=0): pass
+    def m5(self, a, b=0, c=0, d=0, *args): pass
+    def m6(self, a, b=0, c=0, d=0, *args, **kwArgs): pass
+
+class Y1(X):
+    'should not generate any warnings'
+    def m1(self, a, b, c, d): exec a in globals()
+    def m2(self, a, b, c, d, *args): exec a in globals()
+    def m3(self, a, b, c, d, *args, **kwArgs): exec a in globals()
+    def m4(self, a, b, c, d): exec a in globals()
+    def m5(self, a, b, c, d, *args): exec a in globals()
+    def m6(self, a, b, c, d, *args, **kwArgs): exec a in globals()
+
+class Z1(X):
+    'should generate warnings'
+    def m1(self, a, b, c): pass
+    def m2(self, a, b, c, d): pass
+    def m3(self, a, b, c, d, **kwArgs): pass
+    def m4(self, a, b=0, c=0): pass
+    def m5(self, a, b=0, c=0, d=0): pass
+    def m6(self, a, b=0, c=0, d=0, **kwArgs): pass
+
+class Z2(X):
+    'should generate warnings'
+    def m3(self, a, b, c, d, *args): pass
+    def m6(self, a, b=0, c=0, d=0, *args): pass
+
+class Z3(X):
+    'should generate warnings'
+    def m3(self, a, b, c, d): pass
+    def m6(self, a, b=0, c=0, d=0): pass
+
+class Z4(X):
+    'should generate warnings'
+    def m1(self): pass
+    def m2(self): pass
+    def m3(self): pass
+    def m4(self): pass
+    def m5(self): pass
+    def m6(self): pass
+
+class AAA:
+    'should generate 1 warning'
+    __pychecker__ = 'exec'
+    def m1(self, a, b, c, d): pass
+    def m2(self, a, b, c, d, *args): exec a in d
+    def m3(self, a, b, c, d, *args): exec a

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test39.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test39.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test39.py
new file mode 100644
index 0000000..755301b
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test39.py
@@ -0,0 +1,44 @@
+
+def func1(): pass
+def func2(): pass
+
+class X1:
+    def x(self) : pass
+    def y(self) : pass
+
+class X2:
+    def x(self) : pass
+    def y(self) : pass
+
+class Y1:
+    def a(self) : pass
+    def x(self) : pass
+    def y(self) : pass
+
+class Y2:
+    def a(self) : pass
+    def x(self) : pass
+    def y(self) : pass
+
+class check_here:
+    'test __pychecker__ var at class scope'
+    __pychecker__ = 'funcdoc argsused unusednames=foo,bar'
+    def a(self) :
+        'd'
+        pass
+    def x(self, foo) :
+        print self
+    def y(self, bar) :
+        print self
+    def z(self, jjj) :
+        j = 0
+
+# Requires Python 2.2+
+try:
+    class NewStyle(object):
+        'test that suppressions work with new style classes'
+        def f(self):
+            i = 5
+
+except NameError:
+    pass

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test4.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test4.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test4.py
new file mode 100644
index 0000000..0a7bcc2
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test4.py
@@ -0,0 +1,32 @@
+
+import UserDict 
+
+class jj(UserDict.UserDict) :
+    "jj"
+    def __init__(self):
+      UserDict.UserDict.__init__(self, None)
+
+class jj2(UserDict.UserDict) :
+    "jj2"
+    def __init__(self):
+      "Warning don't call UserDict.UserDict.__init__()"
+      print "don't call UserDict.UserDict.__init__()"
+
+class jj3(jj) :
+    "jj3"
+    def __init__(self):
+      jj.__init__(self)
+
+class jj4(jj) :
+    "jj4"
+
+class A: 
+    'should not generate warnings'
+    def __init__(self): pass
+
+class B(A):
+    'should not generate warnings'
+
+class C(B):
+    'should not generate warnings'
+    def __init__(self): B.__init__(self)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test40.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test40.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test40.py
new file mode 100644
index 0000000..61114c0
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test40.py
@@ -0,0 +1,34 @@
+'d'
+
+__pychecker__ = 'argsused'
+
+def x0():
+    print 'should be ok'
+
+def x1(a, b, c, *args, **kw):
+    print a, b, c
+
+def x2(a, b, c, *args, **kw):
+    print a, b, c, args
+
+def x3(a, b, c, *args, **kw):
+    print a, b, c, args, kw
+
+def x4(a, b, c, *args, **kw):
+    print 'uh-oh, forgot to use args'
+
+def x5(a, b, c, *args, **kw):
+    raise NotImplementedError
+
+def x6(a, b, c, *args, **kw):
+    pass
+
+def x7(a, b, c, *args, **kw):
+    return None
+
+class X:
+    'd'
+    def x1(self):
+    	print 'hi'
+    def x2(self, a, *args, **kw):
+    	print 'oops'

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test41.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test41.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test41.py
new file mode 100644
index 0000000..e88be46
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test41.py
@@ -0,0 +1,18 @@
+'d'
+
+def x(): pass
+def x(): pass
+
+class X:
+   'first use okay'
+class X:
+   'reuse not okay'
+
+class Y:
+    'should warning about x being redefined'
+    def x(self): pass
+    def x(self): pass
+
+class Z:
+    'should not be a warning'
+    def x(self): pass

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test42.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test42.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test42.py
new file mode 100644
index 0000000..ebf1aac
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test42.py
@@ -0,0 +1,16 @@
+'d'
+
+import sys
+
+def x():
+   print sys.ps1
+   print sys.ps2
+   print sys.tracebacklimit
+   print sys.exc_type
+   print sys.exc_value
+   print sys.exc_traceback
+   print sys.last_type
+   print sys.last_value
+   print sys.last_traceback
+   print sys.__dict__
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test43.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test43.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test43.py
new file mode 100644
index 0000000..460ee7a
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test43.py
@@ -0,0 +1,11 @@
+'d'
+
+class GameObject:
+    'd'
+    # def isIntersecting(self, other): pass
+    pass
+
+class SoAndSo(GameObject):
+    'd'
+    def isIntersecting(self, other):
+        return GameObject.isIntersecting(self, other)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test44.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test44.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test44.py
new file mode 100644
index 0000000..89bd7f8
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test44.py
@@ -0,0 +1,9 @@
+'d'
+
+from import44 import * 
+
+class Ccc:
+  'd'
+  def __init__(self):
+    pass
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test45.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test45.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test45.py
new file mode 100644
index 0000000..21ea625
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test45.py
@@ -0,0 +1,23 @@
+'d'
+
+__pychecker__ = 'argsused'
+
+def x(empty, unused):
+    print 'nothing'
+def y(empty1, unused1):
+    print 'nothing'
+def z():
+    empty = 1
+    unused = 2
+    empty1 = 1
+    unused1 = 2
+
+class A:
+    'd'
+    def x(self, other, empty, unused):
+        print 'nothing'
+    def y(self, other1, empty1, unused1):
+        print 'nothing'
+
+def a():
+  _ = 5

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test46.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test46.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test46.py
new file mode 100644
index 0000000..a5a5885
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test46.py
@@ -0,0 +1,7 @@
+'d'
+
+def x(): pass
+
+import test46
+from test46 import x
+from test46 import *

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test47.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test47.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test47.py
new file mode 100644
index 0000000..fd9af25
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test47.py
@@ -0,0 +1,7 @@
+'there was a spurious warning when the module and class name were the same'
+
+import import47
+
+class jj(import47.import47):
+    'doc'
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test48.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test48.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test48.py
new file mode 100644
index 0000000..9b8b01c
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test48.py
@@ -0,0 +1,84 @@
+'d'
+
+class X:
+    'd'
+    def x(self): pass
+    def y(self): pass
+
+def x():
+    i, l, d, s, n, e = 0, [], {}, '', None, Ellipsis
+    i.has_no_method()
+    l.has_no_method()
+    d.has_no_method()
+    s.has_no_method()
+    n.has_no_method()
+    e.has_no_method()
+
+    print i.has_no_attr
+    print l.has_no_attr
+    print d.has_no_attr
+    print s.has_no_attr
+    print n.has_no_attr
+    print e.has_no_attr
+
+    l.sort()
+    d.clear()
+
+    d[i] = jj = X()
+    jj.a()
+    jj.b()
+    jj.x()
+    jj.y()
+
+def y():
+    for j in []:
+        print j.a()
+
+
+class Z:
+    'd'
+    def __init__(self): pass
+    def x(self): pass
+    def y(self): pass
+
+def zz():
+    tt = Z()
+    tt.a()
+    tt.b()
+    tt.x()
+    tt.y()
+
+def abc(a, b, c):
+    # these should all generate a warning for doing nothing
+    a
+    b
+    c
+    abc
+    5
+    zz.func_doc
+    str
+
+def j343():
+    d = {}
+    d['HOME']
+    l = []
+    l[5]
+    d, l
+
+def jklasdflksdjf():
+  d = {}
+  5 + 3
+  5 - 3
+  5 / 3.
+  5 * 3
+  5 ** 3
+  d.get
+  d[1]
+  d[1:2]
+  d, d
+  [d, d]
+
+def print_item_to(fp, boundary):
+    # this should not generate a warning, note comma at end
+    print >> fp, '\n--' + boundary + '--',
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test49.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test49.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test49.py
new file mode 100644
index 0000000..711766e
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test49.py
@@ -0,0 +1,37 @@
+'d'
+
+def x():
+    d = e = 7
+    print d / e
+    print d / 3
+    print 7 / e
+    print 5 / 6
+
+def y1():
+    x = 0
+    return (x * 100.0) / 10
+
+def y2():
+    x = 0
+    return (x + 100.0) / 10
+
+def y3():
+    x = 0
+    return (x - 100.0) / 10
+
+def y4():
+    x = 1
+    return (x ** 100.0) / 10
+
+def z(e):
+    x = 0
+    if e:
+        x = x + 1
+        return (x * 100.0) / 10
+    y = 0
+    return (x * 100.0) / y
+
+def should_not_warn(a):
+    # this warning should be suppressed automatically
+    x = int(a)
+    return int(x / 5)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test5.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test5.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test5.py
new file mode 100644
index 0000000..46e8fea
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test5.py
@@ -0,0 +1,20 @@
+'test named args'
+__pychecker__ = 'namedargs'
+
+def x(a, b, c = None, d = None, **kw):
+    pass
+
+def y():
+    x(1, 2, c=3, d=4, e=5)
+
+def z():
+    x(1, 2, e=5, d=4)
+
+class X:
+    "doc"
+    def __init__(self):
+        self.y = 0
+    def z(self):
+        "this should not have any warnings"
+        x(self.y, { 'a': 'b' })
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test50.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test50.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test50.py
new file mode 100644
index 0000000..9fd3d8f
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test50.py
@@ -0,0 +1,21 @@
+'d'
+
+__pychecker__ = 'maxargs=4 maxlocals=3'
+
+def A(a, b, c): pass
+def B(a, b, c, d): pass
+def C(a, b, c, d, e): pass
+def D(a, b, c, d, f, g): pass
+
+def E(a, b, c, d):
+    w = x = y = 0
+    print a, b, c, d, w, x, y
+
+def F(a, b, c, d):
+    w = x = y = z = 0
+    print a, b, c, d, w, x, y, z
+
+def G(a, b, c, d):
+    w = x = y = z = jj = 0
+    print a, b, c, d, w, x, y, z, jj
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test51.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test51.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test51.py
new file mode 100644
index 0000000..70033dd
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test51.py
@@ -0,0 +1,19 @@
+'d'
+
+def x():
+    n = []
+    d = {}
+    print n[5]
+    print n[5,-3]
+    print n[1,3]
+    print n[1:3]
+    print n[1:-3]
+
+    print d[5]
+    print d[5,-3]
+    print d[1,3]
+    print d[1:3]
+    print d[1:-3]
+
+    print [1, 2][1]
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test52.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test52.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test52.py
new file mode 100644
index 0000000..cb470ea
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test52.py
@@ -0,0 +1,54 @@
+"doesn't work in 1.5.2"
+
+class foo:
+    'd'
+    def __init__(self, *args, **kwargs):
+        self.args = args
+        self.kw = kwargs
+
+class foo2(foo):
+    'd'
+    def __init__(self, *args):
+        foo.__init__(self, jj=5, kk=10, *args)
+
+class foo3(foo):
+    'd'
+    def __init__(self, **kwargs):
+        foo.__init__(self, jj=5, kk=10, **kwargs)
+
+class foo4(foo):
+    'd'
+    def __init__(self, *args, **kwargs):
+        foo.__init__(self, jj=5, kk=10, *args, **kwargs)
+
+class c: 
+    'd'
+    def __init__(self): 
+        pass 
+
+class c1: 
+    'd'
+    o = c() 
+    def c(self,x): 
+        print x 
+
+def x():
+    a = c1() 
+    a.b = c1() 
+    # we can't handle this yet
+    # a.b.c(5)
+
+class c2: 
+    'd'
+    def m1(self): 
+        print "ok" 
+    def m2(self,x): 
+        print "ok" 
+
+class c3: 
+    'd'
+    c2 = None 
+    def m(self): 
+        self.c2.m1()
+        self.c2.m2(5)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test53.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test53.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test53.py
new file mode 100644
index 0000000..df40518
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test53.py
@@ -0,0 +1,28 @@
+'d'
+
+def x():
+    # these are broken, this is BAD code!!!
+    i = ~~ (10)
+    while i > 0 :
+      --i
+    while i < 100 :
+      ++i
+
+    # these are fine
+    j = 0
+    while j > 0 :
+      j = j - 1
+    while j < 100 :
+      j = j + 1
+
+def y():
+    # should not generate a warning
+    print ("format w/2 strings %s" + "=" + "'%s'") % ('a', 'b')
+    # should generate a warning
+    print ("format w/2 strings %s" + "=" + "'%s'") % ('a', 'b', 'c')
+
+def z():
+    i = -5
+    print +i, i, -i
+    print +5, 5, -5
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test54.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test54.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test54.py
new file mode 100644
index 0000000..45c1b5d
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test54.py
@@ -0,0 +1,20 @@
+'d'
+
+real_global = 0
+
+def f(a, b, c):
+    del a
+    del z
+    z = 0
+    del a
+    del z
+
+    print a, b, c
+
+    global no_global
+    del no_global
+
+if __name__ == '__main__':
+    del another_non_existant_global
+    del real_global
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test55.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test55.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test55.py
new file mode 100644
index 0000000..f08ec9f
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test55.py
@@ -0,0 +1,47 @@
+'d'
+
+def x():
+    try :
+        print "howdy, this ain't right"
+    except KeyError, RuntimeError :
+        pass
+
+def y():
+    try :
+        print "ok, " + "this func %s should be fine" % y.__name__
+    except (KeyError, RuntimeError) :
+        pass
+
+def z():
+    try :
+        pass
+    except (KeyError, RuntimeError, IndexError) :
+        pass
+
+def a():
+    try :
+        pass
+    except (KeyError, RuntimeError, IndexError), a :
+        print a
+
+try :
+    pass
+except KeyError, RuntimeError :
+    pass
+
+try :
+    pass
+except (KeyError, RuntimeError) :
+    pass
+
+def b():
+    try :
+        print "ok, " + "this func %s should be fine" % y.__name__
+    except (KeyError, RuntimeError), msg :
+        print msg
+def c():
+    try :
+        print "ok, " + "this func %s should be fine" % y.__name__
+    except KeyError, detail :
+        print detail
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test56.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test56.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test56.py
new file mode 100644
index 0000000..0eba6c6
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test56.py
@@ -0,0 +1,7 @@
+'doc'
+
+from import56a import Foo
+
+def x():
+  print Foo
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test57.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test57.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test57.py
new file mode 100644
index 0000000..1c8e6df
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test57.py
@@ -0,0 +1,11 @@
+"doesn't work in 1.5.2"
+
+def ttt(c):
+  return None
+
+def x():
+  "should not complain about either, we can't check # args"
+  columns = [ 1, 2 ]
+  print zip(*columns)
+  print ttt(*columns)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test58.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test58.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test58.py
new file mode 100644
index 0000000..abc557f
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test58.py
@@ -0,0 +1,11 @@
+'Note: this will only work on Python 2.1 and before'
+
+yield = None
+
+def x():
+    yield = 53
+    print yield
+
+def y():
+    print yield
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test59.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test59.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test59.py
new file mode 100644
index 0000000..03ed7f0
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test59.py
@@ -0,0 +1,31 @@
+'d'
+
+def x1(a, b, c = [], d = {}):
+  c.reverse()
+  d.update({ a: b})
+
+def x2(a, b, c, d):
+  c.reverse()
+  d.update({ a: b})
+
+def y(a, b, c = [], d = {}):
+  print a, b, c, d
+
+class X:
+  'd'
+  def x(self) : pass
+
+def zz(x = X()):
+    print x.x()
+
+def zz2(a = [], b = {}):
+    a[0] = b
+    b[0] = a
+
+def aaa1(a, b, c = [], d = {}):
+  print c.index(a)
+  print c.count(a)
+  print d.get(b)
+  print d.has_key(b)
+  print d.keys()
+  print d[b]

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test6.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test6.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test6.py
new file mode 100644
index 0000000..e4ad2ee
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test6.py
@@ -0,0 +1,31 @@
+
+"doc"
+
+from xml.dom import pulldom
+
+class X(pulldom.PullDOM) :
+    "doc"
+    def __init__(self):
+        "shouldn't be a warning"
+        pulldom.PullDOM.__init__(self)
+
+class Y(Exception):
+    "doc"
+    def __init__(self, err):
+        "this shouldn't produce a warning"
+        Exception.__init__(self, err)
+
+class Z(Y):
+    "doc"
+    def __init__(self, err):
+        "this shouldn't produce a warning"
+        apply(Y.__init__, (self, err))
+
+def uuu(func):
+    "shouldn't crash"
+    return tuple([i for i in func() if func(globals()[i])])
+
+def yyy():
+    "shouldn't crash"
+    map(apply, globals().keys(), ((),) * len(globals()), globals().values())
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test60.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test60.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test60.py
new file mode 100644
index 0000000..e0d192e
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test60.py
@@ -0,0 +1,22 @@
+'d'
+
+def __repr__(self):
+    print `self`
+
+class X:
+  'd'
+  def __repr__(self):
+    print `self`
+
+class Y:
+  'd'
+  def __init__(self):
+    self.x = 0
+  def __repr__(self):
+    print `self.x`
+
+class Z:
+  'd'
+  def other_method(self):
+    print `self`
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test61.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test61.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test61.py
new file mode 100644
index 0000000..e7eb549
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test61.py
@@ -0,0 +1,28 @@
+'d'
+
+class X:
+  'd'
+  def x(self, g, h): pass
+
+def y():
+  x = X()
+  print x.x()
+
+def z():
+  x = X()
+  print x.x(1, 2)
+
+def a():
+  d = {}
+  print d.get(1, 5)
+  print d.get(1, 5, 7)
+  print d.keys()
+  print d.keys(1, 5, 7)
+  print d.clear()
+  x = d.clear()
+  x.y = d.clear()
+  d.clear()
+  print
+  print setattr(d, 'junk', 'neal')
+  print `d`.rjust(5)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test62.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test62.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test62.py
new file mode 100644
index 0000000..82e821b
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test62.py
@@ -0,0 +1,4 @@
+'bug found by Joe VanAndel'
+
+isintorlong = lambda x: type(x) == type(0) or type(x) == type(0L)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test63.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test63.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test63.py
new file mode 100644
index 0000000..85769a8
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test63.py
@@ -0,0 +1,15 @@
+'d'
+
+def x(v):
+  count = 0
+  if v != 0:
+    return 1
+  return count
+
+def y(v):
+  x = len(v)
+  if x == 0 :
+    return x
+  else :
+    return x - 1
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test64.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test64.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test64.py
new file mode 100644
index 0000000..dad2288
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test64.py
@@ -0,0 +1,17 @@
+'''spurious warnings reported by Andrew Dalke
+'''
+
+import sys, string, re
+import array
+
+class _Anything: pass
+_anything = _Anything()
+
+def outer():
+    def x():
+        return _anything
+
+    def y():
+        return dir(string.translate)
+
+    x()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test65.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test65.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test65.py
new file mode 100644
index 0000000..2f4843d
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test65.py
@@ -0,0 +1,21 @@
+'test nested scopes'
+
+from __future__ import nested_scopes
+
+def x(p):
+    def y():
+       print p
+
+    y()
+    print p
+
+def a(p):
+    def y():
+       print p
+
+    y()
+
+def chop(seq,size):
+    chunk = lambda i: seq[i:i+size]
+    return map(chunk,range(len(seq)))
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test66.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test66.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test66.py
new file mode 100644
index 0000000..6dcad76
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test66.py
@@ -0,0 +1,7 @@
+'d'
+
+from time import time, sleep
+
+def x():
+    print time, sleep
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test67.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test67.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test67.py
new file mode 100644
index 0000000..67ddd4c
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test67.py
@@ -0,0 +1,16 @@
+'d'
+
+__pychecker__ = 'members'
+
+class X:
+  'd'
+  j = 0
+  def __init__(self):
+    self.a = 0
+    self.b = 0
+    self.c = 0
+    self.d = 0
+
+  def p(self):
+    print self.b, self.c, self.j
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test68.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test68.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test68.py
new file mode 100644
index 0000000..547f4d6
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test68.py
@@ -0,0 +1,170 @@
+'test implicit returns'
+
+__pychecker__ = 'implicitreturns'
+
+def func1(x):
+    'should not produce a warning'
+    if x == 1:
+        return 1
+    return 0
+
+def func2(x):
+    'should produce a warning'
+    if x == 1:
+        return 1
+
+def func3(x):
+    'should not produce a warning'
+    while 1:
+        if x == 1:
+            return 1
+        x = x / 2
+    return 0
+
+def func4(x):
+    'should not produce a warning'
+    while 1:
+        if x == 1:
+            return 1
+        x = x / 2
+
+def func5(x):
+    'should not produce a warning'
+    while 1:
+        if x == 1:
+            return 1
+    return 0
+
+def func6(x):
+    'should produce a warning'
+    while 1:
+        if x == 1:
+            return 1
+        break
+
+def func7(x):
+    'should not produce a warning'
+    try:
+        print x
+        return 2
+    except:
+        pass
+    return 0
+
+def func8(x):
+    'should produce a warning'
+    try:
+        if x == 1:
+            return 3
+        if x == 2:
+            return 6
+    except:
+        pass
+
+def func9(x):
+    'should not produce a warning'
+    try:
+        return x
+    except:
+        return 0
+
+def func10(x):
+    'should not produce a warning'
+    if x:
+        raise ValueError
+
+def func11(x):
+    'should not produce a warning'
+    if x:
+        raise ValueError
+    return 5
+
+def func12(x):
+    'should not produce a warning'
+    raise ValueError, 'test'
+
+def func13(x):
+    'should not produce a warning'
+    if x == 1:
+        return 1
+    else:
+        return 0
+
+def func14(x):
+    'should not produce a warning'
+    try:
+        if x == 1:
+            return 3
+        return 6
+    except:
+        raise
+
+def func15(x):
+    'should not produce a warning'
+    try:
+        return x.j
+    except AttributeError:
+        return 0
+
+def func16(x):
+    'should not produce a warning'
+    try:
+        return x.j
+    except AttributeError:
+        raise
+
+def func17(x):
+    'should not produce a warning'
+    try:
+        return x.j
+    except (AttributeError, KeyError, IndexError):
+        return 0
+
+def func18(x):
+    if x == 'n':
+        return x
+    if x != 'j':
+        raise AttributeError
+
+def func19(x):
+    'should not produce a warning'
+    while 1:
+        if x:
+            x = x + 1
+        return 1
+
+def func20(x):
+    'should produce a warning'
+    while 1:
+        if x:
+            break
+        return 1
+
+def func21(x):
+    'should not produce a warning'
+    try:
+        if x == 1:
+            return 3
+        return 6
+    finally:
+        print 'do nothing'
+
+def func22(x):
+    'should not produce a warning'
+    while 1:
+        for _ in range(10) :
+            x = x / 2
+            break
+        return 1
+
+def catchup(slave, image, inProgress):
+    d = func1.bogus()
+    def next_func():
+        defer = slave.call('', image.next())
+        try:
+            defer.add(d.errback)
+        except:
+            slave.call(inProgress)
+    next_func()
+    return d
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test69.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test69.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test69.py
new file mode 100644
index 0000000..457019e
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test69.py
@@ -0,0 +1,22 @@
+'d'
+
+import import69
+
+__pychecker__ = 'callattr'
+class B:
+    'd'
+    def __init__(self): pass
+
+class C(B):
+    'd'
+    __super_init = B.__init__
+    def __init__(self):
+        self.__super_init()
+
+class D(import69.Alias):
+    'd'
+    __super_init = import69.Alias.__init__
+    def __init__(self):
+        self.__super_init()
+
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test7.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test7.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test7.py
new file mode 100644
index 0000000..f201ac0
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test7.py
@@ -0,0 +1,18 @@
+
+"doc"
+
+def func(): pass
+
+class X:
+    "should only generate a warning w/-A, --callattr cmd line options"
+    def __init__(self, other):
+        self.func = func
+        self.other = other
+        self.x = None
+
+    def test(self):
+        "self.y should generate a function"
+        self.func()
+        self.other()
+        self.x()
+        self.y()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test70.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test70.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test70.py
new file mode 100644
index 0000000..379a9ea
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test70.py
@@ -0,0 +1,60 @@
+'test checking constant conditions'
+
+# __pychecker__ = ''
+
+def func1(x):
+    'should not produce a warning'
+    if 1:
+        pass
+    while 1:
+        print x
+        break
+    assert x, 'test'
+    return 0
+
+def func2(x):
+    'should produce a warning'
+    __pychecker__ = 'constant1'
+    if 1:
+        pass
+    while 1:
+        print x
+        break
+    return 0
+
+def func3(x):
+    'should produce a warning'
+    if 21:
+        return 1
+    if 31:
+        return 2
+    assert(x, 'test')
+    assert(5, 'test')
+    assert 5, 'test'
+
+    if 'str':
+        return 3
+
+    return 4
+
+def func4(x):
+    'should not produce a warning'
+    if x == 204 or x == 201 or 200 <= x < 300:
+        x = 0
+    if x == 1:
+        pass
+    while x == 'str':
+        print x
+        break
+    return 0
+
+def func5(need_quotes, text):
+    'should not produce a warning'
+    return (need_quotes) and ('"%s"' % text) or (text)
+
+def func6(x):
+    'should not produce warnings'
+    if x & 32:
+        print 'ya'
+    if 32 & x:
+        print 'ya'

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test71.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test71.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test71.py
new file mode 100644
index 0000000..e45ea05
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test71.py
@@ -0,0 +1,50 @@
+'test unreachable code'
+
+__pychecker__ = 'unreachable'
+
+def a(x):
+    if x == 5:
+        return x
+    return 0
+    print x
+
+def b(x):
+    if x == 5:
+        return x
+    raise ValueError
+    print x
+
+def c(x):
+    if x == 5:
+        return
+    return
+    print x
+
+def d(x):
+    if x == 5:
+        return
+    raise ValueError
+    print x
+
+def e(x):
+    def foo():
+        print x
+    foo()
+    return x
+
+def f():
+    x = e(1)
+    print x
+
+class Point:
+    """doc string"""
+    parse = None
+
+    def get_position(self, parts):
+        try:
+            return Point.parse('%s %s' % (parts[1], parts[2]), float(parts[3]))
+        except ValueError, e:
+            # FIXME: handle better than printing
+            print 'Unable to process position report\n', e
+        return None
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test72.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test72.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test72.py
new file mode 100644
index 0000000..d32771b
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test72.py
@@ -0,0 +1,29 @@
+'test setting class attributes not in __init__ w/initattr set'
+
+__pychecker__ = 'initattr no-classdoc'
+
+class A:
+  'd'
+  def a(self):
+    self.y = 0
+
+class B(A):
+  'd'
+  def b(self):
+    self.z = 0
+
+class C:
+  'd'
+  def __init__(self):
+    self.a = self.b = self.c = 0
+    self.d = None
+    self.e = []
+
+  def b(self):
+    print self.z
+    self.y = 0
+
+class D(C):
+  def c(self):
+    self.a = 5
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test73.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test73.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test73.py
new file mode 100644
index 0000000..47b2dc4
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test73.py
@@ -0,0 +1,37 @@
+'test abstract classes'
+
+__pychecker__ = 'no-classdoc'
+
+class Abstract:
+    def f(self): raise NotImplementedError, "override in subclass"
+    def g(self): raise NotImplementedError
+class ConcreteBad(Abstract):
+    def g(self): pass
+class ConcreteGood(ConcreteBad):
+    def f(self): pass
+a = Abstract()                          # error
+cb = ConcreteBad()                      # error
+cg = ConcreteGood()                     # ok, f defined
+
+class ConcreteInst:
+    def f(self): raise SystemError("not yet ready for prime time")
+ch = ConcreteInst()                     # ok, raises SystemError
+
+class AbstractInst:
+    def f(self): raise NotImplementedError("not yet ready for prime time")
+ch = AbstractInst()
+
+cb.g()
+def f():
+    class MoreBad(Abstract):
+        def g(): pass
+    _ = MoreBad()                       # FIXME, error not caught
+
+import import73
+class ImplAbstract(import73.AbstractLib):
+    def __init__(self):
+        import73.AbstractLib.__init__(self)
+
+def lib_example():
+    _ = import73.AbstractLib()          # error
+    unused = ImplAbstract()             # error

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test74.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test74.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test74.py
new file mode 100644
index 0000000..acf45e3
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test74.py
@@ -0,0 +1,41 @@
+'test __getattr[ibute]__ returning None'
+
+class A:
+    'no warning'
+    def __getattr__(self, attr):
+        return attr
+
+class B:
+    'no warning'
+    def __getattribute__(self, attr):
+        return attr
+
+class C:
+    'warning'
+    def __getattr__(self, attr):
+        pass
+
+class D:
+    'warning'
+    def __getattribute__(self, attr):
+        pass
+
+class E:
+    'warning'
+    def __getattr__(self, attr):
+        if attr == 'n':
+            return attr
+        if attr != 'j':
+            raise AttributeError
+
+class F:
+    'no warning'
+    def __getattr__(self, attr):
+        if attr == 'n':
+            return attr
+        raise AttributeError
+
+class G:
+    'should not gen a warning'
+    def __getattr__(self, name):
+        return getattr(self, 'a')[name]

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test75.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test75.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test75.py
new file mode 100644
index 0000000..c8f5ee8
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test75.py
@@ -0,0 +1,87 @@
+'test slots & property, this will only work in Python 2.2'
+
+class A:
+    'warn about using slots in classic classes'
+    __slots__ = ('a',)
+
+try:
+    class B(object):
+        'no warning'
+        __slots__ = ('a',)
+
+    class C(object):
+        'warn about using empty slots'
+        __slots__ = ()
+
+    class D(object):
+        "don't warn about using empty slots"
+        __pychecker__ = '--no-emptyslots'
+        __slots__ = ()
+
+    class E:
+        'this should generate a warning for using properties w/classic classes'
+        def getx(self):
+            print 'get x'
+            return 5
+        x = property(getx)
+
+    class F(object):
+        'this should not generate a warning for using properties'
+        def getx(self):
+            print 'get x'
+            return 5
+        x = property(getx)
+
+    class Solution(list):
+        'this should not generate a warning or crash'
+        def __init__(self):
+            pass
+
+    class MethodArgNames:
+        'check warnings for static/class methods for first arg name'
+        def __init__(self, *args): pass
+
+        # should warn
+        def nn(self, *args): pass
+        nn = classmethod(nn)
+
+        # should warn
+        def mm(self, *args): pass
+        mm = staticmethod(mm)
+
+        # should not warn
+        def oo(cls, *args): pass
+        oo = classmethod(oo)
+
+        # should not warn
+        def pp(*args): pass
+        pp = staticmethod(pp)
+
+        # should not warn
+        def qq(): pass
+        qq = staticmethod(qq)
+
+        # should not warn
+        def rr(klass, *args): pass
+        rr = classmethod(rr)
+
+    class Bug4(object):
+        '''doc'''
+        def static(arg1, arg2):
+            return arg1+arg2
+        static = staticmethod(static)
+
+        def buggy(self):
+            return self.static(1,2)
+
+    class Slots(dict):
+        'doc'
+        pass
+
+    class Foo(object):
+        'doc'
+        __slots__ = Slots()
+
+except NameError:
+    pass
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test76.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test76.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test76.py
new file mode 100644
index 0000000..bffc077
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test76.py
@@ -0,0 +1,12 @@
+'test 3+ nested functions'
+
+__pychecker__ = 'argsused'
+
+def x(a=1):
+    def y(b=2, c=3, d=4):
+        def z(b=2, e=5):
+            print 'in z', b, e
+        print 'in y', b, c
+        z()
+    print 'in x'
+    y()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test77.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test77.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test77.py
new file mode 100644
index 0000000..002b3b6
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test77.py
@@ -0,0 +1,9 @@
+"always raise an exception and make sure pychecker doesn't - from Greg Ward"
+
+class MyError(Exception):
+    'd'
+    def __init__(self, msg):
+        self.msg = msg
+
+raise MyError("FOO!")
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test78.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test78.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test78.py
new file mode 100644
index 0000000..73e1378
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test78.py
@@ -0,0 +1,19 @@
+'test using input()'
+
+import readline # should not generate a warning since input/raw_input() is used
+
+def f1():
+    x = input()
+    print x
+
+def f2():
+    x = raw_input()
+    print x
+
+def f3():
+    'should not generate a warning, since this is not the real input'
+    __pychecker__ = 'no-shadowbuiltin'
+    def input(): return 0
+
+    x = input()
+    print x

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test79.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test79.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test79.py
new file mode 100644
index 0000000..8524f94
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test79.py
@@ -0,0 +1,33 @@
+'test iterating over a string'
+
+__pychecker__ = 'stringiter'
+
+def func1():
+    'should generate a warning'
+    s = 'string'
+    for c in s:
+        print 'oops', c[0]
+
+def func2():
+    'should generate a warning'
+    f = open('/dev/null')
+    s = f.read()
+    for c in s:
+        print 'oops', c[0]
+
+def func3():
+    'should not generate a warning'
+    for i in []:
+        print 'ok', i
+    for i in ():
+        print 'ok', i
+
+def func4():
+    'should not generate a warning'
+    v = []
+    for i in v:
+        print 'ok', i
+    w = ()
+    for i in w:
+        print 'ok', i
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test8.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test8.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test8.py
new file mode 100644
index 0000000..0ac0586
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test8.py
@@ -0,0 +1,4 @@
+"doc"
+
+def func():
+    syntax error here

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test80.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test80.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test80.py
new file mode 100644
index 0000000..a855134
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test80.py
@@ -0,0 +1,25 @@
+'test inconsistent types'
+
+__pychecker__ = 'changetypes'
+
+def func1():
+    'should generate a warning'
+    x = 0
+    x += 1.1
+    print x
+
+def func2():
+    'should not generate a warning'
+    x = ""
+    x = "string"
+    for j in []:
+        x = j
+    print x
+
+def func3():
+    'should generate a warning'
+    y = None
+    y = []
+    y = {}
+    print y
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test81.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test81.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test81.py
new file mode 100644
index 0000000..6e9e1f8
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test81.py
@@ -0,0 +1,30 @@
+'test use of freevars and cellvars'
+
+from __future__ import nested_scopes
+
+__pychecker__ = 'classattr'
+
+class Board:
+    'base class to test'
+    def atomCount(self):
+        pass
+
+def func(l):
+    pass
+
+class BoardTests:
+    'should not generate a warning'
+    def testAddAtom(self):
+        b = Board()
+        b.atomCount()
+        func(lambda:b.atomCount())
+
+def q(funcp):
+   print funcp()
+
+def f():
+   y = 1
+   def g():
+      return y
+   q(g)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test82.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test82.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test82.py
new file mode 100644
index 0000000..8b2cb63
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test82.py
@@ -0,0 +1,18 @@
+'test private globals in a class, from tom culliton'
+
+_happy_private_name=("eyes", "nose", "fingers", "toes")
+__unhappy_private_name=("missing life", "long commute", "dumb user")
+
+def whatsit(thingee):
+    if (thingee in _happy_private_name
+    or  thingee in __unhappy_private_name):
+        return "I got one too!"
+    else:
+        return "Ooo! What's that?"
+
+class geek:
+    'd'
+    def __init__(self):
+        self.happy = _happy_private_name
+        self.unhappy = __unhappy_private_name
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test83.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test83.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test83.py
new file mode 100644
index 0000000..f2a6a94
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test83.py
@@ -0,0 +1,43 @@
+'test unpacking variables'
+
+def func1():
+    'should not warn'
+    x, z = (5, 2)
+
+def func2():
+    'should warn'
+    x, y, z = (5, 2)
+
+def func3():
+    'should warn'
+    a = (5, 2)
+    x, y, z = a
+
+def func4():
+    'should warn'
+    x, = (5, 2)
+
+def func5():
+    'should warn'
+    x, y = 5,
+
+def func6():
+    'should warn'
+    x, = 5
+
+def func101():
+    'should not warn'
+    x, y, z = (5, 2, 3, 4, 5)[:3]
+
+def func102():
+    'should warn ideally, but size becomes unknown'
+    x, y, z = (5, 2, 3, 4, 5)[:2]
+
+def func103():
+    'should not warn'
+    x, y, z = (5, 2, 3, 4, 5)[2:]
+
+def func104():
+    'should warn ideally, but size becomes unknown'
+    x, y, z = (5, 2, 3, 4, 5)[3:]
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test84.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test84.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test84.py
new file mode 100644
index 0000000..a26bea6
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test84.py
@@ -0,0 +1,10 @@
+'this crashed pychecker from calendar.py in Python 2.2'
+
+class X:
+    'd'
+    def test(self, item):
+        return [e for e in item].__getslice__()
+
+# this crashed in 2.2, but not 2.3
+def f(a):
+  a.a = [x for x in range(2) if x > 1]

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test85.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test85.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test85.py
new file mode 100644
index 0000000..b549493
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test85.py
@@ -0,0 +1,22 @@
+'''test return (x and 'true' or 'false') idiom'''
+
+def f1(test):
+    'should not warn'
+    return test and 'true' or 'false'
+
+def f2(test):
+    'should not warn about None'
+    return test and 'true' or None
+
+def f3(test):
+    'should warn about None'
+    return test and None or 'false'
+
+def f4(test):
+    'should warn'
+    return test and [] or 0
+
+def f5(test):
+    'should not warn'
+    return test and 'true' or 0
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test86.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test86.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test86.py
new file mode 100644
index 0000000..36935c0
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test86.py
@@ -0,0 +1,96 @@
+'warn about raising/catching string exceptions'
+
+__pychecker__ = 'no-classdoc'
+
+class g(Exception): pass
+h = 'blah'
+i = g
+j = KeyError
+class k: pass
+
+def f1(a, b, c):
+    'should not warn'
+    class z(Exception): pass
+    if a:
+        raise
+    if a:
+        raise KeyError
+    if a:
+        raise b, ''
+    if a:
+        raise c()
+    if a:
+        raise g, ''
+    if a:
+        raise i
+    if a:
+        raise j
+    if a:
+        raise z
+
+def f2(a):
+    'should warn'
+    if a:
+        raise 'strerr'
+    if a:
+        raise h, ''
+    if a:
+        raise k
+
+def f3(a, b, c):
+    'should not warn'
+    class z(Exception): pass
+    try:
+        f1(a, b, c)
+    except a:
+        pass
+    except b.bbb:
+        pass
+    except KeyError:
+        pass
+    except (TypeError, KeyError):
+        pass
+    except g:
+        pass
+    except z:
+        pass
+    except (g, z):
+        pass
+    except i, detail:
+        print detail
+    except Exception, detail:
+        print detail
+    except:
+        pass
+
+def f4(a):
+    'should warn'
+    try:
+        f2(a)
+    except 'strerr':
+        pass
+    except ('strerr1', 'strerr2'):
+        pass
+    except ('strerr1', KeyError):
+        pass
+    except h:
+        pass
+    except k:
+        pass
+
+tt = (KeyError, ValueError)
+
+def f5(a):
+    'should not warn'
+    try:
+        f2(a)
+    except tt:
+        pass
+
+def f6(a):
+    'should not warn'
+    # but does in 0.8.17
+    try:
+        pass
+    except KeyboardInterrupt:
+        pass



[09/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code

Posted by rl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-operatorPlus
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-operatorPlus b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-operatorPlus
new file mode 100644
index 0000000..3de3e4f
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-operatorPlus
@@ -0,0 +1,48 @@
+tests/badparse.py:1 Unable to parse: could not parse string
+
+tests/class.py:20 Method x defined at line 28 in class A redefined
+tests/class.py:21 Class A has no attribute w
+tests/class.py:28 Method x is missing self parameter
+tests/class.py:38 Class A has no attribute w
+
+tests/global.py:3 Unknown identifier: y
+
+tests/import.py:1 Identifier (bar) not used
+tests/import.py:3 Identifier (nifty) not used
+tests/import.py:7 Import of "join" is duplicate of import in parent scope <ModuleScope: global>
+tests/import.py:9 Unknown identifier: __all__
+tests/import.py:13 Error trying to import xYzZy: No module named xYzZy
+tests/import.py:14 Unknown identifier: z
+tests/import.py:17 Identifier (getopt) not used
+tests/import.py:17 Import of "getopt" is duplicate in current scope
+tests/import.py:18 Import of "join" duplicates import from module posixpath at 4
+tests/import.py:18 Import of "split" duplicates import from module posixpath at 4
+
+tests/not_there.py:[unknown line] Unable to parse: [Errno 2] No such file or directory: 'tests/not_there.py'
+
+tests/op.py:2 Operator (++) doesn't exist, statement has no effect
+tests/op.py:4 Scope (g) is redefined at line 7
+tests/op.py:8 Operator (--) doesn't exist, statement has no effect
+
+tests/self.py:9 First argument to method f (x) is not in ['self', 'this', 's']
+tests/self.py:14 Identifier (a) not used
+
+tests/shadow.py:2 Scope (f) is redefined at line 8
+tests/shadow.py:4 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:15 Identifier (a) not used
+tests/shadow.py:15 Identifier (b) not used
+tests/shadow.py:15 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:16 Identifier (f) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:17 Identifier (a) not used
+tests/shadow.py:17 Identifier (a) shadows definition in scope <FunctionScope: g>
+tests/shadow.py:17 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:18 Identifier (b) not used
+tests/shadow.py:18 Identifier (b) shadows definition in scope <FunctionScope: g>
+tests/shadow.py:19 Unknown identifier: c
+tests/shadow.py:19 Unknown identifier: d
+tests/shadow.py:22 Identifier (a) shadows definition in scope <ModuleScope: global>
+
+tests/unused.py:6 Identifier (Test) not used
+
+tests/unusedImport.py:1 Identifier (sys) not used
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-redefinedScope
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-redefinedScope b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-redefinedScope
new file mode 100644
index 0000000..e3df55a
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-redefinedScope
@@ -0,0 +1,47 @@
+tests/badparse.py:1 Unable to parse: could not parse string
+
+tests/class.py:20 Method x defined at line 28 in class A redefined
+tests/class.py:21 Class A has no attribute w
+tests/class.py:28 Method x is missing self parameter
+tests/class.py:38 Class A has no attribute w
+
+tests/global.py:3 Unknown identifier: y
+
+tests/import.py:1 Identifier (bar) not used
+tests/import.py:3 Identifier (nifty) not used
+tests/import.py:7 Import of "join" is duplicate of import in parent scope <ModuleScope: global>
+tests/import.py:9 Unknown identifier: __all__
+tests/import.py:13 Error trying to import xYzZy: No module named xYzZy
+tests/import.py:14 Unknown identifier: z
+tests/import.py:17 Identifier (getopt) not used
+tests/import.py:17 Import of "getopt" is duplicate in current scope
+tests/import.py:18 Import of "join" duplicates import from module posixpath at 4
+tests/import.py:18 Import of "split" duplicates import from module posixpath at 4
+
+tests/not_there.py:[unknown line] Unable to parse: [Errno 2] No such file or directory: 'tests/not_there.py'
+
+tests/op.py:2 Operator (++) doesn't exist, statement has no effect
+tests/op.py:5 Operator (+) normally has no effect
+tests/op.py:8 Operator (--) doesn't exist, statement has no effect
+
+tests/self.py:9 First argument to method f (x) is not in ['self', 'this', 's']
+tests/self.py:14 Identifier (a) not used
+
+tests/shadow.py:4 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:15 Identifier (a) not used
+tests/shadow.py:15 Identifier (b) not used
+tests/shadow.py:15 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:16 Identifier (f) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:17 Identifier (a) not used
+tests/shadow.py:17 Identifier (a) shadows definition in scope <FunctionScope: g>
+tests/shadow.py:17 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:18 Identifier (b) not used
+tests/shadow.py:18 Identifier (b) shadows definition in scope <FunctionScope: g>
+tests/shadow.py:19 Unknown identifier: c
+tests/shadow.py:19 Unknown identifier: d
+tests/shadow.py:22 Identifier (a) shadows definition in scope <ModuleScope: global>
+
+tests/unused.py:6 Identifier (Test) not used
+
+tests/unusedImport.py:1 Identifier (sys) not used
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-selfName
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-selfName b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-selfName
new file mode 100644
index 0000000..a4decde
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-selfName
@@ -0,0 +1,48 @@
+tests/badparse.py:1 Unable to parse: could not parse string
+
+tests/class.py:20 Method x defined at line 28 in class A redefined
+tests/class.py:21 Class A has no attribute w
+tests/class.py:28 Method x is missing self parameter
+tests/class.py:38 Class A has no attribute w
+
+tests/global.py:3 Unknown identifier: y
+
+tests/import.py:1 Identifier (bar) not used
+tests/import.py:3 Identifier (nifty) not used
+tests/import.py:7 Import of "join" is duplicate of import in parent scope <ModuleScope: global>
+tests/import.py:9 Unknown identifier: __all__
+tests/import.py:13 Error trying to import xYzZy: No module named xYzZy
+tests/import.py:14 Unknown identifier: z
+tests/import.py:17 Identifier (getopt) not used
+tests/import.py:17 Import of "getopt" is duplicate in current scope
+tests/import.py:18 Import of "join" duplicates import from module posixpath at 4
+tests/import.py:18 Import of "split" duplicates import from module posixpath at 4
+
+tests/not_there.py:[unknown line] Unable to parse: [Errno 2] No such file or directory: 'tests/not_there.py'
+
+tests/op.py:2 Operator (++) doesn't exist, statement has no effect
+tests/op.py:4 Scope (g) is redefined at line 7
+tests/op.py:5 Operator (+) normally has no effect
+tests/op.py:8 Operator (--) doesn't exist, statement has no effect
+
+tests/self.py:14 Identifier (a) not used
+
+tests/shadow.py:2 Scope (f) is redefined at line 8
+tests/shadow.py:4 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:15 Identifier (a) not used
+tests/shadow.py:15 Identifier (b) not used
+tests/shadow.py:15 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:16 Identifier (f) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:17 Identifier (a) not used
+tests/shadow.py:17 Identifier (a) shadows definition in scope <FunctionScope: g>
+tests/shadow.py:17 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:18 Identifier (b) not used
+tests/shadow.py:18 Identifier (b) shadows definition in scope <FunctionScope: g>
+tests/shadow.py:19 Unknown identifier: c
+tests/shadow.py:19 Unknown identifier: d
+tests/shadow.py:22 Identifier (a) shadows definition in scope <ModuleScope: global>
+
+tests/unused.py:6 Identifier (Test) not used
+
+tests/unusedImport.py:1 Identifier (sys) not used
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-shadowIdentifier
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-shadowIdentifier b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-shadowIdentifier
new file mode 100644
index 0000000..93ce959
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-shadowIdentifier
@@ -0,0 +1,42 @@
+tests/badparse.py:1 Unable to parse: could not parse string
+
+tests/class.py:20 Method x defined at line 28 in class A redefined
+tests/class.py:21 Class A has no attribute w
+tests/class.py:28 Method x is missing self parameter
+tests/class.py:38 Class A has no attribute w
+
+tests/global.py:3 Unknown identifier: y
+
+tests/import.py:1 Identifier (bar) not used
+tests/import.py:3 Identifier (nifty) not used
+tests/import.py:7 Import of "join" is duplicate of import in parent scope <ModuleScope: global>
+tests/import.py:9 Unknown identifier: __all__
+tests/import.py:13 Error trying to import xYzZy: No module named xYzZy
+tests/import.py:14 Unknown identifier: z
+tests/import.py:17 Identifier (getopt) not used
+tests/import.py:17 Import of "getopt" is duplicate in current scope
+tests/import.py:18 Import of "join" duplicates import from module posixpath at 4
+tests/import.py:18 Import of "split" duplicates import from module posixpath at 4
+
+tests/not_there.py:[unknown line] Unable to parse: [Errno 2] No such file or directory: 'tests/not_there.py'
+
+tests/op.py:2 Operator (++) doesn't exist, statement has no effect
+tests/op.py:4 Scope (g) is redefined at line 7
+tests/op.py:5 Operator (+) normally has no effect
+tests/op.py:8 Operator (--) doesn't exist, statement has no effect
+
+tests/self.py:9 First argument to method f (x) is not in ['self', 'this', 's']
+tests/self.py:14 Identifier (a) not used
+
+tests/shadow.py:2 Scope (f) is redefined at line 8
+tests/shadow.py:15 Identifier (a) not used
+tests/shadow.py:15 Identifier (b) not used
+tests/shadow.py:17 Identifier (a) not used
+tests/shadow.py:18 Identifier (b) not used
+tests/shadow.py:19 Unknown identifier: c
+tests/shadow.py:19 Unknown identifier: d
+
+tests/unused.py:6 Identifier (Test) not used
+
+tests/unusedImport.py:1 Identifier (sys) not used
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-syntaxErrors
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-syntaxErrors b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-syntaxErrors
new file mode 100644
index 0000000..ab26963
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-syntaxErrors
@@ -0,0 +1,45 @@
+tests/class.py:20 Method x defined at line 28 in class A redefined
+tests/class.py:21 Class A has no attribute w
+tests/class.py:28 Method x is missing self parameter
+tests/class.py:38 Class A has no attribute w
+
+tests/global.py:3 Unknown identifier: y
+
+tests/import.py:1 Identifier (bar) not used
+tests/import.py:3 Identifier (nifty) not used
+tests/import.py:7 Import of "join" is duplicate of import in parent scope <ModuleScope: global>
+tests/import.py:9 Unknown identifier: __all__
+tests/import.py:13 Error trying to import xYzZy: No module named xYzZy
+tests/import.py:14 Unknown identifier: z
+tests/import.py:17 Identifier (getopt) not used
+tests/import.py:17 Import of "getopt" is duplicate in current scope
+tests/import.py:18 Import of "join" duplicates import from module posixpath at 4
+tests/import.py:18 Import of "split" duplicates import from module posixpath at 4
+
+tests/op.py:2 Operator (++) doesn't exist, statement has no effect
+tests/op.py:4 Scope (g) is redefined at line 7
+tests/op.py:5 Operator (+) normally has no effect
+tests/op.py:8 Operator (--) doesn't exist, statement has no effect
+
+tests/self.py:9 First argument to method f (x) is not in ['self', 'this', 's']
+tests/self.py:14 Identifier (a) not used
+
+tests/shadow.py:2 Scope (f) is redefined at line 8
+tests/shadow.py:4 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:15 Identifier (a) not used
+tests/shadow.py:15 Identifier (b) not used
+tests/shadow.py:15 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:16 Identifier (f) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:17 Identifier (a) not used
+tests/shadow.py:17 Identifier (a) shadows definition in scope <FunctionScope: g>
+tests/shadow.py:17 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:18 Identifier (b) not used
+tests/shadow.py:18 Identifier (b) shadows definition in scope <FunctionScope: g>
+tests/shadow.py:19 Unknown identifier: c
+tests/shadow.py:19 Unknown identifier: d
+tests/shadow.py:22 Identifier (a) shadows definition in scope <ModuleScope: global>
+
+tests/unused.py:6 Identifier (Test) not used
+
+tests/unusedImport.py:1 Identifier (sys) not used
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-unknown
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-unknown b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-unknown
new file mode 100644
index 0000000..52dc58e
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-unknown
@@ -0,0 +1,43 @@
+tests/badparse.py:1 Unable to parse: could not parse string
+
+tests/class.py:20 Method x defined at line 28 in class A redefined
+tests/class.py:21 Class A has no attribute w
+tests/class.py:28 Method x is missing self parameter
+tests/class.py:38 Class A has no attribute w
+
+tests/import.py:1 Identifier (bar) not used
+tests/import.py:3 Identifier (nifty) not used
+tests/import.py:7 Import of "join" is duplicate of import in parent scope <ModuleScope: global>
+tests/import.py:13 Error trying to import xYzZy: No module named xYzZy
+tests/import.py:17 Identifier (getopt) not used
+tests/import.py:17 Import of "getopt" is duplicate in current scope
+tests/import.py:18 Import of "join" duplicates import from module posixpath at 4
+tests/import.py:18 Import of "split" duplicates import from module posixpath at 4
+
+tests/not_there.py:[unknown line] Unable to parse: [Errno 2] No such file or directory: 'tests/not_there.py'
+
+tests/op.py:2 Operator (++) doesn't exist, statement has no effect
+tests/op.py:4 Scope (g) is redefined at line 7
+tests/op.py:5 Operator (+) normally has no effect
+tests/op.py:8 Operator (--) doesn't exist, statement has no effect
+
+tests/self.py:9 First argument to method f (x) is not in ['self', 'this', 's']
+tests/self.py:14 Identifier (a) not used
+
+tests/shadow.py:2 Scope (f) is redefined at line 8
+tests/shadow.py:4 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:15 Identifier (a) not used
+tests/shadow.py:15 Identifier (b) not used
+tests/shadow.py:15 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:16 Identifier (f) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:17 Identifier (a) not used
+tests/shadow.py:17 Identifier (a) shadows definition in scope <FunctionScope: g>
+tests/shadow.py:17 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:18 Identifier (b) not used
+tests/shadow.py:18 Identifier (b) shadows definition in scope <FunctionScope: g>
+tests/shadow.py:22 Identifier (a) shadows definition in scope <ModuleScope: global>
+
+tests/unused.py:6 Identifier (Test) not used
+
+tests/unusedImport.py:1 Identifier (sys) not used
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-unpackedUsed
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-unpackedUsed b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-unpackedUsed
new file mode 100644
index 0000000..2230ee3
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-unpackedUsed
@@ -0,0 +1,52 @@
+tests/badparse.py:1 Unable to parse: could not parse string
+
+tests/class.py:20 Method x defined at line 28 in class A redefined
+tests/class.py:21 Class A has no attribute w
+tests/class.py:28 Method x is missing self parameter
+tests/class.py:38 Class A has no attribute w
+
+tests/global.py:3 Unknown identifier: y
+
+tests/import.py:1 Identifier (bar) not used
+tests/import.py:3 Identifier (nifty) not used
+tests/import.py:7 Import of "join" is duplicate of import in parent scope <ModuleScope: global>
+tests/import.py:9 Unknown identifier: __all__
+tests/import.py:13 Error trying to import xYzZy: No module named xYzZy
+tests/import.py:14 Unknown identifier: z
+tests/import.py:17 Identifier (getopt) not used
+tests/import.py:17 Import of "getopt" is duplicate in current scope
+tests/import.py:18 Import of "join" duplicates import from module posixpath at 4
+tests/import.py:18 Import of "split" duplicates import from module posixpath at 4
+
+tests/not_there.py:[unknown line] Unable to parse: [Errno 2] No such file or directory: 'tests/not_there.py'
+
+tests/op.py:2 Operator (++) doesn't exist, statement has no effect
+tests/op.py:4 Scope (g) is redefined at line 7
+tests/op.py:5 Operator (+) normally has no effect
+tests/op.py:8 Operator (--) doesn't exist, statement has no effect
+
+tests/self.py:9 First argument to method f (x) is not in ['self', 'this', 's']
+tests/self.py:14 Identifier (a) not used
+
+tests/shadow.py:2 Scope (f) is redefined at line 8
+tests/shadow.py:4 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:15 Identifier (a) not used
+tests/shadow.py:15 Identifier (b) not used
+tests/shadow.py:15 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:16 Identifier (f) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:17 Identifier (a) not used
+tests/shadow.py:17 Identifier (a) shadows definition in scope <FunctionScope: g>
+tests/shadow.py:17 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:18 Identifier (b) not used
+tests/shadow.py:18 Identifier (b) shadows definition in scope <FunctionScope: g>
+tests/shadow.py:19 Unknown identifier: c
+tests/shadow.py:19 Unknown identifier: d
+tests/shadow.py:22 Identifier (a) shadows definition in scope <ModuleScope: global>
+
+tests/unused.py:6 Identifier (Test) not used
+tests/unused.py:30 Identifier (b) not used
+tests/unused.py:30 Identifier (c) not used
+tests/unused.py:30 Identifier (d) not used
+
+tests/unusedImport.py:1 Identifier (sys) not used
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-unused
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-unused b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-unused
new file mode 100644
index 0000000..d378496
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-unused
@@ -0,0 +1,36 @@
+tests/badparse.py:1 Unable to parse: could not parse string
+
+tests/class.py:20 Method x defined at line 28 in class A redefined
+tests/class.py:21 Class A has no attribute w
+tests/class.py:28 Method x is missing self parameter
+tests/class.py:38 Class A has no attribute w
+
+tests/global.py:3 Unknown identifier: y
+
+tests/import.py:7 Import of "join" is duplicate of import in parent scope <ModuleScope: global>
+tests/import.py:9 Unknown identifier: __all__
+tests/import.py:13 Error trying to import xYzZy: No module named xYzZy
+tests/import.py:14 Unknown identifier: z
+tests/import.py:17 Import of "getopt" is duplicate in current scope
+tests/import.py:18 Import of "join" duplicates import from module posixpath at 4
+tests/import.py:18 Import of "split" duplicates import from module posixpath at 4
+
+tests/not_there.py:[unknown line] Unable to parse: [Errno 2] No such file or directory: 'tests/not_there.py'
+
+tests/op.py:2 Operator (++) doesn't exist, statement has no effect
+tests/op.py:4 Scope (g) is redefined at line 7
+tests/op.py:5 Operator (+) normally has no effect
+tests/op.py:8 Operator (--) doesn't exist, statement has no effect
+
+tests/self.py:9 First argument to method f (x) is not in ['self', 'this', 's']
+
+tests/shadow.py:2 Scope (f) is redefined at line 8
+tests/shadow.py:4 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:16 Identifier (f) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:17 Identifier (a) shadows definition in scope <FunctionScope: g>
+tests/shadow.py:17 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:18 Identifier (b) shadows definition in scope <FunctionScope: g>
+tests/shadow.py:19 Unknown identifier: c
+tests/shadow.py:19 Unknown identifier: d
+tests/shadow.py:22 Identifier (a) shadows definition in scope <ModuleScope: global>
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/normal
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/normal b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/normal
new file mode 100644
index 0000000..5f4592c
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/normal
@@ -0,0 +1,47 @@
+tests/badparse.py:1 Unable to parse: could not parse string
+
+tests/class.py:20 Method x defined at line 28 in class A redefined
+tests/class.py:21 Class A has no attribute w
+tests/class.py:28 Method x is missing self parameter
+tests/class.py:38 Class A has no attribute w
+
+tests/global.py:3 Unknown identifier: y
+
+tests/import.py:1 Identifier (bar) not used
+tests/import.py:3 Identifier (nifty) not used
+tests/import.py:7 Import of "join" is duplicate of import in parent scope <ModuleScope: global>
+tests/import.py:9 Unknown identifier: __all__
+tests/import.py:13 Error trying to import xYzZy: No module named xYzZy
+tests/import.py:14 Unknown identifier: z
+tests/import.py:17 Identifier (getopt) not used
+tests/import.py:17 Import of "getopt" is duplicate in current scope
+tests/import.py:18 Import of "join" duplicates import from module posixpath at 4
+tests/import.py:18 Import of "split" duplicates import from module posixpath at 4
+
+tests/op.py:2 Operator (++) doesn't exist, statement has no effect
+tests/op.py:4 Scope (g) is redefined at line 7
+tests/op.py:5 Operator (+) normally has no effect
+tests/op.py:8 Operator (--) doesn't exist, statement has no effect
+
+tests/self.py:9 First argument to method f (x) is not in ['self', 'this', 's']
+tests/self.py:14 Identifier (a) not used
+
+tests/shadow.py:2 Scope (f) is redefined at line 8
+tests/shadow.py:4 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:15 Identifier (a) not used
+tests/shadow.py:15 Identifier (b) not used
+tests/shadow.py:15 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:16 Identifier (f) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:17 Identifier (a) not used
+tests/shadow.py:17 Identifier (a) shadows definition in scope <FunctionScope: g>
+tests/shadow.py:17 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:18 Identifier (b) not used
+tests/shadow.py:18 Identifier (b) shadows definition in scope <FunctionScope: g>
+tests/shadow.py:19 Unknown identifier: c
+tests/shadow.py:19 Unknown identifier: d
+tests/shadow.py:22 Identifier (a) shadows definition in scope <ModuleScope: global>
+
+tests/unused.py:6 Identifier (Test) not used
+
+tests/unusedImport.py:1 Identifier (sys) not used
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/options
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/options b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/options
new file mode 100644
index 0000000..26f9016
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/options
@@ -0,0 +1,33 @@
+Error: option -? not recognized
+Usage:
+ ./../pychecker2/main.py [options] [--] file1.py file2.py ...
+available options:
+
+Error:
+ --no-duplicateImport   Report/ignore duplicate imports
+ --no-hasAttribute      Report unknown object attributes in methods
+ --no-importError       Report/ignore imports that may fail
+ --no-main              Ignore module-level code protected by __name__ == "__main__"
+ --no-methodRedefined   Report the redefinition of class methods
+ --no-missingSelf       Report methods without "self"
+ --no-operator          Check for (++) and (--) which are legal, but not useful
+ --no-operatorPlus      Check for unary +
+ --no-redefinedScope    Report redefined scopes
+ --reportUnusedSelf     Ignore unused method "self" parameter
+ --no-selfName          Report any methods whose first argument is not self
+ --selfNames            Name of self parameter
+                        ['self', 'this', 's']
+ --shadowBuiltins       Report names that shadow builtins
+ --no-shadowIdentifier  Report names already defined in outer scopes
+ --no-shadowImport      Report imports which shadow names from other imports
+ --no-syntaxErrors      Report/ignore syntax errors
+ --no-unknown           Report names that are not defined
+ --no-unpackedUsed      Do not treat variables used in tuple assignment as used
+ --no-unused            Report names not used
+ --unusedPrefixes       Ignore unused identifiers that start with these values
+                        ['unused', 'empty', 'dummy', '__pychecker__', '__all__', '__version__', 'ignored']
+
+Miscellaneous:
+ --incremental          print warnings as they are created
+ --profile              print a profile of pychecker
+ --verbose              turn on verbose messages

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/reportUnusedSelf
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/reportUnusedSelf b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/reportUnusedSelf
new file mode 100644
index 0000000..2eb9d41
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/reportUnusedSelf
@@ -0,0 +1,55 @@
+tests/badparse.py:1 Unable to parse: could not parse string
+
+tests/class.py:20 Method x defined at line 28 in class A redefined
+tests/class.py:21 Class A has no attribute w
+tests/class.py:28 Method x is missing self parameter
+tests/class.py:38 Class A has no attribute w
+
+tests/global.py:3 Unknown identifier: y
+
+tests/import.py:1 Identifier (bar) not used
+tests/import.py:3 Identifier (nifty) not used
+tests/import.py:7 Import of "join" is duplicate of import in parent scope <ModuleScope: global>
+tests/import.py:9 Unknown identifier: __all__
+tests/import.py:13 Error trying to import xYzZy: No module named xYzZy
+tests/import.py:14 Unknown identifier: z
+tests/import.py:17 Identifier (getopt) not used
+tests/import.py:17 Import of "getopt" is duplicate in current scope
+tests/import.py:18 Import of "join" duplicates import from module posixpath at 4
+tests/import.py:18 Import of "split" duplicates import from module posixpath at 4
+
+tests/not_there.py:[unknown line] Unable to parse: [Errno 2] No such file or directory: 'tests/not_there.py'
+
+tests/op.py:2 Operator (++) doesn't exist, statement has no effect
+tests/op.py:4 Scope (g) is redefined at line 7
+tests/op.py:5 Operator (+) normally has no effect
+tests/op.py:8 Operator (--) doesn't exist, statement has no effect
+
+tests/self.py:4 Identifier (self) not used
+tests/self.py:9 First argument to method f (x) is not in ['self', 'this', 's']
+tests/self.py:9 Identifier (x) not used
+tests/self.py:14 First argument to method f (x) is not in ['self', 'this', 's']
+tests/self.py:14 Identifier (a) not used
+
+tests/shadow.py:2 Scope (f) is redefined at line 8
+tests/shadow.py:4 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:15 Identifier (a) not used
+tests/shadow.py:15 Identifier (b) not used
+tests/shadow.py:15 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:16 Identifier (f) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:17 Identifier (a) not used
+tests/shadow.py:17 Identifier (a) shadows definition in scope <FunctionScope: g>
+tests/shadow.py:17 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:18 Identifier (b) not used
+tests/shadow.py:18 Identifier (b) shadows definition in scope <FunctionScope: g>
+tests/shadow.py:19 Unknown identifier: c
+tests/shadow.py:19 Unknown identifier: d
+tests/shadow.py:22 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:28 Identifier (self) not used
+tests/shadow.py:32 Identifier (a) shadows definition in scope <ModuleScope: global>
+
+tests/unused.py:6 Identifier (Test) not used
+tests/unused.py:9 Identifier (self) not used
+
+tests/unusedImport.py:1 Identifier (sys) not used
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/shadowBuiltins
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/shadowBuiltins b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/shadowBuiltins
new file mode 100644
index 0000000..dd0cc0f
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/shadowBuiltins
@@ -0,0 +1,50 @@
+tests/badparse.py:1 Unable to parse: could not parse string
+
+tests/class.py:20 Method x defined at line 28 in class A redefined
+tests/class.py:21 Class A has no attribute w
+tests/class.py:28 Method x is missing self parameter
+tests/class.py:38 Class A has no attribute w
+
+tests/global.py:3 Unknown identifier: y
+
+tests/import.py:1 Identifier (bar) not used
+tests/import.py:3 Identifier (nifty) not used
+tests/import.py:7 Import of "join" is duplicate of import in parent scope <ModuleScope: global>
+tests/import.py:9 Unknown identifier: __all__
+tests/import.py:13 Error trying to import xYzZy: No module named xYzZy
+tests/import.py:14 Unknown identifier: z
+tests/import.py:17 Identifier (getopt) not used
+tests/import.py:17 Import of "getopt" is duplicate in current scope
+tests/import.py:18 Import of "join" duplicates import from module posixpath at 4
+tests/import.py:18 Import of "split" duplicates import from module posixpath at 4
+
+tests/not_there.py:[unknown line] Unable to parse: [Errno 2] No such file or directory: 'tests/not_there.py'
+
+tests/op.py:2 Operator (++) doesn't exist, statement has no effect
+tests/op.py:4 Scope (g) is redefined at line 7
+tests/op.py:5 Operator (+) normally has no effect
+tests/op.py:8 Operator (--) doesn't exist, statement has no effect
+
+tests/self.py:9 First argument to method f (x) is not in ['self', 'this', 's']
+tests/self.py:14 Identifier (a) not used
+
+tests/shadow.py:2 Scope (f) is redefined at line 8
+tests/shadow.py:4 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:13 Identifier (max) shadows builtin
+tests/shadow.py:15 Identifier (a) not used
+tests/shadow.py:15 Identifier (b) not used
+tests/shadow.py:15 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:16 Identifier (f) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:17 Identifier (a) not used
+tests/shadow.py:17 Identifier (a) shadows definition in scope <FunctionScope: g>
+tests/shadow.py:17 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:18 Identifier (b) not used
+tests/shadow.py:18 Identifier (b) shadows definition in scope <FunctionScope: g>
+tests/shadow.py:19 Unknown identifier: c
+tests/shadow.py:19 Unknown identifier: d
+tests/shadow.py:22 Identifier (a) shadows definition in scope <ModuleScope: global>
+
+tests/unused.py:6 Identifier (Test) not used
+
+tests/unusedImport.py:1 Identifier (sys) not used
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/verbose
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/verbose b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/verbose
new file mode 100644
index 0000000..253c7a8
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/verbose
@@ -0,0 +1,69 @@
+Checking file tests/badparse.py
+
+Checking file tests/class.py
+
+Checking file tests/global.py
+
+Checking file tests/import.py
+
+Checking file tests/op.py
+
+Checking file tests/self.py
+
+Checking file tests/shadow.py
+
+Checking file tests/unusedImport.py
+
+Checking file tests/unused.py
+
+Checking file tests/not_there.py
+
+tests/badparse.py:1 Unable to parse: could not parse string
+
+tests/class.py:20 Method x defined at line 28 in class A redefined
+tests/class.py:21 Class A has no attribute w
+tests/class.py:28 Method x is missing self parameter
+tests/class.py:38 Class A has no attribute w
+
+tests/global.py:3 Unknown identifier: y
+
+tests/import.py:1 Identifier (bar) not used
+tests/import.py:3 Identifier (nifty) not used
+tests/import.py:7 Import of "join" is duplicate of import in parent scope <ModuleScope: global>
+tests/import.py:9 Unknown identifier: __all__
+tests/import.py:13 Error trying to import xYzZy: No module named xYzZy
+tests/import.py:14 Unknown identifier: z
+tests/import.py:17 Identifier (getopt) not used
+tests/import.py:17 Import of "getopt" is duplicate in current scope
+tests/import.py:18 Import of "join" duplicates import from module posixpath at 4
+tests/import.py:18 Import of "split" duplicates import from module posixpath at 4
+
+tests/not_there.py:[unknown line] Unable to parse: [Errno 2] No such file or directory: 'tests/not_there.py'
+
+tests/op.py:2 Operator (++) doesn't exist, statement has no effect
+tests/op.py:4 Scope (g) is redefined at line 7
+tests/op.py:5 Operator (+) normally has no effect
+tests/op.py:8 Operator (--) doesn't exist, statement has no effect
+
+tests/self.py:9 First argument to method f (x) is not in ['self', 'this', 's']
+tests/self.py:14 Identifier (a) not used
+
+tests/shadow.py:2 Scope (f) is redefined at line 8
+tests/shadow.py:4 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:15 Identifier (a) not used
+tests/shadow.py:15 Identifier (b) not used
+tests/shadow.py:15 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:16 Identifier (f) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:17 Identifier (a) not used
+tests/shadow.py:17 Identifier (a) shadows definition in scope <FunctionScope: g>
+tests/shadow.py:17 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:18 Identifier (b) not used
+tests/shadow.py:18 Identifier (b) shadows definition in scope <FunctionScope: g>
+tests/shadow.py:19 Unknown identifier: c
+tests/shadow.py:19 Unknown identifier: d
+tests/shadow.py:22 Identifier (a) shadows definition in scope <ModuleScope: global>
+
+tests/unused.py:6 Identifier (Test) not used
+
+tests/unusedImport.py:1 Identifier (sys) not used
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/format.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/format.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/format.py
new file mode 100644
index 0000000..2290ea4
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/format.py
@@ -0,0 +1,48 @@
+
+def f1(x):
+    return '%s' % x
+
+def f2(x):
+    return ('%s' + '%s') % (x, x)
+
+def f3(x):
+    return (('%s' + '%s') * 8) % ((x,) * 16)
+
+def f4():
+    return '%(x)f %(y)s' % locals()
+
+def f5():
+    return '%' % locals()
+
+def f6():
+    return '%z this, too is a kookie format, yah' % locals()
+
+def f7():
+    return '%*.s %*.*s %*f' % locals()
+
+def f8():
+    return '%(mi)x %(it)s %up' % locals()
+
+def f9():
+    return '%s %d %f' % ('', 2)
+
+def f10():
+    return '%s %%' % ('',)
+
+def f11(t):
+    return '%s %f' % t
+
+def f12(t):
+    return '%s %lf' % (t, t)
+
+def f13(t):
+    return ('%s %f' + t) % (1, 2)
+
+def f14():
+    return '%up %(mi)x' % (1, 2)
+
+def f15():
+    return ('%s' * 6) % ((1, 2) + 3 * 7)
+
+def f16():
+    return '%(foo)*.*s' % {'foo': 'bar'}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/global.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/global.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/global.py
new file mode 100644
index 0000000..cb54d59
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/global.py
@@ -0,0 +1,14 @@
+
+if __name__ == "__main__":
+    x = y
+
+debug = 1
+def _debug(msg):
+    if debug:
+        print msg
+
+def main():
+    import sys
+    global debug
+    debug = '-d' in sys.argv
+    _debug('debug is %d' % debug)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/import.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/import.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/import.py
new file mode 100644
index 0000000..6446b89
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/import.py
@@ -0,0 +1,19 @@
+from sys import path as foo, argv as bar# bar not used
+import getopt                           # getopt not used
+import os.path as nifty                 # nifty not used
+from os.path import *
+
+def f(v):
+    from os.path import join            # duplicate import
+    v.append(join(foo))                 # join from os.path
+    v.append(__all__)                   # __all__ is unknown
+
+x = 7
+if x == 100:
+    from xYzZy import *                 # not found
+    x = z
+
+not_used = 13
+import getopt                           # duplicate import
+from string import *                    # shadow 'join'
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/nested.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/nested.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/nested.py
new file mode 100644
index 0000000..fd854b8
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/nested.py
@@ -0,0 +1,8 @@
+
+class N1:
+    class N2:
+        x = 1
+        class N3:
+            pass
+
+        

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/op.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/op.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/op.py
new file mode 100644
index 0000000..1db2ec0
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/op.py
@@ -0,0 +1,24 @@
+def f(a):
+    return ++a
+
+def g(a):
+    return +a
+
+def g(a):
+    return --a
+
+def foo():
+    if 1 == None:
+        print "whoa!"
+    else:
+        print "whew!"
+
+    if None == 1:
+        print "whoa!"
+    else:
+        print "whew!"
+
+def bar():
+    a = b = 0
+    if 'a' <= b >= 'c':
+        print ""

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/self.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/self.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/self.py
new file mode 100644
index 0000000..8c7fc7c
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/self.py
@@ -0,0 +1,31 @@
+
+class SelfTester:
+
+    def f(self, a):
+        return a
+
+class SelfTester2:
+
+    def f(x, a):
+        return a
+
+class SelfTester3:
+
+    def f(x, a):
+        return x, a
+
+class SelfTester4:
+
+    def f(self = 1):
+        return self
+
+class SelfTester5:
+
+    def f(self = 1, *args, **kwargs):
+        return self, args, kwargs
+
+def f(self):
+    print self
+
+x = lambda self: self
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/shadow.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/shadow.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/shadow.py
new file mode 100644
index 0000000..e78cff5
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/shadow.py
@@ -0,0 +1,59 @@
+
+def f(a, b):
+    a = b
+    for a in range(10):
+        b += a
+    return b
+
+def f(a, b):
+    return a + b
+
+f = 3
+
+max = 3
+
+def g(a, b):
+    def f(c, d):
+        a = c
+        b = d + max
+    return f(c, d)
+
+class C:
+    f = lambda a, b: a + b
+    def f(self, b):
+        pass
+
+class D:
+    CONSTANT = 1
+    def h(self, arg):
+        CONSTANT = D.CONSTANT
+        arg.append(CONSTANT)
+
+def xyzzy(a, max=max, *args, **kw):
+    print a, args, kw
+    return max
+
+if __name__ == '__main__':
+    a = 2
+if '__main__' == __name__:
+    a = 2
+
+if x:
+    def f1():
+        print x
+else:
+    def f1():
+        print x
+
+try:
+    def f2():
+        print x
+except AttributeError:
+    def f2():
+        print x
+except:
+    def f2():
+        print x
+else:
+    def f2():                           # should still warn
+        print x

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/unreachable.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/unreachable.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/unreachable.py
new file mode 100644
index 0000000..11e2f5c
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/unreachable.py
@@ -0,0 +1,58 @@
+v1=0
+
+def f1():
+    if v1:
+        v2 = 2 + 3 * 4 / 7 << 3;
+        return v2
+    elif v2:
+        a, b = 1, 2
+        b, a = a, b
+        return 0
+    else:
+        print 7
+        return 1
+    return 0                            # unreachable
+
+def f2():
+    if v1:
+        return 0
+    return 0
+
+def f3():
+    if v1:
+        raise v1
+    else:
+        raise v1
+    print v1                            # unreachable
+
+def f4():
+    assert None
+    print v1                            # unreachable
+
+def f5():
+    assert 1
+    print v1
+    
+def f6():
+    assert 0
+    print v1                            # unreachable
+
+
+def f7():
+    global v1
+    try:
+        assert None
+    except KeyError:
+        v1 = 7
+    else:
+        raise v1                        # unreachable
+    return 0
+
+def f8():
+    try:
+        print v1()
+    except KeyError:
+        return 7
+    else:
+        raise v1
+    return 0                            # unreachable

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/unused.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/unused.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/unused.py
new file mode 100644
index 0000000..9edc124
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/unused.py
@@ -0,0 +1,31 @@
+
+def f(a):
+    return 1
+
+def g():
+    class Test:
+        def q(self):
+            class TestInner:
+                def p(self, a):
+                    return a
+            self.foo = TestInner()
+            
+                    
+x, y = 1, 2
+class Object: pass
+x = Object()
+x.y, x.z = 1, 2
+
+def h(a, b, c):
+    assert 0, "should not be called"
+
+[x1, y1, z1] = [1, 2, 3]
+[x1, y1, z1] = [y1, z1, x1]
+
+def xyzzy():
+    global x
+    global y
+    y = 1
+
+def XyZZy(a, (b, (c, d)), e):
+    return a + e

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/unusedImport.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/unusedImport.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/unusedImport.py
new file mode 100644
index 0000000..5c98a10
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/unusedImport.py
@@ -0,0 +1,4 @@
+import sys
+
+def f(x):
+    return f(x)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/__init__.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/__init__.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/__init__.py
new file mode 100644
index 0000000..e16c76d
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/__init__.py
@@ -0,0 +1 @@
+""

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/class.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/class.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/class.py
new file mode 100644
index 0000000..44efdb4
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/class.py
@@ -0,0 +1,232 @@
+from pychecker2.TestSupport import WarningTester
+from pychecker2 import ClassChecks
+
+class ClassTestCase(WarningTester):
+    def testClassChecks(self):
+        self.silent('class A:\n'
+                    '  def f(self):\n'
+                    '    return 0\n'
+                    'class B(A):\n'
+                    '  def g(self):\n'
+                    '    return self.f\n')
+    def testSignature(self):
+        w = ClassChecks.AttributeCheck.signatureChanged
+        self.silent('class Base:\n'
+                    '  def f(self): pass\n'
+                    'class Derived(Base):\n'
+                    '  def f(self): pass\n')
+        self.warning('class Base:\n'
+                     '  def f(self): pass\n'
+                     'class Derived(Base):\n'
+                     '  def f(self, x): pass\n',
+                     4, w, 'f', 'Base')
+        self.silent('class Base:\n'
+                    '  def f(self, x, y, *args): pass\n'
+                    'class Derived(Base):\n'
+                    '  def f(self, x, *args): pass\n')
+        self.warning('class Base:\n'
+                     '  def f(self, x, *args): pass\n'
+                     'class Derived(Base):\n'
+                     '  def f(self, x, y, *args): pass\n',
+                     4, w, 'f', 'Base')
+        self.silent('class Base:\n'
+                    '  def __private(self, x, y): pass\n'
+                    'class Derived(Base):\n'
+                    '  def __private(self, x): pass\n')
+        self.warning('class Base:\n'
+                     '  def __private(self, x, y): pass\n'
+                     'class Derived(Base):\n'
+                     '  def _Base__private(self, x): pass\n',
+                     4, w, '__private', 'Base')
+
+    def testUnknownAttribute(self):
+        w = ClassChecks.AttributeCheck.unknownAttribute
+        self.warning('class C:\n'
+                     '  def f(self): return self.x\n', 2, w, 'C', 'x')
+        self.silent('class C:\n'
+                    '  def f(self): return self.x\n'
+                    '  def __init__(self, v): self.x = v\n')
+        self.silent('class D:\n'
+                    '  def __init__(self): self.x = 1\n'
+                    'class C(D):\n'
+                    '  def f(self): return self.x\n')
+        self.silent('from pychecker2.utest.data import *\n'
+                    'class C(Data):\n'
+                    '  def get_value2(self):\n'
+                    '    return self.get_value()\n'
+                    '\n')
+        imp = '\n\nimport'
+        frm = '\n\nfrom'
+        import_abuse = [
+            (imp, 'pychecker2.utest.data', 'pychecker2.utest.data.Data'),
+            (imp, 'pychecker2.utest.data as F',             'F.Data'),
+            (frm, 'pychecker2.utest import data',           'data.Data'),
+            (frm, 'pychecker2.utest import data as F',      'F.Data'),
+            (frm, 'pychecker2.utest.data import Data',      'Data'),
+            (frm, 'pychecker2.utest.data import Data as F', 'F'),
+            (frm, 'pychecker2.utest.data import *',         'Data'),
+            ('class A:\n  class B:\n    import pychecker2.utest.data',
+             '',
+             'A.B.pychecker2.utest.data.Data'),
+            ('class A:\n'
+             '  class B:\n'
+             '    from pychecker2.utest import data as F',
+             '',
+             'A.B.F.Data')
+            ]
+        for fmt in import_abuse:
+            self.silent('%s %s\n'
+                        'class C(%s):\n'
+                        '  def f(self): return self.value\n' % fmt)
+            self.silent('%s %s\n'
+                        'def g(v):\n'
+                        '  class C(%s):\n'
+                        '    def f(self): return self.value\n'
+                        '  return C(v)\n' % fmt)
+            self.warning('%s %s\n'
+                         'class C(%s):\n'
+                         '  def f(self): self.get_value = 1\n' % fmt,
+                         5, ClassChecks.AttributeCheck.methodRedefined,
+                         'get_value', 'C')
+
+            self.warning('%s %s\n'
+                         'def g(v):\n'
+                         '  class C(%s):\n'
+                         '    def f(self): self.get_value = 1\n'
+                         '  return C(v)\n' % fmt,
+                         6, ClassChecks.AttributeCheck.methodRedefined,
+                         'get_value', 'C')
+
+            self.warning('%s %s\n'
+                         'class C(%s):\n'
+                         '  def get_value(self, x): pass\n' % fmt,
+                         5, ClassChecks.AttributeCheck.signatureChanged,
+                         'get_value', 'Data')
+
+    def testSpecial(self):
+        for fmt in [('__del__', 'self, args', 1),
+                    ('__cmp__', 'self', 2),
+                    ]:
+            self.warning('class C:\n'
+                         '  def %s(%s):\n'
+                         '     pass\n' % fmt[0:2],
+                         2, ClassChecks.SpecialCheck.specialMethod,
+                         fmt[0], fmt[2], fmt[2] > 1 and "s" or "")
+        for fmt in [('__del__', 'self'),
+                    ('__ge__', 'self, a, b = None, c = None'),
+                    ]:
+            self.silent('class C:\n'
+                         '  def %s(%s):\n'
+                         '     pass\n' % fmt)
+        self.warning('class C:\n'
+                     '  def __not_special__(self):\n'
+                     '     pass\n',
+                     2, ClassChecks.SpecialCheck.notSpecial,
+                     '__not_special__')
+
+    def testUncheckableAttribute(self):
+        # inherit from local variable
+        self.silent('def f(klass):\n'
+                    '  class C(klass):\n'
+                    '      def __init__(self, x):\n'
+                    '          self.foo = x\n'
+                    '      def g(self): return self.foo\n'
+                    '  return C(1)\n')
+        # inherit from an expression
+        self.silent('class A:\n'
+                    '  def __add__(self, unused):\n'
+                    '     return A\n'
+                    'class B(A): pass\n'
+                    'class C(A() + B()): pass\n')
+        # inherit from something not in a source module
+        self.warning('import exceptions\n'
+                     'class C(exceptions):\n'
+                     '  def f(self):\n'
+                     '    return self.value\n',
+                     4, ClassChecks.AttributeCheck.unknownAttribute,
+                     'C', 'value')
+        self.warning('import pychecker2.utest.data\n'
+                     'class C(pychecker2.utest.data.exceptions.AssertionError):\n'
+                     '  def f(self):\n'
+                     '    return self.value\n',
+                     4, ClassChecks.AttributeCheck.unknownAttribute,
+                     'C', 'value')
+        self.warning('from pychecker2.utest.data import Data as F\n'
+                     'class C(F.DataError):\n'
+                     '  def f(self):\n'
+                     '    return self.value\n',
+                     4, ClassChecks.AttributeCheck.unknownAttribute,
+                     'C', 'value')
+        self.silent('def f():\n'
+                    '   class Foo(None.__class__): pass\n'
+                    '   return Foo()\n')
+
+    def testUnused(self):
+        self.warning('class C:\n'
+                     '  def __init__(self):\n'
+                     '    self.__x = 1\n',
+                     3, ClassChecks.AttributeCheck.unusedAttribute, '__x', 'C')
+        self.warning('class C:\n'
+                     '  def __init__(self):\n'
+                     '    class D:\n'
+                     '       def __init__(self): self.__x = 1\n'
+                     '       def f(self):\n'
+                     '          return self.__x\n'
+                     '    self.__x = D()\n',
+                     7, ClassChecks.AttributeCheck.unusedAttribute, '__x', 'C')
+        self.silent('class C:\n'
+                     '  def __init__(self):\n'
+                     '    self.x = 1\n')
+
+    def testInit(self):
+        w = ClassChecks.InitCheck.initReturnsValue
+        self.warning('class C:\n'
+                     '  def __init__(self):\n'
+                     '    return 1\n', 3, w)
+        self.warning('class C:\n'
+                     '  def __init__(self):\n'
+                     '    def f(x):\n'
+                     '        return f(x - 1)\n'
+                     '    return f(1)\n', 5, w)
+
+        w = ClassChecks.AttributeCheck.attributeInitialized
+        self.silent('class C:\n'
+                    '  def f(self):\n'
+                    '    self.value = 1\n'
+                    '  def __init__(self):\n'
+                    '    self.value = None\n')
+        self.warning('class C:\n'
+                     '  def __init__(self): pass\n'
+                     '  def f(self):\n'
+                     '    self.value = 1',
+                     4, w, 'value')
+
+    def testRepr(self):
+        w = ClassChecks.ReprCheck.backquoteSelf
+        self.silent('class C:\n'
+                    '  def __str__(self):\n'
+                    '    return "C" + `self`\n')
+        self.warning('class C:\n'
+                    '  def __repr__(self):\n'
+                    '    return "C" + `self`\n', 3, w)
+
+    def testMethodRedefined(self):
+        w = ClassChecks.AttributeCheck.methodRedefined
+
+        self.warning('class C:\n'
+                     '  def f(self):\n'
+                     '     self.f = lambda x: x\n',
+                     3, w, 'f', 'C')
+        self.warning('class B:\n'
+                     '  def g(self): pass\n'
+                     'class C(B):\n'
+                     '  def f(self):\n'
+                     '     self.g = lambda x: x\n',
+                     5, w, 'g', 'C')
+        self.warning('from pychecker2.utest.data import Data\n'
+                     'class C(Data):\n'
+                     '  def f(self):\n'
+                     '    self.get_value = 1\n',
+                     4, w, 'get_value','C')
+
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/conditional.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/conditional.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/conditional.py
new file mode 100644
index 0000000..2c7250e
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/conditional.py
@@ -0,0 +1,27 @@
+from pychecker2.TestSupport import WarningTester
+from pychecker2 import ConditionalChecks
+
+class ConditionalTestCase(WarningTester):
+    def testConstants(self):
+        w = ConditionalChecks.ConstantCheck.constantInConditional
+        
+        self.silent('a, b = 1, 2\n'
+                    'if a < b:\n'
+                    '   print a\n')
+        self.warning('a = 1\n'
+                     'if a or 1:\n'
+                     '  print a\n', 2, w, '1')
+        self.warning('a = 1\n'
+                     'if not 1:\n'
+                     '  print a\n', 2, w, '1')
+        self.silent('a, b = 1, 2\n'
+                    'if a < 1 + 7:\n'
+                    '   print a\n')
+        self.warning('result = [x for x in [1, 2, 3] if x or 1]\n',
+                     1, w, '1')
+        self.warning('result = [x for x in [1, 2, 3] if x or None]\n',
+                     1, w, 'None')
+        self.warning('x = 1\n'
+                     'while x or None:\n'
+                     '   x = x + 1\n',
+                     2, w, 'None')

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/data.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/data.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/data.py
new file mode 100644
index 0000000..b0b903a
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/data.py
@@ -0,0 +1,8 @@
+import exceptions
+
+class Data:
+    class DataError(exceptions.ValueError): pass
+    def __init__(self, value):
+        self.value = value
+    def get_value(self):
+        return self.value

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/format.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/format.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/format.py
new file mode 100644
index 0000000..7b561a1
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/format.py
@@ -0,0 +1,78 @@
+from pychecker2 import TestSupport
+from pychecker2 import FormatStringChecks
+
+class FormatTestCase(TestSupport.WarningTester):
+
+    def testGoodFormats(self):
+        self.silent('def f(x):\n'
+                    '    return "%s" % x\n')
+        self.silent('def f(x):\n'
+                    "    return ('%s' + '%s') % (x, x)\n")
+        self.silent("def f(x):\n"
+                    "   return (('%s' + '%s') * 8) % ((x,) * 16)\n")
+        self.silent("def f(x):\n"
+                    "   y = 2\n"
+                    "   return '%(x)f %(y)s' % locals()\n")
+        self.silent("y = 1\n"
+                    "def f():\n"
+                    "   return '%(y)s' % globals()\n")
+        self.silent("def f():\n"
+                     "  return '%*.s %*.*s %*f' % locals()\n")
+        self.silent("def f():\n"
+                    "   return '%s %%' % ('',)\n")
+        self.silent("def f(t):\n"
+                    "    return '%s %f' % t\n")
+        self.silent("def f(t):\n"
+                    "    return ('%s %f' + t) % (1, 2)\n")
+        self.silent("def f(t):\n"
+                    "    return '%s' % `t`\n")
+        self.silent("def f(t):\n"
+                    "    return '%s' * ((7 - 1) / 2) % (t,t,t)\n")
+
+    def testBadFormats(self):
+        w = FormatStringChecks.FormatStringCheck.badFormat
+        self.warning("def f():\n"
+                     "    return '%' % locals()\n", 2, w, 0, '%')
+        self.warning("def f():\n"
+                     "  return '%z a kookie format, yah' % locals()\n",
+                     2, w, 0, '%z a kooki...')
+        self.warning("def f():\n"
+                     "    return '%(foo)*.*s' % {'foo': 'bar'}\n",
+                     2, w, 0, '%(foo)*.*s')
+
+    def testMixed(self):
+        w = FormatStringChecks.FormatStringCheck.mixedFormat
+        self.warning("def f():\n"
+                     "  return '%(mi)x %up' % locals()\n", 2, w, '(mi)')
+        self.warning("def f():\n"
+                     "    return '%up %(mi)x' % (1, 2)\n", 2, w, '(mi)')
+
+    def testFormatCount(self):
+        w = FormatStringChecks.FormatStringCheck.formatCount
+        self.warning("def f():\n"
+                     "    return '%s %d %f' % ('', 2)\n",
+                     2, w, 2, 3)
+
+    def testUselessModifier(self):
+        w = FormatStringChecks.FormatStringCheck.uselessModifier
+        self.warning("def f(t):\n"
+                     "    return '%s %lf' % (t, t)\n",
+                     2, w, 'l')
+
+    def testFormatConstants(self):
+        w = FormatStringChecks.FormatStringCheck.badConstant
+        self.warning("def f():\n"
+                    "    return ('%s' * 6) % ((1, 2) + 3 * 7)\n",
+                     2, w, 'can only concatenate tuple (not "int") to tuple')
+        self.warning("def f():\n"
+                    "    return ('%s' + 6) % ((1, 2) * 3)\n",
+                     2, w, "cannot concatenate 'str' and 'int' objects")
+
+    def testUnknownName(self):
+        w = FormatStringChecks.FormatStringCheck.unknownFormatName
+        self.warning("def f():\n"
+                     "   return '%(unknown)s' % globals()\n",
+                     2, w, "unknown", "globals")
+        self.warning("def f():\n"
+                     "   return '%(unknown)s' % locals()\n",
+                     2, w, "unknown", "locals")

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/import.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/import.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/import.py
new file mode 100644
index 0000000..0334649
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/import.py
@@ -0,0 +1,33 @@
+from pychecker2.TestSupport import WarningTester
+from pychecker2 import ImportChecks
+
+class ImportTestCase(WarningTester):
+    def testImportChecks(self):
+        self.silent('import sys; print sys.argv')
+        self.silent('import pychecker2; print pychecker2')
+        self.silent('import pychecker2.utest; print pychecker2.utest')
+
+    def testImportChecks(self):
+        self.warning('import sys\n'
+                     'print sys.argv\n'
+                     'import sys\n',
+                     3, ImportChecks.ImportCheck.duplicateImport,
+                     'sys', ' in current scope')
+        self.warning('from sys import *\n'
+                     'def f():\n'
+                     '  def g():\n'
+                     '    from sys import argv\n'
+                     '    return argv\n'
+                     '  return g() + g()\n'
+                     'print argv\n',
+                     4, ImportChecks.ImportCheck.duplicateImport, 'argv',
+                     ' of import in parent scope <ModuleScope: global>')
+        self.warning('import no_such_module\n',
+                     1, ImportChecks.ImportCheck.importError, 'no_such_module',
+                     'No module named no_such_module')
+        self.warning('from pychecker2.utest.data import *\n'
+                     'import exceptions\n'
+                     'print exceptions\n',
+                     2, ImportChecks.ImportCheck.shadowImport,
+                     'exceptions', 'pychecker2.utest.data', 1)
+                     

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/ops.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/ops.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/ops.py
new file mode 100644
index 0000000..79bbfd0
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/ops.py
@@ -0,0 +1,43 @@
+from pychecker2 import TestSupport
+from pychecker2 import OpChecks
+
+class OpTests(TestSupport.WarningTester):
+    def testOperator(self):
+        for op in ['--', '++']:
+            self.warning('def f(x):\n'
+                         '   return %sx' % op,
+                         2, OpChecks.OpCheck.operator, op)
+            
+    def testOperatorPlus(self):
+        self.warning('def f(x):\n'
+                     '   return +x', 2, OpChecks.OpCheck.operatorPlus)
+
+    def testEqualNone(self):
+        self.silent('def f(x):\n'
+                     '   return 1 <= x <= None\n')
+        self.warning('def f(x):\n'
+                     '   return x == None\n', 2, OpChecks.CompareCheck.useIs)
+        self.warning('def f(x):\n'
+                     '   return 1 == x == None\n', 2, OpChecks.CompareCheck.useIs)
+        self.warning('def f(x):\n'
+                     '   return None == x == 1\n', 2, OpChecks.CompareCheck.useIs)
+        self.warning('def f(x):\n'
+                     '   return None == x\n', 2, OpChecks.CompareCheck.useIs)
+
+    def testExcept(self):
+        self.warning('try:\n'
+                     '   pass\n'
+                     'except:\n'
+                     '   pass\n', 4, OpChecks.ExceptCheck.emptyExcept)
+        self.warning('try:\n'
+                     '   pass\n'
+                     'except AssertionError:\n'\
+                     '   pass\n'
+                     'except:\n'
+                     '   pass\n', 6, OpChecks.ExceptCheck.emptyExcept)
+        self.warning('try:\n'
+                     '   pass\n'
+                     'except:\n'
+                     '   pass\n'
+                     'except AssertionError:\n'\
+                     '   pass\n', 4, OpChecks.ExceptCheck.emptyExcept)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/parseerror.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/parseerror.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/parseerror.py
new file mode 100644
index 0000000..877cbf9
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/parseerror.py
@@ -0,0 +1,24 @@
+from pychecker2 import TestSupport
+from pychecker2 import ParseChecks
+from pychecker2 import VariableChecks
+from pychecker2.File import File
+
+class UnknownTestCase(TestSupport.WarningTester):
+    def testParseError(self):
+        self.warning('===\n', 1, ParseChecks.ParseCheck.syntaxErrors,
+                     'could not parse string')
+        f = File('no-such-file')
+        self.checklist.check_file(f)
+        self.warning_file(f, 0, ParseChecks.ParseCheck.syntaxErrors,
+                          "No such file or directory")
+
+        self.warning('if __name__=="__main__":\n'
+                     '  _x = 1\n',
+                     2, VariableChecks.UnusedCheck.unused, '_x')
+        self.argv = ['--no-main']
+        self.silent('NoMoreGood = 1\n'
+                    'assert NoMoreGood\n')
+        self.silent('if __name__=="__main__":\n'
+                     '  _x = 1\n')
+        self.silent('if "__main__"==__name__:\n'
+                     '  _x = 1\n')

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/reachable.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/reachable.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/reachable.py
new file mode 100644
index 0000000..d04691d
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/reachable.py
@@ -0,0 +1,73 @@
+from pychecker2.TestSupport import WarningTester
+from pychecker2 import ReachableChecks
+
+class ReachableTestCase(WarningTester):
+    def testUnreachable(self):
+        w = ReachableChecks.ReachableCheck.unreachable
+        self.warning('v1, v2 = 0, 0\n'
+                     'def f():\n'
+                     '  if v1:\n'
+                     '     return v2\n'
+                     '  elif v2:\n'
+                     '    return 1\n'
+                     '  else:\n'
+                     '    return 0\n'
+                     '  return 1\n', 9, w)
+        self.warning('v1, v2 = 0, 0\n'
+                     'def f():\n'
+                     '  if v1:\n'
+                     '    raise AssertionError("assertion")\n'
+                     '  elif v2:\n'
+                     '    assert 0, "Another error"\n'
+                     '  else:\n'
+                     '    return 0\n'
+                     '  return f()\n', 9, w)
+        self.silent('def f(x):\n'
+                    '   while x:\n'
+                    '      pass\n')
+        self.silent('def f(x):\n'
+                    '   for i in x:\n'
+                    '      assert i\n')
+        self.silent('def f(x):\n'
+                    '  if x:\n'
+                    '    return 0\n'
+                    '  return 0\n')
+        self.warning('def f(x):\n'
+                     '  try:\n'
+                     '    x = 1 / x\n'
+                     '    return x\n'
+                     '  except Exception:\n'
+                     '    return 0\n'
+                     '  else:\n'
+                     '    x = 7\n'
+                     '  return x\n', 8, w)
+
+        self.silent('def f(v1, v2):\n'
+                    '  if v1:\n'
+                    '    return v2\n'
+                    '  elif v2:\n'
+                    '    v1 = v2\n'
+                    '  else:\n'
+                    '    assert 0, "Another error"\n'
+                    '  return f()\n')
+
+        self.silent('def f(v1, v2):\n'
+                    '  if v1:\n'
+                    '    return v2\n'
+                    '  elif v2:\n'
+                    '    v1 = v2\n'
+                    '  else:\n'
+                    '    assert 0, "Another error"\n'
+                    '  return 0\n')
+
+        self.silent('def f(x):\n'
+                    '  try:\n'
+                    '    return 1.0 / x\n'
+                    '  except ZeroDivisionError:\n'
+                    '    raise\n')
+    
+    def testImplicitReturn(self):
+        w = ReachableChecks.ReachableCheck.implicitReturn
+        self.warning('def f(v1, v2):\n'
+                     '  if v1:\n'
+                     '    return v2\n', 2, w, 'f')

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/returns.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/returns.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/returns.py
new file mode 100644
index 0000000..2a0ecc3
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/returns.py
@@ -0,0 +1,21 @@
+from pychecker2.TestSupport import WarningTester
+from pychecker2 import ReturnChecks
+
+class ReturnTestCase(WarningTester):
+    def testReturnChecks(self):
+        w = ReturnChecks.MixedReturnCheck.mixedReturns
+        self.silent('def f(): return\n')
+        self.silent('def f(): return 1\n')
+        self.silent('def f(x):\n'
+                     '  if x:\n'
+                     '    return 0\n'
+                     '  return 1\n')
+        self.warning('def f(x):\n'
+                     '  if x:\n'
+                     '    return\n'
+                     '  return 1\n', 3, w, 'f')
+        self.silent('def f(x):\n'
+                    '  def g():\n'
+                    '    return\n'
+                    '  return x + g()\n')
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/scopes.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/scopes.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/scopes.py
new file mode 100644
index 0000000..7553bf9
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/scopes.py
@@ -0,0 +1,47 @@
+from pychecker2.TestSupport import WarningTester
+from pychecker2 import ScopeChecks
+
+class RedefinedTestCase(WarningTester):
+    def testScopes(self):
+        w = ScopeChecks.RedefineCheck.redefinedScope
+        self.warning('def f(): pass\n'
+                     'def f(): pass\n',
+                     1, w, 'f', 2)
+        self.warning('class C:\n'
+                     '  def g(self): pass\n'
+                     '  def g(self): pass\n',
+                     2, w, 'g', 3)
+        self.silent('def s(): pass\n'
+                    'def f(): pass\n')
+        self.silent('import sys\n'
+                    'if sys.argv:\n'
+                    '   def f(): return 1\n'
+                    'else:\n'
+                    '   def f(): return 0\n')
+        self.warning('import sys\n'
+                     'if sys.argv:\n'
+                     '   def f(): return 1\n'
+                     '   def f(): return 0\n',
+                     3, w, 'f', 4)
+        self.warning('try:\n'
+                     '   def f(): return 1\n'
+                     'except Exception:\n'
+                     '   pass\n'
+                     'else:\n'
+                     '   def f(): return 0\n',
+                     2, w, 'f', 6)
+        self.warning('try:\n'
+                     '   def f(): return 1\n'
+                     '   def f(): return 0\n'
+                     'except Exception:\n'
+                     '   pass\n'
+                     'else:\n'
+                     '   pass\n',
+                     2, w, 'f', 3)
+
+        self.silent('try:\n'
+                    '   def f(): return 1\n'
+                    'except Exception:\n'
+                    '   def f(): return 0\n'
+                    'else:\n'
+                    '   pass\n')

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/self.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/self.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/self.py
new file mode 100644
index 0000000..f141830
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/self.py
@@ -0,0 +1,45 @@
+from pychecker2 import TestSupport
+from pychecker2 import VariableChecks
+
+class SelfTestCase(TestSupport.WarningTester):
+    def testSelf(self):
+        self.warning('class C:\n'
+                     '  def f(x): return x\n',
+                     2, VariableChecks.SelfCheck.selfName,
+                     'f', 'x', "['self', 'this', 's']")
+
+    def testSelfNames(self):
+        self.silent('class C:\n'
+                    '  def f(self): return self\n')
+        self.argv = ["--selfNames=['x']"]
+        self.warning('class C:\n'
+                     '  def f(self): return self\n',
+                     2, VariableChecks.SelfCheck.selfName,
+                     'f', 'self', "['x']")
+
+    def testSelfDefault(self):
+        w = VariableChecks.SelfCheck.selfDefault
+        self.warning('class C:\n'
+                     '  def f(s=None): return s\n', 2, w, 'f', 's')
+        self.warning('class C:\n'
+                     '  def f(s=None, **kw): return s, kw\n', 2, w, 'f', 's')
+        self.warning('class C:\n'
+                     '  def f(s=None, *args): return s, args\n',
+                     2, w, 'f', 's')
+        self.warning('class C:\n'
+                     '  def f(s=None, *args, **kw): return s, args, kw\n',
+                     2, w, 'f', 's')
+        
+    def testFunctionSelf(self):
+        w = VariableChecks.SelfCheck.functionSelf
+        self.warning('def f(a, self, b): return a + self + b\n',
+                     1, w, 'f', 'self')
+        self.argv = ["--selfSuspicious=['a']"]
+        self.warning('def f(a, self, b): return a + self + b\n',
+                     1, w, 'f', 'a')
+
+    def testMissingSelf(self):
+        w = VariableChecks.SelfCheck.missingSelf
+        self.warning('class C:\n'
+                     '  def f(): pass\n', 2, w, 'f')
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/shadow.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/shadow.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/shadow.py
new file mode 100644
index 0000000..b51ca43
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/shadow.py
@@ -0,0 +1,21 @@
+from pychecker2 import TestSupport
+from pychecker2 import VariableChecks
+
+class ShadowTestCase(TestSupport.WarningTester):
+    def testShadow(self):
+        "Test variable shadowing"
+        self.warning('a = 1\n'
+                     'def f(x):\n'
+                     '  a = x\n'
+                     '  return x + a\n',
+                     3, VariableChecks.ShadowCheck.shadowIdentifier,
+                     'a', '<ModuleScope: global>')
+        self.warning('file = None\n',
+                     1, VariableChecks.ShadowCheck.shadowBuiltins, 'file')
+
+        w = VariableChecks.ShadowCheck.defineNone
+        self.silent('none, x = 1, 2')
+        self.warning('None = None', 1, w)
+        self.warning('def None(x, y): pass', 1, w)
+        self.warning('None, x = 1, 2', 1, w)
+        self.warning('class None: pass', 1, w)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/unknown.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/unknown.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/unknown.py
new file mode 100644
index 0000000..cc394d8
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/unknown.py
@@ -0,0 +1,27 @@
+from pychecker2 import TestSupport
+from pychecker2 import VariableChecks
+
+class UnknownTestCase(TestSupport.WarningTester):
+    def testUnknown(self):
+        self.warning('def f(): print a\n',
+                     1, VariableChecks.UnknownCheck.unknown, 'a')
+        self.silent('def f():\n'
+                    '   a = 1\n'
+                    '   def g():\n'
+                    '      print a\n'
+                    '   print g()\n')
+        self.warning('def f():\n'
+                     '  def g():\n'
+                     '    print a\n'
+                     '  print g()\n',
+                     3, VariableChecks.UnknownCheck.unknown, 'a')
+        self.silent('from sys import *\n'
+                    'def f():\n'
+                    '    print argv\n')
+        self.silent('import sys\n'
+                    'def f():\n'
+                    '  def g():\n'
+                    '    print g, sys\n')
+        self.silent('def f():\n'
+                    '  for a, b in [(1,2)]:\n'
+                    '    print a, b\n')

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/unused.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/unused.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/unused.py
new file mode 100644
index 0000000..d488746
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/unused.py
@@ -0,0 +1,96 @@
+from pychecker2.TestSupport import WarningTester
+from pychecker2 import VariableChecks
+
+class UnusedTestCase(WarningTester):
+    def testUnusedBasic(self):
+        self.warning('def f(i, j): return i * 2\n',
+                     1, VariableChecks.UnusedCheck.unused, 'j')
+        self.warning('def _unused(): pass\n',
+                     1, VariableChecks.UnusedCheck.unused, '_unused')
+        self.silent('def f(x):\n'
+                    '  def g():\n'
+                    '     x.y.z, = 1\n'
+                    '  g()\n')
+
+    def testUnusedAbstract(self):
+        self.silent('def f(i): assert 0\n')
+        self.silent('def f(i): assert None\n')
+        self.silent('def f(i): return\n')
+        self.silent('def f(i): return 7\n')
+        self.silent('def f(i): pass\n')
+        self.silent('def f(i): raise NotImplementedError\n')
+
+    def testUnusedScopeNotSelf(self):
+        self.silent('class A:\n'
+                    '  def f(self, j): return j * 2\n')
+        self.argv = ['--reportUnusedSelf']
+        self.warning('class A:\n'
+                     '  def f(self, j): return j * 2\n',
+                     2, VariableChecks.UnusedCheck.unused, 'self')
+
+    def testUnusedScope(self):
+        self.warning('class A:\n'
+                     '  def f(self, j): return self\n', 2,
+                     VariableChecks.UnusedCheck.unused, 'j')
+        self.silent('def f(a, b):\n'
+                    '  def g(x):\n'
+                    '     return x * a\n'
+                    '  return g(b)\n')
+
+    def testUnusedIgnore(self):
+        self.warning('def f(a, xyzzySilly): return a\n',
+                     1, VariableChecks.UnusedCheck.unused, 'xyzzySilly')
+        self.argv = ['--unusedPrefixes=["xyzzy"]']
+        self.silent('def f(a, xyzzySilly): return a\n')
+                    
+
+    def testGlobal(self):
+        self.silent('x = 1\ndef f(x=x): return 7\n')
+        self.silent('def f(x):\n'
+                    '  global _y\n'
+                    '  _y = x\n'
+                    'def g(x): return x + _y\n')
+
+    def testUnpack(self):
+        w = VariableChecks.UnusedCheck.unused
+        self.silent('_x, _y = 1, 2\n')
+        self.silent('def f(a, (b, c)): print a, b\n')
+        self.silent('def f(a, (b, (c, d))): print a, b\n')
+        
+        self.argv = ['--no-unpackedUsed']
+        self.warning('_x, _y = 1, 2\n'
+                     'print _x\n', 1, w, '_y')
+        self.warning('def f(a, (b, c)): print a, b\n', 1, w, 'c')
+        self.silent('def f(a):\n'
+                    '   "this is an empty function"\n')
+
+    def testUsedBeforeSet(self):
+        w = VariableChecks.UsedBeforeSetCheck.usedBeforeDefined
+        self.warning('G1 = 1\n'
+                     'def f(L1, (L2, L3)):\n'
+                     '  x = 1\n'
+                     '  if G1:\n'
+                     '    y = 2\n'
+                     '  if G1:\n'
+                     '    z = 1\n'
+                     '    y = 2\n'
+                     '  else:\n'
+                     '    z = 2\n'
+                     '  return L1, L2, L3, x, y, z\n',
+                     11, w, 'y')
+        self.silent('def f():\n'
+                    '  import sys\n'
+                    '  return sys.argv\n')
+        self.silent('def f():\n'
+                    '  from sys import argv\n'
+                    '  return argv\n')
+        self.silent('def f():\n'
+                    '  from sys import *\n'
+                    '  return argv\n')
+        self.silent('def f():\n'
+                    '  return [(a, b) for a, b in [(1,2)]]\n')
+        self.silent('def f():\n'
+                    '  r = [(a, b) for a, b in [(1,2)]]\n'
+                    '  return r, a, b\n')
+        self.silent('import pychecker2.utest\n'
+                    'print pychecker2.utest.data.exceptions.Warning()')

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/usage.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/usage.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/usage.py
new file mode 100644
index 0000000..8ac02fb
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/usage.py
@@ -0,0 +1,7 @@
+from pychecker2.TestSupport import WarningTester
+from StringIO import StringIO
+
+class UsageTestCase(WarningTester):
+    def testUsage(self):
+        self.options.usage(['-?'], StringIO())
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/warnings.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/warnings.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/warnings.py
new file mode 100644
index 0000000..44a81ef
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/utest/warnings.py
@@ -0,0 +1,23 @@
+from pychecker2 import TestSupport
+from pychecker2 import OpChecks
+from pychecker2 import main
+
+from StringIO import StringIO
+
+class OpTests(TestSupport.WarningTester):
+
+    def _get_warnings(self):
+        out = StringIO()
+        f = self.check_file('def f(x):\n'
+                            '   return +x\n')
+        assert len(f.warnings) == 1
+        line, warning, args = f.warnings[0]
+        main.print_warnings(f, out)
+        return out.getvalue()
+    
+    def testWarningSuppression(self):
+        # check cmd-line warning suppression
+        assert self._get_warnings() != ''
+        self.argv = ['--no-operatorPlus']
+        assert self._get_warnings() == ''
+


[08/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code

Posted by rl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/util.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/util.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/util.py
new file mode 100644
index 0000000..55dee24
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/util.py
@@ -0,0 +1,73 @@
+
+class BaseVisitor:
+
+    def visit(self, unused_node):
+        "method is really overridden by compiler.visitor.ASTVisitor"
+        assert 0, 'Unreachable'
+
+    def visitChildren(self, n):
+        for c in n.getChildNodes():
+            self.visit(c)     
+
+def try_if_exclusive(stmt_node1, stmt_node2):
+    from compiler import ast as ast
+    
+    """return true if the statements are in exclusive parts of if/elif/else
+    or try/finally/else"""
+    
+    parent = stmt_node1.parent.parent
+    if parent == stmt_node2.parent.parent:
+        if isinstance(parent, ast.If):
+            parts = [code for test, code in parent.tests]
+            parts.append(parent.else_)
+            for part in parts:
+                if part and stmt_node1 in part.nodes:
+                    return stmt_node2 not in part.nodes
+        if isinstance(parent, ast.TryExcept):
+            parts = []
+            if parent.body:
+                parts.extend(parent.body.nodes)
+            if parent.else_:
+                parts.extend(parent.else_.nodes)
+            return not (stmt_node1 in parts and stmt_node2 in parts)
+    return None
+
+def parents(obj):
+    class Parents:
+        def __init__(self, start):
+            self.next = start
+        def __call__(self):
+            retval = self.next.parent
+            self.next = retval
+            return retval
+    return iter(Parents(obj), None)
+
+def enclosing_scopes(scopes, node):
+    result = []
+    n = node
+    while n:
+        try:
+            result.append(scopes[n])
+        except KeyError:
+            pass
+        n = n.parent
+    return result
+
+def type_filter(seq, *classes):
+    return [s for s in seq if isinstance(s, classes)]
+
+    
+def dict_minus(a, b):
+    r = {}
+    for k, v in a.iteritems():
+        if not b.has_key(k):
+            r[k] = v
+    return r
+
+def dict_intersect(a, b):
+    r = {}
+    for k, v in a.iteritems():
+        if b.has_key(k):
+            r[k] = v
+    return r
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pycheckrc
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pycheckrc b/tools/bin/pythonSrc/pychecker-0.8.18/pycheckrc
new file mode 100644
index 0000000..9ef8566
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pycheckrc
@@ -0,0 +1,225 @@
+# Sample defaults file for PyChecker 0.8.17
+# This file should be called:  .pycheckrc
+# It should be placed in your home directory (value of $HOME).
+# If $HOME is not set, it will look in the current directory.
+
+# bool: only warn about files passed on the command line
+only = 0
+
+# int: the maximum number of warnings to be displayed
+limit = 10
+
+# bool: warnings for Doc Strings
+noDocModule = 0
+noDocClass = 0
+noDocFunc = 0
+
+# bool: when checking if class data members (attributes) are set
+#       check all members or __init__() only
+onlyCheckInitForMembers = 0
+
+# bool: warn when all module variables are not used (including private vars)
+allVariablesUsed = 0
+
+# bool: produce warnings for each occurrence of a warning for global (xxx)
+reportAllGlobals = 0
+
+# bool: warn when private module variables are not used (_var)
+privateVariableUsed = 1
+
+# bool: warn when imports are not used
+importUsed = 1
+
+# bool: warn when import and from ... import are used for same module
+mixImport = 1
+
+# bool: warn when imports are not used in __init__.py
+packageImportUsed = 1
+
+# bool: warn when a module reimports another module (import & from/import)
+moduleImportErrors = 1
+
+# bool: warn when modules import themselves
+reimportSelf = 1
+
+# bool: warn when local variables are not used
+localVariablesUsed = 1
+
+# bool: assume a, b, and c are used in this case:  a, b, c = func()
+unusedLocalTuple = 0
+
+# bool: warn when class attributes (data members) are unused
+membersUsed = 0
+
+# bool: warn when Subclass.__init__ is not called in a subclass
+baseClassInitted = 1
+
+# bool: warn when Subclass needs to override methods that only throw exceptions
+abstractClasses = 1
+
+# bool: warn when __init__ is defined in a subclass
+initDefinedInSubclass = 0
+
+# bool: warn when __init__ returns None
+returnNoneFromInit = 1
+
+# bool: warn when code is not reachable
+unreachableCode = 0
+
+# bool: warn when a constant is used in a conditional statement (if '':)
+constantConditions = 1
+
+# bool: warn when 1 is used in a conditional statement, (if 1: while 1: etc)
+constant1 = 0
+
+# bool: warn when iterating over a string in a for loop
+stringIteration = 1
+
+# bool: warn when setting a variable to different types
+inconsistentTypes = 0
+
+# bool: warn when setting a tuple of variables to a non-sequence (a, b = None)
+unpackNonSequence = 1
+
+# bool: warn when setting a tuple of variables to the wrong length (a, b = 1,)
+unpackLength = 1
+
+# bool: warn when using strings exceptions or 
+#       other classes not derived from Exception to raise/catch exceptions
+badExceptions = 1
+
+# bool: warn when statements appear to have no effect
+noEffect = 1
+
+# bool: warn when using (expr % 1), it has no effect on integers and strings
+modulo1 = 1
+
+# bool: warn if using (expr is const-literal), 
+# doesn't always work on integers and strings
+isLiteral = 1
+
+# bool: warn when possibly using string.find() improperly (if s.find():)
+stringFind = 1
+
+# bool: warn when using a deprecated module or function
+deprecated = 1
+
+# bool: warn when the class attribute does not exist
+classAttrExists = 1
+
+# bool: warn when calling an attribute not a method
+callingAttribute = 0
+
+# bool: warn when using named arguments: func(a=1, b=2), where def func(a, b):
+#       def func2(a, b, **kw): doesn't generate a warning
+namedArgs = 0
+
+# str: name of 'self' parameter
+methodArgName = 'self'
+
+# list of str: names of first parameter to classmethods
+classmethodArgNames = ['cls', 'klass']
+
+# bool: warn when method/function arguments are unused
+argumentsUsed = 1
+
+# bool: ignore if self is unused in methods
+ignoreSelfUnused = 0
+
+# bool: warn if functions/classes/methods names are redefined in same scope
+redefiningFunction = 1
+
+# bool:  check if an overriden method has the same signature
+#	 as base class method (__init__() methods are not checked)
+checkOverridenMethods = 1
+
+# bool:  check if a special (reserved) method has the correct signature
+#	 and is known (these are methods that begin and end with __
+checkSpecialMethods = 1
+
+# int: warnings for code complexity, max value before generating a warning
+maxLines = 200
+maxBranches = 50
+maxReturns = 10
+maxArgs = 10
+maxLocals = 40
+maxReferences = 5
+
+
+# bool:  ignore all warnings from standard library components
+#	 (this includes anything under the standard library, eg, site-packages)
+ignoreStandardLibrary = 0
+
+
+# list of strings: ignore unused locals/arguments if name is one of
+unusedNames = [ '_', 'empty', 'unused', 'dummy', ]
+
+
+# list of strings: ignore warnings generated from these modules
+blacklist = [ 'Tkinter', 'wxPython', 'gtk', 'GTK', 'GDK', ]
+
+
+# list of strings: ignore global variables not used if name is one of
+variablesToIgnore = [ '__all__', '__version__', '__copyright__', ]
+
+
+# bool: print the PyChecker parse of modules, classes, etc.
+printParse = 0
+
+# bool: turn debugging of PyChecker on
+debug = 0
+
+# bool: check that attributes of objects exist
+checkObjectAttrs = 1
+
+# bool: various warnings about incorrect usage of __slots__
+slots = 1
+
+# bool: check if __slots__ is empty
+emptySlots = 1
+
+# bool: check for using properties in classic classes
+classicProperties = 1
+
+# bool: check for integer division (may be problem between Python versions)
+intDivide = 1
+
+# bool: check if local variables shadow a global variable with same name
+shadows = 1
+
+# bool: check if local variables shadow a builtin variable with same name
+shadowBuiltins = 1
+
+# bool: check if input() is used, which is a security problem, use raw_input()
+usesInput = 1
+
+# bool: check if using a constant string to getattr()/setattr()
+constAttr = 1
+
+# bool: check for using +variable, since it is almost always has no effect
+unaryPositive = 1
+
+# bool: check for modifying a parameter with a default value
+#       (value must be: list, dict, instance)
+#       modifying the value may have undesirable/unexpected side-effects
+modifyDefaultValue = 1
+
+# bool: check if the exec statement is used (possible security problem)
+usesExec = 0
+
+# bool: check consistent return values
+checkReturnValues = 1
+
+# bool: check if using implict and explicit return values
+checkImplicitReturns = 1
+
+# dict: suppress warnings, key is module.class.method or module.function
+#	value is a string of command line arguments (can omit -- for long args)
+#       { 'module1': 'no-namedargs maxlines=0',
+#	  'module2.my_func': 'argsused',
+#	  'module3.my_class': 'no-initreturn', }
+suppressions = {}
+
+# dict: suppress warnings where keys can be regular expressions
+suppressionRegexs = {}
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/setup.cfg
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/setup.cfg b/tools/bin/pythonSrc/pychecker-0.8.18/setup.cfg
new file mode 100644
index 0000000..66a10eb
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/setup.cfg
@@ -0,0 +1,8 @@
+[bdist_rpm]
+doc_files = README ChangeLog COPYRIGHT KNOWN_BUGS MAINTAINERS NEWS
+	pycheckrc TODO
+
+# adding this so that bdist_rpm does not complain about installed but
+# unpackaged .pyo files
+[install]
+optimize = 1

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/setup.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/setup.py b/tools/bin/pythonSrc/pychecker-0.8.18/setup.py
new file mode 100644
index 0000000..8250df9
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/setup.py
@@ -0,0 +1,281 @@
+#!/usr/bin/env python
+# -*- coding: iso-8859-1 -*-
+
+"""
+Python distutils setup script for pychecker.
+
+This code was originally contributed by Nicolas Chauvat, and has been rewritten
+to generalize it so it works properly with --prefix and other distutils
+options.
+
+This install script needs to customize two distutils behaviors: it needs to
+install the documentation to the configured package install directory, and it
+needs to create a pychecker (or pychecker.bat) script containing the correct
+path to the installed checker.py module and the Python interpreter.
+
+Nicolas' original attempt at this worked fine in the normal case (i.e. a root
+user install).  However, because it assumed that the package directory was
+always within sysconfig.get_python_lib(), it broke when users wanted to specify
+a prefix or a home directory install to, etc.
+
+After some research, I've decided that the best way to make this work is to
+customize (override) some of the distutils action classes.  This way, we get
+access to the distutils configuration and can "do the right thing" when options
+are specified.  
+
+@author: Kenneth J. Pronovici <pr...@ieee.org>, after Nicolas Chauvat.
+"""
+
+###################
+# Imported modules
+###################
+
+import sys
+import os
+from distutils import core
+from distutils.util import execute
+from distutils.command.bdist import bdist
+from distutils.command.bdist_dumb import bdist_dumb
+from distutils.command.bdist_rpm import bdist_rpm
+from distutils.command.bdist_wininst import bdist_wininst
+from distutils.command.install_data import install_data
+from distutils.command.install_scripts import install_scripts
+from distutils.command.build_scripts import build_scripts
+
+
+###############################
+# Overridden distutils actions
+###############################
+
+using_bdist = 0   # assume we're not using bdist
+
+class my_bdist(bdist):
+   """Customized action which flags that a binary distribution is being produced."""
+   def run(self):
+      global using_bdist
+      using_bdist = 1
+      bdist.run(self)
+
+class my_bdist_dumb(bdist_dumb):
+   """Customized action which flags that a binary distribution is being produced."""
+   def run(self):
+      global using_bdist
+      using_bdist = 1
+      bdist_dumb.run(self)
+
+class my_bdist_rpm(bdist_rpm):
+   """Customized action which flags that a binary distribution is being produced."""
+   def run(self):
+      global using_bdist
+      using_bdist = 1
+      bdist_rpm.run(self)
+
+class my_bdist_wininst(bdist_wininst):
+   """Customized action which flags that a binary distribution is being produced."""
+   def run(self):
+      global using_bdist
+      using_bdist = 1
+      bdist_wininst.run(self)
+
+class my_install_data(install_data):
+   """
+   Customized install_data distutils action.
+
+   This customized action forces all data files to all be installed relative to
+   the normal library install directory (within site-packages) rather than in
+   the standard location.
+
+   This action does not obey any --install-data flag that the user specifies.
+   Distutils apparently does not provide a way to tell whether the install data
+   directory on the Distribution class is "standard" or has already been
+   overrwritten.  This means that we don't have a way to say "change this only
+   if it hasn't been changed already".  All we can do is override the location
+   all of the time.
+
+   Note: If you want your files to go in the "pychecker" package directory,
+   make sure that you specify "pychecker" as the prefix in the setup target.
+   """
+   def finalize_options(self):
+      self.set_undefined_options('install', ('install_lib', 'install_dir'))
+      install_data.finalize_options(self) # invoke "standard" action
+
+class my_install_scripts(install_scripts):
+   """
+   Customized install_scripts distutils action.
+
+   This customized action fills in the pychecker script (either Windows or
+   shell style, depending on platform) using the proper path to the checker.py
+   file and Python interpreter.  This all is done through the execute() method,
+   so that the action obeys the --dry-run flag, etc.  
+
+   The pychecker script must be built here, in the install action, because the
+   proper path to checker.py cannot be known before this point.
+
+   If this action is invoked directly from the command-line, it won't have
+   access to certain configuration, such as the list of scripts.  Instead of
+   trying to work around all that (it's a pain), I've just disallowed the
+   action if it doesn't have the information it needs.
+
+   We have some special behavior around binary distributions.  If we're
+   building a binary distibution, then we don't try to figure out where
+   checker.py will be installed "for real".  We just assume it will be put in
+   the standard site-packages location.
+   """
+   def run(self):
+      global using_bdist
+      if not using_bdist:
+         install_lib = self.distribution.get_command_obj("install").install_lib
+      else:
+         install_lib = get_site_packages_path()
+      scripts = self.distribution.get_command_obj("build_scripts").scripts
+      if install_lib is None or scripts is None or self.build_dir is None:
+         print "note: install_scripts can only be invoked by install"
+      else:
+         script_path = get_script_path(self.build_dir)
+         if script_path in scripts:
+            package_path = os.path.join(install_lib, "pychecker")
+            # if a staging root is used, we don't want that path to end up
+            # in the install_lib path
+            root = self.distribution.get_command_obj("install").root
+            if root:
+               package_path = package_path[len(root):]
+            self.execute(func=create_script, 
+                         args=[script_path, package_path], 
+                         msg="filling in script %s" % script_path)
+         install_scripts.run(self) # invoke "standard" action
+
+class my_build_scripts(build_scripts):
+   """
+   Customized build_scripts distutils action.
+
+   This action looks through the configured scripts list, and if "pychecker" is
+   in the list, replaces that entry with the real name of the script to be
+   created within the build directory (including the .bat extension if needed).
+   Then, it creates an empty script file at that path to make distutils happy.
+   This is all done through the execute() method, so that the action obeys the
+   --dry-run flag, etc.
+
+   It might be surprising that we don't fill in the pychecker script here.
+   This is because in order to fill in the script, we need to know the
+   installed location of checker.py.  This information isn't available until
+   the install action is executed.
+
+   This action completely ignores any scripts other than "pychecker" which are
+   listed in the setup configuration, and it only does anything if "pychecker"
+   is listed in the first place.  This way, new scripts with constant contents
+   (if any) can be added to the setup configuration without writing any new
+   code.  It also helps OS package maintainers (like for the Debian package)
+   because they can still avoid installing scripts just by commenting out the
+   scripts line in configuration, just like usual.
+   """
+   def run(self):
+      if self.scripts is not None and "pychecker" in self.scripts:
+         script_path = get_script_path(self.build_dir)
+         self.scripts.remove("pychecker")
+         self.scripts.append(script_path)
+         self.mkpath(self.build_dir)
+         self.execute(func=open, args=[script_path, "w"], msg="creating empty script %s" % script_path)
+      build_scripts.run(self) # invoke "standard" action
+
+def get_script_path(build_dir):
+   """
+   Returns the platform-specific path to the pychecker script within the build dir.
+   """
+   if sys.platform == "win32":
+      return os.path.join(build_dir, "pychecker.bat")
+   else:
+      return os.path.join(build_dir, "pychecker")
+
+def get_site_packages_path():
+   """
+   Returns the platform-specific location of the site-packages directory.
+   This directory is usually something like /usr/share/python2.3/site-packages
+   on UNIX platforms and /Python23/Lib/site-packages on Windows platforms.
+   """
+   if sys.platform.lower().startswith('win'):
+      return os.path.join(sys.prefix, "Lib", "site-packages")
+   else:
+      return os.path.join(sys.prefix, "lib", 
+                          "python%s" % sys.version[:3], 
+                          "site-packages")
+
+def create_script(script_path, package_path):
+   """
+   Creates the pychecker script at the indicated path.
+
+   The pychecker script will be created to point to checker.py in the package
+   directory, using the Python executable specified in sys.executable.  If the
+   platform is Windows, a batch-style script will be created.  Otherwise, a
+   Bourne-shell script will be created.  Note that we don't worry about what
+   permissions mode the created file will have because the distutils install
+   process takes care of that for us.
+
+   @param script_path: Path to the script to be created
+   @param package_path: Path to the package that checker.py can be found within
+
+   @raise Exception: If script cannot be created on disk.
+   """
+   try:
+      checker_path = os.path.join(package_path, "checker.py")
+      if sys.platform == "win32":
+         script_str = "%s %s %%*\n" % (sys.executable, checker_path)
+      else:
+         script_str = '#! /bin/sh\n\n%s %s "$@"\n' % (sys.executable, checker_path)
+      open(script_path, "w").write(script_str)
+   except Exception, e:
+      print "ERROR: Unable to create %s: %s" % (script_path, e)
+      raise e
+
+
+######################
+# Setup configuration
+######################
+
+CUSTOMIZED_ACTIONS = { 'build_scripts'  : my_build_scripts, 
+                       'install_scripts': my_install_scripts, 
+                       'install_data'   : my_install_data,
+                       'bdist'          : my_bdist,
+                       'bdist_dumb'     : my_bdist_dumb,
+                       'bdist_rpm'      : my_bdist_rpm,
+                       'bdist_wininst'  : my_bdist_wininst,
+                     }
+
+DATA_FILES = [ 'COPYRIGHT', 'README', 'VERSION', 'ChangeLog', 'NEWS', 
+                'KNOWN_BUGS', 'MAINTAINERS', 'TODO', 
+             ]
+
+LONG_DESCRIPTION = """
+PyChecker is a tool for finding bugs in python source code.  It finds problems
+that are typically caught by a compiler for less dynamic languages, like C and
+C++. Because of the dynamic nature of Python, some warnings may be incorrect;
+however, spurious warnings should be fairly infrequent.
+"""
+
+kw =  { 'name'             : "PyChecker",
+        'version'          : "0.8.18",
+        'license'          : "BSD-like",
+        'description'      : "Python source code checking tool",
+        'author'           : "Neal Norwitz",
+        'author_email'     : "nnorwitz@gmail.com",
+        'url'              : "http://pychecker.sourceforge.net/",
+        'packages'         : [ 'pychecker', ],
+        'scripts'          : [ "pychecker" ],   # note: will be replaced by customized action
+        'data_files'       : [ ( "pychecker", DATA_FILES, ) ], 
+        'long_description' : LONG_DESCRIPTION,
+        'cmdclass'         : CUSTOMIZED_ACTIONS, 
+      }
+
+if hasattr(core, 'setup_keywords') and 'classifiers' in core.setup_keywords:
+   kw['classifiers'] =  [ 'Development Status :: 4 - Beta',
+                          'Environment :: Console',
+                          'Intended Audience :: Developers',
+                          'License :: OSI Approved :: BSD License',
+                          'Operating System :: OS Independent',
+                          'Programming Language :: Python',
+                          'Topic :: Software Development :: Debuggers',
+                          'Topic :: Software Development :: Quality Assurance',
+                          'Topic :: Software Development :: Testing',
+                        ]
+
+if __name__ == '__main__' :
+   core.setup(**kw)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test/common.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test/common.py b/tools/bin/pythonSrc/pychecker-0.8.18/test/common.py
new file mode 100644
index 0000000..a2b1afd
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test/common.py
@@ -0,0 +1,88 @@
+# -*- Mode: Python -*-
+# vi:si:et:sw=4:sts=4:ts=4
+
+import os
+import commands
+import unittest
+
+def canImport(module):
+    '''
+    Check if we can import the given module name.
+
+    @type module: str
+
+    @rtype: bool
+    '''
+    try:
+        __import__(module)
+        return True
+    except ImportError:
+        return False
+
+# lifted from flumotion with permission
+def _diff(old, new, desc):
+    import difflib
+    lines = difflib.unified_diff(old, new)
+    lines = list(lines)
+    if not lines:
+        return
+    output = ''
+    for line in lines:
+        output += '%s: %s\n' % (desc, line[:-1])
+
+    raise AssertionError(
+        ("\nError while comparing strings:\n"
+         "%s") % (output,))
+
+def diffStrings(orig, new, desc='input'):
+    def tolines(s):
+        return [line + '\n' for line in s.split('\n')]
+
+    return _diff(tolines(orig), tolines(new), desc=desc)
+
+
+# our base class for all tests
+class TestCase(unittest.TestCase):
+    def check(self, testname, args=''):
+        """
+        Run pychecker on the given test, located in input/
+        Will compare to output of the same name in expected/
+        """
+        return self.checkMultiple(testname, [testname + '.py'], args)
+
+    def checkMultiple(self, testname, checkables, args=''):
+        """
+        Run pychecker on the given test, located in input/
+        Will compare to output of the same name in expected/
+
+        @type checkables: list of str
+        """
+        testdir = os.path.dirname(__file__)
+        # make this relative to where we are, so paths shown are relative too
+        if testdir.startswith(os.getcwd()):
+            testdir = testdir[len(os.getcwd()) + 1:]
+
+        pycheckerpy = os.path.join(os.path.dirname(testdir),
+            'pychecker', 'checker.py')
+        testfiles = [os.path.join(testdir, 'input', c) for c in checkables]
+
+        cmd = "python -tt %s " \
+            "--limit 0 --no-argsused " \
+            "%s %s" % (pycheckerpy, args, " ".join(testfiles))
+        # getoutput output never ends on a newline the way
+        # pychecker ... > expected/... would
+        output = commands.getoutput(cmd) + '\n'
+        
+        # here we can select a different file based on os/python version/arch
+        expectedfile = os.path.join(testdir, 'expected', testname)
+
+        # FIXME: make generating an option
+        # for now, do it every time we don't have the expected output
+        # to help us
+        if not os.path.exists(expectedfile):
+            open(expectedfile, 'w').write(output)
+
+        expected = open(expectedfile).read()
+
+        diffStrings(output, expected, desc=expectedfile)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test/expected/test_getmodule
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test/expected/test_getmodule b/tools/bin/pythonSrc/pychecker-0.8.18/test/expected/test_getmodule
new file mode 100644
index 0000000..68de65c
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test/expected/test_getmodule
@@ -0,0 +1,8 @@
+Processing module C (test/input/getmodule/A/C.py)...
+Processing module C (test/input/getmodule/B/C.py)...
+
+Warnings...
+
+test/input/getmodule/A/C.py:4: Imported module (time) not used
+
+test/input/getmodule/B/C.py:4: Imported module (os) not used

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test/expected/test_zope_interface
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test/expected/test_zope_interface b/tools/bin/pythonSrc/pychecker-0.8.18/test/expected/test_zope_interface
new file mode 100644
index 0000000..ecde326
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test/expected/test_zope_interface
@@ -0,0 +1,5 @@
+Processing module test_zope_interface (test/input/test_zope_interface.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test/input/getmodule/A/C.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test/input/getmodule/A/C.py b/tools/bin/pythonSrc/pychecker-0.8.18/test/input/getmodule/A/C.py
new file mode 100644
index 0000000..11fff15
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test/input/getmodule/A/C.py
@@ -0,0 +1,4 @@
+# -*- Mode: Python -*-
+# vi:si:et:sw=4:sts=4:ts=4
+
+import time

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test/input/getmodule/A/__init__.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test/input/getmodule/A/__init__.py b/tools/bin/pythonSrc/pychecker-0.8.18/test/input/getmodule/A/__init__.py
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test/input/getmodule/B/C.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test/input/getmodule/B/C.py b/tools/bin/pythonSrc/pychecker-0.8.18/test/input/getmodule/B/C.py
new file mode 100644
index 0000000..59fdef3
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test/input/getmodule/B/C.py
@@ -0,0 +1,4 @@
+# -*- Mode: Python -*-
+# vi:si:et:sw=4:sts=4:ts=4
+
+import os

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test/input/getmodule/B/__init__.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test/input/getmodule/B/__init__.py b/tools/bin/pythonSrc/pychecker-0.8.18/test/input/getmodule/B/__init__.py
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test/input/getmodule/__init__.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test/input/getmodule/__init__.py b/tools/bin/pythonSrc/pychecker-0.8.18/test/input/getmodule/__init__.py
new file mode 100644
index 0000000..3a324eb
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test/input/getmodule/__init__.py
@@ -0,0 +1 @@
+'d'

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test/input/test_getmodule.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test/input/test_getmodule.py b/tools/bin/pythonSrc/pychecker-0.8.18/test/input/test_getmodule.py
new file mode 100644
index 0000000..2d3118a
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test/input/test_getmodule.py
@@ -0,0 +1,5 @@
+# -*- Mode: Python -*-
+# vi:si:et:sw=4:sts=4:ts=4
+
+from getmodule.A import C as one
+from getmodule.B import C as two

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test/input/test_zope_interface.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test/input/test_zope_interface.py b/tools/bin/pythonSrc/pychecker-0.8.18/test/input/test_zope_interface.py
new file mode 100644
index 0000000..8d2717f
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test/input/test_zope_interface.py
@@ -0,0 +1,4 @@
+# -*- Mode: Python -*-
+# vi:si:et:sw=4:sts=4:ts=4
+
+from zope.interface import Interface

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test/main.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test/main.py b/tools/bin/pythonSrc/pychecker-0.8.18/test/main.py
new file mode 100644
index 0000000..10d2389
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test/main.py
@@ -0,0 +1,13 @@
+# -*- Mode: Python -*-
+# vi:si:et:sw=4:sts=4:ts=4
+
+# import all TestCase from all test modules
+# FIXME: we could autodiscovery all test_ modules
+# note: this means all TestCase classes need a different name, might
+# be a problem if one shadows another accidentally ?
+
+from test_stdlib import *
+from test_module import *
+
+if __name__ == '__main__':
+    unittest.main()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test/test_module.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test/test_module.py b/tools/bin/pythonSrc/pychecker-0.8.18/test/test_module.py
new file mode 100644
index 0000000..d57c7c6
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test/test_module.py
@@ -0,0 +1,22 @@
+# -*- Mode: Python -*-
+# vi:si:et:sw=4:sts=4:ts=4
+
+'''
+Tests related to modules.
+'''
+
+import unittest
+import common
+
+class SameModuleNameTestCase(common.TestCase):
+    '''
+    Test that modules with the same name do not shadow eachother.
+    '''
+    def test_getmodule(self):
+        self.checkMultiple('test_getmodule', [
+            'getmodule/A/C.py',
+            'getmodule/B/C.py',
+            ])
+    
+if __name__ == '__main__':
+    unittest.main()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test/test_stdlib.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test/test_stdlib.py b/tools/bin/pythonSrc/pychecker-0.8.18/test/test_stdlib.py
new file mode 100644
index 0000000..d9cb89d
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test/test_stdlib.py
@@ -0,0 +1,25 @@
+# -*- Mode: Python -*-
+# vi:si:et:sw=4:sts=4:ts=4
+
+'''
+Tests related to the -q/--stdlib option.
+'''
+
+import unittest
+import common
+
+class ZopeTestCase(common.TestCase):
+    '''
+    test that -q properly ignores errors for modules in the arch-specific
+    directory.
+
+    See http://sourceforge.net/tracker/index.php?func=detail&aid=1564614&group_id=24686&atid=382217
+    '''
+    def test_zope_interface(self):
+        if not common.canImport('zope.interface'):
+            self.skip = True # FIXME: interpret this
+
+        self.check('test_zope_interface', '-q')
+    
+if __name__ == '__main__':
+    unittest.main()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_check.sh
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_check.sh b/tools/bin/pythonSrc/pychecker-0.8.18/test_check.sh
new file mode 100755
index 0000000..6bc71a5
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_check.sh
@@ -0,0 +1,69 @@
+#!/bin/sh
+
+TESTS="test_input/test[1-9]*.py"
+# comment out to use python from path
+#PYTHON="python2"
+#PYTHON="$HOME/build/python/2_3/python"
+#PYTHON="$PYTHON -tt coverage.py -x"
+#PYTHON="/usr/bin/python2.3"
+
+if [ "$PYTHON" = "" ]; then
+    PYTHON=python
+fi
+
+if [ $# -gt 0 ]; then
+    TESTS=""
+    for arg in $* ; do
+        TESTS="$TESTS test_input/test${arg}.py"
+    done
+fi
+
+if [ -z "$TMP" ]; then
+    TMP=/tmp
+fi
+
+error=0
+
+VERSION=`$PYTHON -c "import sys ; print '%d.%d' % sys.version_info[0:2]"`
+FAILED=""
+NO_EXPECTED_RESULTS=""
+for test_file in $TESTS ; do
+    echo "Testing $test_file ..."
+    test_name=`basename $test_file .py`
+    expected=test_expected/$test_name
+    if [ -e ${expected}-$VERSION ]; then
+        expected=${expected}-$VERSION
+    elif [ ! -e $expected ]; then
+        echo "  WARNING:  $expected expected results does not exist"
+        NO_EXPECTED_RESULTS="$NO_EXPECTED_RESULTS $test_name"
+        continue
+    fi
+
+    # make sure to use the -F option for this special test
+    extra_args=""
+    if [ "$test_file" = "test_input/test39.py" ]; then
+        extra_args="-F test_input/pycheckrc"
+    fi
+
+    test_path=$TMP/$test_name
+    $PYTHON -tt ./pychecker/checker.py --limit 0 --moduledoc --classdoc --no-argsused $extra_args $test_file 2>&1 | egrep -v '\[[0-9]+ refs\]$' > $test_path
+    diff $test_path $expected
+    if [ $? -ne 0 ]; then
+        error=`expr $error + 1`
+        echo "  $test_name FAILED"
+        FAILED="$FAILED $test_name"
+    fi
+    rm -f $test_path
+done
+
+if [ $error -ne 0 ]; then
+    echo ""
+    echo "$errors TESTS FAILED: $FAILED"
+else
+    echo "ALL TESTS PASSED"
+fi
+
+if [ "$NO_EXPECTED_RESULTS" != "" ]; then
+    echo " WARNING no expected results for: $NO_EXPECTED_RESULTS"
+fi
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test1
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test1 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test1
new file mode 100644
index 0000000..e34874d
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test1
@@ -0,0 +1,35 @@
+Processing module test1 (test_input/test1.py)...
+test_input/test1.py:67: SyntaxWarning: local name 'b' in 'test_kw_lambda' shadows use of 'b' as global in nested scope 'lambda'
+  def test_kw_lambda(a, b, c):
+
+Warnings...
+
+test_input/test1.py:1: No module doc string
+test_input/test1.py:2: Imported module (imp) not used
+test_input/test1.py:3: Imported module (re) not used
+test_input/test1.py:5: Variable (_NOT_USED1) not used
+test_input/test1.py:10: Local variable (m) not used
+test_input/test1.py:10: No global (unknownList) found
+test_input/test1.py:13: self is argument in function
+test_input/test1.py:21: Invalid arguments to (jjj2), got 0, expected between 1 and 3
+test_input/test1.py:25: Invalid arguments to (jjj2), got 4, expected between 1 and 3
+test_input/test1.py:28: Invalid arguments to (ddd), got 0, expected at least 1
+test_input/test1.py:34: No doc string for class X
+test_input/test1.py:34: No doc string for class Y
+test_input/test1.py:35: No global (sys) found
+test_input/test1.py:36: No class attribute (__x__) found
+test_input/test1.py:36: No class attribute (x) found
+test_input/test1.py:39: self is not first method argument
+test_input/test1.py:40: No global (nofunc) found
+test_input/test1.py:41: Local variable (i) not used
+test_input/test1.py:41: No class attribute (a) found
+test_input/test1.py:41: No global (self) found
+test_input/test1.py:42: Function (jjj) doesn't support **kwArgs
+test_input/test1.py:42: Invalid arguments to (jjj), got 3, expected 1
+test_input/test1.py:46: Local variable (asdf) not used
+test_input/test1.py:48: Local variable (j) not used
+test_input/test1.py:48: No global (jjjj) found
+test_input/test1.py:50: No class attribute (z) found
+test_input/test1.py:54: Invalid arguments to (xxx), got 2, expected 1
+test_input/test1.py:70: (str) shadows builtin
+test_input/test1.py:75: Function (append) doesn't support **kwArgs

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test1-2.3
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test1-2.3 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test1-2.3
new file mode 100644
index 0000000..a822a83
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test1-2.3
@@ -0,0 +1,33 @@
+Processing module test1 (test_input/test1.py)...
+
+Warnings...
+
+test_input/test1.py:1: No module doc string
+test_input/test1.py:2: Imported module (imp) not used
+test_input/test1.py:3: Imported module (re) not used
+test_input/test1.py:5: Variable (_NOT_USED1) not used
+test_input/test1.py:10: Local variable (m) not used
+test_input/test1.py:10: No global (unknownList) found
+test_input/test1.py:13: self is argument in function
+test_input/test1.py:21: Invalid arguments to (jjj2), got 0, expected between 1 and 3
+test_input/test1.py:25: Invalid arguments to (jjj2), got 4, expected between 1 and 3
+test_input/test1.py:28: Invalid arguments to (ddd), got 0, expected at least 1
+test_input/test1.py:34: No doc string for class X
+test_input/test1.py:34: No doc string for class Y
+test_input/test1.py:35: No global (sys) found
+test_input/test1.py:36: No class attribute (__x__) found
+test_input/test1.py:36: No class attribute (x) found
+test_input/test1.py:39: self is not first method argument
+test_input/test1.py:40: No global (nofunc) found
+test_input/test1.py:41: Local variable (i) not used
+test_input/test1.py:41: No class attribute (a) found
+test_input/test1.py:41: No global (self) found
+test_input/test1.py:42: Function (jjj) doesn't support **kwArgs
+test_input/test1.py:42: Invalid arguments to (jjj), got 3, expected 1
+test_input/test1.py:46: Local variable (asdf) not used
+test_input/test1.py:48: Local variable (j) not used
+test_input/test1.py:48: No global (jjjj) found
+test_input/test1.py:50: No class attribute (z) found
+test_input/test1.py:54: Invalid arguments to (xxx), got 2, expected 1
+test_input/test1.py:70: (str) shadows builtin
+test_input/test1.py:75: Function (append) doesn't support **kwArgs

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test1-2.4
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test1-2.4 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test1-2.4
new file mode 100644
index 0000000..a822a83
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test1-2.4
@@ -0,0 +1,33 @@
+Processing module test1 (test_input/test1.py)...
+
+Warnings...
+
+test_input/test1.py:1: No module doc string
+test_input/test1.py:2: Imported module (imp) not used
+test_input/test1.py:3: Imported module (re) not used
+test_input/test1.py:5: Variable (_NOT_USED1) not used
+test_input/test1.py:10: Local variable (m) not used
+test_input/test1.py:10: No global (unknownList) found
+test_input/test1.py:13: self is argument in function
+test_input/test1.py:21: Invalid arguments to (jjj2), got 0, expected between 1 and 3
+test_input/test1.py:25: Invalid arguments to (jjj2), got 4, expected between 1 and 3
+test_input/test1.py:28: Invalid arguments to (ddd), got 0, expected at least 1
+test_input/test1.py:34: No doc string for class X
+test_input/test1.py:34: No doc string for class Y
+test_input/test1.py:35: No global (sys) found
+test_input/test1.py:36: No class attribute (__x__) found
+test_input/test1.py:36: No class attribute (x) found
+test_input/test1.py:39: self is not first method argument
+test_input/test1.py:40: No global (nofunc) found
+test_input/test1.py:41: Local variable (i) not used
+test_input/test1.py:41: No class attribute (a) found
+test_input/test1.py:41: No global (self) found
+test_input/test1.py:42: Function (jjj) doesn't support **kwArgs
+test_input/test1.py:42: Invalid arguments to (jjj), got 3, expected 1
+test_input/test1.py:46: Local variable (asdf) not used
+test_input/test1.py:48: Local variable (j) not used
+test_input/test1.py:48: No global (jjjj) found
+test_input/test1.py:50: No class attribute (z) found
+test_input/test1.py:54: Invalid arguments to (xxx), got 2, expected 1
+test_input/test1.py:70: (str) shadows builtin
+test_input/test1.py:75: Function (append) doesn't support **kwArgs

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test1-2.5
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test1-2.5 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test1-2.5
new file mode 100644
index 0000000..a822a83
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test1-2.5
@@ -0,0 +1,33 @@
+Processing module test1 (test_input/test1.py)...
+
+Warnings...
+
+test_input/test1.py:1: No module doc string
+test_input/test1.py:2: Imported module (imp) not used
+test_input/test1.py:3: Imported module (re) not used
+test_input/test1.py:5: Variable (_NOT_USED1) not used
+test_input/test1.py:10: Local variable (m) not used
+test_input/test1.py:10: No global (unknownList) found
+test_input/test1.py:13: self is argument in function
+test_input/test1.py:21: Invalid arguments to (jjj2), got 0, expected between 1 and 3
+test_input/test1.py:25: Invalid arguments to (jjj2), got 4, expected between 1 and 3
+test_input/test1.py:28: Invalid arguments to (ddd), got 0, expected at least 1
+test_input/test1.py:34: No doc string for class X
+test_input/test1.py:34: No doc string for class Y
+test_input/test1.py:35: No global (sys) found
+test_input/test1.py:36: No class attribute (__x__) found
+test_input/test1.py:36: No class attribute (x) found
+test_input/test1.py:39: self is not first method argument
+test_input/test1.py:40: No global (nofunc) found
+test_input/test1.py:41: Local variable (i) not used
+test_input/test1.py:41: No class attribute (a) found
+test_input/test1.py:41: No global (self) found
+test_input/test1.py:42: Function (jjj) doesn't support **kwArgs
+test_input/test1.py:42: Invalid arguments to (jjj), got 3, expected 1
+test_input/test1.py:46: Local variable (asdf) not used
+test_input/test1.py:48: Local variable (j) not used
+test_input/test1.py:48: No global (jjjj) found
+test_input/test1.py:50: No class attribute (z) found
+test_input/test1.py:54: Invalid arguments to (xxx), got 2, expected 1
+test_input/test1.py:70: (str) shadows builtin
+test_input/test1.py:75: Function (append) doesn't support **kwArgs

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test1-2.6
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test1-2.6 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test1-2.6
new file mode 100644
index 0000000..a822a83
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test1-2.6
@@ -0,0 +1,33 @@
+Processing module test1 (test_input/test1.py)...
+
+Warnings...
+
+test_input/test1.py:1: No module doc string
+test_input/test1.py:2: Imported module (imp) not used
+test_input/test1.py:3: Imported module (re) not used
+test_input/test1.py:5: Variable (_NOT_USED1) not used
+test_input/test1.py:10: Local variable (m) not used
+test_input/test1.py:10: No global (unknownList) found
+test_input/test1.py:13: self is argument in function
+test_input/test1.py:21: Invalid arguments to (jjj2), got 0, expected between 1 and 3
+test_input/test1.py:25: Invalid arguments to (jjj2), got 4, expected between 1 and 3
+test_input/test1.py:28: Invalid arguments to (ddd), got 0, expected at least 1
+test_input/test1.py:34: No doc string for class X
+test_input/test1.py:34: No doc string for class Y
+test_input/test1.py:35: No global (sys) found
+test_input/test1.py:36: No class attribute (__x__) found
+test_input/test1.py:36: No class attribute (x) found
+test_input/test1.py:39: self is not first method argument
+test_input/test1.py:40: No global (nofunc) found
+test_input/test1.py:41: Local variable (i) not used
+test_input/test1.py:41: No class attribute (a) found
+test_input/test1.py:41: No global (self) found
+test_input/test1.py:42: Function (jjj) doesn't support **kwArgs
+test_input/test1.py:42: Invalid arguments to (jjj), got 3, expected 1
+test_input/test1.py:46: Local variable (asdf) not used
+test_input/test1.py:48: Local variable (j) not used
+test_input/test1.py:48: No global (jjjj) found
+test_input/test1.py:50: No class attribute (z) found
+test_input/test1.py:54: Invalid arguments to (xxx), got 2, expected 1
+test_input/test1.py:70: (str) shadows builtin
+test_input/test1.py:75: Function (append) doesn't support **kwArgs

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test10
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test10 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test10
new file mode 100644
index 0000000..3015d51
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test10
@@ -0,0 +1,5 @@
+Processing module test10 (test_input/test10.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test100
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test100 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test100
new file mode 100644
index 0000000..97411d3
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test100
@@ -0,0 +1,5 @@
+Processing module test100 (test_input/test100.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test101
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test101 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test101
new file mode 100644
index 0000000..93270b1
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test101
@@ -0,0 +1,5 @@
+Processing module test101 (test_input/test101.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test102
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test102 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test102
new file mode 100644
index 0000000..95a20b0
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test102
@@ -0,0 +1,5 @@
+Processing module test102 (test_input/test102.py)...
+
+Warnings...
+
+test_input/test102.py:8: __getattr__ should not return None, raise an exception if not found

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test11
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test11 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test11
new file mode 100644
index 0000000..62ac16c
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test11
@@ -0,0 +1,5 @@
+Processing module test11 (test_input/test11.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test12
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test12 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test12
new file mode 100644
index 0000000..158a259
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test12
@@ -0,0 +1,5 @@
+Processing module test12 (test_input/test12.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test13
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test13 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test13
new file mode 100644
index 0000000..457342a
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test13
@@ -0,0 +1,6 @@
+Processing module test13 (test_input/test13.py)...
+
+Warnings...
+
+test_input/test13.py:12: Global variable (x) not defined in module scope
+test_input/test13.py:29: No global (xxx) found

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test14
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test14 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test14
new file mode 100644
index 0000000..642f595
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test14
@@ -0,0 +1,9 @@
+Processing module test14 (test_input/test14.py)...
+
+Warnings...
+
+test_input/test14.py:4: Module (string) re-imported
+test_input/test14.py:7: Variable (_unused) not used
+test_input/test14.py:10: Local variable (jj) not used
+test_input/test14.py:10: Module (string) re-imported
+test_input/test14.py:18: Variable (_noglobal) not used

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test15
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test15 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test15
new file mode 100644
index 0000000..eb2bf44
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test15
@@ -0,0 +1,8 @@
+Processing module test15 (test_input/test15.py)...
+
+Warnings...
+
+test_input/test15.py:19: Law of Demeter violated, more than 5 references for (obj.x.y.z.a.b)
+test_input/test15.py:20: Law of Demeter violated, more than 5 references for (obj.x.y.z.a.b.c)
+test_input/test15.py:30: Law of Demeter violated, more than 6 references for (self.xx.y.z.a.b)
+test_input/test15.py:38: Law of Demeter violated, more than 6 references for (self.xx.y.z.a.b.c)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test16
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test16 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test16
new file mode 100644
index 0000000..cb1cc49
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test16
@@ -0,0 +1,5 @@
+Processing module test16 (test_input/test16.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test17
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test17 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test17
new file mode 100644
index 0000000..dcd8e4e
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test17
@@ -0,0 +1,8 @@
+Processing module test17 (test_input/test17.py)...
+
+Warnings...
+
+test_input/test17.py:7: Cannot return a value from __init__
+test_input/test17.py:13: Cannot return a value from __init__
+test_input/test17.py:15: Cannot return a value from __init__
+test_input/test17.py:16: Cannot return a value from __init__

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test17-2.4
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test17-2.4 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test17-2.4
new file mode 100644
index 0000000..ee54569
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test17-2.4
@@ -0,0 +1,7 @@
+Processing module test17 (test_input/test17.py)...
+
+Warnings...
+
+test_input/test17.py:7: Cannot return a value from __init__
+test_input/test17.py:13: Cannot return a value from __init__
+test_input/test17.py:15: Cannot return a value from __init__

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test18
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test18 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test18
new file mode 100644
index 0000000..7446046
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test18
@@ -0,0 +1,16 @@
+Processing module test18 (test_input/test18.py)...
+
+Warnings...
+
+test_input/test18.py:21: Invalid arguments to (__init__), got 1, expected 0
+test_input/test18.py:23: Invalid arguments to (__init__), got 0, expected 1
+test_input/test18.py:25: Invalid arguments to (__init__), got 2, expected 1
+test_input/test18.py:26: Invalid arguments to (__init__), got 3, expected 1
+test_input/test18.py:27: Invalid arguments to (__init__), got 4, expected 1
+test_input/test18.py:29: Invalid arguments to (__init__), got 0, expected 3
+test_input/test18.py:30: Invalid arguments to (__init__), got 1, expected 3
+test_input/test18.py:31: Invalid arguments to (__init__), got 2, expected 3
+test_input/test18.py:33: Invalid arguments to (__init__), got 4, expected 3
+test_input/test18.py:35: Invalid arguments to (__init__), got 0, expected at least 3
+test_input/test18.py:36: Invalid arguments to (__init__), got 1, expected at least 3
+test_input/test18.py:37: Invalid arguments to (__init__), got 2, expected at least 3

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test19
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test19 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test19
new file mode 100644
index 0000000..449ad40
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test19
@@ -0,0 +1,6 @@
+Processing module test19 (test_input/test19.py)...
+
+Warnings...
+
+test_input/test19.py:8: Invalid arguments to (__init__), got 2, expected between 0 and 1
+test_input/test19.py:9: Invalid arguments to (__init__), got 3, expected between 0 and 1

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test2
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test2 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test2
new file mode 100644
index 0000000..3b25b9d
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test2
@@ -0,0 +1,8 @@
+Processing module test2 (test_input/test2.py)...
+
+Warnings...
+
+test_input/test2.py:4: Imported module (time) not used
+test_input/test2.py:9: No doc string for class X
+test_input/test2.py:16: Base class (test2.X) __init__() not called
+test_input/test2.py:16: No doc string for class Y

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test20
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test20 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test20
new file mode 100644
index 0000000..1977854
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test20
@@ -0,0 +1,7 @@
+Processing module test20 (test_input/test20.py)...
+
+Warnings...
+
+test_input/test20.py:11: Function returns a value and also implicitly returns None
+test_input/test20.py:21: Function return types are inconsistent
+test_input/test20.py:40: Function return types are inconsistent

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test20-2.4
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test20-2.4 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test20-2.4
new file mode 100644
index 0000000..adab540
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test20-2.4
@@ -0,0 +1,6 @@
+Processing module test20 (test_input/test20.py)...
+
+Warnings...
+
+test_input/test20.py:21: Function return types are inconsistent
+test_input/test20.py:40: Function return types are inconsistent

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test20-2.5
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test20-2.5 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test20-2.5
new file mode 100644
index 0000000..adab540
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test20-2.5
@@ -0,0 +1,6 @@
+Processing module test20 (test_input/test20.py)...
+
+Warnings...
+
+test_input/test20.py:21: Function return types are inconsistent
+test_input/test20.py:40: Function return types are inconsistent

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test20-2.6
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test20-2.6 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test20-2.6
new file mode 100644
index 0000000..adab540
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test20-2.6
@@ -0,0 +1,6 @@
+Processing module test20 (test_input/test20.py)...
+
+Warnings...
+
+test_input/test20.py:21: Function return types are inconsistent
+test_input/test20.py:40: Function return types are inconsistent

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test21
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test21 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test21
new file mode 100644
index 0000000..6d598b8
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test21
@@ -0,0 +1,7 @@
+Processing module test21 (test_input/test21.py)...
+
+Warnings...
+
+test_input/test21.py:9: Function return types are inconsistent
+test_input/test21.py:15: Function return types are inconsistent
+test_input/test21.py:21: Function return types are inconsistent

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test22
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test22 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test22
new file mode 100644
index 0000000..fe21833
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test22
@@ -0,0 +1,33 @@
+Processing module test22 (test_input/test22.py)...
+
+Warnings...
+
+test_input/test22.py:6: Format string argument count (4) doesn't match arguments (3)
+test_input/test22.py:9: Local variable (eee) not used
+test_input/test22.py:10: No local variable (ccc)
+test_input/test22.py:10: No local variable (ddd)
+test_input/test22.py:13: No local variable ()
+test_input/test22.py:15: Invalid format string, problem starts near: '(b) '
+test_input/test22.py:16: Invalid format string, problem starts near: '(b)'
+test_input/test22.py:19: Format string argument count (2) doesn't match arguments (3)
+test_input/test22.py:22: Format string argument count (3) doesn't match arguments (4)
+test_input/test22.py:24: Invalid format string, problem starts near: 'z '
+test_input/test22.py:25: Invalid format string, problem starts near: 'J '
+test_input/test22.py:26: Too many *s in format flags
+test_input/test22.py:28: Can't mix tuple/mapping (dictionary) formats in same format string
+test_input/test22.py:29: Can't use * in formats when using a mapping (dictionary), near: '*d'
+test_input/test22.py:31: Can't use * in formats when using a mapping (dictionary), near: '*.*f'
+test_input/test22.py:34: Format string argument count (3) doesn't match arguments (2)
+test_input/test22.py:40: Format string argument count (2) doesn't match arguments (1)
+test_input/test22.py:42: Format string argument count (2) doesn't match arguments (3)
+test_input/test22.py:46: Format string argument count (1) doesn't match arguments (3)
+test_input/test22.py:51: Format string argument count (1) doesn't match arguments (2)
+test_input/test22.py:65: Format string argument count (2) doesn't match arguments (3)
+test_input/test22.py:66: Format string argument count (3) doesn't match arguments (4)
+test_input/test22.py:67: Format string argument count (4) doesn't match arguments (2)
+test_input/test22.py:70: Local variable (c) not used
+test_input/test22.py:74: Local variable (a) not used
+test_input/test22.py:74: Local variable (b) not used
+test_input/test22.py:79: ... % 1 may be constant
+test_input/test22.py:81: ... % 1 may be constant
+test_input/test22.py:86: Invalid format string, problem starts near: '' (end of format string)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test23
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test23 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test23
new file mode 100644
index 0000000..237e308
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test23
@@ -0,0 +1,8 @@
+Processing module test23 (test_input/test23.py)...
+
+Warnings...
+
+test_input/test23.py:13: Using method (x) as an attribute (not invoked)
+test_input/test23.py:15: Using method (x) as an attribute (not invoked)
+test_input/test23.py:17: Using method (x) as an attribute (not invoked)
+test_input/test23.py:39: Using method (x) as an attribute (not invoked)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test24
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test24 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test24
new file mode 100644
index 0000000..5639062
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test24
@@ -0,0 +1,10 @@
+Processing module test24 (test_input/test24.py)...
+
+Warnings...
+
+test_input/import24.py:4: No doc string for class Aaa
+test_input/import24.py:8: Base class (import24.Aaa) __init__() not called
+test_input/import24.py:8: No doc string for class Bbb
+
+test_input/test24.py:8: Invalid arguments to (func24), got 1, expected 0
+test_input/test24.py:11: Local variable (shadow) shadows global defined on line 0 in file <unknown>

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test25
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test25 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test25
new file mode 100644
index 0000000..7277d69
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test25
@@ -0,0 +1,8 @@
+Processing module test25 (test_input/test25.py)...
+
+Warnings...
+
+test_input/test25.py:11: Invalid arguments to (x), got 0, expected 1
+test_input/test25.py:13: No class attribute (a) found
+test_input/test25.py:14: No class attribute (y) found
+test_input/test25.py:15: No module attribute (lkjsdflksjasdlf) found

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test26
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test26 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test26
new file mode 100644
index 0000000..fbed2a5
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test26
@@ -0,0 +1,5 @@
+Processing module test26 (test_input/test26.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test27
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test27 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test27
new file mode 100644
index 0000000..284e831
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test27
@@ -0,0 +1,7 @@
+Processing module test27 (test_input/test27.py)...
+test_input/test27.py:12: SyntaxWarning: local name 'string' in 'd' shadows use of 'string' as global in nested scope 'lambda'
+  def d(lines):
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test27-2.2
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test27-2.2 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test27-2.2
new file mode 100644
index 0000000..f3b2687
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test27-2.2
@@ -0,0 +1,5 @@
+Processing module test27 (test_input/test27.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test27-2.3
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test27-2.3 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test27-2.3
new file mode 100644
index 0000000..f3b2687
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test27-2.3
@@ -0,0 +1,5 @@
+Processing module test27 (test_input/test27.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test27-2.4
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test27-2.4 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test27-2.4
new file mode 100644
index 0000000..f3b2687
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test27-2.4
@@ -0,0 +1,5 @@
+Processing module test27 (test_input/test27.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test27-2.5
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test27-2.5 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test27-2.5
new file mode 100644
index 0000000..f3b2687
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test27-2.5
@@ -0,0 +1,5 @@
+Processing module test27 (test_input/test27.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test27-2.6
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test27-2.6 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test27-2.6
new file mode 100644
index 0000000..f3b2687
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test27-2.6
@@ -0,0 +1,5 @@
+Processing module test27 (test_input/test27.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test28
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test28 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test28
new file mode 100644
index 0000000..021c890
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test28
@@ -0,0 +1,5 @@
+Processing module test28 (test_input/test28.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test29
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test29 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test29
new file mode 100644
index 0000000..5aa02d7
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test29
@@ -0,0 +1,5 @@
+Processing module test29 (test_input/test29.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test3
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test3 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test3
new file mode 100644
index 0000000..03c8bd5
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test3
@@ -0,0 +1,8 @@
+Processing module test3 (test_input/test3.py)...
+
+Warnings...
+
+UserDict.py:4: No doc string for class UserDict
+
+test_input/test3.py:7: No global (x) found
+test_input/test3.py:12: No doc string for class jj

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test3-2.2
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test3-2.2 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test3-2.2
new file mode 100644
index 0000000..6684369
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test3-2.2
@@ -0,0 +1,8 @@
+Processing module test3 (test_input/test3.py)...
+
+Warnings...
+
+/usr/src/build/228093-i386/install/usr/lib/python2.2/UserDict.py:4: No doc string for class UserDict
+
+test_input/test3.py:7: No global (x) found
+test_input/test3.py:12: No doc string for class jj

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test3-2.3
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test3-2.3 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test3-2.3
new file mode 100644
index 0000000..4587796
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test3-2.3
@@ -0,0 +1,9 @@
+Processing module test3 (test_input/test3.py)...
+
+Warnings...
+
+/usr/lib/python2.3/UserDict.py:4: No doc string for class UserDict
+/usr/lib/python2.3/UserDict.py:8: (dict) shadows builtin
+
+test_input/test3.py:7: No global (x) found
+test_input/test3.py:12: No doc string for class jj

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test3-2.4
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test3-2.4 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test3-2.4
new file mode 100644
index 0000000..03c8bd5
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test3-2.4
@@ -0,0 +1,8 @@
+Processing module test3 (test_input/test3.py)...
+
+Warnings...
+
+UserDict.py:4: No doc string for class UserDict
+
+test_input/test3.py:7: No global (x) found
+test_input/test3.py:12: No doc string for class jj

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test3-2.5
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test3-2.5 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test3-2.5
new file mode 100644
index 0000000..d9d8f25
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test3-2.5
@@ -0,0 +1,8 @@
+Processing module test3 (test_input/test3.py)...
+
+Warnings...
+
+/home/neal/local/lib/python2.5/UserDict.py:4: No doc string for class UserDict
+
+test_input/test3.py:7: No global (x) found
+test_input/test3.py:12: No doc string for class jj

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test3-2.6
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test3-2.6 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test3-2.6
new file mode 100644
index 0000000..3b193d5
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test3-2.6
@@ -0,0 +1,8 @@
+Processing module test3 (test_input/test3.py)...
+
+Warnings...
+
+/home/neal/python/dev/trunk5/Lib/UserDict.py:4: No doc string for class UserDict
+
+test_input/test3.py:7: No global (x) found
+test_input/test3.py:12: No doc string for class jj

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test30
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test30 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test30
new file mode 100644
index 0000000..91d70b8
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test30
@@ -0,0 +1,5 @@
+Processing module test30 (test_input/test30.py)...
+
+Warnings...
+
+None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test31
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test31 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test31
new file mode 100644
index 0000000..c963ec0
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test31
@@ -0,0 +1,10 @@
+Processing module test31 (test_input/test31.py)...
+
+Warnings...
+
+test_input/test31.py:21: Instantiating an object with arguments, but no constructor
+test_input/test31.py:22: Instantiating an object with arguments, but no constructor
+test_input/test31.py:23: Instantiating an object with arguments, but no constructor
+test_input/test31.py:24: Instantiating an object with arguments, but no constructor
+test_input/test31.py:25: Function (__init__) doesn't support **kwArgs
+test_input/test31.py:26: Invalid arguments to (__init__), got 2, expected 1

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test32
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test32 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test32
new file mode 100644
index 0000000..17921fe
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test32
@@ -0,0 +1,6 @@
+Processing module test32 (test_input/test32.py)...
+
+Warnings...
+
+test_input/test32.py:10: self is not first method argument
+test_input/test32.py:15: Invalid arguments to (__init__), got 0, expected 1

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test33
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test33 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test33
new file mode 100644
index 0000000..de9440e
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test33
@@ -0,0 +1,5 @@
+Processing module test33 (test_input/test33.py)...
+
+Warnings...
+
+test_input/test33.py:4: Variable (j) used before being set

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test34
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test34 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test34
new file mode 100644
index 0000000..ac793a5
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test34
@@ -0,0 +1,14 @@
+Processing module test34 (test_input/test34.py)...
+
+Warnings...
+
+getopt.py:25: No doc string for class GetoptError
+
+test_input/test34.py:1: No doc string for class Error
+test_input/test34.py:6: Module member (string) re-imported with *
+test_input/test34.py:9: Using import and from ... import for (locale)
+test_input/test34.py:10: Using import and from ... import for (locale)
+test_input/test34.py:13: Using import and from ... import for (getopt)
+test_input/test34.py:16: Using import and from ... import for (copy)
+test_input/test34.py:19: Module member (from re import sub) re-imported
+test_input/test34.py:22: Module (ihooks) re-imported

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test34-2.2
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test34-2.2 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test34-2.2
new file mode 100644
index 0000000..e6e9bbc
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test34-2.2
@@ -0,0 +1,17 @@
+Processing module test34 (test_input/test34.py)...
+
+Warnings...
+
+/usr/lib/python2.2/locale.py:168: (str) shadows builtin
+/usr/lib/python2.2/locale.py:173: (str) shadows builtin
+
+/usr/src/build/228093-i386/install/usr/lib/python2.2/getopt.py:25: No doc string for class GetoptError
+
+test_input/test34.py:1: No doc string for class Error
+test_input/test34.py:6: Module member (string) re-imported with *
+test_input/test34.py:9: Using import and from ... import for (locale)
+test_input/test34.py:10: Using import and from ... import for (locale)
+test_input/test34.py:13: Using import and from ... import for (getopt)
+test_input/test34.py:16: Using import and from ... import for (copy)
+test_input/test34.py:19: Module member (from re import sub) re-imported
+test_input/test34.py:22: Module (ihooks) re-imported

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test34-2.3
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test34-2.3 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test34-2.3
new file mode 100644
index 0000000..4249257
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test34-2.3
@@ -0,0 +1,17 @@
+Processing module test34 (test_input/test34.py)...
+
+Warnings...
+
+/usr/lib/python2.3/getopt.py:42: No doc string for class GetoptError
+
+/usr/lib/python2.3/locale.py:168: (str) shadows builtin
+/usr/lib/python2.3/locale.py:173: (str) shadows builtin
+
+test_input/test34.py:1: No doc string for class Error
+test_input/test34.py:6: Module member (string) re-imported with *
+test_input/test34.py:9: Using import and from ... import for (locale)
+test_input/test34.py:10: Using import and from ... import for (locale)
+test_input/test34.py:13: Using import and from ... import for (getopt)
+test_input/test34.py:16: Using import and from ... import for (copy)
+test_input/test34.py:19: Module member (from re import sub) re-imported
+test_input/test34.py:22: Module (ihooks) re-imported

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test34-2.4
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test34-2.4 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test34-2.4
new file mode 100644
index 0000000..cdcf97d
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test34-2.4
@@ -0,0 +1,14 @@
+Processing module test34 (test_input/test34.py)...
+
+Warnings...
+
+getopt.py:42: No doc string for class GetoptError
+
+test_input/test34.py:1: No doc string for class Error
+test_input/test34.py:6: Module member (string) re-imported with *
+test_input/test34.py:9: Using import and from ... import for (locale)
+test_input/test34.py:10: Using import and from ... import for (locale)
+test_input/test34.py:13: Using import and from ... import for (getopt)
+test_input/test34.py:16: Using import and from ... import for (copy)
+test_input/test34.py:19: Module member (from re import sub) re-imported
+test_input/test34.py:22: Module (ihooks) re-imported

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test34-2.5
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test34-2.5 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test34-2.5
new file mode 100644
index 0000000..b99da64
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test34-2.5
@@ -0,0 +1,14 @@
+Processing module test34 (test_input/test34.py)...
+
+Warnings...
+
+/home/neal/local/lib/python2.5/getopt.py:42: No doc string for class GetoptError
+
+test_input/test34.py:1: No doc string for class Error
+test_input/test34.py:6: Module member (string) re-imported with *
+test_input/test34.py:9: Using import and from ... import for (locale)
+test_input/test34.py:10: Using import and from ... import for (locale)
+test_input/test34.py:13: Using import and from ... import for (getopt)
+test_input/test34.py:16: Using import and from ... import for (copy)
+test_input/test34.py:19: Module member (from re import sub) re-imported
+test_input/test34.py:22: Module (ihooks) re-imported

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test34-2.6
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test34-2.6 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test34-2.6
new file mode 100644
index 0000000..2c135fa
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test34-2.6
@@ -0,0 +1,14 @@
+Processing module test34 (test_input/test34.py)...
+
+Warnings...
+
+/home/neal/python/dev/trunk5/Lib/getopt.py:42: No doc string for class GetoptError
+
+test_input/test34.py:1: No doc string for class Error
+test_input/test34.py:6: Module member (string) re-imported with *
+test_input/test34.py:9: Using import and from ... import for (locale)
+test_input/test34.py:10: Using import and from ... import for (locale)
+test_input/test34.py:13: Using import and from ... import for (getopt)
+test_input/test34.py:16: Using import and from ... import for (copy)
+test_input/test34.py:19: Module member (from re import sub) re-imported
+test_input/test34.py:22: Module (ihooks) re-imported

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test35
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test35 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test35
new file mode 100644
index 0000000..9752b66
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test35
@@ -0,0 +1,6 @@
+Processing module test35 (test_input/test35.py)...
+
+Warnings...
+
+test_input/test35.py:9: No doc string for function x
+test_input/test35.py:11: No doc string for function y

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test36
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test36 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test36
new file mode 100644
index 0000000..eca67ce
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test36
@@ -0,0 +1,7 @@
+Processing module test36 (test_input/test36.py)...
+
+Warnings...
+
+test_input/test36.py:1: No doc string for class NoneType
+test_input/test36.py:31: Function (int) doesn't support **kwArgs for name (args)
+test_input/test36.py:36: [].append() only takes 1 argument in Python 1.6 and above for (n)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test37
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test37 b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test37
new file mode 100644
index 0000000..e4e31d8
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_expected/test37
@@ -0,0 +1,5 @@
+Processing module test37 (test_input/test37.py)...
+
+Warnings...
+
+None



[25/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code

Posted by rl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/simplejson/_speedups.c
----------------------------------------------------------------------
diff --git a/tools/bin/ext/simplejson/_speedups.c b/tools/bin/ext/simplejson/_speedups.c
new file mode 100644
index 0000000..e4cc18f
--- /dev/null
+++ b/tools/bin/ext/simplejson/_speedups.c
@@ -0,0 +1,234 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "Python.h"
+#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
+typedef int Py_ssize_t;
+#define PY_SSIZE_T_MAX INT_MAX
+#define PY_SSIZE_T_MIN INT_MIN
+#endif
+
+static Py_ssize_t
+ascii_escape_char(Py_UNICODE c, char *output, Py_ssize_t chars);
+static PyObject *
+ascii_escape_unicode(PyObject *pystr);
+static PyObject *
+ascii_escape_str(PyObject *pystr);
+static PyObject *
+py_encode_basestring_ascii(PyObject* self __attribute__((__unused__)), PyObject *pystr);
+void init_speedups(void);
+
+#define S_CHAR(c) (c >= ' ' && c <= '~' && c != '\\' && c != '/' && c != '"')
+
+#define MIN_EXPANSION 6
+#ifdef Py_UNICODE_WIDE
+#define MAX_EXPANSION (2 * MIN_EXPANSION)
+#else
+#define MAX_EXPANSION MIN_EXPANSION
+#endif
+
+static Py_ssize_t
+ascii_escape_char(Py_UNICODE c, char *output, Py_ssize_t chars) {
+    Py_UNICODE x;
+    output[chars++] = '\\';
+    switch (c) {
+        case '/': output[chars++] = (char)c; break;
+        case '\\': output[chars++] = (char)c; break;
+        case '"': output[chars++] = (char)c; break;
+        case '\b': output[chars++] = 'b'; break;
+        case '\f': output[chars++] = 'f'; break;
+        case '\n': output[chars++] = 'n'; break;
+        case '\r': output[chars++] = 'r'; break;
+        case '\t': output[chars++] = 't'; break;
+        default:
+#ifdef Py_UNICODE_WIDE
+            if (c >= 0x10000) {
+                /* UTF-16 surrogate pair */
+                Py_UNICODE v = c - 0x10000;
+                c = 0xd800 | ((v >> 10) & 0x3ff);
+                output[chars++] = 'u';
+                x = (c & 0xf000) >> 12;
+                output[chars++] = (x < 10) ? '0' + x : 'a' + (x - 10);
+                x = (c & 0x0f00) >> 8;
+                output[chars++] = (x < 10) ? '0' + x : 'a' + (x - 10);
+                x = (c & 0x00f0) >> 4;
+                output[chars++] = (x < 10) ? '0' + x : 'a' + (x - 10);
+                x = (c & 0x000f);
+                output[chars++] = (x < 10) ? '0' + x : 'a' + (x - 10);
+                c = 0xdc00 | (v & 0x3ff);
+                output[chars++] = '\\';
+            }
+#endif
+            output[chars++] = 'u';
+            x = (c & 0xf000) >> 12;
+            output[chars++] = (x < 10) ? '0' + x : 'a' + (x - 10);
+            x = (c & 0x0f00) >> 8;
+            output[chars++] = (x < 10) ? '0' + x : 'a' + (x - 10);
+            x = (c & 0x00f0) >> 4;
+            output[chars++] = (x < 10) ? '0' + x : 'a' + (x - 10);
+            x = (c & 0x000f);
+            output[chars++] = (x < 10) ? '0' + x : 'a' + (x - 10);
+    }
+    return chars;
+}
+
+static PyObject *
+ascii_escape_unicode(PyObject *pystr) {
+    Py_ssize_t i;
+    Py_ssize_t input_chars;
+    Py_ssize_t output_size;
+    Py_ssize_t chars;
+    PyObject *rval;
+    char *output;
+    Py_UNICODE *input_unicode;
+
+    input_chars = PyUnicode_GET_SIZE(pystr);
+    input_unicode = PyUnicode_AS_UNICODE(pystr);
+    /* One char input can be up to 6 chars output, estimate 4 of these */
+    output_size = 2 + (MIN_EXPANSION * 4) + input_chars;
+    rval = PyString_FromStringAndSize(NULL, output_size);
+    if (rval == NULL) {
+        return NULL;
+    }
+    output = PyString_AS_STRING(rval);
+    chars = 0;
+    output[chars++] = '"';
+    for (i = 0; i < input_chars; i++) {
+        Py_UNICODE c = input_unicode[i];
+        if (S_CHAR(c)) {
+            output[chars++] = (char)c;
+        } else {
+            chars = ascii_escape_char(c, output, chars);
+        }
+        if (output_size - chars < (1 + MAX_EXPANSION)) {
+            /* There's more than four, so let's resize by a lot */
+            output_size *= 2;
+            /* This is an upper bound */
+            if (output_size > 2 + (input_chars * MAX_EXPANSION)) {
+                output_size = 2 + (input_chars * MAX_EXPANSION);
+            }
+            if (_PyString_Resize(&rval, output_size) == -1) {
+                return NULL;
+            }
+            output = PyString_AS_STRING(rval);
+        }
+    }
+    output[chars++] = '"';
+    if (_PyString_Resize(&rval, chars) == -1) {
+        return NULL;
+    }
+    return rval;
+}
+
+static PyObject *
+ascii_escape_str(PyObject *pystr) {
+    Py_ssize_t i;
+    Py_ssize_t input_chars;
+    Py_ssize_t output_size;
+    Py_ssize_t chars;
+    PyObject *rval;
+    char *output;
+    char *input_str;
+
+    input_chars = PyString_GET_SIZE(pystr);
+    input_str = PyString_AS_STRING(pystr);
+    /* One char input can be up to 6 chars output, estimate 4 of these */
+    output_size = 2 + (MIN_EXPANSION * 4) + input_chars;
+    rval = PyString_FromStringAndSize(NULL, output_size);
+    if (rval == NULL) {
+        return NULL;
+    }
+    output = PyString_AS_STRING(rval);
+    chars = 0;
+    output[chars++] = '"';
+    for (i = 0; i < input_chars; i++) {
+        Py_UNICODE c = (Py_UNICODE)input_str[i];
+        if (S_CHAR(c)) {
+            output[chars++] = (char)c;
+        } else if (c > 0x7F) {
+            /* We hit a non-ASCII character, bail to unicode mode */
+            PyObject *uni;
+            Py_DECREF(rval);
+            uni = PyUnicode_DecodeUTF8(input_str, input_chars, "strict");
+            if (uni == NULL) {
+                return NULL;
+            }
+            rval = ascii_escape_unicode(uni);
+            Py_DECREF(uni);
+            return rval;
+        } else {
+            chars = ascii_escape_char(c, output, chars);
+        }
+        /* An ASCII char can't possibly expand to a surrogate! */
+        if (output_size - chars < (1 + MIN_EXPANSION)) {
+            /* There's more than four, so let's resize by a lot */
+            output_size *= 2;
+            if (output_size > 2 + (input_chars * MIN_EXPANSION)) {
+                output_size = 2 + (input_chars * MIN_EXPANSION);
+            }
+            if (_PyString_Resize(&rval, output_size) == -1) {
+                return NULL;
+            }
+            output = PyString_AS_STRING(rval);
+        }
+    }
+    output[chars++] = '"';
+    if (_PyString_Resize(&rval, chars) == -1) {
+        return NULL;
+    }
+    return rval;
+}
+
+PyDoc_STRVAR(pydoc_encode_basestring_ascii,
+    "encode_basestring_ascii(basestring) -> str\n"
+    "\n"
+    "..."
+);
+
+static PyObject *
+py_encode_basestring_ascii(PyObject* self __attribute__((__unused__)), PyObject *pystr) {
+    /* METH_O */
+    if (PyString_Check(pystr)) {
+        return ascii_escape_str(pystr);
+    } else if (PyUnicode_Check(pystr)) {
+        return ascii_escape_unicode(pystr);
+    }
+    PyErr_SetString(PyExc_TypeError, "first argument must be a string");
+    return NULL;
+}
+
+#define DEFN(n, k) \
+    {  \
+        #n, \
+        (PyCFunction)py_ ##n, \
+        k, \
+        pydoc_ ##n \
+    }
+static PyMethodDef speedups_methods[] = {
+    DEFN(encode_basestring_ascii, METH_O),
+    {}
+};
+#undef DEFN
+
+void
+init_speedups(void)
+{
+    PyObject *m;
+    m = Py_InitModule4("_speedups", speedups_methods, NULL, NULL, PYTHON_API_VERSION);
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/simplejson/decoder.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/simplejson/decoder.py b/tools/bin/ext/simplejson/decoder.py
new file mode 100755
index 0000000..5182216
--- /dev/null
+++ b/tools/bin/ext/simplejson/decoder.py
@@ -0,0 +1,289 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""
+Implementation of JSONDecoder
+"""
+import re
+
+from simplejson.scanner import Scanner, pattern
+
+FLAGS = re.VERBOSE | re.MULTILINE | re.DOTALL
+
+def _floatconstants():
+    import struct
+    import sys
+    _BYTES = '7FF80000000000007FF0000000000000'.decode('hex')
+    if sys.byteorder != 'big':
+        _BYTES = _BYTES[:8][::-1] + _BYTES[8:][::-1]
+    nan, inf = struct.unpack('dd', _BYTES)
+    return nan, inf, -inf
+
+NaN, PosInf, NegInf = _floatconstants()
+
+def linecol(doc, pos):
+    lineno = doc.count('\n', 0, pos) + 1
+    if lineno == 1:
+        colno = pos
+    else:
+        colno = pos - doc.rindex('\n', 0, pos)
+    return lineno, colno
+
+def errmsg(msg, doc, pos, end=None):
+    lineno, colno = linecol(doc, pos)
+    if end is None:
+        return '%s: line %d column %d (char %d)' % (msg, lineno, colno, pos)
+    endlineno, endcolno = linecol(doc, end)
+    return '%s: line %d column %d - line %d column %d (char %d - %d)' % (
+        msg, lineno, colno, endlineno, endcolno, pos, end)
+
+_CONSTANTS = {
+    '-Infinity': NegInf,
+    'Infinity': PosInf,
+    'NaN': NaN,
+    'true': True,
+    'false': False,
+    'null': None,
+}
+
+def JSONConstant(match, context, c=_CONSTANTS):
+    return c[match.group(0)], None
+pattern('(-?Infinity|NaN|true|false|null)')(JSONConstant)
+
+def JSONNumber(match, context):
+    match = JSONNumber.regex.match(match.string, *match.span())
+    integer, frac, exp = match.groups()
+    if frac or exp:
+        res = float(integer + (frac or '') + (exp or ''))
+    else:
+        res = int(integer)
+    return res, None
+pattern(r'(-?(?:0|[1-9]\d*))(\.\d+)?([eE][-+]?\d+)?')(JSONNumber)
+
+STRINGCHUNK = re.compile(r'(.*?)(["\\])', FLAGS)
+BACKSLASH = {
+    '"': u'"', '\\': u'\\', '/': u'/',
+    'b': u'\b', 'f': u'\f', 'n': u'\n', 'r': u'\r', 't': u'\t',
+}
+
+DEFAULT_ENCODING = "utf-8"
+
+def scanstring(s, end, encoding=None, _b=BACKSLASH, _m=STRINGCHUNK.match):
+    if encoding is None:
+        encoding = DEFAULT_ENCODING
+    chunks = []
+    _append = chunks.append
+    begin = end - 1
+    while 1:
+        chunk = _m(s, end)
+        if chunk is None:
+            raise ValueError(
+                errmsg("Unterminated string starting at", s, begin))
+        end = chunk.end()
+        content, terminator = chunk.groups()
+        if content:
+            if not isinstance(content, unicode):
+                content = unicode(content, encoding)
+            _append(content)
+        if terminator == '"':
+            break
+        try:
+            esc = s[end]
+        except IndexError:
+            raise ValueError(
+                errmsg("Unterminated string starting at", s, begin))
+        if esc != 'u':
+            try:
+                m = _b[esc]
+            except KeyError:
+                raise ValueError(
+                    errmsg("Invalid \\escape: %r" % (esc,), s, end))
+            end += 1
+        else:
+            esc = s[end + 1:end + 5]
+            try:
+                m = unichr(int(esc, 16))
+                if len(esc) != 4 or not esc.isalnum():
+                    raise ValueError
+            except ValueError:
+                raise ValueError(errmsg("Invalid \\uXXXX escape", s, end))
+            end += 5
+        _append(m)
+    return u''.join(chunks), end
+
+def JSONString(match, context):
+    encoding = getattr(context, 'encoding', None)
+    return scanstring(match.string, match.end(), encoding)
+pattern(r'"')(JSONString)
+
+WHITESPACE = re.compile(r'\s*', FLAGS)
+
+def JSONObject(match, context, _w=WHITESPACE.match):
+    pairs = {}
+    s = match.string
+    end = _w(s, match.end()).end()
+    nextchar = s[end:end + 1]
+    # trivial empty object
+    if nextchar == '}':
+        return pairs, end + 1
+    if nextchar != '"':
+        raise ValueError(errmsg("Expecting property name", s, end))
+    end += 1
+    encoding = getattr(context, 'encoding', None)
+    iterscan = JSONScanner.iterscan
+    while True:
+        key, end = scanstring(s, end, encoding)
+        end = _w(s, end).end()
+        if s[end:end + 1] != ':':
+            raise ValueError(errmsg("Expecting : delimiter", s, end))
+        end = _w(s, end + 1).end()
+        try:
+            value, end = iterscan(s, idx=end, context=context).next()
+        except StopIteration:
+            raise ValueError(errmsg("Expecting object", s, end))
+        pairs[key] = value
+        end = _w(s, end).end()
+        nextchar = s[end:end + 1]
+        end += 1
+        if nextchar == '}':
+            break
+        if nextchar != ',':
+            raise ValueError(errmsg("Expecting , delimiter", s, end - 1))
+        end = _w(s, end).end()
+        nextchar = s[end:end + 1]
+        end += 1
+        if nextchar != '"':
+            raise ValueError(errmsg("Expecting property name", s, end - 1))
+    object_hook = getattr(context, 'object_hook', None)
+    if object_hook is not None:
+        pairs = object_hook(pairs)
+    return pairs, end
+pattern(r'{')(JSONObject)
+            
+def JSONArray(match, context, _w=WHITESPACE.match):
+    values = []
+    s = match.string
+    end = _w(s, match.end()).end()
+    # look-ahead for trivial empty array
+    nextchar = s[end:end + 1]
+    if nextchar == ']':
+        return values, end + 1
+    iterscan = JSONScanner.iterscan
+    while True:
+        try:
+            value, end = iterscan(s, idx=end, context=context).next()
+        except StopIteration:
+            raise ValueError(errmsg("Expecting object", s, end))
+        values.append(value)
+        end = _w(s, end).end()
+        nextchar = s[end:end + 1]
+        end += 1
+        if nextchar == ']':
+            break
+        if nextchar != ',':
+            raise ValueError(errmsg("Expecting , delimiter", s, end))
+        end = _w(s, end).end()
+    return values, end
+pattern(r'\[')(JSONArray)
+ 
+ANYTHING = [
+    JSONObject,
+    JSONArray,
+    JSONString,
+    JSONConstant,
+    JSONNumber,
+]
+
+JSONScanner = Scanner(ANYTHING)
+
+class JSONDecoder(object):
+    """
+    Simple JSON <http://json.org> decoder
+
+    Performs the following translations in decoding:
+    
+    +---------------+-------------------+
+    | JSON          | Python            |
+    +===============+===================+
+    | object        | dict              |
+    +---------------+-------------------+
+    | array         | list              |
+    +---------------+-------------------+
+    | string        | unicode           |
+    +---------------+-------------------+
+    | number (int)  | int, long         |
+    +---------------+-------------------+
+    | number (real) | float             |
+    +---------------+-------------------+
+    | true          | True              |
+    +---------------+-------------------+
+    | false         | False             |
+    +---------------+-------------------+
+    | null          | None              |
+    +---------------+-------------------+
+
+    It also understands ``NaN``, ``Infinity``, and ``-Infinity`` as
+    their corresponding ``float`` values, which is outside the JSON spec.
+    """
+
+    _scanner = Scanner(ANYTHING)
+    __all__ = ['__init__', 'decode', 'raw_decode']
+
+    def __init__(self, encoding=None, object_hook=None):
+        """
+        ``encoding`` determines the encoding used to interpret any ``str``
+        objects decoded by this instance (utf-8 by default).  It has no
+        effect when decoding ``unicode`` objects.
+        
+        Note that currently only encodings that are a superset of ASCII work,
+        strings of other encodings should be passed in as ``unicode``.
+
+        ``object_hook``, if specified, will be called with the result
+        of every JSON object decoded and its return value will be used in
+        place of the given ``dict``.  This can be used to provide custom
+        deserializations (e.g. to support JSON-RPC class hinting).
+        """
+        self.encoding = encoding
+        self.object_hook = object_hook
+
+    def decode(self, s, _w=WHITESPACE.match):
+        """
+        Return the Python representation of ``s`` (a ``str`` or ``unicode``
+        instance containing a JSON document)
+        """
+        obj, end = self.raw_decode(s, idx=_w(s, 0).end())
+        end = _w(s, end).end()
+        if end != len(s):
+            raise ValueError(errmsg("Extra data", s, end, len(s)))
+        return obj
+
+    def raw_decode(self, s, **kw):
+        """
+        Decode a JSON document from ``s`` (a ``str`` or ``unicode`` beginning
+        with a JSON document) and return a 2-tuple of the Python
+        representation and the index in ``s`` where the document ended.
+
+        This can be used to decode a JSON document from a string that may
+        have extraneous data at the end.
+        """
+        kw.setdefault('context', self)
+        try:
+            obj, end = self._scanner.iterscan(s, **kw).next()
+        except StopIteration:
+            raise ValueError("No JSON object could be decoded")
+        return obj, end
+
+__all__ = ['JSONDecoder']

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/simplejson/encoder.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/simplejson/encoder.py b/tools/bin/ext/simplejson/encoder.py
new file mode 100755
index 0000000..4bf1746
--- /dev/null
+++ b/tools/bin/ext/simplejson/encoder.py
@@ -0,0 +1,387 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""
+Implementation of JSONEncoder
+"""
+import re
+try:
+    from simplejson import _speedups
+except ImportError:
+    _speedups = None
+
+ESCAPE = re.compile(r'[\x00-\x19\\"\b\f\n\r\t]')
+ESCAPE_ASCII = re.compile(r'([\\"/]|[^\ -~])')
+ESCAPE_DCT = {
+    # escape all forward slashes to prevent </script> attack
+    '/': '\\/',
+    '\\': '\\\\',
+    '"': '\\"',
+    '\b': '\\b',
+    '\f': '\\f',
+    '\n': '\\n',
+    '\r': '\\r',
+    '\t': '\\t',
+}
+for i in range(0x20):
+    ESCAPE_DCT.setdefault(chr(i), '\\u%04x' % (i,))
+
+# assume this produces an infinity on all machines (probably not guaranteed)
+INFINITY = float('1e66666')
+
+def floatstr(o, allow_nan=True):
+    # Check for specials.  Note that this type of test is processor- and/or
+    # platform-specific, so do tests which don't depend on the internals.
+
+    if o != o:
+        text = 'NaN'
+    elif o == INFINITY:
+        text = 'Infinity'
+    elif o == -INFINITY:
+        text = '-Infinity'
+    else:
+        return repr(o)
+
+    if not allow_nan:
+        raise ValueError("Out of range float values are not JSON compliant: %r"
+            % (o,))
+
+    return text
+
+
+def encode_basestring(s):
+    """
+    Return a JSON representation of a Python string
+    """
+    def replace(match):
+        return ESCAPE_DCT[match.group(0)]
+    return '"' + ESCAPE.sub(replace, s) + '"'
+
+def encode_basestring_ascii(s):
+    def replace(match):
+        s = match.group(0)
+        try:
+            return ESCAPE_DCT[s]
+        except KeyError:
+            n = ord(s)
+            if n < 0x10000:
+                return '\\u%04x' % (n,)
+            else:
+                # surrogate pair
+                n -= 0x10000
+                s1 = 0xd800 | ((n >> 10) & 0x3ff)
+                s2 = 0xdc00 | (n & 0x3ff)
+                return '\\u%04x\\u%04x' % (s1, s2)
+    return '"' + str(ESCAPE_ASCII.sub(replace, s)) + '"'
+        
+try:
+    encode_basestring_ascii = _speedups.encode_basestring_ascii
+    _need_utf8 = True
+except AttributeError:
+    _need_utf8 = False
+
+class JSONEncoder(object):
+    """
+    Extensible JSON <http://json.org> encoder for Python data structures.
+
+    Supports the following objects and types by default:
+    
+    +-------------------+---------------+
+    | Python            | JSON          |
+    +===================+===============+
+    | dict              | object        |
+    +-------------------+---------------+
+    | list, tuple       | array         |
+    +-------------------+---------------+
+    | str, unicode      | string        |
+    +-------------------+---------------+
+    | int, long, float  | number        |
+    +-------------------+---------------+
+    | True              | true          |
+    +-------------------+---------------+
+    | False             | false         |
+    +-------------------+---------------+
+    | None              | null          |
+    +-------------------+---------------+
+
+    To extend this to recognize other objects, subclass and implement a
+    ``.default()`` method with another method that returns a serializable
+    object for ``o`` if possible, otherwise it should call the superclass
+    implementation (to raise ``TypeError``).
+    """
+    __all__ = ['__init__', 'default', 'encode', 'iterencode']
+    item_separator = ', '
+    key_separator = ': '
+    def __init__(self, skipkeys=False, ensure_ascii=True,
+            check_circular=True, allow_nan=True, sort_keys=False,
+            indent=None, separators=None, encoding='utf-8'):
+        """
+        Constructor for JSONEncoder, with sensible defaults.
+
+        If skipkeys is False, then it is a TypeError to attempt
+        encoding of keys that are not str, int, long, float or None.  If
+        skipkeys is True, such items are simply skipped.
+
+        If ensure_ascii is True, the output is guaranteed to be str
+        objects with all incoming unicode characters escaped.  If
+        ensure_ascii is false, the output will be unicode object.
+
+        If check_circular is True, then lists, dicts, and custom encoded
+        objects will be checked for circular references during encoding to
+        prevent an infinite recursion (which would cause an OverflowError).
+        Otherwise, no such check takes place.
+
+        If allow_nan is True, then NaN, Infinity, and -Infinity will be
+        encoded as such.  This behavior is not JSON specification compliant,
+        but is consistent with most JavaScript based encoders and decoders.
+        Otherwise, it will be a ValueError to encode such floats.
+
+        If sort_keys is True, then the output of dictionaries will be
+        sorted by key; this is useful for regression tests to ensure
+        that JSON serializations can be compared on a day-to-day basis.
+
+        If indent is a non-negative integer, then JSON array
+        elements and object members will be pretty-printed with that
+        indent level.  An indent level of 0 will only insert newlines.
+        None is the most compact representation.
+
+        If specified, separators should be a (item_separator, key_separator)
+        tuple. The default is (', ', ': '). To get the most compact JSON
+        representation you should specify (',', ':') to eliminate whitespace.
+
+        If encoding is not None, then all input strings will be
+        transformed into unicode using that encoding prior to JSON-encoding. 
+        The default is UTF-8.
+        """
+
+        self.skipkeys = skipkeys
+        self.ensure_ascii = ensure_ascii
+        self.check_circular = check_circular
+        self.allow_nan = allow_nan
+        self.sort_keys = sort_keys
+        self.indent = indent
+        self.current_indent_level = 0
+        if separators is not None:
+            self.item_separator, self.key_separator = separators
+        self.encoding = encoding
+
+    def _newline_indent(self):
+        return '\n' + (' ' * (self.indent * self.current_indent_level))
+
+    def _iterencode_list(self, lst, markers=None):
+        if not lst:
+            yield '[]'
+            return
+        if markers is not None:
+            markerid = id(lst)
+            if markerid in markers:
+                raise ValueError("Circular reference detected")
+            markers[markerid] = lst
+        yield '['
+        if self.indent is not None:
+            self.current_indent_level += 1
+            newline_indent = self._newline_indent()
+            separator = self.item_separator + newline_indent
+            yield newline_indent
+        else:
+            newline_indent = None
+            separator = self.item_separator
+        first = True
+        for value in lst:
+            if first:
+                first = False
+            else:
+                yield separator
+            for chunk in self._iterencode(value, markers):
+                yield chunk
+        if newline_indent is not None:
+            self.current_indent_level -= 1
+            yield self._newline_indent()
+        yield ']'
+        if markers is not None:
+            del markers[markerid]
+
+    def _iterencode_dict(self, dct, markers=None):
+        if not dct:
+            yield '{}'
+            return
+        if markers is not None:
+            markerid = id(dct)
+            if markerid in markers:
+                raise ValueError("Circular reference detected")
+            markers[markerid] = dct
+        yield '{'
+        key_separator = self.key_separator
+        if self.indent is not None:
+            self.current_indent_level += 1
+            newline_indent = self._newline_indent()
+            item_separator = self.item_separator + newline_indent
+            yield newline_indent
+        else:
+            newline_indent = None
+            item_separator = self.item_separator
+        first = True
+        if self.ensure_ascii:
+            encoder = encode_basestring_ascii
+        else:
+            encoder = encode_basestring
+        allow_nan = self.allow_nan
+        if self.sort_keys:
+            keys = dct.keys()
+            keys.sort()
+            items = [(k, dct[k]) for k in keys]
+        else:
+            items = dct.iteritems()
+        _encoding = self.encoding
+        _do_decode = (_encoding is not None
+            and not (_need_utf8 and _encoding == 'utf-8'))
+        for key, value in items:
+            if isinstance(key, str):
+                if _do_decode:
+                    key = key.decode(_encoding)
+            elif isinstance(key, basestring):
+                pass
+            # JavaScript is weakly typed for these, so it makes sense to
+            # also allow them.  Many encoders seem to do something like this.
+            elif isinstance(key, float):
+                key = floatstr(key, allow_nan)
+            elif isinstance(key, (int, long)):
+                key = str(key)
+            elif key is True:
+                key = 'true'
+            elif key is False:
+                key = 'false'
+            elif key is None:
+                key = 'null'
+            elif self.skipkeys:
+                continue
+            else:
+                raise TypeError("key %r is not a string" % (key,))
+            if first:
+                first = False
+            else:
+                yield item_separator
+            yield encoder(key)
+            yield key_separator
+            for chunk in self._iterencode(value, markers):
+                yield chunk
+        if newline_indent is not None:
+            self.current_indent_level -= 1
+            yield self._newline_indent()
+        yield '}'
+        if markers is not None:
+            del markers[markerid]
+
+    def _iterencode(self, o, markers=None):
+        if isinstance(o, basestring):
+            if self.ensure_ascii:
+                encoder = encode_basestring_ascii
+            else:
+                encoder = encode_basestring
+            _encoding = self.encoding
+            if (_encoding is not None and isinstance(o, str)
+                    and not (_need_utf8 and _encoding == 'utf-8')):
+                o = o.decode(_encoding)
+            yield encoder(o)
+        elif o is None:
+            yield 'null'
+        elif o is True:
+            yield 'true'
+        elif o is False:
+            yield 'false'
+        elif isinstance(o, (int, long)):
+            yield str(o)
+        elif isinstance(o, float):
+            yield floatstr(o, self.allow_nan)
+        elif isinstance(o, (list, tuple)):
+            for chunk in self._iterencode_list(o, markers):
+                yield chunk
+        elif isinstance(o, dict):
+            for chunk in self._iterencode_dict(o, markers):
+                yield chunk
+        else:
+            if markers is not None:
+                markerid = id(o)
+                if markerid in markers:
+                    raise ValueError("Circular reference detected")
+                markers[markerid] = o
+            for chunk in self._iterencode_default(o, markers):
+                yield chunk
+            if markers is not None:
+                del markers[markerid]
+
+    def _iterencode_default(self, o, markers=None):
+        newobj = self.default(o)
+        return self._iterencode(newobj, markers)
+
+    def default(self, o):
+        """
+        Implement this method in a subclass such that it returns
+        a serializable object for ``o``, or calls the base implementation
+        (to raise a ``TypeError``).
+
+        For example, to support arbitrary iterators, you could
+        implement default like this::
+            
+            def default(self, o):
+                try:
+                    iterable = iter(o)
+                except TypeError:
+                    pass
+                else:
+                    return list(iterable)
+                return JSONEncoder.default(self, o)
+        """
+        raise TypeError("%r is not JSON serializable" % (o,))
+
+    def encode(self, o):
+        """
+        Return a JSON string representation of a Python data structure.
+
+        >>> JSONEncoder().encode({"foo": ["bar", "baz"]})
+        '{"foo":["bar", "baz"]}'
+        """
+        # This is for extremely simple cases and benchmarks...
+        if isinstance(o, basestring):
+            if isinstance(o, str):
+                _encoding = self.encoding
+                if (_encoding is not None 
+                        and not (_encoding == 'utf-8' and _need_utf8)):
+                    o = o.decode(_encoding)
+            return encode_basestring_ascii(o)
+        # This doesn't pass the iterator directly to ''.join() because it
+        # sucks at reporting exceptions.  It's going to do this internally
+        # anyway because it uses PySequence_Fast or similar.
+        chunks = list(self.iterencode(o))
+        return ''.join(chunks)
+
+    def iterencode(self, o):
+        """
+        Encode the given object and yield each string
+        representation as available.
+        
+        For example::
+            
+            for chunk in JSONEncoder().iterencode(bigobject):
+                mysocket.write(chunk)
+        """
+        if self.check_circular:
+            markers = {}
+        else:
+            markers = None
+        return self._iterencode(o, markers)
+
+__all__ = ['JSONEncoder']

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/simplejson/jsonfilter.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/simplejson/jsonfilter.py b/tools/bin/ext/simplejson/jsonfilter.py
new file mode 100755
index 0000000..074b481
--- /dev/null
+++ b/tools/bin/ext/simplejson/jsonfilter.py
@@ -0,0 +1,56 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+import simplejson
+import cgi
+
+class JSONFilter(object):
+    def __init__(self, app, mime_type='text/x-json'):
+        self.app = app
+        self.mime_type = mime_type
+
+    def __call__(self, environ, start_response):
+        # Read JSON POST input to jsonfilter.json if matching mime type
+        response = {'status': '200 OK', 'headers': []}
+        def json_start_response(status, headers):
+            response['status'] = status
+            response['headers'].extend(headers)
+        environ['jsonfilter.mime_type'] = self.mime_type
+        if environ.get('REQUEST_METHOD', '') == 'POST':
+            if environ.get('CONTENT_TYPE', '') == self.mime_type:
+                args = [_ for _ in [environ.get('CONTENT_LENGTH')] if _]
+                data = environ['wsgi.input'].read(*map(int, args))
+                environ['jsonfilter.json'] = simplejson.loads(data)
+        res = simplejson.dumps(self.app(environ, json_start_response))
+        jsonp = cgi.parse_qs(environ.get('QUERY_STRING', '')).get('jsonp')
+        if jsonp:
+            content_type = 'text/javascript'
+            res = ''.join(jsonp + ['(', res, ')'])
+        elif 'Opera' in environ.get('HTTP_USER_AGENT', ''):
+            # Opera has bunk XMLHttpRequest support for most mime types
+            content_type = 'text/plain'
+        else:
+            content_type = self.mime_type
+        headers = [
+            ('Content-type', content_type),
+            ('Content-length', len(res)),
+        ]
+        headers.extend(response['headers'])
+        start_response(response['status'], headers)
+        return [res]
+
+def factory(app, global_conf, **kw):
+    return JSONFilter(app, **kw)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/simplejson/scanner.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/simplejson/scanner.py b/tools/bin/ext/simplejson/scanner.py
new file mode 100755
index 0000000..5fe4f41
--- /dev/null
+++ b/tools/bin/ext/simplejson/scanner.py
@@ -0,0 +1,79 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""
+Iterator based sre token scanner
+"""
+import sre_parse, sre_compile, sre_constants
+from sre_constants import BRANCH, SUBPATTERN
+from re import VERBOSE, MULTILINE, DOTALL
+import re
+
+__all__ = ['Scanner', 'pattern']
+
+FLAGS = (VERBOSE | MULTILINE | DOTALL)
+class Scanner(object):
+    def __init__(self, lexicon, flags=FLAGS):
+        self.actions = [None]
+        # combine phrases into a compound pattern
+        s = sre_parse.Pattern()
+        s.flags = flags
+        p = []
+        for idx, token in enumerate(lexicon):
+            phrase = token.pattern
+            try:
+                subpattern = sre_parse.SubPattern(s,
+                    [(SUBPATTERN, (idx + 1, sre_parse.parse(phrase, flags)))])
+            except sre_constants.error:
+                raise
+            p.append(subpattern)
+            self.actions.append(token)
+
+        p = sre_parse.SubPattern(s, [(BRANCH, (None, p))])
+        self.scanner = sre_compile.compile(p)
+
+
+    def iterscan(self, string, idx=0, context=None):
+        """
+        Yield match, end_idx for each match
+        """
+        match = self.scanner.scanner(string, idx).match
+        actions = self.actions
+        lastend = idx
+        end = len(string)
+        while True:
+            m = match()
+            if m is None:
+                break
+            matchbegin, matchend = m.span()
+            if lastend == matchend:
+                break
+            action = actions[m.lastindex]
+            if action is not None:
+                rval, next_pos = action(m, context)
+                if next_pos is not None and next_pos != matchend:
+                    # "fast forward" the scanner
+                    matchend = next_pos
+                    match = self.scanner.scanner(string, matchend).match
+                yield rval, matchend
+            lastend = matchend
+            
+def pattern(pattern, flags=FLAGS):
+    def decorator(fn):
+        fn.pattern = pattern
+        fn.regex = re.compile(pattern, flags)
+        return fn
+    return decorator

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/simplejson/tests/__init__.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/simplejson/tests/__init__.py b/tools/bin/ext/simplejson/tests/__init__.py
new file mode 100755
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/simplejson/tests/test_attacks.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/simplejson/tests/test_attacks.py b/tools/bin/ext/simplejson/tests/test_attacks.py
new file mode 100755
index 0000000..f7bafdd
--- /dev/null
+++ b/tools/bin/ext/simplejson/tests/test_attacks.py
@@ -0,0 +1,22 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+def test_script_close_attack():
+    import simplejson
+    res = simplejson.dumps('</script>')
+    assert '</script>' not in res
+    res = simplejson.dumps(simplejson.loads('"</script>"'))
+    assert '</script>' not in res

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/simplejson/tests/test_dump.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/simplejson/tests/test_dump.py b/tools/bin/ext/simplejson/tests/test_dump.py
new file mode 100755
index 0000000..0e4ebfb
--- /dev/null
+++ b/tools/bin/ext/simplejson/tests/test_dump.py
@@ -0,0 +1,26 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from cStringIO import StringIO
+import simplejson as S
+
+def test_dump():
+    sio = StringIO()
+    S.dump({}, sio)
+    assert sio.getvalue() == '{}'
+    
+def test_dumps():
+    assert S.dumps({}) == '{}'

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/simplejson/tests/test_fail.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/simplejson/tests/test_fail.py b/tools/bin/ext/simplejson/tests/test_fail.py
new file mode 100755
index 0000000..7f78720
--- /dev/null
+++ b/tools/bin/ext/simplejson/tests/test_fail.py
@@ -0,0 +1,86 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# Fri Dec 30 18:57:26 2005
+JSONDOCS = [
+    # http://json.org/JSON_checker/test/fail1.json
+    '"A JSON payload should be an object or array, not a string."',
+    # http://json.org/JSON_checker/test/fail2.json
+    '["Unclosed array"',
+    # http://json.org/JSON_checker/test/fail3.json
+    '{unquoted_key: "keys must be quoted}',
+    # http://json.org/JSON_checker/test/fail4.json
+    '["extra comma",]',
+    # http://json.org/JSON_checker/test/fail5.json
+    '["double extra comma",,]',
+    # http://json.org/JSON_checker/test/fail6.json
+    '[   , "<-- missing value"]',
+    # http://json.org/JSON_checker/test/fail7.json
+    '["Comma after the close"],',
+    # http://json.org/JSON_checker/test/fail8.json
+    '["Extra close"]]',
+    # http://json.org/JSON_checker/test/fail9.json
+    '{"Extra comma": true,}',
+    # http://json.org/JSON_checker/test/fail10.json
+    '{"Extra value after close": true} "misplaced quoted value"',
+    # http://json.org/JSON_checker/test/fail11.json
+    '{"Illegal expression": 1 + 2}',
+    # http://json.org/JSON_checker/test/fail12.json
+    '{"Illegal invocation": alert()}',
+    # http://json.org/JSON_checker/test/fail13.json
+    '{"Numbers cannot have leading zeroes": 013}',
+    # http://json.org/JSON_checker/test/fail14.json
+    '{"Numbers cannot be hex": 0x14}',
+    # http://json.org/JSON_checker/test/fail15.json
+    '["Illegal backslash escape: \\x15"]',
+    # http://json.org/JSON_checker/test/fail16.json
+    '["Illegal backslash escape: \\\'"]',
+    # http://json.org/JSON_checker/test/fail17.json
+    '["Illegal backslash escape: \\017"]',
+    # http://json.org/JSON_checker/test/fail18.json
+    '[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]',
+    # http://json.org/JSON_checker/test/fail19.json
+    '{"Missing colon" null}',
+    # http://json.org/JSON_checker/test/fail20.json
+    '{"Double colon":: null}',
+    # http://json.org/JSON_checker/test/fail21.json
+    '{"Comma instead of colon", null}',
+    # http://json.org/JSON_checker/test/fail22.json
+    '["Colon instead of comma": false]',
+    # http://json.org/JSON_checker/test/fail23.json
+    '["Bad value", truth]',
+    # http://json.org/JSON_checker/test/fail24.json
+    "['single quote']",
+]
+
+SKIPS = {
+    1: "why not have a string payload?",
+    18: "spec doesn't specify any nesting limitations",
+}
+
+def test_failures():
+    import simplejson
+    for idx, doc in enumerate(JSONDOCS):
+        idx = idx + 1
+        if idx in SKIPS:
+            simplejson.loads(doc)
+            continue
+        try:
+            simplejson.loads(doc)
+        except ValueError:
+            pass
+        else:
+            assert False, "Expected failure for fail%d.json: %r" % (idx, doc)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/simplejson/tests/test_float.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/simplejson/tests/test_float.py b/tools/bin/ext/simplejson/tests/test_float.py
new file mode 100755
index 0000000..e33d3ac
--- /dev/null
+++ b/tools/bin/ext/simplejson/tests/test_float.py
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+def test_floats():
+    import simplejson
+    for num in [1617161771.7650001]:
+        assert simplejson.dumps(num) == repr(num)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/simplejson/tests/test_indent.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/simplejson/tests/test_indent.py b/tools/bin/ext/simplejson/tests/test_indent.py
new file mode 100755
index 0000000..74227bd
--- /dev/null
+++ b/tools/bin/ext/simplejson/tests/test_indent.py
@@ -0,0 +1,57 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+
+def test_indent():
+    import simplejson
+    import textwrap
+    
+    h = [['blorpie'], ['whoops'], [], 'd-shtaeou', 'd-nthiouh', 'i-vhbjkhnth',
+         {'nifty': 87}, {'field': 'yes', 'morefield': False} ]
+
+    expect = textwrap.dedent("""\
+    [
+      [
+        "blorpie"
+      ],
+      [
+        "whoops"
+      ],
+      [],
+      "d-shtaeou",
+      "d-nthiouh",
+      "i-vhbjkhnth",
+      {
+        "nifty": 87
+      },
+      {
+        "field": "yes",
+        "morefield": false
+      }
+    ]""")
+
+
+    d1 = simplejson.dumps(h)
+    d2 = simplejson.dumps(h, indent=2, sort_keys=True, separators=(',', ': '))
+
+    h1 = simplejson.loads(d1)
+    h2 = simplejson.loads(d2)
+
+    assert h1 == h
+    assert h2 == h
+    assert d2 == expect

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/simplejson/tests/test_pass1.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/simplejson/tests/test_pass1.py b/tools/bin/ext/simplejson/tests/test_pass1.py
new file mode 100755
index 0000000..87658fd
--- /dev/null
+++ b/tools/bin/ext/simplejson/tests/test_pass1.py
@@ -0,0 +1,88 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# from http://json.org/JSON_checker/test/pass1.json
+JSON = r'''
+[
+    "JSON Test Pattern pass1",
+    {"object with 1 member":["array with 1 element"]},
+    {},
+    [],
+    -42,
+    true,
+    false,
+    null,
+    {
+        "integer": 1234567890,
+        "real": -9876.543210,
+        "e": 0.123456789e-12,
+        "E": 1.234567890E+34,
+        "":  23456789012E666,
+        "zero": 0,
+        "one": 1,
+        "space": " ",
+        "quote": "\"",
+        "backslash": "\\",
+        "controls": "\b\f\n\r\t",
+        "slash": "/ & \/",
+        "alpha": "abcdefghijklmnopqrstuvwyz",
+        "ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWYZ",
+        "digit": "0123456789",
+        "special": "`1~!@#$%^&*()_+-={':[,]}|;.</>?",
+        "hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A",
+        "true": true,
+        "false": false,
+        "null": null,
+        "array":[  ],
+        "object":{  },
+        "address": "50 St. James Street",
+        "url": "http://www.JSON.org/",
+        "comment": "// /* <!-- --",
+        "# -- --> */": " ",
+        " s p a c e d " :[1,2 , 3
+
+,
+
+4 , 5        ,          6           ,7        ],
+        "compact": [1,2,3,4,5,6,7],
+        "jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}",
+        "quotes": "&#34; \u0022 %22 0x22 034 &#x22;",
+        "\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?"
+: "A key can be any string"
+    },
+    0.5 ,98.6
+,
+99.44
+,
+
+1066
+
+
+,"rosebud"]
+'''
+
+def test_parse():
+    # test in/out equivalence and parsing
+    import simplejson
+    res = simplejson.loads(JSON)
+    out = simplejson.dumps(res)
+    assert res == simplejson.loads(out)
+    try:
+        simplejson.dumps(res, allow_nan=False)
+    except ValueError:
+        pass
+    else:
+        assert False, "23456789012E666 should be out of range"

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/simplejson/tests/test_pass2.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/simplejson/tests/test_pass2.py b/tools/bin/ext/simplejson/tests/test_pass2.py
new file mode 100755
index 0000000..72bcfd0
--- /dev/null
+++ b/tools/bin/ext/simplejson/tests/test_pass2.py
@@ -0,0 +1,27 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# from http://json.org/JSON_checker/test/pass2.json
+JSON = r'''
+[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]]
+'''
+
+def test_parse():
+    # test in/out equivalence and parsing
+    import simplejson
+    res = simplejson.loads(JSON)
+    out = simplejson.dumps(res)
+    assert res == simplejson.loads(out)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/simplejson/tests/test_pass3.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/simplejson/tests/test_pass3.py b/tools/bin/ext/simplejson/tests/test_pass3.py
new file mode 100755
index 0000000..2446aa9
--- /dev/null
+++ b/tools/bin/ext/simplejson/tests/test_pass3.py
@@ -0,0 +1,32 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# from http://json.org/JSON_checker/test/pass3.json
+JSON = r'''
+{
+    "JSON Test Pattern pass3": {
+        "The outermost value": "must be an object or array.",
+        "In this test": "It is an object."
+    }
+}
+'''
+
+def test_parse():
+    # test in/out equivalence and parsing
+    import simplejson
+    res = simplejson.loads(JSON)
+    out = simplejson.dumps(res)
+    assert res == simplejson.loads(out)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/simplejson/tests/test_recursion.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/simplejson/tests/test_recursion.py b/tools/bin/ext/simplejson/tests/test_recursion.py
new file mode 100755
index 0000000..24e013c
--- /dev/null
+++ b/tools/bin/ext/simplejson/tests/test_recursion.py
@@ -0,0 +1,78 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+import simplejson
+
+def test_listrecursion():
+    x = []
+    x.append(x)
+    try:
+        simplejson.dumps(x)
+    except ValueError:
+        pass
+    else:
+        assert False, "didn't raise ValueError on list recursion"
+    x = []
+    y = [x]
+    x.append(y)
+    try:
+        simplejson.dumps(x)
+    except ValueError:
+        pass
+    else:
+        assert False, "didn't raise ValueError on alternating list recursion"
+    y = []
+    x = [y, y]
+    # ensure that the marker is cleared
+    simplejson.dumps(x)
+
+def test_dictrecursion():
+    x = {}
+    x["test"] = x
+    try:
+        simplejson.dumps(x)
+    except ValueError:
+        pass
+    else:
+        assert False, "didn't raise ValueError on dict recursion"
+    x = {}
+    y = {"a": x, "b": x}
+    # ensure that the marker is cleared
+    simplejson.dumps(x)
+
+class TestObject:
+    pass
+
+class RecursiveJSONEncoder(simplejson.JSONEncoder):
+    recurse = False
+    def default(self, o):
+        if o is TestObject:
+            if self.recurse:
+                return [TestObject]
+            else:
+                return 'TestObject'
+        simplejson.JSONEncoder.default(o)
+
+def test_defaultrecursion():
+    enc = RecursiveJSONEncoder()
+    assert enc.encode(TestObject) == '"TestObject"'
+    enc.recurse = True
+    try:
+        enc.encode(TestObject)
+    except ValueError:
+        pass
+    else:
+        assert False, "didn't raise ValueError on default recursion"

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/simplejson/tests/test_separators.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/simplejson/tests/test_separators.py b/tools/bin/ext/simplejson/tests/test_separators.py
new file mode 100755
index 0000000..f088e09
--- /dev/null
+++ b/tools/bin/ext/simplejson/tests/test_separators.py
@@ -0,0 +1,57 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+
+def test_separators():
+    import simplejson
+    import textwrap
+    
+    h = [['blorpie'], ['whoops'], [], 'd-shtaeou', 'd-nthiouh', 'i-vhbjkhnth',
+         {'nifty': 87}, {'field': 'yes', 'morefield': False} ]
+
+    expect = textwrap.dedent("""\
+    [
+      [
+        "blorpie"
+      ] ,
+      [
+        "whoops"
+      ] ,
+      [] ,
+      "d-shtaeou" ,
+      "d-nthiouh" ,
+      "i-vhbjkhnth" ,
+      {
+        "nifty" : 87
+      } ,
+      {
+        "field" : "yes" ,
+        "morefield" : false
+      }
+    ]""")
+
+
+    d1 = simplejson.dumps(h)
+    d2 = simplejson.dumps(h, indent=2, sort_keys=True, separators=(' ,', ' : '))
+
+    h1 = simplejson.loads(d1)
+    h2 = simplejson.loads(d2)
+
+    assert h1 == h
+    assert h2 == h
+    assert d2 == expect

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/simplejson/tests/test_unicode.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/simplejson/tests/test_unicode.py b/tools/bin/ext/simplejson/tests/test_unicode.py
new file mode 100755
index 0000000..430bcd3
--- /dev/null
+++ b/tools/bin/ext/simplejson/tests/test_unicode.py
@@ -0,0 +1,32 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+import simplejson as S
+
+def test_encoding1():
+    encoder = S.JSONEncoder(encoding='utf-8')
+    u = u'\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
+    s = u.encode('utf-8')
+    ju = encoder.encode(u)
+    js = encoder.encode(s)
+    assert ju == js
+    
+def test_encoding2():
+    u = u'\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
+    s = u.encode('utf-8')
+    ju = S.dumps(u, encoding='utf-8')
+    js = S.dumps(s, encoding='utf-8')
+    assert ju == js

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/yaml/__init__.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/yaml/__init__.py b/tools/bin/ext/yaml/__init__.py
new file mode 100644
index 0000000..b6c84f9
--- /dev/null
+++ b/tools/bin/ext/yaml/__init__.py
@@ -0,0 +1,306 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from error import *
+
+from tokens import *
+from events import *
+from nodes import *
+
+from loader import *
+from dumper import *
+
+try:
+    from cyaml import *
+except ImportError:
+    pass
+
+def scan(stream, Loader=Loader):
+    """
+    Scan a YAML stream and produce scanning tokens.
+    """
+    loader = Loader(stream)
+    while loader.check_token():
+        yield loader.get_token()
+
+def parse(stream, Loader=Loader):
+    """
+    Parse a YAML stream and produce parsing events.
+    """
+    loader = Loader(stream)
+    while loader.check_event():
+        yield loader.get_event()
+
+def compose(stream, Loader=Loader):
+    """
+    Parse the first YAML document in a stream
+    and produce the corresponding representation tree.
+    """
+    loader = Loader(stream)
+    if loader.check_node():
+        return loader.get_node()
+
+def compose_all(stream, Loader=Loader):
+    """
+    Parse all YAML documents in a stream
+    and produce corresponsing representation trees.
+    """
+    loader = Loader(stream)
+    while loader.check_node():
+        yield loader.get_node()
+
+def load_all(stream, Loader=Loader):
+    """
+    Parse all YAML documents in a stream
+    and produce corresponding Python objects.
+    """
+    loader = Loader(stream)
+    while loader.check_data():
+        yield loader.get_data()
+
+def load(stream, Loader=Loader):
+    """
+    Parse the first YAML document in a stream
+    and produce the corresponding Python object.
+    """
+    loader = Loader(stream)
+    if loader.check_data():
+        return loader.get_data()
+
+def safe_load_all(stream):
+    """
+    Parse all YAML documents in a stream
+    and produce corresponding Python objects.
+    Resolve only basic YAML tags.
+    """
+    return load_all(stream, SafeLoader)
+
+def safe_load(stream):
+    """
+    Parse the first YAML document in a stream
+    and produce the corresponding Python object.
+    Resolve only basic YAML tags.
+    """
+    return load(stream, SafeLoader)
+
+def emit(events, stream=None, Dumper=Dumper,
+        canonical=None, indent=None, width=None,
+        allow_unicode=None, line_break=None):
+    """
+    Emit YAML parsing events into a stream.
+    If stream is None, return the produced string instead.
+    """
+    getvalue = None
+    if stream is None:
+        try:
+            from cStringIO import StringIO
+        except ImportError:
+            from StringIO import StringIO
+        stream = StringIO()
+        getvalue = stream.getvalue
+    dumper = Dumper(stream, canonical=canonical, indent=indent, width=width,
+            allow_unicode=allow_unicode, line_break=line_break)
+    for event in events:
+        dumper.emit(event)
+    if getvalue:
+        return getvalue()
+
+def serialize_all(nodes, stream=None, Dumper=Dumper,
+        canonical=None, indent=None, width=None,
+        allow_unicode=None, line_break=None,
+        encoding='utf-8', explicit_start=None, explicit_end=None,
+        version=None, tags=None):
+    """
+    Serialize a sequence of representation trees into a YAML stream.
+    If stream is None, return the produced string instead.
+    """
+    getvalue = None
+    if stream is None:
+        try:
+            from cStringIO import StringIO
+        except ImportError:
+            from StringIO import StringIO
+        stream = StringIO()
+        getvalue = stream.getvalue
+    dumper = Dumper(stream, canonical=canonical, indent=indent, width=width,
+            allow_unicode=allow_unicode, line_break=line_break,
+            encoding=encoding, version=version, tags=tags,
+            explicit_start=explicit_start, explicit_end=explicit_end)
+    dumper.open()
+    for node in nodes:
+        dumper.serialize(node)
+    dumper.close()
+    if getvalue:
+        return getvalue()
+
+def serialize(node, stream=None, Dumper=Dumper, **kwds):
+    """
+    Serialize a representation tree into a YAML stream.
+    If stream is None, return the produced string instead.
+    """
+    return serialize_all([node], stream, Dumper=Dumper, **kwds)
+
+def dump_all(documents, stream=None, Dumper=Dumper,
+        default_style=None, default_flow_style=None,
+        canonical=None, indent=None, width=None,
+        allow_unicode=None, line_break=None,
+        encoding='utf-8', explicit_start=None, explicit_end=None,
+        version=None, tags=None):
+    """
+    Serialize a sequence of Python objects into a YAML stream.
+    If stream is None, return the produced string instead.
+    """
+    getvalue = None
+    if stream is None:
+        try:
+            from cStringIO import StringIO
+        except ImportError:
+            from StringIO import StringIO
+        stream = StringIO()
+        getvalue = stream.getvalue
+    dumper = Dumper(stream, default_style=default_style,
+            default_flow_style=default_flow_style,
+            canonical=canonical, indent=indent, width=width,
+            allow_unicode=allow_unicode, line_break=line_break,
+            encoding=encoding, version=version, tags=tags,
+            explicit_start=explicit_start, explicit_end=explicit_end)
+    dumper.open()
+    for data in documents:
+        dumper.represent(data)
+    dumper.close()
+    if getvalue:
+        return getvalue()
+
+def dump(data, stream=None, Dumper=Dumper, **kwds):
+    """
+    Serialize a Python object into a YAML stream.
+    If stream is None, return the produced string instead.
+    """
+    return dump_all([data], stream, Dumper=Dumper, **kwds)
+
+def safe_dump_all(documents, stream=None, **kwds):
+    """
+    Serialize a sequence of Python objects into a YAML stream.
+    Produce only basic YAML tags.
+    If stream is None, return the produced string instead.
+    """
+    return dump_all(documents, stream, Dumper=SafeDumper, **kwds)
+
+def safe_dump(data, stream=None, **kwds):
+    """
+    Serialize a Python object into a YAML stream.
+    Produce only basic YAML tags.
+    If stream is None, return the produced string instead.
+    """
+    return dump_all([data], stream, Dumper=SafeDumper, **kwds)
+
+def add_implicit_resolver(tag, regexp, first=None,
+        Loader=Loader, Dumper=Dumper):
+    """
+    Add an implicit scalar detector.
+    If an implicit scalar value matches the given regexp,
+    the corresponding tag is assigned to the scalar.
+    first is a sequence of possible initial characters or None.
+    """
+    Loader.add_implicit_resolver(tag, regexp, first)
+    Dumper.add_implicit_resolver(tag, regexp, first)
+
+def add_path_resolver(tag, path, kind=None, Loader=Loader, Dumper=Dumper):
+    """
+    Add a path based resolver for the given tag.
+    A path is a list of keys that forms a path
+    to a node in the representation tree.
+    Keys can be string values, integers, or None.
+    """
+    Loader.add_path_resolver(tag, path, kind)
+    Dumper.add_path_resolver(tag, path, kind)
+
+def add_constructor(tag, constructor, Loader=Loader):
+    """
+    Add a constructor for the given tag.
+    Constructor is a function that accepts a Loader instance
+    and a node object and produces the corresponding Python object.
+    """
+    Loader.add_constructor(tag, constructor)
+
+def add_multi_constructor(tag_prefix, multi_constructor, Loader=Loader):
+    """
+    Add a multi-constructor for the given tag prefix.
+    Multi-constructor is called for a node if its tag starts with tag_prefix.
+    Multi-constructor accepts a Loader instance, a tag suffix,
+    and a node object and produces the corresponding Python object.
+    """
+    Loader.add_multi_constructor(tag_prefix, multi_constructor)
+
+def add_representer(data_type, representer, Dumper=Dumper):
+    """
+    Add a representer for the given type.
+    Representer is a function accepting a Dumper instance
+    and an instance of the given data type
+    and producing the corresponding representation node.
+    """
+    Dumper.add_representer(data_type, representer)
+
+def add_multi_representer(data_type, multi_representer, Dumper=Dumper):
+    """
+    Add a representer for the given type.
+    Multi-representer is a function accepting a Dumper instance
+    and an instance of the given data type or subtype
+    and producing the corresponding representation node.
+    """
+    Dumper.add_multi_representer(data_type, multi_representer)
+
+class YAMLObjectMetaclass(type):
+    """
+    The metaclass for YAMLObject.
+    """
+    def __init__(cls, name, bases, kwds):
+        super(YAMLObjectMetaclass, cls).__init__(name, bases, kwds)
+        if 'yaml_tag' in kwds and kwds['yaml_tag'] is not None:
+            cls.yaml_loader.add_constructor(cls.yaml_tag, cls.from_yaml)
+            cls.yaml_dumper.add_representer(cls, cls.to_yaml)
+
+class YAMLObject(object):
+    """
+    An object that can dump itself to a YAML stream
+    and load itself from a YAML stream.
+    """
+
+    __metaclass__ = YAMLObjectMetaclass
+    __slots__ = ()  # no direct instantiation, so allow immutable subclasses
+
+    yaml_loader = Loader
+    yaml_dumper = Dumper
+
+    yaml_tag = None
+    yaml_flow_style = None
+
+    def from_yaml(cls, loader, node):
+        """
+        Convert a representation node to a Python object.
+        """
+        return loader.construct_yaml_object(node, cls)
+    from_yaml = classmethod(from_yaml)
+
+    def to_yaml(cls, dumper, data):
+        """
+        Convert a Python object to a representation node.
+        """
+        return dumper.represent_yaml_object(cls.yaml_tag, data, cls,
+                flow_style=cls.yaml_flow_style)
+    to_yaml = classmethod(to_yaml)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/yaml/composer.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/yaml/composer.py b/tools/bin/ext/yaml/composer.py
new file mode 100644
index 0000000..a3fb797
--- /dev/null
+++ b/tools/bin/ext/yaml/composer.py
@@ -0,0 +1,134 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+__all__ = ['Composer', 'ComposerError']
+
+from error import MarkedYAMLError
+from events import *
+from nodes import *
+
+class ComposerError(MarkedYAMLError):
+    pass
+
+class Composer(object):
+
+    def __init__(self):
+        self.anchors = {}
+
+    def check_node(self):
+        # Drop the STREAM-START event.
+        if self.check_event(StreamStartEvent):
+            self.get_event()
+
+        # If there are more documents available?
+        return not self.check_event(StreamEndEvent)
+
+    def get_node(self):
+        # Get the root node of the next document.
+        if not self.check_event(StreamEndEvent):
+            return self.compose_document()
+
+    def compose_document(self):
+        # Drop the DOCUMENT-START event.
+        self.get_event()
+
+        # Compose the root node.
+        node = self.compose_node(None, None)
+
+        # Drop the DOCUMENT-END event.
+        self.get_event()
+
+        self.anchors = {}
+        return node
+
+    def compose_node(self, parent, index):
+        if self.check_event(AliasEvent):
+            event = self.get_event()
+            anchor = event.anchor
+            if anchor not in self.anchors:
+                raise ComposerError(None, None, "found undefined alias %r"
+                        % anchor.encode('utf-8'), event.start_mark)
+            return self.anchors[anchor]
+        event = self.peek_event()
+        anchor = event.anchor
+        if anchor is not None:
+            if anchor in self.anchors:
+                raise ComposerError("found duplicate anchor %r; first occurence"
+                        % anchor.encode('utf-8'), self.anchors[anchor].start_mark,
+                        "second occurence", event.start_mark)
+        self.descend_resolver(parent, index)
+        if self.check_event(ScalarEvent):
+            node = self.compose_scalar_node(anchor)
+        elif self.check_event(SequenceStartEvent):
+            node = self.compose_sequence_node(anchor)
+        elif self.check_event(MappingStartEvent):
+            node = self.compose_mapping_node(anchor)
+        self.ascend_resolver()
+        return node
+
+    def compose_scalar_node(self, anchor):
+        event = self.get_event()
+        tag = event.tag
+        if tag is None or tag == u'!':
+            tag = self.resolve(ScalarNode, event.value, event.implicit)
+        node = ScalarNode(tag, event.value,
+                event.start_mark, event.end_mark, style=event.style)
+        if anchor is not None:
+            self.anchors[anchor] = node
+        return node
+
+    def compose_sequence_node(self, anchor):
+        start_event = self.get_event()
+        tag = start_event.tag
+        if tag is None or tag == u'!':
+            tag = self.resolve(SequenceNode, None, start_event.implicit)
+        node = SequenceNode(tag, [],
+                start_event.start_mark, None,
+                flow_style=start_event.flow_style)
+        if anchor is not None:
+            self.anchors[anchor] = node
+        index = 0
+        while not self.check_event(SequenceEndEvent):
+            node.value.append(self.compose_node(node, index))
+            index += 1
+        end_event = self.get_event()
+        node.end_mark = end_event.end_mark
+        return node
+
+    def compose_mapping_node(self, anchor):
+        start_event = self.get_event()
+        tag = start_event.tag
+        if tag is None or tag == u'!':
+            tag = self.resolve(MappingNode, None, start_event.implicit)
+        node = MappingNode(tag, [],
+                start_event.start_mark, None,
+                flow_style=start_event.flow_style)
+        if anchor is not None:
+            self.anchors[anchor] = node
+        while not self.check_event(MappingEndEvent):
+            #key_event = self.peek_event()
+            item_key = self.compose_node(node, None)
+            #if item_key in node.value:
+            #    raise ComposerError("while composing a mapping", start_event.start_mark,
+            #            "found duplicate key", key_event.start_mark)
+            item_value = self.compose_node(node, item_key)
+            #node.value[item_key] = item_value
+            node.value.append((item_key, item_value))
+        end_event = self.get_event()
+        node.end_mark = end_event.end_mark
+        return node
+


[18/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code

Posted by rl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/sunos_process.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/sunos_process.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/sunos_process.c
new file mode 100644
index 0000000..596341c
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/sunos_process.c
@@ -0,0 +1,1021 @@
+/* The MIT License
+ *
+ * Copyright (C) 2008-2009 Floris Bruynooghe
+ *
+ * Copyright (C) 2008-2009 Abilisoft Ltd.
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/* SunOS implementation of the Process classes */
+
+
+#include <Python.h>
+
+
+/* We do not want to use the large file compilation environment as <procfs.h>
+ * doesn't play nice with that on ILP32 (32-bit machines), but <Python.h>, via
+ * pyconfig.h, sets the environment up for this so we need to reverse that.
+ * The transitional large file compilation environment (where the function
+ * sources are xxx64() instead and no mapping of the xxx symbols to xxx64
+ * symbols happens) is fine, so we leave _LARGEFILE64_SOURCE set.  See the
+ * lfcompile(5) and lfcompile64(5) manpages for notes on mixing objects from
+ * different compilation environments: basically just don't share global
+ * variables across them. */
+#undef _FILE_OFFSET_BITS
+
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <procfs.h>
+#include <signal.h>
+#include <string.h>
+#include <sys/proc.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <time.h>
+#include <unistd.h>
+
+#if SUNOS5_MINOR >= 10
+#include <zone.h>
+#endif
+
+#include "psi.h"
+#include "process.h"
+#include "procfs_utils.h"
+#include "posix_utils.h"
+
+
+/***** Local declarations *****/
+static int parse_psinfo(struct psi_process *proci,
+                        const pid_t pid,
+                        psinfo_t **psinfop);
+static int parse_as(struct psi_process *proci,
+                    const pid_t pid,
+                    psinfo_t *psinfo);
+static int parse_usage(struct psi_process *proci, const pid_t pid);
+static double calc_pcpu(ushort_t pr_pctcpu);
+#if SUNOS5_MINOR >= 10
+static int set_cwd(struct psi_process *proci, const pid_t pid);
+static char *get_terminal(dev_t ttydev);
+static char *get_zonename(zoneid_t zoneid);
+#endif
+
+static int set_args_from_as(struct psi_process *proci,
+                            const struct psinfo *psinfo,
+                            const int asfd);
+static int set_args_from_argv(struct psi_process *proci,
+                              const off_t *argv,
+                              const psinfo_t *psinfo,
+                              const int asfd);
+static int set_env_from_as(struct psi_process *proci,
+                           const struct psinfo *psinfo,
+                           const int asfd);
+static int set_envv_from_envp(struct psi_process *proci,
+                              const int envc,
+                              const off_t *envp,
+                              const psinfo_t *psinfo,
+                              const int asfd);
+static int set_exe(struct psi_process *proci,
+                   const pid_t pid,
+                   const psinfo_t *psinfo);
+static int set_args_env_from_fork(struct psi_process *proci,
+                                  const psinfo_t *psinfo);
+static char *find_sargs64(void);
+static int read_sargs64_pipe(struct psi_process *proci,
+                             const psinfo_t *psinfo,
+                             const int pipe);
+
+
+/***** Public interfaces from process.h. *****/
+
+
+/* The process status flags. */
+#define addflag(CONST) {"PROC_STATUS_"#CONST, CONST}
+struct psi_flag psi_arch_proc_status_flags[] = {
+    addflag(SIDL),
+    addflag(SRUN),
+    addflag(SSLEEP),
+    addflag(SSTOP),
+    addflag(SZOMB),
+#ifdef SONPROC
+    addflag(SONPROC),
+#endif
+#ifdef SWAIT
+    addflag(SWAIT),
+#endif
+    {NULL, 0}
+};
+
+
+/** Collect all information about a process
+ *
+ * The psinfo variable is so that /proc/<pid>/psinfo only needs to be read
+ * once.
+ */
+struct psi_process *
+psi_arch_process(const pid_t pid)
+{
+    struct psi_process *proci;
+    psinfo_t *psinfo;
+
+    if (procfs_check_pid(pid) < 0)
+        return NULL;
+    proci = psi_calloc(sizeof(struct psi_process));
+    if (proci == NULL)
+        return NULL;
+    if (parse_psinfo(proci, pid, &psinfo) < 0) {
+        psi_FREE(psinfo);
+        return psi_free_process(proci);
+    }
+    if (set_exe(proci, pid, psinfo) < 0) {
+        psi_free(psinfo);
+        return psi_free_process(proci);
+    }
+    if (parse_as(proci, pid, psinfo) < 0) {
+        psi_free(psinfo);
+        return psi_free_process(proci);
+    }
+    psi_free(psinfo);
+    if (parse_usage(proci, pid) < 0)
+        return psi_free_process(proci);
+#if SUNOS5_MINOR >= 10
+    if (set_cwd(proci, pid) < 0)
+        return psi_free_process(proci);
+#endif
+    return proci;
+}
+
+
+/***** Local functions *****/
+
+
+/** Parse information from /proc/<pid>/psinfo
+ *
+ * The `psinfop' argument will point to the `psinfo_t' structure or NULL.  The
+ * caller *has* to call psi_free on it if it is non NULL.  This means when an
+ * error arises in this function this function itself *should not* free the
+ * `psinfo' structure.
+ */
+static int
+parse_psinfo(struct psi_process *proci, const pid_t pid, psinfo_t **psinfop)
+{
+    psinfo_t *psinfo;
+    int bufsize;
+
+    bufsize = procfs_read_procfile((char**)&psinfo, pid, "psinfo");
+    *psinfop = psinfo;
+    if (bufsize == -1)
+        return -1;
+    if (bufsize == -2) {
+        proci->name_status = PSI_STATUS_PRIVS;
+        proci->argc_status = PSI_STATUS_PRIVS;
+        proci->command_status = PSI_STATUS_PRIVS;
+        proci->nthreads_status = PSI_STATUS_PRIVS;
+        proci->ppid_status = PSI_STATUS_PRIVS;
+        proci->pgrp_status = PSI_STATUS_PRIVS;
+        proci->sid_status = PSI_STATUS_PRIVS;
+        proci->ruid_status = PSI_STATUS_PRIVS;
+        proci->euid_status = PSI_STATUS_PRIVS;
+        proci->rgid_status = PSI_STATUS_PRIVS;
+        proci->egid_status = PSI_STATUS_PRIVS;
+        proci->euser_status = PSI_STATUS_PRIVS;
+        proci->ruser_status = PSI_STATUS_PRIVS;
+        proci->egroup_status = PSI_STATUS_PRIVS;
+        proci->rgroup_status = PSI_STATUS_PRIVS;
+        proci->vsz_status = PSI_STATUS_PRIVS;
+        proci->rss_status = PSI_STATUS_PRIVS;
+        proci->terminal_status = PSI_STATUS_PRIVS;
+        proci->pcpu_status = PSI_STATUS_PRIVS;
+        proci->start_time_status = PSI_STATUS_PRIVS;
+        proci->cputime_status = PSI_STATUS_PRIVS;
+        proci->exe_status = PSI_STATUS_PRIVS;
+        proci->status_status = PSI_STATUS_PRIVS;
+        proci->nice_status = PSI_STATUS_PRIVS;
+        proci->priority_status = PSI_STATUS_PRIVS;
+        proci->zoneid_status = PSI_STATUS_PRIVS;
+        proci->zonename_status = PSI_STATUS_PRIVS;
+        return 0;
+    }
+    if (bufsize != sizeof(psinfo_t)) {
+        PyErr_Format(PyExc_OSError,
+                     "Unexpected psinfo file size: %d instead of %d",
+                     bufsize, sizeof(psinfo_t));
+        return -1;
+    }
+    proci->name = (char *)psi_malloc(PRFNSZ); /* XXX or strlen()? */
+    if (proci->name == NULL)
+        return -1;
+    strcpy(proci->name, psinfo->pr_fname);
+    proci->name_status = PSI_STATUS_OK;
+    proci->argc = psinfo->pr_argc;
+    proci->argc_status = PSI_STATUS_OK;
+    proci->command = psi_strdup(psinfo->pr_psargs);
+    if (proci->command == NULL)
+        return -1;
+    proci->command_status = PSI_STATUS_OK;
+#if SUNOS5_MINOR >= 10
+    proci->nthreads = psinfo->pr_nlwp + psinfo->pr_nzomb;
+#else
+    proci->nthreads = psinfo->pr_nlwp;
+#endif
+    proci->nthreads_status = PSI_STATUS_OK;
+    proci->ppid = psinfo->pr_ppid;
+    proci->ppid_status = PSI_STATUS_OK;
+    proci->pgrp = psinfo->pr_pgid;
+    proci->pgrp_status = PSI_STATUS_OK;
+    proci->sid = psinfo->pr_sid;
+    proci->sid_status = PSI_STATUS_OK;
+    proci->ruid = psinfo->pr_uid;
+    proci->ruid_status = PSI_STATUS_OK;
+    proci->euid = psinfo->pr_euid;
+    proci->euid_status = PSI_STATUS_OK;
+    proci->rgid = psinfo->pr_gid;
+    proci->rgid_status = PSI_STATUS_OK;
+    proci->egid = psinfo->pr_egid;
+    proci->egid_status = PSI_STATUS_OK;
+    /* XXX rss & vsz are size_t on SunOS! */
+    proci->vsz = psinfo->pr_size * 1024;
+    proci->vsz_status = PSI_STATUS_OK;
+    proci->rss = (psinfo->pr_rssize) * 1024;
+    proci->rss_status = PSI_STATUS_OK;
+#if SUNOS5_MINOR >= 10
+    proci->terminal = get_terminal(psinfo->pr_ttydev);
+    if (proci->terminal == NULL && PyErr_Occurred() != NULL)
+        return -1;
+    proci->terminal_status = PSI_STATUS_OK;
+#endif
+    proci->pcpu = calc_pcpu(psinfo->pr_pctcpu);
+    proci->pcpu_status = PSI_STATUS_OK;
+    proci->start_time.tv_sec = psinfo->pr_start.tv_sec;
+    proci->start_time.tv_nsec = psinfo->pr_start.tv_nsec;
+    proci->start_time_status = PSI_STATUS_OK;
+    proci->cputime.tv_sec = psinfo->pr_time.tv_sec;
+    proci->cputime.tv_nsec = psinfo->pr_time.tv_nsec;
+    proci->cputime_status = PSI_STATUS_OK;
+    proci->status = psinfo->pr_lwp.pr_state;
+    proci->status_status = PSI_STATUS_OK;
+    proci->nice = psinfo->pr_lwp.pr_nice;
+    proci->nice_status = PSI_STATUS_OK;
+    proci->priority = psinfo->pr_lwp.pr_pri;
+    proci->priority_status = PSI_STATUS_OK;
+#if SUNOS5_MINOR >= 10
+    proci->zoneid = psinfo->pr_zoneid;
+    proci->zoneid_status = PSI_STATUS_OK;
+    proci->zonename = get_zonename(proci->zoneid);
+    if (proci->zonename == NULL)
+        return -1;
+    proci->zonename_status = PSI_STATUS_OK;
+#endif
+    *psinfop = psinfo;
+    return 0;
+}
+
+
+/** Parse the process address space: /proc/<pid>/as
+ *
+ * The argv, envc and envv slots are filled in from this.
+ *
+ * Care should be taken here as this is the address space image of the process
+ * it is not coverted to the data model of us (normally ILP32) like the rest
+ * of /proc, so it could be either ILP32 or LP64.
+ */
+static int
+parse_as(struct psi_process *proci, const pid_t pid, psinfo_t *psinfo)
+{
+    char *path;
+    int r;
+    int asfd;
+
+    if (psinfo->pr_dmodel != PR_MODEL_ILP32 &&
+        psinfo->pr_dmodel != PR_MODEL_LP64) {
+        /* Kernel threads/processes/LWPs. */
+        proci->argv_status = PSI_STATUS_NA;
+        proci->envc_status = PSI_STATUS_NA;
+        proci->envv_status = PSI_STATUS_NA;
+        return 0;
+    }
+#ifdef _ILP32
+    if (psinfo->pr_dmodel == PR_MODEL_LP64)
+        return set_args_env_from_fork(proci, psinfo);
+#endif
+    r = psi_asprintf(&path, "/proc/%d/as", pid);
+    if (r < 0)
+        return -1;
+    asfd = open(path, O_RDONLY);
+    if (asfd < 0) {
+        if (errno == EACCES || errno == EPERM) {
+            psi_free(path);
+            proci->argv_status = PSI_STATUS_PRIVS;
+            proci->envc_status = PSI_STATUS_PRIVS;
+            proci->envv_status = PSI_STATUS_PRIVS;
+            return 0;
+        } else if (errno == ENOENT) {
+            PyErr_SetFromErrnoWithFilename(PsiExc_NoSuchProcessError, path);
+            psi_free(path);
+            return -1;
+        } else {
+            PyErr_SetFromErrnoWithFilename(PyExc_OSError, path);
+            psi_free(path);
+            return -1;
+        }
+    }
+    psi_free(path);
+    if (set_args_from_as(proci, psinfo, asfd) < 0) {
+        close(asfd);
+        return -1;
+    }
+    if (set_env_from_as(proci, psinfo, asfd) < 0) {
+        close(asfd);
+        return -1;
+    }
+    close(asfd);
+    return 0;
+}
+
+
+static int
+parse_usage(struct psi_process *proci, const pid_t pid)
+{
+    prusage_t *prusage;
+    int bufsize;
+
+    bufsize = procfs_read_procfile((char**)&prusage, pid, "usage");
+    if (bufsize == -1)
+        return -1;
+    if (bufsize == -2) {
+        proci->utime_status = PSI_STATUS_PRIVS;
+        proci->stime_status = PSI_STATUS_PRIVS;
+        PyErr_Clear();
+        return 0;
+    }
+    if (bufsize != sizeof(prusage_t)) {
+        PyErr_Format(PyExc_OSError,
+                     "Unexpected status file size: %d instead of %d",
+                     bufsize, sizeof(prusage_t));
+        psi_free(prusage);
+        return -1;
+    }
+    proci->utime.tv_sec = prusage->pr_utime.tv_sec;
+    proci->utime.tv_nsec = prusage->pr_utime.tv_nsec;
+    proci->utime_status = PSI_STATUS_OK;
+    proci->stime.tv_sec = prusage->pr_stime.tv_sec;
+    proci->stime.tv_nsec = prusage->pr_stime.tv_nsec;
+    proci->stime_status = PSI_STATUS_OK;
+    psi_free(prusage);
+    return 0;
+}
+
+
+#if SUNOS5_MINOR >= 10
+static int
+set_cwd(struct psi_process *proci, const pid_t pid)
+{
+    char *path;
+    char *link;
+    int r;
+
+    r = psi_asprintf(&path, "/proc/%d/path/cwd", pid);
+    if (r == -1)
+        return -1;
+    r = psi_readlink(&link, path);
+    psi_free(path);
+    if (r == -2) {
+        PyErr_Clear();
+        proci->cwd_status = PSI_STATUS_PRIVS;
+    } else if (r < 0) {
+        procfs_check_pid(pid); /* OSError -> NoSuchProcessError if required */
+        return -1;
+    } else {
+        proci->cwd = psi_strdup(link);
+        psi_free(link);
+        proci->cwd_status = PSI_STATUS_OK;
+    }
+    return 0;
+}
+#endif
+
+
+#if SUNOS5_MINOR >= 10
+/* XXX For other solaris versions consider searching though /dev until the
+ *     device is found like is done on AIX. */
+/** Find the terminal associated with ttydev
+ *
+ * This is derrived from solaris ps:
+ * http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/cmd/ps/ps.c
+ * Unfortunately this only seems to work for SUNOS 5.10 and higher.  Also
+ * _ttyname_dev() is probably an internal function, it appears in the symbol
+ * table of libc.so.1 however.
+ *
+ * The name of the terminal is returned or NULL.  NULL is not always an error,
+ * it can just be there is no terminal (in which case python will see `None'
+ * so check with PyErr_Occurred().
+ */
+extern char *_ttyname_dev(dev_t, char *, size_t);
+
+static char *
+get_terminal(dev_t ttydev)
+{
+    char devname[TTYNAME_MAX];
+    char *rv;
+    int l;
+
+    if (ttydev == PRNODEV)
+        return NULL;
+    rv = _ttyname_dev(ttydev, devname, sizeof(devname));
+    if (rv == NULL)
+        return NULL;
+    l = strlen(devname);
+    rv = (char *)psi_malloc(l+1);
+    if (rv == NULL)
+        return NULL;
+    return strncpy(rv, devname, l+1);
+}
+#endif
+
+static double
+calc_pcpu(ushort_t pr_pctcpu)
+{
+    uint_t value = pr_pctcpu;
+
+    value = ((value*1000) + 0x7000) >> 15;
+    if (value >= 1000)
+        value  = 999;
+    return (double)value/10.0;
+}
+
+
+#if SUNOS5_MINOR >= 10
+static char *
+get_zonename(zoneid_t zoneid)
+{
+    char zonename[ZONENAME_MAX];
+    char *name;
+    size_t reqsize;
+
+    reqsize = getzonenamebyid(zoneid, zonename, ZONENAME_MAX);
+    if (reqsize < 0)
+        return (char*)PyErr_SetFromErrno(PyExc_OSError);
+    name = psi_malloc(reqsize);
+    if (name == NULL)
+        return NULL;
+    strncpy(name, zonename, reqsize);
+    return name;
+}
+#endif
+
+
+/** Read bits in the process address space to extract `argv'
+ *
+ * This depends on the internal representation of the argv array: the base
+ * address of the entire array is pointed too by psinfo.pr_argv and this can't
+ * change, meaning that psinfo.pr_argc denotes the number of elements in the
+ * array.  From this it is possible to create our own version of argv in the
+ * psi_process structure.
+ *
+ * Note that this function will never be called if we're a 32-bit Python
+ * looking at a 64-bit process so no need to detect this.  This means off_t is
+ * always a valid way of pointing to an address in the address space.
+ */
+static int
+set_args_from_as(struct psi_process *proci,
+                 const struct psinfo *psinfo,
+                 const int asfd)
+{
+    off_t argvoff = (off_t)psinfo->pr_argv;
+    off_t *argv;                /* not caddr_t due to casting issues */
+    caddr32_t *argv32;
+    ssize_t r;
+    int i;
+
+    /* First read in the array of pointers, this depends on the data model. */
+    if (psinfo->pr_dmodel == PR_MODEL_ILP32) {
+        argv32 = (caddr32_t*)psi_malloc(psinfo->pr_argc*sizeof(caddr32_t));
+        if (argv32 == NULL)
+            return -1;
+        r = pread(asfd, argv32, psinfo->pr_argc*sizeof(caddr32_t), argvoff);
+        if (r < 0) {
+            PyErr_SetFromErrno(PyExc_OSError);
+            psi_free(argv32);
+            return -1;
+        }
+        argv = (off_t*)psi_malloc(psinfo->pr_argc*sizeof(off_t));
+        if (argv == NULL) {
+            psi_free(argv32);
+            return -1;
+        }
+        for (i = 0; i < psinfo->pr_argc; i++)
+            argv[i] = (off_t)argv32[i];
+        psi_free(argv32);
+    } else {                    /* LP64 */
+        argv = (off_t*)psi_malloc(psinfo->pr_argc*sizeof(off_t));
+        if (argv == NULL)
+            return -1;
+        r = pread(asfd, argv, psinfo->pr_argc*sizeof(off_t), argvoff);
+        if (r < 0) {
+            PyErr_SetFromErrno(PyExc_OSError);
+            psi_free(argv);
+            return -1;
+        }
+    }
+
+    /* Now read each arg from the address space and place it into proci. */
+    i = set_args_from_argv(proci, argv, psinfo, asfd);
+    psi_free(argv);
+    if (i < 0)
+        return -1;
+    return 0;
+}
+
+
+/** Read the arguments from the address space pointed to by argv
+ *
+ * The pointers of where to read from in the address space (pointed to by the
+ * `asfd' file descriptor) are read from `argv' (which is of lenght
+ * `psinfo->pr_argc').  The result is stored in `proci->argv'.
+ *
+ * Note that proci->argv will get freed by psi_arch_process() in case of
+ * failure, so as soon as we assign an arch to it we don't have to worry about
+ * freeing it anymore in case of an error.
+ */
+static int
+set_args_from_argv(struct psi_process *proci,
+                   const off_t *argv,
+                   const psinfo_t *psinfo,
+                   const int asfd)
+{
+    off_t argoff;
+    char *arg;
+    char *ptr;
+    int argsize;
+    ssize_t r;
+    int i;
+
+    proci->argv = (char**)psi_calloc(psinfo->pr_argc*sizeof(char*));
+    if (proci->argv == NULL)
+        return -1;
+    for (i = 0; i  < psinfo->pr_argc; i++) {
+        argoff = argv[i];
+        argsize = 50;
+        arg = (char*)psi_malloc(argsize);
+        if (arg == NULL)
+            return -1;
+        ptr = arg;
+        *ptr = 'a';
+        while (*ptr != '\0') {  /* read and grow buffer if required */
+            proci->argv[i] = arg;
+            r = pread(asfd, arg, argsize, argoff);
+            if (r < 0) {
+                PyErr_SetFromErrno(PyExc_OSError);
+                return -1;
+            }
+            for (ptr = arg; ptr-arg < argsize-1; ptr++)
+                if (*ptr == '\0')
+                    break;
+            if (*ptr != '\0') {
+                argsize += 50;
+                ptr = (char*)psi_realloc(arg, argsize);
+                if (ptr == NULL)
+                    return -1;
+                arg = ptr;
+            }
+        }
+    }
+    proci->argv_status = PSI_STATUS_OK;
+    return 0;
+}
+
+
+
+/** Read bits in the process address space to extract `envp'
+ *
+ * This depends on the internal representation of the envp array: the base
+ * address of the entire array is pointed too by psinfo.pr_envp and POSIX
+ * defines that it is NULL terminated.
+ *
+ * Note that this function will never be called if we're a 32-bit Python
+ * looking at a 64-bit process so no need to detect this.  This means off_t is
+ * always a valid way of pointing to an address in the address space.
+ *
+ * XXX This is too much code for one function.
+ */
+static int
+set_env_from_as(struct psi_process *proci,
+                const struct psinfo *psinfo,
+                const int asfd)
+{
+    off_t envpoff = (off_t)psinfo->pr_envp;
+    off_t *envp;
+    off_t *ptr;
+    caddr32_t *envp32;
+    caddr32_t *ptr32;
+    ssize_t r;
+    int array_size = 50;
+    int envc = 0;
+    int i;
+
+
+    /* First read in the array of pointers, this depends on the data model. */
+    if (psinfo->pr_dmodel == PR_MODEL_ILP32) {
+        envp32 = (caddr32_t*)psi_malloc(array_size*sizeof(caddr32_t));
+        if (envp32 == NULL)
+            return -1;
+        do {
+            r = pread(asfd, envp32, array_size*sizeof(caddr32_t), envpoff);
+            if (r < 0) {
+                PyErr_SetFromErrno(PyExc_OSError);
+                psi_free(envp32);
+                return -1;
+            }
+            ptr32 = envp32;
+            for (i = 0; i < array_size; i++) {
+                ptr32++;
+                if (*ptr32 == (caddr32_t)NULL) {
+                    envc = i + 1;
+                    break;
+                }
+            }
+            if (*ptr32 != (caddr32_t)NULL) { /* array was too small */
+                array_size += 50;
+                ptr32 = (caddr32_t*)psi_realloc(envp32,
+                                                array_size*sizeof(caddr32_t));
+                if (ptr32 == NULL) {
+                    psi_free(envp32);
+                    return -1;
+                }
+                envp32 = ptr32;
+            }
+        } while (*ptr32 != (caddr32_t)NULL);
+        envp = (off_t*)psi_malloc(envc*sizeof(off_t));
+        if (envp == NULL) {
+            psi_free(envp32);
+            return -1;
+        }
+        for (i = 0; i < envc; i++)
+            envp[i] = (off_t)envp32[i];
+        psi_free(envp32);
+    } else {                    /* LP64 */
+        envp = (off_t*)psi_malloc(array_size*sizeof(off_t));
+        if (envp == NULL)
+            return -1;
+        do {
+            r = pread(asfd, envp, array_size*sizeof(off_t), envpoff);
+            if (r < 0) {
+                PyErr_SetFromErrno(PyExc_OSError);
+                psi_free(envp);
+                return -1;
+            }
+            ptr = envp;
+            for (i = 0; i < array_size; i++) {
+                ptr++;
+                if (*ptr == (off_t)NULL) {
+                    envc = i + 1;
+                    break;
+                }
+            }
+            if (*ptr != (off_t)NULL) { /* array was too small */
+                array_size += 50;
+                ptr = (off_t*)psi_realloc(envp, array_size*sizeof(off_t));
+                if (ptr == NULL) {
+                    psi_free(envp);
+                    return -1;
+                }
+                envp = ptr;
+            }
+        } while (*ptr != (off_t)NULL);
+    }
+
+    /* Now we copy the environment vector into the psi_process structure. */
+    i = set_envv_from_envp(proci, envc, envp, psinfo, asfd);
+    psi_free(envp);
+    if (i < 0)
+        return -1;
+    proci->envc = envc;
+    proci->envc_status = PSI_STATUS_OK;
+    return 0;
+}
+
+
+static int
+set_envv_from_envp(struct psi_process *proci,
+                    const int envc,
+                    const off_t *envp,
+                    const psinfo_t *psinfo,
+                    const int asfd)
+{
+    off_t envoff;
+    char *env;
+    char *ptr;
+    ssize_t r;
+    int envsize;
+    int i;
+
+    proci->envv = (char**)psi_calloc(envc*sizeof(char*));
+    if (proci->envv == NULL)
+        return -1;
+    for (i = 0; i  < envc; i++) {
+        envoff = envp[i];
+        envsize = 50;
+        env = (char*)psi_malloc(envsize);
+        if (env == NULL)
+            return -1;
+        ptr = env;
+        *ptr = 'a';
+        while (*ptr != '\0') {  /* read and grow buffer if required */
+            proci->envv[i] = env;
+            r = pread(asfd, env, envsize, envoff);
+            if (r < 0) {
+                PyErr_SetFromErrno(PyExc_OSError);
+                return -1;
+            }
+            for (ptr = env; ptr-env < envsize; ptr++)
+                if (*ptr == '\0')
+                    break;
+            if (*ptr != '\0') {
+                envsize += 50;
+                ptr = (char*)psi_realloc(env, envsize);
+                if (ptr == NULL)
+                    return -1;
+                env = ptr;
+            }
+        }
+    }
+    proci->envv_status = PSI_STATUS_OK;
+    return 0;
+}
+
+
+/** Set the exe and exe_status fields of the psi_process structure
+ *
+ * Returns -1 on failure, 0 on success.
+ */
+static int
+set_exe(struct psi_process *proci, const pid_t pid, const psinfo_t *psinfo)
+{
+#if SUNOS5_MINOR >= 10
+    char *fname;
+    char *link;
+    int r;
+
+    r = psi_asprintf(&fname, "/proc/%d/path/a.out", pid);
+    if (r == -1)
+        return -1;
+    r = psi_readlink(&link, fname);
+    psi_free(fname);
+    if (r < 0) {
+	PyErr_Clear();
+#endif
+        proci->exe = (char *)psi_malloc(PRFNSZ); /* XXX or strlen()? */
+        if (proci->exe == NULL)
+            return -1;
+        strcpy(proci->exe, psinfo->pr_fname);
+        proci->exe_status = PSI_STATUS_OK;
+#if SUNOS5_MINOR >= 10
+    } else {
+        proci->exe = link;
+        proci->exe_status = PSI_STATUS_OK;
+    }
+#endif
+    return 0;
+}
+
+
+/** Set argv, envc and envv by forking to 64-bit application
+ *
+ * This function gets called when we're a 32-bit Python trying to read the
+ * arguments and environment arrays from a 64-bit application.  We can't do
+ * that ourself so we have to call sargs64.so which is a 64-bit helper
+ * program.
+ *
+ * sargs64.so must get the PID of the process as an argument and will write
+ * the results on it's standard output.  The data format of result is:
+ * "arg0\0arg1\0...\0\0env0\0env1\0...\0\0".  So you get a NULL-terminated
+ * array for the argument list, followed by a NULL terminated array of the
+ * environment.  Once all information is sent sargs64.so will close the
+ * filedescriptor.  Unless sargs64.so return 0 the output should not be
+ * trusted.  If sargs64.so returns 2 then there was a permissions problem.
+ *
+ * Implementation notes
+ *
+ * The pipes[0] is read from in this process, pipes[1] gets written to in
+ * sargs64.so.
+ *
+ * We use fork1() (Solaris specific, not POSIX) since Solaris < 10 is not
+ * POSIX compliant and fork() there is an alias for forkall() which copies all
+ * the threads.  And we don't want any threads in the child.
+ *
+ * XXX This function is too large.
+ */
+static int
+set_args_env_from_fork(struct psi_process *proci, const psinfo_t *psinfo)
+{
+    char *pid_str;
+    char *sargs64;
+    int pipes[2];
+    int child_stat;
+    pid_t child_pid;
+    int rv;
+
+    sargs64 = find_sargs64();
+    if (sargs64 == NULL)
+        return -1;
+    if (psi_asprintf(&pid_str, "%ld", (long)psinfo->pr_pid) < 0) {
+        psi_free(sargs64);
+        return -1;
+    }
+    if (pipe(pipes) == -1) {
+        PyErr_SetFromErrno(PyExc_OSError);
+        psi_free(sargs64);
+        psi_free(pid_str);
+        return -1;
+    }
+    child_pid = fork1();
+    if (child_pid == -1) {               /* error */
+        PyErr_SetFromErrno(PyExc_OSError);
+        psi_free(sargs64);
+        psi_free(pid_str);
+        return -1;
+    } else if (child_pid == 0) {        /* child */
+        if (close(pipes[0]) == -1)
+            exit(1);
+        if (dup2(pipes[1], 1) == -1)
+            exit(1);
+        if (close(pipes[1]) == -1)
+            exit(1);
+        execl(sargs64, "sargs64.so", pid_str, NULL);
+        exit(1);
+    } else {                    /* parent */
+        psi_free(sargs64);
+        psi_free(pid_str);
+        if (close(pipes[1]) == -1) {
+            PyErr_SetFromErrno(PyExc_OSError);
+            close(pipes[0]);
+            return -1;
+        }
+        rv = read_sargs64_pipe(proci, psinfo, pipes[0]);
+        if (close(pipes[0]) == -1) {
+            PyErr_SetFromErrno(PyExc_OSError);
+            return -1;
+        }
+        if (waitpid(child_pid, &child_stat, 0) == -1) {
+            PyErr_SetFromErrno(PyExc_OSError);
+            return -1;
+        }
+        if (!WIFEXITED(child_stat)) {
+            /* Someone changed the status of our child, clean it up. */
+            while (!WIFSIGNALED(child_stat) || !WIFEXITED(child_stat)) {
+                if (kill(child_pid, SIGTERM) == -1) {
+                    PyErr_SetFromErrno(PyExc_OSError);
+                    return -1;
+                }
+                if (WIFSTOPPED(child_stat)) {
+                    if (kill(child_pid, SIGCONT) == -1) {
+                        PyErr_SetFromErrno(PyExc_OSError);
+                        return -1;
+                    }
+                }
+                if (waitpid(child_pid, &child_stat, 0) == -1) {
+                    PyErr_SetFromErrno(PyExc_OSError);
+                    return -1;
+                }
+            }
+            PyErr_SetString(PyExc_OSError, "sargs64.so did not exit normally");
+            return -1;
+        }
+        if (WEXITSTATUS(child_stat) == 2) {
+            proci->argv_status = PSI_STATUS_PRIVS;
+            proci->envc_status = PSI_STATUS_PRIVS;
+            proci->envv_status = PSI_STATUS_PRIVS;
+            return 0;
+        } else if (WEXITSTATUS(child_stat) != 0) {
+            PyErr_SetString(PyExc_OSError, "sargs64.so failed");
+            procfs_check_pid(psinfo->pr_pid == 0);
+            return -1;
+        } else
+            return rv;
+    }
+}
+
+
+/** Return the path of sargs64.so
+ *
+ * On success the path of the sargs64.so executable is returned.  Returns NULL
+ * on failure.  The returned value must be freed using psi_free().
+ */
+static char *
+find_sargs64(void)
+{
+    PyObject *mod;
+    char *sargs64;
+    char *file;
+    char *p;
+    int l;
+
+    mod = PyImport_ImportModuleNoBlock("psi.process");
+    if (mod == NULL)
+        return NULL;
+    file = PyModule_GetFilename(mod);
+    Py_DECREF(mod);
+    if (file == NULL)
+        return NULL;
+    l = strlen(file);
+    sargs64 = (char *)psi_malloc(l + 11);
+    strncpy(sargs64, file, l+1);
+    p = strrchr(sargs64, '/') + 1;
+    strcpy(p, "sargs64.so");
+    p += 10;
+    *p = '\0';
+    return sargs64;
+}
+
+
+/** Read the data from sargs64.so via the pipe
+ *
+ * The format is described above in the set_args_env_from_fork() function.
+ * This sets the argv, argv_status, envv and envv_status slots in the procinfo
+ * structure if successful.  If incomplete data is read an exception is set
+ * and -1 is returned.
+ */
+static int
+read_sargs64_pipe(struct psi_process *proci,
+                  const psinfo_t *psinfo,
+                  const int pipe)
+{
+    char *buf, *ptr, *envbuf;
+    ssize_t bytes;
+    int bufsize = 100;
+
+    /* Read buffer from pipe. */
+    buf = (char*)psi_malloc(bufsize + 2);
+    if (buf == NULL)
+        return -1;
+    ptr = buf;
+    while ((bytes = read(pipe, ptr, 100)))
+        if (bytes == 100) {
+            bufsize += 100;
+            ptr = psi_realloc(buf, bufsize + 2);
+            if (ptr == NULL) {
+                psi_free(buf);
+                return -1;
+            }
+            buf = ptr;
+            ptr = buf + bufsize - 100;
+        }
+    buf[bufsize-1] = '\0';        /* Ensure buffer ends in '\0\0' */
+    buf[bufsize] = '\0';
+
+    /* Parse argv. */
+    ptr = strchr(buf, '\0');
+    while (*(ptr+1) != '\0') {
+        ptr = strchr(ptr+1, '\0');
+        if (ptr == NULL) {
+            psi_free(buf);
+            PyErr_SetString(PyExc_OSError, "Invalid data from sargs64.so");
+            return -1;
+        }
+    }
+    proci->argc = psi_strings_count(buf, ptr-buf+1);
+    proci->argv = psi_strings_to_array(buf, proci->argc);
+    proci->argc_status = PSI_STATUS_OK;
+    proci->argv_status = PSI_STATUS_OK;
+
+    /* Parse envv. */
+    envbuf = ptr + 2;
+    if (envbuf-buf > bufsize-2) {
+        psi_free(buf);
+        PyErr_SetString(PyExc_OSError, "Invalid data from sargs64.so");
+        return -1;
+    }
+    ptr = strchr(envbuf, '\0');
+    while (*(ptr+1) != '\0') {
+        ptr = strchr(ptr+1, '\0');
+        if (ptr == NULL) {
+            psi_free(buf);
+            PyErr_SetString(PyExc_OSError, "Invalid data from sargs64.so");
+            return -1;
+        }
+    }
+    proci->envc = psi_strings_count(envbuf, ptr-envbuf+1);
+    proci->envv = psi_strings_to_array(envbuf, proci->envc);
+    proci->envc_status = PSI_STATUS_OK;
+    proci->envv_status = PSI_STATUS_OK;
+    psi_free(buf);
+    return 0;
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/sunos_psi.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/sunos_psi.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/sunos_psi.c
new file mode 100644
index 0000000..e59dafb
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/sunos_psi.c
@@ -0,0 +1,66 @@
+/* The MIT License
+ *
+ * Copyright (C) 2009 Floris Bruynooghe
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/* SunOS implementations of the _psi non-POSIX functions */
+
+
+#include <Python.h>
+
+#include <sys/time.h>
+#include <sys/types.h>
+#include <time.h>
+#include <utmpx.h>
+
+#include "psifuncs.h"
+#include "posix_utils.h"
+
+
+/***** Public functions *****/
+
+
+int
+arch_boottime(struct timespec *boottime)
+{
+    return posix_utmpx_boottime(boottime);
+}
+
+
+int
+arch_uptime(struct timespec *uptime)
+{
+    struct timespec utbt;
+    struct timespec now;
+    struct timeval tvnow;
+
+    if (posix_utmpx_boottime(&utbt) < 0)
+        return -1;
+    if (gettimeofday(&tvnow, NULL) < 0) {
+        PyErr_SetFromErrno(PyExc_OSError);
+        return -1;
+    }
+    now.tv_sec = tvnow.tv_sec;
+    now.tv_nsec = tvnow.tv_usec * 1000;
+    *uptime = posix_timespec_subtract(&now, &utbt);
+    return 0;
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/archmodule.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/archmodule.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/archmodule.c
new file mode 100644
index 0000000..38b6934
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/archmodule.c
@@ -0,0 +1,210 @@
+/* The MIT License
+ *
+ * Copyright (C) 2008-2009 Floris Bruynooghe
+ *
+ * Copyright (C) 2008-2009 Abilisoft Ltd.
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/* The psi.arch module  */
+
+
+#include <Python.h>
+
+#include "psi.h"
+#include "arch.h"
+
+
+/* Declarations (we need these since we use -Wmissing-declarations) */
+#ifdef PY3K
+PyMODINIT_FUNC PyInit_arch(void);
+#else
+PyMODINIT_FUNC initarch(void);
+#endif
+
+
+/* Re-declare these as non-extern since we're providing the symbols */
+PyObject *PsiExc_AttrNotAvailableError = NULL;
+PyObject *PsiExc_AttrInsufficientPrivsError = NULL;
+PyObject *PsiExc_AttrNotImplementedError = NULL;
+
+
+/* More constants */
+static char MODULE_NAME[] = "psi.arch";
+PyDoc_STRVAR(MODULE_DOC, "Module for system architecture information");
+
+
+/* The psi.arch.arch_type() function */
+static PyObject *
+psi_arch_type(PyObject *self, PyObject *args)
+{
+    return PsiArch_New();
+}
+
+
+/** Finalise the types
+ *
+ * Calls PyType_Ready() and does anything else required.
+ */
+static int
+prepare_types(void)
+{
+    if (PyType_Ready(&PsiArchBase_Type) < 0)
+        return -1;
+    if (PyType_Ready(&PsiArchLinux_Type) < 0)
+        return -1;
+    if (PyType_Ready(&PsiArchSunOS_Type) < 0)
+        return -1;
+    if (PyType_Ready(&PsiArchDarwin_Type) < 0)
+        return -1;
+    if (PyType_Ready(&PsiArchAIX_Type) < 0)
+        return -1;
+    Py_INCREF(&PsiArchBase_Type);
+    Py_INCREF(&PsiArchLinux_Type);
+    Py_INCREF(&PsiArchSunOS_Type);
+    Py_INCREF(&PsiArchDarwin_Type);
+    Py_INCREF(&PsiArchAIX_Type);
+    return 0;
+}
+
+
+/** Initialise the global exceptions
+ *
+ * If this function fails the modinit function will Py_XDECREF the exceptions,
+ * so no need to do that here.
+ */
+static int
+init_exceptions(void)
+{
+    PyObject *_psimod;
+
+    _psimod = PyImport_ImportModule("psi._psi");
+    if (_psimod == NULL)
+        return -1;
+    PsiExc_AttrNotAvailableError = PyObject_GetAttrString(
+        _psimod, "AttrNotAvailableError");
+    if (PsiExc_AttrNotAvailableError == NULL)
+        goto error;
+    PsiExc_AttrInsufficientPrivsError = PyObject_GetAttrString(
+        _psimod, "AttrInsufficientPrivsError");
+    if (PsiExc_AttrInsufficientPrivsError == NULL)
+        goto error;
+    PsiExc_AttrNotImplementedError = PyObject_GetAttrString(
+        _psimod, "AttrNotImplementedError");
+    if (PsiExc_AttrNotImplementedError == NULL)
+        goto error;
+    Py_DECREF(_psimod);
+    return 0;
+
+  error:
+    Py_DECREF(_psimod);
+    return -1;
+}
+
+
+/* Add all the objects to the module */
+static int
+add_module_objects(PyObject *mod)
+{
+    if (PyModule_AddObject(mod, "ArchBase",
+                           (PyObject *)&PsiArchBase_Type) < 0)
+        return -1;
+    if (PyModule_AddObject(mod, "ArchLinux",
+                           (PyObject *)&PsiArchLinux_Type) < 0)
+        return -1;
+    if (PyModule_AddObject(mod, "ArchSunOS",
+                           (PyObject *)&PsiArchSunOS_Type) < 0)
+        return -1;
+    if (PyModule_AddObject(mod, "ArchDarwin",
+                           (PyObject *)&PsiArchDarwin_Type) < 0)
+        return -1;
+    if (PyModule_AddObject(mod, "ArchAIX",
+                           (PyObject *)&PsiArchAIX_Type) < 0)
+        return -1;
+    return 0;
+}
+
+
+static PyMethodDef arch_methods[] = {
+    {"arch_type", psi_arch_type, METH_NOARGS,
+     PyDoc_STR("Return an object representing the current architecture type")},
+    {NULL, NULL, 0, NULL}        /* Sentinel */
+};
+
+
+#ifdef PY3K
+static struct PyModuleDef moduledef = {
+        PyModuleDef_HEAD_INIT,  /* m_base */
+        MODULE_NAME,            /* m_name */
+        MODULE_DOC,             /* m_doc */
+        -1,                     /* m_size */
+        arch_methods,           /* m_methods */
+        NULL,                   /* m_reload */
+        NULL,                   /* m_traverse */
+        NULL,                   /* m_clear */
+        NULL                    /* m_free */
+};
+#endif
+
+
+/* Some defines to make the module init function readable */
+#ifdef PY3K
+#define MODFUNC PyInit_arch
+#define RETURN(VAR) return VAR
+#else
+#define MODFUNC initarch
+#define RETURN(VAR) return
+#endif
+
+
+/* Returns the psi.arch module */
+PyMODINIT_FUNC
+MODFUNC(void)
+{
+    PyObject *mod = NULL;
+
+    if (prepare_types() < 0)
+        RETURN(NULL);
+    if (init_exceptions() < 0)
+        goto error;
+#ifdef PY3K
+    mod = PyModule_Create(&moduledef);
+#else
+    mod = Py_InitModule3(MODULE_NAME, arch_methods, MODULE_DOC);
+#endif
+    if (mod == NULL)
+        goto error;
+    if (add_module_objects(mod) < 0)
+        goto error;
+    RETURN(mod);
+
+  error:
+    Py_XDECREF(mod);
+    Py_XDECREF(PsiExc_AttrNotAvailableError);
+    Py_XDECREF(PsiExc_AttrInsufficientPrivsError);
+    Py_XDECREF(PsiExc_AttrNotImplementedError);
+    Py_DECREF(&PsiArchBase_Type);
+    Py_DECREF(&PsiArchLinux_Type);
+    Py_DECREF(&PsiArchSunOS_Type);
+    Py_DECREF(&PsiArchDarwin_Type);
+    Py_DECREF(&PsiArchAIX_Type);
+    RETURN(NULL);
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/mount.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/mount.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/mount.c
new file mode 100644
index 0000000..422c313
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/mount.c
@@ -0,0 +1,502 @@
+/* The MIT License
+ *
+ * Copyright (C) 2009 Erick Tryzelaar
+ *
+ * Copyright (C) 2009 Floris Bruynooghe
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/** psi.mount.Mount* classes
+ *
+ * This file contains the common support for the psi.mount.Mount classes and
+ * factory functions.
+ */
+
+
+#include <Python.h>
+
+#include "psi.h"
+#include "mount.h"
+#include "posix_utils.h"
+
+
+/* The Python MountBase object */
+typedef struct {
+    PyObject_HEAD
+    psi_mountinfo_t *mounti;
+} PsiMountBaseObject;
+
+
+/* Helper functions */
+
+
+/* Always returns NULL */
+void *
+psi_free_mountinfo(psi_mountinfo_t *mounti)
+{
+    psi_FREE(mounti->mount_type);
+    psi_FREE(mounti->mount_options);
+    psi_FREE(mounti->mount_path);
+    psi_FREE(mounti->filesystem_host);
+    psi_FREE(mounti->filesystem_path);
+    psi_free(mounti);
+    return NULL;
+}
+
+
+/* Always returns NULL */
+void *
+psi_free_mountlist(psi_mountlist_t *mountlist)
+{
+    int i;
+
+    for (i = 0; i < mountlist->count; ++i) {
+        if (mountlist->mounts[i] != NULL) {
+            psi_free_mountinfo(mountlist->mounts[i]);
+        }
+    }
+    psi_free(mountlist->mounts);
+    psi_free(mountlist);
+    return NULL;
+}
+
+
+/* MountBase methods */
+
+
+static void
+MountBase_dealloc(PsiMountBaseObject *self)
+{
+    if (self->mounti != NULL) {
+        psi_free_mountinfo(self->mounti);
+    }
+    Py_TYPE(self)->tp_free((PyObject*)self);
+}
+
+
+static PyObject *
+MountBase_repr(PsiMountBaseObject *self)
+{
+    return PyStr_FromFormat("%s()", Py_TYPE(self)->tp_name);
+}
+
+
+/** Check if object is initialised */
+static int
+check_init(PsiMountBaseObject *obj)
+{
+    if (obj->mounti == NULL) {
+        PyErr_SetString(PyExc_RuntimeError,
+                        "Instance has not been initialised properly");
+        return -1;
+    }
+    return 0;
+}
+
+
+static PyObject *
+MountBase_get_fstype(PsiMountBaseObject *self)
+{
+    if (check_init(self) == -1)
+        return NULL;
+    if (psi_checkattr("Mount.fstype", self->mounti->mount_type_status) < 0)
+        return NULL;
+    return PyStr_FromString(self->mounti->mount_type);
+}
+
+
+static PyObject *
+MountBase_get_options(PsiMountBaseObject *self)
+{
+    if (check_init(self) == -1)
+        return NULL;
+    if (psi_checkattr("Mount.options",
+                      self->mounti->mount_options_status) < 0)
+        return NULL;
+    return PyStr_FromString(self->mounti->mount_options);
+}
+
+
+static PyObject *
+MountBase_get_mountpoint(PsiMountBaseObject *self)
+{
+    if (check_init(self) == -1)
+        return NULL;
+    if (psi_checkattr("Mount.mountpoint", self->mounti->mount_path_status) < 0)
+        return NULL;
+    return PyStr_FromString(self->mounti->mount_path);
+}
+
+
+static PyObject *
+MountBase_get_device(PsiMountBaseObject *self)
+{
+    if (check_init(self) == -1)
+        return NULL;
+    if (psi_checkattr("Mount.device", self->mounti->filesystem_path_status) < 0)
+        return NULL;
+    return PyStr_FromString(self->mounti->filesystem_path);
+}
+
+
+static PyObject *
+MountBase_get_total(PsiMountBaseObject *self, void *closure)
+{
+    PyObject *fr = NULL;
+    PyObject *tot = NULL;
+    PyObject *r = NULL;
+
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Mount.total", self->mounti->frsize_status) < 0 ||
+        psi_checkattr("Mount.total", self->mounti->total_status) < 0)
+        return NULL;
+    fr = PyLong_FromUnsignedLong(self->mounti->frsize);
+    if (fr == NULL)
+        goto end;
+    tot = PyLong_FromUnsignedLong(self->mounti->total);
+    if (tot == NULL)
+        goto end;
+    r = PyNumber_Multiply(fr, tot);
+
+  end:
+    Py_XDECREF(fr);
+    Py_XDECREF(tot);
+    return r;
+}
+
+
+static PyObject *
+MountBase_get_free(PsiMountBaseObject *self, void *closure)
+{
+    PyObject *fr = NULL;
+    PyObject *free = NULL;
+    PyObject *r = NULL;
+
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Mount.free", self->mounti->frsize_status) < 0 ||
+        psi_checkattr("Mount.free", self->mounti->ffree_status) < 0)
+        return NULL;
+    fr = PyLong_FromUnsignedLong(self->mounti->frsize);
+    if (fr == NULL)
+        goto end;
+    free = PyLong_FromUnsignedLong(self->mounti->ffree);
+    if (free == NULL)
+        goto end;
+    r = PyNumber_Multiply(fr, free);
+
+  end:
+    Py_XDECREF(fr);
+    Py_XDECREF(free);
+    return r;
+}
+
+
+static PyObject *
+MountBase_get_avail(PsiMountBaseObject *self, void *closure)
+{
+    PyObject *fr = NULL;
+    PyObject *avail = NULL;
+    PyObject *r = NULL;
+
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Mount.available", self->mounti->frsize_status) < 0 ||
+        psi_checkattr("Mount.available", self->mounti->favail_status) < 0)
+        return NULL;
+    fr = PyLong_FromUnsignedLong(self->mounti->frsize);
+    if (fr == NULL)
+        goto end;
+    avail = PyLong_FromUnsignedLong(self->mounti->favail);
+    if (avail == NULL)
+        goto end;
+    r = PyNumber_Multiply(fr, avail);
+
+  end:
+    Py_XDECREF(fr);
+    Py_XDECREF(avail);
+    return r;
+}
+
+
+static PyObject *
+MountBase_get_inodes(PsiMountBaseObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Mount.inodes", self->mounti->files_status) < 0)
+        return NULL;
+    return PyLong_FromUnsignedLong(self->mounti->files);
+}
+
+
+static PyObject *
+MountBase_get_free_inodes(PsiMountBaseObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Mount.free_inodes", self->mounti->ffree_status) < 0)
+        return NULL;
+    return PyLong_FromUnsignedLong(self->mounti->ffree);
+}
+
+
+static PyObject *
+MountBase_get_available_inodes(PsiMountBaseObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Mount.available_inodes", self->mounti->favail_status)<0)
+        return NULL;
+    return PyLong_FromUnsignedLong(self->mounti->favail);
+}
+
+
+static PyObject *
+MountBase_refresh(PsiMountBaseObject *self)
+{
+    psi_mountlist_t *mountlist;
+    psi_mountinfo_t *mounti;
+    int remote = 0;
+    int i;
+
+    if (PyObject_IsInstance((PyObject *)self, (PyObject *)&RemoteMount_Type))
+        remote = 1;
+    mountlist = psi_arch_mountlist(remote);
+    if (mountlist == NULL)
+        return NULL;
+    for (i = 0; i < mountlist->count; i++) {
+        mounti = mountlist->mounts[i];
+        if (strcmp(self->mounti->mount_path, mounti->mount_path) == 0 &&
+            strcmp(self->mounti->filesystem_path, mounti->filesystem_path) == 0)
+            break;
+    }
+    psi_free_mountinfo(self->mounti);
+    self->mounti = mounti;
+    mountlist->mounts[i] = NULL;
+    psi_free_mountlist(mountlist);
+    Py_RETURN_NONE;
+}
+
+
+static PyGetSetDef MountBase_getseters[] = {
+    {"fstype", (getter)MountBase_get_fstype, (setter)NULL,
+     "Type of the filesystem", NULL},
+    {"options", (getter)MountBase_get_options, (setter)NULL,
+     "Mount options", NULL},
+    {"mountpoint", (getter)MountBase_get_mountpoint, (setter)NULL,
+     "Where this filesystem is mounted on the filesystem hierarchy", NULL},
+    {"device", (getter)MountBase_get_device, (setter)NULL,
+     "Filesystem path", NULL},
+    {"total", (getter)MountBase_get_total, (setter)NULL,
+     "Total filesystem size in bytes", NULL},
+    {"free", (getter)MountBase_get_free, (setter)NULL,
+     "Free filesystem size in bytes", NULL},
+    {"available", (getter)MountBase_get_avail, (setter)NULL,
+     "Available filesystem size in bytes, i.e. free space for non-root", NULL},
+    {"inodes", (getter)MountBase_get_inodes, (setter)NULL,
+     "Number of inodes", NULL},
+    {"free_inodes", (getter)MountBase_get_free_inodes, (setter)NULL,
+     "Number of free inodes", NULL},
+    {"available_inodes", (getter)MountBase_get_available_inodes, (setter)NULL,
+     "Number of available nodes, i.e. free inodes for non-root", NULL},
+    {NULL}                      /* Sentinel */
+};
+
+
+static PyMethodDef MountBase_methods[] = {
+    {"refresh", (PyCFunction)MountBase_refresh, METH_NOARGS,
+     PyDoc_STR("Refresh the attributes with recent data")},
+    {NULL}                      /* Sentinel */
+};
+
+
+PyTypeObject MountBase_Type = {
+    PyVarObject_HEAD_INIT(NULL, 0)
+    "psi.mount.Mount",                        /* tp_name */
+    sizeof(PsiMountBaseObject),               /* tp_basicsize */
+    0,                                        /* tp_itemsize */
+    /* methods */
+    (destructor)MountBase_dealloc,            /* tp_dealloc */
+    0,                                        /* tp_print */
+    0,                                        /* tp_getattr */
+    0,                                        /* tp_setattr */
+    0,                                        /* tp_compare */
+    (reprfunc)MountBase_repr,                 /* tp_repr */
+    0,                                        /* tp_as_number */
+    0,                                        /* tp_as_sequence */
+    0,                                        /* tp_as_mapping */
+    0,                                        /* tp_hash */
+    0,                                        /* tp_call */
+    0,                                        /* tp_str */
+    0,                                        /* tp_getattro */
+    0,                                        /* tp_setattro */
+    0,                                        /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+    "Base object for all mount classes",      /* tp_doc */
+    0,                                        /* tp_traverse */
+    0,                                        /* tp_clear */
+    0,                                        /* tp_richcompare */
+    0,                                        /* tp_weaklistoffset */
+    0,                                        /* tp_iter */
+    0,                                        /* tp_iternext */
+    MountBase_methods,                        /* tp_methods */
+    0,                                        /* tp_members */
+    MountBase_getseters,                      /* tp_getset */
+    0,                                        /* tp_base */
+    0,                                        /* tp_dict */
+    0,                                        /* tp_descr_get */
+    0,                                        /* tp_descr_set */
+    0,                                        /* tp_dictoffset */
+    0,                                        /* tp_init */
+    0,                                        /* tp_alloc */
+    0,                                        /* tp_new */
+};
+
+
+PyTypeObject LocalMount_Type = {
+    PyVarObject_HEAD_INIT(NULL, 0)
+    "psi.mount.LocalMount",                   /* tp_name */
+    sizeof(PsiMountBaseObject),               /* tp_basicsize */
+    0,                                        /* tp_itemsize */
+    /* methods */
+    0,                                        /* tp_dealloc */
+    0,                                        /* tp_print */
+    0,                                        /* tp_getattr */
+    0,                                        /* tp_setattr */
+    0,                                        /* tp_compare */
+    0,                                        /* tp_repr */
+    0,                                        /* tp_as_number */
+    0,                                        /* tp_as_sequence */
+    0,                                        /* tp_as_mapping */
+    0,                                        /* tp_hash */
+    0,                                        /* tp_call */
+    0,                                        /* tp_str */
+    0,                                        /* tp_getattro */
+    0,                                        /* tp_setattro */
+    0,                                        /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+    "This object represents a local mountpoint", /* tp_doc */
+    0,                                        /* tp_traverse */
+    0,                                        /* tp_clear */
+    0,                                        /* tp_richcompare */
+    0,                                        /* tp_weaklistoffset */
+    0,                                        /* tp_iter */
+    0,                                        /* tp_iternext */
+    0,                                        /* tp_methods */
+    0,                                        /* tp_members */
+    0,                                        /* tp_getset */
+    &MountBase_Type,                          /* tp_base */
+    0,                                        /* tp_dict */
+    0,                                        /* tp_descr_get */
+    0,                                        /* tp_descr_set */
+    0,                                        /* tp_dictoffset */
+    0,                                        /* tp_init */
+    0,                                        /* tp_alloc */
+    0,                                        /* tp_new */
+};
+
+
+static PyObject *
+RemoteMount_get_host(PsiMountBaseObject *self)
+{
+    if (check_init(self) == -1)
+        return NULL;
+    if (psi_checkattr("Mount.filesystem_host", self->mounti->filesystem_host_status) == -1)
+        return NULL;
+    return PyStr_FromString(self->mounti->filesystem_host);
+}
+
+
+static PyGetSetDef RemoteMount_getseters[] = {
+    {"host", (getter)RemoteMount_get_host, (setter)NULL,
+     "The host of the filesystem", NULL},
+    {NULL}  /* Sentinel */
+};
+
+
+PyTypeObject RemoteMount_Type = {
+    PyVarObject_HEAD_INIT(NULL, 0)
+    "psi.mount.RemoteMount",                  /* tp_name */
+    sizeof(PsiMountBaseObject),               /* tp_basicsize */
+    0,                                        /* tp_itemsize */
+    /* methods */
+    0,                                        /* tp_dealloc */
+    0,                                        /* tp_print */
+    0,                                        /* tp_getattr */
+    0,                                        /* tp_setattr */
+    0,                                        /* tp_compare */
+    0,                                        /* tp_repr */
+    0,                                        /* tp_as_number */
+    0,                                        /* tp_as_sequence */
+    0,                                        /* tp_as_mapping */
+    0,                                        /* tp_hash */
+    0,                                        /* tp_call */
+    0,                                        /* tp_str */
+    0,                                        /* tp_getattro */
+    0,                                        /* tp_setattro */
+    0,                                        /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+    "This object represents a remote mountpoint", /* tp_doc */
+    0,                                        /* tp_traverse */
+    0,                                        /* tp_clear */
+    0,                                        /* tp_richcompare */
+    0,                                        /* tp_weaklistoffset */
+    0,                                        /* tp_iter */
+    0,                                        /* tp_iternext */
+    0,                                        /* tp_methods */
+    0,                                        /* tp_members */
+    RemoteMount_getseters,                    /* tp_getset */
+    &MountBase_Type,                          /* tp_base */
+    0,                                        /* tp_dict */
+    0,                                        /* tp_descr_get */
+    0,                                        /* tp_descr_set */
+    0,                                        /* tp_dictoffset */
+    0,                                        /* tp_init */
+    0,                                        /* tp_alloc */
+    0,                                        /* tp_new */
+};
+
+
+/* Object Creation Functions */
+
+
+PyObject *
+PsiMount_New(psi_mountinfo_t *mounti)
+{
+    PsiMountBaseObject *self;
+
+    if (mounti == NULL) {
+        PyErr_SetString(PyExc_RuntimeError,
+                        "Instance has not been initialised properly");
+        return NULL;
+    }
+    if (mounti->filesystem_host == NULL)
+        self = (PsiMountBaseObject *)PyType_GenericNew(&LocalMount_Type,
+                                                       NULL, NULL);
+    else
+        self = (PsiMountBaseObject *)PyType_GenericNew(&RemoteMount_Type,
+                                                       NULL, NULL);
+    if (self != NULL)
+        self->mounti = mounti;
+    return (PyObject *)self;
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/mountmodule.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/mountmodule.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/mountmodule.c
new file mode 100644
index 0000000..c743bd2
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/mountmodule.c
@@ -0,0 +1,229 @@
+/* The MIT License
+ *
+ * Copyright (C) 2009 Erick Tryzelaar
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/* The psi.mount module */
+
+
+#include <Python.h>
+
+#include "psi.h"
+#include "mount.h"
+
+
+/* Declarations (we need these since we use -Wmissing-declarations) */
+#ifdef PY3K
+PyMODINIT_FUNC PyInit_mount(void);
+#else
+PyMODINIT_FUNC initmount(void);
+#endif
+
+
+/* Re-declare these as non-extern since we're providing the symbols */
+PyObject *PsiExc_AttrNotAvailableError = NULL;
+PyObject *PsiExc_AttrInsufficientPrivsError = NULL;
+PyObject *PsiExc_AttrNotImplementedError = NULL;
+
+
+/* More contstants */
+static char MODULE_NAME[] = "psi.mount";
+PyDoc_STRVAR(MODULE_DOC, "Module for system mount information");
+
+
+PyDoc_STRVAR(psi_mount_mounts__doc, "\
+mounts(remote=False) -> iterator\n\
+\n\
+Return an iterator containing ojects representing mounted filesystems.  The\n\
+remote argument is a boolean value that can be used to control if remote\n\
+filesystems should be included or not.  Remote filesystems might take longer\n\
+to be created or suffer from timeouts collecting information from them.\n\
+");
+static PyObject *
+psi_mount_mounts(PyObject *self, PyObject *args, PyObject *kwds)
+{
+    static char *kwlist[] = {"remote", NULL};
+    psi_mountlist_t *mountlist;
+    PyObject *mount;
+    PyObject *list;
+    PyObject *iter;
+    ssize_t i;
+    int remote = 0;
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwds, "|i", kwlist, &remote))
+        return NULL;
+    mountlist = psi_arch_mountlist(remote);
+    if (mountlist == NULL)
+        return NULL;
+    list = PyList_New(mountlist->count);
+    if (list == NULL)
+        return psi_free_mountlist(mountlist);
+    for (i = 0; i < mountlist->count; ++i) {
+        mount = PsiMount_New(mountlist->mounts[i]);
+        if (mount == NULL) {
+            Py_DECREF(list);
+            return psi_free_mountlist(mountlist);
+        }
+        PyList_SET_ITEM(list, i, mount);
+
+        /* Python now owns the mountinfo, so clear it from the list. */
+        mountlist->mounts[i] = NULL;
+    }
+    psi_free_mountlist(mountlist);
+    iter = PySeqIter_New(list);
+    Py_DECREF(list);
+    return iter;
+}
+
+
+/** Finalise the types
+ *
+ * Calls PyType_Ready() and does anything else required.
+ */
+static int
+prepare_types(void)
+{
+    if (PyType_Ready(&MountBase_Type) < 0)
+        return -1;
+    if (PyType_Ready(&LocalMount_Type) < 0)
+        return -1;
+    if (PyType_Ready(&RemoteMount_Type) < 0)
+        return -1;
+    Py_INCREF(&MountBase_Type);
+    Py_INCREF(&LocalMount_Type);
+    Py_INCREF(&RemoteMount_Type);
+    return 0;
+}
+
+
+/** Initialise the global exceptions
+ *
+ * If this function fails the modinit function will Py_XDECREF the exceptions,
+ * so no need to do that here.
+ */
+static int
+init_exceptions(void)
+{
+    PyObject *_psimod;
+
+    _psimod = PyImport_ImportModule("psi._psi");
+    if (_psimod == NULL)
+        return -1;
+    PsiExc_AttrNotAvailableError = PyObject_GetAttrString(
+        _psimod, "AttrNotAvailableError");
+    if (PsiExc_AttrNotAvailableError == NULL)
+        goto error;
+    PsiExc_AttrInsufficientPrivsError = PyObject_GetAttrString(
+        _psimod, "AttrInsufficientPrivsError");
+    if (PsiExc_AttrInsufficientPrivsError == NULL)
+        goto error;
+    PsiExc_AttrNotImplementedError = PyObject_GetAttrString(
+        _psimod, "AttrNotImplementedError");
+    if (PsiExc_AttrNotImplementedError == NULL)
+        goto error;
+    Py_DECREF(_psimod);
+    return 0;
+
+  error:
+    Py_DECREF(_psimod);
+    return -1;
+}
+
+
+/* Add all the objects to the module */
+static int
+add_module_objects(PyObject *mod)
+{
+    if (PyModule_AddObject(mod, "MountBase", (PyObject *)&MountBase_Type) < 0)
+        return -1;
+    if (PyModule_AddObject(mod, "LocalMount", (PyObject *)&LocalMount_Type) < 0)
+        return -1;
+    if (PyModule_AddObject(mod, "RemoteMount", (PyObject *)&RemoteMount_Type) < 0)
+        return -1;
+    return 0;
+}
+
+
+static PyMethodDef mount_methods[] = {
+    {"mounts", (PyCFunction)psi_mount_mounts, METH_VARARGS | METH_KEYWORDS,
+     psi_mount_mounts__doc},
+    {NULL, NULL, 0, NULL}        /* Sentinel */
+};
+
+
+#ifdef PY3K
+static struct PyModuleDef moduledef = {
+        PyModuleDef_HEAD_INIT,  /* m_base */
+        MODULE_NAME,            /* m_name */
+        MODULE_DOC,             /* m_doc */
+        -1,                     /* m_size */
+        mount_methods,          /* m_methods */
+        NULL,                   /* m_reload */
+        NULL,                   /* m_traverse */
+        NULL,                   /* m_clear */
+        NULL                    /* m_free */
+};
+#endif
+
+
+/* Some defines to make the module init function readable */
+#ifdef PY3K
+#define MODFUNC PyInit_mount
+#define RETURN(VAR) return VAR
+#else
+#define MODFUNC initmount
+#define RETURN(VAR) return
+#endif
+
+
+/* Returns the psi.mount module */
+PyMODINIT_FUNC
+MODFUNC(void)
+{
+    PyObject *mod = NULL;
+
+    if (prepare_types() < 0)
+        RETURN(NULL);
+    if (init_exceptions() < 0)
+        goto error;
+#ifdef PY3K
+    mod = PyModule_Create(&moduledef);
+#else
+    mod = Py_InitModule3(MODULE_NAME, mount_methods, MODULE_DOC);
+#endif
+    if (mod == NULL)
+        goto error;
+    if (add_module_objects(mod) < 0)
+        goto error;
+    PyErr_WarnEx(PyExc_FutureWarning, "Experimental API", 1);
+    RETURN(mod);
+
+error:
+    Py_XDECREF(mod);
+    Py_XDECREF(PsiExc_AttrNotAvailableError);
+    Py_XDECREF(PsiExc_AttrInsufficientPrivsError);
+    Py_XDECREF(PsiExc_AttrNotImplementedError);
+    Py_XDECREF(&MountBase_Type);
+    Py_XDECREF(&LocalMount_Type);
+    Py_XDECREF(&RemoteMount_Type);
+    RETURN(NULL);
+}


[05/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code

Posted by rl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test87.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test87.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test87.py
new file mode 100644
index 0000000..42f4062
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test87.py
@@ -0,0 +1,56 @@
+'test use of True/False'
+
+True = 1
+False = 0
+
+true = 1
+false = 0
+
+TRUE = 1
+FALSE = 0
+
+def x(a):
+    'should warn'
+    if a == TRUE:
+        print 'True'
+    if a == TRUE or \
+       a == True or \
+       a == true:
+        print 'True'
+    if a != false:
+        print 'false'
+    if a is 'false':
+        print 'false'
+    if a is 'True':
+        print 'True'
+    if a is 53343:
+        print '53343'
+    if a is 1e7:
+        print '1e7'
+    if a is not 'false':
+        print 'false'
+    if a is not 'True':
+        print 'True'
+    if a is not 53343:
+        print '53343'
+    if a is not 1e7:
+        print '1e7'
+
+def y(a):
+    'should not warn'
+    if a is True:
+        print 'True'
+    if a is not false:
+        print 'false'
+    if a == 53343:
+        print '53343'
+    if a == 1e7:
+        print '1e7'
+    if a == 'TRUE' or \
+       a == 'True' or \
+       a == 'true':
+        print 'True'
+
+def z(a):
+    return True
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test88.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test88.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test88.py
new file mode 100644
index 0000000..e4e2a04
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test88.py
@@ -0,0 +1,23 @@
+'''
+test depreacted modules (and functions in modules)
+also test functions w/security implications
+'''
+
+import os
+import gopherlib
+import string
+
+try:
+    import whrandom
+except ImportError:
+    pass
+
+def t1():
+    'get rid of warnings about not using deprecated modules'
+    print whrandom, gopherlib
+
+def t2():
+    print os.tempnam()
+    print os.tmpnam()
+    print os.name
+    print string.atof('5')

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test89.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test89.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test89.py
new file mode 100644
index 0000000..8f3fa11
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test89.py
@@ -0,0 +1,8 @@
+'doc'
+
+class Newbie(object):
+    '''__coerce__ is problematic in new style classes,
+    see http://python.org/sf/547211
+    '''
+    def __coerce__(self, o): pass
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test9.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test9.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test9.py
new file mode 100644
index 0000000..e104f5b
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test9.py
@@ -0,0 +1,17 @@
+
+"doc"
+
+import getopt
+
+def func():
+    "re-importing getopt should complain"
+    import getopt
+    print getopt
+
+def test():
+    "this should fail (there is no getopt.xyz)"
+    try:
+        print ""
+    except getopt.xyz:
+        pass
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test90.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test90.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test90.py
new file mode 100644
index 0000000..7e2ff5c
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test90.py
@@ -0,0 +1,22 @@
+'test using is/is not on literals'
+
+def x(a, b, c):
+    print a is 1
+    print a is 's'
+    print a is 1.32
+    print a is ()
+    print a is []
+    print a is {}
+    print a is b
+    print b is c
+    print b is None
+
+    print a is not 1
+    print a is not 's'
+    print a is not 1.32
+    print a is not ()
+    print a is not []
+    print a is not {}
+    print a is not b
+    print b is not c
+    print b is not None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test92.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test92.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test92.py
new file mode 100644
index 0000000..23b5ff1
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test92.py
@@ -0,0 +1,6 @@
+'''test using locals in module scope works and there are no spurious warnings'''
+
+w = '%(u)s'
+u = 'a'
+result = w % locals()
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test93.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test93.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test93.py
new file mode 100644
index 0000000..97edddf
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test93.py
@@ -0,0 +1,11 @@
+'docstring'
+
+def x(a, b):
+    c = getattr(a, b)
+    c = getattr(a, b, None)
+    c = getattr(a, 'c')
+    c = getattr(a, 'c', None)
+    print c
+
+    setattr(a, b, None)
+    setattr(a, 'b', None)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test94.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test94.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test94.py
new file mode 100644
index 0000000..2d674ae
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test94.py
@@ -0,0 +1,54 @@
+'docstring'
+
+def f(a):
+    a = a
+    a.b = a.b
+    a.b.c = a.b.c
+    a.b.c.d = a.b.c.d
+    c = a & a
+    c = a | a
+    c = a.b | a.b
+    c = a.b.c | a.b.c
+    c = a ^ a
+    c = a.b ^ a.b
+    c = a.b.c ^ a.b.c
+    c = a / a
+    print c
+
+def g():
+    a = b = c = 1
+    a = a / 2.0
+    a /= 2.0
+    a = a + b
+    a = a & b
+    a = a << b
+    a = b << a
+    print c
+    a = str(a)
+    a = `a`
+    a = -a
+    a = ~a
+
+def h():
+  a = 1
+  a += a
+  a -= a
+  a *= a
+
+  a = not a
+  a = not not a
+
+  a = (1, 2, 3)
+  a, b, c = a
+
+def i(a):
+    z = hash(a.x) & hash(a.y)
+    z = hash(a.x) | hash(a.y)
+    z = hash(a.x) ^ hash(a.y)
+    return z
+
+def j(x, y):
+    return (x + 1.0) / (y + 2.0)
+
+def k(d):
+    return ((1 << d) | (1 << ((d+4) % 8)))

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test95.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test95.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test95.py
new file mode 100644
index 0000000..a2e4d83
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test95.py
@@ -0,0 +1,5 @@
+'docstring'
+
+def try_uni():
+    word = "a"
+    return u"%s \N{RIGHTWARDS ARROW}" % word

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test96.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test96.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test96.py
new file mode 100644
index 0000000..8e04759
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test96.py
@@ -0,0 +1,15 @@
+'''test using string.find() in if statement as a boolean.  it returns an int'''
+
+class X:
+  '''check string.find() usage'''
+  def foo(self):
+    s = 'abc'
+    if s.find('ab'):
+       print 'this is a bug'
+    if not s.find('ab'):
+       print 'this is also a bug'
+    if s.find('ab') >= 0:
+       print 'this is not a bug'
+    if s.find('ab') < 0:
+       print 'this also is not a bug'
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test97.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test97.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test97.py
new file mode 100644
index 0000000..29a62ba
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test97.py
@@ -0,0 +1,20 @@
+# -*- encoding: latin-1 -*-
+
+__doc__ = 'nested scopes test'
+
+u"Bl\ufffdb\ufffdrgr\ufffdd".upper()
+
+try:
+    from cStringIO import StringIO
+except ImportError:
+    # this shouldn't cause a warning about catching string exceptions
+    pass
+
+def call(proc, y):
+    proc(y)
+
+def fun():
+    def setfooattr(x, y):
+        call(lambda z: setattr(x, 'foo', z), y)
+
+    setfooattr(Exception(), 'bar')

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test98.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test98.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test98.py
new file mode 100644
index 0000000..3a3bb5a
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test98.py
@@ -0,0 +1,33 @@
+# -*- encoding: latin-1 -*-
+
+__doc__ = 'return value from init reports proper file names'
+
+from import98 import BaseGood, BaseBad
+
+class GoodGood(BaseGood):
+    'doc'
+    def __init__(self):
+        BaseGood.__init__(self)
+
+class GoodBad(BaseGood):
+    'doc'
+    def __init__(self):
+        return BaseGood.__init__(self)
+
+class GoodVoid(BaseGood):
+    'doc'
+    pass
+
+class BadGood(BaseBad):
+    'doc'
+    def __init__(self):
+        BaseBad.__init__(self)
+
+class BadBad(BaseBad):
+    'doc'
+    def __init__(self):
+        return BaseBad.__init__(self)
+
+class BadVoid(BaseBad):
+    'doc'
+    pass

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test99.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test99.py b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test99.py
new file mode 100644
index 0000000..d4a9c83
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/test_input/test99.py
@@ -0,0 +1,22 @@
+"""None of these should blow up."""
+
+class Foo:
+  """Base class to call during test"""
+  def __init__(self, *args, **kwargs): pass
+
+A = B = C = D = 1
+
+class AndBar(Foo):
+  """Base class to call during test"""
+  def __init__(self):
+    Foo.__init__(self, style = A & B & C & D)
+
+class OrBar(Foo):
+  """Base class to call during test"""
+  def __init__(self):
+    Foo.__init__(self, style = A | B | C | D)
+
+class XorBar(Foo):
+  """Base class to call during test"""
+  def __init__(self):
+    Foo.__init__(self, style = A ^ B ^ C ^ D)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/PKG-INFO
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/PKG-INFO b/tools/bin/pythonSrc/unittest2-0.5.1/PKG-INFO
new file mode 100644
index 0000000..b0a8ca2
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/PKG-INFO
@@ -0,0 +1,321 @@
+Metadata-Version: 1.0
+Name: unittest2
+Version: 0.5.1
+Summary: The new features in unittest for Python 2.7 backported to Python 2.3+.
+Home-page: http://pypi.python.org/pypi/unittest2
+Author: Michael Foord
+Author-email: michael@voidspace.org.uk
+License: UNKNOWN
+Description: unittest2 is a backport of the new features added to the unittest testing
+        framework in Python 2.7. It is tested to run on Python 2.4 - 2.7.
+        
+        Thanks to Mark Roddy, there is also a version of for Python 2.3. This is
+        maintained as a separate branch and is a separate download.
+        
+        To use unittest2 instead of unittest simply replace ``import unittest`` with
+        ``import unittest2``.
+        
+        unittest2 is maintained in a mercurial repository. The issue tracker is on
+        google code:
+        
+        * `unittest2 hg <http://hg.python.org/unittest2>`_
+        * `unittest2 issue tracker
+          <http://code.google.com/p/unittest-ext/issues/list>`_
+        * `Article / Docs: New features in unittest
+          <http://www.voidspace.org.uk/python/articles/unittest2.shtml>`_
+        
+        
+        Classes in unittest2 derive from the appropriate classes in unittest, so it
+        should be possible to use the unittest2 test running infrastructure without
+        having to switch all your tests to using unittest2 immediately. Similarly
+        you can use the new assert methods on ``unittest2.TestCase`` with the standard
+        unittest test running infrastructure. Not all of the new features in unittest2
+        will work with the standard unittest test loaders, runners result objects
+        however.
+        
+        New features include:
+        
+        * ``addCleanups`` - better resource management
+        * *many* new assert methods including better defaults for comparing lists,
+          sets, dicts unicode strings etc and the ability to specify new default methods
+          for comparing specific types
+        * ``assertRaises`` as context manager, with access to the exception afterwards 
+        * test discovery and new command line options (including failfast and better
+          handling of ctrl-C during test runs)
+        * class and module level fixtures: ``setUpClass``, ``tearDownClass``,
+          ``setUpModule``, ``tearDownModule``
+        * test skipping and expected failures
+        * new ``delta`` keyword argument to ``assertAlmostEqual`` for more useful
+          comparison and for comparing non-numeric objects (like datetimes)
+        * ``load_tests`` protocol for loading tests from modules or packages 
+        * ``startTestRun`` and ``stopTestRun`` methods on TestResult
+        * various other API improvements and fixes
+        
+        .. note:: Command line usage
+        
+            In Python 2.7 you invoke the unittest command line features (including test
+            discover) with ``python -m unittest <args>``. As unittest is a package, and
+            the ability to invoke packages with ``python -m ...`` is new in Python 2.7,
+            we can't do this for unittest2.
+            
+            Instead unittest2 comes with a script ``unit2``. 
+            `Command line usage
+            <http://docs.python.org/dev/library/unittest.html#command-line-interface>`_::
+            
+                unit2 discover
+                unit2 -v test_module
+            
+            There is also a copy of this script called ``unit2.py``, useful for Windows
+            which uses file-extensions rather than shebang lines to determine what
+            program to execute files with. Both of these scripts are installed by
+            distutils.
+        
+        Until I write proper documentation, the best information on all the new features
+        is the development version of the Python documentation for Python 2.7:
+        
+        * http://docs.python.org/dev/library/unittest.html
+        
+        Look for notes about features added or changed in Python 2.7.
+        
+        .. note::
+        
+            unittest2 is already in use for development of`distutils2
+            <http://hg.python.org/distutils2>`_.
+            
+            Version 0.5.0 of unittest2 has feature parity with unittest_ in Python 2.7
+            final. If you want to ensure that your tests run identically under unittest2
+            and unittest in Python 2.7 you should use unittest2 0.5.0.
+            
+            Later versions of unittest2 include changes in unittest made in Python 3.2
+            and onwards after the release of Python 2.7.
+        
+        
+        .. _unittest: http://docs.python.org/release/2.7/library/unittest.html
+        
+        
+        Differences
+        ===========
+        
+        Differences between unittest2 and unittest in Python 2.7:
+        
+        ``assertItemsEqual`` does not silence Py3k warnings as this uses
+        ``warnings.catch_warnings()`` which is new in Python 2.6 (and is used as a
+        context manager which would be a pain to make work with Python 2.4).
+        
+        The underlying dictionary storing the type equality functions on TestCase is a
+        custom object rather than a real dictionary. This allows TestCase instances to
+        be deep-copyable on Python versions prior to 2.7.
+        
+        ``TestCase.longMessage`` defaults to True because it is better. It defaults to
+        False in Python 2.7 for backwards compatibility reasons.
+        
+        ``python -m package`` doesn't work in versions of Python before Python 2.7. The
+        command line features of unittest2 are provided by a ``unit2`` (and 
+        ``unit2.py``) script instead.
+        
+        unittest2 includes a very basic setuptools compatible test collector. Specify
+        ``test_suite = 'unittest2.collector'`` in your setup.py. This starts test
+        discovery with the default parameters from the directory containing setup.py, so
+        it is perhaps most useful as an example (see unittest2/collector.py).
+        
+        
+        
+        Issues
+        ======
+        
+        A ``TestResult`` object with unexpected successes returns True
+        for ``result.wasSuccessful()``. Difficult to know if this is the correct
+        behaviour or not.
+        
+        If a dotted path name is used for test discovery then a globally installed
+        module/package will still be used in preference of one in the current
+        directory. When doing discovery from a dotted path name we could check for this
+        specific case.
+        
+        The ``removeHandler`` decorator could also be a context manager.
+        
+        `Issue 8313: <http://bugs.python.org/issue8313>`_, \<unprintable AssertionError object\>
+        message in unittest tracebacks, is hard to fix in versions of Python before 2.7.
+        The fix in Python 2.7 relies on changes to both the traceback module and
+        traceback objects. As the issue is rare I am leaving it unfixed in unittest2.
+        
+        There are several places in unittest2 (and unittest) that call ``str(...)`` on
+        exceptions to get the exception message. This can fail if the exception was
+        created with non-ascii unicode. This is rare and I won't address it unless it is
+        actually reported as a problem for someone.
+        
+        A comparison of text or long sequences (using ``assertSequenceEqual`` or
+        ``assertMultiLineEqual`` etc) can take a *long* time to generate diffs for
+        failure messages. These methods use ``prettyprint`` and ``difflib``.
+        
+        
+        CHANGELOG
+        =========
+        
+        2010/07/12 - 0.5.1
+        ------------------
+        
+        Reverted script names created by setuptools back to "unit2" instead of
+        "unit2.py". (Not necessary as setuptools creates stub .exes for console scripts
+        anyway.)
+        
+        
+        2010/07/11 - 0.5.0
+        ------------------
+        
+        Addition of a setuptools compatible test collector (very basic). Specify
+        ``test_suite = 'unittest2.collector'`` in your setup.py.
+        
+        ``TestSuite.debug()`` and ``TestCase.debug()`` now execute cleanup functions
+        and class and module level setups and teardowns.
+        
+        No longer monkey-patch os.path.relpath for Python 2.4 / 2.5 so that projects
+        don't accidentally depend on our patching. Contributed by Konrad Delong.
+        
+        Added a Python version specific unit2 entrypoint. This will, for example,
+        create a ``unit2-2.6`` script if unittest2 is installed with Python 2.6.
+        (Requires setuptools or distribute.)
+        
+        Python 2.3 compatibility (in the python2.3 branch of the repository),
+        contributed by Mark Roddy.
+        
+        setuptools console script entry points are created as '.py' scripts on Windows.
+        
+        Feature parity with the Python 2.7 final release.
+        
+        
+        2010/06/06 - 0.4.2
+        ------------------
+        
+        Improved help message for ``unit2 discover -h``.
+        
+        SkipTest in unittest.TestCase.setUpClass or setUpModule is now reported as a 
+        skip rather than an error.
+        
+        Excessively large diffs due to ``TestCase.assertSequenceEqual`` are no
+        longer included in failure reports. (Controlled by ``TestCase.maxDiff``.)
+        
+        Matching files during test discovery is done in ``TestLoader._match_path``. This
+        method can be overriden in subclasses to, for example, match on the full file
+        path or use regular expressions for matching.
+        
+        Addition of a setuptools compatible entrypoint for the unit2 test runner script.
+        Contributed by Chris Withers.
+        
+        Tests fixed to be compatible with Python 2.7, where deprecation warnings are
+        silenced by default.
+        
+        Feature parity with unittest in Python 2.7 RC 1.
+        
+        
+        2010/05/09 - 0.4.1
+        ------------------
+        
+        If test discovery imports a module from the wrong location (usually because the
+        module is globally installed and the user is expecting to run tests against a
+        development version in a different location) then discovery halts with an
+        ``ImportError`` and the problem is reported.
+        
+        Added docstrings to ``assertRegexpMatches`` and ``assertNotRegexpMatches``.
+        
+        Putting functions in test suites no longer crashes.
+        
+        Feature parity with unittest in Python 2.7 Beta 2.
+        
+        2010/04/08 - 0.4.0
+        ------------------
+        
+        Addition of ``removeHandler`` for removing the control-C handler.
+        
+        ``delta`` keyword argument for ``assertAlmostEqual`` and
+        ``assertNotAlmostEqual``.
+        
+        Addition of -b command line option (and ``TestResult.buffer``) for buffering 
+        stdout / stderr during test runs.
+        
+        Addition of ``TestCase.assertNotRegexpMatches``.
+        
+        Allow test discovery using dotted module names instead of a path.
+        
+        All imports requiring the signal module are now optional, for compatiblity
+        with IronPython (or other platforms without this module).
+        
+        Tests fixed to be compatible with nosetest.
+        
+        
+        2010/03/26 - 0.3.0
+        ------------------
+        
+        ``assertSameElements`` removed and ``assertItemsEqual`` added; assert that
+        sequences contain the same elements.
+        
+        Addition of -f/--failfast command line option, stopping test run on first
+        failure or error.
+        
+        Addition of -c/--catch command line option for better control-C handling during
+        test runs.
+        
+        Added ``BaseTestSuite``, for use by frameworks that don't want to support shared
+        class and module fixtures.
+        
+        Skipped test methods no longer have ``setUp`` and ``tearDown`` called around
+        them.
+        
+        Faulty ``load_tests`` functions no longer halt test discovery.
+        
+        Using non-strings for failure messages now works.
+        
+        Potential for ``UnicodeDecodeError`` whilst creating failure messages fixed.
+        
+        Split out monolithic test module into a package.
+        
+        BUGFIX: Correct usage message now shown for unit2 scripts.
+        
+        BUGFIX: ``__unittest`` in module globals trims frames from that module in
+        reported stacktraces.
+        
+        
+        2010/03/06 - 0.2.0
+        ------------------
+        
+        The ``TextTestRunner`` is now compatible with old result objects and standard
+        (non-TextTestResult) ``TestResult`` objects.
+        
+        ``setUpClass`` / ``tearDownClass`` / ``setUpModule`` / ``tearDownModule`` added.
+        
+        
+        2010/02/22 - 0.1.6
+        ------------------
+        
+        Fix for compatibility with old ``TestResult`` objects. New tests can now be run
+        with nosetests (with a DeprecationWarning for ``TestResult`` objects without
+        methods to support skipping etc).
+        
+        
+        0.1
+        ---
+        
+        Initial release.
+        
+        
+        TODO
+        ====
+        
+        * Document ``SkipTest``, ``BaseTestSuite```
+        
+Keywords: unittest,testing,tests
+Platform: UNKNOWN
+Classifier: Development Status :: 4 - Beta
+Classifier: Environment :: Console
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: BSD License
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2.3
+Classifier: Programming Language :: Python :: 2.4
+Classifier: Programming Language :: Python :: 2.5
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Operating System :: OS Independent
+Classifier: Topic :: Software Development :: Libraries
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
+Classifier: Topic :: Software Development :: Testing

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/README.txt
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/README.txt b/tools/bin/pythonSrc/unittest2-0.5.1/README.txt
new file mode 100644
index 0000000..27d8e68
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/README.txt
@@ -0,0 +1,296 @@
+unittest2 is a backport of the new features added to the unittest testing
+framework in Python 2.7. It is tested to run on Python 2.4 - 2.7.
+
+Thanks to Mark Roddy, there is also a version of for Python 2.3. This is
+maintained as a separate branch and is a separate download.
+
+To use unittest2 instead of unittest simply replace ``import unittest`` with
+``import unittest2``.
+
+unittest2 is maintained in a mercurial repository. The issue tracker is on
+google code:
+
+* `unittest2 hg <http://hg.python.org/unittest2>`_
+* `unittest2 issue tracker
+  <http://code.google.com/p/unittest-ext/issues/list>`_
+* `Article / Docs: New features in unittest
+  <http://www.voidspace.org.uk/python/articles/unittest2.shtml>`_
+
+
+Classes in unittest2 derive from the appropriate classes in unittest, so it
+should be possible to use the unittest2 test running infrastructure without
+having to switch all your tests to using unittest2 immediately. Similarly
+you can use the new assert methods on ``unittest2.TestCase`` with the standard
+unittest test running infrastructure. Not all of the new features in unittest2
+will work with the standard unittest test loaders, runners result objects
+however.
+
+New features include:
+
+* ``addCleanups`` - better resource management
+* *many* new assert methods including better defaults for comparing lists,
+  sets, dicts unicode strings etc and the ability to specify new default methods
+  for comparing specific types
+* ``assertRaises`` as context manager, with access to the exception afterwards 
+* test discovery and new command line options (including failfast and better
+  handling of ctrl-C during test runs)
+* class and module level fixtures: ``setUpClass``, ``tearDownClass``,
+  ``setUpModule``, ``tearDownModule``
+* test skipping and expected failures
+* new ``delta`` keyword argument to ``assertAlmostEqual`` for more useful
+  comparison and for comparing non-numeric objects (like datetimes)
+* ``load_tests`` protocol for loading tests from modules or packages 
+* ``startTestRun`` and ``stopTestRun`` methods on TestResult
+* various other API improvements and fixes
+
+.. note:: Command line usage
+
+    In Python 2.7 you invoke the unittest command line features (including test
+    discover) with ``python -m unittest <args>``. As unittest is a package, and
+    the ability to invoke packages with ``python -m ...`` is new in Python 2.7,
+    we can't do this for unittest2.
+    
+    Instead unittest2 comes with a script ``unit2``. 
+    `Command line usage
+    <http://docs.python.org/dev/library/unittest.html#command-line-interface>`_::
+    
+        unit2 discover
+        unit2 -v test_module
+    
+    There is also a copy of this script called ``unit2.py``, useful for Windows
+    which uses file-extensions rather than shebang lines to determine what
+    program to execute files with. Both of these scripts are installed by
+    distutils.
+
+Until I write proper documentation, the best information on all the new features
+is the development version of the Python documentation for Python 2.7:
+
+* http://docs.python.org/dev/library/unittest.html
+
+Look for notes about features added or changed in Python 2.7.
+
+.. note::
+
+    unittest2 is already in use for development of`distutils2
+    <http://hg.python.org/distutils2>`_.
+    
+    Version 0.5.0 of unittest2 has feature parity with unittest_ in Python 2.7
+    final. If you want to ensure that your tests run identically under unittest2
+    and unittest in Python 2.7 you should use unittest2 0.5.0.
+    
+    Later versions of unittest2 include changes in unittest made in Python 3.2
+    and onwards after the release of Python 2.7.
+
+
+.. _unittest: http://docs.python.org/release/2.7/library/unittest.html
+
+
+Differences
+===========
+
+Differences between unittest2 and unittest in Python 2.7:
+
+``assertItemsEqual`` does not silence Py3k warnings as this uses
+``warnings.catch_warnings()`` which is new in Python 2.6 (and is used as a
+context manager which would be a pain to make work with Python 2.4).
+
+The underlying dictionary storing the type equality functions on TestCase is a
+custom object rather than a real dictionary. This allows TestCase instances to
+be deep-copyable on Python versions prior to 2.7.
+
+``TestCase.longMessage`` defaults to True because it is better. It defaults to
+False in Python 2.7 for backwards compatibility reasons.
+
+``python -m package`` doesn't work in versions of Python before Python 2.7. The
+command line features of unittest2 are provided by a ``unit2`` (and 
+``unit2.py``) script instead.
+
+unittest2 includes a very basic setuptools compatible test collector. Specify
+``test_suite = 'unittest2.collector'`` in your setup.py. This starts test
+discovery with the default parameters from the directory containing setup.py, so
+it is perhaps most useful as an example (see unittest2/collector.py).
+
+
+
+Issues
+======
+
+A ``TestResult`` object with unexpected successes returns True
+for ``result.wasSuccessful()``. Difficult to know if this is the correct
+behaviour or not.
+
+If a dotted path name is used for test discovery then a globally installed
+module/package will still be used in preference of one in the current
+directory. When doing discovery from a dotted path name we could check for this
+specific case.
+
+The ``removeHandler`` decorator could also be a context manager.
+
+`Issue 8313: <http://bugs.python.org/issue8313>`_, \<unprintable AssertionError object\>
+message in unittest tracebacks, is hard to fix in versions of Python before 2.7.
+The fix in Python 2.7 relies on changes to both the traceback module and
+traceback objects. As the issue is rare I am leaving it unfixed in unittest2.
+
+There are several places in unittest2 (and unittest) that call ``str(...)`` on
+exceptions to get the exception message. This can fail if the exception was
+created with non-ascii unicode. This is rare and I won't address it unless it is
+actually reported as a problem for someone.
+
+A comparison of text or long sequences (using ``assertSequenceEqual`` or
+``assertMultiLineEqual`` etc) can take a *long* time to generate diffs for
+failure messages. These methods use ``prettyprint`` and ``difflib``.
+
+
+CHANGELOG
+=========
+
+2010/07/12 - 0.5.1
+------------------
+
+Reverted script names created by setuptools back to "unit2" instead of
+"unit2.py". (Not necessary as setuptools creates stub .exes for console scripts
+anyway.)
+
+
+2010/07/11 - 0.5.0
+------------------
+
+Addition of a setuptools compatible test collector (very basic). Specify
+``test_suite = 'unittest2.collector'`` in your setup.py.
+
+``TestSuite.debug()`` and ``TestCase.debug()`` now execute cleanup functions
+and class and module level setups and teardowns.
+
+No longer monkey-patch os.path.relpath for Python 2.4 / 2.5 so that projects
+don't accidentally depend on our patching. Contributed by Konrad Delong.
+
+Added a Python version specific unit2 entrypoint. This will, for example,
+create a ``unit2-2.6`` script if unittest2 is installed with Python 2.6.
+(Requires setuptools or distribute.)
+
+Python 2.3 compatibility (in the python2.3 branch of the repository),
+contributed by Mark Roddy.
+
+setuptools console script entry points are created as '.py' scripts on Windows.
+
+Feature parity with the Python 2.7 final release.
+
+
+2010/06/06 - 0.4.2
+------------------
+
+Improved help message for ``unit2 discover -h``.
+
+SkipTest in unittest.TestCase.setUpClass or setUpModule is now reported as a 
+skip rather than an error.
+
+Excessively large diffs due to ``TestCase.assertSequenceEqual`` are no
+longer included in failure reports. (Controlled by ``TestCase.maxDiff``.)
+
+Matching files during test discovery is done in ``TestLoader._match_path``. This
+method can be overriden in subclasses to, for example, match on the full file
+path or use regular expressions for matching.
+
+Addition of a setuptools compatible entrypoint for the unit2 test runner script.
+Contributed by Chris Withers.
+
+Tests fixed to be compatible with Python 2.7, where deprecation warnings are
+silenced by default.
+
+Feature parity with unittest in Python 2.7 RC 1.
+
+
+2010/05/09 - 0.4.1
+------------------
+
+If test discovery imports a module from the wrong location (usually because the
+module is globally installed and the user is expecting to run tests against a
+development version in a different location) then discovery halts with an
+``ImportError`` and the problem is reported.
+
+Added docstrings to ``assertRegexpMatches`` and ``assertNotRegexpMatches``.
+
+Putting functions in test suites no longer crashes.
+
+Feature parity with unittest in Python 2.7 Beta 2.
+
+2010/04/08 - 0.4.0
+------------------
+
+Addition of ``removeHandler`` for removing the control-C handler.
+
+``delta`` keyword argument for ``assertAlmostEqual`` and
+``assertNotAlmostEqual``.
+
+Addition of -b command line option (and ``TestResult.buffer``) for buffering 
+stdout / stderr during test runs.
+
+Addition of ``TestCase.assertNotRegexpMatches``.
+
+Allow test discovery using dotted module names instead of a path.
+
+All imports requiring the signal module are now optional, for compatiblity
+with IronPython (or other platforms without this module).
+
+Tests fixed to be compatible with nosetest.
+
+
+2010/03/26 - 0.3.0
+------------------
+
+``assertSameElements`` removed and ``assertItemsEqual`` added; assert that
+sequences contain the same elements.
+
+Addition of -f/--failfast command line option, stopping test run on first
+failure or error.
+
+Addition of -c/--catch command line option for better control-C handling during
+test runs.
+
+Added ``BaseTestSuite``, for use by frameworks that don't want to support shared
+class and module fixtures.
+
+Skipped test methods no longer have ``setUp`` and ``tearDown`` called around
+them.
+
+Faulty ``load_tests`` functions no longer halt test discovery.
+
+Using non-strings for failure messages now works.
+
+Potential for ``UnicodeDecodeError`` whilst creating failure messages fixed.
+
+Split out monolithic test module into a package.
+
+BUGFIX: Correct usage message now shown for unit2 scripts.
+
+BUGFIX: ``__unittest`` in module globals trims frames from that module in
+reported stacktraces.
+
+
+2010/03/06 - 0.2.0
+------------------
+
+The ``TextTestRunner`` is now compatible with old result objects and standard
+(non-TextTestResult) ``TestResult`` objects.
+
+``setUpClass`` / ``tearDownClass`` / ``setUpModule`` / ``tearDownModule`` added.
+
+
+2010/02/22 - 0.1.6
+------------------
+
+Fix for compatibility with old ``TestResult`` objects. New tests can now be run
+with nosetests (with a DeprecationWarning for ``TestResult`` objects without
+methods to support skipping etc).
+
+
+0.1
+---
+
+Initial release.
+
+
+TODO
+====
+
+* Document ``SkipTest``, ``BaseTestSuite```

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/setup.cfg
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/setup.cfg b/tools/bin/pythonSrc/unittest2-0.5.1/setup.cfg
new file mode 100644
index 0000000..3543f2d
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/setup.cfg
@@ -0,0 +1,8 @@
+[sdist]
+force-manifest = 1
+
+[egg_info]
+tag_build = 
+tag_date = 0
+tag_svn_revision = 0
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/setup.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/setup.py b/tools/bin/pythonSrc/unittest2-0.5.1/setup.py
new file mode 100755
index 0000000..8dffe49
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/setup.py
@@ -0,0 +1,85 @@
+#! /usr/bin/env python
+# setup.py
+# Install script for unittest2
+# Copyright (C) 2010 Michael Foord
+# E-mail: fuzzyman AT voidspace DOT org DOT uk
+
+# This software is licensed under the terms of the BSD license.
+# http://www.voidspace.org.uk/python/license.shtml
+
+import os
+import sys
+from unittest2 import __version__ as VERSION
+
+NAME = 'unittest2'
+
+PACKAGES = ['unittest2', 'unittest2.test']
+SCRIPTS = ['unit2.py', 'unit2']
+
+DESCRIPTION = ('The new features in unittest for Python 2.7 backported to '
+               'Python 2.3+.')
+
+URL = 'http://pypi.python.org/pypi/unittest2'
+
+readme = os.path.join(os.path.dirname(__file__), 'README.txt')
+LONG_DESCRIPTION = open(readme).read()
+
+CLASSIFIERS = [
+    'Development Status :: 4 - Beta',
+    'Environment :: Console',
+    'Intended Audience :: Developers',
+    'License :: OSI Approved :: BSD License',
+    'Programming Language :: Python',
+    'Programming Language :: Python :: 2.3',
+    'Programming Language :: Python :: 2.4',
+    'Programming Language :: Python :: 2.5',
+    'Programming Language :: Python :: 2.6',
+    'Programming Language :: Python :: 2.7',
+    'Operating System :: OS Independent',
+    'Topic :: Software Development :: Libraries',
+    'Topic :: Software Development :: Libraries :: Python Modules',
+    'Topic :: Software Development :: Testing',
+]
+
+AUTHOR = 'Michael Foord'
+
+AUTHOR_EMAIL = 'michael@voidspace.org.uk'
+
+KEYWORDS = "unittest testing tests".split(' ')
+
+
+params = dict(
+    name=NAME,
+    version=VERSION,
+    description=DESCRIPTION,
+    long_description=LONG_DESCRIPTION,
+    packages=PACKAGES,
+    scripts=SCRIPTS,
+    author=AUTHOR,
+    author_email=AUTHOR_EMAIL,
+    url=URL,
+    classifiers=CLASSIFIERS,
+    keywords=KEYWORDS
+)
+
+
+py_version = sys.version[:3]
+
+SCRIPT1 = 'unit2'
+SCRIPT2 = 'unit2-%s' % (py_version,)
+
+try:
+    from setuptools import setup
+except ImportError:
+    from distutils.core import setup
+else:
+    params['entry_points'] = {
+        'console_scripts': [
+            '%s = unittest2:main_' % SCRIPT1,
+            '%s = unittest2:main_' % SCRIPT2,
+        ],
+    }
+    
+    params['test_suite'] = 'unittest2.collector'
+
+setup(**params)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unit2
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unit2 b/tools/bin/pythonSrc/unittest2-0.5.1/unit2
new file mode 100755
index 0000000..6d84985
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unit2
@@ -0,0 +1,7 @@
+#! /usr/bin/env python
+
+__unittest = True
+
+from unittest2.main import main_
+
+main_()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unit2.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unit2.py b/tools/bin/pythonSrc/unittest2-0.5.1/unit2.py
new file mode 100644
index 0000000..6d84985
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unit2.py
@@ -0,0 +1,7 @@
+#! /usr/bin/env python
+
+__unittest = True
+
+from unittest2.main import main_
+
+main_()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2.egg-info/PKG-INFO
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2.egg-info/PKG-INFO b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2.egg-info/PKG-INFO
new file mode 100644
index 0000000..b0a8ca2
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2.egg-info/PKG-INFO
@@ -0,0 +1,321 @@
+Metadata-Version: 1.0
+Name: unittest2
+Version: 0.5.1
+Summary: The new features in unittest for Python 2.7 backported to Python 2.3+.
+Home-page: http://pypi.python.org/pypi/unittest2
+Author: Michael Foord
+Author-email: michael@voidspace.org.uk
+License: UNKNOWN
+Description: unittest2 is a backport of the new features added to the unittest testing
+        framework in Python 2.7. It is tested to run on Python 2.4 - 2.7.
+        
+        Thanks to Mark Roddy, there is also a version of for Python 2.3. This is
+        maintained as a separate branch and is a separate download.
+        
+        To use unittest2 instead of unittest simply replace ``import unittest`` with
+        ``import unittest2``.
+        
+        unittest2 is maintained in a mercurial repository. The issue tracker is on
+        google code:
+        
+        * `unittest2 hg <http://hg.python.org/unittest2>`_
+        * `unittest2 issue tracker
+          <http://code.google.com/p/unittest-ext/issues/list>`_
+        * `Article / Docs: New features in unittest
+          <http://www.voidspace.org.uk/python/articles/unittest2.shtml>`_
+        
+        
+        Classes in unittest2 derive from the appropriate classes in unittest, so it
+        should be possible to use the unittest2 test running infrastructure without
+        having to switch all your tests to using unittest2 immediately. Similarly
+        you can use the new assert methods on ``unittest2.TestCase`` with the standard
+        unittest test running infrastructure. Not all of the new features in unittest2
+        will work with the standard unittest test loaders, runners result objects
+        however.
+        
+        New features include:
+        
+        * ``addCleanups`` - better resource management
+        * *many* new assert methods including better defaults for comparing lists,
+          sets, dicts unicode strings etc and the ability to specify new default methods
+          for comparing specific types
+        * ``assertRaises`` as context manager, with access to the exception afterwards 
+        * test discovery and new command line options (including failfast and better
+          handling of ctrl-C during test runs)
+        * class and module level fixtures: ``setUpClass``, ``tearDownClass``,
+          ``setUpModule``, ``tearDownModule``
+        * test skipping and expected failures
+        * new ``delta`` keyword argument to ``assertAlmostEqual`` for more useful
+          comparison and for comparing non-numeric objects (like datetimes)
+        * ``load_tests`` protocol for loading tests from modules or packages 
+        * ``startTestRun`` and ``stopTestRun`` methods on TestResult
+        * various other API improvements and fixes
+        
+        .. note:: Command line usage
+        
+            In Python 2.7 you invoke the unittest command line features (including test
+            discover) with ``python -m unittest <args>``. As unittest is a package, and
+            the ability to invoke packages with ``python -m ...`` is new in Python 2.7,
+            we can't do this for unittest2.
+            
+            Instead unittest2 comes with a script ``unit2``. 
+            `Command line usage
+            <http://docs.python.org/dev/library/unittest.html#command-line-interface>`_::
+            
+                unit2 discover
+                unit2 -v test_module
+            
+            There is also a copy of this script called ``unit2.py``, useful for Windows
+            which uses file-extensions rather than shebang lines to determine what
+            program to execute files with. Both of these scripts are installed by
+            distutils.
+        
+        Until I write proper documentation, the best information on all the new features
+        is the development version of the Python documentation for Python 2.7:
+        
+        * http://docs.python.org/dev/library/unittest.html
+        
+        Look for notes about features added or changed in Python 2.7.
+        
+        .. note::
+        
+            unittest2 is already in use for development of`distutils2
+            <http://hg.python.org/distutils2>`_.
+            
+            Version 0.5.0 of unittest2 has feature parity with unittest_ in Python 2.7
+            final. If you want to ensure that your tests run identically under unittest2
+            and unittest in Python 2.7 you should use unittest2 0.5.0.
+            
+            Later versions of unittest2 include changes in unittest made in Python 3.2
+            and onwards after the release of Python 2.7.
+        
+        
+        .. _unittest: http://docs.python.org/release/2.7/library/unittest.html
+        
+        
+        Differences
+        ===========
+        
+        Differences between unittest2 and unittest in Python 2.7:
+        
+        ``assertItemsEqual`` does not silence Py3k warnings as this uses
+        ``warnings.catch_warnings()`` which is new in Python 2.6 (and is used as a
+        context manager which would be a pain to make work with Python 2.4).
+        
+        The underlying dictionary storing the type equality functions on TestCase is a
+        custom object rather than a real dictionary. This allows TestCase instances to
+        be deep-copyable on Python versions prior to 2.7.
+        
+        ``TestCase.longMessage`` defaults to True because it is better. It defaults to
+        False in Python 2.7 for backwards compatibility reasons.
+        
+        ``python -m package`` doesn't work in versions of Python before Python 2.7. The
+        command line features of unittest2 are provided by a ``unit2`` (and 
+        ``unit2.py``) script instead.
+        
+        unittest2 includes a very basic setuptools compatible test collector. Specify
+        ``test_suite = 'unittest2.collector'`` in your setup.py. This starts test
+        discovery with the default parameters from the directory containing setup.py, so
+        it is perhaps most useful as an example (see unittest2/collector.py).
+        
+        
+        
+        Issues
+        ======
+        
+        A ``TestResult`` object with unexpected successes returns True
+        for ``result.wasSuccessful()``. Difficult to know if this is the correct
+        behaviour or not.
+        
+        If a dotted path name is used for test discovery then a globally installed
+        module/package will still be used in preference of one in the current
+        directory. When doing discovery from a dotted path name we could check for this
+        specific case.
+        
+        The ``removeHandler`` decorator could also be a context manager.
+        
+        `Issue 8313: <http://bugs.python.org/issue8313>`_, \<unprintable AssertionError object\>
+        message in unittest tracebacks, is hard to fix in versions of Python before 2.7.
+        The fix in Python 2.7 relies on changes to both the traceback module and
+        traceback objects. As the issue is rare I am leaving it unfixed in unittest2.
+        
+        There are several places in unittest2 (and unittest) that call ``str(...)`` on
+        exceptions to get the exception message. This can fail if the exception was
+        created with non-ascii unicode. This is rare and I won't address it unless it is
+        actually reported as a problem for someone.
+        
+        A comparison of text or long sequences (using ``assertSequenceEqual`` or
+        ``assertMultiLineEqual`` etc) can take a *long* time to generate diffs for
+        failure messages. These methods use ``prettyprint`` and ``difflib``.
+        
+        
+        CHANGELOG
+        =========
+        
+        2010/07/12 - 0.5.1
+        ------------------
+        
+        Reverted script names created by setuptools back to "unit2" instead of
+        "unit2.py". (Not necessary as setuptools creates stub .exes for console scripts
+        anyway.)
+        
+        
+        2010/07/11 - 0.5.0
+        ------------------
+        
+        Addition of a setuptools compatible test collector (very basic). Specify
+        ``test_suite = 'unittest2.collector'`` in your setup.py.
+        
+        ``TestSuite.debug()`` and ``TestCase.debug()`` now execute cleanup functions
+        and class and module level setups and teardowns.
+        
+        No longer monkey-patch os.path.relpath for Python 2.4 / 2.5 so that projects
+        don't accidentally depend on our patching. Contributed by Konrad Delong.
+        
+        Added a Python version specific unit2 entrypoint. This will, for example,
+        create a ``unit2-2.6`` script if unittest2 is installed with Python 2.6.
+        (Requires setuptools or distribute.)
+        
+        Python 2.3 compatibility (in the python2.3 branch of the repository),
+        contributed by Mark Roddy.
+        
+        setuptools console script entry points are created as '.py' scripts on Windows.
+        
+        Feature parity with the Python 2.7 final release.
+        
+        
+        2010/06/06 - 0.4.2
+        ------------------
+        
+        Improved help message for ``unit2 discover -h``.
+        
+        SkipTest in unittest.TestCase.setUpClass or setUpModule is now reported as a 
+        skip rather than an error.
+        
+        Excessively large diffs due to ``TestCase.assertSequenceEqual`` are no
+        longer included in failure reports. (Controlled by ``TestCase.maxDiff``.)
+        
+        Matching files during test discovery is done in ``TestLoader._match_path``. This
+        method can be overriden in subclasses to, for example, match on the full file
+        path or use regular expressions for matching.
+        
+        Addition of a setuptools compatible entrypoint for the unit2 test runner script.
+        Contributed by Chris Withers.
+        
+        Tests fixed to be compatible with Python 2.7, where deprecation warnings are
+        silenced by default.
+        
+        Feature parity with unittest in Python 2.7 RC 1.
+        
+        
+        2010/05/09 - 0.4.1
+        ------------------
+        
+        If test discovery imports a module from the wrong location (usually because the
+        module is globally installed and the user is expecting to run tests against a
+        development version in a different location) then discovery halts with an
+        ``ImportError`` and the problem is reported.
+        
+        Added docstrings to ``assertRegexpMatches`` and ``assertNotRegexpMatches``.
+        
+        Putting functions in test suites no longer crashes.
+        
+        Feature parity with unittest in Python 2.7 Beta 2.
+        
+        2010/04/08 - 0.4.0
+        ------------------
+        
+        Addition of ``removeHandler`` for removing the control-C handler.
+        
+        ``delta`` keyword argument for ``assertAlmostEqual`` and
+        ``assertNotAlmostEqual``.
+        
+        Addition of -b command line option (and ``TestResult.buffer``) for buffering 
+        stdout / stderr during test runs.
+        
+        Addition of ``TestCase.assertNotRegexpMatches``.
+        
+        Allow test discovery using dotted module names instead of a path.
+        
+        All imports requiring the signal module are now optional, for compatiblity
+        with IronPython (or other platforms without this module).
+        
+        Tests fixed to be compatible with nosetest.
+        
+        
+        2010/03/26 - 0.3.0
+        ------------------
+        
+        ``assertSameElements`` removed and ``assertItemsEqual`` added; assert that
+        sequences contain the same elements.
+        
+        Addition of -f/--failfast command line option, stopping test run on first
+        failure or error.
+        
+        Addition of -c/--catch command line option for better control-C handling during
+        test runs.
+        
+        Added ``BaseTestSuite``, for use by frameworks that don't want to support shared
+        class and module fixtures.
+        
+        Skipped test methods no longer have ``setUp`` and ``tearDown`` called around
+        them.
+        
+        Faulty ``load_tests`` functions no longer halt test discovery.
+        
+        Using non-strings for failure messages now works.
+        
+        Potential for ``UnicodeDecodeError`` whilst creating failure messages fixed.
+        
+        Split out monolithic test module into a package.
+        
+        BUGFIX: Correct usage message now shown for unit2 scripts.
+        
+        BUGFIX: ``__unittest`` in module globals trims frames from that module in
+        reported stacktraces.
+        
+        
+        2010/03/06 - 0.2.0
+        ------------------
+        
+        The ``TextTestRunner`` is now compatible with old result objects and standard
+        (non-TextTestResult) ``TestResult`` objects.
+        
+        ``setUpClass`` / ``tearDownClass`` / ``setUpModule`` / ``tearDownModule`` added.
+        
+        
+        2010/02/22 - 0.1.6
+        ------------------
+        
+        Fix for compatibility with old ``TestResult`` objects. New tests can now be run
+        with nosetests (with a DeprecationWarning for ``TestResult`` objects without
+        methods to support skipping etc).
+        
+        
+        0.1
+        ---
+        
+        Initial release.
+        
+        
+        TODO
+        ====
+        
+        * Document ``SkipTest``, ``BaseTestSuite```
+        
+Keywords: unittest,testing,tests
+Platform: UNKNOWN
+Classifier: Development Status :: 4 - Beta
+Classifier: Environment :: Console
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: BSD License
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2.3
+Classifier: Programming Language :: Python :: 2.4
+Classifier: Programming Language :: Python :: 2.5
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Operating System :: OS Independent
+Classifier: Topic :: Software Development :: Libraries
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
+Classifier: Topic :: Software Development :: Testing

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2.egg-info/SOURCES.txt
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2.egg-info/SOURCES.txt b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2.egg-info/SOURCES.txt
new file mode 100644
index 0000000..949938e
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2.egg-info/SOURCES.txt
@@ -0,0 +1,39 @@
+README.txt
+setup.cfg
+setup.py
+unit2
+unit2.py
+unittest2/__init__.py
+unittest2/__main__.py
+unittest2/case.py
+unittest2/collector.py
+unittest2/compatibility.py
+unittest2/loader.py
+unittest2/main.py
+unittest2/result.py
+unittest2/runner.py
+unittest2/signals.py
+unittest2/suite.py
+unittest2/util.py
+unittest2.egg-info/PKG-INFO
+unittest2.egg-info/SOURCES.txt
+unittest2.egg-info/dependency_links.txt
+unittest2.egg-info/entry_points.txt
+unittest2.egg-info/top_level.txt
+unittest2/test/__init__.py
+unittest2/test/dummy.py
+unittest2/test/support.py
+unittest2/test/test_assertions.py
+unittest2/test/test_break.py
+unittest2/test/test_case.py
+unittest2/test/test_discovery.py
+unittest2/test/test_functiontestcase.py
+unittest2/test/test_loader.py
+unittest2/test/test_new_tests.py
+unittest2/test/test_program.py
+unittest2/test/test_result.py
+unittest2/test/test_runner.py
+unittest2/test/test_setups.py
+unittest2/test/test_skipping.py
+unittest2/test/test_suite.py
+unittest2/test/test_unittest2_with.py
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2.egg-info/dependency_links.txt
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2.egg-info/dependency_links.txt b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2.egg-info/entry_points.txt
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2.egg-info/entry_points.txt b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2.egg-info/entry_points.txt
new file mode 100644
index 0000000..0ff978b
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2.egg-info/entry_points.txt
@@ -0,0 +1,4 @@
+[console_scripts]
+unit2 = unittest2:main_
+unit2-2.7 = unittest2:main_
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2.egg-info/top_level.txt
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2.egg-info/top_level.txt b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2.egg-info/top_level.txt
new file mode 100644
index 0000000..9a23970
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2.egg-info/top_level.txt
@@ -0,0 +1 @@
+unittest2

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/__init__.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/__init__.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/__init__.py
new file mode 100644
index 0000000..11cbadc
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/__init__.py
@@ -0,0 +1,68 @@
+"""
+unittest2
+
+unittest2 is a backport of the new features added to the unittest testing
+framework in Python 2.7. It is tested to run on Python 2.4 - 2.6.
+
+To use unittest2 instead of unittest simply replace ``import unittest`` with
+``import unittest2``.
+
+
+Copyright (c) 1999-2003 Steve Purcell
+Copyright (c) 2003-2010 Python Software Foundation
+This module is free software, and you may redistribute it and/or modify
+it under the same terms as Python itself, so long as this copyright message
+and disclaimer are retained in their original form.
+
+IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
+THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.
+
+THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE.  THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS,
+AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
+SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+"""
+
+__all__ = ['TestResult', 'TestCase', 'TestSuite',
+           'TextTestRunner', 'TestLoader', 'FunctionTestCase', 'main',
+           'defaultTestLoader', 'SkipTest', 'skip', 'skipIf', 'skipUnless',
+           'expectedFailure', 'TextTestResult', '__version__', 'collector']
+
+__version__ = '0.5.1'
+
+# Expose obsolete functions for backwards compatibility
+__all__.extend(['getTestCaseNames', 'makeSuite', 'findTestCases'])
+
+
+from unittest2.collector import collector
+from unittest2.result import TestResult
+from unittest2.case import (
+    TestCase, FunctionTestCase, SkipTest, skip, skipIf,
+    skipUnless, expectedFailure
+)
+from unittest2.suite import BaseTestSuite, TestSuite
+from unittest2.loader import (
+    TestLoader, defaultTestLoader, makeSuite, getTestCaseNames,
+    findTestCases
+)
+from unittest2.main import TestProgram, main, main_
+from unittest2.runner import TextTestRunner, TextTestResult
+
+try:
+    from unittest2.signals import (
+        installHandler, registerResult, removeResult, removeHandler
+    )
+except ImportError:
+    # Compatibility with platforms that don't have the signal module
+    pass
+else:
+    __all__.extend(['installHandler', 'registerResult', 'removeResult', 
+                    'removeHandler'])
+
+# deprecated
+_TextTestResult = TextTestResult
+
+__unittest = True
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/__main__.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/__main__.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/__main__.py
new file mode 100644
index 0000000..04ed982
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/__main__.py
@@ -0,0 +1,10 @@
+"""Main entry point"""
+
+import sys
+if sys.argv[0].endswith("__main__.py"):
+    sys.argv[0] = "unittest2"
+
+__unittest = True
+
+from unittest2.main import main_
+main_()


[19/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code

Posted by rl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/darwin_processtable.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/darwin_processtable.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/darwin_processtable.c
new file mode 100644
index 0000000..0132381
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/darwin_processtable.c
@@ -0,0 +1,131 @@
+/* The MIT License
+ *
+ * Copyright (C) 2009 Erick Tryzelaar
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/* ProcessTable functions for arch: Mac OS X */
+
+#include <Python.h>
+#include <sys/sysctl.h>
+#include <sys/proc.h>
+
+#include "psi.h"
+#include "process.h"
+
+
+/***** Local declarations *****/
+static int psi_sysctl(int *name, int nlen, void **oldval, size_t *oldlenp);
+
+
+/***** ProcessTable methods *****/
+
+
+struct psi_proclist *
+psi_arch_proclist(void)
+{
+    static const int    name[] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0 };
+    struct kinfo_proc   *result = NULL;
+    size_t              length;
+    int                 i;
+    struct psi_proclist *prl = NULL;
+
+    if (psi_sysctl((int*)name, (sizeof(name) / sizeof(*name)) - 1,
+                   (void**)&result, &length) == -1)
+        return NULL;
+    prl = (struct psi_proclist *) psi_malloc(sizeof(struct psi_proclist));
+    if (prl == NULL) {
+        psi_free(result);
+        return NULL;
+    }
+    prl->count = length / sizeof(struct kinfo_proc);
+    prl->pids = (pid_t *) psi_malloc(prl->count * sizeof(pid_t));
+    if (prl->pids == NULL) {
+        psi_free(prl);
+        psi_free(result);
+        return NULL;
+    }
+    for(i = 0; i < prl->count; i++)
+        prl->pids[i] = result[i].kp_proc.p_pid;
+    psi_free(result);
+    return prl;
+}
+
+
+/***** Local functions *****/
+
+
+static int
+psi_sysctl(int *name, int nlen, void **oldval, size_t *oldlenp)
+{
+    int  err;
+    int  done = 0;
+
+    /* We start by calling sysctl with oldval == NULL and oldlenp == 0.  That
+     * will succeed, and set length to the appropriate length.  We then
+     * allocate a buffer of that size and call sysctl again with that buffer.
+     * If that succeeds, we're done.  If that fails with ENOMEM, we have to
+     * throw away our buffer and loop.  Note that the loop causes us to call
+     * sysctl with NULL again; this is necessary because the ENOMEM failure
+     * case sets length to the amount of data returned, not the amount of data
+     * that could have been returned. */
+    do {
+        /* Call sysctl with a NULL buffer. */
+        *oldlenp = 0;
+        err = sysctl(name, nlen, NULL, oldlenp, NULL, 0);
+        if (err == -1)
+            err = errno;
+
+        /* Allocate an appropriately sized buffer based on the results from the
+         * previous call. */
+        if (err == 0) {
+            *oldval = psi_malloc(*oldlenp);
+            if (*oldval == NULL)
+                err = ENOMEM;
+        }
+
+        /* Call sysctl again with the new buffer.  If we get an ENOMEM error,
+         * toss away our buffer and start again. */
+        if (err == 0) {
+            err = sysctl(name, nlen, *oldval, oldlenp, NULL, 0);
+            if (err == -1)
+                err = errno;
+            if (err == 0)
+                done = 1;
+            else if (err == ENOMEM) {
+                assert(*oldval != NULL);
+                psi_free(*oldval);
+                *oldval = NULL;
+                err = 0;
+            }
+        }
+    } while (err == 0 && !done);
+
+    /* Clean up and establish post conditions. */
+    if (err != 0) {
+        if (*oldval != NULL)
+            psi_free(*oldval);
+        *oldval = NULL;
+        PyErr_SetFromErrnoWithFilename(PyExc_OSError, "sysctl()");
+        return -1;
+    }
+    return 0;
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/darwin_psi.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/darwin_psi.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/darwin_psi.c
new file mode 100644
index 0000000..66149f0
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/darwin_psi.c
@@ -0,0 +1,93 @@
+/* The MIT License
+ *
+ * Copyright (C) 2008-2009 Floris Bruynooghe
+ *
+ * Copyright (C) 2008-2009 Erick Tryzelaar
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/* Darwin implementations of the _psi non-POSIX functions */
+
+#include <Python.h>
+#include <sys/sysctl.h>
+#include "psi.h"
+#include "posix_utils.h"
+
+
+/***** Public functions *****/
+
+/*
+ * arch_boottime(&boottime)
+ *
+ * Fetch system boot time in seconds from sysctl and save in the provided long
+ * pointer.
+ *
+ * Returns: 0 if successful; -1 for failure (Python Exception raised)
+ */
+int
+arch_boottime(struct timespec *boottime)
+{
+    struct timeval kern_boottime;
+    int error;
+    unsigned long length = sizeof(kern_boottime);
+    error = sysctlbyname("kern.boottime", &kern_boottime, &length, NULL, 0);
+    if (error) {
+        PyErr_SetFromErrno(PyExc_OSError);
+        return -1;
+    }
+    else {
+        boottime->tv_sec = kern_boottime.tv_sec;
+        boottime->tv_nsec = kern_boottime.tv_usec * 1000;
+    }
+
+    return 0;
+}
+
+
+/*
+ * arch_uptime(&uptime_secs, &idle_secs)
+ *
+ * Fetch system uptime and idle time, in seconds and save in the double
+ * pointers provided.
+ *
+ * Returns: 0 if successful; -1 for failure (Python Exception raised)
+ */
+int
+arch_uptime(struct timespec *uptime)
+{
+    struct timespec boottime;
+    struct timeval now;
+
+    if (arch_boottime(&boottime) == -1) {
+        /* arch_boottime will raise the exception for us. */
+        return -1;
+    }
+
+    if (gettimeofday(&now, NULL) < 0) {
+        PyErr_SetFromErrno(PyExc_OSError);
+        return -1;
+    }
+
+    uptime->tv_sec = now.tv_sec - boottime.tv_sec;
+    uptime->tv_nsec = (now.tv_usec * 1000) - boottime.tv_nsec;
+
+    return 0;
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/getloadavg.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/getloadavg.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/getloadavg.c
new file mode 100644
index 0000000..843123b
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/getloadavg.c
@@ -0,0 +1,67 @@
+/* The MIT License
+ *
+ * Copyright (C) 2008-2009 Floris Bruynooghe
+ *
+ * Copyright (C) 2008-2009 Abilisoft Ltd.
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/* Implementation of arch_loadavginfo using the common but nonstandard
+ * getloadavg. */
+
+
+#include <Python.h>
+
+#ifdef SUNOS
+#include <sys/loadavg.h>
+#else
+#include <stdlib.h>
+#endif
+
+#include "psi.h"
+#include "psifuncs.h"
+
+
+struct loadavginfo *
+arch_loadavginfo(void)
+{
+    struct loadavginfo *loadi;
+    double avg[3];
+    int r;
+
+    r = getloadavg(avg, 3);
+    if (r == -1) {
+        PyErr_SetString(PyExc_OSError, "getloadavg() failed");
+        return NULL;
+    } else if (r < 3) {
+        PyErr_Format(PyExc_OSError,
+                     "getloadavg() only returned %d numbers (expected 3)", r);
+        return NULL;
+    }
+    loadi = psi_calloc(sizeof(struct loadavginfo));
+    if (loadi == NULL)
+        return NULL;
+    loadi->one = avg[0];
+    loadi->five = avg[1];
+    loadi->fifteen = avg[2];
+    loadi->loadavg_status = PSI_STATUS_OK;
+    return loadi;
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/linux_mount.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/linux_mount.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/linux_mount.c
new file mode 100644
index 0000000..9024c15
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/linux_mount.c
@@ -0,0 +1,156 @@
+/* The MIT License
+ *
+ * Copyright (C) 2009 Erick Tryzelaar
+ *
+ * Copyright (C) 2009 Floris Bruynooghe
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include <Python.h>
+
+#include <mntent.h>
+#include <stdlib.h>
+#include <sys/statvfs.h>
+
+#include "psi.h"
+#include "mount.h"
+#include "posix_mount.h"
+
+
+/***** Local declarations *****/
+
+static int set_mntent(psi_mountinfo_t *mounti, struct mntent *mnt);
+
+
+/***** Public functions *****/
+
+psi_mountlist_t *
+psi_arch_mountlist(const int remote)
+{
+    FILE *mntent;
+    struct mntent mnt;
+    char buf[PATH_MAX * 3];     /* size used in autofs so I hope it's okay */
+    psi_mountlist_t *ml = NULL;
+    psi_mountinfo_t *mounti, **mounts;
+
+    /* Open /etc/mtab */
+    mntent = setmntent(_PATH_MOUNTED, "r");
+    if (mntent == NULL)
+        return (psi_mountlist_t *) PyErr_SetFromErrnoWithFilename(
+            PyExc_OSError, _PATH_MOUNTED);
+
+    /* Create our (empty) mountlist */
+    ml = (psi_mountlist_t *)psi_calloc(sizeof(psi_mountlist_t));
+    if (ml == NULL) {
+        fclose(mntent);
+        return NULL;
+    }
+
+    /* Step through each line in the mount file */
+    while (getmntent_r(mntent, &mnt, buf, sizeof(buf)) != NULL) {
+
+        /* Skip remote filesystems if not asked for them */
+        if (!remote &&
+            (strchr(mnt.mnt_fsname, ':') != NULL ||
+             strncmp(mnt.mnt_fsname, "//", 2) == 0))
+            continue;
+
+        /* Allocate space for the mount information */
+        if ((mounti = psi_calloc(sizeof(psi_mountinfo_t))) == NULL) {
+            fclose(mntent);
+            psi_free_mountlist(ml);
+            return NULL;
+        }
+        
+        /* And then allocate more space for the mount list */
+        mounts = (psi_mountinfo_t **)psi_realloc(
+            ml->mounts,
+            (ml->count + 1) * sizeof(psi_mountinfo_t *));
+        if (mounts == NULL) {
+            fclose(mntent);
+            psi_free_mountinfo(mounti);
+            psi_free_mountlist(ml);
+            return NULL;
+        }
+        ml->mounts = mounts;
+        ml->mounts[ml->count] = mounti;
+        ml->count += 1;
+
+        /* Finally add the information to mounti */
+        if (set_mntent(mounti, &mnt) < 0) {
+            fclose(mntent);
+            psi_free_mountlist(ml);
+            return NULL;
+        }
+        if (posix_set_vfs(mounti) < 0) {
+            fclose(mntent);
+            psi_free_mountlist(ml);
+            return NULL;
+        }
+    }
+    if (!feof(mntent)) {        /* Uh oh, we had a read error */
+        endmntent(mntent);
+        psi_free_mountlist(ml);
+        PyErr_Format(PyExc_OSError, "Read error in %s", _PATH_MOUNTED);
+        return NULL;
+    }
+    endmntent(mntent);
+    return ml;
+}
+
+
+/***** Local Functions *****/
+
+
+#define STRDUP(dst, src)                    \
+    if ((dst = psi_strdup(src)) == NULL)    \
+        return -1;                          \
+    dst ## _status = PSI_STATUS_OK
+
+
+static int
+set_mntent(psi_mountinfo_t *mounti, struct mntent *mnt)
+{
+    char *p;
+    int r;
+
+    p = strchr(mnt->mnt_fsname, ':');
+    r = strncmp(mnt->mnt_fsname, "//", 2);
+    if (p == NULL || r != 0) {  /* Local mount */
+        mounti->filesystem_host_status = PSI_STATUS_OK;
+        STRDUP(mounti->filesystem_path, mnt->mnt_fsname);
+    } else
+        if (p != NULL) {
+            *p = '\0';
+            STRDUP(mounti->filesystem_host, mnt->mnt_fsname);
+            STRDUP(mounti->filesystem_path, p + 1);
+        } else {
+            p = strchr(mnt->mnt_fsname + 2, '/');
+            *p = '\0';
+            STRDUP(mounti->filesystem_host, mnt->mnt_fsname + 2);
+            STRDUP(mounti->filesystem_path, p + 1);
+        }
+    STRDUP(mounti->mount_type, mnt->mnt_type);
+    STRDUP(mounti->mount_path, mnt->mnt_dir);
+    STRDUP(mounti->mount_options, mnt->mnt_opts);
+    return 0;
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/linux_process.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/linux_process.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/linux_process.c
new file mode 100644
index 0000000..e23c8c0
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/linux_process.c
@@ -0,0 +1,771 @@
+/* The MIT License
+ *
+ * Copyright (C) 2007 Chris Miles
+ *
+ * Copyright (C) 2008-2009 Floris Bruynooghe
+ *
+ * Copyright (C) 2008-2009 Abilisoft Ltd.
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/* Linux implementation of the Process classes */
+
+
+#include <Python.h>
+
+#include <limits.h>
+#include <locale.h>
+#include <string.h>
+#include <sys/time.h>
+#include <time.h>
+#include <unistd.h>
+#include <asm/param.h>
+
+#include "psi.h"
+#include "process.h"
+#include "procfs_utils.h"
+#include "posix_utils.h"
+#include "linux_utils.h"
+
+
+/* Constant numbers don't matter, but apparently these are copied form
+ * linux/fs/proc/array.c.  Whatever.  --flub */
+#define PROC_STATUS_RUNNING 0
+#define PROC_STATUS_SLEEPING 1
+#define PROC_STATUS_DISKSLEEP 2
+#define PROC_STATUS_STOPPED 4
+#define PROC_STATUS_TRACINGSTOP 8
+#define PROC_STATUS_ZOMBIE 16
+#define PROC_STATUS_DEAD 32
+#define PROC_STATUS_PAGING 64   /* not from array.c  */
+
+
+/***** Local declarations *****/
+static int parse_uid_from_proc_status(struct psi_process *proci,
+                                      const char *line);
+static int parse_gid_from_proc_status(struct psi_process *proci,
+                                      const char *line);
+static int parse_stat(struct psi_process *proci,
+                      const char *stat_buf,
+                      const pid_t pid);
+static int decode_state(const char state);
+static void ticks2timespec(struct timespec *tspec,
+                           const unsigned long long ticks);
+static struct timespec calc_cputime(const struct timespec utime,
+                                    const struct timespec stime);
+static int calc_start_time(struct timespec *start_time,
+                           const unsigned long long starttime);
+static int find_terminal(char **terminal, pid_t pid, int fd);
+
+static int set_exe(struct psi_process *proci, const pid_t pid);
+static int set_arg(struct psi_process *proci, const pid_t pid);
+static int set_env(struct psi_process *proci, const pid_t pid);
+static int set_cwd(struct psi_process *proci, const pid_t pid);
+static int set_ids(struct psi_process *proci, const pid_t pid);
+static int set_stat(struct psi_process *proci, const pid_t pid);
+static int set_term(struct psi_process *proci, pid_t pid);
+
+
+
+/***** Public interfaces from process.h. *****/
+
+
+
+/* The process status flags. */
+#define addconst(CONST) {#CONST, CONST}
+struct psi_flag psi_arch_proc_status_flags[] = {
+    addconst(PROC_STATUS_RUNNING),
+    addconst(PROC_STATUS_SLEEPING),
+    addconst(PROC_STATUS_DISKSLEEP),
+    addconst(PROC_STATUS_STOPPED),
+    addconst(PROC_STATUS_TRACINGSTOP),
+    addconst(PROC_STATUS_ZOMBIE),
+    addconst(PROC_STATUS_DEAD),
+    addconst(PROC_STATUS_PAGING),
+    {NULL, 0}};             /* sentinel */
+
+
+struct psi_process *
+psi_arch_process(const pid_t pid)
+{
+    struct psi_process *proci;
+
+    if (procfs_check_pid(pid) == -1)
+        return NULL;
+    proci = psi_calloc(sizeof(struct psi_process));
+    if (proci == NULL)
+        return NULL;
+    if (set_exe(proci, pid) == -1)
+        return psi_free_process(proci);
+    if (set_arg(proci, pid) == -1)
+        return psi_free_process(proci);
+    if (set_env(proci, pid) == -1)
+        return psi_free_process(proci);
+    if (set_cwd(proci, pid) == -1)
+        return psi_free_process(proci);
+    if (set_ids(proci, pid) == -1)
+        return psi_free_process(proci);
+    if (set_stat(proci, pid) == -1)
+        return psi_free_process(proci);
+    if (set_term(proci, pid) == -1)
+        return psi_free_process(proci);
+    return proci;
+}
+
+
+/***** Local functions *****/
+
+
+/*
+ * terminal_name()
+ *
+ * Returns:
+ *       0 = success
+ *      -1 = Failure and Exception was raised
+ */
+static int
+set_term(struct psi_process *proci, pid_t pid)
+{
+    char *terminal = NULL;
+    int i;
+    int r;
+    int fds[] = {255, 2, 0, 1};
+
+    for (i=0; i<4; i++) {
+        r = find_terminal(&terminal, pid, fds[i]);
+        if (r == -2) {
+            PyErr_Clear();
+            proci->terminal_status = PSI_STATUS_PRIVS;
+            return 0;
+        } else if (r < 0)
+            PyErr_Clear();
+        else if (r == 1)
+            break;
+    }
+    proci->terminal = terminal;
+    proci->terminal_status = PSI_STATUS_OK;
+    return 0;
+}
+
+
+/** Read /proc/pid/stat
+ *
+ * The psi_process members filled by this are: nthreads, ppid, status,
+ * virtual_size, resident_size, flags, user_time, system_time, cpu_time,
+ * priority, nice, start_time, pcpu.  Their matching *_status slots are filled
+ * in too.
+ *
+ * Returns 0 for success; -1 for failure (Exception raised).
+ */
+static int
+set_stat(struct psi_process *proci, const pid_t pid)
+{
+    char *buf;
+    int bufsize;
+    int r;
+
+    bufsize = procfs_read_procfile(&buf, pid, "stat");
+    if (bufsize == -1)
+        return -1;
+    if (bufsize == -2) {
+        proci->ppid_status = PSI_STATUS_PRIVS;
+        proci->pgrp_status = PSI_STATUS_PRIVS;
+        proci->sid_status = PSI_STATUS_PRIVS;
+        proci->priority_status = PSI_STATUS_PRIVS;
+        proci->nice_status = PSI_STATUS_PRIVS;
+        proci->start_time_status = PSI_STATUS_PRIVS;
+        proci->status_status = PSI_STATUS_PRIVS;
+        proci->nthreads_status = PSI_STATUS_PRIVS;
+        proci->terminal_status = PSI_STATUS_PRIVS;
+        proci->utime_status = PSI_STATUS_PRIVS;
+        proci->stime_status = PSI_STATUS_PRIVS;
+        proci->vsz_status = PSI_STATUS_PRIVS;
+        proci->rss_status = PSI_STATUS_PRIVS;
+        proci->pcpu_status = PSI_STATUS_PRIVS;
+        return 0;
+    }
+    r = parse_stat(proci, buf, pid);
+    psi_free(buf);
+    if (r == -1)
+        return -1;
+    return 0;
+}
+
+
+/** Set euid, egid, ruid and rgid members of a psi_process structure
+ *
+ * The matching *_status members will be set too.
+ *
+ * Note that this will also set the RSS value since we're reading
+ * /proc/<pid>/status here and this is the best value for RSS we can get.
+ * This function should probably be renamed to parse_status() or something
+ * like that.
+ */
+static int
+set_ids(struct psi_process *proci, const pid_t pid)
+{
+    char *buf;
+    char *line_start;
+    char *line_end;
+    char *value;
+    int bufsize;
+    int uid_seen = 0;
+    int gid_seen = 0;
+/*     int rss_seen = 0; */
+
+    bufsize = procfs_read_procfile(&buf, pid, "status");
+    if (bufsize == -1)
+        return -1;
+    if (bufsize == -2) {
+        proci->euid_status = PSI_STATUS_PRIVS;
+        proci->ruid_status = PSI_STATUS_PRIVS;
+        proci->egid_status = PSI_STATUS_PRIVS;
+        proci->rgid_status = PSI_STATUS_PRIVS;
+        proci->euser_status = PSI_STATUS_PRIVS;
+        proci->ruser_status = PSI_STATUS_PRIVS;
+        proci->egroup_status = PSI_STATUS_PRIVS;
+        proci->rgroup_status = PSI_STATUS_PRIVS;
+        proci->rss_status = PSI_STATUS_PRIVS;
+        return 0;
+    }
+    line_start = buf;
+    while (line_start < buf + bufsize) {
+        line_end = line_start;
+        while (*line_end != '\n' && line_end <= buf+bufsize)
+            line_end++;
+        *line_end = '\0';
+        value = strchr(line_start, ':');
+        if (value) {
+            *value++ = '\0';    /* terminate line_start & point to value */
+            if (strcmp("Uid", line_start) == 0) {
+                uid_seen = 1;
+                if (parse_uid_from_proc_status(proci, value) < 0) {
+                    psi_free(buf);
+                    return -1;
+                }
+            } else if (strcmp("Gid", line_start) == 0) {
+                gid_seen = 1;
+                if (parse_gid_from_proc_status(proci, value) < 0) {
+                    psi_free(buf);
+                    return -1;
+                }
+            }
+        } /* if (value) */
+        line_start = line_end + 1;
+    } /* while (line_start < buf + bufsize) */
+    psi_free(buf);
+    if (!uid_seen || !gid_seen) {
+        PyErr_Format(
+            PyExc_RuntimeError,
+            "Failed to parse required information from /proc/%d/status",
+            pid);
+        return -1;
+    }
+    return 0;
+}
+
+
+/* XXX: This is exactly the same as set_arg, only with a different
+ *      filename! */
+static int
+set_env(struct psi_process *proci, const pid_t pid)
+{
+    char *buf;
+    char **envv;
+    int envc;
+    int bufsize;
+
+    bufsize = procfs_read_procfile(&buf, pid, "environ");
+    if (bufsize == -1)
+        return -1;
+    if (bufsize == -2) {
+        proci->envc_status = PSI_STATUS_PRIVS;
+        proci->envv_status = PSI_STATUS_PRIVS;
+        return 0;
+    }
+    envc = psi_strings_count(buf, bufsize);
+    envv = psi_strings_to_array(buf, envc);
+    psi_free(buf);
+    if (envv == NULL)
+        return -1;
+    proci->envc = envc;
+    proci->envc_status = PSI_STATUS_OK;
+    proci->envv = envv;
+    proci->envv_status = PSI_STATUS_OK;
+    return 0;
+}
+
+
+/** Set the argument list
+ *
+ * This sets argc, argv and command in the psi_process structure.
+ *
+ * Returns 0 on success, -1 on failure (Python exception raised).
+ */
+static int
+set_arg(struct psi_process *proci, const pid_t pid)
+{
+    char *ptr;
+    char **argv;
+    int argc;
+    int bufsize;
+
+    bufsize = procfs_read_procfile(&proci->command, pid, "cmdline");
+    if (bufsize == -1)
+        return -1;
+    if (bufsize == -2) {
+        proci->argc_status = PSI_STATUS_PRIVS;
+        proci->argv_status = PSI_STATUS_PRIVS;
+        return 0;
+    }
+    argc = psi_strings_count(proci->command, bufsize);
+    argv = psi_strings_to_array(proci->command, argc);
+    if (argv == NULL)
+        return -1;
+    for (ptr = proci->command; ptr-proci->command < bufsize-1; ptr++)
+        if (*ptr == '\0')
+            *ptr = ' ';
+    proci->argc = argc;
+    proci->argc_status = PSI_STATUS_OK;
+    proci->argv = argv;
+    proci->argv_status = PSI_STATUS_OK;
+    proci->command_status = PSI_STATUS_OK;
+    return 0;
+}
+
+
+/** Set the exe and exe_status fields of the psi_process structure
+ *
+ * Returns -1 on failure, 0 on success.
+ */
+static int
+set_exe(struct psi_process *proci, const pid_t pid)
+{
+    char *fname;
+    char *link;
+    int r;
+
+    r = psi_asprintf(&fname, "/proc/%d/exe", pid);
+    if (r == -1)
+        return -1;
+    r = psi_readlink(&link, fname);
+    psi_free(fname);
+    if (r == -2) {
+        PyErr_Clear();
+        proci->exe_status = PSI_STATUS_PRIVS;
+        return 0;
+    } else if (r < 0) {
+        if (procfs_check_pid(pid) < 0)
+            return -1;          /* NoSuchProcessError now set */
+        else {
+            PyErr_Clear();
+            proci->exe_status = PSI_STATUS_NA;
+            return 0;
+        }
+    } else {
+        proci->exe = link;
+        proci->exe_status = PSI_STATUS_OK;
+        return 0;
+    }
+}
+
+
+/** Set the cwd and cwd_status fields of the psi_process structure
+ *
+ * Returns -1 on failure, 0 on success.
+ */
+static int
+set_cwd(struct psi_process *proci, const pid_t pid)
+{
+    PyObject *exc_type, *exc_val, *exc_tb;
+    PyObject *errno_attr;
+    long errno_long;
+    char *fname;
+    char *link;
+    int r;
+
+    r = psi_asprintf(&fname, "/proc/%d/cwd", pid);
+    if (r == -1)
+        return -1;
+    r = psi_readlink(&link, fname);
+    psi_free(fname);
+    if (r == -2) {
+        PyErr_Clear();
+        proci->cwd_status = PSI_STATUS_PRIVS;
+        return 0;
+    } else if (r < 0) {
+        procfs_check_pid(pid);  /* OSError -> NoSuchProcessError if required */
+        /* If the process is a zombie, readlink sets errno to ENOENT since the
+         * target does no longer exist.  But psi still wants to show the
+         * process and should not error out. */
+        if (PyErr_ExceptionMatches(PyExc_OSError)) {
+            PyErr_Fetch(&exc_type, &exc_val, &exc_tb);
+            PyErr_NormalizeException(&exc_type, &exc_val, &exc_tb);
+            errno_attr = PyObject_GetAttrString(exc_val, "errno");
+            errno_long = PyLong_AsLong(errno_attr);
+            Py_DECREF(errno_attr);
+            if (errno_long == ENOENT) {
+                Py_DECREF(exc_type);
+                Py_DECREF(exc_val);
+                Py_XDECREF(exc_tb);
+                proci->cwd_status = PSI_STATUS_NA;
+                return 0;
+            }
+            PyErr_Restore(exc_type, exc_val, exc_tb);
+        }
+        return -1;
+    } else {
+        proci->cwd = link;
+        proci->cwd_status = PSI_STATUS_OK;
+        return 0;
+    }
+}
+
+
+/** Find which file/device a filedescriptor is symlinked too
+ *
+ * This will read a symlink in /proc/<pid>/fd/<fd> and if it is pointing to a
+ * valid file will return the name of that file.  You need to psi_free()
+ * `terminal' after use, but only if you got `1' as return value, otherwise it
+ * won't be allocated.
+ *
+ * Returns:
+ *      -2 = insufficient privileges, exception raised
+ *      -1 = error, exception raised
+ *      0 = no terminal name found, `terminal' set to NULL.
+ *      1 = terminal name found
+ */
+static int
+find_terminal(char **terminal, pid_t pid, int fd)
+{
+    char *path;
+    char *link;
+    int r;
+
+    r = psi_asprintf(&path, "/proc/%d/fd/%d", pid, fd);
+    if (r == -1)
+        return -1;
+    r = psi_readlink(&link, path);
+    psi_free(path);
+    if (r < 0)
+        return r;
+    if (strncmp(link, "/dev/null", 9) != 0) {
+        *terminal = link;
+        return 1;
+    }
+    psi_free(link);
+    terminal = NULL;
+    return 0;
+}
+
+
+/** Calculate elapsed time from jiffies
+ *
+ * @param tspec: The timespec into which the result is stored.
+ * @param ticks: The number of clock ticks aka jiffies.
+ */
+static void
+ticks2timespec(struct timespec *tspec, const unsigned long long ticks)
+{
+    int hz;
+
+    hz = sysconf(_SC_CLK_TCK);
+    tspec->tv_sec = ticks/hz;
+    tspec->tv_nsec = (((double)ticks/hz) - tspec->tv_sec)*1000000000;
+}
+
+
+/** Calculate the cputime from utime and stime
+ *
+ * This really just adds two struct timespec values together.
+ */
+static struct timespec
+calc_cputime(const struct timespec utime, const struct timespec stime)
+{
+    struct timespec cputime;
+
+    cputime.tv_sec = utime.tv_sec + stime.tv_sec;
+    cputime.tv_nsec = (utime.tv_nsec + stime.tv_nsec) % 1000000000;
+    cputime.tv_sec += (utime.tv_nsec + stime.tv_nsec) / 1000000000;
+    return cputime;
+}
+
+
+
+/** Calculate the start time of a proc in seconds since epoch
+ *
+ * @param starttime: The starttime in jiffies since system start.
+ */
+static int
+calc_start_time(struct timespec *start_time, const unsigned long long starttime)
+{
+    struct timespec uptime;
+    struct timespec idle;
+    struct timespec now;
+    struct timeval tv_now;
+    
+    int hz;
+
+    hz = sysconf(_SC_CLK_TCK);
+    if (psi_linux_uptime(&uptime, &idle) < 0)
+        return -1;
+    gettimeofday(&tv_now, NULL);
+    if (&tv_now == NULL) {
+        PyErr_SetFromErrno(PyExc_OSError);
+        return -1;
+    }
+    now.tv_sec = tv_now.tv_sec;
+    now.tv_nsec = tv_now.tv_usec * 1000;
+    *start_time = posix_timespec_subtract(&now, &uptime);
+    start_time->tv_sec += starttime/hz;
+    start_time->tv_nsec += ((starttime % hz) * 1000000000)/hz;
+    return 0;
+}
+
+
+/** Decode the state character from /proc/<pid>/stat or /proc/<pid>/status
+ *
+ * Returns an int with the correct PROC_STATUS_* constant in.
+ */
+static int
+decode_state(const char state)
+{
+    int tmpi;
+
+    switch (state) {
+    case 'R':
+        tmpi = PROC_STATUS_RUNNING;
+        break;
+    case 'S':
+        tmpi = PROC_STATUS_SLEEPING;
+        break;
+    case 'D':
+        tmpi = PROC_STATUS_DISKSLEEP;
+        break;
+    case 'Z':
+        tmpi = PROC_STATUS_ZOMBIE;
+        break;
+    case 'T':
+        tmpi = PROC_STATUS_STOPPED;
+        break;
+    case 'W':
+        tmpi = PROC_STATUS_PAGING;
+        break;
+    case 'X':
+        tmpi = PROC_STATUS_DEAD;
+        break;
+    default:
+        PyErr_Format(PyExc_OSError, "Invalid/unknown state: %s", &state);
+        return -1;
+    }
+    return tmpi;
+}
+
+
+/** Reads /prop/<pid>/stat files and fills relevant proc slots.
+ *
+ * Reads /proc/pid/stat files, being careful not to trip over processes with
+ * names like ":-) 1 2 3 4 5 6".
+ *
+ * Note that the RSS value is not read from here.  For some reason it is not
+ * correct here nor in /proc/<pid>/mstat, but it does seem correct in
+ * /proc/<pid>/status so we get it from there.
+ *
+ * Returns 0 for success; -1 for failure (Exception raised).
+ */
+static int
+parse_stat(struct psi_process *proci, const char *stat_buf, const pid_t pid)
+{
+    char *name_start, *name_end;
+    int r;
+
+    /* variables filled from the stat file by scanf */
+    char state;
+    int ppid;
+    int pgrp;
+    int sid;
+    unsigned long utime;
+    unsigned long stime;
+    long priority;
+    long nice;
+    long num_threads;
+    unsigned long long starttime;
+    unsigned long vsize;
+    long rss;
+
+    /* The accounting name is surrounded by parenthesis. */
+    name_start = strchr(stat_buf, '(');
+    name_end = strrchr(stat_buf, ')');
+
+    /* Copy the name and strip off the parenthesis. */
+    proci->name = psi_strndup(name_start + 1, name_end - name_start - 1);
+    if (proci->name == NULL)
+        return -1;
+    proci->name_status = PSI_STATUS_OK;
+
+    /* Note that disabled specs don't have the proper length modifier since
+     * that is illegal.  Check proc(5) if you want to enable one of them. */
+    r = sscanf(name_end + 1,
+               " %c"            /* state */
+               " %d"            /* ppid */
+               " %d"            /* pgrp */
+               " %d"            /* session */
+               " %*d"           /* tty_nr */
+               " %*d"           /* tpgid */
+               " %*u"           /* flags */
+               " %*u"           /* minflt */
+               " %*u"           /* cminflt */
+               " %*u"           /* majflt */
+               " %*u"           /* cmajflt */
+               " %lu"           /* utime */
+               " %lu"           /* stime */
+               " %*u"           /* cutime */
+               " %*d"           /* cstime */
+               " %ld"           /* priority */
+               " %ld"           /* nice */
+               " %ld"           /* num_threads */
+               " %*d"           /* itrealvalue (not maintained) */
+               " %llu"          /* starttime */
+               " %lu"           /* vsize */
+               " %ld"           /* rss */
+               " %*u"           /* rsslim */
+               " %*u"           /* startcode */
+               " %*u"           /* endcode */
+               " %*u"           /* startstack */
+               " %*u"           /* kstkesp */
+               " %*u"           /* kstkeip */
+               " %*u"           /* signal (obsolete) */
+               " %*u"           /* blocked (obsolete) */
+               " %*u"           /* sigignore (obsolete) */
+               " %*u"           /* sigcatch (obsolete) */
+               " %*u"           /* wchan */
+               " %*u"           /* nswap (not maintained) */
+               " %*u"           /* cnswap (not maintained) */
+               " %*d"           /* exit_signal (since 2.1.22) */
+               " %*d"           /* processor (since 2.2.8) */
+#ifdef LINUX2_6
+               " %*u"           /* rt_priority (since 2.5.19) */
+               " %*u"           /* policy (since 2.5.19) */
+#if LINUX2_6_MINOR >= 18
+               " %*u"           /* delayacct_blkio_ticks (since 2.6.18) */
+#endif
+#if LINUX2_6_MINOR >= 24
+               " %*u"           /* guest_time (since 2.6.24) */
+               " %*d"           /* cguest_time (since 2.6.24) */
+#endif
+#endif /* #ifdef LINUX2_6 */
+               ,
+               &state,
+               &ppid,
+               &pgrp,
+               &sid,
+               &utime,
+               &stime,
+               &priority,
+               &nice,
+               &num_threads,
+               &starttime,
+               &vsize,
+               &rss);
+    if (r != 12) {
+        /* XXX I see this happening sometimes, but hard to reproduce.  Maybe
+         *     this happens if the process disappears while the stat file is
+         *     being read, resulting in incomplete data? */
+        PyErr_Format(PyExc_OSError,
+                     "Failed to parse stat file for pid %d", pid);
+        return -1;
+    }
+    proci->status = decode_state(state);
+    proci->status_status = PSI_STATUS_OK;
+    proci->ppid = (pid_t)ppid;
+    proci->ppid_status = PSI_STATUS_OK;
+    proci->pgrp = (pid_t)pgrp;
+    proci->pgrp_status = PSI_STATUS_OK;
+    proci->sid = (pid_t)sid;
+    proci->sid_status = PSI_STATUS_OK;
+    ticks2timespec(&proci->utime, utime);
+    proci->utime_status = PSI_STATUS_OK;
+    ticks2timespec(&proci->stime, stime);
+    proci->stime_status = PSI_STATUS_OK;
+    proci->cputime = calc_cputime(proci->utime, proci->stime);
+    proci->cputime_status = PSI_STATUS_OK;
+    if (priority < 0)
+        proci->priority = -priority - 1;
+    else
+        proci->priority = 0;
+    proci->priority_status = PSI_STATUS_OK;
+    proci->nice = nice;
+    proci->nice_status = PSI_STATUS_OK;
+    proci->nthreads = num_threads;
+    proci->nthreads_status = PSI_STATUS_OK;
+    if (calc_start_time(&proci->start_time, starttime) < 0)
+        return -1;
+    proci->start_time_status = PSI_STATUS_OK;
+    proci->jiffies = starttime;
+    proci->jiffies_status = PSI_STATUS_OK;
+    proci->vsz = vsize;
+    proci->vsz_status = PSI_STATUS_OK;
+    proci->rss = rss * sysconf(_SC_PAGESIZE);
+    proci->rss_status = PSI_STATUS_OK;
+    return 0;
+}
+
+
+static int
+parse_uid_from_proc_status(struct psi_process *proci, const char *line)
+{
+    int ruid, euid, suid, fsuid;
+    int r;
+
+    r = sscanf(line, "%d%d%d%d", &ruid, &euid, &suid, &fsuid);
+    if (r == 4) {
+        proci->ruid = ruid;
+        proci->ruid_status = PSI_STATUS_OK;
+        proci->euid = euid;
+        proci->euid_status = PSI_STATUS_OK;
+        return 0;
+    }
+    else {
+        PyErr_SetString(PyExc_OSError, "Failed to parse UID");
+        return -1;
+    }
+}
+
+
+static int
+parse_gid_from_proc_status(struct psi_process *proci, const char *line)
+{
+    int rgid, egid, sgid, fsgid;
+    int r;
+
+    r = sscanf(line, "%d%d%d%d", &rgid, &egid, &sgid, &fsgid);
+    if (r == 4) {
+        proci->rgid = rgid;
+        proci->rgid_status = PSI_STATUS_OK;
+        proci->egid = egid;
+        proci->egid_status = PSI_STATUS_OK;
+        return 0;
+    }
+    else {
+        PyErr_SetString(PyExc_OSError, "Failed to parse GID");
+        return -1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/linux_psi.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/linux_psi.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/linux_psi.c
new file mode 100644
index 0000000..f7eefa2
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/linux_psi.c
@@ -0,0 +1,77 @@
+/* The MIT License
+ *
+ * Copyright (C) 2009 Erick Tryzelaar
+ *
+ * Copyright (C) 2009 Floris Bruynooghe
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/* Linux implementations of the _psi non-POSIX functions */
+
+#include <Python.h>
+
+#include <stdlib.h>
+
+#include "psifuncs.h"
+#include "linux_utils.h"
+
+
+int
+arch_boottime(struct timespec *boottime) {
+    FILE* fp;
+    char* line = NULL;
+    size_t len = 0;
+    long btime;
+    int found = 0;
+
+    fp = fopen("/proc/stat", "r");
+    if (fp == NULL) {
+        PyErr_SetFromErrnoWithFilename(PyExc_OSError, "/proc/stat");
+        return -1;
+    }
+    while ((getline(&line, &len, fp)) != -1)
+        if (sscanf(line, "btime %ld", &btime) != 0) {
+            found = 1;
+            break;
+        }
+    if (line)
+        free(line);
+    fclose(fp);
+    if (!found) {
+        PyErr_SetString(PyExc_OSError,
+                        "Failed to find btime in /proc/stat");
+        return -1;
+    }
+    boottime->tv_sec = btime;
+    boottime->tv_nsec = 0;
+    return 0;
+}
+
+
+int
+arch_uptime(struct timespec *uptime)
+{
+    struct timespec it;
+    
+    if (psi_linux_uptime(uptime, &it) < 0)
+        return -1;
+    return 0;
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/linux_utils.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/linux_utils.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/linux_utils.c
new file mode 100644
index 0000000..979b5ba
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/linux_utils.c
@@ -0,0 +1,83 @@
+/* The MIT License
+ *
+ * Copyright (C) 2009 Floris Bruynooghe
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+
+/* Utility functions specific to Linux */
+
+
+#include <Python.h>
+
+#include <time.h>
+
+#include "psi.h"
+#include "linux_utils.h"
+#include "posix_utils.h"
+
+
+/** psi_linux_uptime(&uptime, &idletime
+ *
+ * Retrieve the uptime and idle time from /proc/uptime in seconds and save
+ * them in the double * pointers provided.
+ *
+ * This function needs to avoid setlocale() for thread safety, hence the
+ * jumping though hoops to use PyOS_ascii_atof().
+ *
+ * Returns -1 in case of failure, 0 for success.
+ */
+int
+psi_linux_uptime(struct timespec *uptime, struct timespec *idletime)
+{
+    char *uptime_s; 
+    char *idle_s; 
+    char *buf;
+    double uptime_d;
+    double idletime_d;
+    int bufsize; 
+    int r; 
+
+    bufsize = psi_read_file(&buf, "/proc/uptime");
+    if (bufsize < 0)
+        return -1;
+    uptime_s = psi_malloc(bufsize * sizeof(char)); 
+    idle_s = psi_malloc(bufsize * sizeof(char)); 
+    if (uptime_s == NULL || idle_s == NULL) { 
+        psi_free(buf); 
+        psi_FREE(uptime_s); 
+        psi_FREE(idle_s); 
+        return -1; 
+    } 
+    r = sscanf(buf, "%s %s", uptime_s, idle_s); 
+    psi_free(buf); 
+    if (r != 2) { 
+        PyErr_SetString(PyExc_OSError, "Failed to parse /proc/uptime"); 
+        return -1; 
+    }
+    uptime_d = PyOS_string_to_double(uptime_s, NULL, NULL);
+    idletime_d = PyOS_string_to_double(idle_s, NULL, NULL);
+    psi_free(uptime_s); 
+    psi_free(idle_s);
+    *uptime = posix_double2timespec(uptime_d);
+    *idletime = posix_double2timespec(idletime_d);
+    return 0; 
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/posix_arch.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/posix_arch.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/posix_arch.c
new file mode 100644
index 0000000..923cfa9
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/posix_arch.c
@@ -0,0 +1,75 @@
+/* The MIT License
+ *
+ * Copyright (C) 2008-2009 Floris Bruynooghe
+ *
+ * Copyright (C) 2008-2009 Abilisoft Ltd.
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/* POSIX implementation of the Arch classes */
+
+
+#include <Python.h>
+
+#include <string.h>
+#include <sys/utsname.h>
+
+#include "psi.h"
+#include "arch.h"
+
+
+struct psi_archinfo *
+psi_arch_archinfo(void)
+{
+    struct psi_archinfo *archi;
+    struct utsname uts;
+    int r;
+
+    r = uname(&uts);
+    if( r == -1 ) {
+        PyErr_Format(PyExc_OSError, "uname() system call failed");
+        return NULL;
+    }
+    archi = psi_calloc(sizeof(struct psi_archinfo));
+    if (archi == NULL)
+        return NULL;
+    archi->sysname_status = PSI_STATUS_OK;
+    archi->sysname = psi_strdup(uts.sysname);
+    if (archi->sysname == NULL)
+        return psi_free_archinfo(archi);
+    archi->release_status = PSI_STATUS_OK;
+    archi->release = psi_strdup(uts.release);
+    if (archi->release == NULL)
+        return psi_free_archinfo(archi);
+    archi->version_status = PSI_STATUS_OK;
+    archi->version = psi_strdup(uts.version);
+    if (archi->version == NULL)
+        return psi_free_archinfo(archi);
+    archi->machine_status = PSI_STATUS_OK;
+    archi->machine = psi_strdup(uts.machine);
+    if (archi->machine == NULL)
+        return psi_free_archinfo(archi);
+    archi->nodename_status = PSI_STATUS_OK;
+    archi->nodename = psi_strdup(uts.nodename);
+    if (archi->nodename == NULL)
+        return psi_free_archinfo(archi);
+    return archi;
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/posix_mount.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/posix_mount.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/posix_mount.c
new file mode 100644
index 0000000..42a704f
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/posix_mount.c
@@ -0,0 +1,67 @@
+/* The MIT License
+ *
+ * Copyright (C) 2008-2009 Floris Bruynooghe
+ *
+ * Copyright (C) 2008-2009 Abilisoft Ltd.
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/* Common functions for POSIX process implementations. */
+
+#include <Python.h>
+
+#include <errno.h>
+#include <sys/statvfs.h>
+
+#include "psi.h"
+#include "mount.h"
+#include "posix_mount.h"
+
+
+int
+posix_set_vfs(psi_mountinfo_t *mounti)
+{
+    struct statvfs stat;
+    int r;
+
+    Py_BEGIN_ALLOW_THREADS;
+    r = statvfs(mounti->mount_path, &stat);
+    Py_END_ALLOW_THREADS;
+    if (r < 0) {
+        PyErr_SetFromErrnoWithFilename(PyExc_OSError, mounti->mount_path);
+        return -1;
+    }
+    mounti->frsize = stat.f_frsize;
+    mounti->total = stat.f_blocks;
+    mounti->bfree = stat.f_bfree;
+    mounti->bavail = stat.f_bavail;
+    mounti->files = stat.f_files;
+    mounti->ffree = stat.f_ffree;
+    mounti->favail = stat.f_favail;
+    mounti->frsize_status = PSI_STATUS_OK;
+    mounti->total_status = PSI_STATUS_OK;
+    mounti->bfree_status = PSI_STATUS_OK;
+    mounti->bavail_status = PSI_STATUS_OK;
+    mounti->files_status = PSI_STATUS_OK;
+    mounti->ffree_status = PSI_STATUS_OK;
+    mounti->favail_status = PSI_STATUS_OK;
+    return 0;
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/posix_utils.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/posix_utils.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/posix_utils.c
new file mode 100644
index 0000000..4caf79a
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/posix_utils.c
@@ -0,0 +1,167 @@
+/* The MIT License
+ *
+ * Copyright (C) 2008-2009 Floris Bruynooghe
+ *
+ * Copyright (C) 2008-2009 Abilisoft Ltd.
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/* Common functions for POSIX process implementations. */
+
+#include <Python.h>
+
+#include <errno.h>
+#include <grp.h>
+#include <pwd.h>
+#include <time.h>
+#include <utmpx.h>
+
+#include "psi.h"
+#include "posix_utils.h"
+
+
+/* Global variable for caching, need to read utmp only once. */
+static struct timespec utmpx_boottime = {0, 0};
+
+
+/***** Functions *****/
+
+
+struct timeval
+posix_timeval_subtract(struct timeval *x, struct timeval *y)
+{
+    struct timeval result;
+    long nsec;
+    
+    if (x->tv_usec < y->tv_usec) {
+        nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1;
+        y->tv_usec -= 1000000 * nsec;
+        y->tv_sec += nsec;
+    }
+    if (x->tv_usec - y->tv_usec > 1000000) {
+        nsec = (x->tv_usec - y->tv_usec) / 1000000;
+        y->tv_usec += 1000000 * nsec;
+        y->tv_sec -= nsec;
+    }
+    result.tv_sec = x->tv_sec - y->tv_sec;
+    result.tv_usec = x->tv_usec - y->tv_usec;
+    return result;
+}
+
+
+struct timespec
+posix_timespec_subtract(struct timespec *x, struct timespec *y)
+{
+    struct timespec result;
+    long nsec;
+    
+    if (x->tv_nsec < y->tv_nsec) {
+        nsec = (y->tv_nsec - x->tv_nsec) / 1000000000 + 1;
+        y->tv_nsec -= 1000000000 * nsec;
+        y->tv_sec += nsec;
+    }
+    if (x->tv_nsec - y->tv_nsec > 1000000000) {
+        nsec = (x->tv_nsec - y->tv_nsec) / 1000000000;
+        y->tv_nsec += 1000000000 * nsec;
+        y->tv_sec -= nsec;
+    }
+    result.tv_sec = x->tv_sec - y->tv_sec;
+    result.tv_nsec = x->tv_nsec - y->tv_nsec;
+    return result;
+}
+
+
+struct timespec
+posix_double2timespec(const double dbl)
+{
+    struct timespec tspec;
+    
+    tspec.tv_sec = (long)dbl;
+    tspec.tv_nsec = (long)((dbl-tspec.tv_sec)*1000000000);
+    return tspec;
+}
+
+
+/** Read boottime from utmpx
+ *
+ * Note that the assignment of uti->ut_tv needs to be done in parts since
+ * Linux does specify it weirdly to keep the same size in 32 and 64-bit.
+ */
+int
+posix_utmpx_boottime(struct timespec *boottime)
+{
+    struct timeval new_time;
+    struct utmpx *uti;
+    struct utmpx id;
+
+    if (utmpx_boottime.tv_sec != 0) {
+        *boottime = utmpx_boottime;
+        return 0;
+    }
+    uti = getutxent();
+    if (uti == NULL) {
+        PyErr_SetString(PyExc_OSError, "Failed to open utmpx database");
+        return -1;
+    }
+    setutxent();
+    id.ut_type = BOOT_TIME;
+    uti = getutxid(&id);
+    if (uti == NULL) {
+        endutxent();
+        PyErr_SetString(PyExc_OSError,
+                        "Failed to find BOOT_TIME in utmpx database");
+        return -1;
+    }
+    utmpx_boottime.tv_sec = uti->ut_tv.tv_sec;
+    utmpx_boottime.tv_nsec = uti->ut_tv.tv_usec * 1000;
+
+    /* Now possibly adjust for clock changes since boot */
+    setutxent();
+    id.ut_type = NEW_TIME;
+    uti = getutxid(&id);
+    while (uti != NULL) {
+        new_time.tv_sec = uti->ut_tv.tv_sec;
+        new_time.tv_usec = uti->ut_tv.tv_usec;
+        id.ut_type = OLD_TIME;
+        uti = getutxid(&id);
+        if (uti == NULL) {
+            PyErr_SetString(PyExc_OSError,
+                            "No matching OLD_TIME record "
+                            "for a NEW_TIME record in utmpx");
+            utmpx_boottime.tv_sec = 0;
+            utmpx_boottime.tv_nsec = 0;
+            return -1;
+        }
+        if (uti->ut_tv.tv_sec > utmpx_boottime.tv_sec ||
+            (uti->ut_tv.tv_sec == utmpx_boottime.tv_sec &&
+             uti->ut_tv.tv_usec * 1000 > utmpx_boottime.tv_nsec)) {
+            utmpx_boottime.tv_sec += new_time.tv_sec - uti->ut_tv.tv_sec;
+            utmpx_boottime.tv_nsec += (new_time.tv_usec -
+                                       uti->ut_tv.tv_usec) * 1000;
+        } else
+            break;
+        id.ut_type = NEW_TIME;
+        uti = getutxid(&id);
+    }
+    endutxent();
+    *boottime = utmpx_boottime;
+    return 0;
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/procfs_processtable.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/procfs_processtable.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/procfs_processtable.c
new file mode 100644
index 0000000..b7a562f
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/procfs_processtable.c
@@ -0,0 +1,158 @@
+/* The MIT License
+ *
+ * Copyright (C) 2008-2009 Floris Bruynooghe
+ *
+ * Copyright (C) 2008-2009 Abilisoft Ltd.
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/* POSIX implementation of the ProcessTable class */
+
+
+#include <Python.h>
+
+#include <dirent.h>
+
+#include "psi.h"
+#include "process.h"
+
+
+#if (defined(SUNOS5) && SUNOS5_MINOR < 10) || defined(AIX)
+#define SCANDIR myscandir
+#else
+#define SCANDIR scandir
+#endif
+
+
+static void
+free_dentlist(struct dirent **dentlist, const int ndirs)
+{
+    int i;
+
+    for (i = 0; i < ndirs; i++)
+        free(dentlist[i]);
+    free(dentlist);
+}
+
+
+#if (defined(SUNOS5) && SUNOS5_MINOR < 10) || defined(AIX)
+
+/** Simplified scandir() implementation
+ *
+ * The scandir() function is hidden somewhere in /usr/ucb/cc on Solaris 8 & 9
+ * and not available by default.  On AIX scandir() does not return any entries
+ * in /proc for some unknown reason, this version does.
+ *
+ * In this version the `select' and `cmp' arguments are ignored.
+ */
+static int
+myscandir(const char *dir,
+          struct dirent ***namelist,
+          int (*select) (const struct dirent *),
+          int (*cmp) (const void *, const void *))
+{
+    DIR *dirp;
+    struct dirent **dentlist;
+    struct dirent **dlp;
+    struct dirent *dentp;
+    struct dirent *dcpy;
+    int dentlist_size = 100;
+    int ndirs = 0;
+
+    dentlist = (struct dirent **)malloc(dentlist_size*sizeof(struct dirent *));
+    if (dentlist == NULL)
+        return -1;
+    dirp = opendir(dir);
+    if (dirp == NULL) {
+        free(dentlist);
+        return -1;
+    }
+    while ((dentp = readdir(dirp)) != NULL) {
+        dcpy = (struct dirent *)malloc(sizeof(struct dirent));
+        if (dcpy == NULL) {
+            free_dentlist(dentlist, ndirs);
+            closedir(dirp);
+            return -1;
+        }
+        memcpy(dcpy, dentp, sizeof(struct dirent));
+        dentlist[ndirs] = dcpy;
+        ndirs++;
+        if (ndirs >= dentlist_size) {
+            dentlist_size += 100;
+            dlp = (struct dirent **)realloc(
+                dentlist, dentlist_size*sizeof(struct dirent *));
+            if (dlp == NULL) {
+                free_dentlist(dentlist, ndirs);
+                closedir(dirp);
+                return -1;
+            }
+            dentlist = dlp;
+        }
+    }
+    closedir(dirp);
+    *namelist = dentlist;
+    return ndirs;
+}
+
+#endif  /* (defined(SUNOS5) && SUNOS5_MINOR < 10) || defined(AIX) */
+
+
+struct psi_proclist *
+psi_arch_proclist(void)
+{
+    struct psi_proclist *prl;
+    struct dirent **dentlist;
+    struct dirent *dentp;
+    pid_t pid;
+    int ndirs;
+    int i;
+
+    errno = 0;
+    ndirs = SCANDIR("/proc", &dentlist, NULL, NULL);
+    if (ndirs == -1)
+        return (struct psi_proclist *) PyErr_SetFromErrnoWithFilename(
+            PyExc_OSError, "/proc");
+    prl = (struct psi_proclist *) psi_malloc(sizeof(struct psi_proclist));
+    if (prl == NULL) {
+        free_dentlist(dentlist, ndirs);
+        return NULL;
+    }
+    prl->pids = (pid_t *) psi_malloc(ndirs * sizeof(pid_t));
+    if (prl->pids == NULL) {
+        psi_free(prl);
+        free_dentlist(dentlist, ndirs);
+        return NULL;
+    }
+    prl->count = 0;
+    for (i = 0; i < ndirs; i++) {
+        dentp = dentlist[i];
+        if (dentp->d_name[0] == '.')
+            continue;           /* skip `.' and `..' */
+        errno = 0;
+        pid = (pid_t)strtol(dentp->d_name, (char**)NULL, 10);
+        if (pid <= 0 || errno)
+            continue;           /* not a /proc/<pid> */
+        prl->pids[prl->count] = pid;
+        prl->count++;
+    }
+    free_dentlist(dentlist, ndirs);
+    return prl;
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/procfs_utils.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/procfs_utils.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/procfs_utils.c
new file mode 100644
index 0000000..353edcf
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/procfs_utils.c
@@ -0,0 +1,131 @@
+/* The MIT License
+ *
+ * Copyright (C) 2008-2009 Floris Bruynooghe
+ *
+ * Copyright (C) 2008-2009 Abilisoft Ltd.
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/* Common functions for POSIX process implementations. */
+
+
+#include <Python.h>
+
+#include <limits.h>
+#include <sys/stat.h>
+
+#include "psi.h"
+#include "process.h"
+#include "procfs_utils.h"
+
+
+int
+procfs_check_pid(pid_t pid)
+{
+    struct stat stati;
+    char *fname;
+    int r;
+
+    r = psi_asprintf(&fname, "/proc/%d", pid);
+    errno = 0;
+    r = stat(fname, &stati);
+    if (r == -1) {
+        if (errno == EACCES)
+            PyErr_SetString(PyExc_OSError, "No read access for /proc");
+        else if (errno == ENOENT)
+            PyErr_Format(PsiExc_NoSuchProcessError,
+                         "No such PID: %ld", (long)pid);
+        else
+            PyErr_SetFromErrnoWithFilename(PyExc_OSError, fname);
+    }
+    psi_free(fname);
+    return r;
+}
+
+
+int
+procfs_read_procfile(char **buf, const pid_t pid, char *fname)
+{
+    char *path;
+    int r;
+
+    *buf = NULL;
+    r = psi_asprintf(&path, "/proc/%d/%s", pid, fname);
+    if (r == -1)
+        return -1;
+    r = psi_read_file(buf, path);
+    psi_free(path);
+    if (r == -1)
+        procfs_check_pid(pid);  /* OSError -> NoSuchProcessError if required */
+    return r;
+}
+
+
+int
+procfs_argv_from_string(char ***argv,
+                        char *argstr,
+                        const unsigned int argc)
+{
+    char *ptr;
+    char *arg;
+    char quote;
+    unsigned int i;
+
+    *argv = (char**)psi_calloc(argc*sizeof(char*));
+    if (*argv == NULL)
+        return -1;
+    ptr = argstr;
+    for (i=0; i < argc; i++) {
+        while (isspace((int)*ptr) && *ptr != '\0')
+            ptr++;
+        if (*ptr == '\0')
+            break;
+        arg = ptr;
+        if (*ptr == '\'' || *ptr == '"') {
+            quote = *ptr;
+            arg++;              /* don't include the quote in the arg */
+            do {
+                ptr++;
+                while (*ptr == '\\') /* skip to next unescaped char */
+                    ptr += 2;
+            } while (*ptr != quote);
+            (*argv)[i] = (char*)psi_malloc(ptr - arg + 1);
+            if ((*argv)[i] == NULL)
+                return -1;
+            strncpy((*argv)[i], arg, ptr-arg);
+            *((*argv)[i] + (ptr-arg)) = '\0';
+        } else {
+            do
+                ptr++;
+            while (!isspace((int)*ptr) && *ptr != '\0');
+            (*argv)[i] = (char*)psi_malloc(ptr - arg + 1);
+            if ((*argv)[i] == NULL)
+
+                return -1;
+            strncpy((*argv)[i], arg, ptr-arg);
+            *((*argv)[i] + (ptr-arg)) = '\0';
+        }
+    }
+    if (i > INT_MAX)
+        return INT_MAX;
+    else
+        return (int)i;
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/sargs64.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/sargs64.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/sargs64.c
new file mode 100644
index 0000000..55735c2
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/sargs64.c
@@ -0,0 +1,202 @@
+/* The MIT License
+ *
+ * Copyright (C) 2009 Floris Bruynooghe
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/* SunOS helper to retrieve arguments and environment variables from a 64-bit
+ * process when Python is compiled as 32-bit. */
+
+/* Note that we avoid reporting errors to stderr since we're not sure where
+ * they would appear.  Stdout gets ignored when we return non-zero so that is
+ * a good place to report errors to. */
+
+/* For now there is no dynamic allocation and if there was this program is
+ * very-short lived anyway.  So any function with an error should just print
+ * the error (for debugging purposes) and call `exit(1)'.  `exit(2)' is
+ * reserved for when there is a permissions problem. */
+
+
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <procfs.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+
+#ifdef _ILP32
+#error This helper app should be compiled in 64-bit mode
+#endif 
+
+
+/* Read psinfo into a buffer and return it
+ *
+ * The psinfo variable will be filled in on success.
+ */
+static void
+read_psinfo(psinfo_t *psinfo, const char *pidstr)
+{
+    char path[PATH_MAX];
+    ssize_t r;
+    int fd;
+
+    sprintf(path, "/proc/%s/psinfo", pidstr);
+    fd = open(path, O_RDONLY);
+    if (fd == -1) {
+        printf("Failed to open %s\n", path);
+        exit(1);
+    }
+    r = read(fd, psinfo, sizeof(psinfo_t));
+    if (r == -1) {              /* XXX */
+        printf("errno %d: %s\n", errno, strerror(errno));
+        exit(1);
+    }
+    if (r != sizeof(psinfo_t)) {
+        printf("Read wrong number of bytes from psinfo (%d != %d)\n",
+               (int)r, (int)sizeof(psinfo_t));
+        exit(1);
+    }
+}
+
+
+/* Open the address space (core) of the process
+ *
+ * The fd parameter will contain the open file descriptor of the core on
+ * success.
+ */
+static void
+open_as(int *fd, const char *pidstr)
+{
+    char path[PATH_MAX];
+
+    sprintf(path, "/proc/%s/as", pidstr);
+    *fd = open(path, O_RDONLY);
+    if (*fd == -1) {
+        if (errno == EACCES || errno == EPERM)
+            exit(2);
+        else {
+            printf("Failed to open core: %d, %s", errno, strerror(errno));
+            exit(1);
+        }
+    }
+}
+
+
+/** Read a string from a process core
+ *
+ * This keeps reading characters from the core image, open as file descriptor
+ * `asfd', starting from `offset' until '\0' is read.  Each character,
+ * including the trailing NULL character is written to stdout.
+ */
+static void
+read_str_from_core(const off_t offset, const int asfd)
+{
+    off_t charptr;
+    ssize_t r;
+    char c;
+
+    charptr = offset;
+    do {
+        r = pread(asfd, &c, sizeof(char), charptr++);
+        if (r < 0) {
+            puts("Failed reading char from core\n");
+            exit(1);
+        }
+        putchar(c);
+    } while (c != '\0');
+}
+
+
+/** Retrieve the argument list from process core
+ *
+ * This prints the argv vector on stdout and will terminate with an extra
+ * '\0'.
+ */
+static void
+get_args(const psinfo_t *psinfo, const int asfd)
+{
+    off_t argvoff = (off_t)psinfo->pr_argv;
+    off_t argaddr;              /* not caddr_t because of casting issues */
+    ssize_t r;
+    int i;
+
+    for (i = 0; i < psinfo->pr_argc; i++) {
+        r = pread(asfd, &argaddr, sizeof(off_t), argvoff + i*sizeof(off_t));
+        if (r < 0) {
+            puts("Failed reading argaddr from core\n");
+            exit(1);
+        }
+        read_str_from_core(argaddr, asfd);
+    }
+    putchar('\0');
+}
+
+
+static void
+get_envp(const psinfo_t *psinfo, const int asfd) {
+    off_t envpoff = (off_t)psinfo->pr_envp;
+    off_t envaddr;              /* not caddr_t because of casting issues */
+    ssize_t r;
+    int i = 0;
+
+    r = pread(asfd, &envaddr, sizeof(off_t), envpoff);
+    if (r < 0) {
+        puts("Failed to read envaddr from core\n");
+        exit(1);
+    }
+    while (envaddr != NULL) {
+        read_str_from_core(envaddr, asfd);
+        i++;
+        r = pread(asfd, &envaddr, sizeof(off_t), envpoff + i*sizeof(off_t));
+        if (r < 0) {
+            puts("Failed to read envaddr from core (bis)\n");
+            exit(1);
+        }
+    }
+    putchar('\0');
+}
+
+
+int
+main(int argc, char **argv)
+{
+    psinfo_t psinfo;
+    int fd;
+
+    if (argc != 2) {
+        printf("Wrong argument count: %d\n", argc);
+        exit(1);
+    }
+    read_psinfo(&psinfo, argv[1]);
+    if (psinfo.pr_dmodel != PR_MODEL_LP64) {
+        puts("psinfo.pr_dmodel != PR_MODEL_LP64\n");
+        exit(1);
+    }
+    open_as(&fd, argv[1]);
+    get_args(&psinfo, fd);
+    get_envp(&psinfo, fd);
+    return 0;
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/sunos_mount.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/sunos_mount.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/sunos_mount.c
new file mode 100644
index 0000000..e0c1557
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch/sunos_mount.c
@@ -0,0 +1,171 @@
+/* The MIT License
+ *
+ * Copyright (C) 2009 Erick Tryzelaar
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include <Python.h>
+
+#include <stdio.h>
+#include <sys/mnttab.h>
+#include <sys/statvfs.h>
+#include <sys/types.h>
+
+#include "psi.h"
+#include "mount.h"
+
+
+/***** Local declarations *****/
+
+static int set_mntent(psi_mountinfo_t *mounti, struct mnttab *mntent);
+static int set_vfs(psi_mountinfo_t *mounti);
+
+
+/***** Public functions *****/
+
+psi_mountlist_t *
+psi_arch_mountlist(const int remote)
+{
+    FILE *mnttab;
+    struct mnttab mntent;
+    psi_mountlist_t *ml = NULL;
+    psi_mountinfo_t *mounti, **mounts;
+    int rc;
+
+    /* Open up the system's mount information file */
+    if ((mnttab = fopen(MNTTAB, "r")) == NULL) {
+        PyErr_SetFromErrnoWithFilename(PyExc_OSError, MNTTAB);
+        return NULL;
+    }
+
+    /* Create our (empty) mountlist */
+    ml = (psi_mountlist_t *)psi_calloc(sizeof(psi_mountlist_t));
+    if (ml == NULL) {
+        fclose(mnttab);
+        return NULL;
+    }
+
+    /* Step through each line in the mount file */
+    while ((rc = getmntent(mnttab, &mntent)) == 0) {
+        if (!remote && strchr(mntent.mnt_special, ':') != NULL)
+            continue;           /* Skip remote filesystems */
+        if ((mounti = psi_calloc(sizeof(psi_mountinfo_t))) == NULL) {
+            fclose(mnttab);
+            psi_free_mountlist(ml);
+            return NULL;
+        }
+        mounts = (psi_mountinfo_t **)psi_realloc(
+            ml->mounts,
+            (ml->count + 1) * sizeof(psi_mountinfo_t *));
+        if (mounts == NULL) {
+            fclose(mnttab);
+            psi_free_mountinfo(mounti);
+            psi_free_mountlist(ml);
+            return NULL;
+        }
+        ml->mounts = mounts;
+        ml->mounts[ml->count] = mounti;
+        ml->count += 1;
+
+        /* Finally add the information to mounti */
+        if (set_mntent(mounti, &mntent) < 0) {
+            fclose(mnttab);
+            psi_free_mountlist(ml);
+            return NULL;
+        }
+        if (set_vfs(mounti) < 0) {
+            fclose(mnttab);
+            psi_free_mountlist(ml);
+            return NULL;
+        }
+    }
+    fclose(mnttab);
+    if (rc != -1) {             /* Uh oh, we had a read error */
+        psi_free_mountlist(ml);
+        PyErr_Format(PyExc_OSError, "Read error in %s", MNTTAB);
+        return NULL;
+    }
+    return ml;
+}
+
+
+/***** Local Functions *****/
+
+
+#define STRDUP(dst, src)                    \
+    if ((dst = psi_strdup(src)) == NULL)    \
+        return -1;                          \
+    dst ## _status = PSI_STATUS_OK
+
+
+static int
+set_mntent(psi_mountinfo_t *mounti, struct mnttab *mntent)
+{
+    char *p;
+
+    p = strchr(mntent->mnt_special, ':');
+    if (p == NULL) {            /* Local mount */
+        mounti->filesystem_host_status = PSI_STATUS_OK;
+        STRDUP(mounti->filesystem_path, mntent->mnt_special);
+    } else {
+        *p = '\0';
+        STRDUP(mounti->filesystem_host, mntent->mnt_special);
+        STRDUP(mounti->filesystem_path, p + 1);
+    }
+    STRDUP(mounti->mount_type, mntent->mnt_fstype);
+    STRDUP(mounti->mount_path, mntent->mnt_mountp);
+    STRDUP(mounti->mount_options, mntent->mnt_mntopts);
+    return 0;
+}
+
+
+/** Set the filesystem size information
+ *
+ * This information comes from the POSIX statvfs() call.
+ */
+static int set_vfs(psi_mountinfo_t *mounti)
+{
+    struct statvfs stat;
+    int r;
+
+    Py_BEGIN_ALLOW_THREADS;
+    r = statvfs(mounti->mount_path, &stat);
+    Py_END_ALLOW_THREADS;
+    if (r < 0) {
+        PyErr_SetFromErrnoWithFilename(PyExc_OSError, mounti->mount_path);
+        return -1;
+    }
+    mounti->frsize = stat.f_frsize;
+    mounti->total = stat.f_blocks;
+    mounti->bfree = stat.f_bfree;
+    mounti->bavail = stat.f_bavail;
+    mounti->files = stat.f_files;
+    mounti->ffree = stat.f_ffree;
+    mounti->favail = stat.f_favail;
+    mounti->frsize_status = PSI_STATUS_OK;
+    mounti->total_status = PSI_STATUS_OK;
+    mounti->bfree_status = PSI_STATUS_OK;
+    mounti->bavail_status = PSI_STATUS_OK;
+    mounti->files_status = PSI_STATUS_OK;
+    mounti->ffree_status = PSI_STATUS_OK;
+    mounti->favail_status = PSI_STATUS_OK;
+    return 0;
+}


[14/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code

Posted by rl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/NEWS
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/NEWS b/tools/bin/pythonSrc/pychecker-0.8.18/NEWS
new file mode 100644
index 0000000..1b602db
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/NEWS
@@ -0,0 +1,406 @@
+Version 0.8.18   - XXX
+  * Fixed SF Bug [ 1827412 ] pychecker.bat only handles 9 cmdline args
+  * Fix warning about comparison checking with bool false alert for 'in' and 'not in'
+  * Add warning for using __set__, __get__, and __delete__ in an old-style class
+  * Fix spurious warning about __set__, __get__, and __delete__ not being special
+    methods.
+  * Fix inability to disable Warning about constant setattr()/getattr()
+  * Fix spurious warning on min/max not accepting kwarg of key in Python 2.5
+  * Add some __special__ pickling methods that were missing
+  * Add --missingattrs option to ignore some (but not all) attribute names
+  * Fix crash when using keyword arguments with builtin methods
+  * Add --keepgoing option to ignore import errors
+  * Add --findevil option to make it easier to find objects that crash the interpreter
+  * Add support for Python 2.5
+
+Version 0.8.17   - 3 February 2006
+  * Fix spurious warning for Statement with no effect using bit shifts
+  * Add -#/--limit command line option to set the max # of warnings to show
+  * Remove broken command line options:  -e/--errors, --complexity
+  * Add -e/--level command line options which allows the error level
+    to be specified:  error, security, warning, unused, deprecated, style.
+    These names map to numbers: 90, 90, 70, 50, 40, 10 (error == security).
+    Specifying a value means all levels equal to or greater than it.
+  * Add --only option which displays warnings only for files specified
+    on the command line
+  * Add --evil option for users to prevent the interpreter from crashing
+    due to broken C extensions
+  * Fix wrong file name when warning about returning values from
+    __init__ functions. (#1291116)
+  * Fix a few more glitches with setup.py.
+  * Suppress warning about integer division when the code is: int(x / y)
+  * Add code to skip testing objects from extension modules that are
+    known to crash the interpreter.  Currently, the list includes old versions of
+    matplotlib.axes.BinOpType and wx.TheClipboard.
+  * Support ROT_THREE and ROT_FOUR opcodes
+
+Version 0.8.16   - 4 September 2005
+  * Fix problems installing on Windows and running setup.py build
+
+Version 0.8.15   - 31 August 2005
+  * Fix spurious warning about catching string exceptions
+  * Don't barf if there is # -*- encoding: ... -*- lines and unicode strings
+  * setup.py was rewritten to honor --root, --home, etc options
+  * Fix internal error on processing nested scopes
+  * Fix constant tuples in Python 2.4
+  * Don't warn about implicit/explicit returns in Python 2.4, we can't tell
+  * Fix crash when __slots__ was an instance w/o __len__
+  * Fix bug that declared {}.pop to only take one argument, it takes 1 or 2
+  * Fix spurious warning when using tuples for exceptions
+  * Fix spurious warning <stack> / <stack> 
+  * Fix spurious warnings for sets module about __cmp__, __hash__
+  * Changed abstract check to require raising NotImplementedError
+    rather than raising any error
+  * Fix spurious warnings in Python 2.4 for Using is (not) None warnings
+  * Fix spurious warnings for some instances of No class attribute found
+  * Fix spurious warnings for implicit returns when using nested functions
+
+Version 0.8.14   - 6 June 2004
+  * Fix spurious warning in Python 2.3+ when doing a,b = 1,2
+  * Add warning to check for "if s.find(str):"
+      this should be "if s.find(str) >= 0:" when s is a string
+  * Fix spurious warning when using augmented assignment (e.g., x += x)
+  * Fix spurious warning when doing x = not x
+  * Fix spurious warning for invalid arg count when calling a staticmethod
+  * Fix spurious warning for setting a variable to itself when:  x, y, z = x
+  * Fix spurious warning when doing some binary operations:  self.a ^ self.b
+  * Fix crash in STORE_ATTR with some list comprehensions in Python 2.2
+  	e.g., a.a = [x for x in range(2) if x > 1]
+  * Support Tk 8.4 and above in the GUI (change col= to column=)
+
+Version 0.8.13   - 18 November 2003
+  * Add -s/--shadowbuiltin option to warn when overriding a builtin
+  * Add warning when assigning a variable to itself
+  * Add warning when dividing a variable by itself
+  * Add warnings when using a bit-wise operator with the same variable (a & a)
+  * Add warning when passing a constant string to getattr()/setattr()
+  * Add --special option to check for __special__ (reserved) method names
+    and that their signature (argument count) is correct
+  * Add warning for using __getattribute__ in an old-style class
+  * Suppress 'self as first argument' warning for static and class methods
+  * Add --classmethodargs option to specify first argument name
+    for class methods
+
+Version 0.8.12   - 23 December 2002
+  * Add --isliteral option to warn when using is/is not against literal
+    (e.g., XXX is 5    YYY is not 'abcdef', etc)
+  * Add --modulo1 option to warn when using (expr % 1),
+    which is constant when expr is an integer or string
+  * Add -4/--noeffect option to disable warnings for 'Statement has no effect'
+  * self is not first argument warning can be disabled with -S/--self ''
+  * Don't print duplicate warnings when importing pychecker
+  * Fix other spurious warnings when importing pychecker
+  * Fix bug for spurious invalid arguments when passing a dict inline
+  * Fix bug for spurious Statement has no effect when print >> x, ... ,
+  * Add @option_file command line argument to read options from a file
+  	(used on platforms which can't have too many options, ie Windows)
+  * Fix several crashes
+  * Line numbers should be close for Python 2.3 and if run on optimized code
+
+Version 0.8.11   - 06 June 2002
+  * Improve error message for syntax errors from user files
+  * Fix pychecker.bat so it should work now
+  * Add a warning for using __coerce__ in new-style classes
+  * Add --deprecated option for using deprecated modules or functions
+  * Add a warning for using functions with security problems (os.t[e]mpnam)
+  * Add a warning for comparing against True/False or defining True/False
+  * Add --badexcept option to warn when using string exceptions or
+        classes not derived from Exception to raise/catch exceptions
+  * Fix spurious warnings from using (test and 'true' or 'false)
+
+Version 0.8.10   - 20 March 2002
+  * Add --unpack option to warn when unpacking a non-sequence
+  * Add --unpacklen option to warn when unpacking sequence of wrong size
+  * Add --changetypes option to warn when setting a variable to different types
+  * Add --stringiter option to warn when iterating over a string
+  * Add --input option to warn when using input()
+  * Fix crash with checking properties or deriving from objects (2.2 only)
+  * Fix crash with nested scopes and lambdas
+  * Fix spurious warnings for constant conditionals when using ('%s' % value)
+  * Fix spurious warnings for unused identifiers caused by from XXX import *
+  * Add more information when module cannot be imported
+  * Fix spurious warnings for implicit returns when using while 1:
+  * Fix spurious warnings for implicit returns when using try/finally:
+  * Fix spurious warning with globals that start w/__
+  * Fix spurious warnings for modifying default arguments 
+        when calling {}.get(), {}.has_key(), [].index(), [].count(), etc.
+  * Fix spurious warnings in Python 1.5.2 when using from/import
+
+Version 0.8.9   - 02 February 2002
+  * Add -3/--properties warning when using properties with classic classes
+  * Add more warnings for statements with no effect
+  * Fix crash due to import module problems
+  * Fix crash with nested scopes
+  * Fix spurious warnings about module attributes and importing
+  * Fix spurious warnings in Python 2.2 when using builtin classes (eg, socket)
+  * Fix spurious warning for format string problem when using % at module scope
+  * Fix spurious warning for implicit returns when doing while 1:
+  * Fix spurious warning for inconsistent return types 
+        when objects are subclasses
+  * Don't warn about inconsistent return types from __getattr[ibute]__
+  * Always assume readline module is used if input/raw_input is used
+
+Version 0.8.8   - 13 January 2002
+  * Add -F/--config option to specify pycheckrc file to use
+        Always read $HOME/.pycheckrc, .pycheckrc, and -F options in that order
+  * Add -0/--abstract option to warn that subclass should override
+        a base class whose method(s) only raise exceptions
+  * Add -6/--exec option to warn when using the exec statement
+  * Add -7/--slots option to warn about __slots__ usage problems
+  * Add --emptyslots option to warn about empty __slots__
+  * Add check if __getattr[ibute]__ returns None, should raise an exception
+  * Allow pychecker to be imported (in your code do: import pychecker.check)
+  * Using vars() for format string argument works like locals()
+  * Make unusedNames a prefix, so emptyVal, unusedVal, etc are also ignored
+  * Fix -a/--initattr warning to actually warn when attributes 
+        are set outside of __init__(), but not in __init__()
+  * Fix case where an implicit return did not generate a warning
+  * Fix spurious warnings when using nested scopes, code should be checked now
+  * Fix spurious warnings for unreachable code (not enough to enable, yet)
+  * Fix spurious warnings for integer division from:  (x + 100.0) / 10
+  * Fix spurious warnings for implicit returns when raise in except: clause
+  * Fix various spurious warnings when using Python 2.2
+  * Fix spurious warning for overridden method mismatch when using exec
+  * Fix spurious warning when doing len(filter(lambda x: ..., ...))
+  * Fix spurious warnings from some from ... import ... and deriving classes
+
+Version 0.8.7   - 05 January 2002
+  * Add -2/--constcond option to warn if using a constant 
+        in a conditional statement (if '': ; while 'str': ; etc)
+  * Add -1/--constant1 option to warn when using if 1: or while 1: etc.
+  * Add -8/--unreachable option to warn about unreachable code
+  * Add -9/--members option to warn about unused data members
+  * Add -w/--shadow for local variable shadowing global variable
+  * Add warning statements with no effect (load var, but do nothing)
+  * Handle string multiplication (helps format strings)
+        code like this doesn't generate a warning now:  '%d ' * 3 % (1, 2, 3)
+  * Fix -C/--implicitreturns option so it works, turn it on by default
+  * Fix spurious warning when accessing 'static' class members that are methods
+        (e.g. class C(B): __super_init = B.__init__) (still a problem w/2.2)
+  * Fix some strange spurious warnings and exceptions
+  * Handle nested scopes better, includes fixing a crash and
+        eliminating some spurious warnings
+
+Version 0.8.6   - 16 November 2001
+  * Add -5/--maxrefs for maximum # of identifier references (Law of Demeter)
+  * Fix problem where user defined classes weren't checked for valid attributes
+  * Allow use of __pychecker__ in class scope
+  * Fix a lot of global function arg counts for Python 2.2
+        (many constructors can take no arguments now)
+  * Fix spurious warning (Function return types are inconsistent)
+        when multiple returns w/a constant & a local variable of same type
+  * Fix spurious warning for format strings when using a dict local variable
+  * Rename pychecker.sh script to pychecker on Unix
+
+Version 0.8.5   - 17 October 2001
+  * Add check for using builtin function/method const (None) return value
+        (e.g., not_a_new_list = [].sort())
+  * Add check for builtin object method calls for right # args
+        (e.g., [].count(), {}.keys(), file.seek(0))
+  * Add check for object method calls for right # args
+        (calling object when type is known, ie instatiated locally)
+  * Add check for modifying a parameter that has a default value
+        (e.g., def func(mutable = []): mutable.append(0))
+  * Add check for using future keywords (e.g., yield)
+  * Add check for using unary positive on variables (e.g., +x)
+  * Add check for recursive calls to __repr__ implementations (`self`)
+  * Add -X/--reimport option to turn off various module reimport warnings
+  * Add -V/--version option for printing PyChecker version
+  * Fix some spurious warnings for inconsistent return value types
+  * Fix spurious warning from calling functions like:  zip(*args)
+  * Fix -F/--rcfile option so it really works
+
+Version 0.8.4   - 24 September 2001
+  * Allow warning suppressions to be specified as regular expressions
+  * Add -z/--no-varargsused to ignore *args for functions w/variable args
+  * Add warning checks when deleting variables
+  * Add check for except Error1, Error2 : # should be except (Error1, Error2) :
+  * Fix spurious warning when using parameter as dict for format string
+  * Fix spurious warning when using lambda in __init__
+  * Add check that pychecker/checker.py is same version as other files
+  * Get setup.py to work on windows, etc. if don't have /tmp
+
+Version 0.8.3   - 12 August 2001
+  * Fix internal errors when doing % on non-strings and other format problems
+  * Fix spurious warning when using a constant {} with a format mapping
+
+Version 0.8.2   - 12 August 2001
+  * Check format strings even if using global & local constants
+  * Add check that [].append() only takes one argument
+  * Add check that # parameters are correct for builtin functions
+  * Add warnings for --, ++, ~~:
+        "Operator (%s) doesn't exist, statement has no effect"
+  * Add -Q/--quiet to be real quiet, only output warning msgs, nothing else
+  * Add -y/--classattr config option (warning was not configurable before)
+        (warn if class attribute doesn't exist)
+  * Add -x/--miximport config option (warning was not configurable before)
+        (warn if mixing: import/from ... import)
+  * Add -u/--callinit config option (warning was not configurable before)
+        (warn if Subclass.__init__() not called)
+  * Add constants together on stack when get + to avoid some spurious warnings
+  * Fix method and attribute checks for None and Ellipsis
+  * Fix spurious warnings when doing a local import and use module in lambda
+  * Fix spurious warnings when object attribute has same name as class
+  * Fix Object (x) has no attribute warnings for Python 2.2a1 built-in types
+  * Change default behaviour to not warn about missing doc strings
+
+Version 0.8.1   - 9 August 2001
+  * Fix internal error when referencing a list constant:  [1,2,3][1]
+  * Fix internal error for Python 1.5 not catching unicode syntax error
+  * Fix deprecation warning for Python 2.2a1 with xrange
+  * Fix spurious warning (No module attribute) when doing import x.y as y
+  * Fix spurious warning (Base __init__() not called) when using *args or **kw
+  * Fix 'No module attribute' warning when doing:  import foo.bar as bar
+  * Spell overridden write
+
+Version 0.8     - 6 August 2001
+  * Add check for accessing list as list[1,2], should be slice 1:2
+  * Add -J/maxargs to warn when using too many arguments
+  * Add -K/maxlocals to warn when using too many local variables
+  * Add -D/intdivide to warn when using integer division
+  * Add -O/objattrs to warn when using object.attribute that doesn't exist
+  * Add -M/reimportself to warn when a module imports itself
+  * Add -E/unusednames to provide a list of unused names to ignore
+        (default is: [ '_', 'empty', 'unused' ])
+  * Major refactoring of warn.py -> utils, msgs, Warning, CodeChecks
+  * Fix spurious warnings for No class attribute for dynamic classes
+  * Fix spurious warnings when using objects from blacklisted modules
+        (Instantiating object with arguments, but no constructor, etc)
+  * Fix spurious warnings when using lambdas
+  * Fix spurious warning (No global Y) when using: from X import Y
+        (problem in python 1.5/1.6 only)
+
+Version 0.7.5   - 22 July 2001
+  * Suppress warnings on a per module/function/class/method basis
+        with new suppressions = {} in .pycheckrc
+  * Suppress warnings by setting __pychecker__ in source code
+  * Change long argument behaviour --arg sets arg to true,
+        --no-arg sets arg to false (also works for warning suppression)
+  * Add -U/--reuseattr check if function/class/method names are reused
+  * Add -T/--argsused check for unused method/function arguments
+  * Add -G/--selfused ignore if self is unused in a method 
+    (requires --argsused)
+  * Add -q/--stdlib to disable warnings from the standard library
+  * Add -o/--override warning when a method has different signature 
+        than one being overridden in a base class
+  * Add -F/--rcfile to generate a .pycheckrc file
+  * Fix checking files in standard library before local file
+  * Fix spurious warning when using from X import Y and imports in methods
+        (Module (m) re-imported)
+  * Fix spurious warning when doing:  from X import Y, Z
+  * Fix spurious warning when deriving from Exception() and
+        instantiating object with multiple arguments
+  * Fix method argument checks when calling base class methods
+  * Fix error msg to base constructors (msg count was wrong)
+  * Fix access to builtin module attributes (e.g., sys.exc_value)
+        generating 'No attribute warnings'
+  * Fix tests (forgot to add : after line number in expected results)
+
+Version 0.7     - 16 July 2001
+  * Improve import warning messages, add from checks
+  * checker.py -h prints defaults after processing .pycheckrc file
+  * Add config option -k/--pkgimport to disable unused imports from __init__.py
+  * Add warning for variable used before being set
+  * Improve format string checks/warnings
+  * Check arguments to constructors
+  * Check that self is first arg to base constructor
+  * Add -e/--errors option to only warn about likely errors
+  * Make 'self' configurable as the first argument to methods
+  * Add check that there is a c'tor when instantiating an object and 
+        passing arguments
+  * Add config option (-N/--initreturn) to turn off warnings 
+        when returning None from __init__()
+  * Fix internal error with python 2.1 which defines a new op: LOAD_DEREF
+  * Check in lambda functions for module/variable use
+  * Fix inability to evaluate { 1: 'a' } inline,
+        led to incorrect __init__() not called warnings
+  * Fix exception when class overrides __special__() methods & raise exception
+  * Fix check in format strings when using '%*g %*.*g', etc
+  * Add check for static class attributes
+  * Fix checking of module attributes
+  * Fix wrong filename in 'Base class (xxx) __init__() not called'
+        when doing a from X import *
+  * Fix 'No attribute found' for very dynamic classes
+        (may also work for classes that use __getattr__)
+
+Version 0.6.1   - 27 June 2001
+  * Fix bug which caused an exception from some import code
+  * Fix bug in determining if there is an implicit return
+
+Version 0.6     - 25 June 2001
+  * Check format strings: "%s %s %s" % (v1, v2, v3, v4) for arg counts
+  * Warn when format strings do: '%(var) %(var2)'
+  * Fix Local variable (xxx) not used, when have:  "%(xxx)s" % locals()
+  * Warn when local variable (xxx) doesn't exist and have: "%(xxx)s" % locals()
+  * Install script in /usr/local/bin to invoke PyChecker
+  * Don't produce unused global warnings when using a module in parameters
+  * Don't produce unused global warnings when using a module in class variables
+  * Add check when using method as an attribute (if self.method and x == y:)
+  * Add check for right # of args to object construction
+  * Add check for right # of args to function calls in other modules
+  * Check for returning a value from __init__
+  * Fix using from XX import YY ; from XX import ZZ causing re-import warning
+  * Fix UNABLE TO IMPORT errors for files that don't end with a newline
+  * Support for checking consistent return values -- not complete 
+        produces too many false positives
+
+Version 0.5     - 29 May 2001
+  * Catch internal errors "gracefully" and turn into a warning
+  * Add checking of most module scoped code
+  * Add pychecker subdir to imports to prevent filename conflicts
+  * Don't produce unused local variable warning if variable name == '_'
+  * Add -g/--allglobals option to report all global warnings, not just first
+  * Add -V/--varlist option to selectively ignore variable not used warnings
+  * Add test script and expected results
+  * Print all instructions when using debug (-d/--debug)
+  * Overhaul internal stack handling so we can look for more problems
+  * Fix glob'ing problems (all args after glob were ignored)
+  * Fix spurious Base class __init__ not called
+  * Fix exception on code like:  ['xxx'].index('xxx')
+  * Fix exception on code like:  func(kw=(a < b))
+  * Fix line numbers for import statements
+
+Version 0.4     - 23 April 2001
+  * Add .pycheckrc file processing to specify options (like on command line)
+  * Add new warning if module.Attribute doesn't exist
+  * Add new warning:  Module (%s) re-imported locally
+  * Add glob'ing support for windows
+  * Handle apply(BaseClass.__init__(self, args))
+  * Fix command line handling so you can pass module, package, or filename
+  * Fix **kwArgs warning if named parameter is not first
+  * Don't exit from checker when import checker from interpreter
+
+Version 0.3     - 17 April 2001
+  * Fix some checker crashes (oops)
+  * Add warnings for code complexity (lines/branches/returns per function)
+  * Add more configuration options
+  * Don't produce spurious warning for:  x(y, { 'a': 'b' })
+  * Fix warnings that indicate they are from a base class file,
+    rather than real file
+  * Fix warnings for **kwArgs not allowed, but using named args
+  * Add configuration option for warning when using attribute as a function
+        (off by default, old behaviour was on)
+
+Version 0.2.5   - 12 April 2001
+  * Add back support for Python 1.5.2 (again)
+        (I sure like 2.0 more with the [ for ] and string methods.)
+  * Add new warning for unused local variables
+  * Add command line switches
+
+Version 0.2     - 10 April 2001
+  * Move tests into a sub-directory so import test doesn't import
+    pychecker/test
+  * Add more test files
+  * Add '.' to the python path so it doesn't need to be done in env't
+  * Print a warning at the end for each file that couldn't be import'ed
+  * Improve stack handling to improve error handling
+  * Try to get base class __init__ checking to work for both:
+        import X.Y
+        from X import Y
+
+Version 0.1.1   - 8 April 2001
+  * Add support for Python 1.5.2
+
+Version 0.1     - 7 April 2001
+  * Initial release
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/README
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/README b/tools/bin/pythonSrc/pychecker-0.8.18/README
new file mode 100644
index 0000000..2ce647d
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/README
@@ -0,0 +1,152 @@
+
+PyChecker is a tool for finding bugs in python source code.
+It finds problems that are typically caught by a compiler for less
+dynamic languages, like C and C++.  It is similar to lint.
+Because of the dynamic nature of python, some warnings
+may be incorrect; however, spurious warnings should be fairly infrequent.
+
+PyChecker works in a combination of ways.  First, it imports each
+module.  If there is an import error, the module cannot be processed.
+The import provides some basic information about the module.  The code
+for each function, class, and method is checked for possible problems.
+
+Types of problems that can be found include:
+
+  * No global found (e.g., using a module without importing it)
+  * Passing the wrong number of parameters to functions/methods/constructors
+  * Passing the wrong number of parameters to builtin functions & methods
+  * Using format strings that don't match arguments
+  * Using class methods and attributes that don't exist
+  * Changing signature when overriding a method
+  * Redefining a function/class/method in the same scope
+  * Using a variable before setting it
+  * self not the first parameter to a method
+  * Unused globals and locals (module or variable)
+  * Unused function/method arguments (can ignore self)
+  * No doc strings in modules, classes, functions, and methods
+
+Using PyChecker
+---------------
+To use PyChecker, pass the python source files you want to check
+on the command line:
+
+	pychecker file1.py file2.py ...
+
+Note:  On Windows, use pychecker.bat.  You may also need to add
+python/scripts to your PATH.
+
+pychecker and pychecker.bat will only exist if pychecker has been
+installed.  To install, do:  python setup.py install
+
+Note:  If you haven't installed pychecker, it can be run by doing:
+python pychecker/checker.py
+
+An alternate way to use PyChecker is to import it in your code.
+See 'Importing PyChecker' below for more details.
+
+If there are import dependencies in your source files, you should
+import those files first on the command line in order to get as many
+files checked as possible.
+
+PyChecker works with Python 2.0 through 2.3.
+Some features don't work on earlier versions of Python.
+I only regularly test with versions 2.2 and 2.3.
+
+You can use the test files as examples:
+
+	pychecker [options] test_input/*.py
+
+If you want to change the default behaviour, you can pass command line options
+or define a .pycheckrc file.  For an example, look at pycheckrc.
+
+To show the available options, do:
+
+	pychecker -h
+
+Some of the most common options are:
+
+      --only         only warn about files passed on the command line [off]
+  -#, --limit        the maximum number of warnings to be displayed [10]
+  -s, --shadowbuiltin check if a variable shadows a builtin [on]
+  -q, --stdlib       ignore warnings from files under standard library [off]
+  -T, --argsused     unused method/function arguments [on]
+
+There is a simple GUI which is not maintained much.  It is good
+for showing all the options and also allows you to run pychecker.
+To run options, you will need to start it manually:
+
+	python pychecker/options.py
+
+If you want to suppress warnings on a module/function/class/method,
+you can define a suppressions dictionary in .pycheckrc.
+Examples of keys are:  'module', 'module.function',
+		       'module.class', 'module.class.method', etc.
+
+You can also define suppressions in your code by doing:
+
+	__pychecker__ = 'no-namedargs maxreturns=0 unusednames=foo,bar'
+
+The format for __pychecker__ values and values in the suppressions dictionary
+are the same.  Dashes (--) are optional when preceding long option names.
+
+Importing PyChecker
+-------------------
+You can import PyChecker in your code's main module, by doing:
+
+        import pychecker.checker
+
+This will allow each module imported after PyChecker to be checked 
+(other than the main module).  NOTE:  Modules imported before PyChecker
+will not be checked.  Warnings will be displayed on stdout 
+(ie, PyChecker uses print).
+
+Since you can't pass command line parameters, you can do:
+
+        os.environ['PYCHECKER'] = 'command line options here'
+
+This is equivalent of setting PYCHECKER in the shell environment:
+
+        PYCHECKER='no-namedargs maxreturns=0' /path/to/your/program
+
+If you want to disable the warnings (and processing done by PyChecker), 
+prior to importing PyChecker, do:
+
+        os.environ['PYCHECKER_DISABLED'] = 1
+
+This is equivalent of setting PYCHECKER_DISABLED in the shell environment:
+
+        PYCHECKER_DISABLED=1 /path/to/your/program
+
+Internal Errors
+---------------
+If you find a bug in PyChecker, meaning you see something like:
+
+	pychecker myfile.py
+
+	myfile.py:13 INTERNAL ERROR -- STOPPED PROCESSING FUNCTION --
+        Traceback (most recent call last):
+          File "./pychecker/warn.py", line 364, in _checkFunction
+            stack, oparg, lastLineNum)
+          File "./pychecker/warn.py", line 195, in _handleFunctionCall
+            kwArgs.append(stack[i].data)
+        IndexError: list index out of range
+
+Please post a bug in the SourceForge Tracker
+(https://sourceforge.net/tracker/?atid=382217&group_id=24686&func=browse)
+or send mail indicating the version of PyChecker, *your source file*
+which broke PyChecker (myfile.py in the example above), and the traceback.
+It is very helpful to provide a simple test case to demonstrate the problem.
+It helps to have the entire file and all the dependencies if you cannot
+produce a simple test case.  But if you can't provide a test case nor
+the file(s), I may be able to figure out the problem with just the line
+which broke PyChecker (myfile.py:13 in the example above).
+
+Good Luck!  As always, feedback is greatly appreciated.
+
+Neal
+pychecker-list@lists.sourceforge.net
+
+PyChecker can be found on SourceForge at:
+	http://pychecker.sourceforge.net/
+	http://sourceforge.net/projects/pychecker
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/TODO
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/TODO b/tools/bin/pythonSrc/pychecker-0.8.18/TODO
new file mode 100644
index 0000000..e3ebc22
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/TODO
@@ -0,0 +1,101 @@
+Goals for next minor release:
+-----------------------------
+* Add warning for duplicated elif conditions
+* Check for "if s.find(str):" s/b "if s.find(str) >= 0:" where s is a string
+* Add warning for: x % x is always 0
+* Add warning when using listcomp variable (x) outside of [... for x in ...]
+* Add warning for import overriding builtin (from os import *)
+* Add warning if defining a module name that's also in the stdlib
+* Add decorator so you can do:
+
+   @pychecker(maxlocals=42)
+   def myfunc():
+
+* Support function attributes in addition to __pychecker__
+* Add warning when iterating over a dict (keys, values, items) and mutating it
+* Add warning for __special_ or __special or _special__ etc.
+* Add warning about redefining a function/method with different signatures
+* Add warning when base class has similar name and same signature:
+
+  class Base:
+    def foobar():
+  class Sub(Base):
+    def foobaz(): # damn, I wanted to override foobar
+
+* If unknown name, suggest similar names
+
+* Check for return from finally (disables exception, default off?)
+* Add another boolean warning for:    if bool(xxx):
+* Need way to configure broken (and non-broken) versions of evil C extensions
+* Add estimated difficulty to research/fix error
+* Shouldn't warn about using return value for generators
+* Suppress argument (self) name warnings if func has no impl?
+* Add warning for a variable that is constant 
+    ie, initialized and used, but never changed
+
+* Add warning for catching AttributeError when there is no attr access
+	ZeroDivisionError w/no division?
+	KeyError UnboundLocalError IndexError IndentationError ImportError
+* Add warning for a import b & b import a (import loops)
+* Check that classes with __slots__ don't get/set any other attributes
+* Expectations of __methods__, constness (don't modify in __nonzero__)
+* Add warning if dict has duplicate keys when creating from literals
+* __new__ should use cls, not self???
+
+* If arg has default value of None, check that arg is assigned some value
+
+* check if returning self from __str__()
+* check for str1 in str2 == otherValue
+* Fix dependancy problem w/checkReturnValues & checkImplicitReturns
+* check for use of self.attr before setting self.attr in __init__ method
+* Handle sys.exit() as non-returnable condition
+* Warn about non-escaping backslashes???
+* vars() should use locals, like locals(), hmmm, it should already ...
+
+Goals for next major release (0.9):
+-----------------------------------
+* Improve handling when importing packages (ie, don't import modules)
+  - Make a base class to handle stack operations
+  - Override base class with classes to handle module scope, functions, etc.
+  - Process module and create Module/Class/Function objects w/o dir(), etc.
+  - Finish tests: 44
+* Add a config option to ignore certain cantankerous modules
+
+* Add warning for global statement inside a conditional
+* Fix spurious warnings for unreachable code checks
+* Fix most of the FIXMEs
+* Add check for import module (from within package p-should be import p.module)
+  - don't use relative imports, should always use absolute paths
+
+Longer Term goals:
+------------------
+* Add check for magic #s/consts
+	(need dict of consts, count, max count, consts to ignore)
+* Add check for unsupported operand type(s) for * + / etc
+* Store types of globals, class attributes, function & method return values
+* Output stats about pychecker's job, good, bad, otherwise...
+	annotate code for problem areas, well checked areas, etc.
+* Add original line warnings for those that refer to another place
+	(e.g., overridden method doesn't match signature)
+* Add capability to check features from a specified version of python
+	which is different from runtime interpreter
+* Security checks for known issues.  Adrian Likins @redhat recommends 
+  looking at http://www.securesw.com/rats/
+* Make check for 'self' a list instead of a string
+* Check function return values - partially complete
+* Add check that private functions are used in module/class
+* Add check for using object members outside of class
+* Add portability checks for win32/unix
+* Add check for except: pass
+* Spell check doc strings
+
+# need to read source code for these:
+* Add warning for unnecessary global stmts
+* Add check for implicit string concatentation
+* Add check for creating tuple when don't want a tuple, like: 1,
+            or not creating tuple when want one, like: (1)
+* Warn when using () with statements (assert, print, del, if, while)
+* Add check for <>, should use !=
+* Find lines that end w/semi-colons (;)
+* inconsistent camel-case
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/VERSION
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/VERSION b/tools/bin/pythonSrc/pychecker-0.8.18/VERSION
new file mode 100644
index 0000000..492fd93
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/VERSION
@@ -0,0 +1 @@
+0.8.18


[28/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code

Posted by rl...@apache.org.
HAWQ-837. Add python modules into HAWQ code

Added figleaf, pg8000, simplejson, pyyaml, lockfile, psi, pychecker, unittest2
Paramiko is not included because of License concern.
Pycrypto is not included because not in use anymore.


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/80e25b46
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/80e25b46
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/80e25b46

Branch: refs/heads/master
Commit: 80e25b468cecb12fd58d28b5c08494ead7dbba81
Parents: 84dd4d4
Author: rlei <rl...@pivotal.io>
Authored: Mon Jun 20 16:49:13 2016 +0800
Committer: rlei <rl...@pivotal.io>
Committed: Tue Jun 21 10:15:46 2016 +0800

----------------------------------------------------------------------
 tools/bin/Makefile                              |   72 +-
 tools/bin/ext/__init__.py                       |  306 +++
 tools/bin/ext/figleaf/__init__.py               |  325 +++
 tools/bin/ext/figleaf/_lib.py                   |   22 +
 tools/bin/ext/figleaf/annotate.py               |  241 +++
 tools/bin/ext/figleaf/annotate_cover.py         |  159 ++
 tools/bin/ext/figleaf/annotate_html.py          |  292 +++
 tools/bin/ext/figleaf/annotate_sections.py      |   95 +
 tools/bin/ext/figleaf/figleaf2html              |    7 +
 tools/bin/ext/figleaf/internals.py              |  257 +++
 tools/bin/ext/figleaf/nose_sections.py          |  133 ++
 tools/bin/ext/pg8000/__init__.py                |   37 +
 tools/bin/ext/pg8000/dbapi.py                   |  621 ++++++
 tools/bin/ext/pg8000/errors.py                  |  115 +
 tools/bin/ext/pg8000/interface.py               |  542 +++++
 tools/bin/ext/pg8000/protocol.py                | 1340 ++++++++++++
 tools/bin/ext/pg8000/types.py                   |  687 ++++++
 tools/bin/ext/pg8000/util.py                    |   20 +
 tools/bin/ext/simplejson/__init__.py            |  303 +++
 tools/bin/ext/simplejson/_speedups.c            |  234 +++
 tools/bin/ext/simplejson/decoder.py             |  289 +++
 tools/bin/ext/simplejson/encoder.py             |  387 ++++
 tools/bin/ext/simplejson/jsonfilter.py          |   56 +
 tools/bin/ext/simplejson/scanner.py             |   79 +
 tools/bin/ext/simplejson/tests/__init__.py      |    0
 tools/bin/ext/simplejson/tests/test_attacks.py  |   22 +
 tools/bin/ext/simplejson/tests/test_dump.py     |   26 +
 tools/bin/ext/simplejson/tests/test_fail.py     |   86 +
 tools/bin/ext/simplejson/tests/test_float.py    |   20 +
 tools/bin/ext/simplejson/tests/test_indent.py   |   57 +
 tools/bin/ext/simplejson/tests/test_pass1.py    |   88 +
 tools/bin/ext/simplejson/tests/test_pass2.py    |   27 +
 tools/bin/ext/simplejson/tests/test_pass3.py    |   32 +
 .../bin/ext/simplejson/tests/test_recursion.py  |   78 +
 .../bin/ext/simplejson/tests/test_separators.py |   57 +
 tools/bin/ext/simplejson/tests/test_unicode.py  |   32 +
 tools/bin/ext/yaml/__init__.py                  |  306 +++
 tools/bin/ext/yaml/composer.py                  |  134 ++
 tools/bin/ext/yaml/constructor.py               |  691 ++++++
 tools/bin/ext/yaml/cyaml.py                     |  101 +
 tools/bin/ext/yaml/dumper.py                    |   78 +
 tools/bin/ext/yaml/emitter.py                   | 1179 +++++++++++
 tools/bin/ext/yaml/error.py                     |   91 +
 tools/bin/ext/yaml/events.py                    |  102 +
 tools/bin/ext/yaml/loader.py                    |   56 +
 tools/bin/ext/yaml/nodes.py                     |   65 +
 tools/bin/ext/yaml/parser.py                    |  602 ++++++
 tools/bin/ext/yaml/reader.py                    |  241 +++
 tools/bin/ext/yaml/representer.py               |  504 +++++
 tools/bin/ext/yaml/resolver.py                  |  239 +++
 tools/bin/ext/yaml/scanner.py                   | 1472 +++++++++++++
 tools/bin/ext/yaml/serializer.py                |  127 ++
 tools/bin/ext/yaml/tokens.py                    |  120 ++
 tools/bin/pythonSrc/PSI-0.3b2_gp/DESIGN         |   95 +
 .../bin/pythonSrc/PSI-0.3b2_gp/GREENPLUM_README |    1 +
 tools/bin/pythonSrc/PSI-0.3b2_gp/LICENSE        |   26 +
 tools/bin/pythonSrc/PSI-0.3b2_gp/MANIFEST       |   61 +
 tools/bin/pythonSrc/PSI-0.3b2_gp/PKG-INFO       |  129 ++
 tools/bin/pythonSrc/PSI-0.3b2_gp/README         |  281 +++
 tools/bin/pythonSrc/PSI-0.3b2_gp/TODO           |   72 +
 .../PSI-0.3b2_gp/examples/process_details.py    |  165 ++
 tools/bin/pythonSrc/PSI-0.3b2_gp/include/arch.h |   89 +
 .../PSI-0.3b2_gp/include/linux_utils.h          |   46 +
 .../bin/pythonSrc/PSI-0.3b2_gp/include/mount.h  |  126 ++
 .../PSI-0.3b2_gp/include/posix_mount.h          |   42 +
 .../PSI-0.3b2_gp/include/posix_utils.h          |   63 +
 .../pythonSrc/PSI-0.3b2_gp/include/process.h    |  217 ++
 .../PSI-0.3b2_gp/include/procfs_utils.h         |   91 +
 tools/bin/pythonSrc/PSI-0.3b2_gp/include/psi.h  |  284 +++
 .../pythonSrc/PSI-0.3b2_gp/include/psifuncs.h   |   85 +
 .../bin/pythonSrc/PSI-0.3b2_gp/misc/mem_test.py |   72 +
 .../bin/pythonSrc/PSI-0.3b2_gp/misc/mktests.sh  |   38 +
 .../PSI-0.3b2_gp/misc/valgrind-python.supp      |  391 ++++
 .../bin/pythonSrc/PSI-0.3b2_gp/psi/__init__.py  |   55 +
 .../bin/pythonSrc/PSI-0.3b2_gp/psi/_version.py  |   44 +
 tools/bin/pythonSrc/PSI-0.3b2_gp/setup.py       |  570 +++++
 .../bin/pythonSrc/PSI-0.3b2_gp/src/_psimodule.c |  389 ++++
 tools/bin/pythonSrc/PSI-0.3b2_gp/src/arch.c     |  561 +++++
 .../pythonSrc/PSI-0.3b2_gp/src/arch/aix_mount.c |  189 ++
 .../PSI-0.3b2_gp/src/arch/aix_process.c         |  597 ++++++
 .../pythonSrc/PSI-0.3b2_gp/src/arch/aix_psi.c   |   89 +
 .../PSI-0.3b2_gp/src/arch/darwin_mount.c        |  170 ++
 .../PSI-0.3b2_gp/src/arch/darwin_process.c      |  562 +++++
 .../PSI-0.3b2_gp/src/arch/darwin_processtable.c |  131 ++
 .../PSI-0.3b2_gp/src/arch/darwin_psi.c          |   93 +
 .../PSI-0.3b2_gp/src/arch/getloadavg.c          |   67 +
 .../PSI-0.3b2_gp/src/arch/linux_mount.c         |  156 ++
 .../PSI-0.3b2_gp/src/arch/linux_process.c       |  771 +++++++
 .../pythonSrc/PSI-0.3b2_gp/src/arch/linux_psi.c |   77 +
 .../PSI-0.3b2_gp/src/arch/linux_utils.c         |   83 +
 .../PSI-0.3b2_gp/src/arch/posix_arch.c          |   75 +
 .../PSI-0.3b2_gp/src/arch/posix_mount.c         |   67 +
 .../PSI-0.3b2_gp/src/arch/posix_utils.c         |  167 ++
 .../PSI-0.3b2_gp/src/arch/procfs_processtable.c |  158 ++
 .../PSI-0.3b2_gp/src/arch/procfs_utils.c        |  131 ++
 .../pythonSrc/PSI-0.3b2_gp/src/arch/sargs64.c   |  202 ++
 .../PSI-0.3b2_gp/src/arch/sunos_mount.c         |  171 ++
 .../PSI-0.3b2_gp/src/arch/sunos_process.c       | 1021 +++++++++
 .../pythonSrc/PSI-0.3b2_gp/src/arch/sunos_psi.c |   66 +
 .../bin/pythonSrc/PSI-0.3b2_gp/src/archmodule.c |  210 ++
 tools/bin/pythonSrc/PSI-0.3b2_gp/src/mount.c    |  502 +++++
 .../pythonSrc/PSI-0.3b2_gp/src/mountmodule.c    |  229 ++
 tools/bin/pythonSrc/PSI-0.3b2_gp/src/process.c  |  981 +++++++++
 .../pythonSrc/PSI-0.3b2_gp/src/processmodule.c  |  208 ++
 .../pythonSrc/PSI-0.3b2_gp/src/processtable.c   |  240 +++
 tools/bin/pythonSrc/PSI-0.3b2_gp/src/timespec.c |  852 ++++++++
 tools/bin/pythonSrc/PSI-0.3b2_gp/src/util.c     |  604 ++++++
 .../pythonSrc/PSI-0.3b2_gp/tests/_psi_test.py   |  145 ++
 tools/bin/pythonSrc/PSI-0.3b2_gp/tests/aixapp.c |   34 +
 tools/bin/pythonSrc/PSI-0.3b2_gp/tests/app.c    |   19 +
 .../pythonSrc/PSI-0.3b2_gp/tests/apphelper.py   |  225 ++
 .../pythonSrc/PSI-0.3b2_gp/tests/arch_test.py   |   68 +
 .../pythonSrc/PSI-0.3b2_gp/tests/mount_test.py  |  169 ++
 .../PSI-0.3b2_gp/tests/process_test.py          |  673 ++++++
 .../PSI-0.3b2_gp/tests/processtable_test.py     |   90 +
 .../PSI-0.3b2_gp/tests/timespec_test.py         |  233 +++
 tools/bin/pythonSrc/lockfile-0.9.1/2.4.diff     |   99 +
 tools/bin/pythonSrc/lockfile-0.9.1/ACKS         |    6 +
 tools/bin/pythonSrc/lockfile-0.9.1/LICENSE      |   21 +
 tools/bin/pythonSrc/lockfile-0.9.1/MANIFEST     |   19 +
 tools/bin/pythonSrc/lockfile-0.9.1/PKG-INFO     |   51 +
 tools/bin/pythonSrc/lockfile-0.9.1/README       |   27 +
 .../bin/pythonSrc/lockfile-0.9.1/RELEASE-NOTES  |   50 +
 tools/bin/pythonSrc/lockfile-0.9.1/doc/Makefile |   73 +
 tools/bin/pythonSrc/lockfile-0.9.1/doc/conf.py  |  179 ++
 .../pythonSrc/lockfile-0.9.1/doc/glossary.rst   |   15 +
 .../bin/pythonSrc/lockfile-0.9.1/doc/index.rst  |   22 +
 .../pythonSrc/lockfile-0.9.1/doc/lockfile.rst   |  257 +++
 .../lockfile-0.9.1/lockfile/__init__.py         |  286 +++
 .../lockfile-0.9.1/lockfile/linklockfile.py     |   69 +
 .../lockfile-0.9.1/lockfile/mkdirlockfile.py    |   79 +
 .../lockfile-0.9.1/lockfile/pidlockfile.py      |  189 ++
 .../lockfile-0.9.1/lockfile/sqlitelockfile.py   |  146 ++
 tools/bin/pythonSrc/lockfile-0.9.1/setup.py     |   32 +
 .../lockfile-0.9.1/test/compliancetest.py       |  222 ++
 .../lockfile-0.9.1/test/test_lockfile.py        |   30 +
 tools/bin/pythonSrc/pychecker-0.8.18/COPYRIGHT  |   31 +
 tools/bin/pythonSrc/pychecker-0.8.18/ChangeLog  |  349 ++++
 tools/bin/pythonSrc/pychecker-0.8.18/KNOWN_BUGS |  100 +
 .../bin/pythonSrc/pychecker-0.8.18/MAINTAINERS  |   81 +
 .../bin/pythonSrc/pychecker-0.8.18/MANIFEST.in  |    2 +
 tools/bin/pythonSrc/pychecker-0.8.18/NEWS       |  406 ++++
 tools/bin/pythonSrc/pychecker-0.8.18/README     |  152 ++
 tools/bin/pythonSrc/pychecker-0.8.18/TODO       |  101 +
 tools/bin/pythonSrc/pychecker-0.8.18/VERSION    |    1 +
 .../pychecker-0.8.18/pychecker/CodeChecks.py    | 1969 ++++++++++++++++++
 .../pychecker-0.8.18/pychecker/Config.py        |  475 +++++
 .../pythonSrc/pychecker-0.8.18/pychecker/OP.py  |  131 ++
 .../pychecker-0.8.18/pychecker/OptionTypes.py   |  117 ++
 .../pychecker-0.8.18/pychecker/Options.ad       |    9 +
 .../pychecker-0.8.18/pychecker/Stack.py         |  115 +
 .../pychecker-0.8.18/pychecker/Warning.py       |   50 +
 .../pychecker-0.8.18/pychecker/__init__.py      |   17 +
 .../pychecker-0.8.18/pychecker/checker.py       |  961 +++++++++
 .../pychecker-0.8.18/pychecker/function.py      |  159 ++
 .../pychecker-0.8.18/pychecker/msgs.py          |  175 ++
 .../pychecker-0.8.18/pychecker/options.py       |  275 +++
 .../pychecker-0.8.18/pychecker/pcmodules.py     |   19 +
 .../pychecker-0.8.18/pychecker/printer.py       |   47 +
 .../pychecker-0.8.18/pychecker/python.py        |  427 ++++
 .../pychecker-0.8.18/pychecker/utils.py         |  102 +
 .../pychecker-0.8.18/pychecker/warn.py          |  778 +++++++
 .../pychecker-0.8.18/pychecker2/Check.py        |   96 +
 .../pychecker-0.8.18/pychecker2/ClassChecks.py  |  364 ++++
 .../pychecker2/ConditionalChecks.py             |   44 +
 .../pychecker-0.8.18/pychecker2/File.py         |   39 +
 .../pychecker2/FormatStringChecks.py            |  183 ++
 .../pychecker-0.8.18/pychecker2/ImportChecks.py |   93 +
 .../pychecker-0.8.18/pychecker2/NOTES.txt       |  131 ++
 .../pychecker-0.8.18/pychecker2/OpChecks.py     |   68 +
 .../pychecker-0.8.18/pychecker2/Options.py      |  106 +
 .../pychecker-0.8.18/pychecker2/ParseChecks.py  |   84 +
 .../pychecker2/ReachableChecks.py               |   91 +
 .../pychecker-0.8.18/pychecker2/ReturnChecks.py |   43 +
 .../pychecker-0.8.18/pychecker2/ScopeChecks.py  |   28 +
 .../pychecker-0.8.18/pychecker2/TestSupport.py  |   57 +
 .../pychecker2/VariableChecks.py                |  354 ++++
 .../pychecker-0.8.18/pychecker2/Warning.py      |   13 +
 .../pychecker-0.8.18/pychecker2/__init__.py     |    1 +
 .../pychecker-0.8.18/pychecker2/main.py         |  115 +
 .../pychecker2/scripts/check.sh                 |    4 +
 .../pychecker2/scripts/clean.sh                 |    5 +
 .../pychecker-0.8.18/pychecker2/scripts/lib.sh  |    2 +
 .../pychecker2/scripts/pychecker2.sh            |    6 +
 .../pychecker-0.8.18/pychecker2/symbols.py      |  372 ++++
 .../pychecker-0.8.18/pychecker2/test.py         |   55 +
 .../pychecker2/tests/__init__.py                |    0
 .../pychecker2/tests/badparse.py                |    1 +
 .../pychecker-0.8.18/pychecker2/tests/class.py  |  152 ++
 .../pychecker-0.8.18/pychecker2/tests/except.py |   11 +
 .../pychecker2/tests/expected/incremental       |   49 +
 .../pychecker2/tests/expected/no-importError    |   48 +
 .../pychecker2/tests/expected/no-operator       |   47 +
 .../pychecker2/tests/expected/no-operatorPlus   |   48 +
 .../pychecker2/tests/expected/no-redefinedScope |   47 +
 .../pychecker2/tests/expected/no-selfName       |   48 +
 .../tests/expected/no-shadowIdentifier          |   42 +
 .../pychecker2/tests/expected/no-syntaxErrors   |   45 +
 .../pychecker2/tests/expected/no-unknown        |   43 +
 .../pychecker2/tests/expected/no-unpackedUsed   |   52 +
 .../pychecker2/tests/expected/no-unused         |   36 +
 .../pychecker2/tests/expected/normal            |   47 +
 .../pychecker2/tests/expected/options           |   33 +
 .../pychecker2/tests/expected/reportUnusedSelf  |   55 +
 .../pychecker2/tests/expected/shadowBuiltins    |   50 +
 .../pychecker2/tests/expected/verbose           |   69 +
 .../pychecker-0.8.18/pychecker2/tests/format.py |   48 +
 .../pychecker-0.8.18/pychecker2/tests/global.py |   14 +
 .../pychecker-0.8.18/pychecker2/tests/import.py |   19 +
 .../pychecker-0.8.18/pychecker2/tests/nested.py |    8 +
 .../pychecker-0.8.18/pychecker2/tests/op.py     |   24 +
 .../pychecker-0.8.18/pychecker2/tests/self.py   |   31 +
 .../pychecker-0.8.18/pychecker2/tests/shadow.py |   59 +
 .../pychecker2/tests/unreachable.py             |   58 +
 .../pychecker-0.8.18/pychecker2/tests/unused.py |   31 +
 .../pychecker2/tests/unusedImport.py            |    4 +
 .../pychecker2/utest/__init__.py                |    1 +
 .../pychecker-0.8.18/pychecker2/utest/class.py  |  232 +++
 .../pychecker2/utest/conditional.py             |   27 +
 .../pychecker-0.8.18/pychecker2/utest/data.py   |    8 +
 .../pychecker-0.8.18/pychecker2/utest/format.py |   78 +
 .../pychecker-0.8.18/pychecker2/utest/import.py |   33 +
 .../pychecker-0.8.18/pychecker2/utest/ops.py    |   43 +
 .../pychecker2/utest/parseerror.py              |   24 +
 .../pychecker2/utest/reachable.py               |   73 +
 .../pychecker2/utest/returns.py                 |   21 +
 .../pychecker-0.8.18/pychecker2/utest/scopes.py |   47 +
 .../pychecker-0.8.18/pychecker2/utest/self.py   |   45 +
 .../pychecker-0.8.18/pychecker2/utest/shadow.py |   21 +
 .../pychecker2/utest/unknown.py                 |   27 +
 .../pychecker-0.8.18/pychecker2/utest/unused.py |   96 +
 .../pychecker-0.8.18/pychecker2/utest/usage.py  |    7 +
 .../pychecker2/utest/warnings.py                |   23 +
 .../pychecker-0.8.18/pychecker2/util.py         |   73 +
 tools/bin/pythonSrc/pychecker-0.8.18/pycheckrc  |  225 ++
 tools/bin/pythonSrc/pychecker-0.8.18/setup.cfg  |    8 +
 tools/bin/pythonSrc/pychecker-0.8.18/setup.py   |  281 +++
 .../pythonSrc/pychecker-0.8.18/test/common.py   |   88 +
 .../test/expected/test_getmodule                |    8 +
 .../test/expected/test_zope_interface           |    5 +
 .../test/input/getmodule/A/C.py                 |    4 +
 .../test/input/getmodule/A/__init__.py          |    0
 .../test/input/getmodule/B/C.py                 |    4 +
 .../test/input/getmodule/B/__init__.py          |    0
 .../test/input/getmodule/__init__.py            |    1 +
 .../test/input/test_getmodule.py                |    5 +
 .../test/input/test_zope_interface.py           |    4 +
 .../bin/pythonSrc/pychecker-0.8.18/test/main.py |   13 +
 .../pychecker-0.8.18/test/test_module.py        |   22 +
 .../pychecker-0.8.18/test/test_stdlib.py        |   25 +
 .../pythonSrc/pychecker-0.8.18/test_check.sh    |   69 +
 .../pychecker-0.8.18/test_expected/test1        |   35 +
 .../pychecker-0.8.18/test_expected/test1-2.3    |   33 +
 .../pychecker-0.8.18/test_expected/test1-2.4    |   33 +
 .../pychecker-0.8.18/test_expected/test1-2.5    |   33 +
 .../pychecker-0.8.18/test_expected/test1-2.6    |   33 +
 .../pychecker-0.8.18/test_expected/test10       |    5 +
 .../pychecker-0.8.18/test_expected/test100      |    5 +
 .../pychecker-0.8.18/test_expected/test101      |    5 +
 .../pychecker-0.8.18/test_expected/test102      |    5 +
 .../pychecker-0.8.18/test_expected/test11       |    5 +
 .../pychecker-0.8.18/test_expected/test12       |    5 +
 .../pychecker-0.8.18/test_expected/test13       |    6 +
 .../pychecker-0.8.18/test_expected/test14       |    9 +
 .../pychecker-0.8.18/test_expected/test15       |    8 +
 .../pychecker-0.8.18/test_expected/test16       |    5 +
 .../pychecker-0.8.18/test_expected/test17       |    8 +
 .../pychecker-0.8.18/test_expected/test17-2.4   |    7 +
 .../pychecker-0.8.18/test_expected/test18       |   16 +
 .../pychecker-0.8.18/test_expected/test19       |    6 +
 .../pychecker-0.8.18/test_expected/test2        |    8 +
 .../pychecker-0.8.18/test_expected/test20       |    7 +
 .../pychecker-0.8.18/test_expected/test20-2.4   |    6 +
 .../pychecker-0.8.18/test_expected/test20-2.5   |    6 +
 .../pychecker-0.8.18/test_expected/test20-2.6   |    6 +
 .../pychecker-0.8.18/test_expected/test21       |    7 +
 .../pychecker-0.8.18/test_expected/test22       |   33 +
 .../pychecker-0.8.18/test_expected/test23       |    8 +
 .../pychecker-0.8.18/test_expected/test24       |   10 +
 .../pychecker-0.8.18/test_expected/test25       |    8 +
 .../pychecker-0.8.18/test_expected/test26       |    5 +
 .../pychecker-0.8.18/test_expected/test27       |    7 +
 .../pychecker-0.8.18/test_expected/test27-2.2   |    5 +
 .../pychecker-0.8.18/test_expected/test27-2.3   |    5 +
 .../pychecker-0.8.18/test_expected/test27-2.4   |    5 +
 .../pychecker-0.8.18/test_expected/test27-2.5   |    5 +
 .../pychecker-0.8.18/test_expected/test27-2.6   |    5 +
 .../pychecker-0.8.18/test_expected/test28       |    5 +
 .../pychecker-0.8.18/test_expected/test29       |    5 +
 .../pychecker-0.8.18/test_expected/test3        |    8 +
 .../pychecker-0.8.18/test_expected/test3-2.2    |    8 +
 .../pychecker-0.8.18/test_expected/test3-2.3    |    9 +
 .../pychecker-0.8.18/test_expected/test3-2.4    |    8 +
 .../pychecker-0.8.18/test_expected/test3-2.5    |    8 +
 .../pychecker-0.8.18/test_expected/test3-2.6    |    8 +
 .../pychecker-0.8.18/test_expected/test30       |    5 +
 .../pychecker-0.8.18/test_expected/test31       |   10 +
 .../pychecker-0.8.18/test_expected/test32       |    6 +
 .../pychecker-0.8.18/test_expected/test33       |    5 +
 .../pychecker-0.8.18/test_expected/test34       |   14 +
 .../pychecker-0.8.18/test_expected/test34-2.2   |   17 +
 .../pychecker-0.8.18/test_expected/test34-2.3   |   17 +
 .../pychecker-0.8.18/test_expected/test34-2.4   |   14 +
 .../pychecker-0.8.18/test_expected/test34-2.5   |   14 +
 .../pychecker-0.8.18/test_expected/test34-2.6   |   14 +
 .../pychecker-0.8.18/test_expected/test35       |    6 +
 .../pychecker-0.8.18/test_expected/test36       |    7 +
 .../pychecker-0.8.18/test_expected/test37       |    5 +
 .../pychecker-0.8.18/test_expected/test38       |   22 +
 .../pychecker-0.8.18/test_expected/test39       |   14 +
 .../pychecker-0.8.18/test_expected/test39-2.2   |   14 +
 .../pychecker-0.8.18/test_expected/test39-2.3   |   14 +
 .../pychecker-0.8.18/test_expected/test39-2.4   |   14 +
 .../pychecker-0.8.18/test_expected/test39-2.5   |   14 +
 .../pychecker-0.8.18/test_expected/test39-2.6   |   14 +
 .../pychecker-0.8.18/test_expected/test4        |    6 +
 .../pychecker-0.8.18/test_expected/test40       |   15 +
 .../pychecker-0.8.18/test_expected/test41       |    7 +
 .../pychecker-0.8.18/test_expected/test42       |    5 +
 .../pychecker-0.8.18/test_expected/test43       |    5 +
 .../pychecker-0.8.18/test_expected/test44       |    5 +
 .../pychecker-0.8.18/test_expected/test45       |    6 +
 .../pychecker-0.8.18/test_expected/test46       |   10 +
 .../pychecker-0.8.18/test_expected/test47       |    5 +
 .../pychecker-0.8.18/test_expected/test48       |   40 +
 .../pychecker-0.8.18/test_expected/test49       |    8 +
 .../pychecker-0.8.18/test_expected/test5        |    5 +
 .../pychecker-0.8.18/test_expected/test50       |    8 +
 .../pychecker-0.8.18/test_expected/test51       |    6 +
 .../pychecker-0.8.18/test_expected/test52       |    5 +
 .../pychecker-0.8.18/test_expected/test53       |    9 +
 .../pychecker-0.8.18/test_expected/test54       |    9 +
 .../pychecker-0.8.18/test_expected/test55       |    9 +
 .../pychecker-0.8.18/test_expected/test56       |    5 +
 .../pychecker-0.8.18/test_expected/test57       |    5 +
 .../pychecker-0.8.18/test_expected/test58       |   10 +
 .../pychecker-0.8.18/test_expected/test58-2.2   |   14 +
 .../pychecker-0.8.18/test_expected/test58-2.3   |    8 +
 .../pychecker-0.8.18/test_expected/test58-2.4   |    8 +
 .../pychecker-0.8.18/test_expected/test58-2.5   |    8 +
 .../pychecker-0.8.18/test_expected/test58-2.6   |    8 +
 .../pychecker-0.8.18/test_expected/test59       |    9 +
 .../pychecker-0.8.18/test_expected/test6        |    5 +
 .../pychecker-0.8.18/test_expected/test60       |    6 +
 .../pychecker-0.8.18/test_expected/test61       |   12 +
 .../pychecker-0.8.18/test_expected/test62       |    5 +
 .../pychecker-0.8.18/test_expected/test63       |    5 +
 .../pychecker-0.8.18/test_expected/test64       |    9 +
 .../pychecker-0.8.18/test_expected/test65       |    5 +
 .../pychecker-0.8.18/test_expected/test66       |    5 +
 .../pychecker-0.8.18/test_expected/test67       |    5 +
 .../pychecker-0.8.18/test_expected/test68       |    9 +
 .../pychecker-0.8.18/test_expected/test68-2.4   |    5 +
 .../pychecker-0.8.18/test_expected/test68-2.5   |    5 +
 .../pychecker-0.8.18/test_expected/test68-2.6   |    5 +
 .../pychecker-0.8.18/test_expected/test69       |    5 +
 .../pychecker-0.8.18/test_expected/test7        |    5 +
 .../pychecker-0.8.18/test_expected/test70       |   12 +
 .../pychecker-0.8.18/test_expected/test71       |   10 +
 .../pychecker-0.8.18/test_expected/test71-2.4   |    8 +
 .../pychecker-0.8.18/test_expected/test71-2.5   |    8 +
 .../pychecker-0.8.18/test_expected/test71-2.6   |    8 +
 .../pychecker-0.8.18/test_expected/test72       |    8 +
 .../pychecker-0.8.18/test_expected/test73       |    9 +
 .../pychecker-0.8.18/test_expected/test74       |   11 +
 .../pychecker-0.8.18/test_expected/test74-2.4   |   10 +
 .../pychecker-0.8.18/test_expected/test74-2.5   |   10 +
 .../pychecker-0.8.18/test_expected/test74-2.6   |   10 +
 .../pychecker-0.8.18/test_expected/test75       |    6 +
 .../pychecker-0.8.18/test_expected/test75-2.2   |    9 +
 .../pychecker-0.8.18/test_expected/test75-2.3   |    9 +
 .../pychecker-0.8.18/test_expected/test75-2.4   |    9 +
 .../pychecker-0.8.18/test_expected/test75-2.5   |    9 +
 .../pychecker-0.8.18/test_expected/test75-2.6   |    9 +
 .../pychecker-0.8.18/test_expected/test76       |    6 +
 .../pychecker-0.8.18/test_expected/test77       |   11 +
 .../pychecker-0.8.18/test_expected/test78       |    5 +
 .../pychecker-0.8.18/test_expected/test79       |    6 +
 .../pychecker-0.8.18/test_expected/test8        |    8 +
 .../pychecker-0.8.18/test_expected/test80       |    6 +
 .../pychecker-0.8.18/test_expected/test80-2.2   |    6 +
 .../pychecker-0.8.18/test_expected/test80-2.3   |    6 +
 .../pychecker-0.8.18/test_expected/test80-2.4   |    6 +
 .../pychecker-0.8.18/test_expected/test80-2.5   |    6 +
 .../pychecker-0.8.18/test_expected/test80-2.6   |    6 +
 .../pychecker-0.8.18/test_expected/test81       |    5 +
 .../pychecker-0.8.18/test_expected/test82       |    5 +
 .../pychecker-0.8.18/test_expected/test83       |    9 +
 .../pychecker-0.8.18/test_expected/test84       |    5 +
 .../pychecker-0.8.18/test_expected/test85       |    6 +
 .../pychecker-0.8.18/test_expected/test86       |   13 +
 .../pychecker-0.8.18/test_expected/test87       |   25 +
 .../pychecker-0.8.18/test_expected/test88       |    9 +
 .../pychecker-0.8.18/test_expected/test88-2.4   |   11 +
 .../pychecker-0.8.18/test_expected/test89       |   11 +
 .../pychecker-0.8.18/test_expected/test89-2.2   |    5 +
 .../pychecker-0.8.18/test_expected/test89-2.3   |    5 +
 .../pychecker-0.8.18/test_expected/test89-2.4   |    5 +
 .../pychecker-0.8.18/test_expected/test89-2.5   |    5 +
 .../pychecker-0.8.18/test_expected/test89-2.6   |    5 +
 .../pychecker-0.8.18/test_expected/test9        |    6 +
 .../pychecker-0.8.18/test_expected/test90       |   16 +
 .../pychecker-0.8.18/test_expected/test92       |    5 +
 .../pychecker-0.8.18/test_expected/test93       |    6 +
 .../pychecker-0.8.18/test_expected/test94       |   16 +
 .../pychecker-0.8.18/test_expected/test95       |    5 +
 .../pychecker-0.8.18/test_expected/test96       |    6 +
 .../pychecker-0.8.18/test_expected/test97       |    5 +
 .../pychecker-0.8.18/test_expected/test98       |    8 +
 .../pychecker-0.8.18/test_expected/test99       |    5 +
 .../pychecker-0.8.18/test_input/__init__.py     |    3 +
 .../pychecker-0.8.18/test_input/import24.py     |   14 +
 .../pychecker-0.8.18/test_input/import37.py     |    7 +
 .../pychecker-0.8.18/test_input/import44.py     |   12 +
 .../pychecker-0.8.18/test_input/import47.py     |    7 +
 .../pychecker-0.8.18/test_input/import56a.py    |    9 +
 .../pychecker-0.8.18/test_input/import56b.py    |    6 +
 .../pychecker-0.8.18/test_input/import69.py     |    8 +
 .../pychecker-0.8.18/test_input/import73.py     |    9 +
 .../pychecker-0.8.18/test_input/import98.py     |   11 +
 .../pychecker-0.8.18/test_input/pycheckrc       |    7 +
 .../pychecker-0.8.18/test_input/test1.py        |   75 +
 .../pychecker-0.8.18/test_input/test10.py       |    8 +
 .../pychecker-0.8.18/test_input/test100.py      |   15 +
 .../pychecker-0.8.18/test_input/test101.py      |   33 +
 .../pychecker-0.8.18/test_input/test102.py      |   16 +
 .../pychecker-0.8.18/test_input/test11.py       |   20 +
 .../pychecker-0.8.18/test_input/test12.py       |    8 +
 .../pychecker-0.8.18/test_input/test13.py       |   30 +
 .../pychecker-0.8.18/test_input/test14.py       |   24 +
 .../pychecker-0.8.18/test_input/test15.py       |   39 +
 .../pychecker-0.8.18/test_input/test16.py       |   19 +
 .../pychecker-0.8.18/test_input/test17.py       |   35 +
 .../pychecker-0.8.18/test_input/test18.py       |   44 +
 .../pychecker-0.8.18/test_input/test19.py       |   10 +
 .../pychecker-0.8.18/test_input/test2.py        |   20 +
 .../pychecker-0.8.18/test_input/test20.py       |   41 +
 .../pychecker-0.8.18/test_input/test21.py       |   57 +
 .../pychecker-0.8.18/test_input/test22.py       |   86 +
 .../pychecker-0.8.18/test_input/test23.py       |   48 +
 .../pychecker-0.8.18/test_input/test24.py       |   12 +
 .../pychecker-0.8.18/test_input/test25.py       |   16 +
 .../pychecker-0.8.18/test_input/test26.py       |   11 +
 .../pychecker-0.8.18/test_input/test27.py       |   15 +
 .../pychecker-0.8.18/test_input/test28.py       |    8 +
 .../pychecker-0.8.18/test_input/test29.py       |   14 +
 .../pychecker-0.8.18/test_input/test3.py        |   14 +
 .../pychecker-0.8.18/test_input/test30.py       |    8 +
 .../pychecker-0.8.18/test_input/test31.py       |   38 +
 .../pychecker-0.8.18/test_input/test32.py       |   16 +
 .../pychecker-0.8.18/test_input/test33.py       |   10 +
 .../pychecker-0.8.18/test_input/test34.py       |   27 +
 .../pychecker-0.8.18/test_input/test35.py       |   13 +
 .../pychecker-0.8.18/test_input/test36.py       |   40 +
 .../pychecker-0.8.18/test_input/test37.py       |    7 +
 .../pychecker-0.8.18/test_input/test38.py       |   54 +
 .../pychecker-0.8.18/test_input/test39.py       |   44 +
 .../pychecker-0.8.18/test_input/test4.py        |   32 +
 .../pychecker-0.8.18/test_input/test40.py       |   34 +
 .../pychecker-0.8.18/test_input/test41.py       |   18 +
 .../pychecker-0.8.18/test_input/test42.py       |   16 +
 .../pychecker-0.8.18/test_input/test43.py       |   11 +
 .../pychecker-0.8.18/test_input/test44.py       |    9 +
 .../pychecker-0.8.18/test_input/test45.py       |   23 +
 .../pychecker-0.8.18/test_input/test46.py       |    7 +
 .../pychecker-0.8.18/test_input/test47.py       |    7 +
 .../pychecker-0.8.18/test_input/test48.py       |   84 +
 .../pychecker-0.8.18/test_input/test49.py       |   37 +
 .../pychecker-0.8.18/test_input/test5.py        |   20 +
 .../pychecker-0.8.18/test_input/test50.py       |   21 +
 .../pychecker-0.8.18/test_input/test51.py       |   19 +
 .../pychecker-0.8.18/test_input/test52.py       |   54 +
 .../pychecker-0.8.18/test_input/test53.py       |   28 +
 .../pychecker-0.8.18/test_input/test54.py       |   20 +
 .../pychecker-0.8.18/test_input/test55.py       |   47 +
 .../pychecker-0.8.18/test_input/test56.py       |    7 +
 .../pychecker-0.8.18/test_input/test57.py       |   11 +
 .../pychecker-0.8.18/test_input/test58.py       |   11 +
 .../pychecker-0.8.18/test_input/test59.py       |   31 +
 .../pychecker-0.8.18/test_input/test6.py        |   31 +
 .../pychecker-0.8.18/test_input/test60.py       |   22 +
 .../pychecker-0.8.18/test_input/test61.py       |   28 +
 .../pychecker-0.8.18/test_input/test62.py       |    4 +
 .../pychecker-0.8.18/test_input/test63.py       |   15 +
 .../pychecker-0.8.18/test_input/test64.py       |   17 +
 .../pychecker-0.8.18/test_input/test65.py       |   21 +
 .../pychecker-0.8.18/test_input/test66.py       |    7 +
 .../pychecker-0.8.18/test_input/test67.py       |   16 +
 .../pychecker-0.8.18/test_input/test68.py       |  170 ++
 .../pychecker-0.8.18/test_input/test69.py       |   22 +
 .../pychecker-0.8.18/test_input/test7.py        |   18 +
 .../pychecker-0.8.18/test_input/test70.py       |   60 +
 .../pychecker-0.8.18/test_input/test71.py       |   50 +
 .../pychecker-0.8.18/test_input/test72.py       |   29 +
 .../pychecker-0.8.18/test_input/test73.py       |   37 +
 .../pychecker-0.8.18/test_input/test74.py       |   41 +
 .../pychecker-0.8.18/test_input/test75.py       |   87 +
 .../pychecker-0.8.18/test_input/test76.py       |   12 +
 .../pychecker-0.8.18/test_input/test77.py       |    9 +
 .../pychecker-0.8.18/test_input/test78.py       |   19 +
 .../pychecker-0.8.18/test_input/test79.py       |   33 +
 .../pychecker-0.8.18/test_input/test8.py        |    4 +
 .../pychecker-0.8.18/test_input/test80.py       |   25 +
 .../pychecker-0.8.18/test_input/test81.py       |   30 +
 .../pychecker-0.8.18/test_input/test82.py       |   18 +
 .../pychecker-0.8.18/test_input/test83.py       |   43 +
 .../pychecker-0.8.18/test_input/test84.py       |   10 +
 .../pychecker-0.8.18/test_input/test85.py       |   22 +
 .../pychecker-0.8.18/test_input/test86.py       |   96 +
 .../pychecker-0.8.18/test_input/test87.py       |   56 +
 .../pychecker-0.8.18/test_input/test88.py       |   23 +
 .../pychecker-0.8.18/test_input/test89.py       |    8 +
 .../pychecker-0.8.18/test_input/test9.py        |   17 +
 .../pychecker-0.8.18/test_input/test90.py       |   22 +
 .../pychecker-0.8.18/test_input/test92.py       |    6 +
 .../pychecker-0.8.18/test_input/test93.py       |   11 +
 .../pychecker-0.8.18/test_input/test94.py       |   54 +
 .../pychecker-0.8.18/test_input/test95.py       |    5 +
 .../pychecker-0.8.18/test_input/test96.py       |   15 +
 .../pychecker-0.8.18/test_input/test97.py       |   20 +
 .../pychecker-0.8.18/test_input/test98.py       |   33 +
 .../pychecker-0.8.18/test_input/test99.py       |   22 +
 tools/bin/pythonSrc/unittest2-0.5.1/PKG-INFO    |  321 +++
 tools/bin/pythonSrc/unittest2-0.5.1/README.txt  |  296 +++
 tools/bin/pythonSrc/unittest2-0.5.1/setup.cfg   |    8 +
 tools/bin/pythonSrc/unittest2-0.5.1/setup.py    |   85 +
 tools/bin/pythonSrc/unittest2-0.5.1/unit2       |    7 +
 tools/bin/pythonSrc/unittest2-0.5.1/unit2.py    |    7 +
 .../unittest2-0.5.1/unittest2.egg-info/PKG-INFO |  321 +++
 .../unittest2.egg-info/SOURCES.txt              |   39 +
 .../unittest2.egg-info/dependency_links.txt     |    1 +
 .../unittest2.egg-info/entry_points.txt         |    4 +
 .../unittest2.egg-info/top_level.txt            |    1 +
 .../unittest2-0.5.1/unittest2/__init__.py       |   68 +
 .../unittest2-0.5.1/unittest2/__main__.py       |   10 +
 .../pythonSrc/unittest2-0.5.1/unittest2/case.py | 1084 ++++++++++
 .../unittest2-0.5.1/unittest2/collector.py      |    9 +
 .../unittest2-0.5.1/unittest2/compatibility.py  |   64 +
 .../unittest2-0.5.1/unittest2/loader.py         |  322 +++
 .../pythonSrc/unittest2-0.5.1/unittest2/main.py |  241 +++
 .../unittest2-0.5.1/unittest2/result.py         |  183 ++
 .../unittest2-0.5.1/unittest2/runner.py         |  206 ++
 .../unittest2-0.5.1/unittest2/signals.py        |   57 +
 .../unittest2-0.5.1/unittest2/suite.py          |  287 +++
 .../unittest2-0.5.1/unittest2/test/__init__.py  |    1 +
 .../unittest2-0.5.1/unittest2/test/dummy.py     |    0
 .../unittest2-0.5.1/unittest2/test/support.py   |  177 ++
 .../unittest2/test/test_assertions.py           |  254 +++
 .../unittest2/test/test_break.py                |  260 +++
 .../unittest2-0.5.1/unittest2/test/test_case.py | 1065 ++++++++++
 .../unittest2/test/test_discovery.py            |  371 ++++
 .../unittest2/test/test_functiontestcase.py     |  149 ++
 .../unittest2/test/test_loader.py               | 1286 ++++++++++++
 .../unittest2/test/test_new_tests.py            |   46 +
 .../unittest2/test/test_program.py              |  239 +++
 .../unittest2/test/test_result.py               |  416 ++++
 .../unittest2/test/test_runner.py               |  129 ++
 .../unittest2/test/test_setups.py               |  502 +++++
 .../unittest2/test/test_skipping.py             |  143 ++
 .../unittest2/test/test_suite.py                |  341 +++
 .../unittest2/test/test_unittest2_with.py       |  143 ++
 .../pythonSrc/unittest2-0.5.1/unittest2/util.py |   99 +
 562 files changed, 55504 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/Makefile
----------------------------------------------------------------------
diff --git a/tools/bin/Makefile b/tools/bin/Makefile
index 273b599..46a2df6 100644
--- a/tools/bin/Makefile
+++ b/tools/bin/Makefile
@@ -36,7 +36,7 @@ PYLIB_SRC=$(SRC)/pythonSrc
 LIB_DIR=$(SRC)/lib
 PYLIB_DIR=$(SRC)/ext
 
-all: stream pygresql
+all: lockfile pygresql stream pychecker psi unittest2
 
 #
 # Python Libraries
@@ -65,6 +65,76 @@ pygresql:
 	cp -r $(PYLIB_SRC)/$(PYGRESQL_DIR)/build/lib.*/* $(PYLIB_DIR)/pygresql
 	touch $(PYLIB_DIR)/__init__.py
 
+#
+# LOCKFILE
+#
+# note the awk commands are used to eliminate references to code in __init__.py
+# that we don't use and also to insert a comment to tell pylint not to complain
+# about these files since we are not in a position to correct those warnings.
+#
+LOCKFILE_VERSION=0.9.1
+LOCKFILE_DIR=lockfile-$(LOCKFILE_VERSION)
+LOCKFILE_SRC=$(PYLIB_SRC)/$(LOCKFILE_DIR)/build/lib/lockfile
+LOCKFILE_DST=$(PYLIB_DIR)/lockfile
+lockfile:
+	@echo "--- lockfile"
+	cd $(PYLIB_SRC)/$(LOCKFILE_DIR)/ && python setup.py build
+	mkdir -p $(PYLIB_DIR)/lockfile
+	awk 'BEGIN{print "# pylint: disable-all"} /^if hasattr/ {exit} { print }' < $(LOCKFILE_SRC)/__init__.py    > $(LOCKFILE_DST)/__init__.py
+	awk 'BEGIN{print "# pylint: disable-all"} { print }'                      < $(LOCKFILE_SRC)/pidlockfile.py > $(LOCKFILE_DST)/pidlockfile.py
+
+#
+# PYCRYPTO
+#
+PYCRYPTO_VERSION=2.0.1
+PYCRYPTO_DIR=pycrypto-$(PYCRYPTO_VERSION)
+
+pycrypto:
+	@echo "--- pycrypto"
+	cd $(PYLIB_SRC)/$(PYCRYPTO_DIR)/ && CC="$(CC)" CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" python setup.py build
+	cp -r $(PYLIB_SRC)/$(PYCRYPTO_DIR)/build/lib.*/Crypto $(PYLIB_DIR)
+
+#
+# PSI
+#
+PSI_VERSION=0.3b2_gp
+PSI_DIR=PSI-$(PSI_VERSION)
+
+psi:
+	@echo "--- psi"
+	cd $(PYLIB_SRC)/$(PSI_DIR)/ && CC="$(CC)" CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" python setup.py build
+	cp -r $(PYLIB_SRC)/$(PSI_DIR)/build/lib.*/psi $(PYLIB_DIR)
+
+#
+# PYCHECKER
+#
+PYCHECKER_VERSION=0.8.18
+PYCHECKER_DIR=pychecker-$(PYCHECKER_VERSION)
+
+pychecker:
+	@echo "--- pychecker"
+	cd $(PYLIB_SRC)/$(PYCHECKER_DIR)/ && python setup.py build
+	cp -r $(PYLIB_SRC)/$(PYCHECKER_DIR)/build/lib/pychecker  $(PYLIB_DIR)/
+
+UNITTEST2_VERSION=0.5.1
+UNITTEST2_DIR=unittest2-${UNITTEST2_VERSION}
+unittest2:
+	@echo "--- unittest2"
+	cd $(PYLIB_SRC)/$(UNITTEST2_DIR)/ && python setup.py build
+	cp -r $(PYLIB_SRC)/$(UNITTEST2_DIR)/build/lib/unittest2  $(PYLIB_DIR)/
+
+#
+# PARAMIKO
+#
+PARAMIKO_VERSION=1.7.6-9
+PARAMIKO_DIR=paramiko-$(PARAMIKO_VERSION)
+paramiko:
+	@echo "--- paramiko"
+	cd $(PYLIB_SRC)/ && $(TAR) xzf $(PARAMIKO_DIR).tar.gz
+	cd $(PYLIB_SRC)/$(PARAMIKO_DIR)/ && python setup.py build
+	cp -r $(PYLIB_SRC)/$(PARAMIKO_DIR)/build/lib/paramiko  $(PYLIB_DIR)/
+
+
 PYTHON_FILES=`grep -l --exclude=Makefile --exclude=gplogfilter --exclude=gpcheckos --exclude=gpgenfsmap.py --exclude=throttlingD.py "/bin/env python" *`\
 			 `grep -l "/bin/env python" $(SRC)/../sbin/*`\
 			 `find ./gppylib -name "*.py"`\

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/__init__.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/__init__.py b/tools/bin/ext/__init__.py
index e69de29..b6c84f9 100644
--- a/tools/bin/ext/__init__.py
+++ b/tools/bin/ext/__init__.py
@@ -0,0 +1,306 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from error import *
+
+from tokens import *
+from events import *
+from nodes import *
+
+from loader import *
+from dumper import *
+
+try:
+    from cyaml import *
+except ImportError:
+    pass
+
+def scan(stream, Loader=Loader):
+    """
+    Scan a YAML stream and produce scanning tokens.
+    """
+    loader = Loader(stream)
+    while loader.check_token():
+        yield loader.get_token()
+
+def parse(stream, Loader=Loader):
+    """
+    Parse a YAML stream and produce parsing events.
+    """
+    loader = Loader(stream)
+    while loader.check_event():
+        yield loader.get_event()
+
+def compose(stream, Loader=Loader):
+    """
+    Parse the first YAML document in a stream
+    and produce the corresponding representation tree.
+    """
+    loader = Loader(stream)
+    if loader.check_node():
+        return loader.get_node()
+
+def compose_all(stream, Loader=Loader):
+    """
+    Parse all YAML documents in a stream
+    and produce corresponsing representation trees.
+    """
+    loader = Loader(stream)
+    while loader.check_node():
+        yield loader.get_node()
+
+def load_all(stream, Loader=Loader):
+    """
+    Parse all YAML documents in a stream
+    and produce corresponding Python objects.
+    """
+    loader = Loader(stream)
+    while loader.check_data():
+        yield loader.get_data()
+
+def load(stream, Loader=Loader):
+    """
+    Parse the first YAML document in a stream
+    and produce the corresponding Python object.
+    """
+    loader = Loader(stream)
+    if loader.check_data():
+        return loader.get_data()
+
+def safe_load_all(stream):
+    """
+    Parse all YAML documents in a stream
+    and produce corresponding Python objects.
+    Resolve only basic YAML tags.
+    """
+    return load_all(stream, SafeLoader)
+
+def safe_load(stream):
+    """
+    Parse the first YAML document in a stream
+    and produce the corresponding Python object.
+    Resolve only basic YAML tags.
+    """
+    return load(stream, SafeLoader)
+
+def emit(events, stream=None, Dumper=Dumper,
+        canonical=None, indent=None, width=None,
+        allow_unicode=None, line_break=None):
+    """
+    Emit YAML parsing events into a stream.
+    If stream is None, return the produced string instead.
+    """
+    getvalue = None
+    if stream is None:
+        try:
+            from cStringIO import StringIO
+        except ImportError:
+            from StringIO import StringIO
+        stream = StringIO()
+        getvalue = stream.getvalue
+    dumper = Dumper(stream, canonical=canonical, indent=indent, width=width,
+            allow_unicode=allow_unicode, line_break=line_break)
+    for event in events:
+        dumper.emit(event)
+    if getvalue:
+        return getvalue()
+
+def serialize_all(nodes, stream=None, Dumper=Dumper,
+        canonical=None, indent=None, width=None,
+        allow_unicode=None, line_break=None,
+        encoding='utf-8', explicit_start=None, explicit_end=None,
+        version=None, tags=None):
+    """
+    Serialize a sequence of representation trees into a YAML stream.
+    If stream is None, return the produced string instead.
+    """
+    getvalue = None
+    if stream is None:
+        try:
+            from cStringIO import StringIO
+        except ImportError:
+            from StringIO import StringIO
+        stream = StringIO()
+        getvalue = stream.getvalue
+    dumper = Dumper(stream, canonical=canonical, indent=indent, width=width,
+            allow_unicode=allow_unicode, line_break=line_break,
+            encoding=encoding, version=version, tags=tags,
+            explicit_start=explicit_start, explicit_end=explicit_end)
+    dumper.open()
+    for node in nodes:
+        dumper.serialize(node)
+    dumper.close()
+    if getvalue:
+        return getvalue()
+
+def serialize(node, stream=None, Dumper=Dumper, **kwds):
+    """
+    Serialize a representation tree into a YAML stream.
+    If stream is None, return the produced string instead.
+    """
+    return serialize_all([node], stream, Dumper=Dumper, **kwds)
+
+def dump_all(documents, stream=None, Dumper=Dumper,
+        default_style=None, default_flow_style=None,
+        canonical=None, indent=None, width=None,
+        allow_unicode=None, line_break=None,
+        encoding='utf-8', explicit_start=None, explicit_end=None,
+        version=None, tags=None):
+    """
+    Serialize a sequence of Python objects into a YAML stream.
+    If stream is None, return the produced string instead.
+    """
+    getvalue = None
+    if stream is None:
+        try:
+            from cStringIO import StringIO
+        except ImportError:
+            from StringIO import StringIO
+        stream = StringIO()
+        getvalue = stream.getvalue
+    dumper = Dumper(stream, default_style=default_style,
+            default_flow_style=default_flow_style,
+            canonical=canonical, indent=indent, width=width,
+            allow_unicode=allow_unicode, line_break=line_break,
+            encoding=encoding, version=version, tags=tags,
+            explicit_start=explicit_start, explicit_end=explicit_end)
+    dumper.open()
+    for data in documents:
+        dumper.represent(data)
+    dumper.close()
+    if getvalue:
+        return getvalue()
+
+def dump(data, stream=None, Dumper=Dumper, **kwds):
+    """
+    Serialize a Python object into a YAML stream.
+    If stream is None, return the produced string instead.
+    """
+    return dump_all([data], stream, Dumper=Dumper, **kwds)
+
+def safe_dump_all(documents, stream=None, **kwds):
+    """
+    Serialize a sequence of Python objects into a YAML stream.
+    Produce only basic YAML tags.
+    If stream is None, return the produced string instead.
+    """
+    return dump_all(documents, stream, Dumper=SafeDumper, **kwds)
+
+def safe_dump(data, stream=None, **kwds):
+    """
+    Serialize a Python object into a YAML stream.
+    Produce only basic YAML tags.
+    If stream is None, return the produced string instead.
+    """
+    return dump_all([data], stream, Dumper=SafeDumper, **kwds)
+
+def add_implicit_resolver(tag, regexp, first=None,
+        Loader=Loader, Dumper=Dumper):
+    """
+    Add an implicit scalar detector.
+    If an implicit scalar value matches the given regexp,
+    the corresponding tag is assigned to the scalar.
+    first is a sequence of possible initial characters or None.
+    """
+    Loader.add_implicit_resolver(tag, regexp, first)
+    Dumper.add_implicit_resolver(tag, regexp, first)
+
+def add_path_resolver(tag, path, kind=None, Loader=Loader, Dumper=Dumper):
+    """
+    Add a path based resolver for the given tag.
+    A path is a list of keys that forms a path
+    to a node in the representation tree.
+    Keys can be string values, integers, or None.
+    """
+    Loader.add_path_resolver(tag, path, kind)
+    Dumper.add_path_resolver(tag, path, kind)
+
+def add_constructor(tag, constructor, Loader=Loader):
+    """
+    Add a constructor for the given tag.
+    Constructor is a function that accepts a Loader instance
+    and a node object and produces the corresponding Python object.
+    """
+    Loader.add_constructor(tag, constructor)
+
+def add_multi_constructor(tag_prefix, multi_constructor, Loader=Loader):
+    """
+    Add a multi-constructor for the given tag prefix.
+    Multi-constructor is called for a node if its tag starts with tag_prefix.
+    Multi-constructor accepts a Loader instance, a tag suffix,
+    and a node object and produces the corresponding Python object.
+    """
+    Loader.add_multi_constructor(tag_prefix, multi_constructor)
+
+def add_representer(data_type, representer, Dumper=Dumper):
+    """
+    Add a representer for the given type.
+    Representer is a function accepting a Dumper instance
+    and an instance of the given data type
+    and producing the corresponding representation node.
+    """
+    Dumper.add_representer(data_type, representer)
+
+def add_multi_representer(data_type, multi_representer, Dumper=Dumper):
+    """
+    Add a representer for the given type.
+    Multi-representer is a function accepting a Dumper instance
+    and an instance of the given data type or subtype
+    and producing the corresponding representation node.
+    """
+    Dumper.add_multi_representer(data_type, multi_representer)
+
+class YAMLObjectMetaclass(type):
+    """
+    The metaclass for YAMLObject.
+    """
+    def __init__(cls, name, bases, kwds):
+        super(YAMLObjectMetaclass, cls).__init__(name, bases, kwds)
+        if 'yaml_tag' in kwds and kwds['yaml_tag'] is not None:
+            cls.yaml_loader.add_constructor(cls.yaml_tag, cls.from_yaml)
+            cls.yaml_dumper.add_representer(cls, cls.to_yaml)
+
+class YAMLObject(object):
+    """
+    An object that can dump itself to a YAML stream
+    and load itself from a YAML stream.
+    """
+
+    __metaclass__ = YAMLObjectMetaclass
+    __slots__ = ()  # no direct instantiation, so allow immutable subclasses
+
+    yaml_loader = Loader
+    yaml_dumper = Dumper
+
+    yaml_tag = None
+    yaml_flow_style = None
+
+    def from_yaml(cls, loader, node):
+        """
+        Convert a representation node to a Python object.
+        """
+        return loader.construct_yaml_object(node, cls)
+    from_yaml = classmethod(from_yaml)
+
+    def to_yaml(cls, dumper, data):
+        """
+        Convert a Python object to a representation node.
+        """
+        return dumper.represent_yaml_object(cls.yaml_tag, data, cls,
+                flow_style=cls.yaml_flow_style)
+    to_yaml = classmethod(to_yaml)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/figleaf/__init__.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/figleaf/__init__.py b/tools/bin/ext/figleaf/__init__.py
new file mode 100644
index 0000000..5761930
--- /dev/null
+++ b/tools/bin/ext/figleaf/__init__.py
@@ -0,0 +1,325 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""
+figleaf is another tool to trace Python code coverage.
+
+figleaf uses the sys.settrace hook to record which statements are
+executed by the CPython interpreter; this record can then be saved
+into a file, or otherwise communicated back to a reporting script.
+
+figleaf differs from the gold standard of Python coverage tools
+('coverage.py') in several ways.  First and foremost, figleaf uses the
+same criterion for "interesting" lines of code as the sys.settrace
+function, which obviates some of the complexity in coverage.py (but
+does mean that your "loc" count goes down).  Second, figleaf does not
+record code executed in the Python standard library, which results in
+a significant speedup.  And third, the format in which the coverage
+format is saved is very simple and easy to work with.
+
+You might want to use figleaf if you're recording coverage from
+multiple types of tests and need to aggregate the coverage in
+interesting ways, and/or control when coverage is recorded.
+coverage.py is a better choice for command-line execution, and its
+reporting is a fair bit nicer.
+
+Command line usage: ::
+
+  figleaf <python file to execute> <args to python file>
+
+The figleaf output is saved into the file '.figleaf', which is an
+*aggregate* of coverage reports from all figleaf runs from this
+directory.  '.figleaf' contains a pickled dictionary of sets; the keys
+are source code filenames, and the sets contain all line numbers
+executed by the Python interpreter. See the docs or command-line
+programs in bin/ for more information.
+
+High level API: ::
+
+ * ``start(ignore_lib=True)`` -- start recording code coverage.
+ * ``stop()``                 -- stop recording code coverage.
+ * ``get_trace_obj()``        -- return the (singleton) trace object.
+ * ``get_info()``             -- get the coverage dictionary
+
+Classes & functions worth knowing about (lower level API):
+
+ * ``get_lines(fp)`` -- return the set of interesting lines in the fp.
+ * ``combine_coverage(d1, d2)`` -- combine coverage info from two dicts.
+ * ``read_coverage(filename)`` -- load the coverage dictionary
+ * ``write_coverage(filename)`` -- write the coverage out.
+ * ``annotate_coverage(...)`` -- annotate a Python file with its coverage info.
+
+Known problems:
+
+ -- module docstrings are *covered* but not found.
+
+AUTHOR: C. Titus Brown, titus@idyll.org, with contributions from Iain Lowe.
+
+'figleaf' is Copyright (C) 2006, 2007 C. Titus Brown.  It is under the
+BSD license.
+"""
+__version__ = "0.6.1"
+
+# __all__ == @CTB
+
+import sys
+import os
+from cPickle import dump, load
+from optparse import OptionParser
+
+import internals
+
+# use builtin sets if in >= 2.4, otherwise use 'sets' module.
+try:
+    set()
+except NameError:
+    from sets import Set as set
+
+def get_lines(fp):
+    """
+    Return the set of interesting lines in the source code read from
+    this file handle.
+    """
+    # rstrip is a workaround for http://bugs.python.org/issue4262
+    src = fp.read().rstrip() + "\n"
+    code = compile(src, "", "exec")
+    
+    return internals.get_interesting_lines(code)
+
+def combine_coverage(d1, d2):
+    """
+    Given two coverage dictionaries, combine the recorded coverage
+    and return a new dictionary.
+    """
+    keys = set(d1.keys())
+    keys.update(set(d2.keys()))
+
+    new_d = {}
+    for k in keys:
+        v = d1.get(k, set())
+        v2 = d2.get(k, set())
+
+        s = set(v)
+        s.update(v2)
+        new_d[k] = s
+
+    return new_d
+
+def write_coverage(filename, append=True):
+    """
+    Write the current coverage info out to the given filename.  If
+    'append' is false, destroy any previously recorded coverage info.
+    """
+    if _t is None:
+        return
+
+    data = internals.CoverageData(_t)
+
+    d = data.gather_files()
+
+    # sum existing coverage?
+    if append:
+        old = {}
+        fp = None
+        try:
+            fp = open(filename)
+        except IOError:
+            pass
+
+        if fp:
+            old = load(fp)
+            fp.close()
+            d = combine_coverage(d, old)
+
+    # ok, save.
+    outfp = open(filename, 'w')
+    try:
+        dump(d, outfp)
+    finally:
+        outfp.close()
+
+def read_coverage(filename):
+    """
+    Read a coverage dictionary in from the given file.
+    """
+    fp = open(filename)
+    try:
+        d = load(fp)
+    finally:
+        fp.close()
+
+    return d
+
+def dump_pickled_coverage(out_fp):
+    """
+    Dump coverage information in pickled format into the given file handle.
+    """
+    dump(_t, out_fp)
+
+def load_pickled_coverage(in_fp):
+    """
+    Replace (overwrite) coverage information from the given file handle.
+    """
+    global _t
+    _t = load(in_fp)
+
+def annotate_coverage(in_fp, out_fp, covered, all_lines,
+                      mark_possible_lines=False):
+    """
+    A simple example coverage annotator that outputs text.
+    """
+    for i, line in enumerate(in_fp):
+        i = i + 1
+
+        if i in covered:
+            symbol = '>'
+        elif i in all_lines:
+            symbol = '!'
+        else:
+            symbol = ' '
+
+        symbol2 = ''
+        if mark_possible_lines:
+            symbol2 = ' '
+            if i in all_lines:
+                symbol2 = '-'
+
+        out_fp.write('%s%s %s' % (symbol, symbol2, line,))
+
+def get_data():
+    if _t:
+        return internals.CoverageData(_t)
+
+#######################
+
+#
+# singleton functions/top-level API
+#
+
+_t = None
+
+def init(exclude_path=None, include_only=None):
+    from internals import CodeTracer
+    
+    global _t
+    if _t is None:
+        _t = CodeTracer(exclude_path, include_only)
+
+def start(ignore_python_lib=True):
+    """
+    Start tracing code coverage.  If 'ignore_python_lib' is True on
+    initial call, ignore all files that live below the same directory as
+    the 'os' module.
+    """
+    global _t
+    if not _t:
+        exclude_path = None
+        if ignore_python_lib:
+            exclude_path = os.path.realpath(os.path.dirname(os.__file__))
+
+        init(exclude_path, None)
+    
+    _t.start()
+
+def start_section(name):
+    global _t
+    _t.start_section(name)
+    
+def stop_section():
+    global _t
+    _t.stop_section()
+
+def stop():
+    """
+    Stop tracing code coverage.
+    """
+    global _t
+    if _t is not None:
+        _t.stop()
+
+def get_trace_obj():
+    """
+    Return the (singleton) trace object, if it exists.
+    """
+    return _t
+
+def get_info(section_name=None):
+    """
+    Get the coverage dictionary from the trace object.
+    """
+    if _t:
+        return get_data().gather_files(section_name)
+
+#############
+
+def display_ast():
+    l = internals.LineGrabber(open(sys.argv[1]))
+    l.pretty_print()
+    print l.lines
+
+def main():
+    """
+    Execute the given Python file with coverage, making it look like it is
+    __main__.
+    """
+    ignore_pylibs = False
+
+    # gather args
+
+    n = 1
+    figleaf_args = []
+    for n in range(1, len(sys.argv)):
+        arg = sys.argv[n]
+        if arg.startswith('-'):
+            figleaf_args.append(arg)
+        else:
+            break
+
+    remaining_args = sys.argv[n:]
+
+    usage = "usage: %prog [options] [python_script arg1 arg2 ...]"
+    option_parser = OptionParser(usage=usage)
+
+    option_parser.add_option('-i', '--ignore-pylibs', action="store_true",
+                             dest="ignore_pylibs", default=False,
+                             help="ignore Python library modules")
+
+    (options, args) = option_parser.parse_args(args=figleaf_args)
+    assert len(args) == 0
+
+    if not remaining_args:
+        option_parser.error("you must specify a python script to run!")
+
+    ignore_pylibs = options.ignore_pylibs
+
+    ## Reset system args so that the subsequently exec'd file can read
+    ## from sys.argv
+    
+    sys.argv = remaining_args
+
+    sys.path[0] = os.path.dirname(sys.argv[0])
+
+    cwd = os.getcwd()
+
+    start(ignore_pylibs)        # START code coverage
+
+    import __main__
+    try:
+        execfile(sys.argv[0], __main__.__dict__)
+    finally:
+        stop()                          # STOP code coverage
+
+        write_coverage(os.path.join(cwd, '.figleaf'))

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/figleaf/_lib.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/figleaf/_lib.py b/tools/bin/ext/figleaf/_lib.py
new file mode 100644
index 0000000..3ee49f8
--- /dev/null
+++ b/tools/bin/ext/figleaf/_lib.py
@@ -0,0 +1,22 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+import os.path, sys
+libdir = os.path.join(os.path.dirname(__file__), '../')
+libdir = os.path.normpath(libdir)
+
+if libdir not in sys.path:
+    sys.path.insert(0, libdir)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/figleaf/annotate.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/figleaf/annotate.py b/tools/bin/ext/figleaf/annotate.py
new file mode 100644
index 0000000..43099f6
--- /dev/null
+++ b/tools/bin/ext/figleaf/annotate.py
@@ -0,0 +1,241 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""
+Common functions for annotating files with figleaf coverage information.
+"""
+import sys, os
+from optparse import OptionParser
+import ConfigParser
+import re
+import logging
+
+import figleaf
+
+thisdir = os.path.dirname(__file__)
+
+try:                                    # 2.3 compatibility
+    logging.basicConfig(format='%(message)s', level=logging.WARNING)
+except TypeError:
+    pass
+
+logger = logging.getLogger('figleaf.annotate')
+
+DEFAULT_CONFIGURE_FILE = ".figleafrc"
+
+### utilities
+
+def safe_conf_get(conf, section, name, default):
+    try:
+        val = conf.get(section, name)
+    except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
+        val = default
+
+    return val
+
+def configure(parser):
+    """
+    Configure the optparse.OptionParser object with defaults, optionally
+    loaded from a configuration file.
+    """
+    CONFIG_FILE = os.environ.get('FIGLEAFRC', DEFAULT_CONFIGURE_FILE)
+    
+    parser.add_option("-c", "--coverage-file", action="store",
+                       type="string", dest="coverage_file",
+                       help="File containing figleaf coverage information.")
+    
+    parser.add_option("-s", "--sections-file", action="store",
+                       type="string", dest="sections_file",
+                       help="File containing figleaf sections coverage info.")
+
+    parser.add_option("-v", "--verbose", action="store_true",
+                      dest="verbose")
+
+    conf_file = ConfigParser.ConfigParser()
+    conf_file.read(CONFIG_FILE)         # ignores if not present
+
+    default_coverage_file = safe_conf_get(conf_file,
+                                          'figleaf', 'coverage_file',
+                                          '.figleaf')
+    default_sections_file = safe_conf_get(conf_file,
+                                          'figleaf', 'sections_file',
+                                          '.figleaf_sections')
+    default_verbose = int(safe_conf_get(conf_file, 'figleaf', 'verbose',
+                                        0))
+
+    parser.set_defaults(coverage_file=default_coverage_file,
+                        sections_file=default_sections_file,
+                        verbose=default_verbose)
+
+def filter_coverage(coverage, re_match):
+    """
+    ...
+    """
+    if not re_match:
+        return coverage
+
+    regexp = re.compile(re_match)
+    
+    d = {}
+    for filename, lines in coverage.items():
+        if regexp.match(filename):
+            d[filename] = lines
+            
+    return d
+
+### commands
+
+def list(options, match=""):
+    """
+    List the filenames in the coverage file, optionally limiting it to
+    those files matching to the regexp 'match'.
+    """
+    if options.verbose:
+        print>>sys.stderr, '** Reading coverage from coverage file %s' % \
+                           (options.coverage_file,)
+        if match:
+            print>>sys.stderr, '** Filtering against regexp "%s"' % (match,)
+        
+    coverage = figleaf.read_coverage(options.coverage_file)
+    coverage = filter_coverage(coverage, match)
+
+    for filename in coverage.keys():
+        print filename
+
+def list_sections(options, match=""):
+    """
+    List the filenames in the coverage file, optionally limiting it to
+    those files matching to the regexp 'match'.
+    """
+    if options.verbose:
+        print>>sys.stderr, '** Reading sections info from sections file %s' % \
+                           (options.sections_file,)
+        if match:
+            print>>sys.stderr, '** Filtering against regexp "%s"' % (match,)
+
+    fp = open(options.sections_file)
+    figleaf.load_pickled_coverage(fp) # @CTB
+
+    data = figleaf.internals.CoverageData(figleaf._t)
+    coverage = data.gather_files()
+    coverage = filter_coverage(coverage, match)
+
+    for filename in coverage.keys():
+        print filename
+
+###
+
+def read_exclude_patterns(filename):
+    """
+    Read in exclusion patterns from a file; these are just regexps.
+    """
+    if not filename:
+        return []
+
+    exclude_patterns = []
+
+    fp = open(filename)
+    for line in fp:
+        line = line.rstrip()
+        if line and not line.startswith('#'):
+            pattern = re.compile(line)
+        exclude_patterns.append(pattern)
+
+    return exclude_patterns
+
+def read_files_list(filename):
+    """
+    Read in a list of files from a file; these are relative or absolute paths.
+    """
+    s = {}
+    for line in open(filename):
+        f = line.strip()
+        s[os.path.abspath(f)] = 1
+
+    return s
+
+def filter_files(filenames, exclude_patterns = [], files_list = {}):
+    files_list = dict(files_list)       # make copy
+
+    # list of files specified?
+    if files_list:
+        for filename in files_list.keys():
+            yield filename
+
+        filenames = [ os.path.abspath(x) for x in filenames ]
+        for filename in filenames:
+            try:
+                del files_list[filename]
+            except KeyError:
+                logger.info('SKIPPING %s -- not in files list' % (filename,))
+            
+        return
+
+    ### no files list given -- handle differently
+
+    for filename in filenames:
+        abspath = os.path.abspath(filename)
+        
+        # check to see if we match anything in the exclude_patterns list
+        skip = False
+        for pattern in exclude_patterns:
+            if pattern.search(filename):
+                logger.info('SKIPPING %s -- matches exclusion pattern' % \
+                            (filename,))
+                skip = True
+                break
+
+        if skip:
+            continue
+
+        # next, check to see if we're part of the figleaf package.
+        if thisdir in filename:
+            logger.debug('SKIPPING %s -- part of the figleaf package' % \
+                         (filename,))
+            continue
+
+        # also, check for <string> (source file from things like 'exec'):
+        if filename == '<string>':
+            continue
+
+        # miscellaneous other things: doctests
+        if filename.startswith('<doctest '):
+            continue
+
+        yield filename
+
+###
+
+def main():
+    parser = OptionParser()
+    configure(parser)
+    
+    options, args = parser.parse_args()
+
+    if not len(args):
+        print "ERROR: You must specify a command like 'list' or 'report'.  Use"
+        print "\n    %s -h\n" % (sys.argv[0],)
+        print "for help on commands and options."
+        sys.exit(-1)
+        
+    cmd = args.pop(0)
+
+    if cmd == 'list':
+        list(options, *args)
+    elif cmd == 'list_sections':
+        list_sections(options, *args)
+
+    sys.exit(0)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/figleaf/annotate_cover.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/figleaf/annotate_cover.py b/tools/bin/ext/figleaf/annotate_cover.py
new file mode 100644
index 0000000..ac72bfa
--- /dev/null
+++ b/tools/bin/ext/figleaf/annotate_cover.py
@@ -0,0 +1,159 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+import figleaf
+import os
+import re
+
+from annotate import read_exclude_patterns, filter_files, logger
+
+def report_as_cover(coverage, exclude_patterns=[], ):
+    ### now, output.
+
+    keys = coverage.keys()
+    info_dict = {}
+    
+    for k in filter_files(keys):
+        try:
+            pyfile = open(k, 'rU')
+            lines = figleaf.get_lines(pyfile)
+        except IOError:
+            logger.warning('CANNOT OPEN: %s' % k)
+            continue
+        except KeyboardInterrupt:
+            raise
+        except Exception, e:
+            logger.error('ERROR: file %s, exception %s' % (pyfile, str(e)))
+            continue
+
+        # ok, got all the info.  now annotate file ==> html.
+
+        covered = coverage[k]
+        pyfile = open(k)
+        (n_covered, n_lines, output) = make_cover_lines(lines, covered, pyfile)
+
+
+        try:
+            pcnt = n_covered * 100. / n_lines
+        except ZeroDivisionError:
+            pcnt = 100
+        info_dict[k] = (n_lines, n_covered, pcnt)
+
+        outfile = make_cover_filename(k)
+        try:
+            outfp = open(outfile, 'w')
+            outfp.write("\n".join(output))
+            outfp.write("\n")
+            outfp.close()
+        except IOError:
+            logger.warning('cannot open filename %s' % (outfile,))
+            continue
+
+        logger.info('reported on %s' % (outfile,))
+
+    ### print a summary, too.
+
+    info_dict_items = info_dict.items()
+
+    def sort_by_pcnt(a, b):
+        a = a[1][2]
+        b = b[1][2]
+
+        return -cmp(a,b)
+
+    info_dict_items.sort(sort_by_pcnt)
+
+    logger.info('reported on %d file(s) total\n' % len(info_dict))
+    return len(info_dict)
+
+def make_cover_lines(line_info, coverage_info, fp):
+    n_covered = n_lines = 0
+    output = []
+    
+    for i, line in enumerate(fp):
+        is_covered = False
+        is_line = False
+
+        i += 1
+
+        if i in coverage_info:
+            is_covered = True
+            prefix = '+'
+
+            n_covered += 1
+            n_lines += 1
+        elif i in line_info:
+            prefix = '-'
+            is_line = True
+
+            n_lines += 1
+        else:
+            prefix = '0'
+
+        line = line.rstrip()
+        output.append(prefix + ' ' + line)
+    
+    return (n_covered, n_lines, output)
+
+def make_cover_filename(orig):
+    return orig + '.cover'
+
+def main():
+    import sys
+    import logging
+    from optparse import OptionParser
+    
+    ###
+
+    option_parser = OptionParser()
+
+    option_parser.add_option('-x', '--exclude-patterns', action="store",
+                             dest="exclude_patterns_file",
+                             help="file containing regexp patterns to exclude")
+
+    option_parser.add_option('-q', '--quiet', action='store_true',
+                             dest='quiet',
+         help="file containig regexp patterns of files to exclude from report")
+    
+    option_parser.add_option('-D', '--debug', action='store_true',
+                             dest='debug',
+                             help='Show all debugging messages')
+
+    (options, args) = option_parser.parse_args()
+
+    if options.quiet:
+        logging.disable(logging.DEBUG)
+
+    if options.debug:
+        logger.setLevel(logging.DEBUG)
+
+    ### load
+
+    if not args:
+        args = ['.figleaf']
+
+    coverage = {}
+    for filename in args:
+        logger.debug("loading coverage info from '%s'\n" % (filename,))
+        d = figleaf.read_coverage(filename)
+        coverage = figleaf.combine_coverage(coverage, d)
+
+    if not coverage:
+        logger.warning('EXITING -- no coverage info!\n')
+        sys.exit(-1)
+
+    exclude = read_exclude_patterns(options.exclude_patterns_file)
+    report_as_cover(coverage, exclude)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/figleaf/annotate_html.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/figleaf/annotate_html.py b/tools/bin/ext/figleaf/annotate_html.py
new file mode 100644
index 0000000..594d07a
--- /dev/null
+++ b/tools/bin/ext/figleaf/annotate_html.py
@@ -0,0 +1,292 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+import figleaf
+import os
+import re
+
+# use builtin sets if in >= 2.4, otherwise use 'sets' module.
+try:
+    set()
+except NameError:
+    from sets import Set as set
+
+from figleaf.annotate import read_exclude_patterns, filter_files, logger, \
+     read_files_list
+
+###
+
+def annotate_file(fp, lines, covered):
+    # initialize
+    n_covered = n_lines = 0
+
+    output = []
+    for i, line in enumerate(fp):
+        is_covered = False
+        is_line = False
+
+        i += 1
+
+        if i in covered:
+            is_covered = True
+
+            n_covered += 1
+            n_lines += 1
+        elif i in lines:
+            is_line = True
+
+            n_lines += 1
+
+        color = 'black'
+        if is_covered:
+            color = 'green'
+        elif is_line:
+            color = 'red'
+
+        line = escape_html(line.rstrip())
+        output.append('<font color="%s">%4d. %s</font>' % (color, i, line))
+
+    try:
+        percent = n_covered * 100. / n_lines
+    except ZeroDivisionError:
+        percent = 100
+
+    return output, n_covered, n_lines, percent
+
+def write_html_summary(info_dict, directory):
+    info_dict_items = info_dict.items()
+
+    def sort_by_percent(a, b):
+        a = a[1][2]
+        b = b[1][2]
+
+        return -cmp(a,b)
+    info_dict_items.sort(sort_by_percent)
+
+    summary_lines = sum([ v[0] for (k, v) in info_dict_items])
+    summary_cover = sum([ v[1] for (k, v) in info_dict_items])
+
+    summary_percent = 100
+    if summary_lines:
+        summary_percent = float(summary_cover) * 100. / float(summary_lines)
+
+
+    percents = [ float(v[1]) * 100. / float(v[0])
+                 for (k, v) in info_dict_items if v[0] ]
+    
+    percent_90 = [ x for x in percents if x >= 90 ]
+    percent_75 = [ x for x in percents if x >= 75 ]
+    percent_50 = [ x for x in percents if x >= 50 ]
+
+    ### write out summary.
+
+    index_fp = open('%s/index.html' % (directory,), 'w')
+    index_fp.write('''
+<html>
+<title>figleaf code coverage report</title>
+<h2>Summary</h2>
+%d files total: %d files &gt; 90%%, %d files &gt; 75%%, %d files &gt; 50%%
+<p>
+<table border=1>
+<tr>
+ <th>Filename</th><th># lines</th><th># covered</th><th>%% covered</th>
+</tr>
+
+<tr>
+ <td><b>totals:</b></td>
+ <td><b>%d</b></td>
+ <td><b>%d</b></td>
+ <td><b>%.1f%%</b></td>
+</tr>
+
+<tr></tr>
+
+''' % (len(percents), len(percent_90), len(percent_75), len(percent_50),
+       summary_lines, summary_cover, summary_percent,))
+
+    for filename, (n_lines, n_covered, percent_covered,) in info_dict_items:
+        html_outfile = make_html_filename(filename)
+
+        index_fp.write('''
+<tr>
+ <td><a href="./%s">%s</a></td>
+ <td>%d</td>
+ <td>%d</td>
+ <td>%.1f</td>
+</tr>
+''' % (html_outfile, filename, n_lines, n_covered, percent_covered,))
+
+    index_fp.write('</table>\n')
+    index_fp.close()
+    
+
+def report_as_html(coverage, directory, exclude_patterns, files_list):
+    """
+    Write an HTML report on all of the files, plus a summary.
+    """
+
+    ### now, output.
+
+    keys = coverage.keys()
+    info_dict = {}
+    for pyfile in filter_files(keys, exclude_patterns, files_list):
+
+        try:
+            fp = open(pyfile, 'rU')
+            lines = figleaf.get_lines(fp)
+        except KeyboardInterrupt:
+            raise
+        except IOError:
+            logger.error('CANNOT OPEN: %s' % (pyfile,))
+            continue
+        except Exception, e:
+            logger.error('ERROR: file %s, exception %s' % (pyfile, str(e)))
+            continue
+
+        #
+        # ok, we want to annotate this file.  now annotate file ==> html.
+        #
+
+        # initialize
+        covered = coverage.get(pyfile, set())
+
+        # rewind
+        fp.seek(0)
+
+        # annotate
+        output, n_covered, n_lines, percent = annotate_file(fp, lines, covered)
+
+        # summarize
+        info_dict[pyfile] = (n_lines, n_covered, percent)
+
+        # write out the file
+        html_outfile = make_html_filename(pyfile)
+        html_outfile = os.path.join(directory, html_outfile)
+        html_outfp = open(html_outfile, 'w')
+        
+        html_outfp.write('source file: <b>%s</b><br>\n' % (pyfile,))
+        html_outfp.write('''
+
+file stats: <b>%d lines, %d executed: %.1f%% covered</b>
+<pre>
+%s
+</pre>
+
+''' % (n_lines, n_covered, percent, "\n".join(output)))
+            
+        html_outfp.close()
+
+        logger.info('reported on %s' % (pyfile,))
+
+    ### print a summary, too.
+    write_html_summary(info_dict, directory)
+
+    logger.info('reported on %d file(s) total\n' % len(info_dict))
+
+def prepare_reportdir(dirname):
+    "Create output directory."
+    try:
+        os.mkdir(dirname)
+    except OSError:                         # already exists
+        pass
+
+def make_html_filename(orig):
+    "'escape' original paths into a single filename"
+
+    orig = os.path.abspath(orig)
+#    orig = os.path.basename(orig)
+    orig = os.path.splitdrive(orig)[1]
+    orig = orig.replace('_', '__')
+    orig = orig.replace(os.path.sep, '_')
+    orig += '.html'
+    return orig
+
+def escape_html(s):
+    s = s.replace("&", "&amp;")
+    s = s.replace("<", "&lt;")
+    s = s.replace(">", "&gt;")
+    s = s.replace('"', "&quot;")
+    return s
+
+def main():
+    import sys
+    import logging
+    from optparse import OptionParser
+    ###
+
+    usage = "usage: %prog [options] [coverage files ... ]"
+    option_parser = OptionParser(usage=usage)
+
+    option_parser.add_option('-x', '--exclude-patterns', action="store",
+                             dest="exclude_patterns_file",
+        help="file containing regexp patterns of files to exclude from report")
+
+    option_parser.add_option('-f', '--files-list', action="store",
+                             dest="files_list",
+                             help="file containing filenames to report on")
+
+    option_parser.add_option('-d', '--output-directory', action='store',
+                             dest="output_dir",
+                             default = "html",
+                             help="directory for HTML output")
+
+    option_parser.add_option('-q', '--quiet', action='store_true',
+                             dest='quiet',
+                             help='Suppress all but error messages')
+    
+    option_parser.add_option('-D', '--debug', action='store_true',
+                             dest='debug',
+                             help='Show all debugging messages')
+
+    (options, args) = option_parser.parse_args()
+
+    if options.quiet:
+        logging.disable(logging.DEBUG)
+        
+    if options.debug:
+        logger.setLevel(logging.DEBUG)
+
+    ### load/combine
+
+    if not args:
+        args = ['.figleaf']
+
+    coverage = {}
+    for filename in args:
+        logger.debug("loading coverage info from '%s'\n" % (filename,))
+        try:
+            d = figleaf.read_coverage(filename)
+            coverage = figleaf.combine_coverage(coverage, d)
+        except IOError:
+            logger.error("cannot open filename '%s'\n" % (filename,))
+
+    if not coverage:
+        logger.warning('EXITING -- no coverage info!\n')
+        sys.exit(-1)
+
+    exclude = []
+    if options.exclude_patterns_file:
+        exclude = read_exclude_patterns(options.exclude_patterns_file)
+
+    files_list = {}
+    if options.files_list:
+        files_list = read_files_list(options.files_list)
+
+    ### make directory
+    prepare_reportdir(options.output_dir)
+    report_as_html(coverage, options.output_dir, exclude, files_list)
+
+    print 'figleaf: HTML output written to %s' % (options.output_dir,)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/figleaf/annotate_sections.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/figleaf/annotate_sections.py b/tools/bin/ext/figleaf/annotate_sections.py
new file mode 100644
index 0000000..6d7fb89
--- /dev/null
+++ b/tools/bin/ext/figleaf/annotate_sections.py
@@ -0,0 +1,95 @@
+#! /usr/bin/env python
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+import figleaf
+from figleaf import internals
+from sets import Set as set
+import sys
+from cPickle import load
+import os
+from optparse import OptionParser
+
+def main():
+    #### OPTIONS
+
+    parser = OptionParser()
+
+    parser.add_option('-c', '--coverage', nargs=1, action="store",
+                      dest="coverage_file", 
+                      help = 'load coverage info from this file',
+                      default='.figleaf_sections')
+
+    ####
+
+    (options, args) = parser.parse_args(sys.argv[1:])
+    coverage_file = options.coverage_file
+    
+    figleaf.load_pickled_coverage(open(coverage_file))
+    data = internals.CoverageData(figleaf._t)
+    full_cov = data.gather_files()
+
+    for filename in args:
+        annotate_file_with_sections(filename, data, full_cov)
+
+def annotate_file_with_sections(short, data, full_cov):
+    full = os.path.abspath(short)
+
+    tags = {}
+    sections = data.gather_sections(full)
+    sections.update(data.gather_sections(short))
+
+    print data.sections
+
+    print '*** PROCESSING:', short, '\n\t==>', short + '.sections'
+    for tag, cov in sections.items():
+        if cov:
+            tags[tag] = cov
+
+    if not tags:
+        print '*** No coverage info for file', short
+
+    tag_names = tags.keys()
+    tag_names.sort()
+    tag_names.reverse()
+
+    tags["-- all coverage --"] = full_cov.get(full, set())
+    tag_names.insert(0, "-- all coverage --")
+
+    n_tags = len(tag_names)
+    
+    fp = open(short + '.sections', 'w')
+
+    for i, tag in enumerate(tag_names):
+        fp.write('%s%s\n' % ('| ' * i, tag))
+    fp.write('| ' * n_tags)
+    fp.write('\n\n')
+
+    source = open(full)
+    for n, line in enumerate(source):
+        marks = ""
+        for tag in tag_names:
+            cov = tags[tag]
+
+            symbol = '  '
+            if (n+1) in cov:
+                symbol = '+ '
+
+            marks += symbol
+
+        fp.write('%s  | %s' % (marks, line))
+    
+    fp.close()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/figleaf/figleaf2html
----------------------------------------------------------------------
diff --git a/tools/bin/ext/figleaf/figleaf2html b/tools/bin/ext/figleaf/figleaf2html
new file mode 100755
index 0000000..58636b0
--- /dev/null
+++ b/tools/bin/ext/figleaf/figleaf2html
@@ -0,0 +1,7 @@
+#! /usr/bin/env python
+"""
+Output an HTML-ized coverage report.
+"""
+import _lib
+import figleaf.annotate_html
+figleaf.annotate_html.main()


[04/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code

Posted by rl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/case.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/case.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/case.py
new file mode 100644
index 0000000..105914b
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/case.py
@@ -0,0 +1,1084 @@
+"""Test case implementation"""
+
+import sys
+import difflib
+import pprint
+import re
+import unittest
+import warnings
+
+from unittest2 import result
+from unittest2.util import (
+    safe_repr, safe_str, strclass,
+    unorderable_list_difference
+)
+
+from unittest2.compatibility import wraps
+
+__unittest = True
+
+
+DIFF_OMITTED = ('\nDiff is %s characters long. '
+                 'Set self.maxDiff to None to see it.')
+
+class SkipTest(Exception):
+    """
+    Raise this exception in a test to skip it.
+
+    Usually you can use TestResult.skip() or one of the skipping decorators
+    instead of raising this directly.
+    """
+
+class _ExpectedFailure(Exception):
+    """
+    Raise this when a test is expected to fail.
+
+    This is an implementation detail.
+    """
+
+    def __init__(self, exc_info):
+        # can't use super because Python 2.4 exceptions are old style
+        Exception.__init__(self)
+        self.exc_info = exc_info
+
+class _UnexpectedSuccess(Exception):
+    """
+    The test was supposed to fail, but it didn't!
+    """
+
+def _id(obj):
+    return obj
+
+def skip(reason):
+    """
+    Unconditionally skip a test.
+    """
+    def decorator(test_item):
+        if not (isinstance(test_item, type) and issubclass(test_item, TestCase)):
+            @wraps(test_item)
+            def skip_wrapper(*args, **kwargs):
+                raise SkipTest(reason)
+            test_item = skip_wrapper
+        
+        test_item.__unittest_skip__ = True
+        test_item.__unittest_skip_why__ = reason
+        return test_item
+    return decorator
+
+def skipIf(condition, reason):
+    """
+    Skip a test if the condition is true.
+    """
+    if condition:
+        return skip(reason)
+    return _id
+
+def skipUnless(condition, reason):
+    """
+    Skip a test unless the condition is true.
+    """
+    if not condition:
+        return skip(reason)
+    return _id
+
+
+def expectedFailure(func):
+    @wraps(func)
+    def wrapper(*args, **kwargs):
+        try:
+            func(*args, **kwargs)
+        except Exception:
+            raise _ExpectedFailure(sys.exc_info())
+        raise _UnexpectedSuccess
+    return wrapper
+
+
+class _AssertRaisesContext(object):
+    """A context manager used to implement TestCase.assertRaises* methods."""
+
+    def __init__(self, expected, test_case, expected_regexp=None):
+        self.expected = expected
+        self.failureException = test_case.failureException
+        self.expected_regexp = expected_regexp
+
+    def __enter__(self):
+        return self
+
+    def __exit__(self, exc_type, exc_value, tb):
+        if exc_type is None:
+            try:
+                exc_name = self.expected.__name__
+            except AttributeError:
+                exc_name = str(self.expected)
+            raise self.failureException(
+                "%s not raised" % (exc_name,))
+        if not issubclass(exc_type, self.expected):
+            # let unexpected exceptions pass through
+            return False
+        self.exception = exc_value # store for later retrieval
+        if self.expected_regexp is None:
+            return True
+
+        expected_regexp = self.expected_regexp
+        if isinstance(expected_regexp, basestring):
+            expected_regexp = re.compile(expected_regexp)
+        if not expected_regexp.search(str(exc_value)):
+            raise self.failureException('"%s" does not match "%s"' %
+                     (expected_regexp.pattern, str(exc_value)))
+        return True
+
+
+class _TypeEqualityDict(object):
+    
+    def __init__(self, testcase):
+        self.testcase = testcase
+        self._store = {}
+    
+    def __setitem__(self, key, value):
+        self._store[key] = value
+    
+    def __getitem__(self, key):
+        value = self._store[key]
+        if isinstance(value, basestring):
+            return getattr(self.testcase, value)
+        return value
+    
+    def get(self, key, default=None):
+        if key in self._store:
+            return self[key]
+        return default
+
+
+class TestCase(unittest.TestCase):
+    """A class whose instances are single test cases.
+
+    By default, the test code itself should be placed in a method named
+    'runTest'.
+
+    If the fixture may be used for many test cases, create as
+    many test methods as are needed. When instantiating such a TestCase
+    subclass, specify in the constructor arguments the name of the test method
+    that the instance is to execute.
+
+    Test authors should subclass TestCase for their own tests. Construction
+    and deconstruction of the test's environment ('fixture') can be
+    implemented by overriding the 'setUp' and 'tearDown' methods respectively.
+
+    If it is necessary to override the __init__ method, the base class
+    __init__ method must always be called. It is important that subclasses
+    should not change the signature of their __init__ method, since instances
+    of the classes are instantiated automatically by parts of the framework
+    in order to be run.
+    """
+
+    # This attribute determines which exception will be raised when
+    # the instance's assertion methods fail; test methods raising this
+    # exception will be deemed to have 'failed' rather than 'errored'
+
+    failureException = AssertionError
+
+    # This attribute sets the maximum length of a diff in failure messages
+    # by assert methods using difflib. It is looked up as an instance attribute
+    # so can be configured by individual tests if required.
+
+    maxDiff = 80*8
+
+    # This attribute determines whether long messages (including repr of
+    # objects used in assert methods) will be printed on failure in *addition*
+    # to any explicit message passed.
+
+    longMessage = True
+    
+    # Attribute used by TestSuite for classSetUp
+    
+    _classSetupFailed = False
+
+    def __init__(self, methodName='runTest'):
+        """Create an instance of the class that will use the named test
+           method when executed. Raises a ValueError if the instance does
+           not have a method with the specified name.
+        """
+        self._testMethodName = methodName
+        self._resultForDoCleanups = None
+        try:
+            testMethod = getattr(self, methodName)
+        except AttributeError:
+            raise ValueError("no such test method in %s: %s" % \
+                  (self.__class__, methodName))
+        self._testMethodDoc = testMethod.__doc__
+        self._cleanups = []
+
+        # Map types to custom assertEqual functions that will compare
+        # instances of said type in more detail to generate a more useful
+        # error message.
+        self._type_equality_funcs = _TypeEqualityDict(self)
+        self.addTypeEqualityFunc(dict, 'assertDictEqual')
+        self.addTypeEqualityFunc(list, 'assertListEqual')
+        self.addTypeEqualityFunc(tuple, 'assertTupleEqual')
+        self.addTypeEqualityFunc(set, 'assertSetEqual')
+        self.addTypeEqualityFunc(frozenset, 'assertSetEqual')
+        self.addTypeEqualityFunc(unicode, 'assertMultiLineEqual')
+
+    def addTypeEqualityFunc(self, typeobj, function):
+        """Add a type specific assertEqual style function to compare a type.
+
+        This method is for use by TestCase subclasses that need to register
+        their own type equality functions to provide nicer error messages.
+
+        Args:
+            typeobj: The data type to call this function on when both values
+                    are of the same type in assertEqual().
+            function: The callable taking two arguments and an optional
+                    msg= argument that raises self.failureException with a
+                    useful error message when the two arguments are not equal.
+        """
+        self._type_equality_funcs[typeobj] = function
+
+    def addCleanup(self, function, *args, **kwargs):
+        """Add a function, with arguments, to be called when the test is
+        completed. Functions added are called on a LIFO basis and are
+        called after tearDown on test failure or success.
+
+        Cleanup items are called even if setUp fails (unlike tearDown)."""
+        self._cleanups.append((function, args, kwargs))
+
+    def setUp(self):
+        "Hook method for setting up the test fixture before exercising it."
+    
+    @classmethod
+    def setUpClass(cls):
+        "Hook method for setting up class fixture before running tests in the class."
+
+    @classmethod
+    def tearDownClass(cls):
+        "Hook method for deconstructing the class fixture after running all tests in the class."
+
+    def tearDown(self):
+        "Hook method for deconstructing the test fixture after testing it."
+
+    def countTestCases(self):
+        return 1
+
+    def defaultTestResult(self):
+        return result.TestResult()
+
+    def shortDescription(self):
+        """Returns a one-line description of the test, or None if no
+        description has been provided.
+
+        The default implementation of this method returns the first line of
+        the specified test method's docstring.
+        """
+        doc = self._testMethodDoc
+        return doc and doc.split("\n")[0].strip() or None
+
+
+    def id(self):
+        return "%s.%s" % (strclass(self.__class__), self._testMethodName)
+
+    def __eq__(self, other):
+        if type(self) is not type(other):
+            return NotImplemented
+
+        return self._testMethodName == other._testMethodName
+
+    def __ne__(self, other):
+        return not self == other
+
+    def __hash__(self):
+        return hash((type(self), self._testMethodName))
+
+    def __str__(self):
+        return "%s (%s)" % (self._testMethodName, strclass(self.__class__))
+
+    def __repr__(self):
+        return "<%s testMethod=%s>" % \
+               (strclass(self.__class__), self._testMethodName)
+    
+    def _addSkip(self, result, reason):
+        addSkip = getattr(result, 'addSkip', None)
+        if addSkip is not None:
+            addSkip(self, reason)
+        else:
+            warnings.warn("Use of a TestResult without an addSkip method is deprecated", 
+                          DeprecationWarning, 2)
+            result.addSuccess(self)
+
+    def run(self, result=None):
+        orig_result = result
+        if result is None:
+            result = self.defaultTestResult()
+            startTestRun = getattr(result, 'startTestRun', None)
+            if startTestRun is not None:
+                startTestRun()
+
+        self._resultForDoCleanups = result
+        result.startTest(self)
+        
+        testMethod = getattr(self, self._testMethodName)
+        
+        if (getattr(self.__class__, "__unittest_skip__", False) or 
+            getattr(testMethod, "__unittest_skip__", False)):
+            # If the class or method was skipped.
+            try:
+                skip_why = (getattr(self.__class__, '__unittest_skip_why__', '')
+                            or getattr(testMethod, '__unittest_skip_why__', ''))
+                self._addSkip(result, skip_why)
+            finally:
+                result.stopTest(self)
+            return
+        try:
+            success = False
+            try:
+                self.setUp()
+            except SkipTest, e:
+                self._addSkip(result, str(e))
+            except Exception:
+                result.addError(self, sys.exc_info())
+            else:
+                try:
+                    testMethod()
+                except self.failureException:
+                    result.addFailure(self, sys.exc_info())
+                except _ExpectedFailure, e:
+                    addExpectedFailure = getattr(result, 'addExpectedFailure', None)
+                    if addExpectedFailure is not None:
+                        addExpectedFailure(self, e.exc_info)
+                    else: 
+                        warnings.warn("Use of a TestResult without an addExpectedFailure method is deprecated", 
+                                      DeprecationWarning)
+                        result.addSuccess(self)
+                except _UnexpectedSuccess:
+                    addUnexpectedSuccess = getattr(result, 'addUnexpectedSuccess', None)
+                    if addUnexpectedSuccess is not None:
+                        addUnexpectedSuccess(self)
+                    else:
+                        warnings.warn("Use of a TestResult without an addUnexpectedSuccess method is deprecated", 
+                                      DeprecationWarning)
+                        result.addFailure(self, sys.exc_info())
+                except SkipTest, e:
+                    self._addSkip(result, str(e))
+                except Exception:
+                    result.addError(self, sys.exc_info())
+                else:
+                    success = True
+
+                try:
+                    self.tearDown()
+                except Exception:
+                    result.addError(self, sys.exc_info())
+                    success = False
+
+            cleanUpSuccess = self.doCleanups()
+            success = success and cleanUpSuccess
+            if success:
+                result.addSuccess(self)
+        finally:
+            result.stopTest(self)
+            if orig_result is None:
+                stopTestRun = getattr(result, 'stopTestRun', None)
+                if stopTestRun is not None:
+                    stopTestRun()
+
+    def doCleanups(self):
+        """Execute all cleanup functions. Normally called for you after
+        tearDown."""
+        result = self._resultForDoCleanups
+        ok = True
+        while self._cleanups:
+            function, args, kwargs = self._cleanups.pop(-1)
+            try:
+                function(*args, **kwargs)
+            except Exception:
+                ok = False
+                result.addError(self, sys.exc_info())
+        return ok
+
+    def __call__(self, *args, **kwds):
+        return self.run(*args, **kwds)
+
+    def debug(self):
+        """Run the test without collecting errors in a TestResult"""
+        self.setUp()
+        getattr(self, self._testMethodName)()
+        self.tearDown()
+        while self._cleanups:
+            function, args, kwargs = self._cleanups.pop(-1)
+            function(*args, **kwargs)
+
+    def skipTest(self, reason):
+        """Skip this test."""
+        raise SkipTest(reason)
+
+    def fail(self, msg=None):
+        """Fail immediately, with the given message."""
+        raise self.failureException(msg)
+
+    def assertFalse(self, expr, msg=None):
+        "Fail the test if the expression is true."
+        if expr:
+            msg = self._formatMessage(msg, "%s is not False" % safe_repr(expr))
+            raise self.failureException(msg)
+
+    def assertTrue(self, expr, msg=None):
+        """Fail the test unless the expression is true."""
+        if not expr:
+            msg = self._formatMessage(msg, "%s is not True" % safe_repr(expr))
+            raise self.failureException(msg)
+
+    def _formatMessage(self, msg, standardMsg):
+        """Honour the longMessage attribute when generating failure messages.
+        If longMessage is False this means:
+        * Use only an explicit message if it is provided
+        * Otherwise use the standard message for the assert
+
+        If longMessage is True:
+        * Use the standard message
+        * If an explicit message is provided, plus ' : ' and the explicit message
+        """
+        if not self.longMessage:
+            return msg or standardMsg
+        if msg is None:
+            return standardMsg
+        try:
+            return '%s : %s' % (standardMsg, msg)
+        except UnicodeDecodeError:
+            return '%s : %s' % (safe_str(standardMsg), safe_str(msg))
+
+
+    def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
+        """Fail unless an exception of class excClass is thrown
+           by callableObj when invoked with arguments args and keyword
+           arguments kwargs. If a different type of exception is
+           thrown, it will not be caught, and the test case will be
+           deemed to have suffered an error, exactly as for an
+           unexpected exception.
+
+           If called with callableObj omitted or None, will return a
+           context object used like this::
+
+                with self.assertRaises(SomeException):
+                    do_something()
+
+           The context manager keeps a reference to the exception as
+           the 'exception' attribute. This allows you to inspect the
+           exception after the assertion::
+
+               with self.assertRaises(SomeException) as cm:
+                   do_something()
+               the_exception = cm.exception
+               self.assertEqual(the_exception.error_code, 3)
+        """
+        if callableObj is None:
+            return _AssertRaisesContext(excClass, self)
+        try:
+            callableObj(*args, **kwargs)
+        except excClass:
+            return
+        
+        if hasattr(excClass,'__name__'):
+            excName = excClass.__name__
+        else:
+            excName = str(excClass)
+        raise self.failureException, "%s not raised" % excName
+
+    def _getAssertEqualityFunc(self, first, second):
+        """Get a detailed comparison function for the types of the two args.
+
+        Returns: A callable accepting (first, second, msg=None) that will
+        raise a failure exception if first != second with a useful human
+        readable error message for those types.
+        """
+        #
+        # NOTE(gregory.p.smith): I considered isinstance(first, type(second))
+        # and vice versa.  I opted for the conservative approach in case
+        # subclasses are not intended to be compared in detail to their super
+        # class instances using a type equality func.  This means testing
+        # subtypes won't automagically use the detailed comparison.  Callers
+        # should use their type specific assertSpamEqual method to compare
+        # subclasses if the detailed comparison is desired and appropriate.
+        # See the discussion in http://bugs.python.org/issue2578.
+        #
+        if type(first) is type(second):
+            asserter = self._type_equality_funcs.get(type(first))
+            if asserter is not None:
+                return asserter
+
+        return self._baseAssertEqual
+
+    def _baseAssertEqual(self, first, second, msg=None):
+        """The default assertEqual implementation, not type specific."""
+        if not first == second:
+            standardMsg = '%s != %s' % (safe_repr(first), safe_repr(second))
+            msg = self._formatMessage(msg, standardMsg)
+            raise self.failureException(msg)
+
+    def assertEqual(self, first, second, msg=None):
+        """Fail if the two objects are unequal as determined by the '=='
+           operator.
+        """
+        assertion_func = self._getAssertEqualityFunc(first, second)
+        assertion_func(first, second, msg=msg)
+
+    def assertNotEqual(self, first, second, msg=None):
+        """Fail if the two objects are equal as determined by the '=='
+           operator.
+        """
+        if not first != second:
+            msg = self._formatMessage(msg, '%s == %s' % (safe_repr(first), 
+                                                           safe_repr(second)))
+            raise self.failureException(msg)
+
+    def assertAlmostEqual(self, first, second, places=None, msg=None, delta=None):
+        """Fail if the two objects are unequal as determined by their
+           difference rounded to the given number of decimal places
+           (default 7) and comparing to zero, or by comparing that the
+           between the two objects is more than the given delta.
+
+           Note that decimal places (from zero) are usually not the same
+           as significant digits (measured from the most signficant digit).
+
+           If the two objects compare equal then they will automatically
+           compare almost equal.
+        """
+        if first == second:
+            # shortcut
+            return
+        if delta is not None and places is not None:
+            raise TypeError("specify delta or places not both")
+        
+        if delta is not None:
+            if abs(first - second) <= delta:
+                return
+        
+            standardMsg = '%s != %s within %s delta' % (safe_repr(first), 
+                                                        safe_repr(second), 
+                                                        safe_repr(delta))
+        else:
+            if places is None:
+                places = 7
+                
+            if round(abs(second-first), places) == 0:
+                return
+        
+            standardMsg = '%s != %s within %r places' % (safe_repr(first), 
+                                                          safe_repr(second), 
+                                                          places)
+        msg = self._formatMessage(msg, standardMsg)
+        raise self.failureException(msg)
+
+    def assertNotAlmostEqual(self, first, second, places=None, msg=None, delta=None):
+        """Fail if the two objects are equal as determined by their
+           difference rounded to the given number of decimal places
+           (default 7) and comparing to zero, or by comparing that the
+           between the two objects is less than the given delta.
+
+           Note that decimal places (from zero) are usually not the same
+           as significant digits (measured from the most signficant digit).
+
+           Objects that are equal automatically fail.
+        """
+        if delta is not None and places is not None:
+            raise TypeError("specify delta or places not both")
+        if delta is not None:
+            if not (first == second) and abs(first - second) > delta:
+                return
+            standardMsg = '%s == %s within %s delta' % (safe_repr(first), 
+                                                        safe_repr(second),
+                                                        safe_repr(delta))
+        else:
+            if places is None:
+                places = 7
+            if not (first == second) and round(abs(second-first), places) != 0:
+                return
+            standardMsg = '%s == %s within %r places' % (safe_repr(first), 
+                                                         safe_repr(second),
+                                                         places)
+
+        msg = self._formatMessage(msg, standardMsg)
+        raise self.failureException(msg)
+
+    # Synonyms for assertion methods
+
+    # The plurals are undocumented.  Keep them that way to discourage use.
+    # Do not add more.  Do not remove.
+    # Going through a deprecation cycle on these would annoy many people.
+    assertEquals = assertEqual
+    assertNotEquals = assertNotEqual
+    assertAlmostEquals = assertAlmostEqual
+    assertNotAlmostEquals = assertNotAlmostEqual
+    assert_ = assertTrue
+
+    # These fail* assertion method names are pending deprecation and will
+    # be a DeprecationWarning in 3.2; http://bugs.python.org/issue2578
+    def _deprecate(original_func):
+        def deprecated_func(*args, **kwargs):
+            warnings.warn(
+                ('Please use %s instead.' % original_func.__name__),
+                PendingDeprecationWarning, 2)
+            return original_func(*args, **kwargs)
+        return deprecated_func
+
+    failUnlessEqual = _deprecate(assertEqual)
+    failIfEqual = _deprecate(assertNotEqual)
+    failUnlessAlmostEqual = _deprecate(assertAlmostEqual)
+    failIfAlmostEqual = _deprecate(assertNotAlmostEqual)
+    failUnless = _deprecate(assertTrue)
+    failUnlessRaises = _deprecate(assertRaises)
+    failIf = _deprecate(assertFalse)
+
+    def assertSequenceEqual(self, seq1, seq2,
+                            msg=None, seq_type=None, max_diff=80*8):
+        """An equality assertion for ordered sequences (like lists and tuples).
+
+        For the purposes of this function, a valid ordered sequence type is one
+        which can be indexed, has a length, and has an equality operator.
+
+        Args:
+            seq1: The first sequence to compare.
+            seq2: The second sequence to compare.
+            seq_type: The expected datatype of the sequences, or None if no
+                    datatype should be enforced.
+            msg: Optional message to use on failure instead of a list of
+                    differences.
+            max_diff: Maximum size off the diff, larger diffs are not shown
+        """
+        if seq_type is not None:
+            seq_type_name = seq_type.__name__
+            if not isinstance(seq1, seq_type):
+                raise self.failureException('First sequence is not a %s: %s'
+                                            % (seq_type_name, safe_repr(seq1)))
+            if not isinstance(seq2, seq_type):
+                raise self.failureException('Second sequence is not a %s: %s'
+                                            % (seq_type_name, safe_repr(seq2)))
+        else:
+            seq_type_name = "sequence"
+
+        differing = None
+        try:
+            len1 = len(seq1)
+        except (TypeError, NotImplementedError):
+            differing = 'First %s has no length.    Non-sequence?' % (
+                    seq_type_name)
+
+        if differing is None:
+            try:
+                len2 = len(seq2)
+            except (TypeError, NotImplementedError):
+                differing = 'Second %s has no length.    Non-sequence?' % (
+                        seq_type_name)
+
+        if differing is None:
+            if seq1 == seq2:
+                return
+
+            seq1_repr = repr(seq1)
+            seq2_repr = repr(seq2)
+            if len(seq1_repr) > 30:
+                seq1_repr = seq1_repr[:30] + '...'
+            if len(seq2_repr) > 30:
+                seq2_repr = seq2_repr[:30] + '...'
+            elements = (seq_type_name.capitalize(), seq1_repr, seq2_repr)
+            differing = '%ss differ: %s != %s\n' % elements
+
+            for i in xrange(min(len1, len2)):
+                try:
+                    item1 = seq1[i]
+                except (TypeError, IndexError, NotImplementedError):
+                    differing += ('\nUnable to index element %d of first %s\n' %
+                                 (i, seq_type_name))
+                    break
+
+                try:
+                    item2 = seq2[i]
+                except (TypeError, IndexError, NotImplementedError):
+                    differing += ('\nUnable to index element %d of second %s\n' %
+                                 (i, seq_type_name))
+                    break
+
+                if item1 != item2:
+                    differing += ('\nFirst differing element %d:\n%s\n%s\n' %
+                                 (i, item1, item2))
+                    break
+            else:
+                if (len1 == len2 and seq_type is None and
+                    type(seq1) != type(seq2)):
+                    # The sequences are the same, but have differing types.
+                    return
+
+            if len1 > len2:
+                differing += ('\nFirst %s contains %d additional '
+                             'elements.\n' % (seq_type_name, len1 - len2))
+                try:
+                    differing += ('First extra element %d:\n%s\n' %
+                                  (len2, seq1[len2]))
+                except (TypeError, IndexError, NotImplementedError):
+                    differing += ('Unable to index element %d '
+                                  'of first %s\n' % (len2, seq_type_name))
+            elif len1 < len2:
+                differing += ('\nSecond %s contains %d additional '
+                             'elements.\n' % (seq_type_name, len2 - len1))
+                try:
+                    differing += ('First extra element %d:\n%s\n' %
+                                  (len1, seq2[len1]))
+                except (TypeError, IndexError, NotImplementedError):
+                    differing += ('Unable to index element %d '
+                                  'of second %s\n' % (len1, seq_type_name))
+        standardMsg = differing
+        diffMsg = '\n' + '\n'.join(
+            difflib.ndiff(pprint.pformat(seq1).splitlines(),
+                          pprint.pformat(seq2).splitlines()))
+
+        standardMsg = self._truncateMessage(standardMsg, diffMsg)
+        msg = self._formatMessage(msg, standardMsg)
+        self.fail(msg)
+
+    def _truncateMessage(self, message, diff):
+        max_diff = self.maxDiff
+        if max_diff is None or len(diff) <= max_diff:
+            return message + diff
+        return message + (DIFF_OMITTED % len(diff))
+
+    def assertListEqual(self, list1, list2, msg=None):
+        """A list-specific equality assertion.
+
+        Args:
+            list1: The first list to compare.
+            list2: The second list to compare.
+            msg: Optional message to use on failure instead of a list of
+                    differences.
+
+        """
+        self.assertSequenceEqual(list1, list2, msg, seq_type=list)
+
+    def assertTupleEqual(self, tuple1, tuple2, msg=None):
+        """A tuple-specific equality assertion.
+
+        Args:
+            tuple1: The first tuple to compare.
+            tuple2: The second tuple to compare.
+            msg: Optional message to use on failure instead of a list of
+                    differences.
+        """
+        self.assertSequenceEqual(tuple1, tuple2, msg, seq_type=tuple)
+
+    def assertSetEqual(self, set1, set2, msg=None):
+        """A set-specific equality assertion.
+
+        Args:
+            set1: The first set to compare.
+            set2: The second set to compare.
+            msg: Optional message to use on failure instead of a list of
+                    differences.
+
+        assertSetEqual uses ducktyping to support
+        different types of sets, and is optimized for sets specifically
+        (parameters must support a difference method).
+        """
+        try:
+            difference1 = set1.difference(set2)
+        except TypeError, e:
+            self.fail('invalid type when attempting set difference: %s' % e)
+        except AttributeError, e:
+            self.fail('first argument does not support set difference: %s' % e)
+
+        try:
+            difference2 = set2.difference(set1)
+        except TypeError, e:
+            self.fail('invalid type when attempting set difference: %s' % e)
+        except AttributeError, e:
+            self.fail('second argument does not support set difference: %s' % e)
+
+        if not (difference1 or difference2):
+            return
+
+        lines = []
+        if difference1:
+            lines.append('Items in the first set but not the second:')
+            for item in difference1:
+                lines.append(repr(item))
+        if difference2:
+            lines.append('Items in the second set but not the first:')
+            for item in difference2:
+                lines.append(repr(item))
+
+        standardMsg = '\n'.join(lines)
+        self.fail(self._formatMessage(msg, standardMsg))
+
+    def assertIn(self, member, container, msg=None):
+        """Just like self.assertTrue(a in b), but with a nicer default message."""
+        if member not in container:
+            standardMsg = '%s not found in %s' % (safe_repr(member), 
+                                                   safe_repr(container))
+            self.fail(self._formatMessage(msg, standardMsg))
+
+    def assertNotIn(self, member, container, msg=None):
+        """Just like self.assertTrue(a not in b), but with a nicer default message."""
+        if member in container:
+            standardMsg = '%s unexpectedly found in %s' % (safe_repr(member), 
+                                                            safe_repr(container))
+            self.fail(self._formatMessage(msg, standardMsg))
+
+    def assertIs(self, expr1, expr2, msg=None):
+        """Just like self.assertTrue(a is b), but with a nicer default message."""
+        if expr1 is not expr2:
+            standardMsg = '%s is not %s' % (safe_repr(expr1), safe_repr(expr2))
+            self.fail(self._formatMessage(msg, standardMsg))
+
+    def assertIsNot(self, expr1, expr2, msg=None):
+        """Just like self.assertTrue(a is not b), but with a nicer default message."""
+        if expr1 is expr2:
+            standardMsg = 'unexpectedly identical: %s' % (safe_repr(expr1),)
+            self.fail(self._formatMessage(msg, standardMsg))
+
+    def assertDictEqual(self, d1, d2, msg=None):
+        self.assert_(isinstance(d1, dict), 'First argument is not a dictionary')
+        self.assert_(isinstance(d2, dict), 'Second argument is not a dictionary')
+
+        if d1 != d2:
+            standardMsg = '%s != %s' % (safe_repr(d1, True), safe_repr(d2, True))
+            diff = ('\n' + '\n'.join(difflib.ndiff(
+                           pprint.pformat(d1).splitlines(),
+                           pprint.pformat(d2).splitlines())))
+            standardMsg = self._truncateMessage(standardMsg, diff)
+            self.fail(self._formatMessage(msg, standardMsg))
+
+    def assertDictContainsSubset(self, expected, actual, msg=None):
+        """Checks whether actual is a superset of expected."""
+        missing = []
+        mismatched = []
+        for key, value in expected.iteritems():
+            if key not in actual:
+                missing.append(key)
+            elif value != actual[key]:
+                mismatched.append('%s, expected: %s, actual: %s' %
+                                  (safe_repr(key), safe_repr(value), 
+                                   safe_repr(actual[key])))
+
+        if not (missing or mismatched):
+            return
+
+        standardMsg = ''
+        if missing:
+            standardMsg = 'Missing: %s' % ','.join(safe_repr(m) for m in 
+                                                    missing)
+        if mismatched:
+            if standardMsg:
+                standardMsg += '; '
+            standardMsg += 'Mismatched values: %s' % ','.join(mismatched)
+
+        self.fail(self._formatMessage(msg, standardMsg))
+
+    def assertItemsEqual(self, expected_seq, actual_seq, msg=None):
+        """An unordered sequence specific comparison. It asserts that
+        expected_seq and actual_seq contain the same elements. It is
+        the equivalent of::
+        
+            self.assertEqual(sorted(expected_seq), sorted(actual_seq))
+
+        Raises with an error message listing which elements of expected_seq
+        are missing from actual_seq and vice versa if any.
+        
+        Asserts that each element has the same count in both sequences.
+        Example:
+            - [0, 1, 1] and [1, 0, 1] compare equal.
+            - [0, 0, 1] and [0, 1] compare unequal.
+        """
+        try:
+            expected = sorted(expected_seq)
+            actual = sorted(actual_seq)
+        except TypeError:
+            # Unsortable items (example: set(), complex(), ...)
+            expected = list(expected_seq)
+            actual = list(actual_seq)
+            missing, unexpected = unorderable_list_difference(
+                expected, actual, ignore_duplicate=False
+            )
+        else:
+            return self.assertSequenceEqual(expected, actual, msg=msg)
+
+        errors = []
+        if missing:
+            errors.append('Expected, but missing:\n    %s' % 
+                           safe_repr(missing))
+        if unexpected:
+            errors.append('Unexpected, but present:\n    %s' % 
+                           safe_repr(unexpected))
+        if errors:
+            standardMsg = '\n'.join(errors)
+            self.fail(self._formatMessage(msg, standardMsg))
+
+    def assertMultiLineEqual(self, first, second, msg=None):
+        """Assert that two multi-line strings are equal."""
+        self.assert_(isinstance(first, basestring), (
+                'First argument is not a string'))
+        self.assert_(isinstance(second, basestring), (
+                'Second argument is not a string'))
+
+        if first != second:
+            standardMsg = '%s != %s' % (safe_repr(first, True), safe_repr(second, True))
+            diff = '\n' + ''.join(difflib.ndiff(first.splitlines(True),
+                                                       second.splitlines(True)))
+            standardMsg = self._truncateMessage(standardMsg, diff)
+            self.fail(self._formatMessage(msg, standardMsg))
+
+    def assertLess(self, a, b, msg=None):
+        """Just like self.assertTrue(a < b), but with a nicer default message."""
+        if not a < b:
+            standardMsg = '%s not less than %s' % (safe_repr(a), safe_repr(b))
+            self.fail(self._formatMessage(msg, standardMsg))
+
+    def assertLessEqual(self, a, b, msg=None):
+        """Just like self.assertTrue(a <= b), but with a nicer default message."""
+        if not a <= b:
+            standardMsg = '%s not less than or equal to %s' % (safe_repr(a), safe_repr(b))
+            self.fail(self._formatMessage(msg, standardMsg))
+
+    def assertGreater(self, a, b, msg=None):
+        """Just like self.assertTrue(a > b), but with a nicer default message."""
+        if not a > b:
+            standardMsg = '%s not greater than %s' % (safe_repr(a), safe_repr(b))
+            self.fail(self._formatMessage(msg, standardMsg))
+
+    def assertGreaterEqual(self, a, b, msg=None):
+        """Just like self.assertTrue(a >= b), but with a nicer default message."""
+        if not a >= b:
+            standardMsg = '%s not greater than or equal to %s' % (safe_repr(a), safe_repr(b))
+            self.fail(self._formatMessage(msg, standardMsg))
+
+    def assertIsNone(self, obj, msg=None):
+        """Same as self.assertTrue(obj is None), with a nicer default message."""
+        if obj is not None:
+            standardMsg = '%s is not None' % (safe_repr(obj),)
+            self.fail(self._formatMessage(msg, standardMsg))
+
+    def assertIsNotNone(self, obj, msg=None):
+        """Included for symmetry with assertIsNone."""
+        if obj is None:
+            standardMsg = 'unexpectedly None'
+            self.fail(self._formatMessage(msg, standardMsg))
+
+    def assertIsInstance(self, obj, cls, msg=None):
+        """Same as self.assertTrue(isinstance(obj, cls)), with a nicer
+        default message."""
+        if not isinstance(obj, cls):
+            standardMsg = '%s is not an instance of %r' % (safe_repr(obj), cls)
+            self.fail(self._formatMessage(msg, standardMsg))
+
+    def assertNotIsInstance(self, obj, cls, msg=None):
+        """Included for symmetry with assertIsInstance."""
+        if isinstance(obj, cls):
+            standardMsg = '%s is an instance of %r' % (safe_repr(obj), cls)
+            self.fail(self._formatMessage(msg, standardMsg))
+
+    def assertRaisesRegexp(self, expected_exception, expected_regexp,
+                           callable_obj=None, *args, **kwargs):
+        """Asserts that the message in a raised exception matches a regexp.
+
+        Args:
+            expected_exception: Exception class expected to be raised.
+            expected_regexp: Regexp (re pattern object or string) expected
+                    to be found in error message.
+            callable_obj: Function to be called.
+            args: Extra args.
+            kwargs: Extra kwargs.
+        """
+        if callable_obj is None:
+            return _AssertRaisesContext(expected_exception, self, expected_regexp)
+        try:
+            callable_obj(*args, **kwargs)
+        except expected_exception, exc_value:
+            if isinstance(expected_regexp, basestring):
+                expected_regexp = re.compile(expected_regexp)
+            if not expected_regexp.search(str(exc_value)):
+                raise self.failureException('"%s" does not match "%s"' %
+                         (expected_regexp.pattern, str(exc_value)))
+        else:
+            if hasattr(expected_exception, '__name__'): 
+                excName = expected_exception.__name__
+            else: 
+                excName = str(expected_exception)
+            raise self.failureException, "%s not raised" % excName
+
+
+    def assertRegexpMatches(self, text, expected_regexp, msg=None):
+        """Fail the test unless the text matches the regular expression."""
+        if isinstance(expected_regexp, basestring):
+            expected_regexp = re.compile(expected_regexp)
+        if not expected_regexp.search(text):
+            msg = msg or "Regexp didn't match"
+            msg = '%s: %r not found in %r' % (msg, expected_regexp.pattern, text)
+            raise self.failureException(msg)
+
+    def assertNotRegexpMatches(self, text, unexpected_regexp, msg=None):
+        """Fail the test if the text matches the regular expression."""
+        if isinstance(unexpected_regexp, basestring):
+            unexpected_regexp = re.compile(unexpected_regexp)
+        match = unexpected_regexp.search(text)
+        if match:
+            msg = msg or "Regexp matched"
+            msg = '%s: %r matches %r in %r' % (msg,
+                                               text[match.start():match.end()],
+                                               unexpected_regexp.pattern,
+                                               text)
+            raise self.failureException(msg)
+
+class FunctionTestCase(TestCase):
+    """A test case that wraps a test function.
+
+    This is useful for slipping pre-existing test functions into the
+    unittest framework. Optionally, set-up and tidy-up functions can be
+    supplied. As with TestCase, the tidy-up ('tearDown') function will
+    always be called if the set-up ('setUp') function ran successfully.
+    """
+
+    def __init__(self, testFunc, setUp=None, tearDown=None, description=None):
+        super(FunctionTestCase, self).__init__()
+        self._setUpFunc = setUp
+        self._tearDownFunc = tearDown
+        self._testFunc = testFunc
+        self._description = description
+
+    def setUp(self):
+        if self._setUpFunc is not None:
+            self._setUpFunc()
+
+    def tearDown(self):
+        if self._tearDownFunc is not None:
+            self._tearDownFunc()
+
+    def runTest(self):
+        self._testFunc()
+
+    def id(self):
+        return self._testFunc.__name__
+
+    def __eq__(self, other):
+        if not isinstance(other, self.__class__):
+            return NotImplemented
+
+        return self._setUpFunc == other._setUpFunc and \
+               self._tearDownFunc == other._tearDownFunc and \
+               self._testFunc == other._testFunc and \
+               self._description == other._description
+
+    def __ne__(self, other):
+        return not self == other
+
+    def __hash__(self):
+        return hash((type(self), self._setUpFunc, self._tearDownFunc,
+                     self._testFunc, self._description))
+
+    def __str__(self):
+        return "%s (%s)" % (strclass(self.__class__),
+                            self._testFunc.__name__)
+
+    def __repr__(self):
+        return "<%s testFunc=%s>" % (strclass(self.__class__),
+                                     self._testFunc)
+
+    def shortDescription(self):
+        if self._description is not None:
+            return self._description
+        doc = self._testFunc.__doc__
+        return doc and doc.split("\n")[0].strip() or None

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/collector.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/collector.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/collector.py
new file mode 100644
index 0000000..28ff3f8
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/collector.py
@@ -0,0 +1,9 @@
+import os
+import sys
+from unittest2.loader import defaultTestLoader
+
+def collector():
+    # import __main__ triggers code re-execution
+    __main__ = sys.modules['__main__']
+    setupDir = os.path.abspath(os.path.dirname(__main__.__file__))
+    return defaultTestLoader.discover(setupDir)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/compatibility.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/compatibility.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/compatibility.py
new file mode 100644
index 0000000..b8f15dd
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/compatibility.py
@@ -0,0 +1,64 @@
+import os
+import sys
+
+try:
+    from functools import wraps
+except ImportError:
+    # only needed for Python 2.4
+    def wraps(_):
+        def _wraps(func):
+            return func
+        return _wraps
+
+__unittest = True
+
+def _relpath_nt(path, start=os.path.curdir):
+    """Return a relative version of a path"""
+
+    if not path:
+        raise ValueError("no path specified")
+    start_list = os.path.abspath(start).split(os.path.sep)
+    path_list = os.path.abspath(path).split(os.path.sep)
+    if start_list[0].lower() != path_list[0].lower():
+        unc_path, rest = os.path.splitunc(path)
+        unc_start, rest = os.path.splitunc(start)
+        if bool(unc_path) ^ bool(unc_start):
+            raise ValueError("Cannot mix UNC and non-UNC paths (%s and %s)"
+                                                                % (path, start))
+        else:
+            raise ValueError("path is on drive %s, start on drive %s"
+                                                % (path_list[0], start_list[0]))
+    # Work out how much of the filepath is shared by start and path.
+    for i in range(min(len(start_list), len(path_list))):
+        if start_list[i].lower() != path_list[i].lower():
+            break
+    else:
+        i += 1
+
+    rel_list = [os.path.pardir] * (len(start_list)-i) + path_list[i:]
+    if not rel_list:
+        return os.path.curdir
+    return os.path.join(*rel_list)
+
+# default to posixpath definition
+def _relpath_posix(path, start=os.path.curdir):
+    """Return a relative version of a path"""
+
+    if not path:
+        raise ValueError("no path specified")
+    
+    start_list = os.path.abspath(start).split(os.path.sep)
+    path_list = os.path.abspath(path).split(os.path.sep)
+
+    # Work out how much of the filepath is shared by start and path.
+    i = len(os.path.commonprefix([start_list, path_list]))
+
+    rel_list = [os.path.pardir] * (len(start_list)-i) + path_list[i:]
+    if not rel_list:
+        return os.path.curdir
+    return os.path.join(*rel_list)
+
+if os.path is sys.modules.get('ntpath'):
+    relpath = _relpath_nt
+else:
+    relpath = _relpath_posix

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/loader.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/loader.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/loader.py
new file mode 100644
index 0000000..8ec2ead
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/loader.py
@@ -0,0 +1,322 @@
+"""Loading unittests."""
+
+import os
+import re
+import sys
+import traceback
+import types
+import unittest
+
+from fnmatch import fnmatch
+
+from unittest2 import case, suite
+
+try:
+    from os.path import relpath
+except ImportError:
+    from unittest2.compatibility import relpath
+
+__unittest = True
+
+
+def _CmpToKey(mycmp):
+    'Convert a cmp= function into a key= function'
+    class K(object):
+        def __init__(self, obj):
+            self.obj = obj
+        def __lt__(self, other):
+            return mycmp(self.obj, other.obj) == -1
+    return K
+
+
+# what about .pyc or .pyo (etc)
+# we would need to avoid loading the same tests multiple times
+# from '.py', '.pyc' *and* '.pyo'
+VALID_MODULE_NAME = re.compile(r'[_a-z]\w*\.py$', re.IGNORECASE)
+
+
+def _make_failed_import_test(name, suiteClass):
+    message = 'Failed to import test module: %s' % name
+    if hasattr(traceback, 'format_exc'):
+        # Python 2.3 compatibility
+        # format_exc returns two frames of discover.py as well
+        message += '\n%s' % traceback.format_exc()
+    return _make_failed_test('ModuleImportFailure', name, ImportError(message),
+                             suiteClass)
+
+def _make_failed_load_tests(name, exception, suiteClass):
+    return _make_failed_test('LoadTestsFailure', name, exception, suiteClass)
+
+def _make_failed_test(classname, methodname, exception, suiteClass):
+    def testFailure(self):
+        raise exception
+    attrs = {methodname: testFailure}
+    TestClass = type(classname, (case.TestCase,), attrs)
+    return suiteClass((TestClass(methodname),))
+    
+
+class TestLoader(unittest.TestLoader):
+    """
+    This class is responsible for loading tests according to various criteria
+    and returning them wrapped in a TestSuite
+    """
+    testMethodPrefix = 'test'
+    sortTestMethodsUsing = cmp
+    suiteClass = suite.TestSuite
+    _top_level_dir = None
+
+    def loadTestsFromTestCase(self, testCaseClass):
+        """Return a suite of all tests cases contained in testCaseClass"""
+        if issubclass(testCaseClass, suite.TestSuite):
+            raise TypeError("Test cases should not be derived from TestSuite."
+                            " Maybe you meant to derive from TestCase?")
+        testCaseNames = self.getTestCaseNames(testCaseClass)
+        if not testCaseNames and hasattr(testCaseClass, 'runTest'):
+            testCaseNames = ['runTest']
+        loaded_suite = self.suiteClass(map(testCaseClass, testCaseNames))
+        return loaded_suite
+
+    def loadTestsFromModule(self, module, use_load_tests=True):
+        """Return a suite of all tests cases contained in the given module"""
+        tests = []
+        for name in dir(module):
+            obj = getattr(module, name)
+            if isinstance(obj, type) and issubclass(obj, unittest.TestCase):
+                tests.append(self.loadTestsFromTestCase(obj))
+
+        load_tests = getattr(module, 'load_tests', None)
+        tests = self.suiteClass(tests)
+        if use_load_tests and load_tests is not None:
+            try:
+                return load_tests(self, tests, None)
+            except Exception, e:
+                return _make_failed_load_tests(module.__name__, e,
+                                               self.suiteClass)
+        return tests
+
+    def loadTestsFromName(self, name, module=None):
+        """Return a suite of all tests cases given a string specifier.
+
+        The name may resolve either to a module, a test case class, a
+        test method within a test case class, or a callable object which
+        returns a TestCase or TestSuite instance.
+
+        The method optionally resolves the names relative to a given module.
+        """
+        parts = name.split('.')
+        if module is None:
+            parts_copy = parts[:]
+            while parts_copy:
+                try:
+                    module = __import__('.'.join(parts_copy))
+                    break
+                except ImportError:
+                    del parts_copy[-1]
+                    if not parts_copy:
+                        raise
+            parts = parts[1:]
+        obj = module
+        for part in parts:
+            parent, obj = obj, getattr(obj, part)
+
+        if isinstance(obj, types.ModuleType):
+            return self.loadTestsFromModule(obj)
+        elif isinstance(obj, type) and issubclass(obj, unittest.TestCase):
+            return self.loadTestsFromTestCase(obj)
+        elif (isinstance(obj, types.UnboundMethodType) and
+              isinstance(parent, type) and
+              issubclass(parent, case.TestCase)):
+            return self.suiteClass([parent(obj.__name__)])
+        elif isinstance(obj, unittest.TestSuite):
+            return obj
+        elif hasattr(obj, '__call__'):
+            test = obj()
+            if isinstance(test, unittest.TestSuite):
+                return test
+            elif isinstance(test, unittest.TestCase):
+                return self.suiteClass([test])
+            else:
+                raise TypeError("calling %s returned %s, not a test" %
+                                (obj, test))
+        else:
+            raise TypeError("don't know how to make test from: %s" % obj)
+
+    def loadTestsFromNames(self, names, module=None):
+        """Return a suite of all tests cases found using the given sequence
+        of string specifiers. See 'loadTestsFromName()'.
+        """
+        suites = [self.loadTestsFromName(name, module) for name in names]
+        return self.suiteClass(suites)
+
+    def getTestCaseNames(self, testCaseClass):
+        """Return a sorted sequence of method names found within testCaseClass
+        """
+        def isTestMethod(attrname, testCaseClass=testCaseClass,
+                         prefix=self.testMethodPrefix):
+            return attrname.startswith(prefix) and \
+                hasattr(getattr(testCaseClass, attrname), '__call__')
+        testFnNames = filter(isTestMethod, dir(testCaseClass))
+        if self.sortTestMethodsUsing:
+            testFnNames.sort(key=_CmpToKey(self.sortTestMethodsUsing))
+        return testFnNames
+
+    def discover(self, start_dir, pattern='test*.py', top_level_dir=None):
+        """Find and return all test modules from the specified start
+        directory, recursing into subdirectories to find them. Only test files
+        that match the pattern will be loaded. (Using shell style pattern
+        matching.)
+
+        All test modules must be importable from the top level of the project.
+        If the start directory is not the top level directory then the top
+        level directory must be specified separately.
+
+        If a test package name (directory with '__init__.py') matches the
+        pattern then the package will be checked for a 'load_tests' function. If
+        this exists then it will be called with loader, tests, pattern.
+
+        If load_tests exists then discovery does  *not* recurse into the package,
+        load_tests is responsible for loading all tests in the package.
+
+        The pattern is deliberately not stored as a loader attribute so that
+        packages can continue discovery themselves. top_level_dir is stored so
+        load_tests does not need to pass this argument in to loader.discover().
+        """
+        set_implicit_top = False
+        if top_level_dir is None and self._top_level_dir is not None:
+            # make top_level_dir optional if called from load_tests in a package
+            top_level_dir = self._top_level_dir
+        elif top_level_dir is None:
+            set_implicit_top = True
+            top_level_dir = start_dir
+
+        top_level_dir = os.path.abspath(top_level_dir)
+
+        if not top_level_dir in sys.path:
+            # all test modules must be importable from the top level directory
+            # should we *unconditionally* put the start directory in first
+            # in sys.path to minimise likelihood of conflicts between installed
+            # modules and development versions?
+            sys.path.insert(0, top_level_dir)
+        self._top_level_dir = top_level_dir
+
+        is_not_importable = False
+        if os.path.isdir(os.path.abspath(start_dir)):
+            start_dir = os.path.abspath(start_dir)
+            if start_dir != top_level_dir:
+                is_not_importable = not os.path.isfile(os.path.join(start_dir, '__init__.py'))
+        else:
+            # support for discovery from dotted module names
+            try:
+                __import__(start_dir)
+            except ImportError:
+                is_not_importable = True
+            else:
+                the_module = sys.modules[start_dir]
+                top_part = start_dir.split('.')[0]
+                start_dir = os.path.abspath(os.path.dirname((the_module.__file__)))
+                if set_implicit_top:
+                    self._top_level_dir = os.path.abspath(os.path.dirname(os.path.dirname(sys.modules[top_part].__file__)))
+                    sys.path.remove(top_level_dir)
+
+        if is_not_importable:
+            raise ImportError('Start directory is not importable: %r' % start_dir)
+
+        tests = list(self._find_tests(start_dir, pattern))
+        return self.suiteClass(tests)
+
+    def _get_name_from_path(self, path):
+        path = os.path.splitext(os.path.normpath(path))[0]
+
+        _relpath = relpath(path, self._top_level_dir)
+        assert not os.path.isabs(_relpath), "Path must be within the project"
+        assert not _relpath.startswith('..'), "Path must be within the project"
+
+        name = _relpath.replace(os.path.sep, '.')
+        return name
+
+    def _get_module_from_name(self, name):
+        __import__(name)
+        return sys.modules[name]
+
+    def _match_path(self, path, full_path, pattern):
+        # override this method to use alternative matching strategy
+        return fnmatch(path, pattern)
+    
+    def _find_tests(self, start_dir, pattern):
+        """Used by discovery. Yields test suites it loads."""
+        paths = os.listdir(start_dir)
+
+        for path in paths:
+            full_path = os.path.join(start_dir, path)
+            if os.path.isfile(full_path):
+                if not VALID_MODULE_NAME.match(path):
+                    # valid Python identifiers only
+                    continue
+                if not self._match_path(path, full_path, pattern):
+                    continue
+                # if the test file matches, load it
+                name = self._get_name_from_path(full_path)
+                try:
+                    module = self._get_module_from_name(name)
+                except:
+                    yield _make_failed_import_test(name, self.suiteClass)
+                else:
+                    mod_file = os.path.abspath(getattr(module, '__file__', full_path))
+                    realpath = os.path.splitext(mod_file)[0]
+                    fullpath_noext = os.path.splitext(full_path)[0]
+                    if realpath.lower() != fullpath_noext.lower():
+                        module_dir = os.path.dirname(realpath)
+                        mod_name = os.path.splitext(os.path.basename(full_path))[0]
+                        expected_dir = os.path.dirname(full_path)
+                        msg = ("%r module incorrectly imported from %r. Expected %r. "
+                               "Is this module globally installed?")
+                        raise ImportError(msg % (mod_name, module_dir, expected_dir))
+                    yield self.loadTestsFromModule(module)
+            elif os.path.isdir(full_path):
+                if not os.path.isfile(os.path.join(full_path, '__init__.py')):
+                    continue
+
+                load_tests = None
+                tests = None
+                if fnmatch(path, pattern):
+                    # only check load_tests if the package directory itself matches the filter
+                    name = self._get_name_from_path(full_path)
+                    package = self._get_module_from_name(name)
+                    load_tests = getattr(package, 'load_tests', None)
+                    tests = self.loadTestsFromModule(package, use_load_tests=False)
+
+                if load_tests is None:
+                    if tests is not None:
+                        # tests loaded from package file
+                        yield tests
+                    # recurse into the package
+                    for test in self._find_tests(full_path, pattern):
+                        yield test
+                else:
+                    try:
+                        yield load_tests(self, tests, pattern)
+                    except Exception, e:
+                        yield _make_failed_load_tests(package.__name__, e,
+                                                      self.suiteClass)
+
+defaultTestLoader = TestLoader()
+
+
+def _makeLoader(prefix, sortUsing, suiteClass=None):
+    loader = TestLoader()
+    loader.sortTestMethodsUsing = sortUsing
+    loader.testMethodPrefix = prefix
+    if suiteClass:
+        loader.suiteClass = suiteClass
+    return loader
+
+def getTestCaseNames(testCaseClass, prefix, sortUsing=cmp):
+    return _makeLoader(prefix, sortUsing).getTestCaseNames(testCaseClass)
+
+def makeSuite(testCaseClass, prefix='test', sortUsing=cmp,
+              suiteClass=suite.TestSuite):
+    return _makeLoader(prefix, sortUsing, suiteClass).loadTestsFromTestCase(testCaseClass)
+
+def findTestCases(module, prefix='test', sortUsing=cmp,
+                  suiteClass=suite.TestSuite):
+    return _makeLoader(prefix, sortUsing, suiteClass).loadTestsFromModule(module)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/main.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/main.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/main.py
new file mode 100644
index 0000000..9db1d30
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/main.py
@@ -0,0 +1,241 @@
+"""Unittest main program"""
+
+import sys
+import os
+import types
+
+from unittest2 import loader, runner
+try:
+    from unittest2.signals import installHandler
+except ImportError:
+    installHandler = None
+
+__unittest = True
+
+FAILFAST     = "  -f, --failfast   Stop on first failure\n"
+CATCHBREAK   = "  -c, --catch      Catch control-C and display results\n"
+BUFFEROUTPUT = "  -b, --buffer     Buffer stdout and stderr during test runs\n"
+
+USAGE_AS_MAIN = """\
+Usage: %(progName)s [options] [tests]
+
+Options:
+  -h, --help       Show this message
+  -v, --verbose    Verbose output
+  -q, --quiet      Minimal output
+%(failfast)s%(catchbreak)s%(buffer)s
+Examples:
+  %(progName)s test_module                       - run tests from test_module
+  %(progName)s test_module.TestClass             - run tests from
+                                                   test_module.TestClass
+  %(progName)s test_module.TestClass.test_method - run specified test method
+
+[tests] can be a list of any number of test modules, classes and test
+methods.
+
+Alternative Usage: %(progName)s discover [options]
+
+Options:
+  -v, --verbose    Verbose output
+%(failfast)s%(catchbreak)s%(buffer)s  -s directory     Directory to start discovery ('.' default)
+  -p pattern       Pattern to match test files ('test*.py' default)
+  -t directory     Top level directory of project (default to
+                   start directory)
+
+For test discovery all test modules must be importable from the top
+level directory of the project.
+"""
+
+USAGE_FROM_MODULE = """\
+Usage: %(progName)s [options] [test] [...]
+
+Options:
+  -h, --help       Show this message
+  -v, --verbose    Verbose output
+  -q, --quiet      Minimal output
+%(failfast)s%(catchbreak)s%(buffer)s
+Examples:
+  %(progName)s                               - run default set of tests
+  %(progName)s MyTestSuite                   - run suite 'MyTestSuite'
+  %(progName)s MyTestCase.testSomething      - run MyTestCase.testSomething
+  %(progName)s MyTestCase                    - run all 'test*' test methods
+                                               in MyTestCase
+"""
+
+
+class TestProgram(object):
+    """A command-line program that runs a set of tests; this is primarily
+       for making test modules conveniently executable.
+    """
+    USAGE = USAGE_FROM_MODULE
+    
+    # defaults for testing
+    failfast = catchbreak = buffer = progName = None
+
+    def __init__(self, module='__main__', defaultTest=None,
+                 argv=None, testRunner=None,
+                 testLoader=loader.defaultTestLoader, exit=True,
+                 verbosity=1, failfast=None, catchbreak=None, buffer=None):
+        if isinstance(module, basestring):
+            self.module = __import__(module)
+            for part in module.split('.')[1:]:
+                self.module = getattr(self.module, part)
+        else:
+            self.module = module
+        if argv is None:
+            argv = sys.argv
+
+        self.exit = exit
+        self.verbosity = verbosity
+        self.failfast = failfast
+        self.catchbreak = catchbreak
+        self.buffer = buffer
+        self.defaultTest = defaultTest
+        self.testRunner = testRunner
+        self.testLoader = testLoader
+        self.progName = os.path.basename(argv[0])
+        self.parseArgs(argv)
+        self.runTests()
+
+    def usageExit(self, msg=None):
+        if msg:
+            print msg
+        usage = {'progName': self.progName, 'catchbreak': '', 'failfast': '',
+                 'buffer': ''}
+        if self.failfast != False:
+            usage['failfast'] = FAILFAST
+        if self.catchbreak != False and installHandler is not None:
+            usage['catchbreak'] = CATCHBREAK
+        if self.buffer != False:
+            usage['buffer'] = BUFFEROUTPUT
+        print self.USAGE % usage
+        sys.exit(2)
+
+    def parseArgs(self, argv):
+        if len(argv) > 1 and argv[1].lower() == 'discover':
+            self._do_discovery(argv[2:])
+            return
+
+        import getopt
+        long_opts = ['help', 'verbose', 'quiet', 'failfast', 'catch', 'buffer']
+        try:
+            options, args = getopt.getopt(argv[1:], 'hHvqfcb', long_opts)
+            for opt, value in options:
+                if opt in ('-h','-H','--help'):
+                    self.usageExit()
+                if opt in ('-q','--quiet'):
+                    self.verbosity = 0
+                if opt in ('-v','--verbose'):
+                    self.verbosity = 2
+                if opt in ('-f','--failfast'):
+                    if self.failfast is None:
+                        self.failfast = True
+                    # Should this raise an exception if -f is not valid?
+                if opt in ('-c','--catch'):
+                    if self.catchbreak is None and installHandler is not None:
+                        self.catchbreak = True
+                    # Should this raise an exception if -c is not valid?
+                if opt in ('-b','--buffer'):
+                    if self.buffer is None:
+                        self.buffer = True
+                    # Should this raise an exception if -b is not valid?
+            if len(args) == 0 and self.defaultTest is None:
+                # createTests will load tests from self.module
+                self.testNames = None
+            elif len(args) > 0:
+                self.testNames = args
+                if __name__ == '__main__':
+                    # to support python -m unittest ...
+                    self.module = None
+            else:
+                self.testNames = (self.defaultTest,)
+            self.createTests()
+        except getopt.error, msg:
+            self.usageExit(msg)
+
+    def createTests(self):
+        if self.testNames is None:
+            self.test = self.testLoader.loadTestsFromModule(self.module)
+        else:
+            self.test = self.testLoader.loadTestsFromNames(self.testNames,
+                                                           self.module)
+
+    def _do_discovery(self, argv, Loader=loader.TestLoader):
+        # handle command line args for test discovery
+        self.progName = '%s discover' % self.progName
+        import optparse
+        parser = optparse.OptionParser()
+        parser.prog = self.progName
+        parser.add_option('-v', '--verbose', dest='verbose', default=False,
+                          help='Verbose output', action='store_true')
+        if self.failfast != False:
+            parser.add_option('-f', '--failfast', dest='failfast', default=False,
+                              help='Stop on first fail or error', 
+                              action='store_true')
+        if self.catchbreak != False and installHandler is not None:
+            parser.add_option('-c', '--catch', dest='catchbreak', default=False,
+                              help='Catch ctrl-C and display results so far', 
+                              action='store_true')
+        if self.buffer != False:
+            parser.add_option('-b', '--buffer', dest='buffer', default=False,
+                              help='Buffer stdout and stderr during tests', 
+                              action='store_true')
+        parser.add_option('-s', '--start-directory', dest='start', default='.',
+                          help="Directory to start discovery ('.' default)")
+        parser.add_option('-p', '--pattern', dest='pattern', default='test*.py',
+                          help="Pattern to match tests ('test*.py' default)")
+        parser.add_option('-t', '--top-level-directory', dest='top', default=None,
+                          help='Top level directory of project (defaults to start directory)')
+
+        options, args = parser.parse_args(argv)
+        if len(args) > 3:
+            self.usageExit()
+
+        for name, value in zip(('start', 'pattern', 'top'), args):
+            setattr(options, name, value)
+        
+        # only set options from the parsing here
+        # if they weren't set explicitly in the constructor
+        if self.failfast is None:
+            self.failfast = options.failfast
+        if self.catchbreak is None and installHandler is not None:
+            self.catchbreak = options.catchbreak
+        if self.buffer is None:
+            self.buffer = options.buffer
+        
+        if options.verbose:
+            self.verbosity = 2
+
+        start_dir = options.start
+        pattern = options.pattern
+        top_level_dir = options.top
+
+        loader = Loader()
+        self.test = loader.discover(start_dir, pattern, top_level_dir)
+
+    def runTests(self):
+        if self.catchbreak:
+            installHandler()
+        if self.testRunner is None:
+            self.testRunner = runner.TextTestRunner
+        if isinstance(self.testRunner, (type, types.ClassType)):
+            try:
+                testRunner = self.testRunner(verbosity=self.verbosity,
+                                             failfast=self.failfast,
+                                             buffer=self.buffer)
+            except TypeError:
+                # didn't accept the verbosity, buffer or failfast arguments
+                testRunner = self.testRunner()
+        else:
+            # it is assumed to be a TestRunner instance
+            testRunner = self.testRunner
+        self.result = testRunner.run(self.test)
+        if self.exit:
+            sys.exit(not self.result.wasSuccessful())
+
+main = TestProgram
+
+def main_():
+    TestProgram.USAGE = USAGE_AS_MAIN
+    main(module=None)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/result.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/result.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/result.py
new file mode 100644
index 0000000..7770e64
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/result.py
@@ -0,0 +1,183 @@
+"""Test result object"""
+
+import sys
+import traceback
+import unittest
+
+from StringIO import StringIO
+
+from unittest2 import util
+from unittest2.compatibility import wraps
+
+__unittest = True
+
+def failfast(method):
+    @wraps(method)
+    def inner(self, *args, **kw):
+        if getattr(self, 'failfast', False):
+            self.stop()
+        return method(self, *args, **kw)
+    return inner
+
+
+STDOUT_LINE = '\nStdout:\n%s'
+STDERR_LINE = '\nStderr:\n%s'
+
+class TestResult(unittest.TestResult):
+    """Holder for test result information.
+
+    Test results are automatically managed by the TestCase and TestSuite
+    classes, and do not need to be explicitly manipulated by writers of tests.
+
+    Each instance holds the total number of tests run, and collections of
+    failures and errors that occurred among those test runs. The collections
+    contain tuples of (testcase, exceptioninfo), where exceptioninfo is the
+    formatted traceback of the error that occurred.
+    """
+    _previousTestClass = None
+    _moduleSetUpFailed = False
+    
+    def __init__(self):
+        self.failfast = False
+        self.failures = []
+        self.errors = []
+        self.testsRun = 0
+        self.skipped = []
+        self.expectedFailures = []
+        self.unexpectedSuccesses = []
+        self.shouldStop = False
+        self.buffer = False
+        self._stdout_buffer = None
+        self._stderr_buffer = None
+        self._original_stdout = sys.stdout
+        self._original_stderr = sys.stderr
+        self._mirrorOutput = False
+    
+    def startTest(self, test):
+        "Called when the given test is about to be run"
+        self.testsRun += 1
+        self._mirrorOutput = False
+        if self.buffer:
+            if self._stderr_buffer is None:
+                self._stderr_buffer = StringIO()
+                self._stdout_buffer = StringIO()
+            sys.stdout = self._stdout_buffer
+            sys.stderr = self._stderr_buffer
+
+    def startTestRun(self):
+        """Called once before any tests are executed.
+
+        See startTest for a method called before each test.
+        """
+
+    def stopTest(self, test):
+        """Called when the given test has been run"""
+        if self.buffer:
+            if self._mirrorOutput:
+                output = sys.stdout.getvalue()
+                error = sys.stderr.getvalue()
+                if output:
+                    if not output.endswith('\n'):
+                        output += '\n'
+                    self._original_stdout.write(STDOUT_LINE % output)
+                if error:
+                    if not error.endswith('\n'):
+                        error += '\n'
+                    self._original_stderr.write(STDERR_LINE % error)
+                
+            sys.stdout = self._original_stdout
+            sys.stderr = self._original_stderr
+            self._stdout_buffer.seek(0)
+            self._stdout_buffer.truncate()
+            self._stderr_buffer.seek(0)
+            self._stderr_buffer.truncate()
+        self._mirrorOutput = False
+        
+
+    def stopTestRun(self):
+        """Called once after all tests are executed.
+
+        See stopTest for a method called after each test.
+        """
+
+    @failfast
+    def addError(self, test, err):
+        """Called when an error has occurred. 'err' is a tuple of values as
+        returned by sys.exc_info().
+        """
+        self.errors.append((test, self._exc_info_to_string(err, test)))
+        self._mirrorOutput = True
+
+    @failfast
+    def addFailure(self, test, err):
+        """Called when an error has occurred. 'err' is a tuple of values as
+        returned by sys.exc_info()."""
+        self.failures.append((test, self._exc_info_to_string(err, test)))
+        self._mirrorOutput = True
+
+    def addSuccess(self, test):
+        "Called when a test has completed successfully"
+        pass
+
+    def addSkip(self, test, reason):
+        """Called when a test is skipped."""
+        self.skipped.append((test, reason))
+
+    def addExpectedFailure(self, test, err):
+        """Called when an expected failure/error occured."""
+        self.expectedFailures.append(
+            (test, self._exc_info_to_string(err, test)))
+
+    @failfast
+    def addUnexpectedSuccess(self, test):
+        """Called when a test was expected to fail, but succeed."""
+        self.unexpectedSuccesses.append(test)
+
+    def wasSuccessful(self):
+        "Tells whether or not this result was a success"
+        return (len(self.failures) + len(self.errors) == 0)
+
+    def stop(self):
+        "Indicates that the tests should be aborted"
+        self.shouldStop = True
+
+    def _exc_info_to_string(self, err, test):
+        """Converts a sys.exc_info()-style tuple of values into a string."""
+        exctype, value, tb = err
+        # Skip test runner traceback levels
+        while tb and self._is_relevant_tb_level(tb):
+            tb = tb.tb_next
+        if exctype is test.failureException:
+            # Skip assert*() traceback levels
+            length = self._count_relevant_tb_levels(tb)
+            msgLines = traceback.format_exception(exctype, value, tb, length)
+        else:
+            msgLines = traceback.format_exception(exctype, value, tb)
+        
+        if self.buffer:
+            output = sys.stdout.getvalue()
+            error = sys.stderr.getvalue()            
+            if output:
+                if not output.endswith('\n'):
+                    output += '\n'
+                msgLines.append(STDOUT_LINE % output)
+            if error:
+                if not error.endswith('\n'):
+                    error += '\n'
+                msgLines.append(STDERR_LINE % error)
+        return ''.join(msgLines)
+
+    def _is_relevant_tb_level(self, tb):
+        return '__unittest' in tb.tb_frame.f_globals
+
+    def _count_relevant_tb_levels(self, tb):
+        length = 0
+        while tb and not self._is_relevant_tb_level(tb):
+            length += 1
+            tb = tb.tb_next
+        return length
+
+    def __repr__(self):
+        return "<%s run=%i errors=%i failures=%i>" % \
+               (util.strclass(self.__class__), self.testsRun, len(self.errors),
+                len(self.failures))

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/runner.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/runner.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/runner.py
new file mode 100644
index 0000000..15a6f88
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/runner.py
@@ -0,0 +1,206 @@
+"""Running tests"""
+
+import sys
+import time
+import unittest
+
+from unittest2 import result
+
+try:
+    from unittest2.signals import registerResult
+except ImportError:
+    def registerResult(_):
+        pass
+    
+__unittest = True
+
+
+class _WritelnDecorator(object):
+    """Used to decorate file-like objects with a handy 'writeln' method"""
+    def __init__(self,stream):
+        self.stream = stream
+
+    def __getattr__(self, attr):
+        if attr in ('stream', '__getstate__'):
+            raise AttributeError(attr)
+        return getattr(self.stream,attr)
+
+    def writeln(self, arg=None):
+        if arg:
+            self.write(arg)
+        self.write('\n') # text-mode streams translate to \r\n if needed
+
+
+class TextTestResult(result.TestResult):
+    """A test result class that can print formatted text results to a stream.
+
+    Used by TextTestRunner.
+    """
+    separator1 = '=' * 70
+    separator2 = '-' * 70
+
+    def __init__(self, stream, descriptions, verbosity):
+        super(TextTestResult, self).__init__()
+        self.stream = stream
+        self.showAll = verbosity > 1
+        self.dots = verbosity == 1
+        self.descriptions = descriptions
+
+    def getDescription(self, test):
+        doc_first_line = test.shortDescription()
+        if self.descriptions and doc_first_line:
+            return '\n'.join((str(test), doc_first_line))
+        else:
+            return str(test)
+
+    def startTest(self, test):
+        super(TextTestResult, self).startTest(test)
+        if self.showAll:
+            self.stream.write(self.getDescription(test))
+            self.stream.write(" ... ")
+            self.stream.flush()
+
+    def addSuccess(self, test):
+        super(TextTestResult, self).addSuccess(test)
+        if self.showAll:
+            self.stream.writeln("ok")
+        elif self.dots:
+            self.stream.write('.')
+            self.stream.flush()
+
+    def addError(self, test, err):
+        super(TextTestResult, self).addError(test, err)
+        if self.showAll:
+            self.stream.writeln("ERROR")
+        elif self.dots:
+            self.stream.write('E')
+            self.stream.flush()
+
+    def addFailure(self, test, err):
+        super(TextTestResult, self).addFailure(test, err)
+        if self.showAll:
+            self.stream.writeln("FAIL")
+        elif self.dots:
+            self.stream.write('F')
+            self.stream.flush()
+
+    def addSkip(self, test, reason):
+        super(TextTestResult, self).addSkip(test, reason)
+        if self.showAll:
+            self.stream.writeln("skipped %r" % (reason,))
+        elif self.dots:
+            self.stream.write("s")
+            self.stream.flush()
+
+    def addExpectedFailure(self, test, err):
+        super(TextTestResult, self).addExpectedFailure(test, err)
+        if self.showAll:
+            self.stream.writeln("expected failure")
+        elif self.dots:
+            self.stream.write("x")
+            self.stream.flush()
+
+    def addUnexpectedSuccess(self, test):
+        super(TextTestResult, self).addUnexpectedSuccess(test)
+        if self.showAll:
+            self.stream.writeln("unexpected success")
+        elif self.dots:
+            self.stream.write("u")
+            self.stream.flush()
+
+    def printErrors(self):
+        if self.dots or self.showAll:
+            self.stream.writeln()
+        self.printErrorList('ERROR', self.errors)
+        self.printErrorList('FAIL', self.failures)
+
+    def printErrorList(self, flavour, errors):
+        for test, err in errors:
+            self.stream.writeln(self.separator1)
+            self.stream.writeln("%s: %s" % (flavour, self.getDescription(test)))
+            self.stream.writeln(self.separator2)
+            self.stream.writeln("%s" % err)
+
+    def stopTestRun(self):
+        super(TextTestResult, self).stopTestRun()
+        self.printErrors()
+
+
+class TextTestRunner(unittest.TextTestRunner):
+    """A test runner class that displays results in textual form.
+
+    It prints out the names of tests as they are run, errors as they
+    occur, and a summary of the results at the end of the test run.
+    """
+    resultclass = TextTestResult
+
+    def __init__(self, stream=sys.stderr, descriptions=True, verbosity=1,
+                    failfast=False, buffer=False, resultclass=None):
+        self.stream = _WritelnDecorator(stream)
+        self.descriptions = descriptions
+        self.verbosity = verbosity
+        self.failfast = failfast
+        self.buffer = buffer
+        if resultclass is not None:
+            self.resultclass = resultclass
+
+    def _makeResult(self):
+        return self.resultclass(self.stream, self.descriptions, self.verbosity)
+
+    def run(self, test):
+        "Run the given test case or test suite."
+        result = self._makeResult()
+        result.failfast = self.failfast
+        result.buffer = self.buffer
+        registerResult(result)
+        
+        startTime = time.time()
+        startTestRun = getattr(result, 'startTestRun', None)
+        if startTestRun is not None:
+            startTestRun()
+        try:
+            test(result)
+        finally:
+            stopTestRun = getattr(result, 'stopTestRun', None)
+            if stopTestRun is not None:
+                stopTestRun()
+            else:
+                result.printErrors()
+        stopTime = time.time()
+        timeTaken = stopTime - startTime
+        if hasattr(result, 'separator2'):
+            self.stream.writeln(result.separator2)
+        run = result.testsRun
+        self.stream.writeln("Ran %d test%s in %.3fs" %
+                            (run, run != 1 and "s" or "", timeTaken))
+        self.stream.writeln()
+        
+        expectedFails = unexpectedSuccesses = skipped = 0
+        try:
+            results = map(len, (result.expectedFailures,
+                                result.unexpectedSuccesses,
+                                result.skipped))
+            expectedFails, unexpectedSuccesses, skipped = results
+        except AttributeError:
+            pass
+        infos = []
+        if not result.wasSuccessful():
+            self.stream.write("FAILED")
+            failed, errored = map(len, (result.failures, result.errors))
+            if failed:
+                infos.append("failures=%d" % failed)
+            if errored:
+                infos.append("errors=%d" % errored)
+        else:
+            self.stream.write("OK")
+        if skipped:
+            infos.append("skipped=%d" % skipped)
+        if expectedFails:
+            infos.append("expected failures=%d" % expectedFails)
+        if unexpectedSuccesses:
+            infos.append("unexpected successes=%d" % unexpectedSuccesses)
+        if infos:
+            self.stream.writeln(" (%s)" % (", ".join(infos),))
+        else:
+            self.stream.write("\n")
+        return result

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/signals.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/signals.py b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/signals.py
new file mode 100644
index 0000000..e40328d
--- /dev/null
+++ b/tools/bin/pythonSrc/unittest2-0.5.1/unittest2/signals.py
@@ -0,0 +1,57 @@
+import signal
+import weakref
+
+from unittest2.compatibility import wraps
+
+__unittest = True
+
+
+class _InterruptHandler(object):
+    def __init__(self, default_handler):
+        self.called = False
+        self.default_handler = default_handler
+
+    def __call__(self, signum, frame):
+        installed_handler = signal.getsignal(signal.SIGINT)
+        if installed_handler is not self:
+            # if we aren't the installed handler, then delegate immediately
+            # to the default handler
+            self.default_handler(signum, frame)
+            
+        if self.called:
+            self.default_handler(signum, frame)
+        self.called = True
+        for result in _results.keys():
+            result.stop()
+
+_results = weakref.WeakKeyDictionary()
+def registerResult(result):
+    _results[result] = 1
+
+def removeResult(result):
+    return bool(_results.pop(result, None))
+
+_interrupt_handler = None
+def installHandler():
+    global _interrupt_handler
+    if _interrupt_handler is None:
+        default_handler = signal.getsignal(signal.SIGINT)
+        _interrupt_handler = _InterruptHandler(default_handler)
+        signal.signal(signal.SIGINT, _interrupt_handler)
+
+
+def removeHandler(method=None):
+    if method is not None:
+        @wraps(method)
+        def inner(*args, **kwargs):
+            initial = signal.getsignal(signal.SIGINT)
+            removeHandler()
+            try:
+                return method(*args, **kwargs)
+            finally:
+                signal.signal(signal.SIGINT, initial)
+        return inner
+
+    global _interrupt_handler
+    if _interrupt_handler is not None:
+        signal.signal(signal.SIGINT, _interrupt_handler.default_handler)



[22/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code

Posted by rl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/yaml/scanner.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/yaml/scanner.py b/tools/bin/ext/yaml/scanner.py
new file mode 100644
index 0000000..369c027
--- /dev/null
+++ b/tools/bin/ext/yaml/scanner.py
@@ -0,0 +1,1472 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Scanner produces tokens of the following types:
+# STREAM-START
+# STREAM-END
+# DIRECTIVE(name, value)
+# DOCUMENT-START
+# DOCUMENT-END
+# BLOCK-SEQUENCE-START
+# BLOCK-MAPPING-START
+# BLOCK-END
+# FLOW-SEQUENCE-START
+# FLOW-MAPPING-START
+# FLOW-SEQUENCE-END
+# FLOW-MAPPING-END
+# BLOCK-ENTRY
+# FLOW-ENTRY
+# KEY
+# VALUE
+# ALIAS(value)
+# ANCHOR(value)
+# TAG(value)
+# SCALAR(value, plain, style)
+#
+# Read comments in the Scanner code for more details.
+#
+
+__all__ = ['Scanner', 'ScannerError']
+
+from error import MarkedYAMLError
+from tokens import *
+
+class ScannerError(MarkedYAMLError):
+    pass
+
+class SimpleKey(object):
+    # See below simple keys treatment.
+
+    def __init__(self, token_number, required, index, line, column, mark):
+        self.token_number = token_number
+        self.required = required
+        self.index = index
+        self.line = line
+        self.column = column
+        self.mark = mark
+
+class Scanner(object):
+
+    def __init__(self):
+        """Initialize the scanner."""
+        # It is assumed that Scanner and Reader will have a common descendant.
+        # Reader do the dirty work of checking for BOM and converting the
+        # input data to Unicode. It also adds NUL to the end.
+        #
+        # Reader supports the following methods
+        #   self.peek(i=0)       # peek the next i-th character
+        #   self.prefix(l=1)     # peek the next l characters
+        #   self.forward(l=1)    # read the next l characters and move the pointer.
+
+        # Had we reached the end of the stream?
+        self.done = False
+
+        # The number of unclosed '{' and '['. `flow_level == 0` means block
+        # context.
+        self.flow_level = 0
+
+        # List of processed tokens that are not yet emitted.
+        self.tokens = []
+
+        # Add the STREAM-START token.
+        self.fetch_stream_start()
+
+        # Number of tokens that were emitted through the `get_token` method.
+        self.tokens_taken = 0
+
+        # The current indentation level.
+        self.indent = -1
+
+        # Past indentation levels.
+        self.indents = []
+
+        # Variables related to simple keys treatment.
+
+        # A simple key is a key that is not denoted by the '?' indicator.
+        # Example of simple keys:
+        #   ---
+        #   block simple key: value
+        #   ? not a simple key:
+        #   : { flow simple key: value }
+        # We emit the KEY token before all keys, so when we find a potential
+        # simple key, we try to locate the corresponding ':' indicator.
+        # Simple keys should be limited to a single line and 1024 characters.
+
+        # Can a simple key start at the current position? A simple key may
+        # start:
+        # - at the beginning of the line, not counting indentation spaces
+        #       (in block context),
+        # - after '{', '[', ',' (in the flow context),
+        # - after '?', ':', '-' (in the block context).
+        # In the block context, this flag also signifies if a block collection
+        # may start at the current position.
+        self.allow_simple_key = True
+
+        # Keep track of possible simple keys. This is a dictionary. The key
+        # is `flow_level`; there can be no more that one possible simple key
+        # for each level. The value is a SimpleKey record:
+        #   (token_number, required, index, line, column, mark)
+        # A simple key may start with ALIAS, ANCHOR, TAG, SCALAR(flow),
+        # '[', or '{' tokens.
+        self.possible_simple_keys = {}
+
+    # Public methods.
+
+    def check_token(self, *choices):
+        # Check if the next token is one of the given types.
+        while self.need_more_tokens():
+            self.fetch_more_tokens()
+        if self.tokens:
+            if not choices:
+                return True
+            for choice in choices:
+                if isinstance(self.tokens[0], choice):
+                    return True
+        return False
+
+    def peek_token(self):
+        # Return the next token, but do not delete if from the queue.
+        while self.need_more_tokens():
+            self.fetch_more_tokens()
+        if self.tokens:
+            return self.tokens[0]
+
+    def get_token(self):
+        # Return the next token.
+        while self.need_more_tokens():
+            self.fetch_more_tokens()
+        if self.tokens:
+            self.tokens_taken += 1
+            return self.tokens.pop(0)
+
+    # Private methods.
+
+    def need_more_tokens(self):
+        if self.done:
+            return False
+        if not self.tokens:
+            return True
+        # The current token may be a potential simple key, so we
+        # need to look further.
+        self.stale_possible_simple_keys()
+        if self.next_possible_simple_key() == self.tokens_taken:
+            return True
+
+    def fetch_more_tokens(self):
+
+        # Eat whitespaces and comments until we reach the next token.
+        self.scan_to_next_token()
+
+        # Remove obsolete possible simple keys.
+        self.stale_possible_simple_keys()
+
+        # Compare the current indentation and column. It may add some tokens
+        # and decrease the current indentation level.
+        self.unwind_indent(self.column)
+
+        # Peek the next character.
+        ch = self.peek()
+
+        # Is it the end of stream?
+        if ch == u'\0':
+            return self.fetch_stream_end()
+
+        # Is it a directive?
+        if ch == u'%' and self.check_directive():
+            return self.fetch_directive()
+
+        # Is it the document start?
+        if ch == u'-' and self.check_document_start():
+            return self.fetch_document_start()
+
+        # Is it the document end?
+        if ch == u'.' and self.check_document_end():
+            return self.fetch_document_end()
+
+        # TODO: support for BOM within a stream.
+        #if ch == u'\uFEFF':
+        #    return self.fetch_bom()    <-- issue BOMToken
+
+        # Note: the order of the following checks is NOT significant.
+
+        # Is it the flow sequence start indicator?
+        if ch == u'[':
+            return self.fetch_flow_sequence_start()
+
+        # Is it the flow mapping start indicator?
+        if ch == u'{':
+            return self.fetch_flow_mapping_start()
+
+        # Is it the flow sequence end indicator?
+        if ch == u']':
+            return self.fetch_flow_sequence_end()
+
+        # Is it the flow mapping end indicator?
+        if ch == u'}':
+            return self.fetch_flow_mapping_end()
+
+        # Is it the flow entry indicator?
+        if ch == u',':
+            return self.fetch_flow_entry()
+
+        # Is it the block entry indicator?
+        if ch == u'-' and self.check_block_entry():
+            return self.fetch_block_entry()
+
+        # Is it the key indicator?
+        if ch == u'?' and self.check_key():
+            return self.fetch_key()
+
+        # Is it the value indicator?
+        if ch == u':' and self.check_value():
+            return self.fetch_value()
+
+        # Is it an alias?
+        if ch == u'*':
+            return self.fetch_alias()
+
+        # Is it an anchor?
+        if ch == u'&':
+            return self.fetch_anchor()
+
+        # Is it a tag?
+        if ch == u'!':
+            return self.fetch_tag()
+
+        # Is it a literal scalar?
+        if ch == u'|' and not self.flow_level:
+            return self.fetch_literal()
+
+        # Is it a folded scalar?
+        if ch == u'>' and not self.flow_level:
+            return self.fetch_folded()
+
+        # Is it a single quoted scalar?
+        if ch == u'\'':
+            return self.fetch_single()
+
+        # Is it a double quoted scalar?
+        if ch == u'\"':
+            return self.fetch_double()
+
+        # It must be a plain scalar then.
+        if self.check_plain():
+            return self.fetch_plain()
+
+        # No? It's an error. Let's produce a nice error message.
+        raise ScannerError("while scanning for the next token", None,
+                "found character %r that cannot start any token"
+                % ch.encode('utf-8'), self.get_mark())
+
+    # Simple keys treatment.
+
+    def next_possible_simple_key(self):
+        # Return the number of the nearest possible simple key. Actually we
+        # don't need to loop through the whole dictionary. We may replace it
+        # with the following code:
+        #   if not self.possible_simple_keys:
+        #       return None
+        #   return self.possible_simple_keys[
+        #           min(self.possible_simple_keys.keys())].token_number
+        min_token_number = None
+        for level in self.possible_simple_keys:
+            key = self.possible_simple_keys[level]
+            if min_token_number is None or key.token_number < min_token_number:
+                min_token_number = key.token_number
+        return min_token_number
+
+    def stale_possible_simple_keys(self):
+        # Remove entries that are no longer possible simple keys. According to
+        # the YAML specification, simple keys
+        # - should be limited to a single line,
+        # - should be no longer than 1024 characters.
+        # Disabling this procedure will allow simple keys of any length and
+        # height (may cause problems if indentation is broken though).
+        for level in self.possible_simple_keys.keys():
+            key = self.possible_simple_keys[level]
+            if key.line != self.line  \
+                    or self.index-key.index > 1024:
+                if key.required:
+                    raise ScannerError("while scanning a simple key", key.mark,
+                            "could not found expected ':'", self.get_mark())
+                del self.possible_simple_keys[level]
+
+    def save_possible_simple_key(self):
+        # The next token may start a simple key. We check if it's possible
+        # and save its position. This function is called for
+        #   ALIAS, ANCHOR, TAG, SCALAR(flow), '[', and '{'.
+
+        # Check if a simple key is required at the current position.
+        required = not self.flow_level and self.indent == self.column
+
+        # A simple key is required only if it is the first token in the current
+        # line. Therefore it is always allowed.
+        assert self.allow_simple_key or not required
+
+        # The next token might be a simple key. Let's save it's number and
+        # position.
+        if self.allow_simple_key:
+            self.remove_possible_simple_key()
+            token_number = self.tokens_taken+len(self.tokens)
+            key = SimpleKey(token_number, required,
+                    self.index, self.line, self.column, self.get_mark())
+            self.possible_simple_keys[self.flow_level] = key
+
+    def remove_possible_simple_key(self):
+        # Remove the saved possible key position at the current flow level.
+        if self.flow_level in self.possible_simple_keys:
+            key = self.possible_simple_keys[self.flow_level]
+            
+            if key.required:
+                raise ScannerError("while scanning a simple key", key.mark,
+                        "could not found expected ':'", self.get_mark())
+
+            del self.possible_simple_keys[self.flow_level]
+
+    # Indentation functions.
+
+    def unwind_indent(self, column):
+
+        ## In flow context, tokens should respect indentation.
+        ## Actually the condition should be `self.indent >= column` according to
+        ## the spec. But this condition will prohibit intuitively correct
+        ## constructions such as
+        ## key : {
+        ## }
+        #if self.flow_level and self.indent > column:
+        #    raise ScannerError(None, None,
+        #            "invalid intendation or unclosed '[' or '{'",
+        #            self.get_mark())
+
+        # In the flow context, indentation is ignored. We make the scanner less
+        # restrictive then specification requires.
+        if self.flow_level:
+            return
+
+        # In block context, we may need to issue the BLOCK-END tokens.
+        while self.indent > column:
+            mark = self.get_mark()
+            self.indent = self.indents.pop()
+            self.tokens.append(BlockEndToken(mark, mark))
+
+    def add_indent(self, column):
+        # Check if we need to increase indentation.
+        if self.indent < column:
+            self.indents.append(self.indent)
+            self.indent = column
+            return True
+        return False
+
+    # Fetchers.
+
+    def fetch_stream_start(self):
+        # We always add STREAM-START as the first token and STREAM-END as the
+        # last token.
+
+        # Read the token.
+        mark = self.get_mark()
+        
+        # Add STREAM-START.
+        self.tokens.append(StreamStartToken(mark, mark,
+            encoding=self.encoding))
+        
+
+    def fetch_stream_end(self):
+
+        # Set the current intendation to -1.
+        self.unwind_indent(-1)
+
+        # Reset everything (not really needed).
+        self.allow_simple_key = False
+        self.possible_simple_keys = {}
+
+        # Read the token.
+        mark = self.get_mark()
+        
+        # Add STREAM-END.
+        self.tokens.append(StreamEndToken(mark, mark))
+
+        # The steam is finished.
+        self.done = True
+
+    def fetch_directive(self):
+        
+        # Set the current intendation to -1.
+        self.unwind_indent(-1)
+
+        # Reset simple keys.
+        self.remove_possible_simple_key()
+        self.allow_simple_key = False
+
+        # Scan and add DIRECTIVE.
+        self.tokens.append(self.scan_directive())
+
+    def fetch_document_start(self):
+        self.fetch_document_indicator(DocumentStartToken)
+
+    def fetch_document_end(self):
+        self.fetch_document_indicator(DocumentEndToken)
+
+    def fetch_document_indicator(self, TokenClass):
+
+        # Set the current intendation to -1.
+        self.unwind_indent(-1)
+
+        # Reset simple keys. Note that there could not be a block collection
+        # after '---'.
+        self.remove_possible_simple_key()
+        self.allow_simple_key = False
+
+        # Add DOCUMENT-START or DOCUMENT-END.
+        start_mark = self.get_mark()
+        self.forward(3)
+        end_mark = self.get_mark()
+        self.tokens.append(TokenClass(start_mark, end_mark))
+
+    def fetch_flow_sequence_start(self):
+        self.fetch_flow_collection_start(FlowSequenceStartToken)
+
+    def fetch_flow_mapping_start(self):
+        self.fetch_flow_collection_start(FlowMappingStartToken)
+
+    def fetch_flow_collection_start(self, TokenClass):
+
+        # '[' and '{' may start a simple key.
+        self.save_possible_simple_key()
+
+        # Increase the flow level.
+        self.flow_level += 1
+
+        # Simple keys are allowed after '[' and '{'.
+        self.allow_simple_key = True
+
+        # Add FLOW-SEQUENCE-START or FLOW-MAPPING-START.
+        start_mark = self.get_mark()
+        self.forward()
+        end_mark = self.get_mark()
+        self.tokens.append(TokenClass(start_mark, end_mark))
+
+    def fetch_flow_sequence_end(self):
+        self.fetch_flow_collection_end(FlowSequenceEndToken)
+
+    def fetch_flow_mapping_end(self):
+        self.fetch_flow_collection_end(FlowMappingEndToken)
+
+    def fetch_flow_collection_end(self, TokenClass):
+
+        # Reset possible simple key on the current level.
+        self.remove_possible_simple_key()
+
+        # Decrease the flow level.
+        self.flow_level -= 1
+
+        # No simple keys after ']' or '}'.
+        self.allow_simple_key = False
+
+        # Add FLOW-SEQUENCE-END or FLOW-MAPPING-END.
+        start_mark = self.get_mark()
+        self.forward()
+        end_mark = self.get_mark()
+        self.tokens.append(TokenClass(start_mark, end_mark))
+
+    def fetch_flow_entry(self):
+
+        # Simple keys are allowed after ','.
+        self.allow_simple_key = True
+
+        # Reset possible simple key on the current level.
+        self.remove_possible_simple_key()
+
+        # Add FLOW-ENTRY.
+        start_mark = self.get_mark()
+        self.forward()
+        end_mark = self.get_mark()
+        self.tokens.append(FlowEntryToken(start_mark, end_mark))
+
+    def fetch_block_entry(self):
+
+        # Block context needs additional checks.
+        if not self.flow_level:
+
+            # Are we allowed to start a new entry?
+            if not self.allow_simple_key:
+                raise ScannerError(None, None,
+                        "sequence entries are not allowed here",
+                        self.get_mark())
+
+            # We may need to add BLOCK-SEQUENCE-START.
+            if self.add_indent(self.column):
+                mark = self.get_mark()
+                self.tokens.append(BlockSequenceStartToken(mark, mark))
+
+        # It's an error for the block entry to occur in the flow context,
+        # but we let the parser detect this.
+        else:
+            pass
+
+        # Simple keys are allowed after '-'.
+        self.allow_simple_key = True
+
+        # Reset possible simple key on the current level.
+        self.remove_possible_simple_key()
+
+        # Add BLOCK-ENTRY.
+        start_mark = self.get_mark()
+        self.forward()
+        end_mark = self.get_mark()
+        self.tokens.append(BlockEntryToken(start_mark, end_mark))
+
+    def fetch_key(self):
+        
+        # Block context needs additional checks.
+        if not self.flow_level:
+
+            # Are we allowed to start a key (not nessesary a simple)?
+            if not self.allow_simple_key:
+                raise ScannerError(None, None,
+                        "mapping keys are not allowed here",
+                        self.get_mark())
+
+            # We may need to add BLOCK-MAPPING-START.
+            if self.add_indent(self.column):
+                mark = self.get_mark()
+                self.tokens.append(BlockMappingStartToken(mark, mark))
+
+        # Simple keys are allowed after '?' in the block context.
+        self.allow_simple_key = not self.flow_level
+
+        # Reset possible simple key on the current level.
+        self.remove_possible_simple_key()
+
+        # Add KEY.
+        start_mark = self.get_mark()
+        self.forward()
+        end_mark = self.get_mark()
+        self.tokens.append(KeyToken(start_mark, end_mark))
+
+    def fetch_value(self):
+
+        # Do we determine a simple key?
+        if self.flow_level in self.possible_simple_keys:
+
+            # Add KEY.
+            key = self.possible_simple_keys[self.flow_level]
+            del self.possible_simple_keys[self.flow_level]
+            self.tokens.insert(key.token_number-self.tokens_taken,
+                    KeyToken(key.mark, key.mark))
+
+            # If this key starts a new block mapping, we need to add
+            # BLOCK-MAPPING-START.
+            if not self.flow_level:
+                if self.add_indent(key.column):
+                    self.tokens.insert(key.token_number-self.tokens_taken,
+                            BlockMappingStartToken(key.mark, key.mark))
+
+            # There cannot be two simple keys one after another.
+            self.allow_simple_key = False
+
+        # It must be a part of a complex key.
+        else:
+            
+            # Block context needs additional checks.
+            # (Do we really need them? They will be catched by the parser
+            # anyway.)
+            if not self.flow_level:
+
+                # We are allowed to start a complex value if and only if
+                # we can start a simple key.
+                if not self.allow_simple_key:
+                    raise ScannerError(None, None,
+                            "mapping values are not allowed here",
+                            self.get_mark())
+
+            # If this value starts a new block mapping, we need to add
+            # BLOCK-MAPPING-START.  It will be detected as an error later by
+            # the parser.
+            if not self.flow_level:
+                if self.add_indent(self.column):
+                    mark = self.get_mark()
+                    self.tokens.append(BlockMappingStartToken(mark, mark))
+
+            # Simple keys are allowed after ':' in the block context.
+            self.allow_simple_key = not self.flow_level
+
+            # Reset possible simple key on the current level.
+            self.remove_possible_simple_key()
+
+        # Add VALUE.
+        start_mark = self.get_mark()
+        self.forward()
+        end_mark = self.get_mark()
+        self.tokens.append(ValueToken(start_mark, end_mark))
+
+    def fetch_alias(self):
+
+        # ALIAS could be a simple key.
+        self.save_possible_simple_key()
+
+        # No simple keys after ALIAS.
+        self.allow_simple_key = False
+
+        # Scan and add ALIAS.
+        self.tokens.append(self.scan_anchor(AliasToken))
+
+    def fetch_anchor(self):
+
+        # ANCHOR could start a simple key.
+        self.save_possible_simple_key()
+
+        # No simple keys after ANCHOR.
+        self.allow_simple_key = False
+
+        # Scan and add ANCHOR.
+        self.tokens.append(self.scan_anchor(AnchorToken))
+
+    def fetch_tag(self):
+
+        # TAG could start a simple key.
+        self.save_possible_simple_key()
+
+        # No simple keys after TAG.
+        self.allow_simple_key = False
+
+        # Scan and add TAG.
+        self.tokens.append(self.scan_tag())
+
+    def fetch_literal(self):
+        self.fetch_block_scalar(style='|')
+
+    def fetch_folded(self):
+        self.fetch_block_scalar(style='>')
+
+    def fetch_block_scalar(self, style):
+
+        # A simple key may follow a block scalar.
+        self.allow_simple_key = True
+
+        # Reset possible simple key on the current level.
+        self.remove_possible_simple_key()
+
+        # Scan and add SCALAR.
+        self.tokens.append(self.scan_block_scalar(style))
+
+    def fetch_single(self):
+        self.fetch_flow_scalar(style='\'')
+
+    def fetch_double(self):
+        self.fetch_flow_scalar(style='"')
+
+    def fetch_flow_scalar(self, style):
+
+        # A flow scalar could be a simple key.
+        self.save_possible_simple_key()
+
+        # No simple keys after flow scalars.
+        self.allow_simple_key = False
+
+        # Scan and add SCALAR.
+        self.tokens.append(self.scan_flow_scalar(style))
+
+    def fetch_plain(self):
+
+        # A plain scalar could be a simple key.
+        self.save_possible_simple_key()
+
+        # No simple keys after plain scalars. But note that `scan_plain` will
+        # change this flag if the scan is finished at the beginning of the
+        # line.
+        self.allow_simple_key = False
+
+        # Scan and add SCALAR. May change `allow_simple_key`.
+        self.tokens.append(self.scan_plain())
+
+    # Checkers.
+
+    def check_directive(self):
+
+        # DIRECTIVE:        ^ '%' ...
+        # The '%' indicator is already checked.
+        if self.column == 0:
+            return True
+
+    def check_document_start(self):
+
+        # DOCUMENT-START:   ^ '---' (' '|'\n')
+        if self.column == 0:
+            if self.prefix(3) == u'---'  \
+                    and self.peek(3) in u'\0 \t\r\n\x85\u2028\u2029':
+                return True
+
+    def check_document_end(self):
+
+        # DOCUMENT-END:     ^ '...' (' '|'\n')
+        if self.column == 0:
+            if self.prefix(3) == u'...'  \
+                    and self.peek(3) in u'\0 \t\r\n\x85\u2028\u2029':
+                return True
+
+    def check_block_entry(self):
+
+        # BLOCK-ENTRY:      '-' (' '|'\n')
+        return self.peek(1) in u'\0 \t\r\n\x85\u2028\u2029'
+
+    def check_key(self):
+
+        # KEY(flow context):    '?'
+        if self.flow_level:
+            return True
+
+        # KEY(block context):   '?' (' '|'\n')
+        else:
+            return self.peek(1) in u'\0 \t\r\n\x85\u2028\u2029'
+
+    def check_value(self):
+
+        # VALUE(flow context):  ':'
+        if self.flow_level:
+            return True
+
+        # VALUE(block context): ':' (' '|'\n')
+        else:
+            return self.peek(1) in u'\0 \t\r\n\x85\u2028\u2029'
+
+    def check_plain(self):
+
+        # A plain scalar may start with any non-space character except:
+        #   '-', '?', ':', ',', '[', ']', '{', '}',
+        #   '#', '&', '*', '!', '|', '>', '\'', '\"',
+        #   '%', '@', '`'.
+        #
+        # It may also start with
+        #   '-', '?', ':'
+        # if it is followed by a non-space character.
+        #
+        # Note that we limit the last rule to the block context (except the
+        # '-' character) because we want the flow context to be space
+        # independent.
+        ch = self.peek()
+        return ch not in u'\0 \t\r\n\x85\u2028\u2029-?:,[]{}#&*!|>\'\"%@`'  \
+                or (self.peek(1) not in u'\0 \t\r\n\x85\u2028\u2029'
+                        and (ch == u'-' or (not self.flow_level and ch in u'?:')))
+
+    # Scanners.
+
+    def scan_to_next_token(self):
+        # We ignore spaces, line breaks and comments.
+        # If we find a line break in the block context, we set the flag
+        # `allow_simple_key` on.
+        # The byte order mark is stripped if it's the first character in the
+        # stream. We do not yet support BOM inside the stream as the
+        # specification requires. Any such mark will be considered as a part
+        # of the document.
+        #
+        # TODO: We need to make tab handling rules more sane. A good rule is
+        #   Tabs cannot precede tokens
+        #   BLOCK-SEQUENCE-START, BLOCK-MAPPING-START, BLOCK-END,
+        #   KEY(block), VALUE(block), BLOCK-ENTRY
+        # So the checking code is
+        #   if <TAB>:
+        #       self.allow_simple_keys = False
+        # We also need to add the check for `allow_simple_keys == True` to
+        # `unwind_indent` before issuing BLOCK-END.
+        # Scanners for block, flow, and plain scalars need to be modified.
+
+        if self.index == 0 and self.peek() == u'\uFEFF':
+            self.forward()
+        found = False
+        while not found:
+            while self.peek() == u' ':
+                self.forward()
+            if self.peek() == u'#':
+                while self.peek() not in u'\0\r\n\x85\u2028\u2029':
+                    self.forward()
+            if self.scan_line_break():
+                if not self.flow_level:
+                    self.allow_simple_key = True
+            else:
+                found = True
+
+    def scan_directive(self):
+        # See the specification for details.
+        start_mark = self.get_mark()
+        self.forward()
+        name = self.scan_directive_name(start_mark)
+        value = None
+        if name == u'YAML':
+            value = self.scan_yaml_directive_value(start_mark)
+            end_mark = self.get_mark()
+        elif name == u'TAG':
+            value = self.scan_tag_directive_value(start_mark)
+            end_mark = self.get_mark()
+        else:
+            end_mark = self.get_mark()
+            while self.peek() not in u'\0\r\n\x85\u2028\u2029':
+                self.forward()
+        self.scan_directive_ignored_line(start_mark)
+        return DirectiveToken(name, value, start_mark, end_mark)
+
+    def scan_directive_name(self, start_mark):
+        # See the specification for details.
+        length = 0
+        ch = self.peek(length)
+        while u'0' <= ch <= u'9' or u'A' <= ch <= 'Z' or u'a' <= ch <= 'z'  \
+                or ch in u'-_':
+            length += 1
+            ch = self.peek(length)
+        if not length:
+            raise ScannerError("while scanning a directive", start_mark,
+                    "expected alphabetic or numeric character, but found %r"
+                    % ch.encode('utf-8'), self.get_mark())
+        value = self.prefix(length)
+        self.forward(length)
+        ch = self.peek()
+        if ch not in u'\0 \r\n\x85\u2028\u2029':
+            raise ScannerError("while scanning a directive", start_mark,
+                    "expected alphabetic or numeric character, but found %r"
+                    % ch.encode('utf-8'), self.get_mark())
+        return value
+
+    def scan_yaml_directive_value(self, start_mark):
+        # See the specification for details.
+        while self.peek() == u' ':
+            self.forward()
+        major = self.scan_yaml_directive_number(start_mark)
+        if self.peek() != '.':
+            raise ScannerError("while scanning a directive", start_mark,
+                    "expected a digit or '.', but found %r"
+                    % self.peek().encode('utf-8'),
+                    self.get_mark())
+        self.forward()
+        minor = self.scan_yaml_directive_number(start_mark)
+        if self.peek() not in u'\0 \r\n\x85\u2028\u2029':
+            raise ScannerError("while scanning a directive", start_mark,
+                    "expected a digit or ' ', but found %r"
+                    % self.peek().encode('utf-8'),
+                    self.get_mark())
+        return (major, minor)
+
+    def scan_yaml_directive_number(self, start_mark):
+        # See the specification for details.
+        ch = self.peek()
+        if not (u'0' <= ch <= '9'):
+            raise ScannerError("while scanning a directive", start_mark,
+                    "expected a digit, but found %r" % ch.encode('utf-8'),
+                    self.get_mark())
+        length = 0
+        while u'0' <= self.peek(length) <= u'9':
+            length += 1
+        value = int(self.prefix(length))
+        self.forward(length)
+        return value
+
+    def scan_tag_directive_value(self, start_mark):
+        # See the specification for details.
+        while self.peek() == u' ':
+            self.forward()
+        handle = self.scan_tag_directive_handle(start_mark)
+        while self.peek() == u' ':
+            self.forward()
+        prefix = self.scan_tag_directive_prefix(start_mark)
+        return (handle, prefix)
+
+    def scan_tag_directive_handle(self, start_mark):
+        # See the specification for details.
+        value = self.scan_tag_handle('directive', start_mark)
+        ch = self.peek()
+        if ch != u' ':
+            raise ScannerError("while scanning a directive", start_mark,
+                    "expected ' ', but found %r" % ch.encode('utf-8'),
+                    self.get_mark())
+        return value
+
+    def scan_tag_directive_prefix(self, start_mark):
+        # See the specification for details.
+        value = self.scan_tag_uri('directive', start_mark)
+        ch = self.peek()
+        if ch not in u'\0 \r\n\x85\u2028\u2029':
+            raise ScannerError("while scanning a directive", start_mark,
+                    "expected ' ', but found %r" % ch.encode('utf-8'),
+                    self.get_mark())
+        return value
+
+    def scan_directive_ignored_line(self, start_mark):
+        # See the specification for details.
+        while self.peek() == u' ':
+            self.forward()
+        if self.peek() == u'#':
+            while self.peek() not in u'\0\r\n\x85\u2028\u2029':
+                self.forward()
+        ch = self.peek()
+        if ch not in u'\0\r\n\x85\u2028\u2029':
+            raise ScannerError("while scanning a directive", start_mark,
+                    "expected a comment or a line break, but found %r"
+                        % ch.encode('utf-8'), self.get_mark())
+        self.scan_line_break()
+
+    def scan_anchor(self, TokenClass):
+        # The specification does not restrict characters for anchors and
+        # aliases. This may lead to problems, for instance, the document:
+        #   [ *alias, value ]
+        # can be interpteted in two ways, as
+        #   [ "value" ]
+        # and
+        #   [ *alias , "value" ]
+        # Therefore we restrict aliases to numbers and ASCII letters.
+        start_mark = self.get_mark()
+        indicator = self.peek()
+        if indicator == '*':
+            name = 'alias'
+        else:
+            name = 'anchor'
+        self.forward()
+        length = 0
+        ch = self.peek(length)
+        while u'0' <= ch <= u'9' or u'A' <= ch <= 'Z' or u'a' <= ch <= 'z'  \
+                or ch in u'-_':
+            length += 1
+            ch = self.peek(length)
+        if not length:
+            raise ScannerError("while scanning an %s" % name, start_mark,
+                    "expected alphabetic or numeric character, but found %r"
+                    % ch.encode('utf-8'), self.get_mark())
+        value = self.prefix(length)
+        self.forward(length)
+        ch = self.peek()
+        if ch not in u'\0 \t\r\n\x85\u2028\u2029?:,]}%@`':
+            raise ScannerError("while scanning an %s" % name, start_mark,
+                    "expected alphabetic or numeric character, but found %r"
+                    % ch.encode('utf-8'), self.get_mark())
+        end_mark = self.get_mark()
+        return TokenClass(value, start_mark, end_mark)
+
+    def scan_tag(self):
+        # See the specification for details.
+        start_mark = self.get_mark()
+        ch = self.peek(1)
+        if ch == u'<':
+            handle = None
+            self.forward(2)
+            suffix = self.scan_tag_uri('tag', start_mark)
+            if self.peek() != u'>':
+                raise ScannerError("while parsing a tag", start_mark,
+                        "expected '>', but found %r" % self.peek().encode('utf-8'),
+                        self.get_mark())
+            self.forward()
+        elif ch in u'\0 \t\r\n\x85\u2028\u2029':
+            handle = None
+            suffix = u'!'
+            self.forward()
+        else:
+            length = 1
+            use_handle = False
+            while ch not in u'\0 \r\n\x85\u2028\u2029':
+                if ch == u'!':
+                    use_handle = True
+                    break
+                length += 1
+                ch = self.peek(length)
+            handle = u'!'
+            if use_handle:
+                handle = self.scan_tag_handle('tag', start_mark)
+            else:
+                handle = u'!'
+                self.forward()
+            suffix = self.scan_tag_uri('tag', start_mark)
+        ch = self.peek()
+        if ch not in u'\0 \r\n\x85\u2028\u2029':
+            raise ScannerError("while scanning a tag", start_mark,
+                    "expected ' ', but found %r" % ch.encode('utf-8'),
+                    self.get_mark())
+        value = (handle, suffix)
+        end_mark = self.get_mark()
+        return TagToken(value, start_mark, end_mark)
+
+    def scan_block_scalar(self, style):
+        # See the specification for details.
+
+        if style == '>':
+            folded = True
+        else:
+            folded = False
+
+        chunks = []
+        start_mark = self.get_mark()
+
+        # Scan the header.
+        self.forward()
+        chomping, increment = self.scan_block_scalar_indicators(start_mark)
+        self.scan_block_scalar_ignored_line(start_mark)
+
+        # Determine the indentation level and go to the first non-empty line.
+        min_indent = self.indent+1
+        if min_indent < 1:
+            min_indent = 1
+        if increment is None:
+            breaks, max_indent, end_mark = self.scan_block_scalar_indentation()
+            indent = max(min_indent, max_indent)
+        else:
+            indent = min_indent+increment-1
+            breaks, end_mark = self.scan_block_scalar_breaks(indent)
+        line_break = u''
+
+        # Scan the inner part of the block scalar.
+        while self.column == indent and self.peek() != u'\0':
+            chunks.extend(breaks)
+            leading_non_space = self.peek() not in u' \t'
+            length = 0
+            while self.peek(length) not in u'\0\r\n\x85\u2028\u2029':
+                length += 1
+            chunks.append(self.prefix(length))
+            self.forward(length)
+            line_break = self.scan_line_break()
+            breaks, end_mark = self.scan_block_scalar_breaks(indent)
+            if self.column == indent and self.peek() != u'\0':
+
+                # Unfortunately, folding rules are ambiguous.
+                #
+                # This is the folding according to the specification:
+                
+                if folded and line_break == u'\n'   \
+                        and leading_non_space and self.peek() not in u' \t':
+                    if not breaks:
+                        chunks.append(u' ')
+                else:
+                    chunks.append(line_break)
+                
+                # This is Clark Evans's interpretation (also in the spec
+                # examples):
+                #
+                #if folded and line_break == u'\n':
+                #    if not breaks:
+                #        if self.peek() not in ' \t':
+                #            chunks.append(u' ')
+                #        else:
+                #            chunks.append(line_break)
+                #else:
+                #    chunks.append(line_break)
+            else:
+                break
+
+        # Chomp the tail.
+        if chomping is not False:
+            chunks.append(line_break)
+        if chomping is True:
+            chunks.extend(breaks)
+
+        # We are done.
+        return ScalarToken(u''.join(chunks), False, start_mark, end_mark,
+                style)
+
+    def scan_block_scalar_indicators(self, start_mark):
+        # See the specification for details.
+        chomping = None
+        increment = None
+        ch = self.peek()
+        if ch in u'+-':
+            if ch == '+':
+                chomping = True
+            else:
+                chomping = False
+            self.forward()
+            ch = self.peek()
+            if ch in u'0123456789':
+                increment = int(ch)
+                if increment == 0:
+                    raise ScannerError("while scanning a block scalar", start_mark,
+                            "expected indentation indicator in the range 1-9, but found 0",
+                            self.get_mark())
+                self.forward()
+        elif ch in u'0123456789':
+            increment = int(ch)
+            if increment == 0:
+                raise ScannerError("while scanning a block scalar", start_mark,
+                        "expected indentation indicator in the range 1-9, but found 0",
+                        self.get_mark())
+            self.forward()
+            ch = self.peek()
+            if ch in u'+-':
+                if ch == '+':
+                    chomping = True
+                else:
+                    chomping = False
+                self.forward()
+        ch = self.peek()
+        if ch not in u'\0 \r\n\x85\u2028\u2029':
+            raise ScannerError("while scanning a block scalar", start_mark,
+                    "expected chomping or indentation indicators, but found %r"
+                        % ch.encode('utf-8'), self.get_mark())
+        return chomping, increment
+
+    def scan_block_scalar_ignored_line(self, start_mark):
+        # See the specification for details.
+        while self.peek() == u' ':
+            self.forward()
+        if self.peek() == u'#':
+            while self.peek() not in u'\0\r\n\x85\u2028\u2029':
+                self.forward()
+        ch = self.peek()
+        if ch not in u'\0\r\n\x85\u2028\u2029':
+            raise ScannerError("while scanning a block scalar", start_mark,
+                    "expected a comment or a line break, but found %r"
+                        % ch.encode('utf-8'), self.get_mark())
+        self.scan_line_break()
+
+    def scan_block_scalar_indentation(self):
+        # See the specification for details.
+        chunks = []
+        max_indent = 0
+        end_mark = self.get_mark()
+        while self.peek() in u' \r\n\x85\u2028\u2029':
+            if self.peek() != u' ':
+                chunks.append(self.scan_line_break())
+                end_mark = self.get_mark()
+            else:
+                self.forward()
+                if self.column > max_indent:
+                    max_indent = self.column
+        return chunks, max_indent, end_mark
+
+    def scan_block_scalar_breaks(self, indent):
+        # See the specification for details.
+        chunks = []
+        end_mark = self.get_mark()
+        while self.column < indent and self.peek() == u' ':
+            self.forward()
+        while self.peek() in u'\r\n\x85\u2028\u2029':
+            chunks.append(self.scan_line_break())
+            end_mark = self.get_mark()
+            while self.column < indent and self.peek() == u' ':
+                self.forward()
+        return chunks, end_mark
+
+    def scan_flow_scalar(self, style):
+        # See the specification for details.
+        # Note that we loose indentation rules for quoted scalars. Quoted
+        # scalars don't need to adhere indentation because " and ' clearly
+        # mark the beginning and the end of them. Therefore we are less
+        # restrictive then the specification requires. We only need to check
+        # that document separators are not included in scalars.
+        if style == '"':
+            double = True
+        else:
+            double = False
+        chunks = []
+        start_mark = self.get_mark()
+        quote = self.peek()
+        self.forward()
+        chunks.extend(self.scan_flow_scalar_non_spaces(double, start_mark))
+        while self.peek() != quote:
+            chunks.extend(self.scan_flow_scalar_spaces(double, start_mark))
+            chunks.extend(self.scan_flow_scalar_non_spaces(double, start_mark))
+        self.forward()
+        end_mark = self.get_mark()
+        return ScalarToken(u''.join(chunks), False, start_mark, end_mark,
+                style)
+
+    ESCAPE_REPLACEMENTS = {
+        u'0':   u'\0',
+        u'a':   u'\x07',
+        u'b':   u'\x08',
+        u't':   u'\x09',
+        u'\t':  u'\x09',
+        u'n':   u'\x0A',
+        u'v':   u'\x0B',
+        u'f':   u'\x0C',
+        u'r':   u'\x0D',
+        u'e':   u'\x1B',
+        u' ':   u'\x20',
+        u'\"':  u'\"',
+        u'\\':  u'\\',
+        u'N':   u'\x85',
+        u'_':   u'\xA0',
+        u'L':   u'\u2028',
+        u'P':   u'\u2029',
+    }
+
+    ESCAPE_CODES = {
+        u'x':   2,
+        u'u':   4,
+        u'U':   8,
+    }
+
+    def scan_flow_scalar_non_spaces(self, double, start_mark):
+        # See the specification for details.
+        chunks = []
+        while True:
+            length = 0
+            while self.peek(length) not in u'\'\"\\\0 \t\r\n\x85\u2028\u2029':
+                length += 1
+            if length:
+                chunks.append(self.prefix(length))
+                self.forward(length)
+            ch = self.peek()
+            if not double and ch == u'\'' and self.peek(1) == u'\'':
+                chunks.append(u'\'')
+                self.forward(2)
+            elif (double and ch == u'\'') or (not double and ch in u'\"\\'):
+                chunks.append(ch)
+                self.forward()
+            elif double and ch == u'\\':
+                self.forward()
+                ch = self.peek()
+                if ch in self.ESCAPE_REPLACEMENTS:
+                    chunks.append(self.ESCAPE_REPLACEMENTS[ch])
+                    self.forward()
+                elif ch in self.ESCAPE_CODES:
+                    length = self.ESCAPE_CODES[ch]
+                    self.forward()
+                    for k in range(length):
+                        if self.peek(k) not in u'0123456789ABCDEFabcdef':
+                            raise ScannerError("while scanning a double-quoted scalar", start_mark,
+                                    "expected escape sequence of %d hexdecimal numbers, but found %r" %
+                                        (length, self.peek(k).encode('utf-8')), self.get_mark())
+                    code = int(self.prefix(length), 16)
+                    chunks.append(unichr(code))
+                    self.forward(length)
+                elif ch in u'\r\n\x85\u2028\u2029':
+                    self.scan_line_break()
+                    chunks.extend(self.scan_flow_scalar_breaks(double, start_mark))
+                else:
+                    raise ScannerError("while scanning a double-quoted scalar", start_mark,
+                            "found unknown escape character %r" % ch.encode('utf-8'), self.get_mark())
+            else:
+                return chunks
+
+    def scan_flow_scalar_spaces(self, double, start_mark):
+        # See the specification for details.
+        chunks = []
+        length = 0
+        while self.peek(length) in u' \t':
+            length += 1
+        whitespaces = self.prefix(length)
+        self.forward(length)
+        ch = self.peek()
+        if ch == u'\0':
+            raise ScannerError("while scanning a quoted scalar", start_mark,
+                    "found unexpected end of stream", self.get_mark())
+        elif ch in u'\r\n\x85\u2028\u2029':
+            line_break = self.scan_line_break()
+            breaks = self.scan_flow_scalar_breaks(double, start_mark)
+            if line_break != u'\n':
+                chunks.append(line_break)
+            elif not breaks:
+                chunks.append(u' ')
+            chunks.extend(breaks)
+        else:
+            chunks.append(whitespaces)
+        return chunks
+
+    def scan_flow_scalar_breaks(self, double, start_mark):
+        # See the specification for details.
+        chunks = []
+        while True:
+            # Instead of checking indentation, we check for document
+            # separators.
+            prefix = self.prefix(3)
+            if (prefix == u'---' or prefix == u'...')   \
+                    and self.peek(3) in u'\0 \t\r\n\x85\u2028\u2029':
+                raise ScannerError("while scanning a quoted scalar", start_mark,
+                        "found unexpected document separator", self.get_mark())
+            while self.peek() in u' \t':
+                self.forward()
+            if self.peek() in u'\r\n\x85\u2028\u2029':
+                chunks.append(self.scan_line_break())
+            else:
+                return chunks
+
+    def scan_plain(self):
+        # See the specification for details.
+        # We add an additional restriction for the flow context:
+        #   plain scalars in the flow context cannot contain ',', ':' and '?'.
+        # We also keep track of the `allow_simple_key` flag here.
+        # Indentation rules are loosed for the flow context.
+        chunks = []
+        start_mark = self.get_mark()
+        end_mark = start_mark
+        indent = self.indent+1
+        # We allow zero indentation for scalars, but then we need to check for
+        # document separators at the beginning of the line.
+        #if indent == 0:
+        #    indent = 1
+        spaces = []
+        while True:
+            length = 0
+            if self.peek() == u'#':
+                break
+            while True:
+                ch = self.peek(length)
+                if ch in u'\0 \t\r\n\x85\u2028\u2029'   \
+                        or (not self.flow_level and ch == u':' and
+                                self.peek(length+1) in u'\0 \t\r\n\x85\u2028\u2029') \
+                        or (self.flow_level and ch in u',:?[]{}'):
+                    break
+                length += 1
+            # It's not clear what we should do with ':' in the flow context.
+            if (self.flow_level and ch == u':'
+                    and self.peek(length+1) not in u'\0 \t\r\n\x85\u2028\u2029,[]{}'):
+                self.forward(length)
+                raise ScannerError("while scanning a plain scalar", start_mark,
+                    "found unexpected ':'", self.get_mark(),
+                    "Please check http://pyyaml.org/wiki/YAMLColonInFlowContext for details.")
+            if length == 0:
+                break
+            self.allow_simple_key = False
+            chunks.extend(spaces)
+            chunks.append(self.prefix(length))
+            self.forward(length)
+            end_mark = self.get_mark()
+            spaces = self.scan_plain_spaces(indent, start_mark)
+            if not spaces or self.peek() == u'#' \
+                    or (not self.flow_level and self.column < indent):
+                break
+        return ScalarToken(u''.join(chunks), True, start_mark, end_mark)
+
+    def scan_plain_spaces(self, indent, start_mark):
+        # See the specification for details.
+        # The specification is really confusing about tabs in plain scalars.
+        # We just forbid them completely. Do not use tabs in YAML!
+        chunks = []
+        length = 0
+        while self.peek(length) in u' ':
+            length += 1
+        whitespaces = self.prefix(length)
+        self.forward(length)
+        ch = self.peek()
+        if ch in u'\r\n\x85\u2028\u2029':
+            line_break = self.scan_line_break()
+            self.allow_simple_key = True
+            prefix = self.prefix(3)
+            if (prefix == u'---' or prefix == u'...')   \
+                    and self.peek(3) in u'\0 \t\r\n\x85\u2028\u2029':
+                return
+            breaks = []
+            while self.peek() in u' \r\n\x85\u2028\u2029':
+                if self.peek() == ' ':
+                    self.forward()
+                else:
+                    breaks.append(self.scan_line_break())
+                    prefix = self.prefix(3)
+                    if (prefix == u'---' or prefix == u'...')   \
+                            and self.peek(3) in u'\0 \t\r\n\x85\u2028\u2029':
+                        return
+            if line_break != u'\n':
+                chunks.append(line_break)
+            elif not breaks:
+                chunks.append(u' ')
+            chunks.extend(breaks)
+        elif whitespaces:
+            chunks.append(whitespaces)
+        return chunks
+
+    def scan_tag_handle(self, name, start_mark):
+        # See the specification for details.
+        # For some strange reasons, the specification does not allow '_' in
+        # tag handles. I have allowed it anyway.
+        ch = self.peek()
+        if ch != u'!':
+            raise ScannerError("while scanning a %s" % name, start_mark,
+                    "expected '!', but found %r" % ch.encode('utf-8'),
+                    self.get_mark())
+        length = 1
+        ch = self.peek(length)
+        if ch != u' ':
+            while u'0' <= ch <= u'9' or u'A' <= ch <= 'Z' or u'a' <= ch <= 'z'  \
+                    or ch in u'-_':
+                length += 1
+                ch = self.peek(length)
+            if ch != u'!':
+                self.forward(length)
+                raise ScannerError("while scanning a %s" % name, start_mark,
+                        "expected '!', but found %r" % ch.encode('utf-8'),
+                        self.get_mark())
+            length += 1
+        value = self.prefix(length)
+        self.forward(length)
+        return value
+
+    def scan_tag_uri(self, name, start_mark):
+        # See the specification for details.
+        # Note: we do not check if URI is well-formed.
+        chunks = []
+        length = 0
+        ch = self.peek(length)
+        while u'0' <= ch <= u'9' or u'A' <= ch <= 'Z' or u'a' <= ch <= 'z'  \
+                or ch in u'-;/?:@&=+$,_.!~*\'()[]%':
+            if ch == u'%':
+                chunks.append(self.prefix(length))
+                self.forward(length)
+                length = 0
+                chunks.append(self.scan_uri_escapes(name, start_mark))
+            else:
+                length += 1
+            ch = self.peek(length)
+        if length:
+            chunks.append(self.prefix(length))
+            self.forward(length)
+            length = 0
+        if not chunks:
+            raise ScannerError("while parsing a %s" % name, start_mark,
+                    "expected URI, but found %r" % ch.encode('utf-8'),
+                    self.get_mark())
+        return u''.join(chunks)
+
+    def scan_uri_escapes(self, name, start_mark):
+        # See the specification for details.
+        bytes = []
+        mark = self.get_mark()
+        while self.peek() == u'%':
+            self.forward()
+            for k in range(2):
+                if self.peek(k) not in u'0123456789ABCDEFabcdef':
+                    raise ScannerError("while scanning a %s" % name, start_mark,
+                            "expected URI escape sequence of 2 hexdecimal numbers, but found %r" %
+                                (self.peek(k).encode('utf-8')), self.get_mark())
+            bytes.append(chr(int(self.prefix(2), 16)))
+            self.forward(2)
+        try:
+            value = unicode(''.join(bytes), 'utf-8')
+        except UnicodeDecodeError, exc:
+            raise ScannerError("while scanning a %s" % name, start_mark, str(exc), mark)
+        return value
+
+    def scan_line_break(self):
+        # Transforms:
+        #   '\r\n'      :   '\n'
+        #   '\r'        :   '\n'
+        #   '\n'        :   '\n'
+        #   '\x85'      :   '\n'
+        #   '\u2028'    :   '\u2028'
+        #   '\u2029     :   '\u2029'
+        #   default     :   ''
+        ch = self.peek()
+        if ch in u'\r\n\x85':
+            if self.prefix(2) == u'\r\n':
+                self.forward(2)
+            else:
+                self.forward()
+            return u'\n'
+        elif ch in u'\u2028\u2029':
+            self.forward()
+            return ch
+        return u''
+
+#try:
+#    import psyco
+#    psyco.bind(Scanner)
+#except ImportError:
+#    pass
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/yaml/serializer.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/yaml/serializer.py b/tools/bin/ext/yaml/serializer.py
new file mode 100644
index 0000000..eb70372
--- /dev/null
+++ b/tools/bin/ext/yaml/serializer.py
@@ -0,0 +1,127 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+__all__ = ['Serializer', 'SerializerError']
+
+from error import YAMLError
+from events import *
+from nodes import *
+
+class SerializerError(YAMLError):
+    pass
+
+class Serializer(object):
+
+    ANCHOR_TEMPLATE = u'id%03d'
+
+    def __init__(self, encoding=None,
+            explicit_start=None, explicit_end=None, version=None, tags=None):
+        self.use_encoding = encoding
+        self.use_explicit_start = explicit_start
+        self.use_explicit_end = explicit_end
+        self.use_version = version
+        self.use_tags = tags
+        self.serialized_nodes = {}
+        self.anchors = {}
+        self.last_anchor_id = 0
+        self.closed = None
+
+    def open(self):
+        if self.closed is None:
+            self.emit(StreamStartEvent(encoding=self.use_encoding))
+            self.closed = False
+        elif self.closed:
+            raise SerializerError("serializer is closed")
+        else:
+            raise SerializerError("serializer is already opened")
+
+    def close(self):
+        if self.closed is None:
+            raise SerializerError("serializer is not opened")
+        elif not self.closed:
+            self.emit(StreamEndEvent())
+            self.closed = True
+
+    #def __del__(self):
+    #    self.close()
+
+    def serialize(self, node):
+        if self.closed is None:
+            raise SerializerError("serializer is not opened")
+        elif self.closed:
+            raise SerializerError("serializer is closed")
+        self.emit(DocumentStartEvent(explicit=self.use_explicit_start,
+            version=self.use_version, tags=self.use_tags))
+        self.anchor_node(node)
+        self.serialize_node(node, None, None)
+        self.emit(DocumentEndEvent(explicit=self.use_explicit_end))
+        self.serialized_nodes = {}
+        self.anchors = {}
+        self.last_alias_id = 0
+
+    def anchor_node(self, node):
+        if node in self.anchors:
+            if self.anchors[node] is None:
+                self.anchors[node] = self.generate_anchor(node)
+        else:
+            self.anchors[node] = None
+            if isinstance(node, SequenceNode):
+                for item in node.value:
+                    self.anchor_node(item)
+            elif isinstance(node, MappingNode):
+                for key, value in node.value:
+                    self.anchor_node(key)
+                    self.anchor_node(value)
+
+    def generate_anchor(self, node):
+        self.last_anchor_id += 1
+        return self.ANCHOR_TEMPLATE % self.last_anchor_id
+
+    def serialize_node(self, node, parent, index):
+        alias = self.anchors[node]
+        if node in self.serialized_nodes:
+            self.emit(AliasEvent(alias))
+        else:
+            self.serialized_nodes[node] = True
+            self.descend_resolver(parent, index)
+            if isinstance(node, ScalarNode):
+                detected_tag = self.resolve(ScalarNode, node.value, (True, False))
+                default_tag = self.resolve(ScalarNode, node.value, (False, True))
+                implicit = (node.tag == detected_tag), (node.tag == default_tag)
+                self.emit(ScalarEvent(alias, node.tag, implicit, node.value,
+                    style=node.style))
+            elif isinstance(node, SequenceNode):
+                implicit = (node.tag
+                            == self.resolve(SequenceNode, node.value, True))
+                self.emit(SequenceStartEvent(alias, node.tag, implicit,
+                    flow_style=node.flow_style))
+                index = 0
+                for item in node.value:
+                    self.serialize_node(item, node, index)
+                    index += 1
+                self.emit(SequenceEndEvent())
+            elif isinstance(node, MappingNode):
+                implicit = (node.tag
+                            == self.resolve(MappingNode, node.value, True))
+                self.emit(MappingStartEvent(alias, node.tag, implicit,
+                    flow_style=node.flow_style))
+                for key, value in node.value:
+                    self.serialize_node(key, node, None)
+                    self.serialize_node(value, node, key)
+                self.emit(MappingEndEvent())
+            self.ascend_resolver()
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/ext/yaml/tokens.py
----------------------------------------------------------------------
diff --git a/tools/bin/ext/yaml/tokens.py b/tools/bin/ext/yaml/tokens.py
new file mode 100644
index 0000000..41ee0fb
--- /dev/null
+++ b/tools/bin/ext/yaml/tokens.py
@@ -0,0 +1,120 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class Token(object):
+    def __init__(self, start_mark, end_mark):
+        self.start_mark = start_mark
+        self.end_mark = end_mark
+    def __repr__(self):
+        attributes = [key for key in self.__dict__
+                if not key.endswith('_mark')]
+        attributes.sort()
+        arguments = ', '.join(['%s=%r' % (key, getattr(self, key))
+                for key in attributes])
+        return '%s(%s)' % (self.__class__.__name__, arguments)
+
+#class BOMToken(Token):
+#    id = '<byte order mark>'
+
+class DirectiveToken(Token):
+    id = '<directive>'
+    def __init__(self, name, value, start_mark, end_mark):
+        self.name = name
+        self.value = value
+        self.start_mark = start_mark
+        self.end_mark = end_mark
+
+class DocumentStartToken(Token):
+    id = '<document start>'
+
+class DocumentEndToken(Token):
+    id = '<document end>'
+
+class StreamStartToken(Token):
+    id = '<stream start>'
+    def __init__(self, start_mark=None, end_mark=None,
+            encoding=None):
+        self.start_mark = start_mark
+        self.end_mark = end_mark
+        self.encoding = encoding
+
+class StreamEndToken(Token):
+    id = '<stream end>'
+
+class BlockSequenceStartToken(Token):
+    id = '<block sequence start>'
+
+class BlockMappingStartToken(Token):
+    id = '<block mapping start>'
+
+class BlockEndToken(Token):
+    id = '<block end>'
+
+class FlowSequenceStartToken(Token):
+    id = '['
+
+class FlowMappingStartToken(Token):
+    id = '{'
+
+class FlowSequenceEndToken(Token):
+    id = ']'
+
+class FlowMappingEndToken(Token):
+    id = '}'
+
+class KeyToken(Token):
+    id = '?'
+
+class ValueToken(Token):
+    id = ':'
+
+class BlockEntryToken(Token):
+    id = '-'
+
+class FlowEntryToken(Token):
+    id = ','
+
+class AliasToken(Token):
+    id = '<alias>'
+    def __init__(self, value, start_mark, end_mark):
+        self.value = value
+        self.start_mark = start_mark
+        self.end_mark = end_mark
+
+class AnchorToken(Token):
+    id = '<anchor>'
+    def __init__(self, value, start_mark, end_mark):
+        self.value = value
+        self.start_mark = start_mark
+        self.end_mark = end_mark
+
+class TagToken(Token):
+    id = '<tag>'
+    def __init__(self, value, start_mark, end_mark):
+        self.value = value
+        self.start_mark = start_mark
+        self.end_mark = end_mark
+
+class ScalarToken(Token):
+    id = '<scalar>'
+    def __init__(self, value, plain, start_mark, end_mark, style=None):
+        self.value = value
+        self.plain = plain
+        self.start_mark = start_mark
+        self.end_mark = end_mark
+        self.style = style
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/DESIGN
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/DESIGN b/tools/bin/pythonSrc/PSI-0.3b2_gp/DESIGN
new file mode 100644
index 0000000..7ee2628
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/DESIGN
@@ -0,0 +1,95 @@
+Design of PSI
+=============
+
+
+The C code of psi is split in two: (i) The Python modules and classes
+in src/ and (ii) the architecture or system dependent implementations
+that gather the required information in src/arch/.  These two parts
+communicate all the required information to each other using
+structures, i.e. each class will make a call to an arch_*() function
+that will return a new structure with all the required information in
+for that class.
+
+The reason for doing this is to shield the system implementations
+from any Python housekeeping like reference counting.  It is hoped
+that this greatly simplifies creating implementations (porting) and
+reduces the risk of hidden memory leaks etc.  There is one exception
+on this: error handling.  Error handling is done exactly as in Python,
+i.e. you set an exception using PyErr_*(PyExc_*, ...) and then return
+NULL or -1 as appropriate.  Therefore whenever a function returns NULL
+or -1 you can be assured an exception is set and you need to bail out
+too.
+
+An implication of using structures to communicate between different
+parts of the application is that the system implementations will have
+to allocate some things like strings etc.  For this reason there are
+utility functions that should always be used for memory management
+purposes: psi_malloc(), psi_calloc(), psi_realloc() and psi_free(),
+all defined in psi.h.  There are also more convenience functions
+available in psi.h, you should definitely read this file.
+
+Lastly the contents of the structures is important.  They are defined
+in the relevant header files and should have types who's size can be
+determined at compilation time to ensure that the classes and modules
+will be able to convert them to the appropriate Python types (and if
+not the compiler should complain).
+
+
+Exceptions
+----------
+
+At Process() initialisation time only two exceptions should be raised:
+(i) NoSuchProcessError if the process does not exist, (ii) OSError if
+something went wrong.  If a psi_*() function returns a negative number
+an OSError has been raised and you can use the errno attribute of the
+exception if present to fine-tune behaviour based on the context.  Some
+functions might try and help you with this fine-tuning by returning a
+specific negative value (other then -1) which indicates a certain
+class of errors (cf. psi_read_file() and psi_readlink()).
+
+XXX Flesh this out a bit and integrate it better where it belongs
+    instead of just being a random paragraph.
+
+
+Modules, APIs and Platforms
+---------------------------
+
+PSI supports many platforms and has several modules.  While we try to
+keep all APIs of all modules stable and fully implemented on all
+platforms this is not always possible.  But each module must compile
+on all platforms, this is easier than it sounds: chances are you will
+manage even if you don't have each platform available.  Since the
+platform depended implementation is always done via some psi_arch_*()
+functions (or sometimes just arch_*()) it is quite trivial to write
+stubs that will raise a NotImplementedError for all platforms.
+
+This technique also simplifies the source declaration in setup.py.  By
+having each feature in <plat>_<feature>.c files
+(e.g. ``linux_process.c``) the module declaration in setup.py can just
+do ``'src/arch/%s_foo.c' % PLATFORM`` for the "foo" feature.  If two
+platforms can share an implementation for "foo" it is then easiest for
+the <arch>_foo.c files to be skeletons using functions from the common
+implementation, e.g.::
+
+  foo_sources = ['src/util.c',
+                 'src/foomodule.c',
+                 'src/arch/%s_foo.c' % PLATFORM]
+  if PLATFORM in ['linux', 'darwin']:
+      foo_sources.append('src/arch/shared_foo_impl.c')
+
+
+C Coding Standard
+-----------------
+
+* PEP7
+
+* Functions follow the Python convention of returning -1 or NULL in
+  case of an error, in case of an error a Python exception is set.
+  Testing if an `int' function was successful is best done as `if
+  (some_function() < 0)' since some functions might add specific
+  meanings to errors by returning a value smaller then -1
+  (e.g. psi_read_file()).
+
+* Always include <Python.h> first.  Even if nothing of python is used,
+  it defines _POSIX_C_SOURCE and _XOPEN_SOURCE for us which are
+  required for POSIX compliance.

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/GREENPLUM_README
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/GREENPLUM_README b/tools/bin/pythonSrc/PSI-0.3b2_gp/GREENPLUM_README
new file mode 100644
index 0000000..2fe4880
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/GREENPLUM_README
@@ -0,0 +1 @@
+patched with this fix: http://bitbucket.org/chrismiles/psi/changeset/bf3e487a5107/

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/LICENSE
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/LICENSE b/tools/bin/pythonSrc/PSI-0.3b2_gp/LICENSE
new file mode 100644
index 0000000..6ffa900
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/LICENSE
@@ -0,0 +1,26 @@
+The MIT License
+
+Copyright (C) 2007 Chris Miles
+
+Copyright (C) 2008-2009 Floris Bruynooghe
+
+Copyright (C) 2008-2009 Abilisoft Ltd.
+
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/MANIFEST
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/MANIFEST b/tools/bin/pythonSrc/PSI-0.3b2_gp/MANIFEST
new file mode 100644
index 0000000..32043f0
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/MANIFEST
@@ -0,0 +1,61 @@
+DESIGN
+LICENSE
+MANIFEST
+README
+TODO
+setup.py
+examples/process_details.py
+include/arch.h
+include/linux_utils.h
+include/mount.h
+include/posix_mount.h
+include/posix_utils.h
+include/process.h
+include/procfs_utils.h
+include/psi.h
+include/psifuncs.h
+misc/mem_test.py
+misc/mktests.sh
+misc/valgrind-python.supp
+psi/__init__.py
+psi/_version.py
+src/_psimodule.c
+src/arch.c
+src/archmodule.c
+src/mount.c
+src/mountmodule.c
+src/process.c
+src/processmodule.c
+src/processtable.c
+src/timespec.c
+src/util.c
+src/arch/aix_mount.c
+src/arch/aix_process.c
+src/arch/aix_psi.c
+src/arch/darwin_mount.c
+src/arch/darwin_process.c
+src/arch/darwin_processtable.c
+src/arch/darwin_psi.c
+src/arch/getloadavg.c
+src/arch/linux_mount.c
+src/arch/linux_process.c
+src/arch/linux_psi.c
+src/arch/linux_utils.c
+src/arch/posix_arch.c
+src/arch/posix_mount.c
+src/arch/posix_utils.c
+src/arch/procfs_processtable.c
+src/arch/procfs_utils.c
+src/arch/sargs64.c
+src/arch/sunos_mount.c
+src/arch/sunos_process.c
+src/arch/sunos_psi.c
+tests/_psi_test.py
+tests/aixapp.c
+tests/app.c
+tests/apphelper.py
+tests/arch_test.py
+tests/mount_test.py
+tests/process_test.py
+tests/processtable_test.py
+tests/timespec_test.py

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/PKG-INFO
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/PKG-INFO b/tools/bin/pythonSrc/PSI-0.3b2_gp/PKG-INFO
new file mode 100644
index 0000000..f734d64
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/PKG-INFO
@@ -0,0 +1,129 @@
+Metadata-Version: 1.0
+Name: PSI
+Version: 0.3b2
+Summary: Python System Information
+Home-page: http://bitbucket.org/chrismiles/psi
+Author: Chris Miles, Floris Bruynooghe, Erick Tryzelaar
+Author-email: psi-discuss@googlegroups.com
+License: MIT
+Download-URL: http://pypi.python.org/pypi/PSI/
+Description: 
+        -------------------------
+        Python System Information
+        -------------------------
+        
+        ``psi`` is a Python module providing direct access to real-time system
+        and process information.  It is made of of several sub-modules.
+        
+        The ``arch`` module gives some information about the system such as
+        the sytem name and version, the machine architecture etc.  It has a
+        class representing each system and a factory function that will return
+        an instance of the class which ``psi`` is running on currently.
+        
+        The experimental ``mount`` module gives information about the various
+        mounted filesystems on the system.  It has a class representing local
+        or remote filesystems.
+        
+        The ``process`` module provides an interface to information about
+        processes currently running on the system.  Each process is
+        represented as an instance of the ``Process`` class and additionally
+        there is a ``ProcessTable`` class which is a dictionary of all running
+        processes.  To know exactly what attributes are available and what
+        they mean you should look at the docstrings and examples in the
+        ``REAME`` file and ``examples/`` directory, but important to note is
+        that all the information is collected at instatiation time.  So the
+        contents of ``ProcessTable`` and ``Process`` instances are really
+        snapshots and will still contain all information even after the actual
+        process has gone.
+        
+        Lastly there are some general functions available directly under the
+        ``psi`` namespace such as ``loadavg()``, ``getzoneid()`` etc.  Once
+        more see the docstrings for detailed information.
+        
+        Some information may not be available on all platforms, rather then
+        trying to emulate this information these parts of the API just don't
+        exist on those platforms.  Examples of these are:
+        ``psi.process.Process.pcpu`` which is not available on Linux,
+        ``psi.getzoneid()`` which is only available on SunOS 10 and above etc.
+        
+        
+        Supported Platforms
+        ===================
+        
+        Python: 2.2 and above, including 3.x.
+        
+        Linux: all 2.4 and 2.6 kernels.
+        
+        SunOS: Solaris 8 and above, including OpenSolaris (SunOS 11).
+        
+        AIX: 5.3
+        
+        Darwin: 10.3 and above.
+        
+        
+        Documentation
+        =============
+        
+        Care is taken to provide complete and accurate docstrings, so use
+        Python's ``pydoc`` tool and the interactive prompt should get you on
+        your way.
+        
+        We also have a wiki (http://bitbucket.org/chrismiles/psi/wiki/Home)
+        and a mailing list (http://groups.google.com/group/psi-discuss
+        psi-discuss@googlegroups.com).  Don't hesitate to ask questions or
+        give feedback.
+        
+        
+        Bugs
+        ====
+        
+        Please use our issue tracker:
+        http://bitbucket.org/chrismiles/psi/issues
+        
+        
+        Extra setup.py features
+        =======================
+        
+        New ``build_ext`` option: ``--devel``.  This uses ``-Werror`` and
+        enables many more warnings as well as disables optimisation.
+        
+        Using ``--undef PYMALLOC`` or ``-U PYMALLOC`` to ``build_ext`` will
+        use libc's memory heap for allocation instead of Python's.
+        
+        
+        The ``test`` command will run the testsuite.  Some tests will only be
+        run when running the test suite as root.  Currently these are the
+        tests that try to run a simple test application under specific
+        schedulers and priorities to assert psi detects these process
+        attributes correctly.
+        
+        
+        The ``valgrind`` command does run the testsuite under the valgrind
+        memory checker.  For this you need to have a specially compiled
+        python::
+        
+        ./configure --with-pydebug --without-pymalloc --prefix=/opt/pydebug
+        make
+        make install
+        
+        
+        The ``tags`` command will build an emacs TAGS file using ``grind``
+        (which is a binary of the python grin_ package).
+        
+        .. _grin: http://pypi.python.org/pypi/grin
+        
+Platform: UNKNOWN
+Classifier: Development Status :: 4 - Beta
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Intended Audience :: Developers
+Classifier: Operating System :: MacOS :: MacOS X
+Classifier: Operating System :: POSIX :: AIX
+Classifier: Operating System :: POSIX :: Linux
+Classifier: Operating System :: POSIX :: SunOS/Solaris
+Classifier: Programming Language :: C
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 3
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
+Classifier: Topic :: System :: Operating System Kernels
+Classifier: Topic :: System :: Systems Administration

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/README
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/README b/tools/bin/pythonSrc/PSI-0.3b2_gp/README
new file mode 100644
index 0000000..139229e
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/README
@@ -0,0 +1,281 @@
+===============================
+PSI - Python System Information
+===============================
+
+Overview
+========
+
+PSI is a Python module providing direct access to real-time system and
+process information.  It is made up of several sub-modules.
+
+The ``arch`` module gives some information about the system such as the
+system name and version, the machine architecture etc.  It has a class
+representing each system and a factory function that will return an
+instance of the class which psi is running on currently.
+
+The ``process`` module provides an interface to information about
+processes currently running on the system.  Each process is
+represented as an instance of the Process class and additionally there
+is a ProcessTable class which is a dictionary of all running
+processes.  To know exactly what attributes are available and what
+they mean you should look at the docstrings and examples below but
+important to note is that all the information is collected at
+instantiation time.  So the contents of ProcessTable and Process
+instances are really snapshots and will still contain all information
+even after the actual process has gone.
+
+Lastly there are some general functions available directly under the
+``psi`` namespace such as ``loadavg()``, ``getzoneid()`` etc.  Once
+more see the docstrings for detailed information.
+
+Some information may not be available on all platforms, rather then
+trying to emulate this information these parts of the API just don't
+exists on those platforms.  Examples of these are:
+``psi.process.Process.pcpu`` which is not available on Linux,
+``psi.getzoneid()`` which is only available on SunOS 10 and above etc.
+If not all information can be found some attribute descriptors of
+objects might return subclasses of AttributeError, allowing you to use
+generic ``getattr()`` semantics as well as more specifically detect why
+an attribute is not available (insufficient privileges, not
+implemented, ...).
+
+
+Install
+=======
+
+You need to check if it's supported on your platform, check the
+docstring of setup.py for the exact supported platforms.
+
+You will also need a working C compiler and the python development
+files.  If a system is not supported yet the build will fail.  After
+building it is best to run the test suite, on some platforms not all
+tests will pass yet and you would rather know of these problems before
+starting to use PSI.
+
+So to fully install PSI from source::
+
+  $ python setup.py build
+  $ python setup.py test [--all]
+  $ python setup.py install [<your options>]
+
+See the Python documentation on installing Python module for more
+control: http://docs.python.org/install/index.html
+
+
+Here a rough list of packages you will need for some popular GNU/Linux
+distributions, this should give you an idea of what is needed.
+
+Debian/Ubuntu:
+
+ - python
+ - python-dev
+ - gcc
+
+Redhat/CentOS:
+
+ - python
+ - python-devel
+ - gcc
+
+
+
+Limitations
+===========
+
+Solaris
+-------
+
+If the module is compiled as 32-bit (which is what will usually happen
+since that tends to be how python is compiled) it will use the ILP32
+model and will not be able to read the address space of 64-bit
+processes as they use the LP64 model.  This means that the full
+argument list and the environment dictionary will not be available.
+The partial argument list can still be retrieved from the
+``psi.process.Process.command`` attribute.
+
+
+Unit Tests
+==========
+
+To run the unit tests::
+
+  $ python setup.py test [--all]
+
+The --all option will run tests that require superuser privileges,
+this is required to run some test applications under specific
+schedulers and priorities to test if psi does detect these correctly.
+To acquire superuser privileges sudo is used when available, falling
+back to "su -c".
+
+If any tests fail, please copy & paste the output and send operating
+system version, python version, python executable format (32/64-bit)
+and any other applicable details to the mailing list
+(psi-discuss@googlegroups.com).
+
+
+Examples
+========
+
+Examples are the best documentation.  :-)
+
+::
+
+  Python 2.5.2 (r252:60911, Oct  5 2008, 19:24:49)
+  [GCC 4.3.2] on linux2
+  Type "help", "copyright", "credits" or "license" for more information.
+  >>> import psi
+  >>>
+  >>> a = psi.arch.arch_type()
+  >>> a
+  psi.arch.ArchLinux()
+  >>> isinstance(a, psi.arch.ArchLinux)
+  True
+  >>> isinstance(a, psi.arch.ArchSunOS)
+  False
+  >>> a.sysname
+  'Linux'
+  >>> a.nodename
+  'signy'
+  >>> a.release
+  '2.6.27-9-generic'
+  >>> a.release_info
+  (2L, 6L, 26L)
+  >>> a.version
+  '#1 SMP Thu Nov 20 21:57:00 UTC 2008'
+  >>> a.machine
+  'i686'
+  >>>
+  >>> psi.loadavg()
+  (0.059999999999999998, 0.13, 0.13)
+  >>>
+  >>> import os
+  >>> mypid = os.getpid()
+  >>> mypid
+  21374
+  >>> p = psi.process.Process(mypid)
+  >>> p.args
+  ('python',)
+  >>> p.exe
+  '/usr/bin/python2.5'
+  >>> p.uid
+  1000
+  >>> import pwd
+  >>> pwd.getpwuid(p.uid)
+  pwd.struct_passwd(pw_name='flub', pw_passwd='x', pw_uid=1000,
+  pw_gid=1000, pw_gecos='Floris Bruynooghe,,,', pw_dir='/home/flub',
+  pw_shell='/bin/bash')
+  >>> p.start_time
+  datetime.datetime(2009, 5, 11, 20, 4, 31, 709993)
+  >>> help(psi.process.Process.start_time)
+  Help on getset descriptor psi.process.Process.start_time:
+
+  start_time
+    Start time of process as datetime.datetime object
+
+    Use .strftime('%s') to get seconds since epoch
+  >>> p.ppid
+  21304L
+  >>> parent = psi.process.Process(pid=p.ppid)
+  >>> parent.args
+  ('bash',)
+  >>> p.rss
+  2293L
+  >>>
+  >>> pt = psi.process.ProcessTable()
+  >>> len(pt)
+  145
+  >>> pt.keys()
+  [1L, 2L, 3L, 4L, 5L, 6L, 7L, 6152L, 5660L, 6687L, 4648L, 5674L,
+  5639L, 6834L, 46L, 48L, 50L, 51L, 5684L, 1081L, 2621L, 5184L, 6276L,
+  2627L, 6217L, 6220L, 6221L, 4877L, 6224L, 6227L, 6229L, 6235L,
+  6757L, 5729L, 6244L, 2149L, 6246L, 2152L, 2153L, 6763L, 6764L,
+  6254L, 6248L, 6259L, 5749L, 2166L, 6249L, 2169L, 5242L, 2683L,
+  6781L, 6273L, 6274L, 4740L, 6278L, 6279L, 5772L, 5776L, 6290L,
+  5779L, 5268L, 6296L, 6809L, 156L, 157L, 158L, 6341L, 6307L, 2212L,
+  6257L, 20654L, 6856L, 4786L, 4788L, 5814L, 5817L, 6263L, 5821L,
+  6261L, 6336L, 4811L, 118L, 200L, 1739L, 5837L, 1742L, 1743L, 6349L,
+  20693L, 6265L, 5852L, 122L, 4833L, 4834L, 1253L, 2793L, 1258L,
+  6382L, 21374L, 6393L, 5885L, 1278L, 5376L, 6401L, 5675L, 1290L,
+  1293L, 6445L, 5397L, 6262L, 5913L, 4385L, 4386L, 4392L, 4393L,
+  4394L, 1074L, 6449L, 5426L, 6456L, 6458L, 5951L, 19779L, 5963L,
+  5964L, 21327L, 21304L, 5466L, 4955L, 4444L, 2404L, 5501L, 6526L,
+  4992L, 4993L, 6032L, 6572L, 6442L, 5573L, 5576L, 2794L, 17357L,
+  4054L, 6397L, 6136L]
+  >>> q = pt[6856]
+  >>> q.args
+  ('emacs22-gtk',)
+  >>> q.env
+  {'GNOME_DESKTOP_SESSION_ID': 'this-is-deprecated', 'LOGNAME':
+  'flub', 'USER': 'flub', 'HOME': '/home/flub', 'PATH':
+  '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games',
+  'DISPLAY': ':0.0', 'SSH_AGENT_PID': '6217', 'LANG': 'en_GB.UTF-8',
+  'SHELL': '/bin/bash', 'XDG_SESSION_COOKIE':
+  '26100f517aa94dec0dc7b4aa494948ea-1231927234.615881-1120709651',
+  'SESSION_MANAGER': 'local/signy:/tmp/.ICE-unix/6152',
+  'XDG_DATA_DIRS': '/usr/local/share/:/usr/share/:/usr/share/gdm/',
+  'WINDOWPATH': '7', 'GPG_AGENT_INFO':
+  '/tmp/seahorse-SWS6qW/S.gpg-agent:6235:1', 'USERNAME': 'flub',
+  'GDM_XSERVER_LOCATION': 'local', 'SSH_AUTH_SOCK':
+  '/tmp/keyring-AStyaD/ssh', 'DESKTOP_SESSION': 'gnome', 'GDMSESSION':
+  'gnome', 'DBUS_SESSION_BUS_ADDRESS':
+  'unix:abstract=/tmp/dbus-HFM6sYANYS,guid=916b5b81c03bda327eaaa293496db7c5',
+  'ORBIT_SOCKETDIR': '/tmp/orbit-flub', 'XAUTHORITY':
+  '/home/flub/.Xauthority', 'GNOME_KEYRING_SOCKET':
+  '/tmp/keyring-AStyaD/socket', 'GNOME_KEYRING_PID': '6246\n',
+  'GDM_LANG': 'en_GB.UTF-8', 'PWD': '/home/flub', 'GTK_RC_FILES':
+  '/etc/gtk/gtkrc:/home/flub/.gtkrc-1.2-gnome2'}
+  >>>
+  >>> r = []
+  >>> for pp in pt.values():
+  ...     if pp.args and 'evolution' in pp.args[0]:
+  ...         r.append(pp)
+  ...
+  >>> r
+  [psi.process.Process(pid=6336), psi.process.Process(pid=6572),
+  psi.process.Process(pid=6397)]
+  >>> for pp in r:
+  ...     print ' '.join(pp.args)
+  ...
+  /usr/lib/evolution/2.24/evolution-exchange-storage --oaf-activate-iid=OAFIID:GNOME_Evolution_Exchange_Connector_CalFactory:1.2 --oaf-ior-fd=22
+  evolution
+  /usr/lib/evolution/evolution-data-server-2.24 --oaf-activate-iid=OAFIID:GNOME_Evolution_DataServer_CalFactory:1.2 --oaf-ior-fd=23
+  >>>
+  >>> init = psi.process.Process(1)
+  >>> init.env
+  Traceback (most recent call last):
+    File "<stdin>", line 1, in <module>
+  psi.InsufficientPrivsError: Insufficient privileges for Process.env
+  >>>
+
+Some sample scripts are also available in the examples/ subdirectory.
+
+
+Development
+===========
+
+You should definitely read the DESIGN file, it will explain the ideas
+behind how the code is structured and how you should extend it.  Also
+very useful is the TODO file and the wiki
+(http://bitbucket.org/chrismiles/psi/wiki/Development).
+
+The setup.py has some extra features that help with development,
+these are explained in its docstring.
+
+The PSI source code is hosted at bitbucket in a Mercurial repository,
+http://bitbucket.org/chrismiles/psi/
+
+
+Porting
+=======
+
+If PSI does not yet work on your architecture/system then it needs to
+be ported, the design is aimed at making this easy for you.  There is
+no separate porting guide at the moment so you will have to read the
+DESIGN file for details of what to do.
+
+
+Help
+====
+
+There is a mailing list at psi-discuss@googlegroups.com where you can
+post questions, patches, hints, bugs, etc.  Your feedback is welcome!



[13/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code

Posted by rl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/CodeChecks.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/CodeChecks.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/CodeChecks.py
new file mode 100644
index 0000000..359642d
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/CodeChecks.py
@@ -0,0 +1,1969 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2001-2006, MetaSlash Inc.  All rights reserved.
+# Portions Copyright (c) 2005, Google, Inc.  All rights reserved.
+
+"""
+Find warnings in byte code from Python source files.
+"""
+
+import string
+import types
+
+from pychecker import msgs
+from pychecker import utils
+from pychecker import Warning
+from pychecker import OP
+from pychecker import Stack
+from pychecker import python
+
+__pychecker__ = 'no-argsused'
+
+
+def cfg() :
+    return utils.cfg()
+
+def getFunctionArgErr(func_name, argCount, minArgs, maxArgs):
+    err = None
+    if maxArgs == None:
+        if argCount < minArgs :
+            err = msgs.INVALID_ARG_COUNT2 % (func_name, argCount, minArgs)
+    elif argCount < minArgs or argCount > maxArgs:
+        if minArgs == maxArgs:
+            err = msgs.INVALID_ARG_COUNT1 % (func_name, argCount, minArgs)
+        else:
+            err = msgs.INVALID_ARG_COUNT3 % (func_name, argCount, minArgs, maxArgs)
+    return err
+
+def _checkFunctionArgCount(code, func_name, argCount, minArgs, maxArgs,
+                           objectReference = 0) :
+    # there is an implied argument for object creation and self.xxx()
+    if objectReference :
+        minArgs = minArgs - 1
+        if maxArgs is not None :
+            maxArgs = maxArgs - 1
+
+    err = getFunctionArgErr(func_name, argCount, minArgs, maxArgs)
+    if err :
+        code.addWarning(err)
+
+def _checkFunctionArgs(code, func, objectReference, argCount, kwArgs,
+                       check_arg_count = 1) :
+    func_name = func.function.func_code.co_name
+    if kwArgs :
+        args_len = func.function.func_code.co_argcount
+        arg_names = func.function.func_code.co_varnames[argCount:args_len]
+        if argCount < args_len and kwArgs[0] in arg_names:
+            if cfg().namedArgs :
+                code.addWarning(msgs.FUNC_USES_NAMED_ARGS % func_name)
+
+            # convert the named args into regular params, and really check
+            while argCount < args_len and kwArgs and kwArgs[0] in arg_names:
+                argCount = argCount + 1
+                kwArgs = kwArgs[1:]
+            _checkFunctionArgs(code, func, objectReference, argCount, kwArgs,
+                               check_arg_count)
+            return
+
+        if not func.supportsKW :
+            code.addWarning(msgs.FUNC_DOESNT_SUPPORT_KW % func_name)
+
+    if check_arg_count :
+        _checkFunctionArgCount(code, func_name, argCount,
+                               func.minArgs, func.maxArgs, objectReference)
+
+def _getReferenceFromModule(module, identifier) :
+    func = module.functions.get(identifier, None)
+    if func is not None :
+        return func, None, 0
+
+    create = 0
+    c = module.classes.get(identifier, None)
+    if c is not None :
+        func = c.methods.get(utils.INIT, None)
+        create = 1
+    return func, c, create
+
+def _getFunction(module, stackValue) :
+    'Return (function, class) from the stack value'
+
+    identifier = stackValue.data
+    if type(identifier) == types.StringType :
+        return _getReferenceFromModule(module, identifier)
+
+    # find the module this references
+    i, maxLen = 0, len(identifier)
+    while i < maxLen :
+        id = utils.safestr(identifier[i])
+        if module.classes.has_key(id) or module.functions.has_key(id) :
+            break
+        refModule = module.modules.get(id, None)
+        if refModule is not None :
+            module = refModule
+        else :
+            return None, None, 0
+        i = i + 1
+
+    # if we got to the end, there is only modules, nothing we can do
+    # we also can't handle if there is more than 2 items left
+    if i >= maxLen or (i+2) < maxLen :
+        return None, None, 0
+
+    if (i+1) == maxLen :
+        return _getReferenceFromModule(module, identifier[-1])
+
+    # we can't handle self.x.y
+    if (i+2) == maxLen and identifier[0] == cfg().methodArgName:
+        return None, None, 0
+
+    c = module.classes.get(identifier[-2], None)
+    if c is None :
+        return None, None, 0
+    return c.methods.get(identifier[-1], None), c, 0
+
+def _validateKwArgs(code, info, func_name, kwArgs):
+    if len(info) < 4:
+        code.addWarning(msgs.FUNC_DOESNT_SUPPORT_KW % func_name)
+    elif not info[3]:
+        return
+
+    try:
+        # info could be from a builtin method which means that
+        # info[3] is not a list.
+        dummy = info[3][0]
+    except IndexError:
+        return
+
+    for arg in kwArgs:
+        if arg not in info[3]:
+            code.addWarning(msgs.FUNC_DOESNT_SUPPORT_KW_ARG % (func_name, arg))
+
+def _checkBuiltin(code, loadValue, argCount, kwArgs, check_arg_count = 1) :
+    returnValue = Stack.makeFuncReturnValue(loadValue, argCount)
+    func_name = loadValue.data
+    if loadValue.type == Stack.TYPE_GLOBAL :
+        info = python.GLOBAL_FUNC_INFO.get(func_name, None)
+        if info is not None :
+            if func_name == 'input' and cfg().usesInput:
+                code.addWarning(msgs.USES_INPUT)
+            if cfg().constAttr and \
+               ((func_name == 'setattr' and argCount >= 2) or 
+                (func_name == 'getattr' and argCount == 2)):
+                arg2 = code.stack[-argCount + 1]
+                if arg2.const:
+                    # lambda with setattr and const is a common way of setting
+                    # attributes, so allow it
+                    if code.func.function.func_name != '<lambda>':
+                        code.addWarning(msgs.USES_CONST_ATTR % func_name)
+
+            if kwArgs:
+                _validateKwArgs(code, info, func_name, kwArgs)
+            elif check_arg_count :
+                _checkFunctionArgCount(code, func_name, argCount,
+                                       info[1], info[2])
+            returnValue = Stack.Item(returnValue.data, info[0])
+            returnValue.setStringType(info[0])
+    elif type(func_name) == types.TupleType and len(func_name) <= 2 :
+        objType = code.typeMap.get(utils.safestr(func_name[0]), [])
+        if types.ListType in objType :
+            try :
+                if func_name[1] == 'append' and argCount > 1 :
+                    code.addWarning(msgs.LIST_APPEND_ARGS % func_name[0])
+                    check_arg_count = 0
+            except AttributeError :
+                # FIXME: why do we need to catch AttributeError???
+                pass
+        if len(objType) == 1 :
+            # if it's a builtin, check method
+            builtinType = python.BUILTIN_METHODS.get(objType[0])
+            if builtinType is not None :
+                methodInfo = builtinType.get(func_name[1])
+                # set func properly
+                if kwArgs :
+                    _validateKwArgs(code, methodInfo, func_name[1], kwArgs)
+                elif methodInfo :
+                    returnValue = Stack.Item(func_name[1], methodInfo[0])
+                    returnValue.setStringType(methodInfo[0])
+                    if check_arg_count and methodInfo is not None :
+                        _checkFunctionArgCount(code, func_name[1], argCount,
+                                               methodInfo[1], methodInfo[2])
+
+    return returnValue
+
+_IMMUTABLE_LIST_METHODS = ('count', 'index',)
+_IMMUTABLE_DICT_METHODS = ('copy', 'get', 'has_key',
+                           'items', 'keys', 'values',
+                           'iteritems', 'iterkeys', 'itervalues')
+
+def _checkModifyDefaultArg(code, objectName, methodName=None) :
+    try :
+        value = code.func.defaultValue(objectName)
+        objectType = type(value)
+        if objectType in python.MUTABLE_TYPES :
+            if objectType == types.DictType and \
+               methodName in _IMMUTABLE_DICT_METHODS :
+                return 
+            if objectType == types.ListType and \
+               methodName in _IMMUTABLE_LIST_METHODS :
+                return
+            code.addWarning(msgs.MODIFYING_DEFAULT_ARG % objectName)
+    except ValueError :
+        pass
+
+def _isexception(object) :
+    # FIXME: i have no idea why this function is necessary
+    # it seems that the issubclass() should work, but it doesn't always
+
+    if hasattr(object, 'type'):
+        if object.type == types.TupleType:
+        # if we have a tuple, we can't check the contents (not enough info)
+##            for item in object.value:
+##                if not _isexception(item):
+##                    return 0
+            return 1
+
+    try:
+        # try/except is necessary for globals like NotImplemented
+        if issubclass(object, Exception) :
+            return 1
+        # Python 2.5 added a BaseException to the hierarchy.  That's
+        # really what we need to check if it exists.
+        if utils.pythonVersion() >= utils.PYTHON_2_5:
+            if issubclass(object, BaseException):
+                return 1
+    except TypeError:
+        return 0
+
+    for c in object.__bases__ :
+        if utils.startswith(utils.safestr(c), 'exceptions.') :
+            return 1
+        if len(c.__bases__) > 0 and _isexception(c) :
+            return 1
+    return 0
+
+def _checkStringFind(code, loadValue):
+    if len(loadValue.data) == 2 and loadValue.data[1] == 'find':
+        try:
+            if types.StringType in code.typeMap.get(loadValue.data[0], []):
+                op = code.nextOpInfo()[0]
+                if OP.IS_CONDITIONAL_JUMP(op) or OP.IS_NOT(op):
+                    code.addWarning(msgs.BAD_STRING_FIND)
+        except TypeError:
+            # we don't care if loadValue.data[0] is not hashable
+            pass
+
+def _checkAbstract(refClass, code, name):
+    name_list = refClass.isAbstract()
+    if name_list:
+        name_list.sort()
+        names = string.join(name_list, ", ")
+        code.addWarning(msgs.METHODS_NEED_OVERRIDE % (names, name))
+
+_SEQUENCE_TYPES = (types.TupleType, types.ListType, types.StringType)
+try: _SEQUENCE_TYPES = _SEQUENCE_TYPES + (types.UnicodeType,)
+except AttributeError: pass
+
+# FIXME: this is not complete. errors will be caught only sometimes,
+#        depending on the order the functions/methods are processed
+#        in the dict.  Need to be able to run through all functions
+#        twice, but because the code sucks, this is not possible.
+def _checkReturnValueUse(code, func):
+    if func.returnValues is None:
+        return
+
+    err = None
+    opInfo = code.nextOpInfo()
+    if func.returnsNoValue():
+        # make sure we really know how to check for all the return types
+        for rv in func.returnValues:
+            if rv[1].type in _UNCHECKABLE_STACK_TYPES:
+                return
+
+        if not OP.POP_TOP(opInfo[0]):
+            err = msgs.USING_NONE_RETURN_VALUE % utils.safestr(func)
+    elif OP.UNPACK_SEQUENCE(opInfo[0]):
+        # verify unpacking into proper # of vars
+        varCount = opInfo[1]
+        stackRV = func.returnValues[0][1]
+        returnType = stackRV.getType({})
+        funcCount = stackRV.length
+        if returnType in _SEQUENCE_TYPES:
+            if varCount != funcCount and funcCount > 0:
+                err = msgs.WRONG_UNPACK_FUNCTION % (utils.safestr(func), funcCount, varCount)
+        elif returnType not in _UNCHECKABLE_STACK_TYPES:
+            err = msgs.UNPACK_NON_SEQUENCE % (utils.safestr(func), _getTypeStr(returnType))
+    if err:
+        code.addWarning(err)
+
+def _handleFunctionCall(codeSource, code, argCount, indexOffset = 0,
+                        check_arg_count = 1) :
+    'Checks for warnings, returns function called (may be None)'
+
+    if not code.stack :
+        return
+
+    kwArgCount = argCount >> utils.VAR_ARGS_BITS
+    argCount = argCount & utils.MAX_ARGS_MASK
+
+    # function call on stack is before the args, and keyword args
+    funcIndex = argCount + 2 * kwArgCount + 1 + indexOffset
+    if funcIndex > len(code.stack) :
+        funcIndex = 0
+    # to find on stack, we have to look backwards from top of stack (end)
+    funcIndex = -funcIndex
+
+    # store the keyword names/keys to check if using named arguments
+    kwArgs = []
+    if kwArgCount > 0 :
+        # loop backwards by 2 (keyword, value) in stack to find keyword args
+        for i in range(-2 - indexOffset, (-2 * kwArgCount - 1), -2) :
+            kwArgs.append(code.stack[i].data)
+        kwArgs.reverse()
+
+    loadValue = code.stack[funcIndex]
+    funcName = loadValue.getName()
+    returnValue = Stack.makeFuncReturnValue(loadValue, argCount)
+
+    if loadValue.isMethodCall(codeSource.classObject, cfg().methodArgName):
+        methodName = loadValue.data[1]
+        try :
+            m = codeSource.classObject.methods[methodName]
+            if m != None :
+                objRef = not m.isStaticMethod()
+                _checkFunctionArgs(code, m, objRef, argCount, kwArgs,
+                                   check_arg_count)
+        except KeyError :
+            sattr = codeSource.classObject.statics.get(methodName)
+            if sattr is not None :
+                funcName = sattr.getName()
+
+            if sattr is None and cfg().callingAttribute :
+                code.addWarning(msgs.INVALID_METHOD % methodName)
+
+    elif loadValue.type in (Stack.TYPE_ATTRIBUTE, Stack.TYPE_GLOBAL) and \
+         type(loadValue.data) in (types.StringType, types.TupleType) :
+        # apply(func, (args)), can't check # of args, so just return func
+        if loadValue.data == 'apply' :
+            loadValue = code.stack[funcIndex+1]
+            funcName = loadValue.getName()
+        else :
+            if cfg().modifyDefaultValue and \
+               type(loadValue.data) == types.TupleType :
+                _checkModifyDefaultArg(code, loadValue.data[0],
+                                       loadValue.data[1])
+
+            func, refClass, method = _getFunction(codeSource.module, loadValue)
+            if func == None and type(loadValue.data) == types.TupleType and \
+               len(loadValue.data) == 2 :
+                # looks like we are making a method call
+                data = loadValue.data
+                if type(data[0]) == types.StringType :
+                    # do we know the type of the local variable?
+                    varType = code.typeMap.get(data[0])
+                    if varType is not None and len(varType) == 1 :
+                        if hasattr(varType[0], 'methods') :
+                            # it's a class & we know the type, get the method
+                            func = varType[0].methods.get(data[1])
+                            if func is not None :
+                                method = 1
+
+            if cfg().abstractClasses and refClass and method:
+                _checkAbstract(refClass, code, funcName)
+
+            if cfg().stringFind:
+                _checkStringFind(code, loadValue)
+
+            if func != None :
+                if refClass and func.isClassMethod():
+                    argCount = argCount + 1
+                _checkFunctionArgs(code, func, method, argCount, kwArgs,
+                                   check_arg_count)
+                # if this isn't a c'tor, we should check
+                if not (refClass and method) and cfg().checkReturnValues:
+                    _checkReturnValueUse(code, func)
+
+                if refClass :
+                    if method :
+                        # c'tor, return the class as the type
+                        returnValue = Stack.Item(loadValue, refClass)
+                    elif func.isClassMethod():
+                        # FIXME: do anything here?
+                        pass
+                    elif argCount > 0 and cfg().methodArgName and \
+                         not func.isStaticMethod() and \
+                         code.stack[funcIndex].type == Stack.TYPE_ATTRIBUTE and \
+                         code.stack[funcIndex+1].data != cfg().methodArgName:
+                        e = msgs.SELF_NOT_FIRST_ARG % (cfg().methodArgName, '')
+                        code.addWarning(e)
+            elif refClass and method :
+                returnValue = Stack.Item(loadValue, refClass)
+                if (argCount > 0 or len(kwArgs) > 0) and \
+                   not refClass.ignoreAttrs and \
+                   not refClass.methods.has_key(utils.INIT) and \
+                   not _isexception(refClass.classObject) :
+                    code.addWarning(msgs.NO_CTOR_ARGS)
+            else :
+                returnValue = _checkBuiltin(code, loadValue, argCount, kwArgs,
+                                            check_arg_count)
+                if returnValue.type is types.NoneType and \
+                   not OP.POP_TOP(code.nextOpInfo()[0]) :
+                    name = utils.safestr(loadValue.data)
+                    if type(loadValue.data) == types.TupleType :
+                        name = string.join(loadValue.data, '.')
+                    # lambda with setattr is a common way of setting
+                    # attributes, so allow it
+                    if name != 'setattr' \
+                        or code.func.function.func_name != '<lambda>':
+                        code.addWarning(msgs.USING_NONE_RETURN_VALUE % name)
+
+    code.stack = code.stack[:funcIndex] + [ returnValue ]
+    code.functionsCalled[funcName] = loadValue
+
+
+def _classHasAttribute(c, attr) :
+    return (c.methods.has_key(attr) or c.members.has_key(attr) or
+            hasattr(c.classObject, attr))
+
+def _checkClassAttribute(attr, c, code) :
+    if _classHasAttribute(c, attr) :
+        try :
+            del c.memberRefs[attr]
+        except KeyError :
+            pass
+    elif cfg().classAttrExists :
+        if attr not in cfg().missingAttrs:
+            code.addWarning(msgs.INVALID_CLASS_ATTR % attr)
+
+def _checkModuleAttribute(attr, module, code, ref) :
+    try:
+        if attr not in module.modules[ref].attributes and \
+           not utils.endswith(ref, '.' + attr) :
+            code.addWarning(msgs.INVALID_MODULE_ATTR % attr)
+    except (KeyError, TypeError):
+        # if ref isn't found, or ref isn't even hashable, we don't care
+        # we may not know, or ref could be something funky [e for e].method()
+        pass
+
+    try:
+        _checkClassAttribute(attr, module.classes[ref], code)
+    except (KeyError, TypeError):
+        # if ref isn't found, or ref isn't even hashable, we don't care
+        # we may not know, or ref could be something funky [e for e].method()
+        pass
+
+
+def _getGlobalName(name, func) :
+    # get the right name of global refs (for from XXX import YYY)
+    opModule = func.function.func_globals.get(name)
+    try :
+        if opModule and isinstance(opModule, types.ModuleType) :
+            name = opModule.__name__
+    except :
+        # we have to do this in case the class raises an access exception
+        # due to overriding __special__() methods
+        pass
+
+    return name
+
+
+def _checkNoEffect(code, ignoreStmtWithNoEffect=0):
+    if (not ignoreStmtWithNoEffect and
+        OP.POP_TOP(code.nextOpInfo()[0]) and cfg().noEffect):
+        code.addWarning(msgs.POSSIBLE_STMT_WITH_NO_EFFECT)
+    
+def _makeConstant(code, index, factoryFunction) :
+    "Build a constant on the stack ((), [], or {})"
+    if index > 0 :
+        code.stack[-index:] = [ factoryFunction(code.stack[-index:]) ]
+        _checkNoEffect(code)
+    else :
+        code.pushStack(factoryFunction())
+
+
+def _hasGlobal(operand, module, func, main) :
+    return (func.function.func_globals.has_key(operand) or
+             main or module.moduleLineNums.has_key(operand) or
+             __builtins__.has_key(operand))
+
+def _checkGlobal(operand, module, func, code, err, main = 0) :
+    if not _hasGlobal(operand, module, func, main) :
+        code.addWarning(err % operand)
+        if not cfg().reportAllGlobals :
+            func.function.func_globals[operand] = operand
+
+
+def _handleComparison(stack, operand) :
+    num_ops = 2
+    if operand == 'exception match':
+        num_ops = 1
+
+    si = min(len(stack), num_ops)
+    compareValues = stack[-si:]
+    for _ in range(si, 2) :
+        compareValues.append(Stack.Item(None, None))
+    stack[-si:] = [ Stack.makeComparison(compareValues, operand) ]
+    return compareValues
+
+def _handleImport(code, operand, module, main, fromName) :
+    # FIXME: this function should be refactored/cleaned up
+    key = operand
+    tmpOperand = tmpFromName = operand
+    if fromName is not None :
+        tmpOperand = tmpFromName = fromName
+        key = (fromName, operand)
+
+    if cfg().deprecated:
+        try:
+            undeprecated = python.DEPRECATED_MODULES[tmpFromName]
+        except KeyError:
+            pass
+        else:
+            msg = msgs.USING_DEPRECATED_MODULE % tmpFromName
+            if undeprecated:
+                msg.data = msg.data + msgs.USE_INSTEAD % undeprecated
+            code.addWarning(msg)
+
+    if cfg().reimportSelf and tmpOperand == module.module.__name__ :
+        code.addWarning(msgs.IMPORT_SELF % tmpOperand)
+
+    modline1 = module.moduleLineNums.get(tmpOperand, None)
+    modline2 = module.moduleLineNums.get((tmpFromName, '*'), None)
+    key2 = (tmpFromName,)
+    if fromName is not None and operand != '*' :
+        key2 = (tmpFromName, operand)
+    modline3 = module.moduleLineNums.get(key2, None)
+
+    if modline1 is not None or modline2 is not None or modline3 is not None :
+        err = None
+
+        if fromName is None :
+            if modline1 is not None :
+                err = msgs.MODULE_IMPORTED_AGAIN % operand
+            elif cfg().mixImport :
+                err = msgs.MIX_IMPORT_AND_FROM_IMPORT % tmpFromName
+        else :
+            if modline3 is not None and operand != '*' :
+                err = 'from %s import %s' % (tmpFromName, operand)
+                err = msgs.MODULE_MEMBER_IMPORTED_AGAIN % err
+            elif modline1 is not None :
+                if cfg().mixImport and code.getLineNum() != modline1[1] :
+                    err = msgs.MIX_IMPORT_AND_FROM_IMPORT % tmpFromName
+            else :
+                err = msgs.MODULE_MEMBER_ALSO_STAR_IMPORTED % fromName
+
+        # filter out warnings when files are different (ie, from X import ...)
+        if err is not None and cfg().moduleImportErrors :
+            bytes = module.main_code
+            if bytes is None or \
+               bytes.function.func_code.co_filename == code.func_code.co_filename :
+                code.addWarning(err)
+
+    if main :
+        fileline = (code.func_code.co_filename, code.getLineNum())
+        module.moduleLineNums[key] = fileline
+        if fromName is not None :
+            module.moduleLineNums[(fromName,)] = fileline
+
+
+def _handleImportFrom(code, operand, module, main) :
+    fromName = code.stack[-1].data
+    if utils.pythonVersion() < utils.PYTHON_2_0 and \
+       OP.POP_TOP(code.nextOpInfo()[0]):
+        code.popNextOp()
+    code.pushStack(Stack.Item(operand, types.ModuleType))
+    _handleImport(code, operand, module, main, fromName)
+
+
+# http://www.python.org/doc/current/lib/typesseq-strings.html
+_FORMAT_CONVERTERS = 'diouxXeEfFgGcrs'
+# NOTE: lLh are legal in the flags, but are ignored by python, we warn
+_FORMAT_FLAGS = '*#- +.' + string.digits
+
+def _getFormatInfo(format, code) :
+    vars = []
+
+    # first get rid of all the instances of %% in the string, they don't count
+    format = string.replace(format, "%%", "")
+    sections = string.split(format, '%')
+    percentFormatCount = formatCount = string.count(format, '%')
+    mappingFormatCount = 0
+
+    # skip the first item in the list, it's always empty
+    for section in sections[1:] :
+        orig_section = section
+        if not section:
+            w = msgs.INVALID_FORMAT % orig_section
+            w.data = w.data + ' (end of format string)'
+            code.addWarning(w)
+            continue
+
+        # handle dictionary formats
+        if section[0] == '(' :
+            mappingFormatCount = mappingFormatCount + 1
+            varname = string.split(section, ')')
+            if varname[1] == '' :
+                code.addWarning(msgs.INVALID_FORMAT % section)
+            vars.append(varname[0][1:])
+            section = varname[1]
+
+        if not section :
+            # no format data to check
+            continue
+
+        # FIXME: we ought to just define a regular expression to check
+        # formatRE = '[ #+-]*([0-9]*|*)(|.(|*|[0-9]*)[diouxXeEfFgGcrs].*'
+        stars = 0
+        for i in range(0, len(section)) :
+            if section[i] in _FORMAT_CONVERTERS :
+                break
+            if section[i] in _FORMAT_FLAGS :
+                if section[i] == '*' :
+                    stars = stars + 1
+                    if mappingFormatCount > 0 :
+                        code.addWarning(msgs.USING_STAR_IN_FORMAT_MAPPING % section)
+
+        if stars > 2 :
+            code.addWarning(msgs.TOO_MANY_STARS_IN_FORMAT)
+
+        formatCount = formatCount + stars
+        if section[i] not in _FORMAT_CONVERTERS :
+            code.addWarning(msgs.INVALID_FORMAT % orig_section)
+
+    if mappingFormatCount > 0 and mappingFormatCount != percentFormatCount :
+        code.addWarning(msgs.CANT_MIX_MAPPING_IN_FORMATS)
+
+    return formatCount, vars
+
+def _getConstant(code, module, data) :
+    data = utils.safestr(data.data)
+    format = code.constants.get(data)
+    if format is not None :
+        return format
+
+    format = module.variables.get(data)
+    if format is not None and format.value is not None :
+        return format.value
+    return None
+
+_UNCHECKABLE_FORMAT_STACK_TYPES = \
+      (Stack.TYPE_UNKNOWN, Stack.TYPE_FUNC_RETURN, Stack.TYPE_ATTRIBUTE,
+       Stack.TYPE_GLOBAL, Stack.TYPE_EXCEPT)
+_UNCHECKABLE_STACK_TYPES = _UNCHECKABLE_FORMAT_STACK_TYPES + (types.NoneType,)
+
+def _getFormatString(code, codeSource) :
+    if len(code.stack) <= 1 :
+        return ''
+
+    format = code.stack[-2]
+    if format.type != types.StringType or not format.const :
+        format = _getConstant(code, codeSource.module, format)
+        if format is None or type(format) != types.StringType :
+            return ''
+        return format
+    return format.data
+
+    
+def _getFormatWarnings(code, codeSource) :
+    format = _getFormatString(code, codeSource)
+    if not format :
+        return
+
+    args = 0
+    count, vars = _getFormatInfo(format, code)
+    topOfStack = code.stack[-1]
+    if topOfStack.isLocals() :
+        for varname in vars :
+            if not code.unusedLocals.has_key(varname) :
+                code.addWarning(msgs.NO_LOCAL_VAR % varname)
+            else :
+                code.unusedLocals[varname] = None
+    else :
+        stackItemType = topOfStack.getType(code.typeMap)
+        if ((stackItemType == types.DictType and len(vars) > 0) or
+            codeSource.func.isParam(topOfStack.data) or
+            stackItemType in _UNCHECKABLE_FORMAT_STACK_TYPES) :
+            return
+
+        if topOfStack.type == types.TupleType :
+            args = topOfStack.length
+        elif stackItemType == types.TupleType :
+            args = len(code.constants.get(topOfStack.data, (0,)))
+        else :
+            args = 1
+
+    if args and count != args :
+        code.addWarning(msgs.INVALID_FORMAT_COUNT % (count, args))
+
+def _checkAttributeType(code, stackValue, attr) :
+    if not cfg().checkObjectAttrs :
+        return
+
+    varTypes = code.typeMap.get(utils.safestr(stackValue.data), None)
+    if not varTypes :
+        return
+
+    # the value may have been converted on stack (`v`)
+    other_types = []
+    if stackValue.type not in varTypes :
+        other_types = [stackValue.type]
+
+    for varType in varTypes + other_types :
+        # ignore built-in types that have no attributes
+        if python.METHODLESS_OBJECTS.has_key(varType) :
+            continue
+
+        attrs = python.BUILTIN_ATTRS.get(varType, None)
+        if attrs is not None :
+            if attr in attrs :
+                return
+            continue
+
+        if hasattr(varType, 'ignoreAttrs') :
+            if varType.ignoreAttrs or _classHasAttribute(varType, attr) :
+                return
+        elif not hasattr(varType, 'attributes') or attr in varType.attributes :
+            return
+
+    code.addWarning(msgs.OBJECT_HAS_NO_ATTR % (stackValue.data, attr))
+
+
+def _getTypeStr(t):
+    returnStr = utils.safestr(t)
+    strs = string.split(returnStr, "'")
+    try:
+        if len(strs) == 3:
+            returnStr = strs[-2]
+    except IndexError:
+        pass
+    return returnStr
+
+
+def _getLineNum(co, instr_index):
+    co_lnotab = co.co_lnotab
+    lineno = co.co_firstlineno
+    addr = 0
+    for lnotab_index in range(0, len(co_lnotab), 2):
+        addr = addr + ord(co_lnotab[lnotab_index])
+        if addr > instr_index:
+            return lineno
+        lineno = lineno + ord(co_lnotab[lnotab_index+1])
+    return lineno
+
+
+class Code :
+    'Hold all the code state information necessary to find warnings'
+
+    def __init__(self) :
+        self.bytes = None
+        self.func = None
+        self.func_code = None
+        self.index = 0
+        self.indexList = []
+        self.extended_arg = 0
+        self.lastLineNum = 0
+        self.maxCode = 0
+        self.has_except = 0
+        self.try_finally_first = 0
+        self.starts_and_ends_with_finally = 0
+
+        self.returnValues = []
+        self.raiseValues = []
+        self.stack = []
+
+        self.unpackCount = 0
+        self.loops = 0
+        self.branches = {}
+
+        self.warnings = []
+
+        self.globalRefs = {}
+        self.unusedLocals = {}
+        self.deletedLocals = {}
+        self.functionsCalled = {}
+        self.typeMap = {}
+        self.constants = {}
+        self.codeObjects = {}
+
+    def init(self, func) :
+        self.func = func
+        self.func_code, self.bytes, self.index, self.maxCode, self.extended_arg = \
+                        OP.initFuncCode(func.function)
+        self.lastLineNum = self.func_code.co_firstlineno
+        self.returnValues = []
+
+        # initialize the arguments to unused
+        for arg in func.arguments() :
+            self.unusedLocals[arg] = 0
+            self.typeMap[arg] = [ Stack.TYPE_UNKNOWN ]
+
+    def getLineNum(self):
+        line = self.lastLineNum
+        # if we don't have linenum info, calc it from co_lntab & index
+        if line == self.func_code.co_firstlineno:
+            # FIXME: this could be optimized, if we kept last line info
+            line = _getLineNum(self.func_code, self.index - 1)
+        return line
+
+    def getWarning(self, err, line = None) :
+        if line is None :
+            line = self.getLineNum()
+        return Warning.Warning(self.func_code, line, err)
+
+    def addWarning(self, err, line = None) :
+        w = err
+        if not isinstance(w, Warning.Warning):
+            w = self.getWarning(err, line)
+        self.warnings.append(w)
+
+    def popNextOp(self) :
+        self.indexList.append(self.index)
+        info = OP.getInfo(self.bytes, self.index, self.extended_arg)
+        op, oparg, self.index, self.extended_arg = info
+        if op < OP.HAVE_ARGUMENT :
+            utils.debug("  %d %s" % (self.indexList[-1], OP.name[op]))
+            operand = None
+        else :
+            operand = OP.getOperand(op, self.func_code, oparg)
+            self.label = label = OP.getLabel(op, oparg, self.index)
+            utils.debug("  %d %s" % (self.indexList[-1], OP.name[op]), oparg, operand)
+            if label != None :
+                self.addBranch(label)
+
+        return op, oparg, operand
+
+    def nextOpInfo(self, offset = 0) :
+        try :
+            return OP.getInfo(self.bytes, self.index + offset, 0)[0:3]
+        except IndexError :
+            return -1, 0, -1
+
+    def getFirstOp(self) :
+        # find the first real op, maybe we should not check if params are used
+        i = extended_arg = 0
+        while i < self.maxCode :
+            op, oparg, i, extended_arg = OP.getInfo(self.bytes, i, extended_arg)
+            if not OP.LINE_NUM(op) :
+                if not (OP.LOAD_CONST(op) or OP.LOAD_GLOBAL(op)) :
+                    return op
+        raise RuntimeError('Could not find first opcode in function')
+
+    def pushStack(self, item, ignoreStmtWithNoEffect=0):
+        self.stack.append(item)
+        _checkNoEffect(self, ignoreStmtWithNoEffect)
+
+    def popStack(self) :
+        if self.stack :
+            del self.stack[-1]
+
+    def popStackItems(self, count) :
+        stackLen = len(self.stack)
+        if stackLen > 0 :
+            count = min(count, stackLen)
+            del self.stack[-count:]
+
+    def unpack(self) :
+        if self.unpackCount :
+            self.unpackCount = self.unpackCount - 1
+        else :
+            self.popStack()
+
+    def __getStringStackType(self, data) :
+        try :
+            return data.getType({})
+        except AttributeError :
+            return Stack.TYPE_UNKNOWN
+
+    def __getStackType(self) :
+        if not self.stack :
+            return Stack.TYPE_UNKNOWN
+
+        if not self.unpackCount :
+            return self.__getStringStackType(self.stack[-1])
+
+        data = self.stack[-1].data
+        if type(data) == types.TupleType :
+            try :
+                return self.__getStringStackType(data[len(data)-self.unpackCount])
+            except IndexError :
+                # happens when unpacking a var for which we don't know the size
+                pass
+
+        return Stack.TYPE_UNKNOWN
+
+    def setType(self, name) :
+        valueList = self.typeMap.get(name, [])
+        newType = self.__getStackType()
+        # longs are being merged with ints, assume they are the same
+        # comparisons are really ints anyways
+        if newType in (types.LongType, Stack.TYPE_COMPARISON):
+            newType = types.IntType
+        if newType not in valueList :
+            valueList.append(newType)
+
+            # need to ignore various types (Unknown, Func return values, etc)
+            # also ignore None, don't care if they use it and a real type
+            if valueList and newType not in _UNCHECKABLE_STACK_TYPES and \
+               cfg().inconsistentTypes:
+                oldTypes = []
+                # only add types to the value list that are "interesting"
+                for typeToAdd in valueList:
+                    if typeToAdd not in _UNCHECKABLE_STACK_TYPES and \
+                       typeToAdd != newType:
+                        oldTypes.append(_getTypeStr(typeToAdd))
+                # do we have any "interesting" old types?  if so, warn
+                if oldTypes:
+                    self.addWarning(msgs.INCONSISTENT_TYPE % \
+                                    (name, oldTypes, _getTypeStr(newType)))
+        self.typeMap[name] = valueList
+
+    def addReturn(self) :
+        if len(self.stack) > 0 :
+            value = (self.getLineNum(), self.stack[-1], self.nextOpInfo()[2])
+            self.returnValues.append(value)
+            self.popStack()
+
+    def addRaise(self) :
+        self.raiseValues.append((self.getLineNum(), None, self.nextOpInfo()[2]))
+
+    def addBranch(self, label) :
+        if label is not None :
+            self.branches[label] = self.branches.get(label, 0) + 1
+
+    def removeBranch(self, label) :
+        branch = self.branches.get(label, None)
+        if branch is not None :
+            if branch == 1 :
+                del self.branches[label]
+            else :
+                self.branches[label] = branch - 1
+
+    def remove_unreachable_code(self, label) :
+        if len(self.indexList) >= 2 :
+            index = self.indexList[-2]
+            if index >= 0 and OP.POP_BLOCK(ord(self.bytes[index])) :
+                index = self.indexList[-3]
+            if index >= 0 :
+                op = ord(self.bytes[index])
+                if OP.RETURN_VALUE(op) or OP.RAISE_VARARGS(op) or \
+                   OP.END_FINALLY(ord(self.bytes[label-1])) :
+                    self.removeBranch(label)
+
+    def updateCheckerArgs(self, operand) :
+        rc = utils.shouldUpdateArgs(operand)
+        if rc :
+            utils.updateCheckerArgs(self.stack[-1].data, self.func_code,
+                                    self.getLineNum(), self.warnings)
+        return rc
+        
+    def updateModuleLineNums(self, module, operand) :
+        filelist = (self.func_code.co_filename, self.getLineNum())
+        module.moduleLineNums[operand] = filelist
+
+
+class CodeSource :
+    'Holds source information about a code block (module, class, func, etc)'
+    def __init__(self, module, func, c, main, in_class, code) :
+        self.module = module
+        self.func = func
+        self.classObject = c
+        self.main = main
+        self.in_class = in_class
+        self.code = code
+        self.calling_code = []
+
+def _checkException(code, name) :
+    if code.stack and code.stack[-1].type == Stack.TYPE_EXCEPT :
+        if __builtins__.has_key(name) :
+            code.addWarning(msgs.SET_EXCEPT_TO_BUILTIN % name)
+
+def _checkAssign(code, name):
+    if name in _BAD_ASSIGN_NAMES:
+        code.addWarning(msgs.SHOULDNT_ASSIGN_BUILTIN % name)
+    else:
+        cap = string.capitalize(name)
+        if cap in _BAD_ASSIGN_NAMES:
+            code.addWarning(msgs.SHOULDNT_ASSIGN_NAME % (name, cap))
+
+def _checkVariableOperationOnItself(code, lname, msg):
+    if code.stack and code.stack[-1].getName() == lname:
+        code.addWarning(msg % lname)
+
+def _checkFutureKeywords(code, varname) :
+    kw = python.FUTURE_KEYWORDS.get(varname)
+    if kw is not None :
+        code.addWarning(msgs.USING_KEYWORD % (varname, kw))
+
+def _STORE_NAME(oparg, operand, codeSource, code) :
+    if not code.updateCheckerArgs(operand) :
+        _checkFutureKeywords(code, operand)
+        module = codeSource.module
+        if not codeSource.in_class :
+            _checkShadowBuiltin(code, operand)
+            if not codeSource.calling_code :
+                _checkGlobal(operand, module, codeSource.func, code,
+                             msgs.GLOBAL_DEFINED_NOT_DECLARED, codeSource.main)
+        else :
+            if code.stack :
+                codeSource.classObject.statics[operand] = code.stack[-1]
+                codeSource.classObject.lineNums[operand] = code.getLineNum()
+
+        var = module.variables.get(operand)
+        if var is not None and code.stack and code.stack[-1].const :
+            var.value = code.stack[-1].data
+
+        if code.unpackCount :
+            code.unpackCount = code.unpackCount - 1
+        else:
+            _checkAssign(code, operand)
+            _checkException(code, operand)
+            code.popStack()
+        if not module.moduleLineNums.has_key(operand) and codeSource.main :
+            code.updateModuleLineNums(module, operand)
+
+_STORE_GLOBAL = _STORE_NAME
+
+def _checkLoadGlobal(codeSource, code, varname) :
+    _checkFutureKeywords(code, varname)
+    should_check = 1
+    if code.func_code.co_name == utils.LAMBDA :
+        # this could really be a local reference, check first
+        if not codeSource.main and codeSource.calling_code:
+            func = getattr(codeSource.calling_code[-1], 'function', None)
+            if func is not None and varname in func.func_code.co_varnames :
+                _handleLoadLocal(code, codeSource, varname)
+                should_check = 0
+
+    if should_check :
+        # if a global var starts w/__ and the global is referenced in a class
+        # we have to strip off the _class-name, to get the original name
+        if codeSource.classObject and \
+           utils.startswith(varname, '_' + codeSource.classObject.name + '__'):
+            varname = varname[len(codeSource.classObject.name)+1:]
+            
+        # make sure we remember each global ref to check for unused
+        code.globalRefs[_getGlobalName(varname, codeSource.func)] = varname
+        if not codeSource.in_class :
+            _checkGlobal(varname, codeSource.module, codeSource.func,
+                         code, msgs.INVALID_GLOBAL)
+
+def _LOAD_NAME(oparg, operand, codeSource, code) :
+    _checkLoadGlobal(codeSource, code, operand)
+
+    # if there was from XXX import *, _* names aren't imported
+    if codeSource.module.modules.has_key(operand) and \
+       hasattr(codeSource.module.module, operand) :
+        operand = getattr(codeSource.module.module, operand).__name__
+
+    opType, const = Stack.TYPE_GLOBAL, 0
+    if operand == 'None' :
+        opType, const = types.NoneType, 0
+    elif operand == 'Ellipsis' :
+        opType, const = types.EllipsisType, 1
+    code.pushStack(Stack.Item(operand, opType, const))
+
+_LOAD_GLOBAL = _LOAD_NAME
+
+def _LOAD_DEREF(oparg, operand, codeSource, code) :
+    if type(oparg) == types.IntType :
+        func_code = code.func_code
+        try:
+            argname = func_code.co_cellvars[oparg]
+        except IndexError:
+            argname = func_code.co_freevars[oparg - len(func_code.co_cellvars)]
+        code.pushStack(Stack.Item(argname, types.StringType))
+        if code.func_code.co_name != utils.LAMBDA :
+            code.unusedLocals[argname] = None
+    else :
+        _LOAD_GLOBAL(oparg, operand, codeSource, code)
+
+_LOAD_CLOSURE = _LOAD_DEREF
+
+def _DELETE_NAME(oparg, operand, codeSource, code) :
+    _checkLoadGlobal(codeSource, code, operand)
+    # FIXME: handle deleting global multiple times
+_DELETE_GLOBAL = _DELETE_NAME
+
+def _make_const(value):
+    if type(value) == types.TupleType:
+        return Stack.makeTuple(map(_make_const, value))
+    return Stack.Item(value, type(value), 1)
+
+def _LOAD_CONST(oparg, operand, codeSource, code) :
+    code.pushStack(_make_const(operand))
+    if type(operand) == types.CodeType :
+        name = operand.co_name
+        obj = code.codeObjects.get(name, None)
+        if name == utils.LAMBDA :
+            # use a unique key, so we can have multiple lambdas
+            code.codeObjects[code.index] = operand
+        elif obj is None :
+            code.codeObjects[name] = operand
+        elif cfg().redefiningFunction :
+            code.addWarning(msgs.REDEFINING_ATTR % (name, obj.co_firstlineno))
+
+
+def _checkLocalShadow(code, module, varname) :
+    if module.variables.has_key(varname) and cfg().shadows :
+        line = module.moduleLineNums.get(varname, ('<unknown>', 0))
+        w = code.getWarning(msgs.LOCAL_SHADOWS_GLOBAL % (varname, line[1]))
+        if line[0] != w.file:
+            w.err = '%s in file %s' % (w.err, line[0])
+        code.addWarning(w)
+
+def _checkShadowBuiltin(code, varname) :
+    if __builtins__.has_key(varname) and varname[0] != '_' and \
+       cfg().shadowBuiltins:
+        code.addWarning(msgs.VARIABLE_SHADOWS_BUILTIN % varname)
+
+def _checkLoadLocal(code, codeSource, varname, deletedWarn, usedBeforeSetWarn) :
+    _checkFutureKeywords(code, varname)
+    deletedLine = code.deletedLocals.get(varname)
+    if deletedLine :
+        code.addWarning(deletedWarn % (varname, deletedLine))
+    elif not code.unusedLocals.has_key(varname) and \
+         not codeSource.func.isParam(varname) :
+        code.addWarning(usedBeforeSetWarn % varname)
+    code.unusedLocals[varname] = None
+    _checkLocalShadow(code, codeSource.module, varname)
+
+def _handleLoadLocal(code, codeSource, varname) :
+    _checkLoadLocal(code, codeSource, varname,
+                    msgs.LOCAL_DELETED, msgs.VAR_USED_BEFORE_SET)
+
+def _LOAD_FAST(oparg, operand, codeSource, code) :
+    code.pushStack(Stack.Item(operand, type(operand)))
+    _handleLoadLocal(code, codeSource, operand)
+
+def _STORE_FAST(oparg, operand, codeSource, code) :
+    if not code.updateCheckerArgs(operand) :
+        _checkFutureKeywords(code, operand)
+        if code.stack and code.stack[-1].type == types.StringType and \
+               not code.stack[-1].const:
+            _checkVariableOperationOnItself(code, operand,
+                                            msgs.SET_VAR_TO_ITSELF)
+        code.setType(operand)
+        if not code.unpackCount and code.stack and \
+           (code.stack[-1].const or code.stack[-1].type == types.TupleType) :
+            if code.constants.has_key(operand) :
+                del code.constants[operand]
+            else :
+                code.constants[operand] = code.stack[-1].data
+
+        _checkLocalShadow(code, codeSource.module, operand)
+        _checkShadowBuiltin(code, operand)
+        _checkAssign(code, operand)
+        _checkException(code, operand)
+        if code.deletedLocals.has_key(operand) :
+            del code.deletedLocals[operand]
+        if not code.unusedLocals.has_key(operand) :
+            errLine = code.getLineNum()
+            if code.unpackCount and not cfg().unusedLocalTuple :
+                errLine = -errLine
+            code.unusedLocals[operand] = errLine
+        code.unpack()
+
+def _DELETE_FAST(oparg, operand, codeSource, code) :
+    _checkLoadLocal(code, codeSource, operand,
+                    msgs.LOCAL_ALREADY_DELETED, msgs.VAR_DELETED_BEFORE_SET)
+    code.deletedLocals[operand] = code.getLineNum()
+
+def _checkAttribute(top, operand, codeSource, code) :
+    if top.data == cfg().methodArgName and codeSource.classObject != None :
+        _checkClassAttribute(operand, codeSource.classObject, code)
+    elif type(top.type) == types.StringType or top.type == types.ModuleType :
+        _checkModuleAttribute(operand, codeSource.module, code, top.data)
+    else :
+        _checkAttributeType(code, top, operand)
+
+def _checkExcessiveReferences(code, top, extraAttr = None) :
+    if cfg().maxReferences <= 0 :
+        return
+
+    try :
+        data = top.data
+        if extraAttr is not None :
+            data = data + (extraAttr,)
+        
+        maxReferences = cfg().maxReferences
+        if data[0] == cfg().methodArgName:
+            maxReferences = maxReferences + 1
+        if len(data) > maxReferences :
+            name = string.join(top.data, '.')
+            code.addWarning(msgs.TOO_MANY_REFERENCES % (maxReferences, name))
+    except TypeError :
+        pass
+
+def _checkDeprecated(code, identifierTuple):
+    # check deprecated module.function
+    try:
+        name = string.join(identifierTuple, '.')
+        undeprecated = python.DEPRECATED_ATTRS[name]
+    except (KeyError, TypeError):
+        pass
+    else:
+        msg = msgs.USING_DEPRECATED_ATTR % name
+        if undeprecated:
+            msg.data = msg.data + msgs.USE_INSTEAD % undeprecated
+        code.addWarning(msg)
+
+def _LOAD_ATTR(oparg, operand, codeSource, code) :
+    if len(code.stack) > 0 :
+        top = code.stack[-1]
+        _checkAttribute(top, operand, codeSource, code)
+        top.addAttribute(operand)
+
+        if len(top.data) == 2:
+            if cfg().deprecated:
+                _checkDeprecated(code, top.data)
+
+            try:
+                insecure = python.SECURITY_FUNCS.get(top.data[0])
+            except TypeError:
+                pass
+            else:
+                if insecure and insecure.has_key(operand):
+                    func = string.join(top.data, '.')
+                    code.addWarning(msgs.USING_INSECURE_FUNC % func)
+
+        nextOp = code.nextOpInfo()[0]
+        if not OP.LOAD_ATTR(nextOp) :
+            if OP.POP_TOP(nextOp) and cfg().noEffect:
+                code.addWarning(msgs.POSSIBLE_STMT_WITH_NO_EFFECT)
+            else :
+                _checkExcessiveReferences(code, top)
+
+def _ok_to_set_attr(classObject, basename, attr) :
+    return (cfg().onlyCheckInitForMembers and classObject != None and
+            basename == cfg().methodArgName and 
+            not _classHasAttribute(classObject, attr))
+
+def _STORE_ATTR(oparg, operand, codeSource, code) :
+    if code.stack :
+        top = code.stack.pop()
+        top_name = '%s.%s' % (top.getName(), operand)
+        try:
+            # FIXME: this is a hack to handle code like:
+            #        a.a = [x for x in range(2) if x > 1]
+            previous = code.stack[-1]
+        except IndexError:
+            previous = None
+        if top.type in (types.StringType, Stack.TYPE_ATTRIBUTE) and \
+           previous and previous.type == Stack.TYPE_ATTRIBUTE:
+            _checkVariableOperationOnItself(code, top_name,
+                                            msgs.SET_VAR_TO_ITSELF)
+        _checkExcessiveReferences(code, top, operand)
+        if _ok_to_set_attr(codeSource.classObject, top.data, operand) :
+            code.addWarning(msgs.INVALID_SET_CLASS_ATTR % operand)
+    code.unpack()
+
+def _DELETE_ATTR(oparg, operand, codeSource, code) :
+    if len(code.stack) > 0 :
+        _checkAttribute(code.stack[-1], operand, codeSource, code)
+
+def _getExceptionInfo(codeSource, item):
+    # FIXME: probably ought to try to handle raise module.Error
+    if item.type is types.StringType and item.const == 1:
+        return item.data, 1
+
+    e = None
+    if item.type is Stack.TYPE_GLOBAL:
+        try:
+            e = eval(item.data)
+        except NameError:
+            pass
+
+    if not e:
+        try:
+            c = codeSource.module.classes.get(item.data)
+        except TypeError:     # item.data may not be hashable (e.g., list)
+            return e, 0
+
+        if c is not None:
+            e = c.classObject
+        else:
+            v = codeSource.module.variables.get(item.data)
+            if v is not None:
+                return v, (v.type == types.StringType)
+    return e, 0
+
+_UNCHECKABLE_CATCH_TYPES = (Stack.TYPE_UNKNOWN, Stack.TYPE_ATTRIBUTE)
+def _checkCatchException(codeSource, code, item):
+    if not cfg().badExceptions:
+        return
+
+    if item.data is None or item.type in _UNCHECKABLE_CATCH_TYPES:
+        return
+
+    e, is_str = _getExceptionInfo(codeSource, item)
+    if is_str:
+        code.addWarning(msgs.CATCH_STR_EXCEPTION % item.data)
+    elif e is not None and not _isexception(e):
+        code.addWarning(msgs.CATCH_BAD_EXCEPTION % item.data)
+
+def _handleExceptionChecks(codeSource, code, checks):
+    for item in checks:
+        if item is not None:
+            if item.type is not types.TupleType:
+                _checkCatchException(codeSource, code, item)
+            else:
+                for ti in item.data:
+                    if isinstance(ti, Stack.Item):
+                        _checkCatchException(codeSource, code, ti)
+
+_BOOL_NAMES = ('True', 'False')
+_BAD_ASSIGN_NAMES = _BOOL_NAMES + ('None',)
+
+def _checkBoolean(code, checks):
+    for item in checks:
+        try:
+            data = string.capitalize(item.data)
+            if item.type is Stack.TYPE_GLOBAL and data in _BOOL_NAMES:
+                code.addWarning(msgs.BOOL_COMPARE % item.data)
+        except (AttributeError, TypeError):
+            # TypeError is necessary for Python 1.5.2
+            pass # ignore items that are not a StackItem or a string
+
+def _COMPARE_OP(oparg, operand, codeSource, code) :
+    compareValues = _handleComparison(code.stack, operand)
+    if oparg == OP.EXCEPT_COMPARISON:
+        _handleExceptionChecks(codeSource, code, compareValues)
+    elif oparg < OP.IN_COMPARISON: # '<', '<=', '==', '!=', '>', '>='
+        _checkBoolean(code, compareValues)
+    elif oparg < OP.IS_COMPARISON: # 'in', 'not in'
+        # TODO: any checks that should be done here?
+        pass
+    elif cfg().isLiteral:
+        # X is Y   or   X is not Y   comparison
+        second_arg = code.stack[-1].data[2]
+        # FIXME: how should booleans be handled, need to think about it
+##        if second_arg.const or (second_arg.type == Stack.TYPE_GLOBAL and
+##                                second_arg.data in ['True', 'False']):
+        if second_arg.const and second_arg.data is not None:
+            data = second_arg.data
+            if second_arg.type is types.DictType:
+                data = {}
+            not_str = ''
+            if oparg != OP.IS_COMPARISON:
+                not_str = ' not'
+            code.addWarning(msgs.IS_LITERAL % (not_str, data))
+
+    _checkNoEffect(code)
+
+def _IMPORT_NAME(oparg, operand, codeSource, code) :
+    code.pushStack(Stack.Item(operand, types.ModuleType))
+    nextOp = code.nextOpInfo()[0]
+    if not OP.IMPORT_FROM(nextOp) and not OP.IMPORT_STAR(nextOp) :
+        _handleImport(code, operand, codeSource.module, codeSource.main, None)
+
+def _IMPORT_FROM(oparg, operand, codeSource, code) :
+    _handleImportFrom(code, operand, codeSource.module, codeSource.main)
+    # this is necessary for python 1.5 (see STORE_GLOBAL/NAME)
+    if utils.pythonVersion() < utils.PYTHON_2_0 :
+        code.popStack()
+        if not codeSource.main :
+            code.unusedLocals[operand] = None
+        elif not codeSource.module.moduleLineNums.has_key(operand) :
+            code.updateModuleLineNums(codeSource.module, operand)
+
+def _IMPORT_STAR(oparg, operand, codeSource, code) :
+    _handleImportFrom(code, '*', codeSource.module, codeSource.main)
+
+# Python 2.3 introduced some optimizations that create problems
+# this is a utility for ignoring these cases
+def _shouldIgnoreCodeOptimizations(code, bytecodes, offset, length=None):
+    if utils.pythonVersion() < utils.PYTHON_2_3:
+        return 0
+
+    if length is None:
+        length = offset - 1
+    try:
+        start = code.index - offset
+        return bytecodes == code.bytes[start:start+length]
+    except IndexError:
+        return 0
+
+# In Python 2.3, a, b = 1,2 generates this code:
+# ...
+# ROT_TWO
+# JUMP_FORWARD 2
+# DUP_TOP
+# POP_TOP
+#
+# which generates a Possible stmt w/no effect
+
+# ROT_TWO = 2; JUMP_FORWARD = 110; 2, 0 is the offset (2)
+_IGNORE_SEQ = '%c%c%c%c' % (2, 110, 2, 0)
+def _shouldIgnoreNoEffectWarning(code):
+    return _shouldIgnoreCodeOptimizations(code, _IGNORE_SEQ, 5)
+
+def _DUP_TOP(oparg, operand, codeSource, code) :
+    if len(code.stack) > 0 :
+        code.pushStack(code.stack[-1], _shouldIgnoreNoEffectWarning(code))
+
+def _popn(code, n) :
+    if len(code.stack) >= 2 :
+        loadValue = code.stack[-2]
+        if cfg().modifyDefaultValue and loadValue.type == types.StringType :
+            _checkModifyDefaultArg(code, loadValue.data)
+
+    code.popStackItems(n)
+    
+def _DELETE_SUBSCR(oparg, operand, codeSource, code) :
+    _popn(code, 2)
+
+def _STORE_SUBSCR(oparg, operand, codeSource, code) :
+    _popn(code, 3)
+
+def _CALL_FUNCTION(oparg, operand, codeSource, code) :
+    _handleFunctionCall(codeSource, code, oparg)
+
+def _CALL_FUNCTION_VAR(oparg, operand, codeSource, code) :
+    _handleFunctionCall(codeSource, code, oparg, 1, 0)
+
+def _CALL_FUNCTION_KW(oparg, operand, codeSource, code) :
+    _handleFunctionCall(codeSource, code, oparg, 1)
+
+def _CALL_FUNCTION_VAR_KW(oparg, operand, codeSource, code) :
+    _handleFunctionCall(codeSource, code, oparg, 2, 0)
+
+def _MAKE_FUNCTION(oparg, operand, codeSource, code) :
+    newValue = Stack.makeFuncReturnValue(code.stack[-1], oparg)
+    code.popStackItems(oparg+1)
+    code.pushStack(newValue)
+
+def _MAKE_CLOSURE(oparg, operand, codeSource, code) :
+    _MAKE_FUNCTION(max(0, oparg - 1), operand, codeSource, code)
+
+def _BUILD_MAP(oparg, operand, codeSource, code) :
+    _makeConstant(code, oparg, Stack.makeDict)
+def _BUILD_TUPLE(oparg, operand, codeSource, code) :
+    _makeConstant(code, oparg, Stack.makeTuple)
+def _BUILD_LIST(oparg, operand, codeSource, code) :
+    _makeConstant(code, oparg, Stack.makeList)
+
+def _BUILD_CLASS(oparg, operand, codeSource, code) :
+    newValue = Stack.makeFuncReturnValue(code.stack[-1], types.ClassType)
+    code.popStackItems(3)
+    code.pushStack(newValue)
+
+def _LIST_APPEND(oparg, operand, codeSource, code):
+    code.popStackItems(2)
+
+def _modifyStackName(code, suffix):
+    if code.stack:
+        tos = code.stack[-1]
+        tos_type = type(tos.data)
+        if tos_type == types.StringType:
+            tos.data = tos.data + suffix
+        elif tos_type == types.TupleType and \
+             type(tos.data[-1]) == types.StringType:
+            tos.data = tos.data[:-1] + (tos.data[-1] + suffix,)
+
+def _UNARY_CONVERT(oparg, operand, codeSource, code) :
+    if code.stack:
+        stackValue = code.stack[-1]
+        if stackValue.data == cfg().methodArgName and \
+           stackValue.const == 0 and codeSource.classObject is not None and \
+           codeSource.func.function.func_name == '__repr__' :
+            code.addWarning(msgs.USING_SELF_IN_REPR)
+        stackValue.data = utils.safestr(stackValue.data)
+        stackValue.type = types.StringType
+    _modifyStackName(code, '-repr')
+
+def _UNARY_POSITIVE(oparg, operand, codeSource, code) :
+    if OP.UNARY_POSITIVE(code.nextOpInfo()[0]) :
+        code.addWarning(msgs.STMT_WITH_NO_EFFECT % '++')
+        code.popNextOp()
+    elif cfg().unaryPositive and code.stack and not code.stack[-1].const :
+        code.addWarning(msgs.UNARY_POSITIVE_HAS_NO_EFFECT)
+    _modifyStackName(code, '-pos')
+
+def _UNARY_NEGATIVE(oparg, operand, codeSource, code) :
+    if OP.UNARY_NEGATIVE(code.nextOpInfo()[0]) :
+        code.addWarning(msgs.STMT_WITH_NO_EFFECT % '--')
+    _modifyStackName(code, '-neg')
+
+def _UNARY_NOT(oparg, operand, codeSource, code) :
+    _modifyStackName(code, '-not')
+
+def _UNARY_INVERT(oparg, operand, codeSource, code) :
+    if OP.UNARY_INVERT(code.nextOpInfo()[0]) :
+        code.addWarning(msgs.STMT_WITH_NO_EFFECT % '~~')
+    _modifyStackName(code, '-invert')
+
+
+def _popStackRef(code, operand, count = 2) :
+    code.popStackItems(count)
+    code.pushStack(Stack.Item(operand, Stack.TYPE_UNKNOWN))
+
+def _popModifiedStack(code, suffix=' '):
+    code.popStack()
+    _modifyStackName(code, suffix)
+
+def _pop(oparg, operand, codeSource, code) :
+    code.popStack()
+_POP_TOP = _PRINT_ITEM = _pop
+
+def _popModified(oparg, operand, codeSource, code):
+    _popModifiedStack(code)
+
+def _BINARY_RSHIFT(oparg, operand, codeSource, code):
+    _coerce_type(code)
+    _popModified(oparg, operand, codeSource, code)
+_BINARY_LSHIFT = _BINARY_RSHIFT
+
+def _checkModifyNoOp(code, op, msg=msgs.MODIFY_VAR_NOOP, modifyStack=1):
+    stack = code.stack
+    if len(stack) >= 2:
+        if (stack[-1].type != Stack.TYPE_UNKNOWN and
+            stack[-2].type != Stack.TYPE_UNKNOWN):
+            name = stack[-1].getName()
+            if name != Stack.TYPE_UNKNOWN and name == stack[-2].getName():
+                code.addWarning(msg % (name, op, name))
+
+        if modifyStack:
+            code.popStack()
+            stack[-1].const = 0
+            _modifyStackName(code, op)
+
+def _BINARY_AND(oparg, operand, codeSource, code):
+    # Don't modify the stack, since _coerce_type() will do it.
+    _checkModifyNoOp(code, '&', modifyStack=0)
+    _coerce_type(code)
+
+def _BINARY_OR(oparg, operand, codeSource, code):
+    # Don't modify the stack, since _coerce_type() will do it.
+    _checkModifyNoOp(code, '|', modifyStack=0)
+    _coerce_type(code)
+
+def _BINARY_XOR(oparg, operand, codeSource, code):
+    # Don't modify the stack, since _coerce_type() will do it.
+    _checkModifyNoOp(code, '^', msgs.XOR_VAR_WITH_ITSELF, modifyStack=0)
+    _coerce_type(code)
+
+def _PRINT_ITEM_TO(oparg, operand, codeSource, code) :
+    code.popStackItems(2)
+
+try:
+    ComplexType = types.ComplexType
+except NameError:
+    ComplexType = types.FloatType    # need some numeric type here
+
+_NUMERIC_TYPES = (types.IntType, types.FloatType, ComplexType)
+
+# FIXME: This is pathetically weak, need to handle more types
+def _coerce_type(code) :
+    _checkNoEffect(code)
+    newItem = Stack.Item('<stack>', Stack.TYPE_UNKNOWN)
+    if len(code.stack) >= 2 :
+        s1, s2 = code.stack[-2:]
+        s1type = s1.getType(code.typeMap)
+        s2type = s2.getType(code.typeMap)
+        if s1type != s2type :
+            if s1type in _NUMERIC_TYPES and s2type in _NUMERIC_TYPES :
+                newType = types.FloatType
+                if s1type == ComplexType or s2type == ComplexType:
+                    newType = ComplexType
+                newItem.type = newType
+
+    code.popStackItems(2)
+    code.pushStack(newItem)
+
+def _BINARY_ADD(oparg, operand, codeSource, code) :
+    stack = code.stack
+    if len(stack) >= 2 and (stack[-1].const and stack[-2].const and
+                            stack[-1].type == stack[-2].type) :
+        value = stack[-2].data + stack[-1].data
+        code.popStackItems(2)
+        code.pushStack(Stack.Item(value, type(value), 1))
+    else :
+        _coerce_type(code)
+
+def _BINARY_SUBTRACT(oparg, operand, codeSource, code) :
+    _coerce_type(code)
+_BINARY_POWER = _BINARY_SUBTRACT
+
+def _BINARY_SUBSCR(oparg, operand, codeSource, code) :
+    _checkNoEffect(code)
+    if len(code.stack) >= 2 :
+        stack = code.stack
+        varType = code.typeMap.get(utils.safestr(stack[-2].data), [])
+        if types.ListType in varType and stack[-1].type == types.TupleType :
+            code.addWarning(msgs.USING_TUPLE_ACCESS_TO_LIST % stack[-2].data)
+    _popStackRef(code, operand)
+
+def _isint(stackItem, code) :
+    if type(stackItem.data) == types.IntType :
+        return 1
+    stackTypes = code.typeMap.get(stackItem.data, [])
+    if len(stackTypes) != 1 :
+        return 0
+    return types.IntType in stackTypes
+
+def _BINARY_DIVIDE(oparg, operand, codeSource, code) :
+    _checkNoEffect(code)
+    _checkModifyNoOp(code, '/', msgs.DIVIDE_VAR_BY_ITSELF, 0)
+    if cfg().intDivide and len(code.stack) >= 2 :
+        if _isint(code.stack[-1], code) and _isint(code.stack[-2], code) :
+            # don't warn if we are going to convert the result to an int
+            if not (len(code.stack) >= 3 and
+                    code.stack[-3].data == 'int' and
+                    OP.CALL_FUNCTION(code.nextOpInfo()[0])):
+                code.addWarning(msgs.INTEGER_DIVISION % tuple(code.stack[-2:]))
+
+    _popModifiedStack(code, '/')
+
+def _BINARY_TRUE_DIVIDE(oparg, operand, codeSource, code) :
+    _checkNoEffect(code)
+    _checkVariableOperationOnItself(code, operand, msgs.DIVIDE_VAR_BY_ITSELF)
+    _popModifiedStack(code, '/')
+_BINARY_FLOOR_DIVIDE = _BINARY_TRUE_DIVIDE
+
+def _BINARY_MULTIPLY(oparg, operand, codeSource, code) :
+    if len(code.stack) >= 2 :
+        format = _getFormatString(code, codeSource)
+        if format and type(code.stack[-1].data) == types.IntType :
+            code.stack[-2].data = format * code.stack[-1].data
+            code.popStack()
+        else:
+            _coerce_type(code)
+    else:
+        _popModifiedStack(code, '*')
+
+def _BINARY_MODULO(oparg, operand, codeSource, code) :
+    _checkNoEffect(code)
+    if cfg().modulo1 and code.stack and code.stack[-1].data == 1:
+        if len(code.stack) < 2 or \
+           code.stack[-2].getType(code.typeMap) != types.FloatType:
+            code.addWarning(msgs.MODULO_1)
+    _getFormatWarnings(code, codeSource)
+    _popModifiedStack(code, '%')
+    if code.stack:
+        code.stack[-1].const = 0
+
+def _ROT_TWO(oparg, operand, codeSource, code) :
+    if len(code.stack) >= 2 :
+        tmp = code.stack[-2]
+        code.stack[-2] = code.stack[-1]
+        code.stack[-1] = tmp
+
+def _ROT_THREE(oparg, operand, codeSource, code) :
+    """Lifts second and third stack item one position up,
+       moves top down to position three."""
+    if len(code.stack) >= 3 :
+        second = code.stack[-2]
+        third = code.stack[-3]
+        code.stack[-3] = code.stack[-1]
+        code.stack[-2] = third
+        code.stack[-1] = second
+
+def _ROT_FOUR(oparg, operand, codeSource, code) :
+    """Lifts second, third and forth stack item one position up,
+       moves top down to position four."""
+    if len(code.stack) >= 4 :
+        second = code.stack[-2]
+        third = code.stack[-3]
+        fourth = code.stack[-4]
+        code.stack[-4] = code.stack[-1]
+        code.stack[-3] = fourth
+        code.stack[-2] = third
+        code.stack[-1] = second
+
+def _SETUP_EXCEPT(oparg, operand, codeSource, code) :
+    code.has_except = 1
+    code.pushStack(Stack.Item(None, Stack.TYPE_EXCEPT))
+    code.pushStack(Stack.Item(None, Stack.TYPE_EXCEPT))
+
+def _SETUP_FINALLY(oparg, operand, codeSource, code) :
+    if not code.has_except :
+        code.try_finally_first = 1
+
+def _END_FINALLY(oparg, operand, codeSource, code) :
+    if code.try_finally_first and code.index == (len(code.bytes) - 4) :
+        code.starts_and_ends_with_finally = 1
+
+def _LINE_NUM(oparg, operand, codeSource, code) :
+    code.lastLineNum = oparg
+
+def _UNPACK_SEQUENCE(oparg, operand, codeSource, code) :
+    code.unpackCount = oparg
+    if code.stack:
+        top = code.stack[-1]
+        # if we know we have a tuple, make sure we unpack it into the
+        # right # of variables
+        topType = top.getType(code.typeMap)
+        if topType in _SEQUENCE_TYPES:
+            length = top.length
+            # we don't know the length, maybe it's constant and we can find out
+            if length == 0:
+                value = code.constants.get(utils.safestr(top.data))
+                if type(value) in _SEQUENCE_TYPES:
+                    length = len(value)
+            if length > 0 and length != oparg:
+                if cfg().unpackLength:
+                    code.addWarning(msgs.WRONG_UNPACK_SIZE % (length, oparg))
+        elif topType not in _UNCHECKABLE_STACK_TYPES:
+            if cfg().unpackNonSequence:
+                code.addWarning(msgs.UNPACK_NON_SEQUENCE %
+                                (top.data, _getTypeStr(topType)))
+        _modifyStackName(code, '-unpack')
+
+def _SLICE_1_ARG(oparg, operand, codeSource, code) :
+    _popStackRef(code, operand)
+    
+_SLICE1 = _SLICE2 = _SLICE_1_ARG
+
+def _SLICE3(oparg, operand, codeSource, code) :
+    _popStackRef(code, operand, 3)
+
+def _check_string_iteration(code, index):
+    try:
+        item = code.stack[index]
+    except IndexError:
+        return
+    if item.getType(code.typeMap) == types.StringType and \
+       cfg().stringIteration:
+        code.addWarning(msgs.STRING_ITERATION % item.data)
+
+def _FOR_LOOP(oparg, operand, codeSource, code) :
+    code.loops = code.loops + 1
+    _check_string_iteration(code, -2)
+    _popStackRef(code, '<for_loop>', 2)
+
+def _GET_ITER(oparg, operand, codeSource, code) :
+    _check_string_iteration(code, -1)
+
+def _FOR_ITER(oparg, operand, codeSource, code) :
+    code.loops = code.loops + 1
+    _popStackRef(code, '<for_iter>', 1)
+
+def _jump(oparg, operand, codeSource, code) :
+    if len(code.stack) > 0 :
+        topOfStack = code.stack[-1]
+        if topOfStack.isMethodCall(codeSource.classObject, cfg().methodArgName):
+            name = topOfStack.data[-1]
+            if codeSource.classObject.methods.has_key(name) :
+                code.addWarning(msgs.USING_METHOD_AS_ATTR % name)
+_JUMP_ABSOLUTE = _jump
+
+def _skip_loops(bytes, i, lastLineNum, max) :
+    extended_arg = 0
+    blockCount = 1
+    while i < max :
+        op, oparg, i, extended_arg = OP.getInfo(bytes, i, extended_arg)
+        if OP.LINE_NUM(op) :
+            lastLineNum = oparg
+        elif OP.FOR_LOOP(op) or OP.FOR_ITER(op) or OP.SETUP_LOOP(op) :
+            blockCount = blockCount + 1
+        elif OP.POP_BLOCK(op) :
+            blockCount = blockCount - 1
+            if blockCount <= 0 :
+                break
+
+    return lastLineNum, i
+
+def _is_unreachable(code, topOfStack, branch, if_false) :
+    # Are we are checking exceptions, but we not catching all exceptions?
+    if (topOfStack.type == Stack.TYPE_COMPARISON and 
+        topOfStack.data[1] == 'exception match' and 
+        topOfStack.data[2] is not Exception) :
+        return 1
+
+    # do we possibly have while 1: ?
+    if not (topOfStack.const and topOfStack.data == 1 and if_false) :
+        return 0
+
+    # get the op just before the branch (ie, -3)
+    op, oparg, i, extended_arg = OP.getInfo(code.bytes, branch - 3, 0)
+    # are we are jumping to before the while 1: (LOAD_CONST, JUMP_IF_FALSE)
+    if not (OP.JUMP_ABSOLUTE(op) and oparg == (code.index - 3*3)) :
+        return 0
+
+    # check if we break out of the loop
+    i = code.index
+    lastLineNum = code.getLineNum()
+    while i < branch :
+        op, oparg, i, extended_arg = OP.getInfo(code.bytes, i, extended_arg)
+        if OP.LINE_NUM(op) :
+            lastLineNum = oparg
+        elif OP.BREAK_LOOP(op) :
+            return 0
+        elif OP.FOR_LOOP(op) or OP.FOR_ITER(op) or OP.SETUP_LOOP(op) :
+            lastLineNum, i = _skip_loops(code.bytes, i, lastLineNum, branch)
+
+    i = code.index - 3*4
+    op, oparg, i, extended_arg = OP.getInfo(code.bytes, i, 0)
+    if OP.SETUP_LOOP(op) :
+        # a little lie to pretend we have a raise after a while 1:
+        code.removeBranch(i + oparg)
+        code.raiseValues.append((lastLineNum, None, i + oparg))
+    return 1
+
+# In Python 2.3, while/if 1: gets optimized to
+# ...
+# JUMP_FORWARD 4
+# JUMP_IF_FALSE ?
+# POP_TOP
+#
+# which generates a Using a conditional statement with a constant value
+
+# JUMP_FORWARD = 110; 4, 0 is the offset (4)
+_IGNORE_BOGUS_JUMP = '%c%c%c' % (110, 4, 0)
+def _shouldIgnoreBogusJumps(code):
+    return _shouldIgnoreCodeOptimizations(code, _IGNORE_BOGUS_JUMP, 6, 3)
+
+def _checkConstantCondition(code, topOfStack, if_false):
+    # don't warn when doing (test and 'true' or 'false')
+    # still warn when doing (test and None or 'false')
+    if if_false or not OP.LOAD_CONST(code.nextOpInfo(1)[0]) or \
+       not topOfStack.data or topOfStack.type is types.NoneType:
+        if not _shouldIgnoreBogusJumps(code):
+            code.addWarning(msgs.CONSTANT_CONDITION % utils.safestr(topOfStack))
+    
+def _jump_conditional(oparg, operand, codeSource, code, if_false) :
+    # FIXME: this doesn't work in 2.3+ since constant conditions
+    #        are optimized away by the compiler.
+    if code.stack :
+        topOfStack = code.stack[-1]
+        if (topOfStack.const or topOfStack.type is types.NoneType) and \
+           cfg().constantConditions and \
+           (topOfStack.data != 1 or cfg().constant1):
+            _checkConstantCondition(code, topOfStack, if_false)
+
+        if _is_unreachable(code, topOfStack, code.label, if_false) :
+            code.removeBranch(code.label)
+
+    _jump(oparg, operand, codeSource, code)
+
+def _JUMP_IF_FALSE(oparg, operand, codeSource, code) :
+    _jump_conditional(oparg, operand, codeSource, code, 1)
+
+def _JUMP_IF_TRUE(oparg, operand, codeSource, code) :
+    _jump_conditional(oparg, operand, codeSource, code, 0)
+
+def _JUMP_FORWARD(oparg, operand, codeSource, code) :
+    _jump(oparg, operand, codeSource, code)
+    code.remove_unreachable_code(code.label)
+
+def _RETURN_VALUE(oparg, operand, codeSource, code) :
+    if not codeSource.calling_code :
+        code.addReturn()
+
+def _EXEC_STMT(oparg, operand, codeSource, code) :
+    if cfg().usesExec :
+        if code.stack and code.stack[-1].isNone() :
+            code.addWarning(msgs.USES_GLOBAL_EXEC)
+        else :
+            code.addWarning(msgs.USES_EXEC)
+
+def _checkStrException(code, varType, item):
+    if varType is types.StringType:
+        code.addWarning(msgs.RAISE_STR_EXCEPTION % item.data)
+
+def _RAISE_VARARGS(oparg, operand, codeSource, code) :
+    code.addRaise()
+    if not cfg().badExceptions:
+        return
+
+    if oparg > 0 and len(code.stack) >= oparg:
+        item = code.stack[-oparg]
+        if item.type not in (Stack.TYPE_FUNC_RETURN, Stack.TYPE_UNKNOWN):
+            if item.type is Stack.TYPE_GLOBAL:
+                e, is_str = _getExceptionInfo(codeSource, item)
+                if is_str:
+                    _checkStrException(code, e.type, item)
+                elif e is not None and not _isexception(e):
+                    code.addWarning(msgs.RAISE_BAD_EXCEPTION % item.data)
+            else:
+                _checkStrException(code, item.getType(code.typeMap), item)
+
+
+DISPATCH = [ None ] * 256
+DISPATCH[  1] = _POP_TOP
+DISPATCH[  2] = _ROT_TWO
+DISPATCH[  3] = _ROT_THREE
+DISPATCH[  4] = _DUP_TOP
+DISPATCH[  5] = _ROT_FOUR
+DISPATCH[ 10] = _UNARY_POSITIVE
+DISPATCH[ 11] = _UNARY_NEGATIVE
+DISPATCH[ 12] = _UNARY_NOT
+DISPATCH[ 13] = _UNARY_CONVERT
+DISPATCH[ 15] = _UNARY_INVERT
+DISPATCH[ 18] = _LIST_APPEND
+DISPATCH[ 19] = _BINARY_POWER
+DISPATCH[ 20] = _BINARY_MULTIPLY
+DISPATCH[ 21] = _BINARY_DIVIDE
+DISPATCH[ 22] = _BINARY_MODULO
+DISPATCH[ 23] = _BINARY_ADD
+DISPATCH[ 24] = _BINARY_SUBTRACT
+DISPATCH[ 25] = _BINARY_SUBSCR
+DISPATCH[ 26] = _BINARY_FLOOR_DIVIDE
+DISPATCH[ 27] = _BINARY_TRUE_DIVIDE
+# FIXME: add INPLACE FLOOR/TRUE DIVIDE: 28/29
+DISPATCH[ 31] = _SLICE1
+DISPATCH[ 32] = _SLICE2
+DISPATCH[ 33] = _SLICE3
+DISPATCH[ 55] = _BINARY_ADD             # INPLACE
+DISPATCH[ 56] = _BINARY_SUBTRACT        # INPLACE
+DISPATCH[ 57] = _BINARY_MULTIPLY        # INPLACE
+DISPATCH[ 58] = _BINARY_DIVIDE          # INPLACE
+DISPATCH[ 59] = _BINARY_MODULO          # INPLACE
+DISPATCH[ 60] = _STORE_SUBSCR
+DISPATCH[ 61] = _DELETE_SUBSCR
+DISPATCH[ 62] = _BINARY_LSHIFT
+DISPATCH[ 63] = _BINARY_RSHIFT
+DISPATCH[ 64] = _BINARY_AND
+DISPATCH[ 65] = _BINARY_XOR
+DISPATCH[ 66] = _BINARY_OR
+DISPATCH[ 67] = _BINARY_POWER           # INPLACE
+DISPATCH[ 68] = _GET_ITER
+DISPATCH[ 71] = _PRINT_ITEM
+DISPATCH[ 73] = _PRINT_ITEM_TO
+DISPATCH[ 75] = _BINARY_LSHIFT          # INPLACE
+DISPATCH[ 76] = _BINARY_RSHIFT          # INPLACE
+DISPATCH[ 77] = _BINARY_AND             # INPLACE
+DISPATCH[ 78] = _BINARY_XOR             # INPLACE
+DISPATCH[ 79] = _BINARY_OR              # INPLACE
+DISPATCH[ 83] = _RETURN_VALUE
+DISPATCH[ 84] = _IMPORT_STAR
+DISPATCH[ 85] = _EXEC_STMT
+DISPATCH[ 88] = _END_FINALLY
+DISPATCH[ 89] = _BUILD_CLASS
+DISPATCH[ 90] = _STORE_NAME
+DISPATCH[ 91] = _DELETE_NAME
+DISPATCH[ 92] = _UNPACK_SEQUENCE
+DISPATCH[ 93] = _FOR_ITER
+DISPATCH[ 95] = _STORE_ATTR
+DISPATCH[ 96] = _DELETE_ATTR
+DISPATCH[ 97] = _STORE_GLOBAL
+DISPATCH[ 98] = _DELETE_GLOBAL
+DISPATCH[100] = _LOAD_CONST
+DISPATCH[101] = _LOAD_NAME
+DISPATCH[102] = _BUILD_TUPLE
+DISPATCH[103] = _BUILD_LIST
+DISPATCH[104] = _BUILD_MAP
+DISPATCH[105] = _LOAD_ATTR
+DISPATCH[106] = _COMPARE_OP
+DISPATCH[107] = _IMPORT_NAME
+DISPATCH[108] = _IMPORT_FROM
+DISPATCH[110] = _JUMP_FORWARD
+DISPATCH[111] = _JUMP_IF_FALSE
+DISPATCH[112] = _JUMP_IF_TRUE
+DISPATCH[113] = _JUMP_ABSOLUTE
+DISPATCH[114] = _FOR_LOOP
+DISPATCH[116] = _LOAD_GLOBAL
+DISPATCH[121] = _SETUP_EXCEPT
+DISPATCH[122] = _SETUP_FINALLY
+DISPATCH[124] = _LOAD_FAST
+DISPATCH[125] = _STORE_FAST
+DISPATCH[126] = _DELETE_FAST
+DISPATCH[127] = _LINE_NUM
+DISPATCH[130] = _RAISE_VARARGS
+DISPATCH[131] = _CALL_FUNCTION
+DISPATCH[132] = _MAKE_FUNCTION
+DISPATCH[134] = _MAKE_CLOSURE
+DISPATCH[135] = _LOAD_CLOSURE
+DISPATCH[136] = _LOAD_DEREF
+DISPATCH[140] = _CALL_FUNCTION_VAR
+DISPATCH[141] = _CALL_FUNCTION_KW
+DISPATCH[142] = _CALL_FUNCTION_VAR_KW


[21/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code

Posted by rl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/TODO
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/TODO b/tools/bin/pythonSrc/PSI-0.3b2_gp/TODO
new file mode 100644
index 0000000..96b2f94
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/TODO
@@ -0,0 +1,72 @@
+* Mark all symbols not needed by Python as hidden
+
+   The ELF standard allows you to mark symbols as hidden.  These
+   symbols are global since they might be needed by other object
+   files, however once the object files are linked into a Dynamic
+   Shared Object (DSO) the hidden symbols are no longer visable.  The
+   equivalent of this on XCOFF would have to be found too.
+
+* Improve finding the terminal on Linux
+
+   A scheme like aix_process.c uses should be used, but it should be
+   improved slightly so that it will check the device id of the
+   finally found device file.  And this code should probably be shared
+   between all POSIX systems.
+
+* Consider using PSI_STATUS_NA instead of ifdeffing around
+
+   All the #ifdef blocks around descriptors/attributes and their
+   respective getter functions is just going to spiral out of
+   control.  Maybe all attributes should just be always available but
+   raise an AttrNotApplicableError when accessed?
+
+* Create a libpsi.a static library
+
+   All utility functions should go into libpsi.a to simplify getting
+   the correct dependencies in setup.py, this is arleady turning into
+   an unmaintainable hell.  The setup.py script should then use
+   distutils.ccompiler.has_function() and friends to produce a
+   config.h for libpsi to know what to build.  This library can be
+   built using the build_clib command from distutils.
+
+   This will also mean that individual modules will be smaller since
+   only the used symbols will exist in the sofiles, intead of all of
+   them.
+
+* Simplify module sources
+
+   Code that is shared between archs should end up in libpsi.a.  And
+   each arch must have it's <arch>_<thing>.c file, even if it is just
+   calling the shared function an no more.
+
+* Introduce procfs_read_struct()?
+
+   For SunOS and AIX /proc files it could be possible, and safer and
+   faster, not to dynamically allocate the memory but rather read into
+   a statically allocated space.  You'd use it like:
+
+     struct psinfo psinfo;
+
+     if (procfs_read_struct(&psinfo, sizeof(struct psinfo), pid, "psinfo") < 0)
+         return -1;
+
+* Consider renaming the arch module
+
+   The arch module really describes the whole system, not just the
+   architecture.  Therefore the name is a bit misleading.  However
+   calling it `sys' would clash with the stdlib sys module and
+   `system' seems a bit long.
+
+   How about `plat' or `platform'?  Note that `platform' is an stdlib
+   module, so that might be a bad idea.
+
+* Improve InsufficientPrivs error message
+
+   It would be good if psi_checkattr() could also say what process the
+   error message is for instead of just the attribute.
+
+* Consider having ArchLinux24 and ArchLinux26 sub-types
+
+   In the unittests I find myself having to say `if isinstance(arch,
+   ArchLinux) and arch.release[:3] == "2.6"' often.  Maybe it would be
+   easier if we could say `if isinstance(arch, ArchLinux26)'?

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/examples/process_details.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/examples/process_details.py b/tools/bin/pythonSrc/PSI-0.3b2_gp/examples/process_details.py
new file mode 100644
index 0000000..1acdf2a
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/examples/process_details.py
@@ -0,0 +1,165 @@
+#!/usr/bin/env python
+
+# The MIT License
+#
+# Copyright (C) 2007  Chris Miles
+#
+# Copyright (C) 2009  Floris Bruynooghe
+#
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation files
+# (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge,
+# publish, distribute, sublicense, and/or sell copies of the Software,
+# and to permit persons to whom the Software is furnished to do so,
+# subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+
+"""process_details.py
+
+Display information about a running process.
+"""
+
+
+__author__ = 'Chris Miles'
+__copyright__ = """\
+Copyright (C) 2007  Chris Miles
+Copyright (C) 2009  Floris Bruynooghe
+"""
+__version__ = '0.2'
+
+
+import grp
+import optparse
+import os
+import pwd
+import sys
+from datetime import datetime
+
+import psi.arch
+import psi.process
+
+
+help_message = 'Display information about a running process'
+
+
+def run(pid):
+    a = psi.arch.arch_type()
+    print "Python %s / PSI %s / %s %s" % (
+        '.'.join([str(v) for v in sys.version_info[:3]]),
+        psi.__version__,
+        a.sysname,
+        a.release
+    )
+    
+    try:
+        p = psi.process.Process(pid)
+    except ValueError, e:
+        sys.stderr.write("%s\n"%e)
+        return 1
+    
+    print "\nProcess information:"
+    fmt = "  %-20s: %s"
+    print fmt %('Process ID', p.pid)
+    print fmt %('Parent Process ID', p.ppid)
+    print fmt %('Executable', getattr(p, 'exe', 'N/A'))
+    print fmt %('Command', p.command)
+
+    try:
+        v = ' '.join(p.args)
+    except psi.AttrInsufficientPrivsError, e:
+        v = str(e)
+    print fmt %('Full Command', v)
+
+    print fmt %('Effective user', '%s (%d)'
+                % (pwd.getpwuid(p.euid).pw_name, p.euid))
+    print fmt %('Real user', '%s (%d)'
+                % (pwd.getpwuid(p.ruid).pw_name, p.ruid))
+    print fmt %('Effective group', '%s (%d)'
+                %(grp.getgrgid(p.egid).gr_name, p.egid))
+    print fmt %('Real group', '%s (%d)'
+                % (grp.getgrgid(p.rgid).gr_name, p.rgid))
+    print fmt %('Process group', p.pgrp)
+    print fmt %('Number of threads', getattr(p, 'nthreads', 'N/A'))
+    print fmt %('Started', str(p.start_time.datetime()))
+    
+    try:
+        status = p.status
+    except AttributeError, e:
+        value = str(e)
+    else:
+        all_status = [(s, getattr(psi.process, s)) for s in dir(psi.process)
+                      if s.startswith('PROC_STATUS_')]
+        proc_status = [s[0] for s in all_status if status == s[1]]
+        value = ', '.join(proc_status)
+    print fmt %('Status', value)
+
+    print fmt %('Terminal device', getattr(p, 'terminal', 'N/A'))
+    print fmt %('Environment', getattr(p, 'env', 'N/A'))
+
+    print "\nCPU Use:"
+    print fmt %('CPU seconds used', str(p.cputime.timedelta()))
+    try:
+        print ' '*24 + '(User: %s   System: %s)' % (p.utime.timedelta(),
+                                                    p.stime.timedelta())
+    except AttributeError:
+        pass
+    print fmt %('Recent CPU used', getattr(p, 'pcpu', 'N/A'))
+    print fmt %('Nice level', getattr(p, 'nice', 'N/A'))
+    print fmt %('Priority', getattr(p, 'priority', 'N/A'))
+    
+    print "\nMemory Use:"
+    print fmt %('Resident memory used', p.rss)
+    print fmt %('Virtual memory used', p.vsz)
+
+
+def main(argv=None):
+    if argv is None:
+        argv = sys.argv
+    
+    # define usage and version messages
+    usageMsg = "usage: %s [options] pid" % sys.argv[0]
+    versionMsg = """%s %s""" % (os.path.basename(argv[0]), __version__)
+    
+    # get a parser object and define our options
+    parser = optparse.OptionParser(usage=usageMsg, version=versionMsg)
+    
+    parser.add_option('-S', '--self', dest='self',
+            action='store_true', default=False,
+            help="Show information about itself")
+    
+    # Parse options & arguments
+    (options, args) = parser.parse_args()
+    
+    if len(args) < 1 and not options.self:
+        parser.error("A process ID must be specified.")
+    if len(args) > 1:
+        parser.error("Only one process ID can be specified.")
+    
+    if options.self:
+        # introspect itself
+        pid = os.getpid()
+    else:
+        try:
+            pid = int(args[0])
+        except:
+            parser.error("Invalid process ID.")
+    
+    return run(pid)
+
+
+if __name__ == "__main__":
+    sys.exit(main())

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/include/arch.h
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/include/arch.h b/tools/bin/pythonSrc/PSI-0.3b2_gp/include/arch.h
new file mode 100644
index 0000000..c48263b
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/include/arch.h
@@ -0,0 +1,89 @@
+/* The MIT License
+ *
+ * Copyright (C) 2008-2009 Floris Bruynooghe
+ *
+ * Copyright (C) 2008-2009 Abilisoft Ltd.
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef ARCH_H
+#define ARCH_H
+
+
+/** Architecrue info to be filled in by each architecture
+ *
+ * The *_status fields are for use with the PSI_STATUS_* constants in psi.h so
+ * don't forget to allocate this with psi_calloc().
+ */
+struct psi_archinfo {
+    char *sysname;              /* operating system name */
+    char *release;              /* release level of the operating system */
+    char *version;              /* version within release level */
+    char *machine;              /* hardware we're running on */
+    char *nodename;             /* host name */
+    int sysname_status;
+    int release_status;
+    int version_status;
+    int machine_status;
+    int nodename_status;
+};
+
+
+/** Return a newly allocated psi_archinfo structure
+ *
+ * This will have to be freed with psi_free() also on all the pointer
+ * members.
+ */
+struct psi_archinfo *psi_arch_archinfo(void);
+
+
+/** Free an psi_archinfo structure
+ *
+ * This function will check the pointers inside the psi_archinfo structure and
+ * call psi_free() on the non-NULL ones.  For this to work you should have
+ * allocated the memory with psi_calloc().
+ *
+ * The return value is always NULL so you can do `return psi_free_archinfo()'
+ * right away.
+ */
+void *psi_free_archinfo(struct psi_archinfo *archi);
+
+
+/* The following are for the archmodule only, not for arch implementations. */
+
+
+/* The Arch*_Type types */
+extern PyTypeObject PsiArchBase_Type;
+extern PyTypeObject PsiArchDarwin_Type;
+extern PyTypeObject PsiArchSunOS_Type;
+extern PyTypeObject PsiArchLinux_Type;
+extern PyTypeObject PsiArchAIX_Type;
+
+
+/* Return a new ArchBase instance */
+PyObject *PsiArchBase_New(void);
+
+
+/* Return a new Arch* instance representing the current architecture */
+PyObject *PsiArch_New(void);
+
+
+#endif /* ARCH_H */

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/include/linux_utils.h
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/include/linux_utils.h b/tools/bin/pythonSrc/PSI-0.3b2_gp/include/linux_utils.h
new file mode 100644
index 0000000..ad28f23
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/include/linux_utils.h
@@ -0,0 +1,46 @@
+/* The MIT License
+ *
+ * Copyright (C) 2009 Floris Bruynooghe
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef LINUX_UTILS_H
+#define LINUX_UTILS_H
+
+
+#include <Python.h>
+
+#include <time.h>
+
+
+/* Utility functions specific to Linux */
+
+
+/** psi_linux_uptime(&uptime, &idletime
+ *
+ * Retrieve the uptime and idle time from /proc/uptime.  Return -1 in case of
+ * failure, 0 for success.
+ */
+int psi_linux_uptime(struct timespec *uptime, struct timespec *idletime);
+
+
+#endif  /* LINUX_UTILS_H */

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/include/mount.h
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/include/mount.h b/tools/bin/pythonSrc/PSI-0.3b2_gp/include/mount.h
new file mode 100644
index 0000000..f2e7d36
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/include/mount.h
@@ -0,0 +1,126 @@
+/* The MIT License
+ *
+ * Copyright (C) 2009 Erick Tryzelaar
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef PSI_MOUNT_H
+#define PSI_MOUNT_H
+
+
+/** Mount info to be filled in by each architecture
+ *
+ * The *status fields are for use with the PSI_STATUS_* constants in psi.h so
+ * don't forget to allocate this with psi_calloc().
+ */
+typedef struct psi_mountinfo {
+    char *mount_type;           /* mount type */
+    char *mount_options;        /* mount options */
+    char *mount_path;           /* the mountpoint */
+    char *filesystem_host;      /* filesystem host, NULL means local host */
+    char *filesystem_path;      /* path of filesystem device */
+    unsigned long long frsize;  /* fragment size in bytes, unit of blocks */
+    unsigned long long total;   /* no. blocks on fs */
+    unsigned long long bfree;   /* no. free block */
+    unsigned long long bavail;  /* no. available block to non-root users */
+    unsigned long long files;   /* no. inodes */
+    unsigned long long ffree;   /* no. free inodes */
+    unsigned long long favail;  /* no. available indoes to non-root users */
+    int mount_type_status;
+    int mount_options_status;
+    int mount_path_status;
+    int filesystem_host_status;
+    int filesystem_path_status;
+    int frsize_status;
+    int total_status;
+    int bfree_status;
+    int bavail_status;
+    int files_status;
+    int ffree_status;
+    int favail_status;
+} psi_mountinfo_t;
+
+
+/** Free the psi_mountinfo structure
+ *
+ * This function will check all pointers in the passed psi_mountinfo structure
+ * and if they are non-NULL will call psi_free() on them.  At the end it will
+ * call psi_free() on the structure itself thus completely freeing the space
+ * used by the structure.
+ *
+ * Note that for this to work you must have allocated the structure with
+ * psi_calloc() so that all pointers are initialised to NULL.
+ *
+ * The return value is always NULL so you can just do `return
+ * psi_free_mountinfo()'
+ */
+void *psi_free_mountinfo(psi_mountinfo_t *mounti);
+
+
+/** An array with all the mounts
+ *
+ * The array with contain `count' mountpoints
+ */
+typedef struct psi_mountlist {
+    long count;
+    psi_mountinfo_t **mounts;
+} psi_mountlist_t;
+
+
+/** Create the mountlist structure
+ *
+ * Returns a struct psi_mountlist with all the mounts in or NULL in case of
+ * failure.
+ */
+psi_mountlist_t *psi_arch_mountlist(const int remote);
+
+
+/** Free the psi_mountlist structure
+ *
+ * This function will check all pointers in the passed psi_mountlist structure
+ * and if they are non-NULL will call psi_free() on them.  At the end it will
+ * call psi_free() on the structure itself thus completely freeing the space
+ * used by the structure.
+ *
+ * Note that for this to work you must have allocated the structure with
+ * psi_calloc() so that all pointers are initialised to NULL.
+ *
+ * The return value is always NULL so you can just do `return
+ * psi_free_mountlist()'
+ */
+void *psi_free_mountlist(psi_mountlist_t *prl);
+
+
+/* The following are for the mountmodule, not for mount
+ * implementations. */
+
+
+/* The Mount*_Type types */
+extern PyTypeObject MountBase_Type;
+extern PyTypeObject LocalMount_Type;
+extern PyTypeObject RemoteMount_Type;
+
+
+/* Return a new MountBase instance */
+PyObject *PsiMount_New(psi_mountinfo_t *mounti);
+
+
+#endif  /* PSI_MOUNT_H */

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/include/posix_mount.h
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/include/posix_mount.h b/tools/bin/pythonSrc/PSI-0.3b2_gp/include/posix_mount.h
new file mode 100644
index 0000000..19277a3
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/include/posix_mount.h
@@ -0,0 +1,42 @@
+/* The MIT License
+ *
+ * Copyright (C) 2009 Erick Tryzelaar
+ *
+ * Copyright (C) 2009 Floris Bruynooghe
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/* Mount related functions for POSIX implementations */
+
+#ifndef POSIX_MOUNT_H
+#define POSIX_MOUNT_H
+
+#include "mount.h"
+
+
+/** Set the filesystem size information
+ *
+ * This information comes from the POSIX statvfs() call.
+ */
+int posix_set_vfs(psi_mountinfo_t *mounti);
+
+
+#endif /* POSIX_MOUNT_H */

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/include/posix_utils.h
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/include/posix_utils.h b/tools/bin/pythonSrc/PSI-0.3b2_gp/include/posix_utils.h
new file mode 100644
index 0000000..9177801
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/include/posix_utils.h
@@ -0,0 +1,63 @@
+/* The MIT License
+ *
+ * Copyright (C) 2009 Erick Tryzelaar
+ *
+ * Copyright (C) 2009 Floris Bruynooghe
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/* Common functions for POSIX process implementations */
+
+#ifndef POSIX_UTILS_H
+#define POSIX_UTILS_H
+
+#include <time.h>
+
+
+/** Subtract two timeval values
+ *
+ * The result of `x - y' is returned
+ */
+struct timeval posix_timeval_subtract(struct timeval *x, struct timeval *y);
+
+
+/** Subtract two timespec values
+ *
+ * The result of `x - y' is returned
+ */
+struct timespec posix_timespec_subtract(struct timespec *x, struct timespec *y);
+
+
+/** Convert a double to a timespec structure */
+struct timespec posix_double2timespec(const double dbl);
+
+
+/** Read the boottime from the utmpx accounting file
+ *
+ * The returned time will be corrected for any clock changes since boot time.
+ *
+ * The boottime will be stored in the boottime parameter.  On an error -1 is
+ * returned, otherwise 0;
+ */
+int posix_utmpx_boottime(struct timespec *boottime);
+
+
+#endif /* POSIX_UTILS_H */

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/include/process.h
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/include/process.h b/tools/bin/pythonSrc/PSI-0.3b2_gp/include/process.h
new file mode 100644
index 0000000..ad32b22
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/include/process.h
@@ -0,0 +1,217 @@
+/* The MIT License
+ *
+ * Copyright (C) 2008-2009 Floris Bruynooghe
+ *
+ * Copyright (C) 2008-2009 Abilisoft Ltd.
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef PROCESS_H
+#define PROCESS_H
+
+
+#include <time.h>
+
+
+/** Exception used for unknown process
+ *
+ * A process might be unknown because it never existed or because it no longer
+ * exists.
+ */
+extern PyObject *PsiExc_NoSuchProcessError;
+
+
+/** Represent all basic process attributes
+ *
+ * The Python module might expose more but they can all be derived from these.
+ * When allocating this structure be sure that all attributes are filled with
+ * 0 or NULL so that new or forgotten fields will result in a "not
+ * implemented" status.
+ *
+ * Note that only fields who's size can be determined with `sizeof' at compile
+ * time can be others then the basic C types.  If a field can't be converted
+ * like that then the conversion must be the burden of the architecture
+ * implementation.
+ */
+struct psi_process {
+    char *name;                 /* accounting name or basename(exe) */
+    char *exe;                  /* absolute path of the executable */
+    long argc;                  /* argument count */
+    char **argv;                /* full argument list */
+    int envc;                   /* number of environment variables */
+    char **envv;                /* environment in strings of `NAME=VALUE' */
+    char *command;              /* argument list as string */
+    char *cwd;                  /* current working directory */
+    uid_t euid;                 /* effective UID */
+    uid_t ruid;                 /* real UID */
+    gid_t egid;                 /* effective GID */
+    gid_t rgid;                 /* real GID */
+    pid_t ppid;                 /* parent PID */
+    pid_t pgrp;                 /* process group ID */
+    pid_t sid;                  /* session ID */
+#if defined(SUNOS5) && SUNOS5_MINOR >= 10
+    zoneid_t zoneid;            /* solaris 10 zone ID */
+#endif
+    char *zonename;             /* solaris 10 zone name */
+    long priority;              /* priority */
+    long nice;                  /* nice value */
+#ifdef LINUX
+    unsigned long long jiffies; /* start time jiffies from boot */
+#endif
+    struct timespec start_time; /* start time, UTC */
+    int status;                 /* status */
+    long nthreads;              /* number of threads */
+    char *terminal;             /* owning terminal or NULL */
+    struct timespec utime;      /* user time used by the process */
+    struct timespec stime;      /* system time use by the process */
+    struct timespec cputime;    /* total cpu time used by the process */
+    unsigned long long rss;     /* resident memory size in bytes */
+    unsigned long long vsz;     /* virtual memory size in bytes */
+    double pcpu;                /* instantanious % CPU utilisation */
+    int exe_status;
+    int name_status;
+    int argc_status;
+    int argv_status;
+    int envc_status;
+    int envv_status;
+    int command_status;
+    int cwd_status;
+    int euid_status;
+    int ruid_status;
+    int egid_status;
+    int rgid_status;
+    int euser_status;
+    int ruser_status;
+    int egroup_status;
+    int rgroup_status;
+    int zoneid_status;
+    int zonename_status;
+    int ppid_status;
+    int pgrp_status;
+    int sid_status;
+    int priority_status;
+    int nice_status;
+    int jiffies_status;
+    int start_time_status;
+    int status_status;
+    int nthreads_status;
+    int terminal_status;
+    int utime_status;
+    int stime_status;
+    int cputime_status;
+    int rss_status;
+    int vsz_status;
+    int pcpu_status;
+};
+
+
+/** Create the process info for a PID
+ *
+ * @param pid: The PID of the process to create the info for.
+ *
+ * @return A pointer to the filled in psi_process structure or NULL.
+ */
+struct psi_process *psi_arch_process(const pid_t pid);
+
+
+/** Free the psi_process structure
+ *
+ * This function will check all pointers in the passed psi_process structure
+ * and if they are non-NULL will call psi_free() on them.  At the end it will
+ * call psi_free() on the structure itself thus completely freeing the space
+ * used by the structure.
+ *
+ * Note that for this to work you must have allocated the structure with
+ * psi_calloc() so that all pointers are initialised to NULL.
+ *
+ * The return value is always NULL so you can just do `return
+ * psi_free_process()'
+ */
+void *psi_free_process(struct psi_process *proci);
+
+
+/** Create the proclist structure
+ *
+ * Returns a struct psi_proclist with all the PIDs in. or NULL in case of
+ * failure.
+ */
+struct psi_proclist *psi_arch_proclist(void);
+
+
+/** Free the psi_proclist structure
+ *
+ * This function will check all pointers in the passed psi_proclist structure
+ * and if they are non-NULL will call psi_free() on them.  At the end it will
+ * call psi_free() on the structure itself thus completely freeing the space
+ * used by the structure.
+ *
+ * Note that for this to work you must have allocated the structure with
+ * psi_calloc() so that all pointers are initialised to NULL.
+ *
+ * The return value is always NULL so you can just do `return
+ * psi_free_proclist()'
+ */
+void *psi_free_proclist(struct psi_proclist *prl);
+
+
+/** Represent a  constant
+ *
+ * This structure represents a flag so it can be exported to the Python
+ * code.
+ *
+ * Implementations must declare an array of these named
+ * `psi_arch_proc_status_flags', it is for statuses like `running' and `zombie'
+ * etc.  The last element should be a null-sentinel: `{NULL, 0}'.
+ */
+struct psi_flag {
+    char *name;                 /* name of the flag */
+    long val;                   /* value of the flag */
+};
+
+
+extern struct psi_flag psi_arch_proc_status_flags[];
+
+
+/** An array with all the processes
+ *
+ * The array will contain `count' pids.
+ */
+struct psi_proclist {
+    long count;
+    pid_t *pids;
+};
+
+
+/* The following are for the processmodule, not for process
+ * implementations. */
+
+
+/* The type objects */
+extern PyTypeObject PsiProcess_Type;
+extern PyTypeObject PsiProcessTable_Type;
+
+
+/* Convenience functions to create a new objects. */
+PyObject *PsiProcess_New(pid_t pid);
+PyObject *PsiProcessTable_New(void);
+
+
+#endif /* PROCESS_H */

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/include/procfs_utils.h
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/include/procfs_utils.h b/tools/bin/pythonSrc/PSI-0.3b2_gp/include/procfs_utils.h
new file mode 100644
index 0000000..feb62b2
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/include/procfs_utils.h
@@ -0,0 +1,91 @@
+/* The MIT License
+ *
+ * Copyright (C) 2008-2009 Floris Bruynooghe
+ *
+ * Copyright (C) 2008-2009 Abilisoft Ltd.
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef PROCFS_PROCESS_H
+#define PROCFS_PROCESS_H
+
+
+/* Common functions for POSIX process implementations */
+
+
+
+/** Check if a PID is valid
+ *
+ * This checks if a directory entry exists in /proc for the pid.
+ *
+ * Return 0 if the PID exists, -1 if not.
+ */
+int procfs_check_pid(pid_t pid);
+
+
+/** Read a file into a newly created buffer
+ *
+ * Allocates a new buffer with psi_malloc, fills it with the file's contents
+ * and returns it.  Don't forget to free the buffer with psi_free().  The
+ * buffer will point to NULL in case of failure.
+ *
+ * The filename is constructed from the pid using the printf format template
+ * "/proc/%d/%s" where %d is the `pid' parameter and %s the `fname' parameter.
+ *
+ * @param buf: Will point to the new buffer.
+ * @param pid: The pid for which to read the file, `%d' from the template.
+ *
+ * @param fname: The filename to read from, `%s' from the template.  This is
+ * really `const' but PyErr_SetFromErrnoWithFilename() is not declared
+ * properly for this.
+ *
+ * @return The used size of the buffer on success, -1 on failure (exception
+ * raised) and -2 in case of a premissions problem.
+ */
+int procfs_read_procfile(char **buf, const pid_t pid, char *fname);
+
+
+/* XXX What does this have to do with procfs? */
+/* XXX This isn not used by anything currently, remove it? */
+/** Construct an argv array from a string
+ *
+ * We need to be careful to split up the arguments taking shell quoting into
+ * account.
+ *
+ * @param argv: The argv array.
+ * @param argstr: The string to parse argv from.
+ *
+ * The `argv' parameter will point to the newly allocated array and need to be
+ * free with psi_free().  In case of failure it will point to NULL.
+ *
+ * The `argstr' parameter is really const but the compiler isn't clever enough
+ * (and we don't want to allocate memory and copy it just to make the compiler
+ * happy).
+ *
+ * @return The number of elements in `argv' or -1 in case of failure.  If argc
+ *         is greater then INT_MAX, INT_MAX is returned.
+ */
+int procfs_argv_from_string(char ***argv,
+                            char *argstr,
+                            const unsigned int argc);
+
+
+#endif  /* PROCFS_PROCESS_H */

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/include/psi.h
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/include/psi.h b/tools/bin/pythonSrc/PSI-0.3b2_gp/include/psi.h
new file mode 100644
index 0000000..1f45885
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/include/psi.h
@@ -0,0 +1,284 @@
+/* The MIT License
+ *
+ * Copyright (C) 2008-2009 Floris Bruynooghe
+ *
+ * Copyright (C) 2008-2009 Abilisoft Ltd.
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef PSI_H
+#define PSI_H
+
+
+#include <Python.h>
+
+#include <time.h>
+
+
+/** Exceptions
+ *
+ * These are created by the module init function.
+ */
+extern PyObject *PsiExc_AttrNotAvailableError;
+extern PyObject *PsiExc_AttrInsufficientPrivsError;
+extern PyObject *PsiExc_AttrNotImplementedError;
+extern PyObject *PsiExc_MissingResourceError;
+extern PyObject *PsiExc_InsufficientPrivsError;
+
+
+/** Create a new PsiTimeSpec object
+ *
+ * This does get the _C_API CObject from the psi._psi module behind the
+ * scenes.
+ */
+PyObject *PsiTimeSpec_New(const struct timespec *tv);
+
+
+
+/** Constants representing status information of attributes
+ *
+ * These constants are for use with the *_status attributes of the *info
+ * structures.  The "not implemented" option is set to 0 so that if you
+ * allocate the memory with psi_calloc(3) this will be the default.  This
+ * means that things won't blow up if you forget a field or one gets added but
+ * the arch implementation doesn't have it yet (but don't forget to use calloc
+ * instead of malloc for this!).
+ */
+#define PSI_STATUS_NI 0         /* not implemented */
+#define PSI_STATUS_OK 1         /* data collected fine */
+#define PSI_STATUS_NA 2         /* not available for this process */
+#define PSI_STATUS_PRIVS 3      /* insufficient priviliges */
+
+
+/** Check the attribute of an *info structure
+ *
+ * This checks the status attribute passed in against the PSI_STATUS_*
+ * constants and will raise the appropriate Python exception if it is not
+ * PSI_STATUS_OK.  The name parameter is used in the Python exception.
+ *
+ * Returns -1 if a Python exception is raised and 0 if not.
+ */
+int psi_checkattr(const char* name, const int status);
+
+
+/** Memory management functions
+ *
+ * These are important since memory needs to be allocated in architecture
+ * specific implementations and freed in the global/python part of PSI.
+ * Therefore everyone must use the same memory management functions.  By using
+ * these functions it is easy to decide at build time if you want to use the
+ * libc memory allocator or the Python one etc.
+ *
+ * Additionally these function will have set the appropriate Python exception
+ * if they return NULL.
+ */
+void *psi_malloc(size_t size);
+void *psi_realloc(void *ptr, size_t size);
+void psi_free(void *ptr);
+void *psi_calloc(size_t size);
+
+#define psi_FREE(p) if (p != NULL) psi_free(p)
+
+
+/** String functions, allocating memory on the fly
+ *
+ * These are equivalent to the stdlib ones and their use should be obvious.
+ * Again, in case of error NULL is returned and the correct Python exception
+ * is raised.
+ */
+char *psi_strdup(const char *str);
+char *psi_strndup(const char *str, size_t n);
+
+
+/** Store string in a newly created buffer
+ *
+ * This function is like asprintf() in GNU libc, but if an error occurs a
+ * Python exception will be raised.  On success the allocated buffer will have
+ * to be freed using psi_free().
+ *
+ * The return value is the number of characters allocated for the buffer, or
+ * -1 in case of an error.  In case of an error ptr will also be a NULL
+ * pointer.
+ */
+int psi_asprintf(char **ptr, const char *template, ...);
+
+
+/** String conversion and formatting
+ *
+ * Do not forget to use the PyOS_* functions for string formatting whenever
+ * possible.  They are more portable, see
+ * http://docs.python.org/c-api/conversion.html for their documentation.
+ */
+
+
+
+/** Read a file into a newly created buffer
+ *
+ * Allocates a new buffer with psi_malloc, fills it with the file's contents
+ * and returns it.  Don't forget to free the buffer with psi_free().  If it
+ * fails buf will point to NULL.
+ *
+ * `path' is really `const' but PyErr_SetFromErrnoWithFilename is not declared
+ * properly.
+ *
+ * Returns the used size of the buffer on success, a negative value with an
+ * OSError raised on failure.  -1 for a generic failure and -2 in case of a
+ * permissions problem (interprets the errno value for you).
+ */
+int psi_read_file(char **buf, char *path);
+
+
+/** Read a link and allocate space for the string automtically
+ *
+ * This will allocate the space for the target string using psi_malloc(), call
+ * psi_free() on it when you're done.  If it fails target will point to NULL.
+ *
+ * The result will be stored in `target' and will be `\0' terminated.
+ *
+ * The `link' parameter is really `const' but PyErr_SetFromErrnoWithFilename
+ * is not declared as such.
+ *
+ * Returns a negative integer on error, with OSError exception raised.  -2 is
+ * returned in case of insufficient privileges, -1 for any other errors.  The
+ * errno detail will be in the exception.
+*/
+int psi_readlink(char **target, char *link);
+
+
+/** Return the number of strings in a buffer
+ *
+ * This function will count the number of `\0' terminated strings in a buffer.
+ *
+ * @param buf: The buffer.
+ * @param size: The size of the buffer.
+ *
+ * @returns the number of `\0's found
+ */
+int psi_strings_count(const char *cmdl, const int size);
+
+
+/** Return an array of strings build from a list of strings
+ *
+ * This function will create a new array of strings based on a buffer filled
+ * with consecutive strings.  Each element in the returned array must be freed
+ * using psi_free() after which the array itself must be freed with
+ * psi_free().
+ *
+ * XXX This sucks, surely the implementation can figure out how large the
+ *     array needs to be and then allocate it all at once.  That would be a
+ *     lot more natural.
+ *
+ * @param buf: The buffer, really `const' but compiler is not clever enough.
+ * @param count: The number of strings in the buffer.
+ */
+char **psi_strings_to_array(char *buf, const int count);
+
+
+/** Deal with Python 3.0
+ *
+ * The following macros make dealing with Python 3.0 aka Python 3000 aka py3k
+ * easier.
+ */
+
+
+#if PY_MAJOR_VERSION >= 3
+#define PY3K
+#endif
+
+
+/* We would like to just use unicode in Python 2.x too but the convenient
+ * PyUnicode_From*() functions don't exist yet there! */
+#ifdef PY3K
+#define PyStr_FromString(...) PyUnicode_FromString(__VA_ARGS__)
+#define PyStr_FromFormat(...) PyUnicode_FromFormat(__VA_ARGS__)
+#else
+#define PyStr_FromString(...) PyString_FromString(__VA_ARGS__)
+#define PyStr_FromFormat(...) PyString_FromFormat(__VA_ARGS__)
+#endif
+
+
+/** Deal with old Pythons
+ *
+ * These macro's and definitions help with early Python support.
+ */
+
+
+#ifndef PyDoc_VAR
+#define PyDoc_VAR(name) static char name[]
+#endif
+#ifndef PyDoc_STR
+#define PyDoc_STR(str) str
+#endif
+#ifndef PyDoc_STRVAR
+#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)
+#endif
+
+#ifndef PyMODINIT_FUNC
+#define PyMODINIT_FUNC void
+#endif
+
+
+#if PY_VERSION_HEX < 0x02030000 /* < 2.3 */
+#define PyExc_FutureWarning PyExc_Warning
+#endif
+
+#if PY_VERSION_HEX < 0x02040000 /* < 2.4 */
+#define Py_CLEAR(op)				\
+        do {                            	\
+                if (op) {			\
+                        PyObject *_py_tmp = (PyObject *)(op);	\
+                        (op) = NULL;		\
+                        Py_DECREF(_py_tmp);	\
+                }				\
+        } while (0)
+#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
+#define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True
+#define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False
+double PyOS_ascii_strtod(const char *nptr, char **endptr);
+double PyOS_ascii_atof(const char *nptr);
+#endif
+
+
+#if PY_VERSION_HEX < 0x02050000 /* < 2.5 */
+typedef int Py_ssize_t;
+typedef PyObject *(*ssizeargfunc)(PyObject *, Py_ssize_t);
+#define PY_SSIZE_T_MAX INT_MAX
+#define PY_SSIZE_T_MIN INT_MIN
+#define PyErr_WarnEx(EXC, MSG, LVL) PyErr_Warn(EXC, MSG)
+#endif
+
+
+#if PY_VERSION_HEX < 0x02060000 /* < 2.6 */
+#define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
+#define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
+#define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
+#define PyVarObject_HEAD_INIT(type, size) PyObject_HEAD_INIT(type) size,
+#define PyImport_ImportModuleNoBlock(NAME) PyImport_ImportModule(NAME)
+#endif
+
+
+#if PY_VERSION_HEX < 0x03010000 /* < 3.1 */
+double PyOS_string_to_double(const char *s, char **endptr,
+                             PyObject *overflow_exception);
+#endif
+
+
+#endif /* PSI_H */

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/include/psifuncs.h
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/include/psifuncs.h b/tools/bin/pythonSrc/PSI-0.3b2_gp/include/psifuncs.h
new file mode 100644
index 0000000..445bc45
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/include/psifuncs.h
@@ -0,0 +1,85 @@
+/* The MIT License
+ *
+ * Copyright (C) 2008-2009 Floris Bruynooghe
+ *
+ * Copyright (C) 2008-2009 Abilisoft Ltd.
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef PSIFUNCS_H
+#define PSIFUNCS_H
+
+/** Headers for implementing _psi functions
+ *
+ * Putting this in psi.h would make it avaialable to all the other PSI modules
+ * and that is not what we want.
+ *
+ * XXX This should maybe be called psimod.h
+ */
+
+
+#include <time.h>
+
+
+/* There is just one status field currently */
+struct loadavginfo {
+    double one;
+    double five;
+    double fifteen;
+    int loadavg_status;
+};
+
+
+struct loadavginfo *arch_loadavginfo(void);
+
+
+/** System boot time
+ *
+ * Returns 0 if successful, -1 for failure (Python Exception raised).
+ */
+int arch_boottime(struct timespec *boottime);
+
+
+/** System uptime
+ *
+ * Returns 0 if successful, -1 for failure (Python Exception raised).
+ */
+int arch_uptime(struct timespec *uptime);
+
+
+/** Create a new PsiTimeSpec object
+ *
+ * This method creates a new PsiTimeSpec object directly from a C timespec
+ * structure bypassing the init method.  This is exposed in the module as a
+ * CObject under the _C_API name and is used by PsiTimeSpec_New from
+ * psi.h/util.c.  This method is meant to be internal to the _psi module.
+ */
+PyObject *PsiTimeSpec_InternalNew(const struct timespec *tv);
+
+
+/** TimeSpec
+ *
+ * The Python type psi uses to represent time.
+ */
+extern PyTypeObject PsiTimeSpec_Type;
+
+
+#endif  /* PSIFUNCS_H */

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/misc/mem_test.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/misc/mem_test.py b/tools/bin/pythonSrc/PSI-0.3b2_gp/misc/mem_test.py
new file mode 100644
index 0000000..0ae0a76
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/misc/mem_test.py
@@ -0,0 +1,72 @@
+"""Check for memory leak
+
+If the memory goes consistent and significantly up there is a leak,
+either directly or from reference counting errors.
+"""
+
+
+import datetime
+import os
+import sys
+import time
+
+import psi
+import psi.arch
+import psi.process
+import psi.mount
+
+
+def check_psi():
+    psi.loadavg()
+    psi.boottime()
+    psi.uptime()
+
+
+def check_arch():
+    psi.arch.ArchBase()
+
+
+def check_process(pid):
+    p = psi.process.Process(pid)
+    p.children()
+    p.exists()
+    p.refresh()
+    psi.process.ProcessTable()
+
+
+def check_mount():
+    for m in psi.mount.mounts():
+        pass
+
+
+def loop(count=300):
+    pid = os.getpid()
+    print 'pid:', os.getpid()
+    p = psi.process.Process(os.getpid())
+    startrss = p.rss
+    starttime = datetime.datetime.now()
+    tdiff = datetime.datetime.now() - starttime
+    n = 0
+    while n < count:
+        check_psi()
+        check_arch()
+        check_process(pid)
+        p.refresh()
+        tdiff = datetime.datetime.now() - starttime
+        print 'time: %(time)s rss: %(rss)s (%(pct)s%%)' \
+            % {'rss': p.rss,
+               'pct': p.rss*100/startrss,
+               'time': str(tdiff).split('.')[0]}
+        n += 1
+    p = psi.process.Process(os.getpid())
+    print 'n=%(n)d - rss: %(rss)s (%(pct)s%%)' \
+        % {'rss': p.rss,
+           'pct': p.rss*100/startrss,
+           'n': n}
+
+
+if __name__ == '__main__':
+    if len(sys.argv) > 1:
+        loop(int(sys.argv[1]))
+    else:
+        loop()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/misc/mktests.sh
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/misc/mktests.sh b/tools/bin/pythonSrc/PSI-0.3b2_gp/misc/mktests.sh
new file mode 100755
index 0000000..e098fc1
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/misc/mktests.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+# Quick and dirty script to test with lots of python versions.  This
+# could grow many nice features (if it is the right place).
+
+
+set -e
+
+
+TESTED=
+
+
+do_run() {
+    py=$1
+
+    echo
+    echo ======== $py =========
+    echo
+    $py setup.py build_ext --devel
+    $py setup.py test
+    TESTED="$TESTED $py"
+}
+
+
+which python2.3 >/dev/null && do_run python2.3
+which python2.4 >/dev/null && do_run python2.4
+which python2.5 >/dev/null && do_run python2.5
+which python2.6 >/dev/null && do_run python2.6
+which python2.7 >/dev/null && do_run python2.7
+
+which python3.0 >/dev/null && do_run python3.0
+which python3.1 >/dev/null && do_run python3.1
+
+echo
+echo ======= Tested Against following pythons =======
+for py in $TESTED; do
+    $py -V
+done
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/misc/valgrind-python.supp
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/misc/valgrind-python.supp b/tools/bin/pythonSrc/PSI-0.3b2_gp/misc/valgrind-python.supp
new file mode 100644
index 0000000..15982cc
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/misc/valgrind-python.supp
@@ -0,0 +1,391 @@
+#
+# This is a valgrind suppression file that should be used when using valgrind.
+#
+#  Here's an example of running valgrind:
+#
+#	cd python/dist/src
+#	valgrind --tool=memcheck --suppressions=Misc/valgrind-python.supp \
+#		./python -E -tt ./Lib/test/regrtest.py -u bsddb,network
+#
+# You must edit Objects/obmalloc.c and uncomment Py_USING_MEMORY_DEBUGGER
+# to use the preferred suppressions with Py_ADDRESS_IN_RANGE.
+#
+# If you do not want to recompile Python, you can uncomment
+# suppressions for PyObject_Free and PyObject_Realloc.
+#
+# See Misc/README.valgrind for more information.
+
+# all tool names: Addrcheck,Memcheck,cachegrind,helgrind,massif
+{
+   ADDRESS_IN_RANGE/Invalid read of size 4
+   Memcheck:Addr4
+   fun:Py_ADDRESS_IN_RANGE
+}
+
+{
+   ADDRESS_IN_RANGE/Invalid read of size 4
+   Memcheck:Value4
+   fun:Py_ADDRESS_IN_RANGE
+}
+
+{
+   ADDRESS_IN_RANGE/Invalid read of size 8 (x86_64 aka amd64)
+   Memcheck:Value8
+   fun:Py_ADDRESS_IN_RANGE
+}
+
+{
+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
+   Memcheck:Cond
+   fun:Py_ADDRESS_IN_RANGE
+}
+
+#
+# Leaks (including possible leaks)
+#    Hmmm, I wonder if this masks some real leaks.  I think it does.
+#    Will need to fix that.
+#
+
+{
+   Suppress leaking the GIL.  Happens once per process, see comment in ceval.c.
+   Memcheck:Leak
+   fun:malloc
+   fun:PyThread_allocate_lock
+   fun:PyEval_InitThreads
+}
+
+{
+   Suppress leaking the GIL after a fork.
+   Memcheck:Leak
+   fun:malloc
+   fun:PyThread_allocate_lock
+   fun:PyEval_ReInitThreads
+}
+
+{
+   Suppress leaking the autoTLSkey.  This looks like it shouldn't leak though.
+   Memcheck:Leak
+   fun:malloc
+   fun:PyThread_create_key
+   fun:_PyGILState_Init
+   fun:Py_InitializeEx
+   fun:Py_Main
+}
+
+{
+   Hmmm, is this a real leak or like the GIL?
+   Memcheck:Leak
+   fun:malloc
+   fun:PyThread_ReInitTLS
+}
+
+{
+   Handle PyMalloc confusing valgrind (possibly leaked)
+   Memcheck:Leak
+   fun:realloc
+   fun:_PyObject_GC_Resize
+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
+}
+
+{
+   Handle PyMalloc confusing valgrind (possibly leaked)
+   Memcheck:Leak
+   fun:malloc
+   fun:_PyObject_GC_New
+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
+}
+
+{
+   Handle PyMalloc confusing valgrind (possibly leaked)
+   Memcheck:Leak
+   fun:malloc
+   fun:_PyObject_GC_NewVar
+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
+}
+
+#
+# Non-python specific leaks
+#
+
+{
+   Handle pthread issue (possibly leaked)
+   Memcheck:Leak
+   fun:calloc
+   fun:allocate_dtv
+   fun:_dl_allocate_tls_storage
+   fun:_dl_allocate_tls
+}
+
+{
+   Handle pthread issue (possibly leaked)
+   Memcheck:Leak
+   fun:memalign
+   fun:_dl_allocate_tls_storage
+   fun:_dl_allocate_tls
+}
+
+{
+   ADDRESS_IN_RANGE/Invalid read of size 4
+   Memcheck:Addr4
+   fun:PyObject_Free
+}
+
+{
+   ADDRESS_IN_RANGE/Invalid read of size 4
+   Memcheck:Value4
+   fun:PyObject_Free
+}
+
+{
+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
+   Memcheck:Cond
+   fun:PyObject_Free
+}
+
+{
+   ADDRESS_IN_RANGE/Invalid read of size 4
+   Memcheck:Addr4
+   fun:PyObject_Realloc
+}
+
+{
+   ADDRESS_IN_RANGE/Invalid read of size 4
+   Memcheck:Value4
+   fun:PyObject_Realloc
+}
+
+{
+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
+   Memcheck:Cond
+   fun:PyObject_Realloc
+}
+
+###
+### All the suppressions below are for errors that occur within libraries
+### that Python uses.  The problems to not appear to be related to Python's
+### use of the libraries.
+###
+
+{
+   Generic ubuntu ld problems
+   Memcheck:Addr8
+   obj:/lib/ld-2.4.so
+   obj:/lib/ld-2.4.so
+   obj:/lib/ld-2.4.so
+   obj:/lib/ld-2.4.so
+}
+
+{
+   Generic gentoo ld problems
+   Memcheck:Cond
+   obj:/lib/ld-2.3.4.so
+   obj:/lib/ld-2.3.4.so
+   obj:/lib/ld-2.3.4.so
+   obj:/lib/ld-2.3.4.so
+}
+
+{
+   DBM problems, see test_dbm
+   Memcheck:Param
+   write(buf)
+   fun:write
+   obj:/usr/lib/libdb1.so.2
+   obj:/usr/lib/libdb1.so.2
+   obj:/usr/lib/libdb1.so.2
+   obj:/usr/lib/libdb1.so.2
+   fun:dbm_close
+}
+
+{
+   DBM problems, see test_dbm
+   Memcheck:Value8
+   fun:memmove
+   obj:/usr/lib/libdb1.so.2
+   obj:/usr/lib/libdb1.so.2
+   obj:/usr/lib/libdb1.so.2
+   obj:/usr/lib/libdb1.so.2
+   fun:dbm_store
+   fun:dbm_ass_sub
+}
+
+{
+   DBM problems, see test_dbm
+   Memcheck:Cond
+   obj:/usr/lib/libdb1.so.2
+   obj:/usr/lib/libdb1.so.2
+   obj:/usr/lib/libdb1.so.2
+   fun:dbm_store
+   fun:dbm_ass_sub
+}
+
+{
+   DBM problems, see test_dbm
+   Memcheck:Cond
+   fun:memmove
+   obj:/usr/lib/libdb1.so.2
+   obj:/usr/lib/libdb1.so.2
+   obj:/usr/lib/libdb1.so.2
+   obj:/usr/lib/libdb1.so.2
+   fun:dbm_store
+   fun:dbm_ass_sub
+}
+
+{
+   GDBM problems, see test_gdbm
+   Memcheck:Param
+   write(buf)
+   fun:write
+   fun:gdbm_open
+
+}
+
+{
+   ZLIB problems, see test_gzip
+   Memcheck:Cond
+   obj:/lib/libz.so.1.2.3
+   obj:/lib/libz.so.1.2.3
+   fun:deflate
+}
+
+{
+   Avoid problems w/readline doing a putenv and leaking on exit
+   Memcheck:Leak
+   fun:malloc
+   fun:xmalloc
+   fun:sh_set_lines_and_columns
+   fun:_rl_get_screen_size
+   fun:_rl_init_terminal_io
+   obj:/lib/libreadline.so.4.3
+   fun:rl_initialize
+}
+
+###
+### These occur from somewhere within the SSL, when running
+###  test_socket_sll.  They are too general to leave on by default.
+###
+###{
+###   somewhere in SSL stuff
+###   Memcheck:Cond
+###   fun:memset
+###}
+###{
+###   somewhere in SSL stuff
+###   Memcheck:Value4
+###   fun:memset
+###}
+###
+###{
+###   somewhere in SSL stuff
+###   Memcheck:Cond
+###   fun:MD5_Update
+###}
+###
+###{
+###   somewhere in SSL stuff
+###   Memcheck:Value4
+###   fun:MD5_Update
+###}
+
+#
+# All of these problems come from using test_socket_ssl
+#
+{
+   from test_socket_ssl
+   Memcheck:Cond
+   fun:BN_bin2bn
+}
+
+{
+   from test_socket_ssl
+   Memcheck:Cond
+   fun:BN_num_bits_word
+}
+
+{
+   from test_socket_ssl
+   Memcheck:Value4
+   fun:BN_num_bits_word
+}
+
+{
+   from test_socket_ssl
+   Memcheck:Cond
+   fun:BN_mod_exp_mont_word
+}
+
+{
+   from test_socket_ssl
+   Memcheck:Cond
+   fun:BN_mod_exp_mont
+}
+
+{
+   from test_socket_ssl
+   Memcheck:Param
+   write(buf)
+   fun:write
+   obj:/usr/lib/libcrypto.so.0.9.7
+}
+
+{
+   from test_socket_ssl
+   Memcheck:Cond
+   fun:RSA_verify
+}
+
+{
+   from test_socket_ssl
+   Memcheck:Value4
+   fun:RSA_verify
+}
+
+{
+   from test_socket_ssl
+   Memcheck:Value4
+   fun:DES_set_key_unchecked
+}
+
+{
+   from test_socket_ssl
+   Memcheck:Value4
+   fun:DES_encrypt2
+}
+
+{
+   from test_socket_ssl
+   Memcheck:Cond
+   obj:/usr/lib/libssl.so.0.9.7
+}
+
+{
+   from test_socket_ssl
+   Memcheck:Value4
+   obj:/usr/lib/libssl.so.0.9.7
+}
+
+{
+   from test_socket_ssl
+   Memcheck:Cond
+   fun:BUF_MEM_grow_clean
+}
+
+{
+   from test_socket_ssl
+   Memcheck:Cond
+   fun:memcpy
+   fun:ssl3_read_bytes
+}
+
+{
+   from test_socket_ssl
+   Memcheck:Cond
+   fun:SHA1_Update
+}
+
+{
+   from test_socket_ssl
+   Memcheck:Value4
+   fun:SHA1_Update
+}
+
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/psi/__init__.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/psi/__init__.py b/tools/bin/pythonSrc/PSI-0.3b2_gp/psi/__init__.py
new file mode 100644
index 0000000..93e957c
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/psi/__init__.py
@@ -0,0 +1,55 @@
+# The MIT License
+#
+# Copyright (C) 2007 Chris Miles
+#
+# Copyright (C) 2008-2009 Floris Bruynooghe
+#
+# Copyright (C) 2008-2009 Abilisoft Ltd.
+#
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation files
+# (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge,
+# publish, distribute, sublicense, and/or sell copies of the Software,
+# and to permit persons to whom the Software is furnished to do so,
+# subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+"""Python System Information
+
+PSI is a Python module providing direct access to real-time
+system and process information.
+
+See psi.arch for architecture information.  Use psi.arch.arch_type()
+to fetch an object representing the architecture that the Python
+interpreter is running on.
+
+See psi.process module for access to run-time process information.
+"""
+
+
+from psi._psi import AttrNotAvailableError, AttrInsufficientPrivsError, \
+    AttrNotImplementedError, MissingResourceError
+from psi._psi import TimeSpec
+from psi._psi import boottime, loadavg, uptime
+try:
+    from psi._psi import getzoneid, getzoneidbyname, getzonenamebyid
+except ImportError:
+    pass
+
+from psi._version import version as __version__
+from psi._version import author as __author__
+from psi._version import copyright as __copyright__
+from psi._version import license as __license__

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/psi/_version.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/psi/_version.py b/tools/bin/pythonSrc/PSI-0.3b2_gp/psi/_version.py
new file mode 100644
index 0000000..d1d82f8
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/psi/_version.py
@@ -0,0 +1,44 @@
+# The MIT License
+#
+# Copyright (C) 2007 Chris Miles
+#
+# Copyright (C) 2008-2009 Floris Bruynooghe
+#
+# Copyright (C) 2008-2009 Abilisoft Ltd.
+#
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation files
+# (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge,
+# publish, distribute, sublicense, and/or sell copies of the Software,
+# and to permit persons to whom the Software is furnished to do so,
+# subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+"""psi._version
+
+This is used so that this information can stay easily in sync in both
+psi and setup.py.
+"""
+
+
+version = '0.3b2'
+author = 'Chris Miles, Floris Bruynooghe, Erick Tryzelaar'
+copyright = """\
+Copyright (C) 2007-2009 Chris Miles
+Copyright (C) 2008, 2009 Floris Bruynooghe
+Copyright (C) 2008, 2009 Abilisoft Ltd.
+Copyright (C) 2009 Erick Tryzelaar"""
+license = 'MIT'

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/setup.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/setup.py b/tools/bin/pythonSrc/PSI-0.3b2_gp/setup.py
new file mode 100644
index 0000000..afe507b
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/setup.py
@@ -0,0 +1,570 @@
+# The MIT License
+#
+# Copyright (C) 2007 Chris Miles
+#
+# Copyright (C) 2008-2009 Floris Bruynooghe
+#
+# Copyright (C) 2008-2009 Abilisoft Ltd.
+#
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation files
+# (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge,
+# publish, distribute, sublicense, and/or sell copies of the Software,
+# and to permit persons to whom the Software is furnished to do so,
+# subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+"""
+-------------------------
+Python System Information
+-------------------------
+
+``psi`` is a Python module providing direct access to real-time system
+and process information.  It is made of of several sub-modules.
+
+The ``arch`` module gives some information about the system such as
+the sytem name and version, the machine architecture etc.  It has a
+class representing each system and a factory function that will return
+an instance of the class which ``psi`` is running on currently.
+
+The experimental ``mount`` module gives information about the various
+mounted filesystems on the system.  It has a class representing local
+or remote filesystems.
+
+The ``process`` module provides an interface to information about
+processes currently running on the system.  Each process is
+represented as an instance of the ``Process`` class and additionally
+there is a ``ProcessTable`` class which is a dictionary of all running
+processes.  To know exactly what attributes are available and what
+they mean you should look at the docstrings and examples in the
+``REAME`` file and ``examples/`` directory, but important to note is
+that all the information is collected at instatiation time.  So the
+contents of ``ProcessTable`` and ``Process`` instances are really
+snapshots and will still contain all information even after the actual
+process has gone.
+
+Lastly there are some general functions available directly under the
+``psi`` namespace such as ``loadavg()``, ``getzoneid()`` etc.  Once
+more see the docstrings for detailed information.
+
+Some information may not be available on all platforms, rather then
+trying to emulate this information these parts of the API just don't
+exist on those platforms.  Examples of these are:
+``psi.process.Process.pcpu`` which is not available on Linux,
+``psi.getzoneid()`` which is only available on SunOS 10 and above etc.
+
+
+Supported Platforms
+===================
+
+Python: 2.2 and above, including 3.x.
+
+Linux: all 2.4 and 2.6 kernels.
+
+SunOS: Solaris 8 and above, including OpenSolaris (SunOS 11).
+
+AIX: 5.3
+
+Darwin: 10.3 and above.
+
+
+Documentation
+=============
+
+Care is taken to provide complete and accurate docstrings, so use
+Python's ``pydoc`` tool and the interactive prompt should get you on
+your way.
+
+We also have a wiki (http://bitbucket.org/chrismiles/psi/wiki/Home)
+and a mailing list (http://groups.google.com/group/psi-discuss
+psi-discuss@googlegroups.com).  Don't hesitate to ask questions or
+give feedback.
+
+
+Bugs
+====
+
+Please use our issue tracker:
+http://bitbucket.org/chrismiles/psi/issues
+
+
+Extra setup.py features
+=======================
+
+New ``build_ext`` option: ``--devel``.  This uses ``-Werror`` and
+enables many more warnings as well as disables optimisation.
+
+Using ``--undef PYMALLOC`` or ``-U PYMALLOC`` to ``build_ext`` will
+use libc's memory heap for allocation instead of Python's.
+
+
+The ``test`` command will run the testsuite.  Some tests will only be
+run when running the test suite as root.  Currently these are the
+tests that try to run a simple test application under specific
+schedulers and priorities to assert psi detects these process
+attributes correctly.
+
+
+The ``valgrind`` command does run the testsuite under the valgrind
+memory checker.  For this you need to have a specially compiled
+python::
+
+  ./configure --with-pydebug --without-pymalloc --prefix=/opt/pydebug
+  make
+  make install
+
+
+The ``tags`` command will build an emacs TAGS file using ``grind``
+(which is a binary of the python grin_ package).
+
+.. _grin: http://pypi.python.org/pypi/grin
+"""
+
+
+# Note: We can't use the platform module as that breaks Python 2.2
+#       compatibility.  Use os.uname() instead.
+
+
+import distutils.dep_util
+import glob
+import os
+import os.path
+import shutil
+import sys
+import unittest
+from distutils import ccompiler
+from distutils import sysconfig
+from distutils.core import setup, Extension, Command
+from distutils.command.clean import clean
+from distutils.command.build_ext import build_ext
+from distutils.errors import LinkError
+
+
+try:
+    import subprocess
+except ImportError:
+    HAVE_SUBPROCESS = False
+else:
+    HAVE_SUBPROCESS = True
+
+try:
+    import distutils.log
+except ImportError:
+    class MyLog:
+        def info(self, arg):
+            sys.stdout.write(arg)
+            sys.stdout.write('\n')
+
+        def warn(self, arg):
+            sys.stdout.write(arg)
+            sys.stdout.write('\n')
+
+    import distutils
+    distutils.log = MyLog()
+
+try:
+    from distutils.command.build_py import build_py_2to3
+except ImportError:
+    pass
+
+
+# CPP macros we want defined, use --undef or -U if you want to disable
+# any of these.
+MACROS = [('PYMALLOC', None)]
+
+# Define macros describing the system we're compiling on.
+# e.g.:
+# - Linux: LINUX, LINUX2_6, LINUX2_6_27, LINUX2_6_MINOR=27
+# - Solaris: SUNOS, SUNOS5_10, SUNOS5_MINOR=10
+# - AIX: AIX, AIX5, AIX5_3, AIX_MINOR=3
+SYSTEM = os.uname()[0].upper()
+MACROS.append((SYSTEM, None))
+if SYSTEM in ['LINUX', 'SUNOS']:
+    RELEASE = os.uname()[2].split('-')[0].replace('.', '_')
+    MACROS.append((SYSTEM+RELEASE, None))
+if SYSTEM == 'LINUX':
+    maj = '_'.join(RELEASE.split('_')[:2])
+    MACROS.append((SYSTEM+maj, None))
+    MACROS.append((SYSTEM+maj+'_MINOR', RELEASE.split('_')[2]))
+if SYSTEM == 'SUNOS':
+    maj = RELEASE.split('_')[0]
+    MACROS.append((SYSTEM+maj, None))
+    MACROS.append((SYSTEM+maj+'_MINOR', RELEASE.split('_')[1]))
+if SYSTEM == 'AIX':
+    major = os.uname()[3]
+    minor = os.uname()[2]
+    MACROS.append((SYSTEM+major, None))
+    MACROS.append((SYSTEM+major+'_'+minor, None))
+    MACROS.append((SYSTEM+major+'_MINOR', minor))
+
+
+# These are used to locate the correct source files.
+PLATFORM = os.uname()[0].lower()
+
+
+_psi_headers = ['include/psi.h',
+                'include/psifuncs.h',
+                'include/posix_utils.h']
+_psi_sources = ['src/util.c',
+                'src/_psimodule.c',
+                'src/timespec.c',
+                'src/arch/posix_utils.c',
+                'src/arch/%s_psi.c' % PLATFORM]
+_psi_libraries = []
+if PLATFORM == 'aix':
+    _psi_sources.append('src/arch/aix_psi.c')
+    _psi_libraries.append('perfstat')
+if PLATFORM == 'linux':
+    _psi_headers.append('include/linux_utils.h')
+    _psi_sources.append('src/arch/linux_utils.c')
+if PLATFORM != 'aix':
+    _psi_sources.append('src/arch/getloadavg.c')
+
+arch_headers = ['include/psi.h',
+                'include/arch.h']
+arch_sources = ['src/util.c',
+                'src/archmodule.c',
+                'src/arch.c',
+                'src/arch/posix_arch.c']
+
+mount_headers = ['include/psi.h',
+                 'include/mount.h',
+                 'include/posix_mount.h']
+mount_sources = ['src/util.c',
+                 'src/mountmodule.c',
+                 'src/mount.c',
+                 'src/arch/posix_mount.c',
+                 'src/arch/%s_mount.c' % PLATFORM]
+
+process_headers = ['include/psi.h',
+                   'include/process.h',
+                   'include/posix_utils.h',
+                   'include/procfs_utils.h']
+process_sources = ['src/util.c',
+                   'src/processmodule.c',
+                   'src/process.c',
+                   'src/processtable.c',
+                   'src/arch/posix_utils.c',
+                   'src/arch/procfs_utils.c',
+                   'src/arch/%s_process.c' % PLATFORM]
+if PLATFORM == 'linux':
+    process_headers.append('include/linux_utils.h')
+    process_sources.append('src/arch/linux_utils.c')
+if PLATFORM == 'darwin':
+    process_sources.append('src/arch/darwin_processtable.c')
+else:
+    process_sources.append('src/arch/procfs_processtable.c')
+
+_psi = Extension('psi._psi',
+                 define_macros = MACROS,
+                 include_dirs = ['include'],
+                 sources = _psi_sources,
+                 libraries = _psi_libraries,
+                 depends = _psi_headers)
+
+arch = Extension('psi.arch',
+                 define_macros = MACROS,
+                 include_dirs = ['include'],
+                 sources = arch_sources,
+                 depends = arch_headers)
+
+mount = Extension('psi.mount',
+                  define_macros = MACROS,
+                  include_dirs = ['include'],
+                  sources = mount_sources,
+                  depends = mount_headers)
+
+process = Extension('psi.process',
+                    define_macros = MACROS,
+                    include_dirs = ['include'],
+                    sources = process_sources,
+                    depends = process_headers)
+
+
+class BuildExtCommand(build_ext):
+    """Extend the build_ext command
+
+    We add an option to enable extra compilation flags during
+    development.  We also compile the helper application "sargs64.so"
+    on Solaris here.
+    """
+    user_options = build_ext.user_options + [
+        ('devel', None,
+         'use extra-safe compilation options, e.g. -Werror etc.')]
+    boolean_options = build_ext.boolean_options + ['devel']
+    extra_cflags = ['-O0',
+                    '-Wall',
+                    '-Werror',
+                    '-Wdeclaration-after-statement',
+                    '-Wno-pointer-sign',
+                    '-Wcast-align',
+                    '-Wbad-function-cast',
+                    '-Wmissing-declarations',
+                    '-Winline',
+                    '-Wsign-compare',
+                    '-Wmissing-prototypes',
+                    '-Wnested-externs',
+                    '-Wpointer-arith',
+                    '-Wredundant-decls',
+                    '-Wformat-security',
+                    '-Wswitch-enum',
+                    '-Winit-self',
+                    '-Wmissing-include-dirs']
+    def initialize_options(self):
+        build_ext.initialize_options(self)
+        self.devel = False
+        if PLATFORM == 'sunos':
+            # XXX This is rubbish, should check the compiler instead. --flub
+            self.extra_cflags.remove('-Wno-pointer-sign')
+            self.extra_cflags.remove('-Wmissing-include-dirs')
+            self.extra_cflags.remove('-Wredundant-decls')
+
+    def finalize_options(self):
+        build_ext.finalize_options(self)
+        if self.devel:
+            for ext in self.extensions:
+                if hasattr(ext, 'extra_compile_args'):
+                    ext.extra_compile_args.extend(self.extra_cflags)
+                else:
+                    ext.extra_compile_args = self.extra_cflags
+
+    def run(self):
+        build_ext.run(self)
+        if PLATFORM == 'sunos':
+            src = os.path.join('src', 'arch', 'sargs64.c')
+            destdir = os.path.join(self.build_lib, 'psi')
+            if self.devel:
+                postargs = self.extra_cflags
+            else:
+                postargs = []
+            try:
+                self.compiler.link_executable([src],
+                                              'sargs64.so',
+                                              output_dir=destdir,
+                                              extra_preargs=['-m64'],
+                                              extra_postargs=postargs)
+            except LinkError:
+                distutils.log.warn(
+                    'sargs64.so not built, this is normal on 32-bit platforms')
+
+
+class TestCommand(Command):
+    description = "Runs the test suite on the files in build/"
+    user_options = []
+    def initialize_options(self):
+        self._dir = os.getcwd()
+
+    def finalize_options(self):
+        build = self.get_finalized_command('build')
+        self.build_purelib = build.build_purelib
+        self.build_platlib = build.build_platlib
+
+    def run(self):
+        """Finds all the tests modules in tests/, and runs them"""
+        self.run_command('build')
+        self.cc = ccompiler.new_compiler()
+        sysconfig.customize_compiler(self.cc)
+        self.compile_ctests()
+        if os.uname()[0] == 'AIX':
+            self.compile_aix_ctest()
+        sys.path.insert(0, self.build_purelib)
+        sys.path.insert(0, self.build_platlib)
+        tdir = os.path.join(self._dir, 'tests')
+        sys.path.insert(0, tdir)
+        testfiles = []
+        for t in glob.glob(os.path.join(tdir, '*_test.py')):
+            testfiles.append(os.path.splitext(os.path.basename(t))[0])
+        tests = unittest.TestLoader().loadTestsFromNames(testfiles)
+        t = unittest.TextTestRunner(verbosity=2)
+        r = t.run(tests)
+        if not r.wasSuccessful():
+            sys.exit(1)
+
+    def compile_ctests(self):
+        """Compile helper executables from C
+
+        Currently a very simple app is compiled in both 32- and 64-bit
+        mode.  This is used to test argv & envv on AIX and SunOS
+        """
+        # If one of app32 or app64 exists we assume the other can't be
+        # compiled.
+        targets = []
+        if os.path.exists('tests/app32'):
+            targets.append('tests/app32')
+        if os.path.exists('tests/app64'):
+            targets.append('tests/app64')
+        build = True
+        for target in targets:
+            build = False
+            if distutils.dep_util.newer('tests/app.c', target):
+                build = True
+                break
+        if not build:
+            distutils.log.info('helper apps are up-to-date')
+            return
+
+        # We skip the explicity compiling to object files, the command
+        # line invoked by link_executable() will also work from source
+        # files directly.
+        distutils.log.info('compiling helper apps for tests')
+        m32 = '-m32'
+        m64 = '-m64'
+        if sys.platform == 'aix5':
+            m32 = '-maix32'
+            m64 = '-maix64'
+        try:
+            self.cc.link_executable(['tests/app.c'],
+                                    'app32',
+                                    output_dir='tests',
+                                    extra_preargs=[m32])
+        except LinkError:
+            distutils.log.warn('app32 not built, some tests will be skipped')
+        try:
+            self.cc.link_executable(['tests/app.c'],
+                                    'app64',
+                                    output_dir='tests',
+                                    extra_preargs=[m64])
+        except LinkError:
+            distutils.log.warn('app64 not built, some tests will be skipped')
+
+    def compile_aix_ctest(self):
+        """Compile AIX specific helper executables from C"""
+        if not distutils.dep_util.newer('tests/aixapp.c', 'tests/aixapp'):
+            distutils.log.info('AIX helper app is up-to-date')
+            return
+        distutils.log.info('compiling AIX helper app for tests')
+        self.cc.link_executable(['tests/aixapp.c'], 'tests/aixapp')
+
+
+class ValgrindCommand(Command):
+    description = "runs valgrind on test suite using /opt/pydebug/bin/python"
+    user_options = []
+    def initialize_options(self):
+        if not HAVE_SUBPROCESS:
+            sys.exit('This command requires the subprocess module')
+        self._pydbg = os.path.join('/opt', 'pydebug', 'bin', 'python')
+        if not os.path.isfile(self._pydbg):
+            sys.exit('%s not found' % self._pydbg)
+        #self._curdir = os.path.dirname(__file__)
+        self._curdir = os.getcwd() # XXX: Why doesn't the line above work?
+        self._suppr = os.path.join(self._curdir, 'misc', 'valgrind-python.supp')
+        if not os.path.isfile(self._suppr):
+            sys.exit('%s not found' % self._suppr)
+
+    def finalize_options(self):
+        pass
+
+    def run(self):
+        subprocess.call('%s setup.py build_ext --devel'%self._pydbg, shell=True)
+        subprocess.call('%s setup.py build'%self._pydbg, shell=True)
+        subprocess.call('valgrind --tool=memcheck --suppressions=%(suppr)s '
+                        '--leak-check=full %(pydbg)s -E -tt setup.py test'
+                        % {'suppr': self._suppr, 'pydbg': self._pydbg},
+                        shell=True)
+
+
+class CleanCommand(clean):
+    """Extend the clean command
+
+    We also want to remove all .pyc files and test applications.
+    """
+    def initialize_options(self):
+        self._clean_me = []
+        clean.initialize_options(self)
+
+    def finalize_options(self):
+        if hasattr(os, 'walk'):
+            for root, dirs, files in os.walk('.'):
+                for f in files:
+                    if f.endswith('.pyc'):
+                        self._clean_me.append(os.path.join(root, f))
+        if os.path.exists(os.path.join('tests', 'app32')):
+            self._clean_me.append(os.path.join('tests', 'app32'))
+        if os.path.exists(os.path.join('tests', 'app64')):
+            self._clean_me.append(os.path.join('tests', 'app64'))
+        clean.finalize_options(self)
+
+    def run(self):
+        for clean_me in self._clean_me:
+            distutils.log.info("removing '%s'" % clean_me)
+            try:
+                os.unlink(clean_me)
+            except:
+                pass
+        clean.run(self)
+
+
+class TagsCommand(Command):
+    description = "generate a TAGS file for use with Emacs (uses `grind')"
+    user_options = []
+    def initialize_options(self):
+        pass
+
+    def finalize_options(self):
+        pass
+
+    def run(self):
+        subprocess.call('grind --dirs src/ include/ | xargs etags', shell=True)
+
+
+COMMANDS = {'build_ext': BuildExtCommand,
+            'test': TestCommand,
+            'valgrind': ValgrindCommand,
+            'clean': CleanCommand,
+            'tags': TagsCommand}
+if sys.version_info[0] == 3:
+    COMMANDS['build_py'] = build_py_2to3
+
+
+try:
+    psidir = os.path.dirname(__file__)
+except NameError:
+    # Python <= 2.2: Assume we are $(pwd)/setup.py
+    psidir = os.getcwd()
+    if not os.path.exists(os.path.join(psidir, 'setup.py')):
+        sys.exit('Current directory needs to be the root of the PSI package')
+sys.path.insert(0, os.path.join(psidir, 'psi'))
+import _version
+
+
+setup(name = 'PSI',
+      version = _version.version,
+      author = _version.author,
+      author_email = 'psi-discuss@googlegroups.com',
+      license = _version.license,
+      url = 'http://bitbucket.org/chrismiles/psi',
+      download_url='http://pypi.python.org/pypi/PSI/',
+      description = 'Python System Information',
+      long_description = __doc__,
+      packages = ['psi'],
+      ext_modules = [_psi, arch, mount, process],
+      classifiers = [
+        'Development Status :: 4 - Beta',
+        'License :: OSI Approved :: MIT License',
+        'Intended Audience :: Developers',
+        'Operating System :: MacOS :: MacOS X',
+        'Operating System :: POSIX :: AIX',
+        'Operating System :: POSIX :: Linux',
+        'Operating System :: POSIX :: SunOS/Solaris',
+        'Programming Language :: C',
+        'Programming Language :: Python',
+        'Programming Language :: Python :: 2',
+        'Programming Language :: Python :: 3',
+        'Topic :: Software Development :: Libraries :: Python Modules',
+        'Topic :: System :: Operating System Kernels',
+        'Topic :: System :: Systems Administration'],
+      cmdclass = COMMANDS)
+


[17/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code

Posted by rl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/process.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/process.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/process.c
new file mode 100644
index 0000000..555f004
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/process.c
@@ -0,0 +1,981 @@
+/* The MIT License
+ *
+ * Copyright (C) 2007 Chris Miles
+ *
+ * Copyright (C) 2008-2009 Floris Bruynooghe
+ *
+ * Copyright (C) 2008-2009 Abilisoft Ltd.
+ *
+ * Copyright (C) 2009 Erick Tryzelaar
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/** psi.process.Process class
+ *
+ * This file contains the common support for the psi.process.Process class.
+ */
+
+
+#include <Python.h>
+
+#include <errno.h>
+#include <signal.h>
+#include <string.h>
+#include <sys/types.h>
+#include <time.h>
+
+#include "psi.h"
+#include "process.h"
+
+
+/** The Python Process object
+ *
+ * `pid' and `proci' are filled in by the init method.  All the python objects
+ * are filled lazily when they are accessed.  They exist so that accessing
+ * them twice returns a new reference to the same objects instead of creating
+ * new objects.  Just like in the psi_process structure some of these pointers
+ * might never be used on some platforms, e.g. zoneid is Solaris-only.
+ */
+typedef struct {
+    PyObject_HEAD
+    pid_t pid;
+    struct psi_process *proci;
+} PsiProcessObject;
+
+
+/***** Local declarations *****/
+
+static int check_init(PsiProcessObject *obj);
+
+
+/***** Local functions *****/
+
+void *
+psi_free_process(struct psi_process *proci)
+{
+    int i;
+
+    psi_FREE(proci->name);
+    psi_FREE(proci->exe);
+    if (proci->argv != NULL)
+        for (i = 0; i < proci->argc; i++)
+            psi_free(proci->argv[i]);
+    psi_FREE(proci->argv);
+    psi_FREE(proci->command);
+    for (i = 0; i < proci->envc; i++)
+        psi_free(proci->envv[i]);
+    psi_FREE(proci->envv);
+    psi_FREE(proci->cwd);
+    psi_FREE(proci->terminal);
+    psi_FREE(proci->zonename);
+    psi_free(proci);
+    return NULL;
+}
+
+
+/** Create a hash from a proci structure
+ *
+ * This is the implementation of Process.__hash__() really but without
+ * needeing a full PsiProcessObject so it can be used easier in
+ * various places.
+ */
+static long
+hash_proci(const pid_t pid, const struct psi_process *proci)
+{
+    PyObject *tuple;
+    PyObject *pypid;
+    PyObject *starttime;
+    long hash;
+
+#ifdef LINUX
+    if (psi_checkattr("Process.jiffies", proci->jiffies_status) < 0)
+        return -1;
+#else
+    if (psi_checkattr("Process.start_time", proci->start_time_status) < 0)
+        return -1;
+#endif
+    pypid = PyLong_FromLong(pid);
+    if (pypid == NULL)
+        return -1;
+#ifdef LINUX
+    starttime = PyLong_FromLong(proci->jiffies);
+#else
+    starttime = PsiTimeSpec_New(&proci->start_time);
+#endif
+    if (starttime == NULL) {
+        Py_DECREF(pypid);
+        return -1;
+    }
+    if ((tuple = PyTuple_New(2)) == NULL) {
+        Py_DECREF(pypid);
+        Py_DECREF(starttime);
+        return -1;
+    }
+    PyTuple_SET_ITEM(tuple, 0, pypid);
+    PyTuple_SET_ITEM(tuple, 1, starttime);
+    hash = PyObject_Hash(tuple);
+    Py_DECREF(tuple);
+    return hash;
+}
+
+
+static int
+Process_init(PsiProcessObject *self, PyObject *args, PyObject *kwds)
+{
+    static char *kwlist[] = {"pid", NULL};
+    pid_t pid;
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", kwlist, &pid))
+        return -1;
+    self->pid = pid;
+    self->proci = psi_arch_process(pid);
+    if (self->proci == NULL)
+        return -1;
+    return 0;
+}
+
+
+static void
+Process_dealloc(PsiProcessObject *self)
+{
+    if (self == NULL)
+        return;
+    if (self->proci != NULL)
+        psi_free_process(self->proci);
+    Py_TYPE(self)->tp_free((PyObject*)self);
+}
+
+
+static PyObject *
+Process_repr(PsiProcessObject *self)
+{
+    return PyStr_FromFormat("%s(pid=%d)",
+                            Py_TYPE(self)->tp_name, (int)self->pid);
+}
+
+
+static long
+Process_hash(PsiProcessObject *self)
+{
+    return hash_proci(self->pid, self->proci);
+}
+
+
+static PyObject *
+Process_richcompare(PyObject *v, PyObject *w, int op)
+{
+    PsiProcessObject *vo, *wo;
+    PyObject *result;
+    int istrue;
+
+    if (!PyObject_TypeCheck(v, &PsiProcess_Type)
+        || !PyObject_TypeCheck(w, &PsiProcess_Type)) {
+        Py_INCREF(Py_NotImplemented);
+        return Py_NotImplemented;
+    }
+    vo = (PsiProcessObject *)v;
+    wo = (PsiProcessObject *)w;
+    switch (op) {
+        case Py_EQ:
+            istrue = vo->pid == wo->pid;
+            break;
+        case Py_NE:
+            istrue = vo->pid != wo->pid;
+            break;
+        case Py_LE:
+            istrue = vo->pid <= wo->pid;
+            break;
+        case Py_GE:
+            istrue = vo->pid >= wo->pid;
+            break;
+        case Py_LT:
+            istrue = vo->pid < wo->pid;
+            break;
+        case Py_GT:
+            istrue = vo->pid > wo->pid;
+            break;
+        default:
+            assert(!"op unknown");
+            istrue = 0;         /* To shut up compiler */
+    }
+    result = istrue ? Py_True : Py_False;
+    Py_INCREF(result);
+    return result;
+}
+
+
+/** Check if object is initialised
+ *
+ * Small helper function that checks if an object is properly initialised.
+ *
+ * XXX: Maybe this should go into util.c in some from.
+ */
+static int
+check_init(PsiProcessObject *obj)
+{
+    if (obj->proci == NULL) {
+        PyErr_SetString(PyExc_RuntimeError,
+                        "Instance has not been initialised properly");
+        return -1;
+    }
+    return 0;
+}
+
+
+static PyObject *
+Process_get_pid(PsiProcessObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    return PyLong_FromLong(self->pid);
+}
+
+
+static PyObject *
+Process_get_name(PsiProcessObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.name",
+                      self->proci->name_status) < 0)
+        return NULL;
+    return PyStr_FromString(self->proci->name);
+}
+
+
+static PyObject *
+Process_get_exe(PsiProcessObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.exe", self->proci->exe_status) < 0)
+        return NULL;
+    return PyStr_FromString(self->proci->exe);
+}
+
+
+/** Create a tuple from the argv vector in the psi_process structure
+ *
+ * Each element in argv is allowed to be NULL in which case a None object
+ * should be added to the tuple.
+ */
+static PyObject *
+Process_get_args(PsiProcessObject *self, void *closure)
+{
+    PyObject *args;
+    PyObject *arg;
+    int i;
+
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.args", self->proci->argc_status) < 0
+        || psi_checkattr("Process.args", self->proci->argv_status) < 0)
+        return NULL;
+    args = PyTuple_New((Py_ssize_t)self->proci->argc);
+    if (args == NULL)
+        return NULL;
+    for (i = 0; i < self->proci->argc; i++) {
+        arg = PyStr_FromString(self->proci->argv[i]);
+        if (arg == NULL) {
+            Py_DECREF(args);
+            return NULL;
+        }
+        PyTuple_SET_ITEM(args, i, arg);
+    }
+    return args;
+}
+
+
+static PyObject *
+Process_get_argc(PsiProcessObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.argc", self->proci->argc_status) < 0)
+        return NULL;
+    return PyLong_FromLong(self->proci->argc);
+}
+
+
+/** Return the command
+ *
+ * Note that implementations are allowed to return an empty string for this in
+ * which case we need to get the name attribute instead.
+ */
+static PyObject *
+Process_get_command(PsiProcessObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.command", self->proci->command_status) < 0)
+        return NULL;
+    if (strlen(self->proci->command) == 0) {
+        if (psi_checkattr("Process.command", self->proci->name_status) < 0)
+            return NULL;
+        return PyStr_FromString(self->proci->name);
+    } else
+        return PyStr_FromString(self->proci->command);
+}
+
+
+static PyObject *
+Process_get_env(PsiProcessObject *self, void *closure)
+{
+    PyObject *env;
+    PyObject *val;
+    char *key;
+    char *s;
+    char *equals;
+    int i;
+    int r;
+
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.env", self->proci->envc_status) < 0
+        || psi_checkattr("Process.env", self->proci->envv_status) < 0)
+        return NULL;
+    env = PyDict_New();
+    if (env == NULL)
+        return NULL;
+    s = (char *)self->proci->envv;
+    for (i = 0; i < self->proci->envc; i++) {
+        key = self->proci->envv[i];
+        equals = strchr(key, '=');
+        if (!equals)
+            continue;           /* This is possible on at least Linux */
+        *equals = '\0';
+        val = PyStr_FromString(equals + 1);
+        if (val == NULL) {
+            Py_DECREF(env);
+            return NULL;
+        }
+        r = PyDict_SetItemString(env, key, val);
+        Py_DECREF(val);
+        if (r == -1)
+            return NULL;
+    }
+    return env;
+}
+
+
+#if ! (defined(SUNOS5) && SUNOS5_MINOR < 10)
+static PyObject *
+Process_get_cwd(PsiProcessObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.cwd", self->proci->cwd_status) < 0)
+        return NULL;
+    return PyStr_FromString(self->proci->cwd);
+}
+#endif
+
+
+static PyObject *
+Process_get_euid(PsiProcessObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.uid", self->proci->euid_status) < 0)
+        return NULL;
+    return PyLong_FromLong(self->proci->euid);
+}
+
+
+static PyObject *
+Process_get_egid(PsiProcessObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.gid", self->proci->egid_status) < 0)
+        return NULL;
+    return PyLong_FromLong(self->proci->egid);
+}
+
+
+static PyObject *
+Process_get_ruid(PsiProcessObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.real_uid", self->proci->ruid_status) < 0)
+        return NULL;
+    return PyLong_FromLong(self->proci->ruid);
+}
+
+
+static PyObject *
+Process_get_rgid(PsiProcessObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.real_gid", self->proci->rgid_status) < 0)
+        return NULL;
+    return PyLong_FromLong(self->proci->rgid);
+}
+
+
+#if defined(SUNOS5) && SUNOS5_MINOR >= 10
+static PyObject *
+Process_get_zoneid(PsiProcessObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.zoneid", self->proci->zoneid_status) < 0)
+        return NULL;
+    return PyLong_FromLong(self->proci->zoneid);
+}
+#endif
+
+
+#if defined(SUNOS5) && SUNOS5_MINOR >= 10
+static PyObject *
+Process_get_zonename(PsiProcessObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.zonename", self->proci->zonename_status) < 0)
+        return NULL;
+    return PyStr_FromString(self->proci->zonename);
+}
+#endif
+
+
+static PyObject *
+Process_get_ppid(PsiProcessObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.ppid", self->proci->ppid_status) < 0)
+        return NULL;
+    return PyLong_FromLong((long)self->proci->ppid);
+}
+
+
+static PyObject *
+Process_get_sid(PsiProcessObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.sid", self->proci->sid_status) < 0)
+        return NULL;
+    return PyLong_FromLong(self->proci->sid);
+}
+
+
+static PyObject *
+Process_get_pgrp(PsiProcessObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.pgrp", self->proci->pgrp_status) < 0)
+        return NULL;
+    return PyLong_FromLong(self->proci->pgrp);
+}
+
+
+static PyObject *
+Process_get_priority(PsiProcessObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.priority", self->proci->priority_status) < 0)
+        return NULL;
+    return PyLong_FromLong((long)self->proci->priority);
+}
+
+
+static PyObject *
+Process_get_nice(PsiProcessObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.nice", self->proci->nice_status) < 0)
+        return NULL;
+    return PyLong_FromLong((long)self->proci->nice);
+}
+
+
+static PyObject *
+Process_get_start_time(PsiProcessObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.start_time", self->proci->start_time_status) < 0)
+        return NULL;
+    return PsiTimeSpec_New(&self->proci->start_time);
+}
+
+
+#ifdef LINUX
+static PyObject *
+Process_get_jiffies(PsiProcessObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.jiffies", self->proci->jiffies_status) < 0)
+        return NULL;
+    return PyLong_FromLong(self->proci->jiffies);
+}
+#endif
+
+
+static PyObject *
+Process_get_status(PsiProcessObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.status", self->proci->status_status) < 0)
+        return NULL;
+    return PyLong_FromLong((long)self->proci->status);
+}
+
+
+#ifndef LINUX2_4
+static PyObject *
+Process_get_nthreads(PsiProcessObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.nthreads", self->proci->nthreads_status) < 0)
+        return NULL;
+    return PyLong_FromLong((long)self->proci->nthreads);
+}
+#endif
+
+
+#if ! (defined(SUNOS5) && SUNOS5_MINOR < 10)
+static PyObject *
+Process_get_terminal(PsiProcessObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.terminal", self->proci->terminal_status) < 0)
+        return NULL;
+    if (self->proci->terminal == '\0') {
+        Py_INCREF(Py_None);
+        return Py_None;
+    } else
+        return PyStr_FromString(self->proci->terminal);
+}
+#endif
+
+
+static PyObject *
+Process_get_utime(PsiProcessObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.utime", self->proci->utime_status) < 0)
+        return NULL;
+    return PsiTimeSpec_New(&self->proci->utime);
+}
+
+
+static PyObject *
+Process_get_stime(PsiProcessObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.stime", self->proci->stime_status) < 0)
+        return NULL;
+    return PsiTimeSpec_New(&self->proci->stime);
+}
+
+
+static PyObject *
+Process_get_cputime(PsiProcessObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.cputime", self->proci->cputime_status) < 0)
+        return NULL;
+    return PsiTimeSpec_New(&self->proci->cputime);
+}
+
+
+static PyObject *
+Process_get_rss(PsiProcessObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.rss", self->proci->rss_status) < 0)
+        return NULL;
+    return PyLong_FromLong(self->proci->rss);
+}
+
+
+static PyObject *
+Process_get_vsz(PsiProcessObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.vsz", self->proci->vsz_status) < 0)
+        return NULL;
+    return PyLong_FromLong(self->proci->vsz);
+}
+
+
+#if !defined(LINUX) && !defined(AIX)
+static PyObject *
+Process_get_pcpu(PsiProcessObject *self, void *closure)
+{
+    if (check_init(self) < 0)
+        return NULL;
+    if (psi_checkattr("Process.pcpu", self->proci->pcpu_status) < 0)
+        return NULL;
+    return PyFloat_FromDouble(self->proci->pcpu);
+}
+#endif
+
+
+PyDoc_STRVAR(Process_refresh__doc, "\
+Process.refresh()\n\
+\n\
+Refresh all data of the attributes.  This allows you to get new data\n\
+without having to create a new Process instance.\n\
+");
+static PyObject *
+Process_refresh(PsiProcessObject *self)
+{
+    struct psi_process *new_proci;
+    long old_hash;
+    long new_hash;
+
+    if (check_init(self) < 0)
+        return NULL;
+    old_hash = hash_proci(self->pid, self->proci);
+    if (old_hash == -1)
+        return NULL;
+    new_proci = psi_arch_process(self->pid);
+    if (new_proci == NULL) {
+        PyErr_SetString(PsiExc_NoSuchProcessError, "Process no longer exists");
+        return NULL;
+    }
+    new_hash = hash_proci(self->pid, new_proci);
+    if (new_hash == -1) {
+	psi_free_process(new_proci);
+        return NULL;
+    }
+    if (new_hash == old_hash) {
+        psi_free_process(self->proci);
+        self->proci = new_proci;
+        Py_RETURN_NONE;
+    } else {
+        psi_free_process(new_proci);
+        PyErr_SetString(PsiExc_NoSuchProcessError, "Process no longer exists");
+        return NULL;
+    }
+}
+
+
+PyDoc_STRVAR(Process_exists__doc, "\
+Process.exists() -> True or False\n\
+\n\
+Test if a process still exists.  This might not mean it is alive, it\n\
+could be in a zombie state or similar.\
+");
+static PyObject *
+Process_exists(PsiProcessObject *self)
+{
+    struct psi_process *new_proci;
+    long old_hash;
+    long new_hash;
+
+    PyErr_WarnEx(PyExc_FutureWarning, "Experimental method", 1);
+    if (check_init(self) < 0)
+        return NULL;
+    old_hash = hash_proci(self->pid, self->proci);
+    if (old_hash == -1)
+        return NULL;
+    new_proci = psi_arch_process(self->pid);
+    if (new_proci == NULL) {
+        PyErr_Clear();
+        Py_RETURN_FALSE;
+    }
+    new_hash = hash_proci(self->pid, new_proci);
+    psi_free_process(new_proci);
+    if (new_hash == -1) {
+	psi_free_process(new_proci);
+        return NULL;
+    }
+    if (new_hash == old_hash)
+        Py_RETURN_TRUE;
+    else
+        Py_RETURN_FALSE;
+}
+
+
+PyDoc_STRVAR(Process_children__doc, "\
+Process.children() -> [child, ...]\n\
+\n\
+This returns a (possibly empty) list of children of the process.  Each\n\
+child will be the corresponding Process instance.\n\
+");
+static PyObject *
+Process_children(PsiProcessObject *self)
+{
+    PyObject *isalive;
+    PyObject *ptable;
+    PyObject *children;
+    PsiProcessObject *proc;
+    PyObject *pyproc;
+    Py_ssize_t pos = 0;
+
+    PyErr_WarnEx(PyExc_FutureWarning, "Experimental method", 1);
+    isalive = Process_exists(self);
+    if (isalive != Py_True) {
+        PyErr_SetString(PsiExc_NoSuchProcessError, "Process no longer exists");
+        return NULL;
+    }
+    children = PyList_New(0);
+    if (children == NULL)
+        return NULL;
+    ptable = PsiProcessTable_New();
+    if (ptable == NULL) {
+        Py_DECREF(children);
+        return NULL;
+    }
+    while (PyDict_Next(ptable, &pos, NULL, &pyproc)) {
+        proc = (PsiProcessObject *)pyproc;
+        if (proc->proci->ppid == self->pid)
+            if (PyList_Append(children, (PyObject *)proc) == -1) {
+                Py_DECREF(children);
+                Py_DECREF(ptable);
+                return NULL;
+            }
+    }
+    Py_DECREF(ptable);
+    return children;
+}
+
+
+PyDoc_STRVAR(Process_kill__doc, "\
+Process.kill(signal)\n\
+\n\
+Send a signal to the process.  `signal` is an integer signal number\n\
+as defined by the OS, use one of the signal.SIG* constants.\n\
+");
+static PyObject *
+Process_kill(PsiProcessObject* self, PyObject *args, PyObject *kwds)
+{
+    static char *kwlist[] = {"sig", NULL};
+    PyObject *isalive;
+    int sig = SIGTERM;
+    int r;
+
+    PyErr_WarnEx(PyExc_FutureWarning, "Experimental method", 1);
+    if (!PyArg_ParseTupleAndKeywords(args, kwds, "|i", kwlist, &sig))
+        return NULL;
+    isalive = Process_exists(self);
+    if (isalive != Py_True) {
+        PyErr_SetString(PsiExc_NoSuchProcessError, "Process no longer exists");
+        return NULL;
+    }
+    r = kill(self->pid, sig);
+    if (r == -1)
+        if (errno == EINVAL) {
+            PyErr_Format(PyExc_ValueError, "Invalid signal: %d", sig);
+            return NULL;
+        } else if (errno == EPERM) {
+            PyErr_Format(PsiExc_InsufficientPrivsError,
+                         "No permission to send signal %d to process %ld",
+                         sig, (long)self->pid);
+            return NULL;
+        } else if (errno == ESRCH) {
+            PyErr_SetString(PsiExc_NoSuchProcessError,
+                            "Process no longer exists");
+            return NULL;
+        } else {
+            PyErr_Format(PyExc_SystemError, "Unexpected errno: %d", errno);
+            return NULL;
+        }
+    else
+        Py_RETURN_NONE;
+}
+
+
+static PyGetSetDef Process_getseters[] = {
+    {"pid", (getter)Process_get_pid, (setter)NULL,
+     "Process PID", NULL},
+    {"name", (getter)Process_get_name, (setter)NULL,
+     "Name of the process, accounting name if defined", NULL},
+    {"exe", (getter)Process_get_exe, (setter)NULL,
+     "Absolute pathname to the executable of the process", NULL},
+    {"args", (getter)Process_get_args, (setter)NULL,
+     "List of the command and it's arguments\n"
+     "\n"
+     "On some systems (e.g. SunOS, AIX) it possible that this is not\n"
+     "available due to privileges.  The `command' attribute should still\n"
+     "be available in those cases.", NULL},
+    {"argc", (getter)Process_get_argc, (setter)NULL,
+     "Argument count", NULL},
+    {"command", (getter)Process_get_command, (setter)NULL,
+     "Command and arguments as a string\n"
+     "\n"
+     "On some systems (e.g. SunOS, AIX) this might be truncated to a limited\n"
+     "length.  On those systems this will always be available however, while\n"
+     "the `args' attribute might not be.", NULL},
+    {"env", (getter)Process_get_env, (setter)NULL,
+     "The environment of the process as a dictionary", NULL},
+#if ! (defined(SUNOS5) && SUNOS5_MINOR < 10)
+    {"cwd", (getter)Process_get_cwd, (setter)NULL,
+     "Current working directory", NULL},
+#endif
+    {"euid", (getter)Process_get_euid, (setter)NULL,
+     "Current UID", NULL},
+    {"egid", (getter)Process_get_egid, (setter)NULL,
+     "Current GID", NULL},
+    {"ruid", (getter)Process_get_ruid, (setter)NULL,
+     "Real UID", NULL},
+    {"rgid", (getter)Process_get_rgid, (setter)NULL,
+     "Real GID", NULL},
+#if defined(SUNOS5) && SUNOS5_MINOR >= 10
+    {"zoneid", (getter)Process_get_zoneid, (setter)NULL,
+     "ID of the Solaris zone the process is running in", NULL},
+    {"zonename", (getter)Process_get_zonename, (setter)NULL,
+     "Name of the Solaris zone the process is running in", NULL},
+#endif
+    {"ppid", (getter)Process_get_ppid, (setter)NULL,
+     "Parent PID", NULL},
+    {"pgrp", (getter)Process_get_pgrp, (setter)NULL,
+     "Process group ID aka PID of process group leader", NULL},
+    {"sid", (getter)Process_get_sid, (setter)NULL,
+     "Session ID of the process", NULL},
+    {"priority", (getter)Process_get_priority, (setter)NULL,
+     "Priority of the process", NULL},
+    {"nice", (getter)Process_get_nice, (setter)NULL,
+     "Nice value of the process", NULL},
+    {"start_time", (getter)Process_get_start_time, (setter)NULL,
+     "Start time of process as datetime.datetime object\n\n"
+     "Use .strftime('%s') to get seconds since epoch",
+     NULL},
+#ifdef LINUX
+     {"jiffies", (getter)Process_get_jiffies, (setter)NULL,
+     "Number of jiffies of the start of the process since boot", NULL},
+#endif
+    {"status", (getter)Process_get_status, (setter)NULL,
+     "Process status\n\n"
+     "A value matching one of the psi.process.PROC_STATUS_* constants", NULL},
+#ifndef LINUX2_4
+    {"nthreads", (getter)Process_get_nthreads, (setter)NULL,
+     "Number of threads used by this process", NULL},
+#endif
+#if ! (defined(SUNOS5) && SUNOS5_MINOR < 10)
+    {"terminal", (getter)Process_get_terminal, (setter)NULL,
+     "Owning terminal or None", NULL},
+#endif
+    {"utime", (getter)Process_get_utime, (setter)NULL,
+     "Time the process has spent in user mode (datetime.timedelta)", NULL},
+    {"stime", (getter)Process_get_stime, (setter)NULL,
+     "Time the process has spend in system mode (datetime.timedelta)", NULL},
+    {"cputime", (getter)Process_get_cputime, (setter)NULL,
+     "Total CPU time of the process (datetime.timedelta)", NULL},
+    {"rss", (getter)Process_get_rss, (setter)NULL,
+     "Resident memory size (RSS) in bytes", NULL},
+    {"vsz", (getter)Process_get_vsz, (setter)NULL,
+     "Virtual memory size in bytes", NULL},
+#if !defined(LINUX) && !defined(AIX)
+    {"pcpu", (getter)Process_get_pcpu, (setter)NULL,
+     "%% CPU usage, instantaneous", NULL},
+#endif
+    {NULL}  /* Sentinel */
+};
+
+
+static PyMethodDef Process_methods[] = {
+    {"refresh", (PyCFunction)Process_refresh,
+     METH_NOARGS, Process_refresh__doc},
+    {"exists", (PyCFunction)Process_exists,
+     METH_NOARGS, Process_exists__doc},
+    {"children", (PyCFunction)Process_children,
+     METH_NOARGS, Process_children__doc},
+    {"kill", (PyCFunction)Process_kill,
+     METH_VARARGS | METH_KEYWORDS, Process_kill__doc},
+    {NULL}                      /* Sentinel */
+};
+
+
+PyTypeObject PsiProcess_Type = {
+    PyVarObject_HEAD_INIT(NULL, 0)
+    "psi.process.Process",                    /* tp_name */
+    sizeof(PsiProcessObject),                 /* tp_basicsize */
+    0,                                        /* tp_itemsize */
+    /* methods */
+    (destructor)Process_dealloc,              /* tp_dealloc */
+    0,                                        /* tp_print */
+    0,                                        /* tp_getattr */
+    0,                                        /* tp_setattr */
+    0,                                        /* tp_compare */
+    (reprfunc)Process_repr,                   /* tp_repr */
+    0,                                        /* tp_as_number */
+    0,                                        /* tp_as_sequence */
+    0,                                        /* tp_as_mapping */
+    (hashfunc)Process_hash,                   /* tp_hash */
+    0,                                        /* tp_call */
+    0,                                        /* tp_str */
+    0,                                        /* tp_getattro */
+    0,                                        /* tp_setattro */
+    0,                                        /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+    "Process(pid=x) -> Process object",       /* tp_doc */
+    0,                                        /* tp_traverse */
+    0,                                        /* tp_clear */
+    (richcmpfunc)Process_richcompare,         /* tp_richcompare */
+    0,                                        /* tp_weaklistoffset */
+    0,                                        /* tp_iter */
+    0,                                        /* tp_iternext */
+    Process_methods,                          /* tp_methods */
+    0,                                        /* tp_members */
+    Process_getseters,                        /* tp_getset */
+    0,                                        /* tp_base */
+    0,                                        /* tp_dict */
+    0,                                        /* tp_descr_get */
+    0,                                        /* tp_descr_set */
+    0,                                        /* tp_dictoffset */
+    (initproc)Process_init,                   /* tp_init */
+    0,                                        /* tp_alloc */
+    PyType_GenericNew,                        /* tp_new */
+};
+
+
+/** Create a new PsiProcessObject
+ *
+ * Create a new PsiProcessObject for a pid.
+ *
+ * Returns a new reference to a PsiProcessObject or NULL in case of an error.
+ */
+PyObject *
+PsiProcess_New(pid_t pid)
+{
+    PsiProcessObject *obj;
+
+    obj = (PsiProcessObject *)PyType_GenericNew(&PsiProcess_Type, NULL, NULL);
+    if (obj == NULL)
+        return NULL;
+
+    /* Skip calling .__init__() */
+    obj->pid = pid;
+    obj->proci = psi_arch_process(pid);
+    if (obj->proci == NULL)
+        return NULL;
+    return (PyObject *)obj;
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/processmodule.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/processmodule.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/processmodule.c
new file mode 100644
index 0000000..7970c86
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/processmodule.c
@@ -0,0 +1,208 @@
+/* The MIT License
+ *
+ * Copyright (C) 2008-2009 Floris Bruynooghe
+ *
+ * Copyright (C) 2008-2009 Abilisoft Ltd.
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/* The psi.process module  */
+
+
+#include <Python.h>
+
+#include "psi.h"
+#include "process.h"
+
+
+/* Declarations (we need these since we use -Wmissing-declarations) */
+#ifdef PY3K
+PyMODINIT_FUNC PyInit_process(void);
+#else
+PyMODINIT_FUNC initprocess(void);
+#endif
+
+
+/* Re-declare these as non-extern since we're providing the symbols */
+PyObject *PsiExc_AttrNotAvailableError = NULL;
+PyObject *PsiExc_AttrInsufficientPrivsError = NULL;
+PyObject *PsiExc_AttrNotImplementedError = NULL;
+PyObject *PsiExc_MissingResourceError = NULL;
+PyObject *PsiExc_NoSuchProcessError = NULL;
+PyObject *PsiExc_InsufficientPrivsError = NULL;
+
+
+/* More constants */
+static char MODULE_NAME[] = "psi.process";
+PyDoc_STRVAR(MODULE_DOC, "Module for process information");
+
+
+/** Finalise the types
+ *
+ * Calls PyType_Ready() and increases their reference count.
+ */
+static int
+prepare_types(void)
+{
+    if (PyType_Ready(&PsiProcess_Type) < 0)
+        return -1;
+    if (PyType_Ready(&PsiProcessTable_Type) < 0)
+        return -1;
+    Py_INCREF(&PsiProcess_Type);
+    Py_INCREF(&PsiProcessTable_Type);
+    return 0;
+}
+
+
+/** Initialise the global exceptions
+ *
+ * If this function fails the modinit function will Py_XDECREF the exceptions,
+ * so no need to do that here.
+ */
+static int
+init_exceptions(void)
+{
+    PyObject *_psimod;
+
+    _psimod = PyImport_ImportModule("psi._psi");
+    if (_psimod == NULL)
+        return -1;
+    PsiExc_AttrNotAvailableError = PyObject_GetAttrString(
+        _psimod, "AttrNotAvailableError");
+    if (PsiExc_AttrNotAvailableError == NULL)
+        goto error;
+    PsiExc_AttrInsufficientPrivsError = PyObject_GetAttrString(
+        _psimod, "AttrInsufficientPrivsError");
+    if (PsiExc_AttrInsufficientPrivsError == NULL)
+        goto error;
+    PsiExc_AttrNotImplementedError = PyObject_GetAttrString(
+        _psimod, "AttrNotImplementedError");
+    if (PsiExc_AttrNotImplementedError == NULL)
+        goto error;
+    PsiExc_MissingResourceError = PyObject_GetAttrString(
+        _psimod, "MissingResourceError");
+    if (PsiExc_MissingResourceError == NULL)
+        goto error;
+    PsiExc_InsufficientPrivsError = PyObject_GetAttrString(
+        _psimod, "InsufficientPrivsError");
+    if (PsiExc_InsufficientPrivsError == NULL)
+        goto error;
+    PsiExc_NoSuchProcessError = PyErr_NewException(
+        "psi.process.NoSuchProcessError", PsiExc_MissingResourceError, NULL);
+    if (PsiExc_NoSuchProcessError == NULL)
+        goto error;
+    Py_DECREF(_psimod);
+    return 0;
+
+  error:
+    Py_DECREF(_psimod);
+    return -1;
+}
+
+
+/* Add all objects to the module */
+static int
+add_module_objects(PyObject *module)
+{
+    struct psi_flag *flag;
+
+    flag = psi_arch_proc_status_flags;
+    while (flag->name != NULL) {
+        if (PyModule_AddIntConstant(module, flag->name, flag->val) == -1)
+            return -1;
+        flag++;
+    }
+    if (PyModule_AddObject(module, "Process",
+                           (PyObject *)&PsiProcess_Type) < 0)
+        return -1;
+    if (PyModule_AddObject(module, "ProcessTable",
+                           (PyObject *)&PsiProcessTable_Type) < 0)
+        return -1;
+    if (PyModule_AddObject(module, "NoSuchProcessError",
+                           PsiExc_NoSuchProcessError) < 0)
+        return -1;
+    return 0;
+}
+
+
+static PyMethodDef process_methods[] = {
+    {NULL, NULL, 0, NULL}        /* Sentinel */
+};
+
+
+#ifdef PY3K
+static struct PyModuleDef moduledef = {
+        PyModuleDef_HEAD_INIT,  /* m_base */
+        MODULE_NAME,            /* m_name */
+        MODULE_DOC,             /* m_doc */
+        -1,                     /* m_size */
+        process_methods,        /* m_methods */
+        NULL,                   /* m_reload */
+        NULL,                   /* m_traverse */
+        NULL,                   /* m_clear */
+        NULL                    /* m_free */
+};
+#endif
+
+
+/* Some defines to make the module init function readable */
+#ifdef PY3K
+#define MODFUNC PyInit_process
+#define RETURN(VAR) return VAR
+#else
+#define MODFUNC initprocess
+#define RETURN(VAR) return
+#endif
+
+
+/* Returns the psi.process module */
+PyMODINIT_FUNC
+MODFUNC(void)
+{
+    PyObject *mod = NULL;
+
+    if (prepare_types() < 0)
+        RETURN(NULL);
+    if (init_exceptions() < 0)
+        goto error;
+#ifdef PY3K
+    mod = PyModule_Create(&moduledef);
+#else
+    mod = Py_InitModule3(MODULE_NAME, process_methods, MODULE_DOC);
+#endif
+    if (mod == NULL)
+        goto error;
+    if (add_module_objects(mod) < 0)
+        goto error;
+    RETURN(mod);
+
+  error:
+    Py_XDECREF(mod);
+    Py_XDECREF(PsiExc_AttrNotAvailableError);
+    Py_XDECREF(PsiExc_AttrInsufficientPrivsError);
+    Py_XDECREF(PsiExc_AttrNotImplementedError);
+    Py_XDECREF(PsiExc_MissingResourceError);
+    Py_XDECREF(PsiExc_InsufficientPrivsError);
+    Py_XDECREF(PsiExc_NoSuchProcessError);
+    Py_DECREF((PyObject*)&PsiProcess_Type);
+    Py_DECREF((PyObject*)&PsiProcessTable_Type);
+    RETURN(NULL);
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/processtable.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/processtable.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/processtable.c
new file mode 100644
index 0000000..81cee6f
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/processtable.c
@@ -0,0 +1,240 @@
+/* The MIT License
+ *
+ * Copyright (C) 2008-2009 Floris Bruynooghe
+ *
+ * Copyright (C) 2008-2009 Abilisoft Ltd.
+ *
+ * Copyright (C) 2009 Erick Tryzelaar
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/** psi.process.ProcessTable class
+ *
+ * This file contains the common support for the psi.process.ProcessTable
+ * class.
+ */
+
+
+#include <Python.h>
+
+#include "psi.h"
+#include "process.h"
+
+
+/* The ProcessTableObject.  It has no extra fields. */
+typedef PyDictObject PsiProcessTableObject;
+
+
+/* Declarations */
+static int add_procs_to_table(PsiProcessTableObject *pt,
+                              const struct psi_proclist *prl);
+
+
+/* ProcessTable methods */
+
+
+static int
+ProcessTable_init(PsiProcessTableObject *self, PyObject *args, PyObject *kwds)
+{
+    struct psi_proclist *prl;
+    int r;
+
+    if (args != NULL && PySequence_Length(args) > 0) {
+        PyErr_Format(PyExc_TypeError,
+                     "__init__() takes no arguments (%d given)",
+                     (int)PySequence_Length(args));
+        return -1;
+    }
+    if (kwds != NULL && PyMapping_Length(kwds) > 0) {
+        PyErr_SetString(PyExc_TypeError,
+                        "__init__() takes no keyword arguments");
+        return -1;
+    }
+    if (PyDict_Type.tp_init((PyObject *)self, args, kwds) < 0)
+        return -1;
+    prl = psi_arch_proclist();
+    if (prl == NULL)
+        return -1;
+    r = add_procs_to_table(self, prl);
+    psi_free_proclist(prl);
+    return r;
+}
+
+
+static PyObject *
+ProcessTable_repr(PsiProcessTableObject *self)
+{
+    return PyStr_FromString("psi.process.ProcessTable()");
+}
+
+
+static int
+ProcessTable_ass_subscript(PsiProcessTableObject *self,
+                           PyObject *item, PyObject *value)
+{
+    if (value == NULL) {
+        PyErr_SetString(PyExc_TypeError,
+                        "ProcessTable does not support item deletion");
+    } else {
+        PyErr_SetString(PyExc_TypeError,
+                        "ProcessTable does not support item assignment");
+    }
+    return -1;
+}
+
+
+static PyMappingMethods ProcessTable_as_mapping = {
+    0,                                          /* mp_length */
+    0,                                          /* mp_subscript */
+    (objobjargproc)ProcessTable_ass_subscript,  /* mp_ass_subscript */
+};
+
+
+PyTypeObject PsiProcessTable_Type = {
+    PyVarObject_HEAD_INIT(NULL, 0)
+    "psi.process.ProcessTable",                 /* tp_name */
+    sizeof(PsiProcessTableObject),              /* tp_basicsize */
+    0,                                          /* tp_itemsize */
+    /* methods */
+    0,                                          /* tp_dealloc */
+    0,                                          /* tp_print */
+    0,                                          /* tp_getattr */
+    0,                                          /* tp_setattr */
+    0,                                          /* tp_compare */
+    (reprfunc)ProcessTable_repr,                /* tp_repr */
+    0,                                          /* tp_as_number */
+    0,                                          /* tp_as_sequence */
+    &ProcessTable_as_mapping,                   /* tp_as_mapping */
+    0,                                          /* tp_hash */
+    0,                                          /* tp_call */
+    0,                                          /* tp_str */
+    0,                                          /* tp_getattro */
+    0,                                          /* tp_setattro */
+    0,                                          /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,   /* tp_flags */
+    "A dictionary of all processes (snapshot)", /* tp_doc */
+    0,                                          /* tp_traverse */
+    0,                                          /* tp_clear */
+    0,                                          /* tp_richcompare */
+    0,                                          /* tp_weaklistoffset */
+    0,                                          /* tp_iter */
+    0,                                          /* tp_iternext */
+    0,                                          /* tp_methods */
+    0,                                          /* tp_members */
+    0,                                          /* tp_getset */
+    &PyDict_Type,                               /* tp_base */
+    0,                                          /* tp_dict */
+    0,                                          /* tp_descr_get */
+    0,                                          /* tp_descr_set */
+    0,                                          /* tp_dictoffset */
+    (initproc)ProcessTable_init,                /* tp_init */
+    0,                                          /* tp_alloc */
+    0,                                          /* tp_new */
+};
+
+
+/* Local functions */
+
+
+/* Always returns NULL */
+void *
+psi_free_proclist(struct psi_proclist *prl)
+{
+    psi_free(prl->pids);
+    psi_free(prl);
+    return NULL;
+}
+
+
+/** Add Process objects to a PsiProcessTableObject
+ *
+ * This will create a Process object for each PID in the `prl' proclist
+ * structure and add it to the ProcessTable object `pt'.  This will also reset
+ * `pt->count' to the value of `prl->count'.  If a process listed in the
+ * proclist structure does no longer exist (newProcessObject() raise a
+ * NoSuchProcessError) it will be silently skipped and `pt->count' will be
+ * updated accordingly.
+ *
+ * Return 0 on success and -1 on failure.
+ */
+static int
+add_procs_to_table(PsiProcessTableObject *pt, const struct psi_proclist *prl)
+{
+    PyObject *proc;
+    PyObject *key;
+    int i;
+    int r;
+
+    for (i = 0; i < prl->count; i++) {
+        proc = PsiProcess_New(prl->pids[i]);
+        if (proc == NULL && PyErr_ExceptionMatches(PsiExc_NoSuchProcessError)) {
+            PyErr_Clear();
+            continue;
+        } else if (proc == NULL)
+            return -1;
+        key = PyLong_FromLong(prl->pids[i]);
+        if (key == NULL) {
+            Py_DECREF(proc);
+            return -1;
+        }
+        r = PyDict_SetItem((PyObject*)pt, key, proc);
+        Py_DECREF(proc);
+        Py_DECREF(key);
+        if (r == -1)
+            return -1;
+    }
+    return 0;
+}
+
+
+/** Create a new ProcessTableObject
+ *
+ * The ugly part is that PyDict_Type.tp_init (called by ProcessTable_init())
+ * does not cope with NULL as args or kwds.  Oh well.
+ */
+PyObject *
+PsiProcessTable_New(void)
+{
+    PyObject *args = NULL;
+    PyObject *kwds = NULL;
+    PyObject *obj;
+
+    obj = PyDict_Type.tp_new(&PsiProcessTable_Type, NULL, NULL);
+    if (obj == NULL)
+        return NULL;
+    args = PyTuple_New(0);
+    if (args == NULL)
+        goto error;
+    kwds = PyDict_New();
+    if (kwds == NULL)
+        goto error;
+    if (ProcessTable_init((PsiProcessTableObject *)obj, args, kwds) != 0)
+        goto error;
+    Py_DECREF(args);
+    Py_DECREF(kwds);
+    return obj;
+
+  error:
+    Py_XDECREF(args);
+    Py_XDECREF(kwds);
+    Py_DECREF(obj);
+    return NULL;
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/timespec.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/timespec.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/timespec.c
new file mode 100644
index 0000000..548886a
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/timespec.c
@@ -0,0 +1,852 @@
+/* The MIT License
+ *
+ * Copyright (C) 2009 Floris Bruynooghe
+ *
+ * Copyright (C) 2009 Erick Tryzelaar
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/** _psi.TimeSpec class
+ *
+ * This file contains the TimeSpec class, the way psi represents time.
+ */
+
+
+#include <Python.h>
+
+#include <time.h>
+
+#include "psi.h"
+#include "psifuncs.h"
+#include "posix_utils.h"
+
+
+#if PY_VERSION_HEX < 0x02030000 /* < 2.3 */
+#define HAVE_DATETIME 0
+#else
+#define HAVE_DATETIME 1
+#endif
+
+
+/** The Python TimeSpec object
+ *
+ * Note that since Python initialises all members to 0, even when this object
+ * did not have it's .__init__() method called it will be valid and useful.
+ */
+typedef struct {
+    PyObject_HEAD
+    struct timespec tv;
+} PsiTimeSpecObject;
+
+
+/***** Global Variables *****/
+
+#if HAVE_DATETIME
+/* datetime.datetime.fromtimestamp */
+static PyObject *FROMTIMESTAMP = NULL;
+/* datetime.datetime.utcfromtimestamp */
+static PyObject *UTCFROMTIMESTAMP = NULL;
+/* datetime.datetime.timedelta */
+static PyObject *TIMEDELTA = NULL;
+#endif  /* HAVE_DATETIME */
+
+
+/***** Local helper function *****/
+
+
+static void
+norm_timespec(struct timespec *tv)
+{
+    if (tv->tv_nsec >= 1000000000) {
+        tv->tv_sec += tv->tv_nsec / 1000000000;
+        tv->tv_nsec = tv->tv_nsec % 1000000000;
+    } else if (tv->tv_nsec <= -1000000000) {
+        tv->tv_sec -= -(tv->tv_nsec) / 1000000000;
+        tv->tv_nsec = -(tv->tv_nsec) % 1000000000;
+    }
+    if (tv->tv_sec > 0 && tv->tv_nsec < 0) {
+        tv->tv_sec--;
+        tv->tv_nsec = 1000000000 + tv->tv_nsec;
+    } else if (tv->tv_sec < 0 && tv->tv_nsec > 0) {
+        tv->tv_sec++;
+        tv->tv_nsec = tv->tv_nsec - 1000000000;
+    }
+}
+
+
+/** Convert PsiTimeSpecObject to struct timespec
+ *
+ * Use any2timespec() instead.
+ */
+static struct timespec
+timespec2timespec(const PsiTimeSpecObject *pyo)
+{
+    return pyo->tv;
+}
+
+
+/** Convert a PyTypleObject to struct timespec
+ *
+ * Use any2timespec() instead.
+ */
+static struct timespec
+tuple2timespec(const PyObject *tuple)
+{
+    struct timespec tv = {0, 0};
+    PyObject *pyo;
+
+    if (!PyTuple_Check(tuple) || PyTuple_GET_SIZE(tuple) != 2) {
+        PyErr_SetString(PyExc_TypeError, "Not tuple or size != 2");
+        return tv;
+    }
+    pyo = PyTuple_GET_ITEM(tuple, 0);
+    if (PyLong_Check(pyo))
+        tv.tv_sec = PyLong_AsLong(pyo);
+#ifndef PY3K
+    else if (PyInt_Check(pyo))
+        tv.tv_sec = PyInt_AsLong(pyo);
+#endif
+    else {
+        PyErr_SetString(PyExc_TypeError, "Non-number inside tuple");
+        return tv;
+    }
+    if (PyErr_Occurred() != NULL)
+        return tv;
+    pyo = PyTuple_GET_ITEM(tuple, 1);
+    if (PyLong_Check(pyo))
+        tv.tv_nsec = PyLong_AsLong(pyo);
+#ifndef PY3K
+    else if (PyInt_Check(pyo))
+        tv.tv_nsec = PyInt_AsLong(pyo);
+#endif
+    else {
+        PyErr_SetString(PyExc_TypeError, "Non-number inside tuple");
+        return tv;
+    }
+    return tv;
+}
+
+
+/** Convert a Python int to a struct timespec
+ *
+ * Use any2timespec() instead.
+ */
+#ifndef PY3K
+static struct timespec
+int2timespec(const PyObject *obj)
+{
+    struct timespec tv;
+
+    if (!PyInt_Check(obj))
+        PyErr_SetString(PyExc_TypeError, "Not an integer object");
+    else {
+        tv.tv_sec = PyInt_AS_LONG(obj);
+        tv.tv_nsec = 0;
+    }
+    return tv;
+}
+#endif
+
+
+/** Convert a Python long to a struct timespec
+ *
+ * Use any2timespec() instead.
+ */
+static struct timespec
+long2timespec(PyObject *obj)
+{
+    struct timespec tv;
+
+    if (!PyLong_Check(obj))
+        PyErr_SetString(PyExc_TypeError, "Not a long object");
+    else {
+        tv.tv_sec = PyLong_AsLong(obj);
+        tv.tv_nsec = 0;
+    }
+    return tv;
+}
+
+
+/** Convert a Python float to a struct timespec
+ *
+ * Use any2timespec() instead.
+ */
+static struct timespec
+float2timespec(PyObject *obj)
+{
+    struct timespec tv;
+
+    if (!PyFloat_Check(obj))
+        PyErr_SetString(PyExc_TypeError, "Not a float object");
+    else
+        /* Don't use PyFloat_AS_DOUBLE() here as that macro causes alignment
+         * issues on SunOS 5.10 sun4v. */
+        tv = posix_double2timespec(PyFloat_AsDouble(obj));
+    return tv;
+}
+
+
+/** Convert any Python object to a struct timespec if possible
+ *
+ * This function will attempt to convert any Python object into a timespec
+ * structure.  The objects that can be converted are: psi.TimeSpec, 2-tuple of
+ * integers, int or long and float.
+ *
+ * A TypeError will be raised if the object can't be converted, you must check
+ * this with PyErr_Occurred().
+ */
+static struct timespec
+any2timespec(PyObject *obj)
+{
+    struct timespec tv;
+        
+    if (PyObject_TypeCheck(obj, &PsiTimeSpec_Type))
+        tv = timespec2timespec((PsiTimeSpecObject *)obj);
+    else if (PyTuple_Check(obj))
+        tv = tuple2timespec(obj);
+    else if (PyFloat_Check(obj))
+        tv = float2timespec(obj);
+#ifndef PY3K
+    else if (PyInt_Check(obj))
+        tv = int2timespec(obj);
+#endif
+    else if (PyLong_Check(obj))
+        tv = long2timespec(obj);
+    else
+        PyErr_SetString(PyExc_TypeError,
+                        "Unable to convert object to timespec structure");
+    if (PyErr_Occurred() == NULL)
+        norm_timespec(&tv);
+    return tv;
+}
+
+
+/** Import and return the time module
+ *
+ * This will import the time module and return it.  Returns a borrowed
+ * reference or NULL on failure.
+ */
+static PyObject *
+import_time(void)
+{
+    static PyObject *time = NULL;
+
+    if (time != NULL)
+        return time;
+    time = PyImport_ImportModuleNoBlock("time");
+    return time;
+}
+
+
+#if HAVE_DATETIME
+
+/** Initialise datetime module
+ *
+ * This initialises the UTCFROMTIMESTAMP, FROMTIMESTAMP and TIMEDELTA global
+ * variables.
+ */
+static int
+init_datetime(void)
+{
+    PyObject *mod;
+    PyObject *dt;
+
+    mod = PyImport_ImportModuleNoBlock("datetime");
+    if (mod == NULL)
+        return -1;
+    dt = PyObject_GetAttrString(mod, "datetime");
+    if (dt == NULL) {
+        Py_DECREF(mod);
+        return -1;
+    }
+    FROMTIMESTAMP = PyObject_GetAttrString(dt, "fromtimestamp");
+    if (FROMTIMESTAMP == NULL) {
+        Py_DECREF(mod);
+        return -1;
+    }
+    UTCFROMTIMESTAMP = PyObject_GetAttrString(dt, "utcfromtimestamp");
+    Py_DECREF(dt);
+    if (UTCFROMTIMESTAMP == NULL) {
+        Py_DECREF(FROMTIMESTAMP);
+        Py_DECREF(mod);
+        return -1;
+    }
+    TIMEDELTA = PyObject_GetAttrString(mod, "timedelta");
+    Py_DECREF(mod);
+    if (TIMEDELTA == NULL) {
+        Py_CLEAR(FROMTIMESTAMP);
+        Py_CLEAR(UTCFROMTIMESTAMP);
+        return -1;
+    }
+    return 0;
+}
+
+
+/* Can't use PyDateTime_IMPORT and all API things associated with it since
+ * that was only introduced in python 2.4 and we support 2.3 as a minimum.
+ * Even if we could it would be pain to use for this. */
+static PyObject *
+timespec2datetime(const struct timespec *tspec)
+{
+    PyObject *datetime;
+    PyObject *timedelta;
+    PyObject *ret;
+
+    if (FROMTIMESTAMP == NULL || TIMEDELTA == NULL)
+        if (init_datetime() < 0)
+            return NULL;
+    datetime = PyObject_CallFunction(FROMTIMESTAMP, "(l)", tspec->tv_sec);
+    if (datetime == NULL)
+        return NULL;
+    timedelta = PyObject_CallFunction(TIMEDELTA, "(iil)",
+                                      0, 0, tspec->tv_nsec/1000);
+    if (timedelta == NULL) {
+        Py_DECREF(datetime);
+        return NULL;
+    }
+    ret = PyObject_CallMethod(datetime, "__add__", "(O)", timedelta);
+    Py_DECREF(datetime);
+    Py_DECREF(timedelta);
+    return ret;
+}
+
+
+static PyObject *
+timespec2utcdatetime(const struct timespec *tspec)
+{
+    PyObject *datetime;
+    PyObject *timedelta;
+    PyObject *ret;
+
+    if (UTCFROMTIMESTAMP == NULL || TIMEDELTA == NULL)
+        if (init_datetime() < 0)
+            return NULL;
+    datetime = PyObject_CallFunction(UTCFROMTIMESTAMP, "(l)", tspec->tv_sec);
+    if (datetime == NULL)
+        return NULL;
+    timedelta = PyObject_CallFunction(TIMEDELTA, "(iil)",
+                                      0, 0, tspec->tv_nsec/1000);
+    if (timedelta == NULL) {
+        Py_DECREF(datetime);
+        return NULL;
+    }
+    ret = PyObject_CallMethod(datetime, "__add__", "(O)", timedelta);
+    Py_DECREF(datetime);
+    Py_DECREF(timedelta);
+    return ret;
+}
+
+
+static PyObject *
+timespec2timedelta(const struct timespec *tspec)
+{
+    if (TIMEDELTA == NULL)
+        if (init_datetime() < 0)
+            return NULL;
+    return PyObject_CallFunction(TIMEDELTA, "(ill)",
+                                 0, tspec->tv_sec, tspec->tv_nsec/1000);
+}    
+
+#endif  /* HAVE_DATETIME */
+
+
+/***** TimeSpec methods *****/
+
+
+static int
+TimeSpec_init(PsiTimeSpecObject *self, PyObject *args, PyObject *kwds)
+{
+    static char *kwlist[] = {"tv_sec", "tv_nsec", NULL};
+    long tv_sec = 0;
+    long tv_nsec = 0;
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwds, "|ll", kwlist,
+                                     &tv_sec, &tv_nsec))
+        return -1;
+    self->tv.tv_sec = tv_sec;
+    self->tv.tv_nsec = tv_nsec;
+    norm_timespec(&self->tv);
+    return 0;
+}
+
+
+static PyObject *
+TimeSpec_repr(PsiTimeSpecObject *self)
+{
+    return PyStr_FromFormat("%s(tv_sec=%ld, tv_nsec=%ld)",
+                            Py_TYPE(self)->tp_name,
+                            (long)self->tv.tv_sec,
+                            (long)self->tv.tv_nsec);
+}
+
+
+static PyObject *
+TimeSpec_get_tv_sec(PsiTimeSpecObject *self, void *closure)
+{
+    return PyLong_FromLong(self->tv.tv_sec);
+}
+
+
+static PyObject *
+TimeSpec_get_tv_nsec(PsiTimeSpecObject *self, void *closure)
+{
+    return PyLong_FromLong(self->tv.tv_nsec);
+}
+
+
+static PyObject *
+TimeSpec_getitem(PsiTimeSpecObject *self, Py_ssize_t i)
+{
+    if (i == 0)
+        return PyLong_FromLong(self->tv.tv_sec);
+    else if (i == 1)
+        return PyLong_FromLong(self->tv.tv_nsec);
+    else {
+        PyErr_SetString(PyExc_IndexError, "index out of range");
+        return NULL;
+    }
+}
+
+
+static long
+TimeSpec_hash(PsiTimeSpecObject *self)
+{
+    PyObject *tuple;
+    PyObject *item;
+    long hash = -1;
+
+    if ((tuple = PyTuple_New(2)) == NULL)
+        return -1;
+
+    item = PyLong_FromLong(self->tv.tv_sec);
+    if (item == NULL)
+        goto end;
+    PyTuple_SET_ITEM(tuple, 0, item);
+    item = PyLong_FromLong(self->tv.tv_nsec);
+    if (item == NULL)
+        goto end;
+    PyTuple_SET_ITEM(tuple, 1, item);
+    hash = PyObject_Hash(tuple);
+
+  end:
+    Py_DECREF(tuple);
+    return hash;
+}
+
+
+static PyObject *
+TimeSpec_richcompare(PyObject *v, PyObject *w, int op)
+{
+    struct timespec vo, wo;
+    PyObject *result;
+    int istrue;
+
+    vo = any2timespec(v);
+    if (PyErr_Occurred() != NULL)
+        goto error;
+    wo = any2timespec(w);
+    if (PyErr_Occurred() != NULL)
+        goto error;
+
+    /* Note that vo and wo are normalised so simple comparison is fine. */
+    switch (op) {
+        case Py_EQ:
+            istrue = vo.tv_sec == wo.tv_sec && vo.tv_nsec == wo.tv_nsec;
+            break;
+        case Py_NE:
+            istrue = vo.tv_sec != wo.tv_sec || vo.tv_nsec != wo.tv_nsec;
+            break;
+        case Py_LE:
+            istrue = vo.tv_sec <= wo.tv_sec && vo.tv_nsec <= wo.tv_nsec;
+            break;
+        case Py_GE:
+            istrue = vo.tv_sec >= wo.tv_sec && vo.tv_nsec >= wo.tv_nsec;
+            break;
+        case Py_LT:
+            if (vo.tv_sec != wo.tv_sec)
+                istrue = vo.tv_sec < wo.tv_sec;
+            else
+                istrue = vo.tv_nsec < wo.tv_nsec;
+            break;
+        case Py_GT:
+            if (vo.tv_sec != wo.tv_sec)
+                istrue = vo.tv_sec > wo.tv_sec;
+            else
+                istrue = vo.tv_nsec > wo.tv_nsec;
+            break;
+        default:
+            assert(!"op unknown");
+            istrue = 0;         /* To shut up compiler */
+    }
+    result = istrue ? Py_True : Py_False;
+    Py_INCREF(result);
+    return result;
+
+  error:
+    PyErr_Clear();
+    Py_INCREF(Py_NotImplemented);
+    return Py_NotImplemented;
+}
+
+
+static PyObject *
+TimeSpec_add(PyObject *v, PyObject *w)
+{
+    struct timespec vo, wo;
+
+    vo = any2timespec(v);
+    if (PyErr_Occurred() != NULL)
+        goto error;
+    wo = any2timespec(w);
+    if (PyErr_Occurred() != NULL)
+        goto error;
+
+    vo.tv_sec += wo.tv_sec;
+    vo.tv_nsec += wo.tv_nsec;
+    /* PsiTimeSpec_InternalNew() does normalise the members for us. */
+    return PsiTimeSpec_InternalNew(&vo);
+
+  error:
+    PyErr_Clear();
+    Py_INCREF(Py_NotImplemented);
+    return Py_NotImplemented;
+}
+
+
+static PyObject *
+TimeSpec_subtract(PyObject *v, PyObject *w)
+{
+    struct timespec vo, wo;
+
+    vo = any2timespec(v);
+    if (PyErr_Occurred() != NULL)
+        goto error;
+    wo = any2timespec(w);
+    if (PyErr_Occurred() != NULL)
+        goto error;
+
+    vo.tv_sec -= wo.tv_sec;
+    vo.tv_nsec -= wo.tv_nsec;
+    /* PsiTimeSpec_InternalNew() does normalise the members for us. */
+    return PsiTimeSpec_InternalNew(&vo);
+
+  error:
+    PyErr_Clear();
+    Py_INCREF(Py_NotImplemented);
+    return Py_NotImplemented;
+}
+
+
+static int
+TimeSpec_bool(PsiTimeSpecObject *self)
+{
+    return self->tv.tv_sec != 0 || self->tv.tv_nsec != 0;
+}
+
+
+PyDoc_STRVAR(TimeSpec_timestamp__doc, "\
+TimeSpec.timestamp() -> float\n\
+\n\
+Convert a TimeSpec into a UNIX timestamp from the unix EPOCH.  If you\n\
+wanted the integer timestamp just use the tv_sec attribute.\
+");
+PyDoc_STRVAR(TimeSpec_float__doc, "\
+TimeSpec.float() -> float\n\
+\n\
+Alias for .timestamp(), but this may be more natural when working with\n\
+durations.\
+");
+static PyObject *
+TimeSpec_timestamp(PsiTimeSpecObject *self)
+{
+    double d = (double)self->tv.tv_sec + ((double)self->tv.tv_nsec * 1.0e-9);
+    return PyFloat_FromDouble(d);
+}
+
+
+PyDoc_STRVAR(TimeSpec_mktime__doc, "\
+TimeSpec.mktime() -> float\n\
+\n\
+Return the time as a floating point, but converted to the local\n\
+timezone.  The returned time is not a UNIX or POSIX timestamp.\
+");
+static PyObject *
+TimeSpec_mktime(PsiTimeSpecObject *self)
+{
+    PyObject *time;
+    PyObject *obj;
+    double d;
+    long l = self->tv.tv_sec;
+
+    time = import_time();
+    if (time == NULL)
+        return NULL;
+
+    /* Add timezone difference */
+    obj = PyObject_GetAttrString(time, "timezone");
+    if (obj == NULL)
+        return NULL;
+    if (PyLong_Check(obj))
+        l += PyLong_AsLong(obj);
+#ifndef PY3K
+    else if (PyInt_Check(obj))
+        l += PyInt_AsLong(obj);
+#endif
+    Py_DECREF(obj);
+    if (PyErr_Occurred())
+        return NULL;
+
+    /* Add DST difference */
+    obj = PyObject_GetAttrString(time, "altzone");
+    if (obj == NULL)
+        return NULL;
+    if (PyLong_Check(obj))
+        l += PyLong_AsLong(obj);
+#ifndef PY3K
+    else if (PyInt_Check(obj))
+        l += PyInt_AsLong(obj);
+#endif
+    Py_DECREF(obj);
+    if (PyErr_Occurred())
+        return NULL;
+
+    d = (double)l + ((double)self->tv.tv_nsec * 1.0e-9);
+    return PyFloat_FromDouble(d);
+}
+
+
+PyDoc_STRVAR(TimeSpec_timetuple__doc, "\
+TimeSpec.timetuple() -> time.struct_time\n\
+\n\
+Returns a time.struct_time instance in UTC.\
+");
+PyDoc_STRVAR(TimeSpec_gmtime__doc, "\
+TimeSpec.gmtime() -> time.struct_time\n\
+\n\
+Alias for TimeSpec.timetuple()\
+");
+static PyObject *
+TimeSpec_timetuple(PsiTimeSpecObject *self)
+{
+    PyObject *time;
+    PyObject *timetuple;
+
+    time = import_time();
+    if (time == NULL)
+        return NULL;
+    timetuple = PyObject_CallMethod(time, "gmtime", "(l)", self->tv.tv_sec);
+    return timetuple;
+}
+
+
+PyDoc_STRVAR(TimeSpec_localtime__doc, "\
+TimeSpec.localtime() -> time.struct_time\n\
+\n\
+Returns a time.struct_time instance in the local timezone.\
+");
+static PyObject *
+TimeSpec_localtime(PsiTimeSpecObject *self)
+{
+    PyObject *time;
+    PyObject *localtime;
+
+    time = import_time();
+    if (time == NULL)
+        return NULL;
+    localtime = PyObject_CallMethod(time, "localtime", "(l)", self->tv.tv_sec);
+    return localtime;
+}
+
+
+#if HAVE_DATETIME
+
+PyDoc_STRVAR(TimeSpec_utcdatetime__doc, "\
+TimeSpec.utcdatetime()\n\
+\n\
+Returns a datetime.datetime instance representing the time in UTC.\
+");
+static PyObject *
+TimeSpec_utcdatetime(PsiTimeSpecObject *self)
+{
+    return timespec2utcdatetime(&self->tv);
+}
+
+
+PyDoc_STRVAR(TimeSpec_datetime__doc, "\
+TimeSpec.datetime() -> datetime.datetime\n\
+\n\
+Returns a datetime.datetime instance representing the time in the local\n\
+timezone. Note that the tzinfo of the datetime object will be unset.\
+");
+static PyObject *
+TimeSpec_datetime(PsiTimeSpecObject *self)
+{
+    return timespec2datetime(&self->tv);
+}
+
+
+PyDoc_STRVAR(TimeSpec_timedelta__doc, "\
+TimeSpec.timedelta() -> datetime.timedelta\n\
+\n\
+Retruns a datetime.timedelta instance representing the time as a duration.\
+");
+static PyObject *
+TimeSpec_timedelta(PsiTimeSpecObject *self)
+{
+    return timespec2timedelta(&self->tv);
+}
+
+#endif  /* HAVE_DATETIME */
+
+
+static PyGetSetDef TimeSpec_getseters[] = {
+    {"tv_sec", (getter)TimeSpec_get_tv_sec, (setter)NULL,
+     "Seconds", NULL},
+    {"tv_nsec", (getter)TimeSpec_get_tv_nsec, (setter)NULL,
+     "Nanoseconds", NULL},
+    {NULL}                      /* Sentinel */
+};
+
+
+static PyNumberMethods TimeSpec_as_number = {
+    (binaryfunc)TimeSpec_add,      /* nb_add */
+    (binaryfunc)TimeSpec_subtract, /* nb_subtract */
+    0,                             /* nb_multiply */
+#ifndef PY3K
+    0,                             /* nb_divide */
+#endif
+    0,                             /* nb_remainder */
+    0,                             /* nb_divmod */
+    0,                             /* nb_power */
+    0,                             /* nb_negative */
+    0,                             /* nb_posistive */
+    0,                             /* nb_absolute */
+    (inquiry)TimeSpec_bool,        /* nb_nonzero(2.X)/nb_bool(3.X) */
+};
+
+
+static PySequenceMethods TimeSpec_as_sequence = {
+    0,                              /* sq_length */
+    0,                              /* sq_concat */
+    0,                              /* sq_repeat */
+    (ssizeargfunc)TimeSpec_getitem, /* sq_item */
+    0,                              /* sq_ass_item */
+    0,                              /* sq_contains */
+    0,                              /* sq_inplace_concat */
+    0,                              /* sq_inplace_repeat */
+};
+
+
+static PyMethodDef TimeSpec_methods[] = {
+    {"timestamp", (PyCFunction)TimeSpec_timestamp,
+     METH_NOARGS, TimeSpec_timestamp__doc},
+    {"float", (PyCFunction)TimeSpec_timestamp,
+     METH_NOARGS, TimeSpec_float__doc},
+    {"mktime", (PyCFunction)TimeSpec_mktime,
+     METH_NOARGS, TimeSpec_mktime__doc},
+    {"timetuple", (PyCFunction)TimeSpec_timetuple,
+     METH_NOARGS, TimeSpec_timetuple__doc},
+    {"gmtime", (PyCFunction)TimeSpec_timetuple,
+     METH_NOARGS, TimeSpec_gmtime__doc},
+    {"localtime", (PyCFunction)TimeSpec_localtime,
+     METH_NOARGS, TimeSpec_localtime__doc},
+#if HAVE_DATETIME
+    {"utcdatetime", (PyCFunction)TimeSpec_utcdatetime,
+     METH_NOARGS, TimeSpec_utcdatetime__doc},
+    {"datetime", (PyCFunction)TimeSpec_datetime,
+     METH_NOARGS, TimeSpec_datetime__doc},
+    {"timedelta", (PyCFunction)TimeSpec_timedelta,
+     METH_NOARGS, TimeSpec_timedelta__doc},
+#endif  /* HAVE_DATETIME */
+    {NULL}                      /* Sentinel */
+};
+
+
+PyDoc_STRVAR(TimeSpec__doc, "\
+TimeSpec(tv_sec=x, tv_nsec=y) -> TimeSpec object\n\
+\n\
+This represents either absolute time since the epoch\n\
+(00:00 1 January 1970 UTC) in seconds and nanosecods,\n\
+or relative time in seconds and nanoseconds.\n\
+\n\
+It behaves a little bit like a tuple, but only index 0 and 1\n\
+are allowed, negative indexes don't work and neither does len().\n\
+Comparison with a tuple of lenght 2 works too.\n\
+");
+PyTypeObject PsiTimeSpec_Type = {
+    PyVarObject_HEAD_INIT(NULL, 0)
+    "psi.TimeSpec",                           /* tp_name */
+    sizeof(PsiTimeSpecObject),                /* tp_basicsize */
+    0,                                        /* tp_itemsize */
+    /* methods */
+    0,                                        /* tp_dealloc */
+    0,                                        /* tp_print */
+    0,                                        /* tp_getattr */
+    0,                                        /* tp_setattr */
+    0,                                        /* tp_compare */
+    (reprfunc)TimeSpec_repr,                  /* tp_repr */
+    &TimeSpec_as_number,                      /* tp_as_number */
+    &TimeSpec_as_sequence,                    /* tp_as_sequence */
+    0,                                        /* tp_as_mapping */
+    (hashfunc)TimeSpec_hash,                  /* tp_hash */
+    0,                                        /* tp_call */
+    0,                                        /* tp_str */
+    0,                                        /* tp_getattro */
+    0,                                        /* tp_setattro */
+    0,                                        /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE  /* tp_flags */
+#ifndef PY3K
+    | Py_TPFLAGS_CHECKTYPES
+#endif
+    ,
+    TimeSpec__doc,                            /* tp_doc */
+    0,                                        /* tp_traverse */
+    0,                                        /* tp_clear */
+    (richcmpfunc)TimeSpec_richcompare,        /* tp_richcompare */
+    0,                                        /* tp_weaklistoffset */
+    0,                                        /* tp_iter */
+    0,                                        /* tp_iternext */
+    TimeSpec_methods,                         /* tp_methods */
+    0,                                        /* tp_members */
+    TimeSpec_getseters,                       /* tp_getset */
+    0,                                        /* tp_base */
+    0,                                        /* tp_dict */
+    0,                                        /* tp_descr_get */
+    0,                                        /* tp_descr_set */
+    0,                                        /* tp_dictoffset */
+    (initproc)TimeSpec_init,                  /* tp_init */
+    0,                                        /* tp_alloc */
+    PyType_GenericNew,                        /* tp_new */
+};
+
+
+PyObject *
+PsiTimeSpec_InternalNew(const struct timespec *tv)
+{
+    PsiTimeSpecObject *obj;
+
+    obj = (PsiTimeSpecObject*)PyType_GenericNew(&PsiTimeSpec_Type, NULL, NULL);
+    if (obj == NULL)
+        return NULL;
+    obj->tv = *tv;              /* Skip calling the .__init__() method */
+    norm_timespec(&obj->tv);
+    return (PyObject*)obj;
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/PSI-0.3b2_gp/src/util.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/PSI-0.3b2_gp/src/util.c b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/util.c
new file mode 100644
index 0000000..5da6320
--- /dev/null
+++ b/tools/bin/pythonSrc/PSI-0.3b2_gp/src/util.c
@@ -0,0 +1,604 @@
+/* The MIT License
+ *
+ * Copyright (C) 2008-2009 Floris Bruynooghe
+ *
+ * Copyright (C) 2008-2009 Abilisoft Ltd.
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include <Python.h>
+
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+
+#include "psi.h"
+
+
+/***** Global Variables *****/
+
+/* psi._psi._C_API */
+static PyObject *(*TIMESPEC)(const struct timespec *) = NULL;
+
+
+/***** Functions *****/
+
+
+int
+psi_checkattr(const char *name, const int status)
+{
+    if (status == PSI_STATUS_OK)
+        return 0;
+    else if (status == PSI_STATUS_NI)
+        PyErr_Format(PsiExc_AttrNotImplementedError,
+                     "%s is not implemented on this system", name);
+    else if (status == PSI_STATUS_NA)
+        PyErr_Format(PsiExc_AttrNotAvailableError,
+                     "%s is not available for this process", name);
+    else if (status == PSI_STATUS_PRIVS)
+        PyErr_Format(PsiExc_AttrInsufficientPrivsError,
+                     "Insufficient privileges for %s", name);
+    return -1;
+}
+
+
+void *
+psi_malloc(size_t size)
+{
+    void *value;
+
+#ifdef PYMALLOC
+    value = PyMem_Malloc(size);
+#else
+    value = malloc(size);
+#endif
+    if (value == NULL)
+        PyErr_NoMemory();
+    return value;
+}
+
+
+void *
+psi_realloc(void *ptr, size_t size)
+{
+    void *value;
+
+#ifdef PYMALLOC
+    value = PyMem_Realloc(ptr, size);
+#else
+    value = realloc(ptr, size);
+#endif
+    if (value == NULL)
+        PyErr_NoMemory();
+    return value;
+}
+
+
+void
+psi_free(void *ptr)
+{
+#ifdef PYMALLOC
+    PyMem_Free(ptr);
+#else
+    free(ptr);
+#endif
+}
+
+
+void *
+psi_calloc(size_t size)
+{
+    void *value;
+
+    value = psi_malloc(size);
+    if (value == NULL)
+        return NULL;
+    memset(value, 0, size);
+    return value;
+}
+
+
+char *
+psi_strdup(const char *str)
+{
+    char *to;
+
+    to = psi_malloc((size_t)(strlen(str)+1));
+    if (to == NULL)
+        return NULL;
+    return strcpy(to, str);
+}
+
+
+char *
+psi_strndup(const char *str, size_t n)
+{
+    char *to;
+
+    to = psi_malloc((size_t)(n+1));
+    if (to == NULL)
+        return NULL;
+    to[n] = '\0';
+    return strncpy(to, str, n);
+}
+
+
+int
+psi_asprintf(char **ptr, const char *template, ...)
+{
+    va_list ap;
+    int r;
+    size_t size = 128;
+    char *ptr2;
+
+    *ptr = (char *)psi_malloc(size);
+    if (*ptr == NULL) {
+        PyErr_NoMemory();
+        return -1;
+    }
+    va_start(ap, template);
+    r = PyOS_vsnprintf(*ptr, size, template, ap);
+    va_end(ap);
+    if (r < 0) {
+        psi_free(*ptr);
+        *ptr = NULL;
+        PyErr_Format(PyExc_OSError,
+                     "PyOS_vsnprintf returned error code: %d", r);
+        return -1;
+    }
+    else if (r > (int)size) {
+        size = (size_t)r + 1;
+        ptr2 = (char *)psi_realloc(*ptr, size);
+        if (ptr2 == NULL) {
+            psi_free(*ptr);
+            ptr = NULL;
+            PyErr_NoMemory();
+            return -1;
+        }
+        *ptr = ptr2;
+        va_start(ap, template);
+        r = PyOS_vsnprintf(*ptr, size, template, ap);
+        va_end(ap);
+        if (r < 0 || r > (int)size) {
+            psi_free(*ptr);
+            *ptr = NULL;
+            if (r < 0)
+                PyErr_Format(PyExc_OSError,
+                             "PyOS_vsnprintf returned error code: %d", r);
+            else
+                PyErr_SetString(PyExc_OSError,
+                                "Required size from PyOS_vsnprintf was wrong!");
+            return -1;
+        }
+    }
+    return size;
+}
+
+
+int
+psi_read_file(char **buf, char *path)
+{
+    char *p, *startp;
+    FILE *file;
+    int n;
+    int bufsize = 2048;
+    int count = 0;
+    int endoffile = 0;
+
+    errno = 0;
+    file = fopen(path, "r");
+    if (file == NULL) {
+        PyErr_SetFromErrnoWithFilename(PyExc_OSError, path);
+        if (errno == EACCES || errno == EPERM)
+            return -2;
+        else
+            return -1;
+    }
+    startp = p = (char*) psi_malloc(bufsize + 1);
+    if (p == NULL)
+        return -1;
+    while ((n = fread(p, sizeof(char), 2048, file)) > 0) {
+        count += n;
+        if (n < 2048)
+            break;
+        /* We didn't have a big enough buffer so allocate some more. */
+        bufsize += 2048;
+        startp = psi_realloc(startp, bufsize + 1);
+        if (startp == NULL) {
+            fclose(file);
+            return -1;
+        }
+
+        /* Update our pointer to the end of the buffer */
+        p = startp + count;
+    }
+    endoffile = feof(file);
+    fclose(file);
+
+    if (!endoffile) {       /* read error */
+        psi_free(startp);
+        return -2;          /* XXX: Should be more specific here. */
+    }
+
+    /* Make sure the last character is null. */
+    startp[count] = '\0';
+    *buf = startp;
+    return count;
+}
+
+
+int
+psi_readlink(char **target, char *link)
+{
+    void *ptr;
+    size_t size = 128;
+    int r;
+
+    *target = (char *)psi_malloc(size);
+    if (*target == NULL)
+        return -1;
+    errno = 0;
+    r = readlink(link, *target, size-1);
+    while ((size_t)r == size-1) {
+        size += 128;
+        ptr = (char *)psi_realloc(*target, size);
+        if (ptr == NULL) {
+            psi_free(*target);
+            *target = NULL;
+            return -1;
+        }
+        *target = ptr;
+        errno = 0;
+        r = readlink(link, *target, size-1);
+    }
+    if (r == -1) {
+        psi_free(*target);
+        *target = NULL;
+        PyErr_SetFromErrnoWithFilename(PyExc_OSError, link);
+        if (errno == EACCES || errno == EPERM)
+            return -2;
+        else
+            return -1;
+    }
+    (*target)[r] = '\0';
+    return 0;
+}
+
+
+int
+psi_strings_count(const char *cmdl, const int size)
+{
+    int i = 0;
+    int n = 0;
+
+    while (i < size) {
+        if (cmdl[i] == '\0')
+            n += 1;
+        i++;
+    }
+    return n;
+}
+
+
+char **
+psi_strings_to_array(char *buf, const int count)
+{
+    char **array;
+    char *ptr;
+    int i;
+    int j;
+    int l;
+
+    array = psi_malloc(count * sizeof(char*));
+    if (array == NULL)
+        return NULL;
+    ptr = buf;
+    for (i = 0; i < count; i++) {
+        l = strlen(ptr) + 1;
+        array[i] = psi_malloc(l);
+        if (array[i] == NULL) {
+            for (j = 0; j < i; j++)
+                psi_free(array[j]);
+            psi_free(array);
+            return NULL;
+        }
+        memcpy(array[i], ptr, l);
+        ptr += l;
+    }
+    return array;
+}
+
+
+PyObject *
+PsiTimeSpec_New(const struct timespec *tv)
+{
+    if (TIMESPEC == NULL) {
+        PyObject *mod;
+        PyObject *c_api;
+
+        mod = PyImport_ImportModuleNoBlock("psi._psi");
+        if (mod == NULL)
+            return NULL;
+        c_api = PyObject_GetAttrString(mod, "_C_API");
+        if (c_api == NULL) {
+            Py_DECREF(mod);
+            return NULL;
+        }
+        TIMESPEC = PyCObject_AsVoidPtr(c_api);
+    }
+    return (*TIMESPEC)(tv);
+}
+
+
+#if PY_VERSION_HEX < 0x02040000 /* < 2.4 */
+
+/* This is copied from Python 2.6 sources. */
+
+#include <locale.h>
+
+/* ascii character tests (as opposed to locale tests) */
+#define ISSPACE(c)  ((c) == ' ' || (c) == '\f' || (c) == '\n' || \
+                     (c) == '\r' || (c) == '\t' || (c) == '\v')
+#define ISDIGIT(c)  ((c) >= '0' && (c) <= '9')
+
+/**
+ * PyOS_ascii_strtod:
+ * @nptr:    the string to convert to a numeric value.
+ * @endptr:  if non-%NULL, it returns the character after
+ *           the last character used in the conversion.
+ *
+ * Converts a string to a #gdouble value.
+ * This function behaves like the standard strtod() function
+ * does in the C locale. It does this without actually
+ * changing the current locale, since that would not be
+ * thread-safe.
+ *
+ * This function is typically used when reading configuration
+ * files or other non-user input that should be locale independent.
+ * To handle input from the user you should normally use the
+ * locale-sensitive system strtod() function.
+ *
+ * If the correct value would cause overflow, plus or minus %HUGE_VAL
+ * is returned (according to the sign of the value), and %ERANGE is
+ * stored in %errno. If the correct value would cause underflow,
+ * zero is returned and %ERANGE is stored in %errno.
+ * If memory allocation fails, %ENOMEM is stored in %errno.
+ *
+ * This function resets %errno before calling strtod() so that
+ * you can reliably detect overflow and underflow.
+ *
+ * Return value: the #gdouble value.
+ **/
+double
+PyOS_ascii_strtod(const char *nptr, char **endptr)
+{
+    char *fail_pos;
+    double val = -1.0;
+    struct lconv *locale_data;
+    const char *decimal_point;
+    size_t decimal_point_len;
+    const char *p, *decimal_point_pos;
+    const char *end = NULL; /* Silence gcc */
+    const char *digits_pos = NULL;
+    int negate = 0;
+
+    assert(nptr != NULL);
+
+    fail_pos = NULL;
+
+    locale_data = localeconv();
+    decimal_point = locale_data->decimal_point;
+    decimal_point_len = strlen(decimal_point);
+
+    assert(decimal_point_len != 0);
+
+    decimal_point_pos = NULL;
+
+    /* We process any leading whitespace and the optional sign manually,
+       then pass the remainder to the system strtod.  This ensures that
+       the result of an underflow has the correct sign. (bug #1725)  */
+
+    p = nptr;
+    /* Skip leading space */
+    while (ISSPACE(*p))
+        p++;
+
+    /* Process leading sign, if present */
+    if (*p == '-') {
+        negate = 1;
+        p++;
+    } else if (*p == '+') {
+        p++;
+    }
+
+    /* What's left should begin with a digit, a decimal point, or one of
+       the letters i, I, n, N. It should not begin with 0x or 0X */
+    if ((!ISDIGIT(*p) &&
+         *p != '.' && *p != 'i' && *p != 'I' && *p != 'n' && *p != 'N')
+        ||
+        (*p == '0' && (p[1] == 'x' || p[1] == 'X')))
+    {
+        if (endptr)
+            *endptr = (char*)nptr;
+        errno = EINVAL;
+        return val;
+    }
+    digits_pos = p;
+
+    if (decimal_point[0] != '.' ||
+        decimal_point[1] != 0)
+    {
+        while (ISDIGIT(*p))
+            p++;
+
+        if (*p == '.')
+        {
+            decimal_point_pos = p++;
+
+            while (ISDIGIT(*p))
+                p++;
+
+            if (*p == 'e' || *p == 'E')
+                p++;
+            if (*p == '+' || *p == '-')
+                p++;
+            while (ISDIGIT(*p))
+                p++;
+            end = p;
+        }
+        else if (strncmp(p, decimal_point, decimal_point_len) == 0)
+        {
+            /* Python bug #1417699 */
+            if (endptr)
+                *endptr = (char*)nptr;
+            errno = EINVAL;
+            return val;
+        }
+        /* For the other cases, we need not convert the decimal
+           point */
+    }
+
+    /* Set errno to zero, so that we can distinguish zero results
+       and underflows */
+    errno = 0;
+
+    if (decimal_point_pos)
+    {
+        char *copy, *c;
+
+        /* We need to convert the '.' to the locale specific decimal
+           point */
+        copy = (char *)PyMem_MALLOC(end - digits_pos +
+                                    1 + decimal_point_len);
+        if (copy == NULL) {
+            if (endptr)
+                *endptr = (char *)nptr;
+            errno = ENOMEM;
+            return val;
+        }
+
+        c = copy;
+        memcpy(c, digits_pos, decimal_point_pos - digits_pos);
+        c += decimal_point_pos - digits_pos;
+        memcpy(c, decimal_point, decimal_point_len);
+        c += decimal_point_len;
+        memcpy(c, decimal_point_pos + 1,
+               end - (decimal_point_pos + 1));
+        c += end - (decimal_point_pos + 1);
+        *c = 0;
+
+        val = strtod(copy, &fail_pos);
+
+        if (fail_pos)
+        {
+            if (fail_pos > decimal_point_pos)
+                fail_pos = (char *)digits_pos +
+                    (fail_pos - copy) -
+                    (decimal_point_len - 1);
+            else
+                fail_pos = (char *)digits_pos +
+                    (fail_pos - copy);
+        }
+
+        PyMem_FREE(copy);
+
+    }
+    else {
+        val = strtod(digits_pos, &fail_pos);
+    }
+
+    if (fail_pos == digits_pos)
+        fail_pos = (char *)nptr;
+
+    if (negate && fail_pos != nptr)
+        val = -val;
+
+    if (endptr)
+        *endptr = fail_pos;
+
+    return val;
+}
+
+double
+PyOS_ascii_atof(const char *nptr)
+{
+    return PyOS_ascii_strtod(nptr, NULL);
+}
+
+#endif  /* PY_VERSION_HEX < 0x02040000 */
+
+
+#if PY_VERSION_HEX < 0x03010000 /* < 3.1 */
+
+/** Copied from Python 3.1 sources
+ *
+ * Only change was to use PyOS_ascii_strtod instead of _PyOS_ascii_strtod.
+ *
+ * Note that the PyFPE_*_PROTECT macros have been disabled.  This is because
+ * they do a crazy thing with casts that will create a warning (they loose
+ * information) that doesn't matter (the information is not needed, this is
+ * merely used to trick the FPU from some arches into generating SIGFPE), see
+ * pyfpe.h for the details.
+ *
+ * The point is that commenting these macros out should not have any
+ * regressions, when we where using PyOS_ascii_strtod() directly we didn't use
+ * these macro's either.  And if any of uptime or boottime (the only place
+ * this is used currently) do overflow I'm long dead anyway, unless something
+ * crazy happened to the world.
+ */
+
+double
+PyOS_string_to_double(const char *s,
+		      char **endptr,
+		      PyObject *overflow_exception)
+{
+    double x, result=-1.0;
+    char *fail_pos;
+
+    errno = 0;
+/*     PyFPE_START_PROTECT("PyOS_string_to_double", return -1.0) */
+    x = PyOS_ascii_strtod(s, &fail_pos);
+/*     PyFPE_END_PROTECT(x) */
+
+    if (errno == ENOMEM) {
+        PyErr_NoMemory();
+        fail_pos = (char *)s;
+    }
+    else if (!endptr && (fail_pos == s || *fail_pos != '\0'))
+        PyErr_Format(PyExc_ValueError,
+                     "could not convert string to float: %.200s", s);
+    else if (fail_pos == s)
+        PyErr_Format(PyExc_ValueError,
+                     "could not convert string to float: %.200s", s);
+    else if (errno == ERANGE && fabs(x) >= 1.0 && overflow_exception)
+        PyErr_Format(overflow_exception,
+                     "value too large to convert to float: %.200s", s);
+    else
+        result = x;
+
+    if (endptr != NULL)
+        *endptr = fail_pos;
+    return result;
+}
+
+#endif  /* PY_VERSION_HEX < 0x03010000 */


[10/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code

Posted by rl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/FormatStringChecks.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/FormatStringChecks.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/FormatStringChecks.py
new file mode 100644
index 0000000..563da14
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/FormatStringChecks.py
@@ -0,0 +1,183 @@
+from pychecker2.Check import Check
+from pychecker2.util import BaseVisitor
+from pychecker2.Warning import Warning
+from compiler import ast, walk
+from types import *
+import re
+
+class UnknownError(Exception): pass
+
+def _compute_node(node, recurse):
+    if isinstance(node, ast.Add):
+        return recurse(node.left) + recurse(node.right)
+    elif isinstance(node, ast.Mul):
+        return recurse(node.left) * recurse(node.right)
+    elif isinstance(node, ast.Sub):
+        return recurse(node.left) - recurse(node.right)
+    elif isinstance(node, ast.Div):
+        return recurse(node.left) / recurse(node.right)
+    raise UnknownError
+
+def _compute_constant(node):
+    "Compute a simple forms of constant strings from an expression node"
+    if isinstance(node, ast.Const):
+        return node.value
+    return _compute_node(node, _compute_constant)
+
+def _compute_tuple_size(node):
+    "Compute the length of simple forms of tuples from an expression node"
+    if isinstance(node, ast.Tuple):
+        return (None,) * len(node.nodes)
+    if isinstance(node, ast.Const):
+        return node.value
+    if isinstance(node, ast.Backquote):
+        return ''
+    return _compute_node(node, _compute_tuple_size)
+
+# for details: http://www.python.org/doc/current/lib/typesseq-strings.html
+_MOD_AND_TYPE = '([hlL])?([diouxXeEfFgGcrs%])'
+_TUP_FORMAT_REGEX = re.compile('%(())?[ #+-]*'
+                               '([0-9]*|[*])(|[.](|[*]|[0-9]*))' +
+                               _MOD_AND_TYPE)
+_DICT_FORMAT_REGEX = re.compile('%([(]([a-zA-Z_]+)[)])?[ #+-]*'
+                                '([0-9]*)(|[.](|[0-9]*))' + _MOD_AND_TYPE)
+
+class FormatError(Exception):
+    def __init__(self, position):
+        Exception.__init__(self)
+        self.position = position
+
+def _check_format(s):
+    pos = 0
+    specs = []
+    while 1:
+        pos = s.find('%', pos)
+        if pos < 0:
+            return specs
+
+        match = _TUP_FORMAT_REGEX.search(s, pos)
+        if not match or match.start(0) != pos:
+            match = _DICT_FORMAT_REGEX.search(s, pos)
+            if not match or match.start(0) != pos:
+                raise FormatError(pos)
+
+        if match.group(7) != '%':       # ignore "%%"
+            specs.append( (match.group(2), match.group(3), match.group(5),
+                           match.group(6)) )
+        pos = match.end(0)
+    return specs
+
+class _GetMod(BaseVisitor):
+    def __init__(self):
+        self.mods = []
+    def visitMod(self, node):
+        self.mods.append(node)
+        self.visitChildren(node)
+    # don't descend into other scopes
+    def visitFunction(self, node): pass
+    visitClass = visitFunction
+    visitLambda = visitFunction
+
+def get_mods(node):
+    try:
+        return walk(node.code, _GetMod()).mods
+    except AttributeError:
+        return walk(node.node, _GetMod()).mods
+
+_BAD_FORMAT_MAX = 10
+def _bad_format_str(s, pos):
+    result = s[pos : pos + _BAD_FORMAT_MAX]
+    return result + (len(s) > pos + _BAD_FORMAT_MAX and "..." or "")
+
+class FormatStringCheck(Check):
+    "Look for warnings in format strings"
+
+    badFormat = \
+              Warning('Report illegal format specifications in format strings',
+                      'Bad format specifier at position %d (%s)')
+    uselessModifier = \
+              Warning('Report unused modifiers for format strings (l, h, L)',
+                      'Modifier %s is not necessary')
+
+    mixedFormat = \
+              Warning('Report format strings which use both positional '
+                      'and named formats',
+                      'Cannot mix positional and named formats (%%%s)')
+    
+    formatCount = \
+              Warning('Report positional format string with the wrong '
+                      'number of arguments',
+                      'Wrong number of arguments supplied for format: '
+                      '%d given %d required')
+    unknownFormatName = \
+              Warning('Report unknown names if locals() or globals() '
+                      'are used for format strings',
+                      'The name "%s" is not defined in %s')
+
+    badConstant = \
+              Warning('Report bad constant expressions for format strings',
+                      'Error computing constant: %s')
+
+    def check(self, file, unused_checker):
+        if not file.parseTree:
+            return
+
+        for scope in file.scopes.values():
+            for mod in get_mods(scope.node):
+                formats = []
+                try:
+                    s = _compute_constant(mod.left)
+                    formats = _check_format(s)
+                except FormatError, detail:
+                    file.warning(mod, self.badFormat, detail.position,
+                                 _bad_format_str(s, detail.position))
+                except TypeError, detail:
+                    file.warning(mod, self.badConstant, str(detail))
+                except UnknownError:
+                    pass
+                if not formats:
+                    continue
+
+                count = len(formats)
+                for name, width, precision, lmodifier in formats:
+                    if lmodifier:
+                        file.warning(mod, self.uselessModifier, lmodifier)
+                    if width == '*':
+                        count += 1
+                    if precision == '*':
+                        count += 1
+
+                names = [f[0] for f in formats if f[0]]
+                if len(names) == 0:     # tuple
+                    try:
+                        t = _compute_tuple_size(mod.right)
+                        n = 1
+                        if type(t) == TupleType:
+                            n = len(t)
+                        if n != count:
+                            file.warning(mod, self.formatCount, n, count)
+                    except UnknownError:
+                        pass
+                    except TypeError, detail:
+                        file.warning(mod, self.badConstant, str(detail))
+
+                elif len(names) == len(formats): # dictionary
+                    defines = None
+                    if isinstance(mod.right, ast.CallFunc) and \
+                       isinstance(mod.right.node, ast.Name):
+                        if mod.right.node.name in ['locals', 'vars']:
+                            defines = scope.defs
+                            uses = scope.uses
+                        if mod.right.node.name == 'globals':
+                            defines = file.root_scope.defs
+                            uses = file.root_scope.uses
+                    if defines is not None:
+                        for n in names:
+                            if not defines.has_key(n):
+                                file.warning(mod, self.unknownFormatName,
+                                             n, mod.right.node.name)
+                            else:
+                                uses[n] = uses.get(n, mod)
+                else:
+                    file.warning(mod, self.mixedFormat, "(%s)" % names[0])
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/ImportChecks.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/ImportChecks.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/ImportChecks.py
new file mode 100644
index 0000000..43eef4a
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/ImportChecks.py
@@ -0,0 +1,93 @@
+from pychecker2.Check import Check
+from pychecker2.Check import Warning
+from pychecker2 import util
+
+from compiler import walk
+
+class ModuleReference:
+    def __init__(self, localname, remotename, module, nodes):
+        self.localname = localname
+        self.remotename = remotename
+        self.module = module
+        self.nodes = nodes
+
+    def __getstate__(self):
+        return (self.localname, self.remotename, self.module.__name__, 
+                self.nodes)
+
+    def __setstate__(self, data):
+        (self.localname, self.remotename, module, self.nodes) = data
+        self.module = __import__(module, globals(), {}, [''])
+
+class ImportCheck(Check):
+    '''
+Get 'from module import *' names hauled into the file and modules.
+Figure out which names come from 'import name'.
+    '''
+
+    importError = Warning('Report/ignore imports that may fail',
+                          'Error trying to import %s: %s')
+    duplicateImport = Warning('Report/ignore duplicate imports',
+                              'Import of "%s" is duplicate%s')
+    shadowImport = Warning('Report imports which shadow names from '
+                           'other imports',
+                           'Import of "%s" duplicates import from '
+                           'module %s at %d')
+
+    def check(self, file, checker):
+        def try_import(name, node):
+            try:
+                return __import__(name, globals(), {}, [''])
+            except ImportError, detail:
+                file.warning(node, ImportCheck.importError, name, str(detail))
+            except Exception, detail:
+                file.warning(node, ImportCheck.importError, name, str(detail))
+            return None
+
+        def add_import(node, local, remote, module):
+            scopes = util.enclosing_scopes(file.scopes, node)
+            for scope in scopes:
+                try:
+                    ref = scope.imports[local]
+                    if not util.try_if_exclusive(ref.nodes, node):
+                        if ref.module == module:
+                            if scope == scopes[0]:
+                                extra = " in current scope"
+                            else:
+                                extra = " of import in parent scope %s" % scope
+                            file.warning(node, ImportCheck.duplicateImport,
+                                         local, extra)
+                        else:
+                            file.warning(node, ImportCheck.shadowImport,
+                                         local,
+                                         ref.module.__name__,
+                                         ref.nodes.lineno)
+                except KeyError:
+                    pass
+            scopes[0].imports[local] = ModuleReference(local, remote,
+                                                       module, node)
+            checker.check_module(module)
+            
+        class FromImportVisitor:
+
+            def visitFrom(self, node):
+                m = try_import(node.modname, node)
+                if m:
+                    for module_name, local_name in node.names:
+                        if module_name == '*':
+                            for name in dir(m):
+                                if not name.startswith('_'):
+                                   add_import(node, name, name, m)
+                        else:
+                            add_import(node, local_name or module_name,
+                                       module_name, m)
+
+            def visitImport(self, node):
+                for module, name in node.names:
+                    m = try_import(module, node)
+                    if m:
+                        add_import(node, name or module, None, m)
+
+
+        if file.root_scope:
+            walk(file.root_scope.node, FromImportVisitor())

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/NOTES.txt
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/NOTES.txt b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/NOTES.txt
new file mode 100644
index 0000000..95bcb7b
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/NOTES.txt
@@ -0,0 +1,131 @@
+This is a re-write of pychecker using traditional parse tree
+techniques, rather than the bytecode.
+
+There are some other design changes, related to Warning objects and
+Option handling.  In general, pychecker2 tries to distribute checks to
+separate classes.  These classes are more self-contained: they hold
+onto the option variables and define the Warning objects they support.
+
+ToDo:
+        All missing stuff
+        Always returning None
+        It is illegal to delete a name from the local namespace if it occurs
+            as a free variable in a nested block.
+        More path analysis
+            used before set for if/else try/except
+        Warn about unpacking args:
+             def f(a, (b, c)): pass
+
+Items still missing:
+        Error suppression (errors may be suppressed globally)
+
+        Detail of exception is an exception
+        Local used after deleted, already deleted, deleted before set
+        Not calling base class __init__
+        Using return value which is always None
+        Wrong # of args on function (including ctor)
+        Function arguments, kwargs
+        Abstract methods
+        exec may use locals/globals
+        import x with from x import
+
+        Modifying a default parameter
+        Tuple access to list list[1, 2]
+        List .append() takes one argument
+        Return None from __getattr__
+        string iteration
+        Inconsistent return type
+        Object has no attr
+        Method read as attribute, but not called:
+        Function always returns None (use empty return)
+        Unpack wrong size
+        Unpack wrong type
+
+        Exec warnings
+        Security warning: input()
+
+        Module imports itself
+        Complexity
+        Doc strings
+        New python features:
+             slots
+             properties
+             integer division
+        Warning for string raising
+
+Bugs:
+        More member not used
+        Speed
+        Is __file__ a builtin?
+
+        Aliases:
+            class C:
+                  def f(a, b): pass
+                  def g(a, b): pass
+                  h = f
+                  h = g			# redef of h, not caught now
+
+        foo = 1
+        del foo	                        # should not be unused
+
+        from __future__ import produces unused warnings
+        import of readline has side effect on input/raw_input, and should be
+           marked as used
+
+Important stuff:
+
+If you want to add new checks, there are some parts to be aware of:
+
+        File
+                A stupid data structure to hold everything we know about 
+                a file to be checked.
+
+                Members:
+                   name
+                        The file name.
+
+                   parseTree
+                        The root of the Abstract Syntax Tree returned from
+                        compiler.parseFile.  Will be None if the file
+                        won't even parse.
+
+                   scopes
+                        A dictionary of { node, scope } computed with
+                        from compiler.symbols. For convenience, scopes
+                        also refer back to the node and to the
+                        enclosing parent scope (node and parent,
+                        respectively).
+
+                    root_scope
+                        Convience for scopes[parseTree]
+
+        Check
+                Basic step for checking a file.  Usually contributes
+                Warnings or additional information to File.  New checks
+                will subclass this, and be added to the chain of checks
+                given in main().
+
+        Warning
+                A description of a warning emitted by pychecker.
+
+        CheckList
+                Contains "global" check information: cached module
+                data and the list of Check objects.
+
+        Command line options are pulled from each check.
+        A Warning is also turned into a boolean-style command line option.
+
+To add a new check, write a class (e.g., CompareCheck) that subclasses the
+Check class.  In its check method if you need to visit nodes of a particular
+type, write a Visitor class (subclass of BaseVisitor) which has a
+visit<Node> method, where <Node> is the name of a type of node to visit.
+See 
+
+    http://www.python.org/~jeremy/compiler/module-compiler.ast.html
+
+for the types of the nodes or print file.parseTree to see what classes all
+the nodes are.  See the OpChecks.CompareCheck class for an example of a
+check that visits all Compare nodes and the OpChecksExceptCheck class for an
+example that visits all TryExcept nodes.
+
+New checks should have unit tests in utest/.

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/OpChecks.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/OpChecks.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/OpChecks.py
new file mode 100644
index 0000000..c99d5a3
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/OpChecks.py
@@ -0,0 +1,68 @@
+from pychecker2.Check import Check
+from pychecker2.Warning import Warning
+from pychecker2.util import BaseVisitor
+
+import compiler
+
+
+class OpCheck(Check):
+
+    operator = Warning(
+        "Check for (++) and (--) which are legal, but not useful",
+        "Operator (%s) doesn't exist, statement has no effect"
+        )
+    operatorPlus = Warning(
+        'Check for unary +',
+        "Operator (+) normally has no effect"
+        )
+
+    def check(self, file, unused_checklist):
+        class OpVisitor:
+            def visitUnaryAdd(s, n):
+                if n.getChildren()[0].__class__ == compiler.ast.UnaryAdd:
+                    file.warning(n, self.operator, '++')
+                else:
+                    file.warning(n, self.operatorPlus)
+
+            def visitUnarySub(s, n):
+                if n.getChildren()[0].__class__ == compiler.ast.UnarySub:
+                    file.warning(n, self.operator, '--')
+        if file.parseTree:        
+            compiler.walk(file.parseTree, OpVisitor())
+
+class ExceptCheck(Check):
+    emptyExcept = Warning('Warn about "except:"',
+                          'Empty except clauses can hide unexpected errors')
+    
+    def check(self, file, unused_checklist):
+        class ExceptVisitor(BaseVisitor):
+            def visitTryExcept(s, node):
+                for exc, det, code in node.handlers:
+                    if exc is None:
+                        file.warning(code.nodes[0], self.emptyExcept)
+                s.visitChildren(node)
+        if file.parseTree:
+            compiler.walk(file.parseTree, ExceptVisitor())
+
+class CompareCheck(Check):
+    useIs = Warning('warn about "== None"',
+                    'use "is" when comparing with None')
+
+    def check(self, file, unused_checklist):
+        def checkEqualNone(node, expr, op):
+            if (op == '==' and 
+                expr.__class__ == compiler.ast.Name and
+                expr.name == "None"):
+                file.warning(node, self.useIs)
+
+        class CompareVisitor(BaseVisitor):
+            def visitCompare(s, node):
+                children = node.getChildren()
+                for i in range(0, len(children) - 1, 2):
+                    left, op = children[i:i+2]
+                    checkEqualNone(node, left, op)
+                op, right = children[-2:]
+                checkEqualNone(node, right, op)
+
+        if file.parseTree:
+            compiler.walk(file.parseTree, CompareVisitor())

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/Options.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/Options.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/Options.py
new file mode 100644
index 0000000..b64f9a9
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/Options.py
@@ -0,0 +1,106 @@
+class Error(Exception): pass
+
+class Opt:
+
+    def __init__(self, object, longName, description, default):
+        self.object = object
+        self.longName = longName
+        self.description = description
+        setattr(object, longName, default)
+        self.default = default
+        
+    def set_value(self, value):
+        setattr(self.object, self.longName, value)
+
+    def get_value(self):
+        return getattr(self.object, self.longName)
+
+    def get_description(self):
+        return self.description
+
+    def is_boolean(self):
+        return None
+    
+    def reset(self):
+        setattr(self.object, self.longName, self.default)
+
+class BoolOpt(Opt):
+
+    def __init__(self, object, longName, description, default = None):
+        Opt.__init__(self, object, longName, description, default)
+
+    def set_value(self, unused):
+        setattr(self.object, self.longName, not self.get_value())
+        
+    def is_boolean(self):
+        return 1
+
+
+MAJOR = 'Major'
+ERROR = 'Error'
+MISC = 'Miscellaneous'
+Categories = [MAJOR, ERROR, MISC]
+
+class Options:
+
+    def __init__(self):
+        self.options = {}
+        for c in Categories:
+            self.options[c] = []
+        self.add(BoolOpt(self, 'verbose', 'turn on verbose messages'), MISC)
+        self.add(BoolOpt(self, 'incremental', 'print warnings as they are created'), MISC)
+        self.add(BoolOpt(self, 'profile', 'print a profile of pychecker', 0), MISC)
+
+    def add(self, option, category=ERROR):
+        self.options[category].append(option)
+        
+    def process_options(self, args):
+        import getopt
+        try:
+            longopts = {}
+            for opts in self.options.values():
+                for opt in opts:
+                    opt.reset()
+                    optname = opt.longName
+                    if opt.is_boolean() and opt.get_value():
+                        optname = "no-" + opt.longName
+                    longopts[optname] = opt
+            specs = []
+            for k, v in longopts.items():
+                if not v.is_boolean():
+                    k += '='
+                specs.append(k)
+            opts, args = getopt.getopt(args, '', specs)
+        except getopt.GetoptError, detail:
+            raise Error(detail)
+        
+        for opt, arg in opts:
+            longopts[opt[2:]].set_value(arg)
+
+        from pychecker2.File import File
+        return [ File(f) for f in args ]
+
+    def usage(self, argv0, stream):
+        indent = " "
+        over = 20
+        print >> stream, "Usage:"
+        print >> stream, \
+              "%s%s [options] [--] file1.py file2.py ..." % (indent, argv0)
+        print >> stream, "available options:"
+        for c in Categories:
+            if not self.options[c]:
+                continue
+            print >> stream
+            print >> stream, "%s:" % c
+            opts = self.options[c]
+            opts.sort(lambda x, y: cmp(x.longName, y.longName))
+            for opt in opts:
+                name = opt.longName
+                if opt.is_boolean() and opt.get_value():
+                        name = "no-" + name
+                print >> stream, "%s--%*s %s" % (
+                    indent, -over, name, opt.get_description())
+                if not opt.is_boolean():
+                    print >> stream, "%s  %*s %s" % (
+                        indent, -over, '', opt.get_value())
+            

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/ParseChecks.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/ParseChecks.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/ParseChecks.py
new file mode 100644
index 0000000..9c99733
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/ParseChecks.py
@@ -0,0 +1,84 @@
+from pychecker2.Check import Check
+from pychecker2.Warning import Warning
+from pychecker2.Options import BoolOpt
+from pychecker2 import symbols
+
+from compiler import parseFile, walk
+import parser
+
+def _parent_link(node):
+    for c in node.getChildNodes():
+        c.parent = node
+        _parent_link(c)
+
+class ParseCheck(Check):
+
+    syntaxErrors = Warning('Report/ignore syntax errors',
+                           'Unable to parse: %s')
+
+    def __init__(self):
+        self.main = None
+    
+    def get_options(self, options):
+        desc = 'Ignore module-level code protected by __name__ == "__main__"'
+        options.add(BoolOpt(self, 'main', desc, 1))
+    
+    def check(self, file, unused_checker):
+        try:
+            file.parseTree = parseFile(file.name)
+            # link each node to it's parent
+            _parent_link(file.parseTree)
+            file.parseTree.parent = None
+        except parser.ParserError, detail:
+            file.warning(1, self.syntaxErrors, detail.args[0])
+        except IOError, detail:
+            file.warning(0, self.syntaxErrors, detail.strerror)
+        if not file.parseTree:
+            return
+
+        if not self.main:
+            # remove __name__ == '__main__' code from module-level
+            for n in file.parseTree.node.nodes:
+                try:
+                    test, code = n.tests[0]
+                    comparison, value = test.ops[0]
+                    if comparison == '==':
+                        try:
+                            if test.expr.name == '__name__' and \
+                               value.value == '__main__':
+                                file.parseTree.node.nodes.remove(n)
+                                break
+                        except AttributeError:
+                            if test.expr.value == '__main__' and \
+                               value.name == '__name__':
+                                file.parseTree.node.nodes.remove(n)
+                                break
+                except (AttributeError, IndexError):
+                    pass
+
+        file.scopes = walk(file.parseTree, symbols.SymbolVisitor()).scopes
+        file.root_scope = file.scopes[file.parseTree]
+
+        # add starting lineno into scopes, since they don't have it
+        for k, v in file.scopes.items():
+            v.lineno = k.lineno
+
+        # define the root of the scope tree (global scope, within
+        # the module)
+        file.root_scope.lineno = 1
+
+        # create a mapping from scopes back to the nodes which made 'em
+        for node, scope in file.scopes.items():
+            scope.node = node
+
+        # create a mapping from each scope back to it's enclosing scope
+        for s in file.scopes.values():
+            for c in s.get_children():
+                c.parent = s
+        file.root_scope.parent = None
+
+        # initialize the mapping of imported names to modules
+        for s in file.scopes.values():
+            s.imports = {}
+
+            

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/ReachableChecks.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/ReachableChecks.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/ReachableChecks.py
new file mode 100644
index 0000000..7e506cb
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/ReachableChecks.py
@@ -0,0 +1,91 @@
+from pychecker2.Check import Check
+from pychecker2.util import BaseVisitor
+from pychecker2.Warning import Warning
+
+from compiler import ast, walk
+
+class ReachableCheck(Check):
+
+    unreachable = Warning('Report unreachable code', 'Line is unreachable')
+
+    implicitReturn = \
+       Warning('Report implicit return in a function with explicit returns',
+               'Function %s uses both implicit and explicit returns')
+
+    def check(self, file, unused_checker):
+        class ReturnsVisitor(BaseVisitor):
+            def __init__(s):
+                s.always_returns = 0    #  icky: result value by side-effect
+                s.has_returns = 0
+
+            def check_returns(s, node):
+                s.always_returns = 0                
+                s.visit(node)
+                return s.always_returns
+                
+            def alternatives_with_else(s, nodes, else_):
+                for n in nodes:
+                    if not s.check_returns(n):
+                        return
+                s.always_returns = 0
+                if else_:
+                    s.visit(else_)
+
+            def visitAssert(s, node):
+                if isinstance(node.test, ast.Const):
+                    s.always_returns = not node.test.value
+                if isinstance(node.test, ast.Name):
+                    if node.test.name == 'None':
+                        s.always_returns = 1
+
+            def visitReturn(s, node):
+                s.always_returns = 1
+                if not isinstance(node.value, ast.Const) or \
+                   node.value.value is not None:
+                    s.has_returns = 1
+                
+            def visitRaise(s, unused_node):
+                s.always_returns = 1
+
+            def visitTryExcept(s, node):
+                # if body always returns, else code is unreachable
+                if s.check_returns(node.body) and node.else_:
+                    file.warning(node.else_.nodes[0], self.unreachable)
+                s.always_returns = 0
+                # no matter what happens in the try clause, it might
+                # cause an exception, so check the handlers and else
+                # conditions all return
+                handlers = [code for exc, detail, code in node.handlers]
+                s.alternatives_with_else(handlers, node.else_ or node.body)
+
+            def visitIf(s, node):
+                code = [code for cond, code in node.tests]
+                s.alternatives_with_else(code, node.else_)
+                    
+            def visitStmt(s, node):
+                for n in range(len(node.nodes) - 1):
+                    if s.check_returns(node.nodes[n]):
+                        file.warning(node.nodes[n + 1], self.unreachable)
+                        break
+                else:
+                    if node.nodes and \
+                       not s.check_returns(node.nodes[-1]) and \
+                       isinstance(node.parent, ast.Function) and \
+                       s.has_returns:
+                        file.warning(node.nodes[-1], self.implicitReturn,
+                                     node.parent.name)
+                
+            def visitFunction(s, node):
+                pass
+            visitClass = visitFunction
+
+            def visitWhile(s, unused):
+                # FIXME: while's may never execute and not return
+                s.always_returns = 0
+
+            visitFor = visitWhile
+
+        for scope in file.scopes.values():
+            if isinstance(scope.node, ast.Function):
+                walk(scope.node.code, ReturnsVisitor())
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/ReturnChecks.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/ReturnChecks.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/ReturnChecks.py
new file mode 100644
index 0000000..494d6dc
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/ReturnChecks.py
@@ -0,0 +1,43 @@
+from pychecker2.Check import Check
+from pychecker2.Check import Warning
+from pychecker2.util import BaseVisitor, type_filter
+from pychecker2 import symbols
+
+from compiler import ast, walk
+
+class Returns(BaseVisitor):
+
+    def __init__(self):
+        self.result = []
+
+    def visitReturn(self, node):
+        self.result.append(node)
+
+    # Don't descend into other scopes
+    def visitFunction(self, node): pass
+    visitClass = visitFunction
+    visitLambda = visitFunction
+
+def _is_implicit(node):
+    if isinstance(node, ast.Const) and node.value is None:
+        return 1
+    return None
+
+class MixedReturnCheck(Check):
+
+    mixedReturns = \
+        Warning('Report functions using "return" and "return value"',
+                'Function %s uses both "return" and "return value"')
+
+    def check(self, file, unused_checker):
+        for scope in type_filter(file.scopes.values(), symbols.FunctionScope):
+            returns = walk(scope.node.code, Returns()).result
+            empty, value = [], []
+            for node in returns:
+                if _is_implicit(node.value):
+                    empty.append(node)
+                else:
+                    value.append(node)
+            if len(empty) > 0 and len(value) > 0:
+                file.warning(empty[0], self.mixedReturns, scope.name)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/ScopeChecks.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/ScopeChecks.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/ScopeChecks.py
new file mode 100644
index 0000000..5f5d19d
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/ScopeChecks.py
@@ -0,0 +1,28 @@
+
+from pychecker2.Check import Check
+from pychecker2.Warning import Warning
+from pychecker2 import util
+
+from compiler.ast import *
+
+class RedefineCheck(Check):
+    redefinedScope = Warning('Report redefined scopes',
+                             'Scope (%s) is redefined at line %d')
+
+    def check(self, file, unused_checker):
+        names = {}                      # map name, parent to this scope
+        for node, scope in file.scopes.items():
+            if hasattr(node, 'name'):	# classes, functions
+                key = (scope.parent, node.name)
+                if names.has_key(key):
+                    # oops, another scope has the same name and parent
+                    first = node
+                    second = names[key]
+                    # but don't warn if the parent node is the same If or Try
+                    if util.try_if_exclusive(first, second):
+                        continue
+                    if first.lineno > second.lineno:
+                        second, first = first, second
+                    file.warning(first, self.redefinedScope,
+                                 first.name, second.lineno)
+                names[key] = node

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/TestSupport.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/TestSupport.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/TestSupport.py
new file mode 100644
index 0000000..cc03a5e
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/TestSupport.py
@@ -0,0 +1,57 @@
+from pychecker2 import main
+from pychecker2 import Options
+
+import unittest
+
+class WarningTester(unittest.TestCase):
+    def __init__(self, arg):
+        unittest.TestCase.__init__(self, arg)
+        self.options = Options.Options()
+        self.checklist = main.create_checklist(self.options)
+        self.argv = []
+
+    def check_warning(self, w, expected_line, expected_type, *expected_args):
+        warn_line, warn_type, warn_args = w
+        try:
+            self.assertEqual(warn_type, expected_type)
+            self.assertEqual(warn_line, expected_line)
+            self.assertEqual(len(warn_args), len(expected_args))
+            for i in range(len(expected_args)):
+                self.assertEqual(warn_args[i], expected_args[i])
+        except AssertionError:          # help w/debugging
+            print warn_line, warn_type, warn_args
+            print expected_line, expected_type, expected_args
+            raise
+
+    def check_file(self, data):
+        import tempfile, os
+        fname = tempfile.mktemp()
+        fp = open(fname, 'wb')
+        try:
+            fp.write(data)
+            fp.close()
+            f, = self.options.process_options(self.argv + [fname])
+            self.checklist.check_file(f)
+        finally:
+            fp.close()
+            os.unlink(fname)
+        return f
+
+    def warning_file(self, f, line, warning, *args):
+        assert len(f.warnings) == 1, "Not just one warning:" + `f.warnings`
+        self.check_warning(f.warnings[0], line, warning, *args)
+
+    def warning(self, test, line, warning, *args):
+        test += '\n'
+        f = self.check_file(test)
+        self.warning_file(f, line, warning, *args)
+
+    def silent(self, test):
+        f = self.check_file(test)
+        if f.warnings:
+            print f.warnings
+        self.assertEqual(len(f.warnings), 0)
+
+    def setUp(self):
+        self.argv = []
+        

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/VariableChecks.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/VariableChecks.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/VariableChecks.py
new file mode 100644
index 0000000..debdd17
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/VariableChecks.py
@@ -0,0 +1,354 @@
+from pychecker2.Check import Check
+from pychecker2.Options import Opt, BoolOpt
+from pychecker2.Warning import Warning
+from pychecker2.util import *
+from pychecker2 import symbols
+
+from compiler import ast, walk
+
+def _is_method(scope):
+    return scope.__class__ is symbols.FunctionScope and \
+           scope.parent.__class__ is symbols.ClassScope
+
+def _is_self(scope, name):
+    return _is_method(scope) and name in scope.node.argnames[:1]
+
+def is_arg_and_defaulted_to_same_name(name, scope):
+    if isinstance(scope, symbols.FunctionScope):
+        if name in scope.node.argnames and scope.node.defaults:
+            # compute default args
+            args = scope.node.argnames[:]
+            # knock off kwargs
+            if scope.node.kwargs:
+                args = args[:-1]
+            # knock off varags 
+            if scope.node.varargs:
+                args = args[:-1]
+            # take the last args as the defaults
+            args = args[-len(scope.node.defaults):]
+            try:
+                # get the corresponding default arg value
+                default = scope.node.defaults[args.index(name)]
+                # must be a Name node of the same name
+                if isinstance(default, ast.Name) and \
+                   default.name == name:
+                    return 1
+            except ValueError:
+                pass
+    return None
+
+
+class ShadowCheck(Check):
+    """Use symbol information to check that no scope defines a name
+    already known to a parent scope"""
+
+    defineNone = Warning('Report any redefinition of None',
+                         'Do not redefine None')
+    shadowBuiltins = Warning('Report names that shadow builtins',
+                            'Identifier (%s) shadows builtin', 0)
+    shadowIdentifier = Warning('Report names already defined in outer scopes',
+                               'Identifier (%s) shadows definition in scope %s')
+    def check(self, file, unused_checker):
+        # warn if any name defined in a scope is defined in a parent scope
+        # or even the builtins
+        for node, scope in file.not_class_scopes():
+            for name in scope.defs:
+                if name == 'None':
+                    file.warning(scope.defs[name], self.defineNone)
+                    continue
+                if name in scope.globals:
+                    continue
+                if is_arg_and_defaulted_to_same_name(name, scope):
+                    continue
+                if _is_self(scope, name):
+                    continue
+                if __builtins__.has_key(name):
+                    file.warning(scope.defs[name], self.shadowBuiltins, name)
+                for p in parents(scope):
+                    if p.defs.has_key(name) and \
+                       not isinstance(p, symbols.ClassScope):
+                        file.warning(scope.defs[name], \
+                                     self.shadowIdentifier, name, `p`)
+
+def _str_value(s):
+    if type(s) == type(''):
+        return eval(s)
+    return s
+
+
+def _empty_function(stmts):
+    if not stmts:
+        return 1
+    stmt = stmts[0]
+    # functions which only raise exceptions 
+    if isinstance(stmt, ast.Raise):
+        return 1
+    # functions which do nothing 
+    if len(stmts) == 1 and isinstance(stmt, ast.Pass):
+        return 1
+    # functions which just return a constant 
+    if len(stmts) == 1 and \
+       isinstance(stmt, ast.Return) and isinstance(stmt.value, ast.Const):
+        return 1
+    # functions which only assert falsehood 
+    if isinstance(stmt, ast.Assert):
+        if (isinstance(stmt.test, ast.Const) and not stmt.test.value) or \
+            (isinstance(stmt.test, ast.Name) and stmt.test.name == 'None'):
+            return 1
+    return 0
+
+class UnusedCheck(Check):
+    """Use symbol information to check that no scope defines a name
+    not used in this or any child scope"""
+
+    unused = Warning('Report names not used', 'Identifier (%s) not used')
+
+    def __init__(self):
+        self.reportUnusedSelf = None
+        self.unusedPrefixes = None
+
+    def get_options(self, options):
+        desc = 'Ignore unused identifiers that start with these values'
+        default = ['unused', 'empty', 'dummy',
+                   '__pychecker__', '__all__', '__version__', 'ignored']
+        options.add(Opt(self, 'unusedPrefixes', desc, default))
+        
+        desc = 'Ignore unused method "self" parameter'
+        options.add(BoolOpt(self, 'reportUnusedSelf', desc))
+
+    def check(self, file, unused_checker):
+        self.unusedPrefixes = _str_value(self.unusedPrefixes)
+
+        def used(name, parent_scope):
+            if parent_scope.uses.has_key(name):
+                return 1
+            for c in parent_scope.get_children():
+                if used(name, c):
+                    return 1
+            return 0
+
+        for nodes, scope in file.not_class_scopes():
+            if isinstance(nodes, ast.Function):
+                if _empty_function(nodes.code.nodes):
+                    continue
+            
+            # ensure that every defined variable is used in some scope
+            for var in scope.defs:
+                # ignore '_'... just because
+                if var == '_':
+                    continue
+
+                # check for method self
+                if not self.reportUnusedSelf and _is_self(scope, var):
+                    continue
+
+                # ignore names in the root scope which are not imported:
+                # class defs, function defs, variables, etc, unless
+                # they start with '_'
+                if scope == file.root_scope:
+                    if not scope.imports.has_key(var):
+                        if not var.startswith('_'):
+                            continue
+
+                for prefix in self.unusedPrefixes:
+                    if var.startswith(prefix):
+                        break
+                else:
+                    if not used(var, scope) and not scope.globals.has_key(var):
+                        file.warning(scope.defs[var], self.unused, var)
+
+def _importedName(scope, name):
+    if scope.imports.has_key(name):
+        return 1
+    if scope.parent:
+        return _importedName(scope.parent, name)
+    return None
+
+class UnknownCheck(Check):
+    """Use symbol information to check that no scope uses a name
+    not defined in a parent scope"""
+
+    unknown = Warning('Report names that are not defined',
+                      'Unknown identifier: %s')
+
+    builtins = {}
+    builtins.update(__builtins__)
+    builtins['__builtins__'] = __builtins__
+    builtins['WindowsError'] = getattr(__builtins__, 'WindowsError', None)
+
+    def check(self, file, unused_checker):
+
+        # if a name used is not found in the defined variables, complain
+        for scope in file.scopes.values():
+            unknown = dict_minus(scope.uses, scope.defs)
+            unknown = dict_minus(unknown, self.builtins)
+            for var in unknown:
+                for p in parents(scope):
+                    if p.defs.has_key(var):
+                        break
+                else:
+                    if not _importedName(scope, var):
+                        file.warning(scope.uses[var], self.unknown, var)
+
+def _first_arg_defaulted(function_node):
+    count = len(function_node.argnames)
+    if function_node.varargs:
+        count -= 1
+    if function_node.kwargs:
+        count -= 1
+    if count > 0 and len(function_node.defaults) == count:
+        return 1
+    return None
+
+class SelfCheck(Check):
+    'Check for simple self parameter'
+    
+    selfName = Warning('Report any methods whose first argument is not self',
+                       'First argument to method %s (%s) is not in %s')
+    selfDefault = Warning('Report a self parameter with a default value',
+                          'First argument to method %s (%s) has a default value')
+    
+    functionSelf = Warning('Report functions (not methods) with '
+                           'arguments named "self"',
+                           'Argument to function (%s) is "%s"')
+    
+    missingSelf = Warning('Report methods without "self"',
+                          'Method %s is missing self parameter')
+    
+    def get_options(self, options):
+        desc = 'Name of self parameter'
+        default = ["self", "this", "s"]
+        options.add(Opt(self, 'selfNames', desc, default))
+
+        desc = 'Suspicious self parameters'
+        self.selfSuspicious = ["self"]
+        options.add(Opt(self, 'selfSuspicious', desc, self.selfSuspicious))
+
+    def check(self, file, unused_checker):
+        self.selfNames      = _str_value(self.selfNames)
+        self.selfSuspicious = _str_value(self.selfSuspicious)
+
+        for node, scope in file.function_scopes():
+            args = node.argnames
+            name = getattr(scope.node, 'name', 'lambda')
+            if _is_method(scope):
+                if not args:
+                    file.warning(scope.node, self.missingSelf, name)
+                else:
+                    if args[0] not in self.selfNames:
+                        file.warning(scope.node, self.selfName,
+                                     name, args[0], `self.selfNames`)
+                    if _first_arg_defaulted(scope.node):
+                        file.warning(scope.node, self.selfDefault,
+                                     name, args[0])
+            else:
+                for arg in args:
+                    if arg in self.selfSuspicious:
+                        file.warning(scope.defs[arg], self.functionSelf,
+                                     name, arg)
+
+                
+
+class UnpackCheck(Check):
+    'Mark all unpacked variables as used'
+
+    def __init__(self):
+        self.unpackedUsed = None
+
+    def get_options(self, options):
+        desc = 'Do not treat variables used in tuple assignment as used'
+        options.add(BoolOpt(self, 'unpackedUsed', desc, 1))
+
+    def check(self, file, unused_checker):
+        if not self.unpackedUsed:
+            return
+
+        class Visitor:
+            def visitAssTuple(self, node):
+                for c in node.getChildNodes():
+                    for n in parents(c):
+                        try:
+                            file.scopes[n].uses[c.name] = node
+                            break
+                        except (KeyError, AttributeError):
+                            pass
+            visitAssList = visitAssTuple
+
+        # local args unpacked on the `def' line are used, too
+        for scope_node, scope in file.function_scopes():
+            for arg in type_filter(scope_node.argnames, tuple):
+                for unpacked in ast.flatten(arg):
+                    scope.uses[unpacked] = scope.uses.get(unpacked, scope_node)
+
+        if file.root_scope:
+            walk(file.root_scope.node, Visitor())
+
+def intersect2(a, b):
+    return [i for i in a if i in b]
+
+def intersect(items):
+    result = items[0]
+    for item in items[1:]:
+        result = intersect2(result, item)
+    return result
+
+class UsedBeforeSetCheck(Check):
+
+    usedBeforeDefined = \
+          Warning('Report variables that may be used before they are defined',
+                  'The local %s may be used before defined')
+
+    def check(self, file, unused_checker):
+        class Visitor(BaseVisitor):
+            def __init__(self, defines = None, uses = None):
+                # list of vars defined
+                self.defines = []
+                # name->node vars used before defined                    
+                self.uses = {}
+                if defines is not None:
+                    self.defines = defines[:]
+                if uses is not None:
+                    self.uses = uses.copy()
+            def visitFunction(self, n):
+                self.defines.append(n.name)
+                
+            visitClass = visitFunction
+            visitAssName = visitFunction
+
+            def visitGlobal(self, node):
+                for name in node.names:
+                    self.defines.append(name)
+            
+            def visitListComp(self, n):
+                # visit qualifiers before expression
+                children = ast.flatten_nodes(n.quals) + [n.expr]
+                for c in children:
+                    self.visit(c)
+            
+            def visitName(self, n):
+                if n.name not in self.defines:
+                    self.uses[n.name] = self.uses.get(n.name, n)
+
+            def visitIf(self, n):
+                if not n.else_:
+                    return
+                visits = []
+                for test, code in n.tests:
+                    visits.append(walk(code, Visitor(self.defines, self.uses)))
+                visits.append(walk(n.else_, Visitor(self.defines, self.uses)))
+                # compute the intersection of defines
+                self.defines = intersect([v.defines for v in visits])
+                # compute the union of uses, perserving first occurances
+                union = {}
+                visits.reverse()
+                for v in visits:
+                    union.update(v.uses)
+                union.update(self.uses)
+                self.uses = union
+                        
+        for node, scope in file.function_scopes():
+            predefined = ast.flatten(scope.params) + scope.imports.keys()
+            visitor = walk(node.code, Visitor(predefined))
+            usedBefore = dict_intersect(visitor.uses, scope.defs)
+            for name, use_node in usedBefore.items():
+                file.warning(use_node, self.usedBeforeDefined, name)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/Warning.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/Warning.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/Warning.py
new file mode 100644
index 0000000..be01283
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/Warning.py
@@ -0,0 +1,13 @@
+
+class Warning:
+
+    def __init__(self, description, message, value = 1):
+        self.message = message
+        self.description = description
+        self.value = value
+        
+    def __cmp__(self, other):
+        return cmp(self.message, other.message)
+
+    def __repr__(self):
+        return repr(self.message)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/__init__.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/__init__.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/__init__.py
new file mode 100644
index 0000000..e16c76d
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/__init__.py
@@ -0,0 +1 @@
+""

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/main.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/main.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/main.py
new file mode 100644
index 0000000..40b1a9e
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/main.py
@@ -0,0 +1,115 @@
+import sys
+from os.path import dirname, realpath
+sys.path.append(dirname(dirname(realpath(sys.argv[0]))))
+
+from pychecker2.Check import CheckList
+
+from pychecker2 import Options
+from pychecker2 import ParseChecks
+from pychecker2 import OpChecks
+from pychecker2 import VariableChecks
+from pychecker2 import ScopeChecks
+from pychecker2 import ImportChecks
+from pychecker2 import ClassChecks
+from pychecker2 import ReachableChecks
+from pychecker2 import ReturnChecks
+from pychecker2 import ConditionalChecks
+from pychecker2 import FormatStringChecks
+
+CACHE_FILE = '/tmp/t'
+
+def print_warnings(f, out):
+    if not f.warnings:
+        return 0
+    f.warnings.sort()
+    last_line = -1
+    last_msg = None
+    for line, warning, args in f.warnings:
+        if warning.value:
+            msg = warning.message % args
+            if msg != last_msg or line != last_line:
+                print >>out, \
+                      '%s:%s %s' % (f.name, line or '[unknown line]', msg)
+                last_msg, last_line = msg, line
+    if last_msg:
+        print >>out
+    return 1
+
+def create_checklist(options):
+
+    checks = [ ParseChecks.ParseCheck(),
+               OpChecks.OpCheck(),
+               OpChecks.ExceptCheck(),
+               OpChecks.CompareCheck(),
+               ReachableChecks.ReachableCheck(),
+               ConditionalChecks.ConstantCheck(),
+               ClassChecks.ReprCheck(),
+               ImportChecks.ImportCheck(),
+               FormatStringChecks.FormatStringCheck(),
+               VariableChecks.ShadowCheck(),
+               VariableChecks.UnpackCheck(),
+               VariableChecks.UnusedCheck(),
+               VariableChecks.UnknownCheck(),
+               VariableChecks.SelfCheck(),
+               VariableChecks.UsedBeforeSetCheck(),
+               ReturnChecks.MixedReturnCheck(),
+               ClassChecks.AttributeCheck(),
+               ClassChecks.SpecialCheck(),
+               ClassChecks.InitCheck(),
+               ScopeChecks.RedefineCheck(),
+               ]
+    for checker in checks:
+        checker.get_warnings(options)
+        checker.get_options(options)
+    return CheckList(checks)
+
+def main():
+    import cPickle
+    
+    options = Options.Options()
+    try:
+        checker = cPickle.load(open(CACHE_FILE, 'rb'))
+    except (EOFError, IOError):
+        checker = create_checklist(options)
+
+    try:
+        files = options.process_options(sys.argv[1:])
+    except Options.Error, detail:
+        print >> sys.stderr, "Error: %s" % detail
+        options.usage(sys.argv[0], sys.stderr)
+        return 1
+
+    for f in files:
+        checker.check_file(f)
+        if options.incremental and not options.profile:
+            print_warnings(f, sys.stdout)
+
+    result = 0
+    if not options.incremental and not options.profile:
+        files.sort()
+        for f in files:
+            result |=  print_warnings(f, sys.stdout)
+
+        if not result and options.verbose:
+            print >>sys.stdout, None
+
+    fp = open(CACHE_FILE, 'wb')
+    cPickle.dump(checker, fp, 1)
+    fp.close()
+
+    return result
+
+if __name__ == "__main__":
+    if '--profile' in sys.argv:
+        print 'profiling'
+        import hotshot.stats
+        import time
+        hs = hotshot.Profile('logfile.dat')
+        now = time.time()
+        hs.run('main()')
+        print 'total run time', time.time() - now
+        hs.close()
+        stats = hotshot.stats.load('logfile.dat')
+        stats.sort_stats('time', 'cum').print_stats(50)
+    else:
+        sys.exit(main())

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/scripts/check.sh
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/scripts/check.sh b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/scripts/check.sh
new file mode 100755
index 0000000..9d6e2ee
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/scripts/check.sh
@@ -0,0 +1,4 @@
+#! /bin/sh
+PYTHONPATH=$PYTHONPATH:.. pychecker --stdlib *.py
+echo ==============================================================
+scripts/pychecker2.sh $* *.py

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/scripts/clean.sh
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/scripts/clean.sh b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/scripts/clean.sh
new file mode 100755
index 0000000..f290884
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/scripts/clean.sh
@@ -0,0 +1,5 @@
+#! /bin/sh
+for i in `find . -type d -print`
+do
+    /bin/rm -f *.pyc *.pyo *~ 
+done

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/scripts/lib.sh
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/scripts/lib.sh b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/scripts/lib.sh
new file mode 100755
index 0000000..efde8fd
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/scripts/lib.sh
@@ -0,0 +1,2 @@
+#! /bin/sh
+scripts/pychecker2.sh --incremental --no-importError --no-unused --no-shadowIdentifier --no-shadowImport --no-emptyExcept --no-attributeInitialized /usr/local/lib/python2.2/*.py

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/scripts/pychecker2.sh
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/scripts/pychecker2.sh b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/scripts/pychecker2.sh
new file mode 100755
index 0000000..f830212
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/scripts/pychecker2.sh
@@ -0,0 +1,6 @@
+#! /bin/sh
+NAME=$0				# this script
+NAME=`dirname $NAME`		# trim scripts 
+NAME=$NAME/../..
+export PYTHONPATH=$PYTHONPATH:$NAME
+exec python2.2 $NAME/pychecker2/main.py $@

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/symbols.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/symbols.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/symbols.py
new file mode 100644
index 0000000..3f70e97
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/symbols.py
@@ -0,0 +1,372 @@
+#######################################################################
+#
+# THIS FILE IS __NOT__ under the pychecker copyright.
+#
+# The majority of this file is from the python2.2 distribution.
+# It is under the python2.2 copyright.
+#
+#######################################################################
+
+"""Module symbol-table generator"""
+
+from compiler import ast
+from compiler.consts import SC_LOCAL, SC_GLOBAL, SC_FREE, SC_CELL, SC_UNKNOWN
+from compiler.misc import mangle
+import types
+
+import sys
+
+MANGLE_LEN = 256
+
+class Scope:
+    # XXX how much information do I need about each name?
+    def __init__(self, name, module, klass=None):
+        self.name = name
+        self.module = module
+        self.defs = {}
+        self.uses = {}
+        self.globals = {}
+        self.params = {}
+        self.frees = {}
+        self.cells = {}
+        self.children = []
+        # nested is true if the class could contain free variables,
+        # i.e. if it is nested within another function.
+        self.nested = None
+        self.generator = None
+        self.klass = None
+        if klass is not None:
+            for i in range(len(klass)):
+                if klass[i] != '_':
+                    self.klass = klass[i:]
+                    break
+
+    def __repr__(self):
+        return "<%s: %s>" % (self.__class__.__name__, self.name)
+
+    def mangle(self, name):
+        if self.klass is None:
+            return name
+        return mangle(name, self.klass)
+
+    def add_def(self, name, node):
+        self.defs[self.mangle(name)] = node
+
+    def add_use(self, name, node):
+        name = self.mangle(name)
+        self.uses[name] = self.uses.get(name, node)
+
+    def add_global(self, name, node):
+        name = self.mangle(name)
+        if self.uses.has_key(name) or self.defs.has_key(name):
+            pass # XXX warn about global following def/use
+        if self.params.has_key(name):
+            raise SyntaxError, "%s in %s is global and parameter" % \
+                  (name, self.name)
+        self.globals[name] = None
+        self.module.add_def(name, node)
+
+    def add_param(self, name, node):
+        name = self.mangle(name)
+        self.defs[name] = node
+        self.params[name] = node
+
+    def get_names(self):
+        d = {}
+        d.update(self.defs)
+        d.update(self.uses)
+        d.update(self.globals)
+        return d.keys()
+
+    def add_child(self, child):
+        self.children.append(child)
+
+    def get_children(self):
+        return self.children
+
+    def DEBUG(self):
+        print >> sys.stderr, self.name, self.nested and "nested" or ""
+        print >> sys.stderr, "\tglobals: ", self.globals
+        print >> sys.stderr, "\tcells: ", self.cells
+        print >> sys.stderr, "\tdefs: ", self.defs
+        print >> sys.stderr, "\tuses: ", self.uses
+        print >> sys.stderr, "\tfrees:", self.frees
+
+    def check_name(self, name):
+        """Return scope of name.
+
+        The scope of a name could be LOCAL, GLOBAL, FREE, or CELL.
+        """
+        if self.globals.has_key(name):
+            return SC_GLOBAL
+        if self.cells.has_key(name):
+            return SC_CELL
+        if self.defs.has_key(name):
+            return SC_LOCAL
+        if self.nested and (self.frees.has_key(name) or
+                            self.uses.has_key(name)):
+            return SC_FREE
+        if self.nested:
+            return SC_UNKNOWN
+        else:
+            return SC_GLOBAL
+
+    def get_free_vars(self):
+        if not self.nested:
+            return {}
+        free = {}
+        free.update(self.frees)
+        for name in self.uses.keys():
+            if not (self.defs.has_key(name) or
+                    self.globals.has_key(name)):
+                free[name] = self.uses[name]
+        return free
+
+    def handle_children(self):
+        for child in self.children:
+            frees = child.get_free_vars()
+            globals = self.add_frees(frees)
+            for name, node in globals.items():
+                child.force_global(name, node)
+
+    def force_global(self, name, node):
+        """Force name to be global in scope.
+
+        Some child of the current node had a free reference to name.
+        When the child was processed, it was labelled a free
+        variable.  Now that all its enclosing scope have been
+        processed, the name is known to be a global or builtin.  So
+        walk back down the child chain and set the name to be global
+        rather than free.
+
+        Be careful to stop if a child does not think the name is
+        free.
+        """
+        self.globals[name] = node
+        if self.frees.has_key(name):
+            del self.frees[name]
+        for child in self.children:
+            if child.check_name(name) == SC_FREE:
+                child.force_global(name, node)
+
+    def add_frees(self, names):
+        """Process list of free vars from nested scope.
+
+        Returns a list of names that are either 1) declared global in the
+        parent or 2) undefined in a top-level parent.  In either case,
+        the nested scope should treat them as globals.
+        """
+        child_globals = {}
+        for name, node in names.items():
+            sc = self.check_name(name)
+            if self.nested:
+                if sc == SC_UNKNOWN or sc == SC_FREE \
+                   or isinstance(self, ClassScope):
+                    self.frees[name] = node
+                elif sc == SC_GLOBAL:
+                    child_globals[name] = node
+                elif isinstance(self, FunctionScope) and sc == SC_LOCAL:
+                    self.cells[name] = node
+                elif sc != SC_CELL:
+                    child_globals[name] = node
+            else:
+                if sc == SC_LOCAL:
+                    self.cells[name] = node
+                elif sc != SC_CELL:
+                    child_globals[name] = node
+        return child_globals
+
+    def get_cell_vars(self):
+        return self.cells.keys()
+
+class ModuleScope(Scope):
+    __super_init = Scope.__init__
+
+    def __init__(self):
+        self.__super_init("global", self)
+
+class FunctionScope(Scope):
+    pass
+
+class LambdaScope(FunctionScope):
+    __super_init = FunctionScope.__init__
+
+    __counter = 1
+
+    def __init__(self, module, klass=None):
+        i = self.__counter
+        self.__counter += 1
+        self.__super_init("lambda.%d" % i, module, klass)
+
+class ClassScope(Scope):
+    __super_init = Scope.__init__
+
+    def __init__(self, name, module):
+        self.__super_init(name, module, name)
+
+class SymbolVisitor:
+    def __init__(self):
+        self.scopes = {}
+        self.klass = None
+
+    # node that define new scopes
+    def visit(self, unused_node, *args):
+        "overwritten by compiler.walk"
+        pass
+
+    def visitModule(self, node):
+        scope = self.module = self.scopes[node] = ModuleScope()
+        self.visit(node.node, scope)
+
+    visitExpression = visitModule
+
+    def visitFunction(self, node, parent):
+        parent.add_def(node.name, node)
+        for n in node.defaults:
+            self.visit(n, parent)
+        scope = FunctionScope(node.name, self.module, self.klass)
+        if parent.nested or isinstance(parent, FunctionScope):
+            scope.nested = 1
+        self.scopes[node] = scope
+        self._do_args(scope, node.argnames, node)
+        self.visit(node.code, scope)
+        self.handle_free_vars(scope, parent)
+
+    def visitLambda(self, node, parent):
+        for n in node.defaults:
+            self.visit(n, parent)
+        scope = LambdaScope(self.module, self.klass)
+        if parent.nested or isinstance(parent, FunctionScope):
+            scope.nested = 1
+        self.scopes[node] = scope
+        self._do_args(scope, node.argnames, node)
+        self.visit(node.code, scope)
+        self.handle_free_vars(scope, parent)
+
+    def _do_args(self, scope, args, node):
+        for name in args:
+            if type(name) == types.TupleType:
+                self._do_args(scope, name, node)
+            else:
+                scope.add_param(name, node)
+
+    def handle_free_vars(self, scope, parent):
+        parent.add_child(scope)
+        scope.handle_children()
+
+    def visitClass(self, node, parent):
+        parent.add_def(node.name, node)
+        for n in node.bases:
+            self.visit(n, parent)
+        scope = ClassScope(node.name, self.module)
+        if parent.nested or isinstance(parent, FunctionScope):
+            scope.nested = 1
+        self.scopes[node] = scope
+        prev = self.klass
+        self.klass = node.name
+        self.visit(node.code, scope)
+        self.klass = prev
+        self.handle_free_vars(scope, parent)
+
+    # name can be a def or a use
+
+    # XXX a few calls and nodes expect a third "assign" arg that is
+    # true if the name is being used as an assignment.  only
+    # expressions contained within statements may have the assign arg.
+
+    def visitName(self, node, scope, assign=0):
+        if assign:
+            scope.add_def(node.name, node)
+        else:
+            scope.add_use(node.name, node)
+
+    # operations that bind new names
+
+    def visitFor(self, node, scope):
+        self.visit(node.assign, scope, 1)
+        self.visit(node.list, scope)
+        self.visit(node.body, scope)
+        if node.else_:
+            self.visit(node.else_, scope)
+
+    def visitFrom(self, node, scope):
+        for name, asname in node.names:
+            if name == "*":
+                continue
+            scope.add_def(asname or name, node)
+
+    def visitImport(self, node, scope):
+        for name, asname in node.names:
+            i = name.find(".")
+            if i > -1:
+                name = name[:i]
+            scope.add_def(asname or name, node)
+
+    def visitGlobal(self, node, scope):
+        for name in node.names:
+            scope.add_global(name, node)
+
+    def visitAssign(self, node, scope):
+        """Propagate assignment flag down to child nodes.
+
+        The Assign node doesn't itself contains the variables being
+        assigned to.  Instead, the children in node.nodes are visited
+        with the assign flag set to true.  When the names occur in
+        those nodes, they are marked as defs.
+
+        Some names that occur in an assignment target are not bound by
+        the assignment, e.g. a name occurring inside a slice.  The
+        visitor handles these nodes specially; they do not propagate
+        the assign flag to their children.
+        """
+        for n in node.nodes:
+            self.visit(n, scope, 1)
+        self.visit(node.expr, scope)
+
+    def visitAssName(self, node, scope, unused_assign=1):
+        scope.add_def(node.name, node)
+
+    def visitAssAttr(self, node, scope, unused_assign=0):
+        self.visit(node.expr, scope, 0)
+
+    def visitSubscript(self, node, scope, unused_assign=0):
+        self.visit(node.expr, scope, 0)
+        for n in node.subs:
+            self.visit(n, scope, 0)
+
+    def visitSlice(self, node, scope, unused_assign=0):
+        self.visit(node.expr, scope, 0)
+        if node.lower:
+            self.visit(node.lower, scope, 0)
+        if node.upper:
+            self.visit(node.upper, scope, 0)
+
+    def visitAugAssign(self, node, scope):
+        # If the LHS is a name, then this counts as assignment.
+        # Otherwise, it's just use.
+        self.visit(node.node, scope)
+        if isinstance(node.node, ast.Name):
+            self.visit(node.node, scope, 1) # XXX worry about this
+        self.visit(node.expr, scope)
+
+    # prune if statements if tests are false
+
+    _const_types = types.StringType, types.IntType, types.FloatType
+
+    def visitIf(self, node, scope):
+        for test, body in node.tests:
+            if isinstance(test, ast.Const):
+                if type(test.value) in self._const_types:
+                    if not test.value:
+                        continue
+            self.visit(test, scope)
+            self.visit(body, scope)
+        if node.else_:
+            self.visit(node.else_, scope)
+
+    # a yield statement signals a generator
+
+    def visitYield(self, node, scope):
+        scope.generator = 1
+        self.visit(node.value, scope)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/test.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/test.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/test.py
new file mode 100644
index 0000000..945c583
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/test.py
@@ -0,0 +1,55 @@
+import os
+import sys
+import unittest
+import glob
+
+def test(modules, verbosity):
+    for m in modules:
+        s = unittest.defaultTestLoader.loadTestsFromName(m)
+        result = unittest.TextTestRunner(verbosity=verbosity).run(s)
+        if not result.wasSuccessful():
+            return 1
+    return 0
+
+
+def _modules(root):
+    modules = []
+    files = glob.glob(os.path.join(root, 'utest', '*.py'))
+    files.sort()
+    for fname in files:
+        fname = os.path.split(fname)[1] # remove path
+        module = 'pychecker2.utest.' + os.path.splitext(fname)[0]
+        if not module.endswith('_'):    # ignore __init__
+            modules.append(module)
+    return modules
+
+class Usage(Exception): pass
+
+def main(args):
+    import getopt
+    verbosity = 1
+    try:
+        opts, files = getopt.getopt(args, 'v')
+        for opt, arg in opts:
+            if opt == '-v':
+                verbosity += 1
+            else:
+                raise Usage('unknown option ' + opt)
+    except getopt.GetoptError, detail:
+        raise Usage(str(detail))
+
+    root = os.path.dirname(os.path.realpath(sys.argv[0]))
+    pychecker2 = os.path.split(root)[0]
+    sys.path.append(pychecker2)
+
+    return test(_modules(root), verbosity)
+        
+
+if __name__ == '__main__':
+    try:
+        sys.exit(main(sys.argv[1:]))
+    except Usage, error:
+        err = sys.stderr
+        print >>err, "Error: " + str(error)
+        print >>err, "Usage: %s [-v]" % sys.argv[0]
+        sys.exit(1)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/__init__.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/__init__.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/__init__.py
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/badparse.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/badparse.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/badparse.py
new file mode 100644
index 0000000..4b19a81
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/badparse.py
@@ -0,0 +1 @@
+===

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/class.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/class.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/class.py
new file mode 100644
index 0000000..1a2adb0
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/class.py
@@ -0,0 +1,152 @@
+import compiler
+import compiler                   as one
+import compiler.ast              
+import compiler.ast               as two
+from   compiler import ast       
+from   compiler import ast        as three
+from   compiler.ast import Const 
+from   compiler.ast import Const  as four
+
+func = lambda x: x
+
+class D:
+    class B(compiler.ast.Const):
+        inherited2 = 1
+        def x(self):
+            self.inherited1 = 1
+
+class A(D.B):
+    def __init__(self):
+        self.x = 1                      # define x on A
+        self.w.q = 1
+
+    def f(s, self):                     # unusual self
+        print self
+        s.self = 1
+        s = 7
+
+    def x():                            # no self, redefine x on object
+        pass
+
+    def y(self):
+        self.a, self.b = (1, 2)         # define a, b
+
+    def _z(self):
+        print self._z                   # method
+        print self.x                    # assigned
+        print self.a                    # unpacked
+        print self.w                    # unknown
+        print self.inherited1           # known from B
+        print self.inherited2           # known from B
+        print self.value                # from compiler.ast.Const, fails
+        print self.goofy                # defined in class scope
+
+    goofy = x
+    
+class E(one.ast.Const):
+    def f(self):
+        print self.value
+
+class F(two.Const):
+    def f(self):
+        print self.value
+
+class H(three.Const):
+    def f(self):
+        print self.value
+
+class I(four):
+    def f(self):
+        print self.value
+
+class J(ast.Const):
+    def f(self):
+        print self.value
+
+class K(Const):
+    def f(self):
+        print self.value
+
+#
+# Various abusive imports, all under a non-global scope
+#
+
+def z(arg):
+    from xml.dom import minidom as md
+
+    class L(md.Node):
+        def f(self):
+            print arg, self.childNodes
+    print L()
+
+def zz(arg):
+    from xml import dom as d
+
+    class L(d.minidom.Node):
+        def f(self):
+            print arg, self.childNodes  # should fail
+    print L()
+
+def zzz(arg):
+    from xml.dom.minidom import Node as X
+
+    class L(X):
+        def f(self):
+            print arg, self.childNodes
+    print L()
+
+def zzzz(arg):
+    from tests import nested
+
+    class L(nested.N1.N2):
+        def f(self):
+            print self.x
+    print L(), arg
+
+class Base:
+   def f(self, x): pass
+class Derived(Base):
+   def f(self): pass
+
+class Node(compiler.ast.Node):
+    def getChildren(self, x):
+        return x
+
+class Node2(compiler.ast.Slice):
+    def __init__(self):
+        return self
+
+class BadSpecial:
+
+    def __del__(self):
+        return 0
+
+    def __cmp__(self, x):
+        return x
+
+    def __len__(self):
+        return 0
+
+    def __le__(self):
+        return 0
+
+    def __gt__(self, a, b):
+        return 0
+
+    def __ge__(self, a, b = None, c = None):
+        return 0
+
+    def __setattr__(self, a = None):
+        return 0
+
+    def __not_special__(self):
+        return 0
+    
+class Z1:
+    class Z2:
+        from xml.dom import minidom as md
+
+class Z3(Z1.Z2.md.Node):
+    def f(self):
+        print self.childNodes
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/except.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/except.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/except.py
new file mode 100644
index 0000000..0a64ca5
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/except.py
@@ -0,0 +1,11 @@
+
+try:
+    pass
+except AttributeError:
+    pass
+
+try:
+    pass
+except:
+    pass
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/incremental
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/incremental b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/incremental
new file mode 100644
index 0000000..370ecb0
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/incremental
@@ -0,0 +1,49 @@
+tests/badparse.py:1 Unable to parse: could not parse string
+
+tests/class.py:20 Method x defined at line 28 in class A redefined
+tests/class.py:21 Class A has no attribute w
+tests/class.py:28 Method x is missing self parameter
+tests/class.py:38 Class A has no attribute w
+
+tests/global.py:3 Unknown identifier: y
+
+tests/import.py:1 Identifier (bar) not used
+tests/import.py:3 Identifier (nifty) not used
+tests/import.py:7 Import of "join" is duplicate of import in parent scope <ModuleScope: global>
+tests/import.py:9 Unknown identifier: __all__
+tests/import.py:13 Error trying to import xYzZy: No module named xYzZy
+tests/import.py:14 Unknown identifier: z
+tests/import.py:17 Identifier (getopt) not used
+tests/import.py:17 Import of "getopt" is duplicate in current scope
+tests/import.py:18 Import of "join" duplicates import from module posixpath at 4
+tests/import.py:18 Import of "split" duplicates import from module posixpath at 4
+
+tests/op.py:2 Operator (++) doesn't exist, statement has no effect
+tests/op.py:4 Scope (g) is redefined at line 7
+tests/op.py:5 Operator (+) normally has no effect
+tests/op.py:8 Operator (--) doesn't exist, statement has no effect
+
+tests/self.py:9 First argument to method f (x) is not in ['self', 'this', 's']
+tests/self.py:14 Identifier (a) not used
+
+tests/shadow.py:2 Scope (f) is redefined at line 8
+tests/shadow.py:4 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:15 Identifier (a) not used
+tests/shadow.py:15 Identifier (b) not used
+tests/shadow.py:15 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:16 Identifier (f) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:17 Identifier (a) not used
+tests/shadow.py:17 Identifier (a) shadows definition in scope <FunctionScope: g>
+tests/shadow.py:17 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:18 Identifier (b) not used
+tests/shadow.py:18 Identifier (b) shadows definition in scope <FunctionScope: g>
+tests/shadow.py:19 Unknown identifier: c
+tests/shadow.py:19 Unknown identifier: d
+tests/shadow.py:22 Identifier (a) shadows definition in scope <ModuleScope: global>
+
+tests/unusedImport.py:1 Identifier (sys) not used
+
+tests/unused.py:6 Identifier (Test) not used
+
+tests/not_there.py:[unknown line] Unable to parse: [Errno 2] No such file or directory: 'tests/not_there.py'
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-importError
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-importError b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-importError
new file mode 100644
index 0000000..9289799
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-importError
@@ -0,0 +1,48 @@
+tests/badparse.py:1 Unable to parse: could not parse string
+
+tests/class.py:20 Method x defined at line 28 in class A redefined
+tests/class.py:21 Class A has no attribute w
+tests/class.py:28 Method x is missing self parameter
+tests/class.py:38 Class A has no attribute w
+
+tests/global.py:3 Unknown identifier: y
+
+tests/import.py:1 Identifier (bar) not used
+tests/import.py:3 Identifier (nifty) not used
+tests/import.py:7 Import of "join" is duplicate of import in parent scope <ModuleScope: global>
+tests/import.py:9 Unknown identifier: __all__
+tests/import.py:14 Unknown identifier: z
+tests/import.py:17 Identifier (getopt) not used
+tests/import.py:17 Import of "getopt" is duplicate in current scope
+tests/import.py:18 Import of "join" duplicates import from module posixpath at 4
+tests/import.py:18 Import of "split" duplicates import from module posixpath at 4
+
+tests/not_there.py:[unknown line] Unable to parse: [Errno 2] No such file or directory: 'tests/not_there.py'
+
+tests/op.py:2 Operator (++) doesn't exist, statement has no effect
+tests/op.py:4 Scope (g) is redefined at line 7
+tests/op.py:5 Operator (+) normally has no effect
+tests/op.py:8 Operator (--) doesn't exist, statement has no effect
+
+tests/self.py:9 First argument to method f (x) is not in ['self', 'this', 's']
+tests/self.py:14 Identifier (a) not used
+
+tests/shadow.py:2 Scope (f) is redefined at line 8
+tests/shadow.py:4 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:15 Identifier (a) not used
+tests/shadow.py:15 Identifier (b) not used
+tests/shadow.py:15 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:16 Identifier (f) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:17 Identifier (a) not used
+tests/shadow.py:17 Identifier (a) shadows definition in scope <FunctionScope: g>
+tests/shadow.py:17 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:18 Identifier (b) not used
+tests/shadow.py:18 Identifier (b) shadows definition in scope <FunctionScope: g>
+tests/shadow.py:19 Unknown identifier: c
+tests/shadow.py:19 Unknown identifier: d
+tests/shadow.py:22 Identifier (a) shadows definition in scope <ModuleScope: global>
+
+tests/unused.py:6 Identifier (Test) not used
+
+tests/unusedImport.py:1 Identifier (sys) not used
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-operator
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-operator b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-operator
new file mode 100644
index 0000000..78fab6c
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker2/tests/expected/no-operator
@@ -0,0 +1,47 @@
+tests/badparse.py:1 Unable to parse: could not parse string
+
+tests/class.py:20 Method x defined at line 28 in class A redefined
+tests/class.py:21 Class A has no attribute w
+tests/class.py:28 Method x is missing self parameter
+tests/class.py:38 Class A has no attribute w
+
+tests/global.py:3 Unknown identifier: y
+
+tests/import.py:1 Identifier (bar) not used
+tests/import.py:3 Identifier (nifty) not used
+tests/import.py:7 Import of "join" is duplicate of import in parent scope <ModuleScope: global>
+tests/import.py:9 Unknown identifier: __all__
+tests/import.py:13 Error trying to import xYzZy: No module named xYzZy
+tests/import.py:14 Unknown identifier: z
+tests/import.py:17 Identifier (getopt) not used
+tests/import.py:17 Import of "getopt" is duplicate in current scope
+tests/import.py:18 Import of "join" duplicates import from module posixpath at 4
+tests/import.py:18 Import of "split" duplicates import from module posixpath at 4
+
+tests/not_there.py:[unknown line] Unable to parse: [Errno 2] No such file or directory: 'tests/not_there.py'
+
+tests/op.py:4 Scope (g) is redefined at line 7
+tests/op.py:5 Operator (+) normally has no effect
+
+tests/self.py:9 First argument to method f (x) is not in ['self', 'this', 's']
+tests/self.py:14 Identifier (a) not used
+
+tests/shadow.py:2 Scope (f) is redefined at line 8
+tests/shadow.py:4 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:15 Identifier (a) not used
+tests/shadow.py:15 Identifier (b) not used
+tests/shadow.py:15 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:16 Identifier (f) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:17 Identifier (a) not used
+tests/shadow.py:17 Identifier (a) shadows definition in scope <FunctionScope: g>
+tests/shadow.py:17 Identifier (a) shadows definition in scope <ModuleScope: global>
+tests/shadow.py:18 Identifier (b) not used
+tests/shadow.py:18 Identifier (b) shadows definition in scope <FunctionScope: g>
+tests/shadow.py:19 Unknown identifier: c
+tests/shadow.py:19 Unknown identifier: d
+tests/shadow.py:22 Identifier (a) shadows definition in scope <ModuleScope: global>
+
+tests/unused.py:6 Identifier (Test) not used
+
+tests/unusedImport.py:1 Identifier (sys) not used
+



[12/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code

Posted by rl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/Config.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/Config.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/Config.py
new file mode 100644
index 0000000..2021185
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/Config.py
@@ -0,0 +1,475 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2001-2004, MetaSlash Inc.  All rights reserved.
+# Portions Copyright (c) 2005, Google, Inc.  All rights reserved.
+
+"""
+Configuration information for checker.
+"""
+
+import sys
+import os
+import getopt
+import string
+import re
+import time
+
+def get_warning_levels():
+    import types
+    from pychecker import msgs
+    WarningClass = msgs.WarningClass
+
+    result = {}
+    for name in vars(msgs).keys():
+        obj = getattr(msgs, name)
+        if (obj is not WarningClass and
+            isinstance(obj, types.ClassType) and
+            issubclass(obj, WarningClass)):
+            result[name.capitalize()] = obj
+    return result
+
+_WARNING_LEVELS = get_warning_levels()
+
+_RC_FILE = ".pycheckrc"
+CHECKER_VAR = '__pychecker__'
+_VERSION = '0.8.18'
+
+_DEFAULT_BLACK_LIST = [ "Tkinter", "wxPython", "gtk", "GTK", "GDK", ]
+_DEFAULT_VARIABLE_IGNORE_LIST = [ '__version__', '__warningregistry__', 
+                                  '__all__', '__credits__', '__test__',
+                                  '__author__', '__email__', '__revision__',
+                                  '__id__', '__copyright__', '__license__',
+                                  '__date__',
+                                ]
+_DEFAULT_UNUSED_LIST = [ '_', 'empty', 'unused', 'dummy', ]
+_DEFAULT_MISSING_ATTRS_LIST = []
+
+# _OPTIONS = (
+#   (categoryName, [
+#     (shortArg, useValue, longArg, member, description),
+#     ...
+#    ]),
+#   ...
+# )
+_OPTIONS = (
+    ('Major Options', [
+ ('',  0, 'only', 'only', 'only warn about files passed on the command line'),
+ ('e', 1, 'level', None, 'the maximum error level of warnings to be displayed'),
+ ('#', 1, 'limit', 'limit', 'the maximum number of warnings to be displayed'),
+ ('F', 1, 'config', None, 'specify .pycheckrc file to use'),
+ ('',  0, 'quixote', None, 'support Quixote\'s PTL modules'),
+ ('',  1, 'evil', 'evil', 'list of evil C extensions that crash the interpreter'),
+ ('',  0, 'keepgoing', 'ignoreImportErrors', 'ignore import errors'),
+     ]),
+    ('Error Control', [
+ ('i', 0, 'import', 'importUsed', 'unused imports'),
+ ('k', 0, 'pkgimport', 'packageImportUsed', 'unused imports from __init__.py'),
+ ('M', 0, 'reimportself', 'reimportSelf', 'module imports itself'),
+ ('X', 0, 'reimport', 'moduleImportErrors', 'reimporting a module'),
+ ('x', 0, 'miximport', 'mixImport', 'module does import and from ... import'),
+ ('l', 0, 'local', 'localVariablesUsed', 'unused local variables, except tuples'),
+ ('t', 0, 'tuple', 'unusedLocalTuple', 'all unused local variables, including tuples'),
+ ('9', 0, 'members', 'membersUsed', 'all unused class data members'),
+ ('v', 0, 'var', 'allVariablesUsed', 'all unused module variables'),
+ ('p', 0, 'privatevar', 'privateVariableUsed', 'unused private module variables'),
+ ('g', 0, 'allglobals', 'reportAllGlobals', 'report each occurrence of global warnings'),
+ ('n', 0, 'namedargs', 'namedArgs', 'functions called with named arguments (like keywords)'),
+ ('a', 0, 'initattr', 'onlyCheckInitForMembers', 'Attributes (members) must be defined in __init__()'),
+ ('I', 0, 'initsubclass', 'initDefinedInSubclass', 'Subclass.__init__() not defined'),
+ ('u', 0, 'callinit', 'baseClassInitted', 'Baseclass.__init__() not called'),
+ ('0', 0, 'abstract', 'abstractClasses', 'Subclass needs to override methods that only throw exceptions'),
+ ('N', 0, 'initreturn', 'returnNoneFromInit', 'Return None from __init__()'),
+ ('8', 0, 'unreachable', 'unreachableCode', 'unreachable code'),
+ ('2', 0, 'constCond', 'constantConditions', 'a constant is used in a conditional statement'),
+ ('1', 0, 'constant1', 'constant1', '1 is used in a conditional statement (if 1: or while 1:)'),
+ ( '', 0, 'stringiter', 'stringIteration', 'check if iterating over a string'),
+ ( '', 0, 'stringfind', 'stringFind', 'check improper use of string.find()'),
+ ('A', 0, 'callattr', 'callingAttribute', 'Calling data members as functions'),
+ ('y', 0, 'classattr', 'classAttrExists', 'class attribute does not exist'),
+ ('S', 1, 'self', 'methodArgName', 'First argument to methods'),
+ ('',  1, 'classmethodargs', 'classmethodArgNames', 'First argument to classmethods'),
+ ('T', 0, 'argsused', 'argumentsUsed', 'unused method/function arguments'),
+ ('z', 0, 'varargsused', 'varArgumentsUsed', 'unused method/function variable arguments'),
+ ('G', 0, 'selfused', 'ignoreSelfUnused', 'ignore if self is unused in methods'),
+ ('o', 0, 'override', 'checkOverridenMethods', 'check if overridden methods have the same signature'),
+ ('',  0, 'special', 'checkSpecialMethods', 'check if __special__ methods exist and have the correct signature'),
+ ('U', 0, 'reuseattr', 'redefiningFunction', 'check if function/class/method names are reused'),
+ ('Y', 0, 'positive', 'unaryPositive', 'check if using unary positive (+) which is usually meaningless'),
+ ('j', 0, 'moddefvalue', 'modifyDefaultValue', 'check if modify (call method) on a parameter that has a default value'),
+ ( '', 0, 'changetypes', 'inconsistentTypes', 'check if variables are set to different types'),
+ ( '', 0, 'unpack', 'unpackNonSequence', 'check if unpacking a non-sequence'),
+ ( '', 0, 'unpacklen', 'unpackLength', 'check if unpacking sequence with the wrong length'),
+ ( '', 0, 'badexcept', 'badExceptions', 'check if raising or catching bad exceptions'),
+ ('4', 0, 'noeffect', 'noEffect', 'check if statement appears to have no effect'),
+ ('',  0, 'modulo1', 'modulo1', 'check if using (expr % 1), it has no effect on integers and strings'),
+ ('',  0, 'isliteral', 'isLiteral', "check if using (expr is const-literal), doesn't always work on integers and strings"),
+ ('',  0, 'constattr', 'constAttr', "check if a constant string is passed to getattr()/setattr()"),
+     ]),
+    ('Possible Errors', [
+ ('r', 0, 'returnvalues', 'checkReturnValues', 'check consistent return values'),
+ ('C', 0, 'implicitreturns', 'checkImplicitReturns', 'check if using implict and explicit return values'),
+ ('O', 0, 'objattrs', 'checkObjectAttrs', 'check that attributes of objects exist'),
+ ('7', 0, 'slots', 'slots', 'various warnings about incorrect usage of __slots__'),
+ ('3', 0, 'properties', 'classicProperties', 'using properties with classic classes'),
+ ( '', 0, 'emptyslots', 'emptySlots', 'check if __slots__ is empty'),
+ ('D', 0, 'intdivide', 'intDivide', 'check if using integer division'),
+ ('w', 0, 'shadow', 'shadows', 'check if local variable shadows a global'),
+ ('s', 0, 'shadowbuiltin', 'shadowBuiltins', 'check if a variable shadows a builtin'),
+     ]),
+    ('Security', [
+ ( '', 0, 'input', 'usesInput', 'check if input() is used'),
+ ('6', 0, 'exec', 'usesExec', 'check if the exec statement is used'),
+     ]),
+    ('Suppressions', [
+ ('q', 0, 'stdlib', 'ignoreStandardLibrary', 'ignore warnings from files under standard library'),
+ ('b', 1, 'blacklist', 'blacklist', 'ignore warnings from the list of modules\n\t\t\t'),
+ ('Z', 1, 'varlist', 'variablesToIgnore', 'ignore global variables not used if name is one of these values\n\t\t\t'),
+ ('E', 1, 'unusednames', 'unusedNames', 'ignore unused locals/arguments if name is one of these values\n\t\t\t'),
+ ('',  1, 'missingattrs', 'missingAttrs', 'ignore missing class attributes if name is one of these values\n\t\t\t'),
+ ( '', 0, 'deprecated', 'deprecated', 'ignore use of deprecated modules/functions'),
+     ]),
+    ('Complexity', [
+ ('L', 1, 'maxlines', 'maxLines', 'maximum lines in a function'),
+ ('B', 1, 'maxbranches', 'maxBranches', 'maximum branches in a function'),
+ ('R', 1, 'maxreturns', 'maxReturns', 'maximum returns in a function'),
+ ('J', 1, 'maxargs', 'maxArgs', 'maximum # of arguments to a function'),
+ ('K', 1, 'maxlocals', 'maxLocals', 'maximum # of locals in a function'),
+ ('5', 1, 'maxrefs', 'maxReferences', 'maximum # of identifier references (Law of Demeter)'),
+ ('m', 0, 'moduledoc', 'noDocModule', 'no module doc strings'),
+ ('c', 0, 'classdoc', 'noDocClass', 'no class doc strings'),
+ ('f', 0, 'funcdoc', 'noDocFunc', 'no function/method doc strings'),
+     ]),
+    ('Debug', [
+ ( '', 0, 'rcfile', None, 'print a .pycheckrc file generated from command line args'),
+ ('P', 0, 'printparse', 'printParse', 'print internal checker parse structures'),
+ ('d', 0, 'debug', 'debug', 'turn on debugging for checker'),
+ ('',  0, 'findevil', 'findEvil', 'print each class object to find one that crashes'),
+ ('Q', 0, 'quiet', 'quiet', 'turn off all output except warnings'),
+ ('V', 0, 'version', None, 'print the version of PyChecker and exit'),
+     ])
+)
+
+def init() :
+    GET_OPT_VALUE = (('', ''), (':', '='),)
+    shortArgs, longArgs = "", []
+    for _, group in _OPTIONS :
+        for opt in group:
+            optStr = GET_OPT_VALUE[opt[1]]
+            shortArgs = shortArgs + opt[0] + optStr[0]
+            longArgs.append(opt[2] + optStr[1])
+            longArgs.append('no-' + opt[2] + optStr[1])
+
+    options = {}
+    for _, group in _OPTIONS :
+        for opt in group:
+            shortArg, useValue, longArg, member, description = opt
+            if shortArg != '' :
+                options['-' + shortArg] = opt
+            options['--no-' + longArg] = options['--' + longArg] = opt
+
+    return shortArgs, longArgs, options
+
+_SHORT_ARGS, _LONG_ARGS, _OPTIONS_DICT = init()
+
+def _getRCfiles(filename) :
+    """Return a list of .rc filenames, on Windows use the current directory
+                                       on UNIX use the user's home directory
+    """
+
+    files = []
+    home = os.environ.get('HOME')
+    if home :
+        files.append(home + os.sep + filename)
+    files.append(filename)
+    return files
+
+
+_RC_FILE_HEADER = '''#
+# .pycheckrc file created by PyChecker v%s @ %s
+#
+# It should be placed in your home directory (value of $HOME).
+# If $HOME is not set, it will look in the current directory.
+#
+
+'''
+
+def outputRc(cfg) :
+    output = _RC_FILE_HEADER % (_VERSION, time.ctime(time.time()))
+    for name, group in _OPTIONS :
+        for opt in group:
+            shortArg, useValue, longArg, member, description = opt
+            if member is None :
+                continue
+            description = string.strip(description)
+            value = getattr(cfg, member)
+            optStr = '# %s\n%s = %s\n\n' % (description, member, `value`)
+            output = output + optStr
+
+    return output
+        
+
+class UsageError(Exception) :
+    """Exception to indicate that the application should exit due to
+       command line usage error."""
+
+_SUPPRESSIONS_ERR = \
+'''\nWarning, error processing defaults file: %s
+\%s must be a dictionary ({}) -- ignoring suppressions\n'''
+
+def _getSuppressions(name, dict, filename) :
+    suppressions = dict.get(name, {})
+    if type(suppressions) != type({}) :
+        print _SUPPRESSIONS_ERR % (filename, name)
+        suppressions = {}
+    return suppressions
+
+
+class Config :
+    "Hold configuration information"
+
+    def __init__(self) :
+        "Initialize configuration with default values."
+
+        # files to process (typically from cmd line)
+        self.files = {}
+
+        self.debug = 0
+        self.quiet = 0
+        self.only = 0
+        self.level = 0
+        self.limit = 10
+
+        self.ignoreImportErrors = 0
+        self.onlyCheckInitForMembers = 0
+        self.printParse = 0
+        self.quixote = 0
+        self.evil = []
+        self.findEvil = 0
+
+        self.noDocModule = 0
+        self.noDocClass = 0
+        self.noDocFunc = 0
+
+        self.reportAllGlobals = 0
+        self.allVariablesUsed = 0
+        self.privateVariableUsed = 1
+        self.membersUsed = 0
+        self.importUsed = 1
+        self.reimportSelf = 1
+        self.moduleImportErrors = 1
+        self.mixImport = 1
+        self.packageImportUsed = 1
+        self.localVariablesUsed = 1
+        self.unusedLocalTuple = 0
+        self.initDefinedInSubclass = 0
+        self.baseClassInitted = 1
+        self.abstractClasses = 1
+        self.callingAttribute = 0
+        self.classAttrExists = 1
+        self.namedArgs = 0
+        self.returnNoneFromInit = 1
+        self.unreachableCode = 0
+        self.constantConditions = 1
+        self.constant1 = 0
+        self.stringIteration = 1
+        self.inconsistentTypes = 0
+        self.unpackNonSequence = 1
+        self.unpackLength = 1
+        self.badExceptions = 1
+        self.noEffect = 1
+        self.deprecated = 1
+        self.modulo1 = 1
+        self.isLiteral = 1
+        self.stringFind = 1
+
+        self.unusedNames = _DEFAULT_UNUSED_LIST
+        self.variablesToIgnore = _DEFAULT_VARIABLE_IGNORE_LIST
+        self.blacklist = _DEFAULT_BLACK_LIST
+        self.missingAttrs = _DEFAULT_MISSING_ATTRS_LIST
+        self.ignoreStandardLibrary = 0
+        self.methodArgName = 'self'
+        self.classmethodArgNames = ['cls', 'klass']
+        self.checkOverridenMethods = 1
+        self.checkSpecialMethods = 1
+
+        self.argumentsUsed = 1
+        self.varArgumentsUsed = 1
+        self.ignoreSelfUnused = 0
+        self.redefiningFunction = 1
+
+        self.maxLines = 200
+        self.maxBranches = 50
+        self.maxReturns = 10
+        self.maxArgs = 10
+        self.maxLocals = 40
+        self.maxReferences = 5
+
+        self.slots = 1
+        self.emptySlots = 1
+        self.classicProperties = 1
+        self.checkObjectAttrs = 1
+        self.checkReturnValues = 1
+        self.checkImplicitReturns = 1
+        self.intDivide = 1
+        self.shadows = 1
+        self.shadowBuiltins = 1
+        self.unaryPositive = 1
+        self.modifyDefaultValue = 1
+        self.usesExec = 0
+        self.usesInput = 1
+        self.constAttr = 1
+
+    def loadFile(self, filename) :
+        suppressions = {}
+        suppressionRegexs = {}
+        try :
+            tmpGlobal, dict = {}, {}
+            execfile(filename, tmpGlobal, dict)
+            for key, value in dict.items() :
+                if self.__dict__.has_key(key) :
+                    self.__dict__[key] = value
+                elif key not in ('suppressions', 'suppressionRegexs') and \
+                     key[0] != '_':
+                    print "Warning, option (%s) doesn't exist, ignoring" % key
+
+            suppressions = _getSuppressions('suppressions', dict, filename)
+            regexs = _getSuppressions('suppressionRegexs', dict, filename)
+            for regex_str in regexs.keys() :
+                regex = re.compile(regex_str)
+                suppressionRegexs[regex] = regexs[regex_str]
+        except IOError :
+            pass       # ignore if no file
+        except Exception, detail:
+            print "Warning, error loading defaults file:", filename, detail
+        return suppressions, suppressionRegexs
+
+    def loadFiles(self, filenames, oldSuppressions = None) :
+        if oldSuppressions is None :
+            oldSuppressions = ({}, {})
+        suppressions = oldSuppressions[0]
+        suppressionRegexs = oldSuppressions[1]
+        for filename in filenames:
+            updates = self.loadFile(filename)
+            suppressions.update(updates[0])
+            suppressionRegexs.update(updates[1])
+        return suppressions, suppressionRegexs
+
+    def processArgs(self, argList, otherConfigFiles = None) :
+        try :
+            args, files = getopt.getopt(argList, _SHORT_ARGS, _LONG_ARGS)
+        except getopt.error, detail :
+            raise UsageError, detail
+
+        # setup files from cmd line
+        for f in files:
+            self.files[os.path.abspath(f)] = 1
+
+        if otherConfigFiles is None:
+            otherConfigFiles = []
+        for arg, value in args :
+            shortArg, useValue, longArg, member, description = _OPTIONS_DICT[arg]
+            if member == None :
+                # FIXME: this whole block is a hack
+                if longArg == 'rcfile' :
+                    sys.stdout.write(outputRc(self))
+                    continue
+                elif longArg == 'quixote' :
+                    import quixote
+                    quixote.enable_ptl()
+                    self.quixote = 1
+                    continue
+                elif longArg == 'config' :
+                    otherConfigFiles.append(value)
+                    continue
+                elif longArg == 'version' :
+                    # FIXME: it would be nice to define this in only one place
+                    print _VERSION
+                    sys.exit(0)
+                elif longArg == 'level':
+                    normalizedValue = value.capitalize()
+                    if not _WARNING_LEVELS.has_key(normalizedValue):
+                        sys.stderr.write('Invalid warning level (%s).  '
+                                         'Must be one of: %s\n' %
+                                         (value, _WARNING_LEVELS.keys()))
+                        sys.exit(1)
+
+                    self.level = _WARNING_LEVELS[normalizedValue].level
+                    continue
+            elif value  :
+                newValue = value
+                memberType = type(getattr(self, member))
+                if memberType == type(0) :
+                    newValue = int(newValue)
+                elif memberType == type([]) :
+                    newValue = string.split(newValue, ',')
+                elif memberType == type('') and \
+                     newValue[0] in '\'"':
+                        try:
+                            newValue = eval(newValue)
+                        except:
+                            msg = 'Invalid option parameter: %s for %s\n' % \
+                                  (`newValue`, arg)
+                            sys.stderr.write(msg)
+                setattr(self, member, newValue)
+            elif arg[0:2] == '--' :
+                setattr(self, member, arg[2:5] != 'no-')
+            else :
+                # for shortArgs we only toggle
+                setattr(self, member, not getattr(self, member))
+
+        if self.variablesToIgnore.count(CHECKER_VAR) <= 0 :
+            self.variablesToIgnore.append(CHECKER_VAR)
+
+        return files
+
+def printArg(shortArg, longArg, description, defaultValue, useValue) :
+    defStr = ''
+    shortArgStr = '   '
+    if shortArg:
+        shortArgStr = '-%s,' % shortArg
+
+    if defaultValue != None :
+        if not useValue :
+            if defaultValue :
+                defaultValue = 'on'
+            else :
+                defaultValue = 'off'
+        defStr = ' [%s]' % defaultValue
+    args = "%s --%s" % (shortArgStr, longArg)
+    print "  %-18s %s%s" % (args, description, defStr)
+
+def usage(cfg = None) :
+    print "Usage for: checker.py [options] PACKAGE ...\n"
+    print "    PACKAGEs can be a python package, module or filename\n"
+    print "Long options can be preceded with no- to turn off (e.g., no-namedargs)\n"
+    print "Category"
+    print "  Options:           Change warning for ... [default value]"
+    
+    if cfg is None :
+        cfg = Config()
+    for name, group in _OPTIONS :
+        print
+        print name + ":"
+        for opt in group:  
+            shortArg, useValue, longArg, member, description = opt
+            defValue = None
+            if member != None :
+                defValue = cfg.__dict__[member]
+
+            printArg(shortArg, longArg, description, defValue, useValue)
+
+
+def setupFromArgs(argList) :
+    "Returns (Config, [ file1, file2, ... ]) from argList"
+
+    cfg = Config()
+    try :
+        suppressions = cfg.loadFiles(_getRCfiles(_RC_FILE))
+        otherConfigFiles = []
+        files = cfg.processArgs(argList, otherConfigFiles)
+        if otherConfigFiles:
+            suppressions = cfg.loadFiles(otherConfigFiles, suppressions)
+        return cfg, files, suppressions
+    except UsageError :
+        usage(cfg)
+        raise

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/OP.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/OP.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/OP.py
new file mode 100644
index 0000000..ba124f0
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/OP.py
@@ -0,0 +1,131 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2001-2004, MetaSlash Inc.  All rights reserved.
+# Portions Copyright (c) 2005, Google, Inc.  All rights reserved.
+
+"""
+Python byte code operations.
+
+Very similar to the dis module, but dis does not exist in Jython,
+so recreate the small portion we need here.
+"""
+
+def LINE_NUM(op):              return op == 127
+def LOAD_GLOBAL(op):           return op == 116
+def LOAD_CONST(op):            return op == 100
+def LOAD_FAST(op):             return op == 124
+def LOAD_ATTR(op):             return op == 105
+def LOAD_DEREF(op):            return op == 136
+def STORE_ATTR(op):            return op == 95
+def POP_TOP(op):               return op == 1
+def IMPORT_FROM(op):           return op == 108
+def IMPORT_STAR(op):           return op == 84
+def UNARY_POSITIVE(op):        return op == 10
+def UNARY_NEGATIVE(op):        return op == 11
+def UNARY_INVERT(op):          return op == 15
+def RETURN_VALUE(op):          return op == 83
+def JUMP_FORWARD(op):          return op == 110
+def JUMP_ABSOLUTE(op):         return op == 113
+def FOR_ITER(op):              return op == 93
+def FOR_LOOP(op):              return op == 114
+def SETUP_LOOP(op):            return op == 120
+def BREAK_LOOP(op):            return op == 80
+def RAISE_VARARGS(op):         return op == 130
+def POP_BLOCK(op):             return op == 87
+def END_FINALLY(op):           return op == 88
+def CALL_FUNCTION(op):         return op == 131
+
+def UNPACK_SEQUENCE(op) :
+    "Deal w/Python 1.5.2 (UNPACK_[LIST|TUPLE]) or 2.0 (UNPACK_SEQUENCE)"
+    return op in (92, 93,)
+
+def IS_CONDITIONAL_JUMP(op):
+    return op in (111, 112)
+
+def IS_NOT(op):
+    return op == 12
+
+HAVE_ARGUMENT = 90
+EXTENDED_ARG = 143
+
+_HAS_NAME = (90, 91, 95, 96, 97, 98, 101, 105, 107, 108, 116,)
+_HAS_LOCAL = (124, 125, 126,)
+_HAS_CONST = (100,)
+_HAS_COMPARE = (106,)
+_HAS_JREL = (110, 111, 112, 114, 120, 121, 122,)
+_HAS_JABS = (113, 119,)
+
+_CMP_OP =  ('<', '<=', '==', '!=', '>', '>=', 'in', 'not in', 'is',
+            'is not', 'exception match', 'BAD')
+
+EXCEPT_COMPARISON = 10
+IS_COMPARISON = 8
+IN_COMPARISON = 6
+NOT_IN_COMPARISON = 7
+
+def getOperand(op, func_code, oparg) :
+    if op in _HAS_NAME :
+        return func_code.co_names[oparg]
+    elif op in _HAS_LOCAL :
+        return func_code.co_varnames[oparg]
+    elif op in _HAS_CONST :
+        return func_code.co_consts[oparg]
+    elif op in _HAS_COMPARE :
+        return _CMP_OP[oparg]
+    return None
+
+def getLabel(op, oparg, i) :
+    if op in _HAS_JREL :
+        return i + oparg
+    elif op in _HAS_JABS :
+        return oparg
+    return None
+
+def getInfo(code, index, extended_arg) :
+    """Returns (op, oparg, index, extended_arg) based on code
+       this is a helper function while looping through byte code,
+       refer to the standard module dis.disassemble() for more info"""
+
+    # get the operation we are performing
+    op = ord(code[index])
+    index = index + 1
+    if op >= HAVE_ARGUMENT :
+        # get the argument to the operation
+        oparg = ord(code[index]) + ord(code[index+1])*256 + extended_arg
+        index = index + 2
+        extended_arg = 0
+        if op == EXTENDED_ARG :
+            extended_arg = oparg * 65536L
+    else :
+        oparg, extended_arg = 0, 0
+    return op, oparg, index, extended_arg
+
+def initFuncCode(func) :
+    """Returns (func_code, code, i, maxCode, extended_arg) based on func,
+       this is a helper function to setup looping through byte code"""
+
+    func_code = func.func_code
+    code = func_code.co_code
+    return func_code, code, 0, len(code), 0
+
+def conditional(op):
+    "returns true if the code results in conditional execution"
+    return op in [83,                   # return
+                  93,                   # for_iter
+                  111, 112, 114,        # conditional jump
+                  121,                  # setup_exec
+                  130                   # raise_varargs
+                  ]
+
+# this code is here for debugging purposes.
+# Jython doesn't support dis, so don't rely on it
+try :
+    import dis
+    name = dis.opname
+except ImportError :
+    class Name:
+        'Turn name[x] into x'
+        def __getitem__(self, x):
+            from pychecker import utils
+            return utils.safestr(x)
+    name = Name()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/OptionTypes.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/OptionTypes.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/OptionTypes.py
new file mode 100644
index 0000000..f3bd1d2
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/OptionTypes.py
@@ -0,0 +1,117 @@
+import Tkinter
+
+def bool(value):
+    if value:
+        return 1
+    return 0
+
+class Base:
+    "Base class for all OptionTypes"
+    
+    def __init__(self, name, default):
+        self._name = name
+        self._default = default
+        self._var = None
+
+    def name(self):
+        return self._name
+
+    def set(self, value):
+        self._var.set(value)
+
+class Boolean(Base):
+    "A option type for editing boolean values"
+
+    def __init__(self, name, default):
+        Base.__init__(self, name, default)
+
+    def field(self, w):
+        self._var = Tkinter.BooleanVar()
+        if self._default:
+            self._var.set(1)
+        else:
+            self._var.set(0)
+        frame = Tkinter.Frame(w, name = self._name + "Frame")
+        result = Tkinter.Checkbutton(frame,
+                                     name=self._name,
+                                     text=self._name,
+                                     variable=self._var)
+        result.grid(sticky=Tkinter.W)
+        frame.columnconfigure(0, weight=1)
+        return frame
+
+    def arg(self):
+        if bool(self._var.get()) != bool(self._default):
+            if bool(self._var.get()):
+                return "--" + self._name
+            return "--no-" + self._name
+        return None
+
+class Number(Base):
+    "OptionType for editing numbers"
+
+    def __init__(self, name, default):
+        Base.__init__(self, name, default)
+
+    def field(self, w):
+        self._var = Tkinter.IntVar()
+        self._var.set(self._default)
+        frame = Tkinter.Frame(w, name = self._name + "Frame")
+        label = Tkinter.Label(frame, text=self._name + ":")
+        label.grid(row=0, column=0, sticky=Tkinter.W)
+        entry = Tkinter.Entry(frame,
+                              name=self._name,
+                              textvariable=self._var,
+                              width=4)
+        entry.grid(row=0, column=1, sticky=Tkinter.E)
+        for i in range(2):
+            frame.columnconfigure(i, weight=1)
+        return frame
+
+    def arg(self):
+        if self._var.get() != self._default:
+            return "--%s=%d" % (self._name, self._var.get())
+        return None
+    
+class Text(Base):
+    "OptionType for editing a little bit of text"
+
+    def __init__(self, name, default):
+        Base.__init__(self, name, default)
+
+    def width(self):
+        return int(min(15, len(self._default) * 1.20))
+
+    def field(self, w):
+        self._var = Tkinter.StringVar()
+        self._var.set(self._default)
+        frame = Tkinter.Frame(w, name = self._name + "Frame")
+        label = Tkinter.Label(frame, text=self._name + ":")
+        label.grid(row=0, column=0, sticky=Tkinter.W)
+        entry = Tkinter.Entry(frame,
+                              name=self._name,
+                              textvariable=self._var,
+                              width=self.width())
+        entry.grid(row=0, column=1, sticky=Tkinter.E)
+        for i in range(2):
+            frame.columnconfigure(i, weight=1)
+        return frame
+
+    def arg(self):
+        if self._var.get() != self._default:
+            return "--%s=%s" % (self._name, self._var.get())
+        return None
+    
+def join(list):
+    import string
+    return string.join(list, ", ")
+
+class List(Text):
+    "OptionType for editing a list of values"
+
+    def __init__(self, name, default):
+        Text.__init__(self, name, join(default))
+
+    def set(self, value):
+        self._var.set(join(value))
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/Options.ad
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/Options.ad b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/Options.ad
new file mode 100644
index 0000000..afe8310
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/Options.ad
@@ -0,0 +1,9 @@
+*ok.text: Ok
+*cancel.text: Cancel
+*default.text: Reset
+*helpBox.wrapLength: 400
+*helpBox.height: 2
+*getfile.text: File:
+*check.text: Check!
+*fname.width: 50
+*close.text: Close

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/Stack.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/Stack.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/Stack.py
new file mode 100644
index 0000000..caf25b3
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/Stack.py
@@ -0,0 +1,115 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2001-2002, MetaSlash Inc.  All rights reserved.
+
+"""
+Module to hold manipulation of elements on the stack.
+"""
+
+import types
+from pychecker import utils
+
+DATA_UNKNOWN = "-unknown-"
+LOCALS = 'locals'
+
+# These should really be defined by subclasses
+TYPE_UNKNOWN = "-unknown-"
+TYPE_FUNC_RETURN = "-return-value-"
+TYPE_ATTRIBUTE = "-attribute-"
+TYPE_COMPARISON = "-comparison-"
+TYPE_GLOBAL = "-global-"
+TYPE_EXCEPT = "-except-"
+
+class Item :
+    "Representation of data on the stack"
+
+    def __init__(self, data, dataType, const = 0, length = 0) :
+        self.data = data
+        self.type = dataType
+        self.const = const
+        self.length = length
+        self.is_really_string = 0
+
+    def __str__(self) :
+        if type(self.data) == types.TupleType :
+            value = '('
+            for item in self.data :
+                value = value + utils.safestr(item) + ', '
+            # strip off the ', ' for multiple items
+            if len(self.data) > 1 :
+                value = value[:-2]
+            return value + ')'
+        return utils.safestr(self.data)
+
+    def __repr__(self):
+        return 'Stack Item: (%r, %r, %d)' % (self.data, self.type, self.const)
+
+    def isNone(self) :
+        return (self.type != TYPE_UNKNOWN and self.data is None or
+                (self.data == 'None' and not self.const))
+
+    def isImplicitNone(self) :
+        return self.data is None and self.const
+
+    def isMethodCall(self, c, methodArgName):
+        return self.type == TYPE_ATTRIBUTE and c != None and \
+               len(self.data) == 2 and self.data[0] == methodArgName
+
+    def isLocals(self) :
+        return self.type == types.DictType and self.data == LOCALS
+
+    def setStringType(self, value = types.StringType):
+        self.is_really_string = value == types.StringType
+
+    def getType(self, typeMap) :
+        if self.type != types.StringType or self.is_really_string:
+            return self.type
+        if self.const :
+            return type(self.data)
+        if type(self.data) == types.StringType :
+            localTypes = typeMap.get(self.data, [])
+            if len(localTypes) == 1 :
+                return localTypes[0]
+        return TYPE_UNKNOWN
+
+    def getName(self) :
+        if self.type == TYPE_ATTRIBUTE and type(self.data) != types.StringType:
+            strValue = ""
+            # convert the tuple into a string ('self', 'data') -> self.data
+            for item in self.data :
+                strValue = '%s.%s' % (strValue, utils.safestr(item))
+            return strValue[1:]
+        return utils.safestr(self.data)
+
+    def addAttribute(self, attr) :
+        if type(self.data) == types.TupleType :
+            self.data = self.data + (attr,)
+        else :
+            self.data = (self.data, attr)
+        self.type = TYPE_ATTRIBUTE
+
+
+def makeDict(values = (), const = 1) :
+    values = tuple(values)
+    if not values:
+        values = ('<on-stack>',)
+    return Item(values, types.DictType, const, len(values))
+
+def makeTuple(values = (), const = 1) :
+    return Item(tuple(values), types.TupleType, const, len(values))
+
+def makeList(values = [], const = 1) :
+    return Item(values, types.ListType, const, len(values))
+
+def makeFuncReturnValue(stackValue, argCount) :
+    data = DATA_UNKNOWN
+    # vars() without params == locals()
+    if stackValue.type == TYPE_GLOBAL and \
+       (stackValue.data == LOCALS or
+        (argCount == 0 and stackValue.data == 'vars')) :
+        data = LOCALS
+    return Item(data, TYPE_FUNC_RETURN)
+
+def makeComparison(stackItems, comparison) :
+    return Item((stackItems[0], comparison, stackItems[1]), TYPE_COMPARISON)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/Warning.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/Warning.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/Warning.py
new file mode 100644
index 0000000..56183e5
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/Warning.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2001, MetaSlash Inc.  All rights reserved.
+# Portions Copyright (c) 2005, Google, Inc. All rights reserved.
+
+"""
+Warning class to hold info about each warning.
+"""
+
+
+class Warning :
+    "Class which holds error information."
+
+    def __init__(self, file, line, err) :
+        if hasattr(file, "function") :
+            file = file.function.func_code.co_filename
+        elif hasattr(file, "co_filename") :
+            file = file.co_filename
+        elif hasattr(line, "co_filename") :
+            file = line.co_filename
+        if file[:2] == './' :
+            file = file[2:]
+        self.file = file
+
+        if hasattr(line, "co_firstlineno") :
+            line = line.co_firstlineno
+        if line == None :
+            line = 1
+        self.line = line
+        self.err = err
+        self.level = err.level
+
+    def __cmp__(self, warn) :
+        if warn == None :
+            return 1
+        if not self.file and not self.line:
+            return 1
+        if self.file != warn.file :
+            return cmp(self.file, warn.file)
+        if self.line != warn.line :
+            return cmp(self.line, warn.line)
+        return cmp(self.err, warn.err)
+
+    def format(self) :
+        if not self.file and not self.line:
+            return str(self.err)
+        return "%s:%d: %s" % (self.file, self.line, self.err)
+
+    def output(self, stream) :
+        stream.write(self.format() + "\n")

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/__init__.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/__init__.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/__init__.py
new file mode 100644
index 0000000..3616af4
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/__init__.py
@@ -0,0 +1,17 @@
+"""
+Copyright (c) 2001, MetaSlash Inc.  All rights reserved.
+
+PyChecker is a tool for finding common bugs in python source code.
+It finds problems that are typically caught by a compiler for less
+dynamic languages, like C and C++.  It is also similar to lint.
+
+Contact Info:
+  http://pychecker.sourceforge.net/
+  pychecker-list@lists.sourceforge.net
+"""
+
+# A version # to check against in the main module (checker.py)
+# this will allow us to check if there are two versions of checker
+# in site-packages and local dir
+MAIN_MODULE_VERSION = 3
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/checker.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/checker.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/checker.py
new file mode 100755
index 0000000..4a33489
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/checker.py
@@ -0,0 +1,961 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2001-2004, MetaSlash Inc.  All rights reserved.
+# Portions Copyright (c) 2005, Google, Inc.  All rights reserved.
+
+"""
+Check python source code files for possible errors and print warnings
+
+Contact Info:
+  http://pychecker.sourceforge.net/
+  pychecker-list@lists.sourceforge.net
+"""
+
+import string
+import types
+import sys
+import imp
+import os
+import glob
+import traceback
+import re
+
+# see __init__.py for meaning, this must match the version there
+LOCAL_MAIN_VERSION = 3
+
+
+def setupNamespace(path) :
+    # remove pychecker if it's the first component, it needs to be last
+    if sys.path[0][-9:] == 'pychecker' :
+        del sys.path[0]
+
+    # make sure pychecker is last in path, so we can import
+    checker_path = os.path.dirname(os.path.dirname(path))
+    if checker_path not in sys.path :
+        sys.path.append(checker_path)
+
+
+def setupSysPathForDevelopment():
+    import pychecker
+    this_module = sys.modules[__name__]
+    this_path = os.path.normpath(os.path.dirname(this_module.__file__))
+    pkg_path = os.path.normpath(os.path.dirname(pychecker.__file__))
+    if pkg_path != this_path:
+        # pychecker was probably found in site-packages, insert this
+        # directory before the other one so we can do development and run
+        # our local version and not the version from site-packages.
+        pkg_dir = os.path.dirname(pkg_path)
+        i = 0
+        for p in sys.path:
+            if os.path.normpath(p) == pkg_dir:
+                sys.path.insert(i-1, os.path.dirname(this_path))
+                break
+            i = i + 1
+    del sys.modules['pychecker']
+
+
+if __name__ == '__main__' :
+    setupNamespace(sys.argv[0])
+    setupSysPathForDevelopment()
+
+from pychecker import utils
+from pychecker import printer
+from pychecker import warn
+from pychecker import OP
+from pychecker import Config
+from pychecker import function
+from pychecker import msgs
+from pychecker import pcmodules
+from pychecker.Warning import Warning
+
+_cfg = None
+
+# Constants
+_DEFAULT_MODULE_TOKENS = ('__builtins__', '__doc__', '__file__', '__name__',
+                          '__path__')
+_DEFAULT_CLASS_TOKENS = ('__doc__', '__name__', '__module__')
+
+# When using introspection on objects from some C extension modules,
+# the interpreter will crash.  Since pychecker exercises these bugs we
+# need to blacklist the objects and ignore them.  For more info on how
+# to determine what object is causing the crash, search for this
+# comment below (ie, it is also several hundred lines down):
+#
+#     README if interpreter is crashing:
+
+# FIXME: the values should indicate the versions of these modules
+# that are broken.  We shouldn't ignore good modules.
+
+_EVIL_C_OBJECTS = {
+    'matplotlib.axes.BinOpType': None,  # broken on versions <= 0.83.2
+
+    # broken on versions at least 2.5.5 up to 2.6
+    'wx.TheClipboard': None,
+    'wx._core.TheClipboard': None,
+    'wx._misc.TheClipboard': None,
+  }
+
+_VERSION_MISMATCH_ERROR = '''
+There seem to be two versions of PyChecker being used.
+One is probably in python/site-packages, the other in a local directory.
+If you want to run the local version, you must remove the version
+from site-packages.  Or you can install the current version
+by doing python setup.py install.
+'''
+
+def cfg() :
+    return utils.cfg()
+
+def _flattenList(list) :
+    "Returns a list which contains no lists"
+
+    new_list = []
+    for element in list :
+        if type(element) == types.ListType :
+            new_list.extend(_flattenList(element))
+        else :
+            new_list.append(element)
+
+    return new_list
+
+def getModules(arg_list) :
+    """
+    arg_list is a list of arguments to pychecker; arguments can represent
+    a module name, a filename, or a wildcard file specification.
+
+    Returns a list of (module name, dirPath) that can be imported, where
+    dirPath is the on-disk path to the module name for that argument.
+
+    dirPath can be None (in case the given argument is an actual module).
+    """
+
+    new_arguments = []
+    for arg in arg_list :
+        # is this a wildcard filespec? (necessary for windows)
+        if '*' in arg or '?' in arg or '[' in arg :
+            arg = glob.glob(arg)
+        new_arguments.append(arg)
+
+    PY_SUFFIXES = ['.py']
+    PY_SUFFIX_LENS = [3]
+    if _cfg.quixote:
+        PY_SUFFIXES.append('.ptl')
+        PY_SUFFIX_LENS.append(4)
+        
+    modules = []
+    for arg in _flattenList(new_arguments) :
+        # if arg is an actual module, return None for the directory
+        arg_dir = None
+        # is it a .py file?
+        for suf, suflen in zip(PY_SUFFIXES, PY_SUFFIX_LENS):
+            if len(arg) > suflen and arg[-suflen:] == suf:
+                arg_dir = os.path.dirname(arg)
+                if arg_dir and not os.path.exists(arg) :
+                    print 'File or pathname element does not exist: "%s"' % arg
+                    continue
+
+                module_name = os.path.basename(arg)[:-suflen]
+
+                arg = module_name
+        modules.append((arg, arg_dir))
+
+    return modules
+
+def _q_file(f):
+    # crude hack!!!
+    # imp.load_module requires a real file object, so we can't just
+    # fiddle def lines and yield them
+    import tempfile
+    fd, newfname = tempfile.mkstemp(suffix=".py", text=True)
+    newf = os.fdopen(fd, 'r+')
+    os.unlink(newfname)
+    for line in f:
+        mat = re.match(r'(\s*def\s+\w+\s*)\[(html|plain)\](.*)', line)
+        if mat is None:
+            newf.write(line)
+        else:
+            newf.write(mat.group(1)+mat.group(3)+'\n')
+    newf.seek(0)
+    return newf
+
+def _q_find_module(p, path):
+    if not _cfg.quixote:
+        return imp.find_module(p, path)
+    else:
+        for direc in path:
+            try:
+                return imp.find_module(p, [direc])
+            except ImportError:
+                f = os.path.join(direc, p+".ptl")
+                if os.path.exists(f):
+                    return _q_file(file(f)), f, ('.ptl', 'U', 1)
+
+def _findModule(name, moduleDir=None) :
+    """Returns the result of an imp.find_module(), ie, (file, filename, smt)
+       name can be a module or a package name.  It is *not* a filename."""
+
+    path = sys.path[:]
+    if moduleDir:
+        path.insert(0, moduleDir)
+
+    packages = string.split(name, '.')
+    for p in packages :
+        # smt = (suffix, mode, type)
+        file, filename, smt = _q_find_module(p, path)
+        if smt[-1] == imp.PKG_DIRECTORY :
+            try :
+                # package found - read path info from init file
+                m = imp.load_module(p, file, filename, smt)
+            finally :
+                if file is not None :
+                    file.close()
+
+            # importing xml plays a trick, which replaces itself with _xmlplus
+            # both have subdirs w/same name, but different modules in them
+            # we need to choose the real (replaced) version
+            if m.__name__ != p :
+                try :
+                    file, filename, smt = _q_find_module(m.__name__, path)
+                    m = imp.load_module(p, file, filename, smt)
+                finally :
+                    if file is not None :
+                        file.close()
+
+            new_path = m.__path__
+            if type(new_path) == types.ListType :
+                new_path = filename
+            if new_path not in path :
+                path.insert(1, new_path)
+        elif smt[-1] != imp.PY_COMPILED:
+            if p is not packages[-1] :
+                if file is not None :
+                    file.close()
+                raise ImportError, "No module named %s" % packages[-1]
+            return file, filename, smt
+
+    # in case we have been given a package to check
+    return file, filename, smt
+
+
+class Variable :
+    "Class to hold all information about a variable"
+
+    def __init__(self, name, type):
+        self.name = name
+        self.type = type
+        self.value = None
+
+    def __str__(self) :
+        return self.name
+
+    __repr__ = utils.std_repr
+
+
+def _filterDir(object, ignoreList) :
+    "Return a list of tokens (attributes) in a class, except for ignoreList"
+
+    tokens = dir(object)
+    for token in ignoreList :
+        if token in tokens :
+            tokens.remove(token)
+    return tokens
+
+def _getClassTokens(c) :
+    return _filterDir(c, _DEFAULT_CLASS_TOKENS)
+
+
+class Class :
+    "Class to hold all information about a class"
+
+    def __init__(self, name, pcmodule) :
+        """
+        @type pcmodule: PyCheckerModule
+        """
+        self.name = name
+        module = pcmodule.module
+        self.classObject = getattr(module, name)
+
+        modname = getattr(self.classObject, '__module__', None)
+        if modname is None:
+            # hm, some ExtensionClasses don't have a __module__ attribute
+            # so try parsing the type output
+            typerepr = repr(type(self.classObject))
+            mo = re.match("^<type ['\"](.+)['\"]>$", typerepr)
+            if mo:
+                modname = ".".join(mo.group(1).split(".")[:-1])
+
+        # TODO(nnorwitz): this check for __name__ might not be necessary
+        # any more.  Previously we checked objects as if they were classes.
+        # This problem is fixed by not adding objects as if they are classes.
+
+        # zope.interface for example has Provides and Declaration that
+        # look a lot like class objects but do not have __name__
+        if not hasattr(self.classObject, '__name__'):
+            if modname not in cfg().blacklist:
+                sys.stderr.write("warning: no __name__ attribute "
+                                 "for class %s (module name: %s)\n"
+                                 % (self.classObject, modname))
+            self.classObject.__name__ = name
+        # later pychecker code uses this
+        self.classObject__name__ = self.classObject.__name__
+
+        self.module = sys.modules.get(modname)
+        # if the pcmodule has moduleDir, it means we processed it before,
+        # and deleted it from sys.modules
+        if not self.module and not pcmodule.moduleDir:
+            self.module = module
+            if modname not in cfg().blacklist:
+                sys.stderr.write("warning: couldn't find real module "
+                                 "for class %s (module name: %s)\n"
+                                 % (self.classObject, modname))
+        self.ignoreAttrs = 0
+        self.methods = {}
+        self.members = { '__class__': types.ClassType,
+                         '__doc__': types.StringType,
+                         '__dict__': types.DictType, }
+        self.memberRefs = {}
+        self.statics = {}
+        self.lineNums = {}
+
+    def __str__(self) :
+        return self.name
+
+    __repr__ = utils.std_repr
+
+    def getFirstLine(self) :
+        "Return first line we can find in THIS class, not any base classes"
+
+        lineNums = []
+        classDir = dir(self.classObject)
+        for m in self.methods.values() :
+            if m != None and m.function.func_code.co_name in classDir:
+                lineNums.append(m.function.func_code.co_firstlineno)
+        if lineNums :
+            return min(lineNums)
+        return 0
+
+    def allBaseClasses(self, c = None) :
+        "Return a list of all base classes for this class and it's subclasses"
+
+        baseClasses = []
+        if c == None :
+            c = self.classObject
+        for base in getattr(c, '__bases__', None) or ():
+            baseClasses = baseClasses + [ base ] + self.allBaseClasses(base)
+        return baseClasses
+
+    def __getMethodName(self, func_name, className = None) :
+        if func_name[0:2] == '__' and func_name[-2:] != '__' :
+            if className == None :
+                className = self.name
+            if className[0] != '_' :
+                className = '_' + className
+            func_name = className + func_name
+        return func_name
+
+    def addMethod(self, method, methodName = None) :
+        if type(method) == types.StringType :
+            self.methods[method] = None
+        else :
+            assert methodName is not None, "must supply methodName"
+            self.methods[methodName] = function.Function(method, 1)
+                
+    def addMethods(self, classObject) :
+        for classToken in _getClassTokens(classObject) :
+            token = getattr(classObject, classToken, None)
+            if token is None:
+                continue
+
+            # Looks like a method.  Need to code it this way to
+            # accommodate ExtensionClass and Python 2.2.  Yecchh.
+            if (hasattr(token, "func_code") and
+                hasattr(token.func_code, "co_argcount")): 
+                self.addMethod(token, token.__name__)
+
+            elif hasattr(token, '__get__') and \
+                 not hasattr(token, '__set__') and \
+                 type(token) is not types.ClassType :
+                self.addMethod(getattr(token, '__name__', classToken))
+            else :
+                self.members[classToken] = type(token)
+                self.memberRefs[classToken] = None
+
+        self.cleanupMemberRefs()
+        # add standard methods
+        for methodName in ('__class__',) :
+            self.addMethod(methodName, self.classObject__name__)
+
+    def addMembers(self, classObject) :
+        if not cfg().onlyCheckInitForMembers :
+            for classToken in _getClassTokens(classObject) :
+                method = getattr(classObject, classToken, None)
+                if type(method) == types.MethodType :
+                    self.addMembersFromMethod(method.im_func)
+        else:
+            try:
+                self.addMembersFromMethod(classObject.__init__.im_func)
+            except AttributeError:
+                pass
+
+    def addMembersFromMethod(self, method) :
+        if not hasattr(method, 'func_code') :
+            return
+
+        func_code, code, i, maxCode, extended_arg = OP.initFuncCode(method)
+        stack = []
+        while i < maxCode :
+            op, oparg, i, extended_arg = OP.getInfo(code, i, extended_arg)
+            if op >= OP.HAVE_ARGUMENT :
+                operand = OP.getOperand(op, func_code, oparg)
+                if OP.LOAD_CONST(op) or OP.LOAD_FAST(op) or OP.LOAD_GLOBAL(op):
+                    stack.append(operand)
+                elif OP.LOAD_DEREF(op):
+                    try:
+                        operand = func_code.co_cellvars[oparg]
+                    except IndexError:
+                        index = oparg - len(func_code.co_cellvars)
+                        operand = func_code.co_freevars[index]
+                    stack.append(operand)
+                elif OP.STORE_ATTR(op) :
+                    if len(stack) > 0 :
+                        if stack[-1] == cfg().methodArgName:
+                            value = None
+                            if len(stack) > 1 :
+                                value = type(stack[-2])
+                            self.members[operand] = value
+                            self.memberRefs[operand] = None
+                        stack = []
+
+        self.cleanupMemberRefs()
+
+    def cleanupMemberRefs(self) :
+        try :
+            del self.memberRefs[Config.CHECKER_VAR]
+        except KeyError :
+            pass
+
+    def abstractMethod(self, m):
+        """Return 1 if method is abstract, None if not
+           An abstract method always raises an exception.
+        """
+        if not self.methods.get(m, None):
+            return None
+        func_code, bytes, i, maxCode, extended_arg = \
+                   OP.initFuncCode(self.methods[m].function)
+        # abstract if the first opcode is RAISE_VARARGS and it raises
+        # NotImplementedError
+        arg = ""
+        while i < maxCode:
+            op, oparg, i, extended_arg = OP.getInfo(bytes, i, extended_arg)
+            if OP.LOAD_GLOBAL(op):
+                arg = func_code.co_names[oparg]
+            elif OP.RAISE_VARARGS(op):
+                # if we saw NotImplementedError sometime before the raise
+                # assume it's related to this raise stmt
+                return arg == "NotImplementedError"
+            if OP.conditional(op):
+                break
+        return None
+
+    def isAbstract(self):
+        """Return the method names that make a class abstract.
+           An abstract class has at least one abstract method."""
+        result = []
+        for m in self.methods.keys():
+            if self.abstractMethod(m):
+                result.append(m)
+        return result
+
+def _getLineInFile(moduleName, moduleDir, linenum):
+    line = ''
+    file, filename, smt = _findModule(moduleName, moduleDir)
+    if file is None:
+        return ''
+    try:
+        lines = file.readlines()
+        line = string.rstrip(lines[linenum - 1])
+    except (IOError, IndexError):
+        pass
+    file.close()
+    return line
+
+def importError(moduleName, moduleDir=None):
+    exc_type, exc_value, tb = sys.exc_info()
+
+    # First, try to get a nice-looking name for this exception type.
+    exc_name = getattr(exc_type, '__name__', None)
+    if not exc_name:
+        # either it's a string exception or a user-defined exception class
+        # show string or fully-qualified class name
+        exc_name = utils.safestr(exc_type)
+        
+    # Print a traceback, unless this is an ImportError.  ImportError is
+    # presumably the most common import-time exception, so this saves
+    # the clutter of a traceback most of the time.  Also, the locus of
+    # the error is usually irrelevant for ImportError, so the lack of
+    # traceback shouldn't be a problem.
+    if exc_type is SyntaxError:
+        # SyntaxErrors are special, we want to control how we format
+        # the output and make it consistent for all versions of Python
+        e = exc_value
+        msg = '%s (%s, line %d)' % (e.msg, e.filename, e.lineno)
+        line = _getLineInFile(moduleName, moduleDir, e.lineno)
+        offset = e.offset
+        if type(offset) is not types.IntType:
+            offset = 0
+        exc_value = '%s\n    %s\n   %s^' % (msg, line, ' ' * offset)
+    elif exc_type is not ImportError:
+        sys.stderr.write("  Caught exception importing module %s:\n" %
+                         moduleName)
+
+        try:
+            tbinfo = traceback.extract_tb(tb)
+        except:
+            tbinfo = []
+            sys.stderr.write("      Unable to format traceback\n")
+        for filename, line, func, text in tbinfo[1:]:
+            sys.stderr.write("    File \"%s\", line %d" % (filename, line))
+            if func != "?":
+                sys.stderr.write(", in %s()" % func)
+            sys.stderr.write("\n")
+            if text:
+                sys.stderr.write("      %s\n" % text)
+
+    # And finally print the exception type and value.
+    # Careful formatting exc_value -- can fail for some user exceptions
+    sys.stderr.write("  %s: " % exc_name)
+    try:
+        sys.stderr.write(utils.safestr(exc_value) + '\n')
+    except:
+        sys.stderr.write('**error formatting exception value**\n')
+
+
+def _getPyFile(filename):
+    """Return the file and '.py' filename from a filename which could
+    end with .py, .pyc, or .pyo"""
+
+    if filename[-1] in 'oc' and filename[-4:-1] == '.py':
+        return filename[:-1]
+    return filename
+
+class PyCheckerModule :
+    "Class to hold all information for a module"
+
+    def __init__(self, moduleName, check = 1, moduleDir=None) :
+        """
+        @param moduleDir: if specified, the directory where the module can
+                          be loaded from; allows discerning between modules
+                          with the same name in a different directory
+
+        """
+        self.moduleName = moduleName
+        self.moduleDir = moduleDir
+        self.variables = {}
+        self.functions = {}
+        self.classes = {}
+        self.modules = {}
+        self.moduleLineNums = {}
+        self.attributes = [ '__dict__' ]
+        self.main_code = None
+        self.module = None
+        self.check = check
+        # key on a combination of moduleName and moduleDir so we have separate
+        # entries for modules with the same name but in different directories
+        pcmodules.addPCModule(self)
+
+    def __str__(self) :
+        return self.moduleName
+
+    __repr__ = utils.std_repr
+
+    def addVariable(self, var, varType) :
+        self.variables[var] = Variable(var, varType)
+
+    def addFunction(self, func) :
+        self.functions[func.__name__] = function.Function(func)
+
+    def __addAttributes(self, c, classObject) :
+        for base in getattr(classObject, '__bases__', None) or ():
+            self.__addAttributes(c, base)
+        c.addMethods(classObject)
+        c.addMembers(classObject)
+
+    def addClass(self, name) :
+        self.classes[name] = c = Class(name, self)
+        try:
+            objName = utils.safestr(c.classObject)
+        except TypeError:
+            # this can happen if there is a goofy __getattr__
+            c.ignoreAttrs = 1
+        else:
+            packages = string.split(objName, '.')
+            c.ignoreAttrs = packages[0] in cfg().blacklist
+        if not c.ignoreAttrs :
+            self.__addAttributes(c, c.classObject)
+
+    def addModule(self, name, moduleDir=None) :
+        module = pcmodules.getPCModule(name, moduleDir)
+        if module is None :
+            self.modules[name] = module = PyCheckerModule(name, 0)
+            if imp.is_builtin(name) == 0:
+                module.load()
+            else :
+                globalModule = globals().get(name)
+                if globalModule :
+                    module.attributes.extend(dir(globalModule))
+        else :
+            self.modules[name] = module
+
+    def filename(self) :
+        try :
+            filename = self.module.__file__
+        except AttributeError :
+            filename = self.moduleName
+            # FIXME: this would be nice to have, but changes output of
+            # NOT PROCESSED UNABLE TO IMPORT like in test8
+            #if self.moduleDir:
+            #    filename = self.moduleDir + ': ' + filename
+
+        return _getPyFile(filename)
+
+    def load(self):
+        try :
+            # there's no need to reload modules we already have if no moduleDir
+            # is specified for this module
+            if not self.moduleDir:
+                module = sys.modules.get(self.moduleName)
+                if module :
+                    if not pcmodules.getPCModule(self.moduleName).module :
+                        return self._initModule(module)
+                    return 1
+
+            return self._initModule(self.setupMainCode())
+        except (SystemExit, KeyboardInterrupt) :
+            exc_type, exc_value, exc_tb = sys.exc_info()
+            raise exc_type, exc_value
+        except :
+            importError(self.moduleName, self.moduleDir)
+            return cfg().ignoreImportErrors
+
+    def initModule(self, module) :
+        if not self.module:
+            filename = _getPyFile(module.__file__)
+            if string.lower(filename[-3:]) == '.py':
+                try:
+                    file = open(filename)
+                except IOError:
+                    pass
+                else:
+                    self._setupMainCode(file, filename, module)
+            return self._initModule(module)
+        return 1
+
+    def _initModule(self, module):
+        self.module = module
+        self.attributes = dir(self.module)
+
+        pychecker_attr = getattr(module, Config.CHECKER_VAR, None)
+        if pychecker_attr is not None :
+            utils.pushConfig()
+            utils.updateCheckerArgs(pychecker_attr, 'suppressions', 0, [])
+
+        for tokenName in _filterDir(self.module, _DEFAULT_MODULE_TOKENS) :
+            if _EVIL_C_OBJECTS.has_key('%s.%s' % (self.moduleName, tokenName)):
+                continue
+
+            # README if interpreter is crashing:
+            # Change 0 to 1 if the interpretter is crashing and re-run.
+            # Follow the instructions from the last line printed.
+            if _cfg.findEvil:
+                print "Add the following line to _EVIL_C_OBJECTS or the string to evil in a config file:\n" \
+                      "    '%s.%s': None, " % (self.moduleName, tokenName)
+
+            token = getattr(self.module, tokenName)
+            if isinstance(token, types.ModuleType) :
+                # get the real module name, tokenName could be an alias
+                self.addModule(token.__name__)
+            elif isinstance(token, types.FunctionType) :
+                self.addFunction(token)
+            elif isinstance(token, types.ClassType) or \
+                 hasattr(token, '__bases__') and \
+                 issubclass(type(token), type):
+                self.addClass(tokenName)
+            else :
+                self.addVariable(tokenName, type(token))
+
+        if pychecker_attr is not None :
+            utils.popConfig()
+        return 1
+
+    def setupMainCode(self) :
+        file, filename, smt = _findModule(self.moduleName, self.moduleDir)
+        # FIXME: if the smt[-1] == imp.PKG_DIRECTORY : load __all__
+        # HACK: to make sibling imports work, we add self.moduleDir to sys.path
+        # temporarily, and remove it later
+        if self.moduleDir:
+            oldsyspath = sys.path[:]
+            sys.path.insert(0, self.moduleDir)
+        module = imp.load_module(self.moduleName, file, filename, smt)
+        if self.moduleDir:
+            sys.path = oldsyspath
+            # to make sure that subsequent modules with the same moduleName
+            # do not persist, and get their namespace clobbered, delete it
+            del sys.modules[self.moduleName]
+
+        self._setupMainCode(file, filename, module)
+        return module
+
+    def _setupMainCode(self, file, filename, module):
+        try :
+            self.main_code = function.create_from_file(file, filename, module)
+        finally :
+            if file != None :
+                file.close()
+
+
+def getAllModules() :
+    "Returns a list of all modules that should be checked."
+    modules = []
+    for module in pcmodules.getPCModules():
+        if module.check :
+            modules.append(module)
+    return modules
+
+_BUILTIN_MODULE_ATTRS = { 'sys': [ 'ps1', 'ps2', 'tracebacklimit', 
+                                   'exc_type', 'exc_value', 'exc_traceback',
+                                   'last_type', 'last_value', 'last_traceback',
+                                 ],
+                        }
+
+def fixupBuiltinModules(needs_init=0):
+    for moduleName in sys.builtin_module_names :
+        # Skip sys since it will reset sys.stdout in IDLE and cause
+        # stdout to go to the real console rather than the IDLE console.
+        # FIXME: this breaks test42
+        # if moduleName == 'sys':
+        #     continue
+
+        if needs_init:
+            _ = PyCheckerModule(moduleName, 0)
+        # builtin modules don't have a moduleDir
+        module = pcmodules.getPCModule(moduleName)
+        if module is not None :
+            try :
+                m = imp.init_builtin(moduleName)
+            except ImportError :
+                pass
+            else :
+                extra_attrs = _BUILTIN_MODULE_ATTRS.get(moduleName, [])
+                module.attributes = [ '__dict__' ] + dir(m) + extra_attrs
+
+
+def _printWarnings(warnings, stream=None):
+    if stream is None:
+        stream = sys.stdout
+    
+    warnings.sort()
+    lastWarning = None
+    for warning in warnings :
+        if lastWarning is not None:
+            # ignore duplicate warnings
+            if cmp(lastWarning, warning) == 0:
+                continue
+            # print blank line between files
+            if lastWarning.file != warning.file:
+                stream.write("\n")
+
+        lastWarning = warning
+        warning.output(stream)
+
+
+class NullModule:
+    def __getattr__(self, unused_attr):
+        return None
+
+def install_ignore__import__():
+
+    _orig__import__ = None
+
+    def __import__(name, globals=None, locals=None, fromlist=None):
+        if globals is None:
+            globals = {}
+        if locals is None:
+            locals = {}
+        if fromlist is None:
+            fromlist = ()
+
+        try:
+            pymodule = _orig__import__(name, globals, locals, fromlist)
+        except ImportError:
+            pymodule = NullModule()
+            if not _cfg.quiet:
+                modname = '.'.join((name,) + fromlist)
+                sys.stderr.write("Can't import module: %s, ignoring.\n" % modname)
+        return pymodule
+
+    # keep the orig __import__ around so we can call it
+    import __builtin__
+    _orig__import__ = __builtin__.__import__
+    __builtin__.__import__ = __import__
+
+def processFiles(files, cfg = None, pre_process_cb = None) :
+    # insert this here, so we find files in the local dir before std library
+    if sys.path[0] != '' :
+        sys.path.insert(0, '')
+
+    # ensure we have a config object, it's necessary
+    global _cfg
+    if cfg is not None :
+        _cfg = cfg
+    elif _cfg is None :
+        _cfg = Config.Config()
+
+    if _cfg.ignoreImportErrors:
+        install_ignore__import__()
+
+    warnings = []
+    utils.initConfig(_cfg)
+    for file, (moduleName, moduleDir) in zip(files, getModules(files)) :
+        if callable(pre_process_cb) :
+            pre_process_cb("module %s (%s)" % (moduleName, file))
+        oldsyspath = sys.path[:]
+        sys.path.insert(0, moduleDir)
+        module = PyCheckerModule(moduleName, moduleDir=moduleDir)
+        if not module.load() :
+            w = Warning(module.filename(), 1,
+                        msgs.Internal("NOT PROCESSED UNABLE TO IMPORT"))
+            warnings.append(w)
+        sys.path = oldsyspath
+    utils.popConfig()
+    return warnings
+
+
+def getWarnings(files, cfg = None, suppressions = None):
+    warnings = processFiles(files, cfg)
+    fixupBuiltinModules()
+    return warnings + warn.find(getAllModules(), _cfg, suppressions)
+
+
+def _print_processing(name) :
+    if not _cfg.quiet :
+        sys.stderr.write("Processing %s...\n" % name)
+
+
+def main(argv) :
+    __pychecker__ = 'no-miximport'
+    import pychecker
+    if LOCAL_MAIN_VERSION != pychecker.MAIN_MODULE_VERSION :
+        sys.stderr.write(_VERSION_MISMATCH_ERROR)
+        sys.exit(100)
+
+    # remove empty arguments
+    argv = filter(None, argv)
+        
+    # if the first arg starts with an @, read options from the file
+    # after the @ (this is mostly for windows)
+    if len(argv) >= 2 and argv[1][0] == '@':
+        # read data from the file
+        command_file = argv[1][1:]
+        try:
+            f = open(command_file, 'r')
+            command_line = f.read()
+            f.close()
+        except IOError, err:
+            sys.stderr.write("Unable to read commands from file: %s\n  %s\n" % \
+                             (command_file, err))
+            sys.exit(101)
+
+        # convert to an argv list, keeping argv[0] and the files to process
+        argv = argv[:1] + string.split(command_line) + argv[2:]
+ 
+    global _cfg
+    _cfg, files, suppressions = Config.setupFromArgs(argv[1:])
+    if not files :
+        return 0
+
+    # Now that we've got the args, update the list of evil C objects
+    for evil_doer in _cfg.evil:
+        _EVIL_C_OBJECTS[evil_doer] = None
+
+    # insert this here, so we find files in the local dir before std library
+    sys.path.insert(0, '')
+
+    importWarnings = processFiles(files, _cfg, _print_processing)
+    fixupBuiltinModules()
+    if _cfg.printParse :
+        for module in getAllModules() :
+            printer.module(module)
+
+    warnings = warn.find(getAllModules(), _cfg, suppressions)
+    if not _cfg.quiet :
+        print "\nWarnings...\n"
+    if warnings or importWarnings :
+        _printWarnings(importWarnings + warnings)
+        return 1
+
+    if not _cfg.quiet :
+        print "None"
+    return 0
+
+
+if __name__ == '__main__' :
+    try :
+        sys.exit(main(sys.argv))
+    except Config.UsageError :
+        sys.exit(127)
+
+else :
+    _orig__import__ = None
+    _suppressions = None
+    _warnings_cache = {}
+
+    def _get_unique_warnings(warnings):
+        for i in range(len(warnings)-1, -1, -1):
+            w = warnings[i].format()
+            if _warnings_cache.has_key(w):
+                del warnings[i]
+            else:
+                _warnings_cache[w] = 1
+        return warnings
+
+    def __import__(name, globals=None, locals=None, fromlist=None):
+        if globals is None:
+            globals = {}
+        if locals is None:
+            locals = {}
+        if fromlist is None:
+            fromlist = []
+
+        check = not sys.modules.has_key(name) and name[:10] != 'pychecker.'
+        pymodule = _orig__import__(name, globals, locals, fromlist)
+        if check :
+            try :
+                # FIXME: can we find a good moduleDir ?
+                module = PyCheckerModule(pymodule.__name__)
+                if module.initModule(pymodule):
+                    warnings = warn.find([module], _cfg, _suppressions)
+                    _printWarnings(_get_unique_warnings(warnings))
+                else :
+                    print 'Unable to load module', pymodule.__name__
+            except Exception:
+                name = getattr(pymodule, '__name__', utils.safestr(pymodule))
+                # FIXME: can we use it here ?
+                importError(name)
+
+        return pymodule
+
+    def _init() :
+        global _cfg, _suppressions, _orig__import__
+
+        args = string.split(os.environ.get('PYCHECKER', ''))
+        _cfg, files, _suppressions = Config.setupFromArgs(args)
+        utils.initConfig(_cfg)
+        fixupBuiltinModules(1)
+
+        # keep the orig __import__ around so we can call it
+        import __builtin__
+        _orig__import__ = __builtin__.__import__
+        __builtin__.__import__ = __import__
+
+    if not os.environ.get('PYCHECKER_DISABLED') :
+        _init()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/function.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/function.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/function.py
new file mode 100644
index 0000000..73a3ecf
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/function.py
@@ -0,0 +1,159 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2001-2002, MetaSlash Inc.  All rights reserved.
+
+"""
+Object to hold information about functions.
+Also contain a pseudo Python function object
+"""
+
+import string
+
+_ARGS_ARGS_FLAG = 4
+_KW_ARGS_FLAG = 8
+_CO_FLAGS_MASK = _ARGS_ARGS_FLAG + _KW_ARGS_FLAG
+
+class _ReturnValues:
+    def __init__(self):
+        self.returnValues = None
+
+    def returnsNoValue(self):
+        returnValues = self.returnValues
+        # if unset, we don't know
+        if returnValues is None:
+            return 0
+        # it's an empty list, that means no values
+        if not returnValues:
+            return 1
+        # make sure each value is not None
+        for rv in returnValues:
+            if not rv[1].isNone():
+                return 0
+        return returnValues[-1][1].isImplicitNone()
+
+class FakeCode :
+    "This is a holder class for code objects (so we can modify them)"
+    def __init__(self, code, varnames = None) :
+        for attr in dir(code):
+            try:
+                setattr(self, attr, getattr(code, attr))
+            except:
+                pass
+        if varnames is not None:
+            self.co_varnames = varnames
+
+class FakeFunction(_ReturnValues):
+    "This is a holder class for turning code at module level into a function"
+
+    def __init__(self, name, code, func_globals = {}, varnames = None) :
+        _ReturnValues.__init__(self)
+        self.func_name = self.__name__ = name
+        self.func_doc  = self.__doc__  = "ignore"
+
+        self.func_code = FakeCode(code, varnames)
+        self.func_defaults = None
+        self.func_globals = func_globals
+
+    def __str__(self):
+        return self.func_name
+
+    def __repr__(self):
+        return '%s from %r' % (self.func_name, self.func_code.co_filename)
+
+class Function(_ReturnValues):
+    "Class to hold all information about a function"
+
+    def __init__(self, function, isMethod=0):
+        _ReturnValues.__init__(self)
+        self.function = function
+        self.isMethod = isMethod
+        self.minArgs = self.maxArgs = function.func_code.co_argcount
+        if function.func_defaults is not None :
+            self.minArgs = self.minArgs - len(function.func_defaults)
+        # if function uses *args, there is no max # args
+        try:
+            if function.func_code.co_flags & _ARGS_ARGS_FLAG != 0 :
+                self.maxArgs = None
+            self.supportsKW = function.func_code.co_flags & _KW_ARGS_FLAG
+        except AttributeError:
+            # this happens w/Zope
+            self.supportsKW = 0
+
+    def __str__(self):
+        return self.function.func_name
+
+    def __repr__(self):
+        return '%s from %r:%d' % (self.function.func_name,
+                                  self.function.func_code.co_filename,
+                                  self.function.func_code.co_firstlineno)
+
+    def arguments(self) :
+        numArgs = self.function.func_code.co_argcount
+        if self.maxArgs is None :
+            numArgs = numArgs + 1
+        if self.supportsKW :
+            numArgs = numArgs + 1
+        return self.function.func_code.co_varnames[:numArgs]
+        
+    def isParam(self, name) :
+        return name in self.arguments()
+
+    def isStaticMethod(self):
+        return self.isMethod and isinstance(self.function, type(create_fake))
+
+    def isClassMethod(self):
+        try:
+            return self.isMethod and self.function.im_self is not None
+        except AttributeError:
+            return 0
+
+    def defaultValue(self, name) :
+        func_code = self.function.func_code
+        arg_names = list(func_code.co_varnames[:func_code.co_argcount])
+        i = arg_names.index(name)
+        if i < self.minArgs :
+            raise ValueError
+        return self.function.func_defaults[i - self.minArgs]
+
+    def varArgName(self) :
+        if self.maxArgs is not None :
+            return None
+        func_code = self.function.func_code
+        return func_code.co_varnames[func_code.co_argcount]
+
+def create_fake(name, code, func_globals = {}, varnames = None) :
+    return Function(FakeFunction(name, code, func_globals, varnames))
+
+def create_from_file(file, filename, module) :
+    if file is None:
+        return create_fake(filename, compile('', filename, 'exec'))
+
+    # Make sure the file is at the beginning
+    #   if python compiled the file, it will be at the end
+    file.seek(0)
+
+    # Read in the source file, see py_compile.compile() for games w/src str
+    codestr = file.read()
+    codestr = string.replace(codestr, "\r\n", "\n")
+    codestr = string.replace(codestr, "\r", "\n")
+    if codestr and codestr[-1] != '\n' :
+        codestr = codestr + '\n'
+    code = compile(codestr, filename, 'exec')
+    return Function(FakeFunction('__main__', code, module.__dict__))
+
+def _co_flags_equal(o1, o2) :
+    return (o1.co_flags & _CO_FLAGS_MASK) == (o2.co_flags & _CO_FLAGS_MASK)
+    
+def same_signature(func, object) :
+    '''Return a boolean value if the <func> has the same signature as
+       a function with the same name in <object> (ie, an overriden method)'''
+
+    try :
+        baseMethod = getattr(object, func.func_name)
+        base_func_code = baseMethod.im_func.func_code
+    except AttributeError :
+        return 1
+
+    return _co_flags_equal(base_func_code, func.func_code) and \
+           base_func_code.co_argcount == func.func_code.co_argcount
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/80e25b46/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/msgs.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/msgs.py b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/msgs.py
new file mode 100644
index 0000000..8491afb
--- /dev/null
+++ b/tools/bin/pythonSrc/pychecker-0.8.18/pychecker/msgs.py
@@ -0,0 +1,175 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2001-2004, MetaSlash Inc.  All rights reserved.
+# Portions Copyright (c) 2005, Google, Inc.  All rights reserved.
+
+"""
+Warning Messages for PyChecker
+"""
+
+import UserString
+
+class WarningClass:
+  level = 0
+
+  def __init__(self, msg, level_offset=None):
+    self.msg = msg
+    if level_offset is not None:
+      self.level += level_offset
+
+  def __mod__(self, args):
+    result = UserString.UserString(self.msg % args)
+    result.level = self.level
+    return result
+
+  def __str__(self):
+    return self.msg
+
+class Internal(WarningClass):
+  level = 100
+
+class Error(WarningClass):
+  level = 90
+
+class Security(WarningClass):
+  level = 90
+
+class Warning(WarningClass):
+  level = 70
+
+class Unused(WarningClass):
+  level = 50
+
+class Deprecated(WarningClass):
+  level = 40
+
+class Style(WarningClass):
+  level = 10
+
+TOO_MANY_WARNINGS = WarningClass("%d errors suppressed, use -#/--limit to increase the number of errors displayed")
+CHECKER_BROKEN = Internal("INTERNAL ERROR -- STOPPED PROCESSING FUNCTION --\n\t%s")
+INVALID_CHECKER_ARGS = Internal("Invalid warning suppression arguments --\n\t%s")
+
+NO_MODULE_DOC = Style("No module doc string")
+NO_CLASS_DOC = Style("No doc string for class %s")
+NO_FUNC_DOC = Style("No doc string for function %s")
+
+VAR_NOT_USED = Unused("Variable (%s) not used")
+IMPORT_NOT_USED = Unused("Imported module (%s) not used")
+UNUSED_LOCAL = Unused("Local variable (%s) not used")
+UNUSED_PARAMETER = Unused("Parameter (%s) not used")
+UNUSED_MEMBERS = Unused("Members (%s) not used in class (%s)")
+NO_LOCAL_VAR = Unused("No local variable (%s)")
+VAR_USED_BEFORE_SET = Warning("Variable (%s) used before being set")
+
+REDEFINING_ATTR = Warning("Redefining attribute (%s) original line (%d)")
+
+MODULE_IMPORTED_AGAIN = Warning("Module (%s) re-imported")
+MODULE_MEMBER_IMPORTED_AGAIN = Warning("Module member (%s) re-imported")
+MODULE_MEMBER_ALSO_STAR_IMPORTED = Warning("Module member (%s) re-imported with *")
+MIX_IMPORT_AND_FROM_IMPORT = Warning("Using import and from ... import for (%s)")
+IMPORT_SELF = Warning("Module (%s) imports itself")
+
+NO_METHOD_ARGS = Error("No method arguments, should have %s as argument")
+SELF_NOT_FIRST_ARG = Error("%s is not first %smethod argument")
+SELF_IS_ARG = Error("self is argument in %s")
+RETURN_FROM_INIT = Error("Cannot return a value from __init__")
+NO_CTOR_ARGS = Error("Instantiating an object with arguments, but no constructor")
+
+GLOBAL_DEFINED_NOT_DECLARED = Warning("Global variable (%s) not defined in module scope")
+INVALID_GLOBAL = Error("No global (%s) found")
+INVALID_METHOD = Error("No method (%s) found")
+INVALID_CLASS_ATTR = Warning("No class attribute (%s) found")
+INVALID_SET_CLASS_ATTR = Warning("Setting class attribute (%s) not set in __init__")
+INVALID_MODULE_ATTR = Error("No module attribute (%s) found")
+
+LOCAL_SHADOWS_GLOBAL = Warning("Local variable (%s) shadows global defined on line %d")
+VARIABLE_SHADOWS_BUILTIN = Warning("(%s) shadows builtin")
+USING_METHOD_AS_ATTR = Warning("Using method (%s) as an attribute (not invoked)")
+OBJECT_HAS_NO_ATTR = Warning("Object (%s) has no attribute (%s)")
+METHOD_SIGNATURE_MISMATCH = Warning("Overridden method (%s) doesn't match signature in class (%s)")
+
+INVALID_ARG_COUNT1 = Error("Invalid arguments to (%s), got %d, expected %d")
+INVALID_ARG_COUNT2 = Error("Invalid arguments to (%s), got %d, expected at least %d")
+INVALID_ARG_COUNT3 = Error("Invalid arguments to (%s), got %d, expected between %d and %d")
+FUNC_DOESNT_SUPPORT_KW = Error("Function (%s) doesn't support **kwArgs")
+FUNC_DOESNT_SUPPORT_KW_ARG = Error("Function (%s) doesn't support **kwArgs for name (%s)")
+FUNC_USES_NAMED_ARGS = Warning("Function (%s) uses named arguments")
+
+BASE_CLASS_NOT_INIT = Warning("Base class (%s) __init__() not called")
+NO_INIT_IN_SUBCLASS = Warning("No __init__() in subclass (%s)")
+METHODS_NEED_OVERRIDE = Error("Methods (%s) in %s need to be overridden in a subclass")
+
+FUNC_TOO_LONG = Style("Function (%s) has too many lines (%d)")
+TOO_MANY_BRANCHES = Style("Function (%s) has too many branches (%d)")
+TOO_MANY_RETURNS = Style("Function (%s) has too many returns (%d)")
+TOO_MANY_ARGS = Style("Function (%s) has too many arguments (%d)")
+TOO_MANY_LOCALS = Style("Function (%s) has too many local variables (%d)")
+TOO_MANY_REFERENCES = Style('Law of Demeter violated, more than %d references for (%s)')
+
+IMPLICIT_AND_EXPLICIT_RETURNS = Warning("Function returns a value and also implicitly returns None")
+INCONSISTENT_RETURN_TYPE = Warning("Function return types are inconsistent")
+INCONSISTENT_TYPE = Warning("Variable (%s) already has types %s and set to %s")
+CODE_UNREACHABLE = Error("Code appears to be unreachable")
+CONSTANT_CONDITION = Warning("Using a conditional statement with a constant value (%s)")
+STRING_ITERATION = Warning("Iterating over a string (%s)")
+DONT_RETURN_NONE = Error("%s should not return None, raise an exception if not found")
+IS_LITERAL = Warning("Using is%s %s, may not always work")
+INVALID_FORMAT = Error("Invalid format string, problem starts near: '%s'")
+INVALID_FORMAT_COUNT = Error("Format string argument count (%d) doesn't match arguments (%d)")
+TOO_MANY_STARS_IN_FORMAT = Error("Too many *s in format flags")
+USING_STAR_IN_FORMAT_MAPPING = Error("Can't use * in formats when using a mapping (dictionary), near: '%s'")
+CANT_MIX_MAPPING_IN_FORMATS = Error("Can't mix tuple/mapping (dictionary) formats in same format string")
+
+INTEGER_DIVISION = Warning("Using integer division (%s / %s) may return integer or float")
+MODULO_1 = Warning("... % 1 may be constant")
+USING_TUPLE_ACCESS_TO_LIST = Error("Using a tuple instead of slice as list accessor for (%s)")
+BOOL_COMPARE = Warning("Comparisons with %s are not necessary and may not work as expected")
+SHOULDNT_ASSIGN_BUILTIN = Deprecated("Should not assign to %s, it is (or will be) a builtin")
+SHOULDNT_ASSIGN_NAME = Deprecated("Should not assign to %s, it is similar to builtin %s")
+SET_VAR_TO_ITSELF = Warning("Setting %s to itself has no effect")
+MODIFY_VAR_NOOP = Warning("%s %s %s has no effect")
+DIVIDE_VAR_BY_ITSELF = Warning("%s %s %s is always 1 or ZeroDivisionError")
+XOR_VAR_WITH_ITSELF = Warning("%s %s %s is always 0")
+
+STMT_WITH_NO_EFFECT = Error("Operator (%s) doesn't exist, statement has no effect")
+POSSIBLE_STMT_WITH_NO_EFFECT = Error("Statement appears to have no effect")
+UNARY_POSITIVE_HAS_NO_EFFECT = Error("Unary positive (+) usually has no effect")
+LIST_APPEND_ARGS = Error("[].append() only takes 1 argument in Python 1.6 and above for (%s)")
+
+LOCAL_DELETED = Error("(%s) cannot be used after being deleted on line %d")
+LOCAL_ALREADY_DELETED = Error("Local variable (%s) has already been deleted on line %d")
+VAR_DELETED_BEFORE_SET = Error("Variable (%s) deleted before being set")
+
+CATCH_BAD_EXCEPTION = Warning("Catching a non-Exception object (%s)")
+CATCH_STR_EXCEPTION = Deprecated("Catching string exceptions are deprecated (%s)")
+RAISE_BAD_EXCEPTION = Warning("Raising an exception on a non-Exception object (%s)")
+RAISE_STR_EXCEPTION = Deprecated("Raising string exceptions are deprecated (%s)")
+SET_EXCEPT_TO_BUILTIN = Error("Setting exception to builtin (%s), consider () around exceptions")
+USING_KEYWORD = Warning("Using identifier (%s) which will become a keyword in version %s")
+MODIFYING_DEFAULT_ARG = Warning("Modifying parameter (%s) with a default value may have unexpected consequences")
+USING_SELF_IN_REPR = Warning("Using `self` in __repr__ method")
+USING_NONE_RETURN_VALUE = Error("Using the return value from (%s) which is always None")
+WRONG_UNPACK_SIZE = Error("Unpacking %d values into %d variables")
+WRONG_UNPACK_FUNCTION = Error("Unpacking function (%s) which returns %d values into %d variables")
+UNPACK_NON_SEQUENCE = Error("Unpacking a non-sequence (%s) of type %s")
+
+NOT_SPECIAL_METHOD = Warning("%s is not a special method")
+USING_COERCE_IN_NEW_CLASS = Error("Using __coerce__ in new-style class (%s) will not work for binary operations")
+USING_NEW_STYLE_METHOD_IN_OLD_CLASS = Error("Using %s in old-style class (%s) does not work")
+USING_PROPERTIES_IN_CLASSIC_CLASS = Error("Using property (%s) in classic class %s may not work")
+USING_SLOTS_IN_CLASSIC_CLASS = Error("Using __slots__ in classic class %s has no effect, consider deriving from object")
+EMPTY_SLOTS = Warning("__slots__ are empty in %s")
+
+USES_EXEC = Security("Using the exec statement")
+USES_GLOBAL_EXEC = Security("Using the exec statement in global namespace")
+USES_INPUT = Security("Using input() is a security problem, consider using raw_input()")
+
+USING_DEPRECATED_MODULE = Deprecated("%s module is deprecated")
+USING_DEPRECATED_ATTR = Deprecated("%s is deprecated")
+USING_INSECURE_FUNC = Security("%s() is a security problem")
+USE_INSTEAD = ", consider using %s"
+
+USES_CONST_ATTR = Warning("Passing a constant string to %s, consider direct reference")
+
+BAD_STRING_FIND = Error("string.find() returns an integer, consider checking >= 0 or < 0 for not found")