hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [21/28] incubator-hawq git commit: HAWQ-837. Add python modules into HAWQ code
Date Tue, 21 Jun 2016 02:41:37 GMT
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)
+


Mime
View raw message