Import of pkgsrc-2016Q3

This commit is contained in:
2016-10-14 07:49:11 +02:00
committed by Lionel Sambuc
parent 9d819b6d54
commit 1242aa1e36
35952 changed files with 949749 additions and 377083 deletions

View File

@@ -1,22 +1,27 @@
# $NetBSD: Makefile,v 1.11 2015/01/24 23:23:48 adam Exp $
# $NetBSD: Makefile,v 1.18 2016/04/29 15:33:57 prlw1 Exp $
DISTNAME= psutil-2.1.3
PKGNAME= ${PYPKGPREFIX}-${DISTNAME}
DISTNAME= psutil-release-4.1.0
PKGNAME= ${PYPKGPREFIX}-${DISTNAME:S/-release//}
CATEGORIES= sysutils
MASTER_SITES= https://pypi.python.org/packages/source/p/psutil/
MASTER_SITES= ${MASTER_SITE_GITHUB:=giampaolo/}
GITHUB_PROJECT= psutil
GITHUB_TAG= release-${PKGVERSION_NOREV}
MAINTAINER= pkgsrc-users@NetBSD.org
HOMEPAGE= http://code.google.com/p/psutil/
HOMEPAGE= https://github.com/giampaolo/psutil
COMMENT= Cross-platform process and system utilities module for Python
LICENSE= modified-bsd
REPLACE_PYTHON= psutil/*py
EGG_NAME= psutil-${PKGVERSION_NOREV}
.include "../../mk/bsd.prefs.mk"
# facilitate PLIST processing
.if ${OPSYS} == "Darwin"
PLIST_SUBST+= SYSTEM=osx
.elif !empty(OPSYS:M*BSD)
PLIST_SUBST+= SYSTEM=bsd
.else
PLIST_SUBST+= SYSTEM=${OPSYS:tl}
.endif

View File

@@ -1,6 +1,4 @@
@comment $NetBSD: PLIST,v 1.5 2015/01/24 23:23:48 adam Exp $
${PYSITELIB}/_psutil_${SYSTEM}.so
${PYSITELIB}/_psutil_posix.so
@comment $NetBSD: PLIST,v 1.8 2016/04/29 15:33:57 prlw1 Exp $
${PYSITELIB}/${EGG_INFODIR}/PKG-INFO
${PYSITELIB}/${EGG_INFODIR}/SOURCES.txt
${PYSITELIB}/${EGG_INFODIR}/dependency_links.txt
@@ -20,9 +18,6 @@ ${PYSITELIB}/psutil/_psbsd.pyo
${PYSITELIB}/psutil/_pslinux.py
${PYSITELIB}/psutil/_pslinux.pyc
${PYSITELIB}/psutil/_pslinux.pyo
${PYSITELIB}/psutil/_psnetbsd.py
${PYSITELIB}/psutil/_psnetbsd.pyc
${PYSITELIB}/psutil/_psnetbsd.pyo
${PYSITELIB}/psutil/_psosx.py
${PYSITELIB}/psutil/_psosx.pyc
${PYSITELIB}/psutil/_psosx.pyo
@@ -32,6 +27,44 @@ ${PYSITELIB}/psutil/_psposix.pyo
${PYSITELIB}/psutil/_pssunos.py
${PYSITELIB}/psutil/_pssunos.pyc
${PYSITELIB}/psutil/_pssunos.pyo
${PYSITELIB}/psutil/_psutil_${SYSTEM}.so
${PYSITELIB}/psutil/_psutil_posix.so
${PYSITELIB}/psutil/_pswindows.py
${PYSITELIB}/psutil/_pswindows.pyc
${PYSITELIB}/psutil/_pswindows.pyo
${PYSITELIB}/psutil/tests/__init__.py
${PYSITELIB}/psutil/tests/__init__.pyc
${PYSITELIB}/psutil/tests/__init__.pyo
${PYSITELIB}/psutil/tests/runner.py
${PYSITELIB}/psutil/tests/runner.pyc
${PYSITELIB}/psutil/tests/runner.pyo
${PYSITELIB}/psutil/tests/test_bsd.py
${PYSITELIB}/psutil/tests/test_bsd.pyc
${PYSITELIB}/psutil/tests/test_bsd.pyo
${PYSITELIB}/psutil/tests/test_linux.py
${PYSITELIB}/psutil/tests/test_linux.pyc
${PYSITELIB}/psutil/tests/test_linux.pyo
${PYSITELIB}/psutil/tests/test_memory_leaks.py
${PYSITELIB}/psutil/tests/test_memory_leaks.pyc
${PYSITELIB}/psutil/tests/test_memory_leaks.pyo
${PYSITELIB}/psutil/tests/test_misc.py
${PYSITELIB}/psutil/tests/test_misc.pyc
${PYSITELIB}/psutil/tests/test_misc.pyo
${PYSITELIB}/psutil/tests/test_osx.py
${PYSITELIB}/psutil/tests/test_osx.pyc
${PYSITELIB}/psutil/tests/test_osx.pyo
${PYSITELIB}/psutil/tests/test_posix.py
${PYSITELIB}/psutil/tests/test_posix.pyc
${PYSITELIB}/psutil/tests/test_posix.pyo
${PYSITELIB}/psutil/tests/test_process.py
${PYSITELIB}/psutil/tests/test_process.pyc
${PYSITELIB}/psutil/tests/test_process.pyo
${PYSITELIB}/psutil/tests/test_sunos.py
${PYSITELIB}/psutil/tests/test_sunos.pyc
${PYSITELIB}/psutil/tests/test_sunos.pyo
${PYSITELIB}/psutil/tests/test_system.py
${PYSITELIB}/psutil/tests/test_system.pyc
${PYSITELIB}/psutil/tests/test_system.pyo
${PYSITELIB}/psutil/tests/test_windows.py
${PYSITELIB}/psutil/tests/test_windows.pyc
${PYSITELIB}/psutil/tests/test_windows.pyo

View File

@@ -1,13 +1,8 @@
$NetBSD: distinfo,v 1.8 2015/01/24 23:01:29 adam Exp $
$NetBSD: distinfo,v 1.16 2016/04/29 15:33:57 prlw1 Exp $
SHA1 (psutil-2.1.3.tar.gz) = aae4725eb33cf56d4480bc60f50c147870d607ba
RMD160 (psutil-2.1.3.tar.gz) = 4d5d0971c7acbd81cd883eceb237b688a60d3b80
Size (psutil-2.1.3.tar.gz) = 224008 bytes
SHA1 (patch-psutil_____init____.py) = 4036989d048542eb2b5649c6398146369d2793a5
SHA1 (patch-psutil___psnetbsd.py) = 1a017104b6ac800de1a47ccb810d5a56b2bde66a
SHA1 (patch-psutil___psutil__netbsd.c) = 00480e009800bb1970592c8bcfbef17d7ac79240
SHA1 (patch-psutil___psutil__netbsd.h) = 33e3c857f764d8391db747068ade7ea333698ec0
SHA1 (patch-psutil_arch_netbsd_process__info.c) = c384d12cc47514d6396d779d59c586ef2b42a89a
SHA1 (patch-psutil_arch_netbsd_process__info.h) = b23075df15749e4e5274ccb9e21d67ac55fdd199
SHA1 (patch-setup.py) = 3e87561b6dfd7e851e232342dab3b2e8ade28cfd
SHA1 (patch-test_test__psutil.py) = c521f4fa30b24cb86115370e52979c2c7f7af4a3
SHA1 (psutil-release-4.1.0.tar.gz) = 3f1c5f9c75fcaad72ce9f3465e77d7b9e191c732
RMD160 (psutil-release-4.1.0.tar.gz) = c092eaff3d575c5e4f73206026d2f2087c2f025d
SHA512 (psutil-release-4.1.0.tar.gz) = 98becc6d150de8580699ea348396f843f552f50a95acdebb42ff30c6a9d968a3b69b2e0162404fcb2e27a3573feaa1f03a12d1715899c0759c5aeb03f5635c43
Size (psutil-release-4.1.0.tar.gz) = 292325 bytes
SHA1 (patch-psutil___psutil__bsd.c) = 20665e0e5cf13280a61064a29a8b77eeb38a3ad4
SHA1 (patch-psutil_arch_bsd_netbsd.c) = fbbabddd7a548e8ff1e8e958298f543c3fd1a4cd

View File

@@ -1,16 +0,0 @@
$NetBSD: patch-psutil_____init____.py,v 1.2 2014/10/01 11:53:33 wiz Exp $
Port to NetBSD.
--- psutil/__init__.py.orig 2014-07-15 15:23:11.000000000 +0000
+++ psutil/__init__.py
@@ -150,6 +150,9 @@ elif sys.platform.startswith("darwin"):
elif sys.platform.startswith("freebsd"):
import psutil._psbsd as _psplatform
+elif sys.platform.startswith("netbsd"):
+ import psutil._psnetbsd as _psplatform
+
elif sys.platform.startswith("sunos"):
import psutil._pssunos as _psplatform
from psutil._pssunos import (CONN_IDLE, # NOQA

View File

@@ -1,373 +0,0 @@
$NetBSD: patch-psutil___psnetbsd.py,v 1.2 2015/01/24 23:01:29 adam Exp $
Port to NetBSD.
--- psutil/_psnetbsd.py.orig 2013-10-12 13:19:29.000000000 +0000
+++ psutil/_psnetbsd.py
@@ -0,0 +1,366 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""NetBSD platform implementation."""
+
+import errno
+import os
+import sys
+import warnings
+
+import _psutil_netbsd
+import _psutil_posix
+from psutil import _psposix
+from psutil._compat import namedtuple, wraps
+from psutil._common import *
+
+__extra__all__ = []
+
+# --- constants
+
+# Since these constants get determined at import time we do not want to
+# crash immediately; instead we'll set them to None and most likely
+# we'll crash later as they're used for determining process CPU stats
+# and creation_time
+try:
+ NUM_CPUS = _psutil_netbsd.get_num_cpus()
+except Exception:
+ NUM_CPUS = None
+ warnings.warn("couldn't determine platform's NUM_CPUS", RuntimeWarning)
+try:
+ TOTAL_PHYMEM = _psutil_netbsd.get_virtual_mem()[0]
+except Exception:
+ TOTAL_PHYMEM = None
+ warnings.warn("couldn't determine platform's TOTAL_PHYMEM", RuntimeWarning)
+try:
+ BOOT_TIME = _psutil_netbsd.get_system_boot_time()
+except Exception:
+ BOOT_TIME = None
+ warnings.warn("couldn't determine platform's BOOT_TIME", RuntimeWarning)
+
+
+_PAGESIZE = os.sysconf("SC_PAGE_SIZE")
+_cputimes_ntuple = namedtuple('cputimes', 'user nice system idle irq')
+
+# --- public functions
+
+get_system_boot_time = _psutil_netbsd.get_system_boot_time
+
+nt_virtmem_info = namedtuple('vmem', ' '.join([
+ # all platforms
+ 'total', 'available', 'percent', 'used', 'free',
+ # *BSD specific
+ 'active',
+ 'inactive',
+ 'shared',
+ 'wired']))
+
+def virtual_memory():
+ """System virtual memory as a namedutple."""
+ mem = _psutil_netbsd.get_virtual_mem()
+ total, free, active, inactive, wired, shared = mem
+ avail = inactive + free
+ used = active + wired
+ percent = usage_percent((total - avail), total, _round=1)
+ return nt_virtmem_info(total, avail, percent, used, free,
+ active, inactive, shared, wired)
+
+def swap_memory():
+ """System swap memory as (total, used, free, sin, sout) namedtuple."""
+ total, used, free, sin, sout = \
+ [x * _PAGESIZE for x in _psutil_netbsd.get_swap_mem()]
+ percent = usage_percent(used, total, _round=1)
+ return nt_swapmeminfo(total, used, free, percent, sin, sout)
+
+def cpu_times():
+ """Return system per-CPU times as a named tuple"""
+ user, nice, system, idle, irq = _psutil_netbsd.get_system_cpu_times()
+ return _cputimes_ntuple(user, nice, system, idle, irq)
+
+def per_cpu_times():
+ """Return system CPU times as a named tuple"""
+ ret = []
+ for cpu_t in _psutil_netbsd.get_system_per_cpu_times():
+ user, nice, system, idle, irq = cpu_t
+ item = _cputimes_ntuple(user, nice, system, idle, irq)
+ ret.append(item)
+ return ret
+
+# \todo: check this
+# XXX
+# Ok, this is very dirty.
+# On FreeBSD < 8 we cannot gather per-cpu information, see:
+# http://code.google.com/p/psutil/issues/detail?id=226
+# If NUM_CPUS > 1, on first call we return single cpu times to avoid a
+# crash at psutil import time.
+# Next calls will fail with NotImplementedError
+if not hasattr(_psutil_netbsd, "get_system_per_cpu_times"):
+ def per_cpu_times():
+ if NUM_CPUS == 1:
+ return [get_system_cpu_times]
+ if per_cpu_times.__called__:
+ raise NotImplementedError("supported only starting from FreeBSD 8")
+ per_cpu_times.__called__ = True
+ return [get_system_cpu_times]
+per_cpu_times.__called__ = False
+
+def disk_partitions(all=False):
+ retlist = []
+ partitions = _psutil_netbsd.get_disk_partitions()
+ for partition in partitions:
+ device, mountpoint, fstype, opts = partition
+ if device == 'none':
+ device = ''
+ if not all:
+ if not os.path.isabs(device) \
+ or not os.path.exists(device):
+ continue
+ ntuple = nt_partition(device, mountpoint, fstype, opts)
+ retlist.append(ntuple)
+ return retlist
+
+def get_system_users():
+ retlist = []
+ rawlist = _psutil_netbsd.get_system_users()
+ for item in rawlist:
+ user, tty, hostname, tstamp = item
+ if tty == '~':
+ continue # reboot or shutdown
+ nt = nt_user(user, tty or None, hostname, tstamp)
+ retlist.append(nt)
+ return retlist
+
+get_pid_list = _psutil_netbsd.get_pid_list
+pid_exists = _psposix.pid_exists
+disk_usage = _psposix.disk_usage
+net_io_counters = _psutil_netbsd.get_net_io_counters
+disk_io_counters = _psutil_netbsd.get_disk_io_counters
+
+
+def wrap_exceptions(fun):
+ """Decorator which translates bare OSError exceptions into
+ NoSuchProcess and AccessDenied.
+ """
+ @wraps(fun)
+ def wrapper(self, *args, **kwargs):
+ try:
+ return fun(self, *args, **kwargs)
+ except OSError:
+ err = sys.exc_info()[1]
+ if err.errno == errno.ESRCH:
+ raise NoSuchProcess(self.pid, self._process_name)
+ if err.errno in (errno.EPERM, errno.EACCES):
+ raise AccessDenied(self.pid, self._process_name)
+ raise
+ return wrapper
+
+_status_map = {
+ _psutil_netbsd.SSTOP : STATUS_STOPPED,
+ _psutil_netbsd.SIDL : STATUS_IDLE,
+ _psutil_netbsd.SACTIVE : STATUS_RUNNING,
+# \todo: to what to map this?
+# _psutil_netbsd.SDYING : STATUS_IDLE,
+ _psutil_netbsd.SDEAD : STATUS_DEAD,
+ _psutil_netbsd.SZOMB : STATUS_ZOMBIE,
+}
+
+_conn_status_map = {_psutil_netbsd.TCPS_ESTABLISHED : CONN_ESTABLISHED,
+ _psutil_netbsd.TCPS_SYN_SENT : CONN_SYN_SENT,
+ _psutil_netbsd.TCPS_SYN_RECEIVED : CONN_SYN_RECV,
+ _psutil_netbsd.TCPS_FIN_WAIT_1 : CONN_FIN_WAIT1,
+ _psutil_netbsd.TCPS_FIN_WAIT_2 : CONN_FIN_WAIT2,
+ _psutil_netbsd.TCPS_TIME_WAIT : CONN_TIME_WAIT,
+ _psutil_netbsd.TCPS_CLOSED : CONN_CLOSE,
+ _psutil_netbsd.TCPS_CLOSE_WAIT : CONN_CLOSE_WAIT,
+ _psutil_netbsd.TCPS_LAST_ACK : CONN_LAST_ACK,
+ _psutil_netbsd.TCPS_LISTEN : CONN_LISTEN,
+ _psutil_netbsd.TCPS_CLOSING : CONN_CLOSING,
+ }
+
+
+class Process(object):
+ """Wrapper class around underlying C implementation."""
+
+ __slots__ = ["pid", "_process_name"]
+
+ def __init__(self, pid):
+ self.pid = pid
+ self._process_name = None
+
+ @wrap_exceptions
+ def get_process_name(self):
+ """Return process name as a string of limited len (15)."""
+ return _psutil_netbsd.get_process_name(self.pid)
+
+ @wrap_exceptions
+ def get_process_exe(self):
+ """Return process executable pathname."""
+ return _psutil_netbsd.get_process_exe(self.pid)
+
+ @wrap_exceptions
+ def get_process_cmdline(self):
+ """Return process cmdline as a list of arguments."""
+ return _psutil_netbsd.get_process_cmdline(self.pid)
+
+ @wrap_exceptions
+ def get_process_terminal(self):
+ tty_nr = _psutil_netbsd.get_process_tty_nr(self.pid)
+ tmap = _psposix._get_terminal_map()
+ try:
+ return tmap[tty_nr]
+ except KeyError:
+ return None
+
+ @wrap_exceptions
+ def get_process_ppid(self):
+ """Return process parent pid."""
+ return _psutil_netbsd.get_process_ppid(self.pid)
+
+ # XXX - available on FreeBSD >= 8 only
+ if hasattr(_psutil_netbsd, "get_process_cwd"):
+ @wrap_exceptions
+ def get_process_cwd(self):
+ """Return process current working directory."""
+ # sometimes we get an empty string, in which case we turn
+ # it into None
+ return _psutil_netbsd.get_process_cwd(self.pid) or None
+
+ @wrap_exceptions
+ def get_process_uids(self):
+ """Return real, effective and saved user ids."""
+ real, effective, saved = _psutil_netbsd.get_process_uids(self.pid)
+ return nt_uids(real, effective, saved)
+
+ @wrap_exceptions
+ def get_process_gids(self):
+ """Return real, effective and saved group ids."""
+ real, effective, saved = _psutil_netbsd.get_process_gids(self.pid)
+ return nt_gids(real, effective, saved)
+
+ @wrap_exceptions
+ def get_cpu_times(self):
+ """return a tuple containing process user/kernel time."""
+ user, system = _psutil_netbsd.get_process_cpu_times(self.pid)
+ return nt_cputimes(user, system)
+
+ @wrap_exceptions
+ def get_memory_info(self):
+ """Return a tuple with the process' RSS and VMS size."""
+ rss, vms = _psutil_netbsd.get_process_memory_info(self.pid)[:2]
+ return nt_meminfo(rss, vms)
+
+ _nt_ext_mem = namedtuple('meminfo', 'rss vms text data stack')
+
+ @wrap_exceptions
+ def get_ext_memory_info(self):
+ return self._nt_ext_mem(*_psutil_netbsd.get_process_memory_info(self.pid))
+
+ @wrap_exceptions
+ def get_process_create_time(self):
+ """Return the start time of the process as a number of seconds since
+ the epoch."""
+ return _psutil_netbsd.get_process_create_time(self.pid)
+
+ @wrap_exceptions
+ def get_process_num_threads(self):
+ """Return the number of threads belonging to the process."""
+ return _psutil_netbsd.get_process_num_threads(self.pid)
+
+ @wrap_exceptions
+ def get_num_ctx_switches(self):
+ return nt_ctxsw(*_psutil_netbsd.get_process_num_ctx_switches(self.pid))
+
+ @wrap_exceptions
+ def get_num_fds(self):
+ """Return the number of file descriptors opened by this process."""
+ return _psutil_netbsd.get_process_num_fds(self.pid)
+
+ @wrap_exceptions
+ def get_process_threads(self):
+ """Return the number of threads belonging to the process."""
+ rawlist = _psutil_netbsd.get_process_threads(self.pid)
+ retlist = []
+ for thread_id, utime, stime in rawlist:
+ ntuple = nt_thread(thread_id, utime, stime)
+ retlist.append(ntuple)
+ return retlist
+
+ @wrap_exceptions
+ def get_open_files(self):
+ """Return files opened by process as a list of namedtuples."""
+ # XXX - C implementation available on FreeBSD >= 8 only
+ # else fallback on lsof parser
+ if hasattr(_psutil_netbsd, "get_process_open_files"):
+ rawlist = _psutil_netbsd.get_process_open_files(self.pid)
+ return [nt_openfile(path, fd) for path, fd in rawlist]
+ else:
+ lsof = _psposix.LsofParser(self.pid, self._process_name)
+ return lsof.get_process_open_files()
+
+ @wrap_exceptions
+ def get_connections(self, kind='inet'):
+ """Return etwork connections opened by a process as a list of
+ namedtuples.
+ """
+ if kind not in conn_tmap:
+ raise ValueError("invalid %r kind argument; choose between %s"
+ % (kind, ', '.join([repr(x) for x in conn_tmap])))
+ families, types = conn_tmap[kind]
+ rawlist = _psutil_netbsd.get_process_connections(self.pid, families,
+ types)
+ ret = []
+ for item in rawlist:
+ fd, fam, type, laddr, raddr, status = item
+ status = _conn_status_map[status]
+ nt = nt_connection(fd, fam, type, laddr, raddr, status)
+ ret.append(nt)
+ return ret
+
+ @wrap_exceptions
+ def process_wait(self, timeout=None):
+ try:
+ return _psposix.wait_pid(self.pid, timeout)
+ except TimeoutExpired:
+ raise TimeoutExpired(self.pid, self._process_name)
+
+ @wrap_exceptions
+ def get_process_nice(self):
+ return _psutil_posix.getpriority(self.pid)
+
+ @wrap_exceptions
+ def set_process_nice(self, value):
+ return _psutil_posix.setpriority(self.pid, value)
+
+ @wrap_exceptions
+ def get_process_status(self):
+ code = _psutil_netbsd.get_process_status(self.pid)
+ if code in _status_map:
+ return _status_map[code]
+ # XXX is this legit? will we even ever get here?
+ return "?"
+
+ @wrap_exceptions
+ def get_process_io_counters(self):
+ rc, wc, rb, wb = _psutil_netbsd.get_process_io_counters(self.pid)
+ return nt_io(rc, wc, rb, wb)
+
+ nt_mmap_grouped = namedtuple('mmap',
+ 'path rss, private, ref_count, shadow_count')
+ nt_mmap_ext = namedtuple('mmap',
+ 'addr, perms path rss, private, ref_count, shadow_count')
+
+ @wrap_exceptions
+ def get_memory_maps(self):
+ return _psutil_netbsd.get_process_memory_maps(self.pid)
+
+ # FreeBSD < 8 does not support kinfo_getfile() and kinfo_getvmmap()
+ if not hasattr(_psutil_netbsd, 'get_process_open_files'):
+ def _not_implemented(self):
+ raise NotImplementedError("supported only starting from FreeBSD 8")
+ get_open_files = _not_implemented
+ get_process_cwd = _not_implemented
+ get_memory_maps = _not_implemented
+ get_num_fds = _not_implemented

View File

@@ -0,0 +1,29 @@
$NetBSD: patch-psutil___psutil__bsd.c,v 1.6 2016/04/29 15:33:57 prlw1 Exp $
MNT_RELATIME and MNT_EXTATTR are not available on NetBSD-5.
https://github.com/giampaolo/psutil/pull/812
--- psutil/_psutil_bsd.c.orig 2016-03-12 17:12:23.000000000 +0000
+++ psutil/_psutil_bsd.c
@@ -712,16 +712,20 @@ psutil_disk_partitions(PyObject *self, P
strlcat(opts, ",union", sizeof(opts));
if (flags & MNT_NOCOREDUMP)
strlcat(opts, ",nocoredump", sizeof(opts));
+#if defined(MNT_RELATIME)
if (flags & MNT_RELATIME)
strlcat(opts, ",relatime", sizeof(opts));
+#endif
if (flags & MNT_IGNORE)
strlcat(opts, ",ignore", sizeof(opts));
#if defined(MNT_DISCARD)
if (flags & MNT_DISCARD)
strlcat(opts, ",discard", sizeof(opts));
#endif
+#if defined(MNT_EXTATTR)
if (flags & MNT_EXTATTR)
strlcat(opts, ",extattr", sizeof(opts));
+#endif
if (flags & MNT_LOG)
strlcat(opts, ",log", sizeof(opts));
if (flags & MNT_SYMPERM)

File diff suppressed because it is too large Load Diff

View File

@@ -1,57 +0,0 @@
$NetBSD: patch-psutil___psutil__netbsd.h,v 1.1 2013/10/12 13:32:36 wiz Exp $
Port to NetBSD.
--- psutil/_psutil_netbsd.h.orig 2013-10-12 13:19:29.000000000 +0000
+++ psutil/_psutil_netbsd.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * NetBSD platform-specific module methods for _psutil_netbsd
+ */
+
+#include <Python.h>
+
+// --- per-process functions
+
+static PyObject* get_process_cpu_times(PyObject* self, PyObject* args);
+static PyObject* get_process_name(PyObject* self, PyObject* args);
+static PyObject* get_process_exe(PyObject* self, PyObject* args);
+static PyObject* get_process_cmdline(PyObject* self, PyObject* args);
+static PyObject* get_process_ppid(PyObject* self, PyObject* args);
+static PyObject* get_process_uids(PyObject* self, PyObject* args);
+static PyObject* get_process_gids(PyObject* self, PyObject* args);
+static PyObject* get_process_connections(PyObject* self, PyObject* args);
+static PyObject* get_process_create_time(PyObject* self, PyObject* args);
+static PyObject* get_process_memory_info(PyObject* self, PyObject* args);
+static PyObject* get_process_num_threads(PyObject* self, PyObject* args);
+static PyObject* get_process_num_fds(PyObject* self, PyObject* args);
+static PyObject* get_process_threads(PyObject* self, PyObject* args);
+static PyObject* get_process_status(PyObject* self, PyObject* args);
+static PyObject* get_process_io_counters(PyObject* self, PyObject* args);
+static PyObject* get_process_tty_nr(PyObject* self, PyObject* args);
+static PyObject* get_process_memory_maps(PyObject* self, PyObject* args);
+static PyObject* get_process_num_ctx_switches(PyObject* self, PyObject* args);
+#if NOTYET
+static PyObject* get_process_open_files(PyObject* self, PyObject* args);
+static PyObject* get_process_cwd(PyObject* self, PyObject* args);
+#endif
+
+// --- system-related functions
+
+static PyObject* get_pid_list(PyObject* self, PyObject* args);
+static PyObject* get_num_cpus(PyObject* self, PyObject* args);
+static PyObject* get_virtual_mem(PyObject* self, PyObject* args);
+static PyObject* get_swap_mem(PyObject* self, PyObject* args);
+static PyObject* get_system_cpu_times(PyObject* self, PyObject* args);
+#if NOTYET
+static PyObject* get_system_per_cpu_times(PyObject* self, PyObject* args);
+#endif
+static PyObject* get_system_boot_time(PyObject* self, PyObject* args);
+static PyObject* get_disk_partitions(PyObject* self, PyObject* args);
+static PyObject* get_net_io_counters(PyObject* self, PyObject* args);
+static PyObject* get_disk_io_counters(PyObject* self, PyObject* args);
+static PyObject* get_system_users(PyObject* self, PyObject* args);

View File

@@ -0,0 +1,16 @@
$NetBSD: patch-psutil_arch_bsd_netbsd.c,v 1.4 2016/04/29 15:33:57 prlw1 Exp $
Declare warn().
https://github.com/giampaolo/psutil/pull/812
--- psutil/arch/bsd/netbsd.c.orig 2016-03-12 17:12:23.000000000 +0000
+++ psutil/arch/bsd/netbsd.c
@@ -13,6 +13,7 @@
#include <Python.h>
#include <assert.h>
+#include <err.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>

View File

@@ -1,296 +0,0 @@
$NetBSD: patch-psutil_arch_netbsd_process__info.c,v 1.1 2013/10/12 13:32:36 wiz Exp $
Port to NetBSD.
--- psutil/arch/netbsd/process_info.c.orig 2013-10-12 13:19:29.000000000 +0000
+++ psutil/arch/netbsd/process_info.c
@@ -0,0 +1,289 @@
+/*
+ * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Helper functions related to fetching process information. Used by _psutil_netbsd
+ * module methods.
+ */
+
+#include <Python.h>
+#include <assert.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#include <sys/param.h>
+#include <sys/user.h>
+#include <sys/proc.h>
+#include <signal.h>
+
+#include "process_info.h"
+
+
+/*
+ * Returns a list of all BSD processes on the system. This routine
+ * allocates the list and puts it in *procList and a count of the
+ * number of entries in *procCount. You are responsible for freeing
+ * this list (use "free" from System framework).
+ * On success, the function returns 0.
+ * On error, the function returns a BSD errno value.
+ */
+int
+psutil_get_proc_list(struct kinfo_proc2 **procList, size_t *procCount)
+{
+ int err;
+ struct kinfo_proc2 * result;
+ int done;
+ static const int name[] = { CTL_KERN, KERN_PROC2, KERN_PROC_ALL, 0 };
+ // Declaring name as const requires us to cast it when passing it to
+ // sysctl because the prototype doesn't include the const modifier.
+ size_t length;
+
+ assert( procList != NULL);
+ assert(*procList == NULL);
+ assert(procCount != NULL);
+
+ *procCount = 0;
+
+ /*
+ * We start by calling sysctl with result == NULL and length == 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 use 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.
+ */
+ result = NULL;
+ done = 0;
+ do {
+ assert(result == NULL);
+ // Call sysctl with a NULL buffer.
+ length = 0;
+ err = sysctl((int *)name, (sizeof(name) / sizeof(*name)) - 1,
+ NULL, &length, NULL, 0);
+ if (err == -1)
+ err = errno;
+
+ // Allocate an appropriately sized buffer based on the results
+ // from the previous call.
+ if (err == 0) {
+ result = malloc(length);
+ if (result == 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((int *) name, (sizeof(name) / sizeof(*name)) - 1,
+ result, &length, NULL, 0);
+ if (err == -1)
+ err = errno;
+ if (err == 0) {
+ done = 1;
+ }
+ else if (err == ENOMEM) {
+ assert(result != NULL);
+ free(result);
+ result = NULL;
+ err = 0;
+ }
+ }
+ } while (err == 0 && ! done);
+
+ // Clean up and establish post conditions.
+ if (err != 0 && result != NULL) {
+ free(result);
+ result = NULL;
+ }
+
+ *procList = result;
+ *procCount = length / sizeof(struct kinfo_proc2);
+
+ assert((err == 0) == (*procList != NULL));
+ return err;
+}
+
+
+char
+*psutil_get_cmd_path(long pid, size_t *pathsize)
+{
+#if defined(__FreeBSD__)
+ int mib[4];
+ char *path;
+ size_t size = 0;
+
+ /*
+ * Make a sysctl() call to get the raw argument space of the process.
+ */
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_PROC2;
+ mib[2] = KERN_PROC_PATHNAME;
+ mib[3] = pid;
+
+ // call with a null buffer first to determine if we need a buffer
+ if (sysctl(mib, 4, NULL, &size, NULL, 0) == -1) {
+ return NULL;
+ }
+
+ path = malloc(size);
+ if (path == NULL) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+
+ *pathsize = size;
+ if (sysctl(mib, MIB_LEN, path, &size, NULL, 0) == -1) {
+ free(path);
+ return NULL; /* Insufficient privileges */
+ }
+
+ return path;
+#else
+ /* not supported */
+ return NULL;
+#endif
+}
+
+
+/*
+ * XXX no longer used; it probably makese sense to remove it.
+ * Borrowed from psi Python System Information project
+ *
+ * Get command arguments and environment variables.
+ *
+ * Based on code from ps.
+ *
+ * Returns:
+ * 0 for success;
+ * -1 for failure (Exception raised);
+ * 1 for insufficient privileges.
+ */
+char
+*psutil_get_cmd_args(long pid, size_t *argsize)
+{
+ int mib[4], argmax;
+ size_t size = sizeof(argmax);
+ char *procargs = NULL;
+
+ /* 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)
+ return NULL;
+
+ /* Allocate space for the arguments. */
+ procargs = (char *)malloc(argmax);
+ if (procargs == NULL) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+
+ /*
+ * Make a sysctl() call to get the raw argument space of the process.
+ */
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_PROC;
+ mib[2] = KERN_PROC_ARGS;
+ mib[3] = pid;
+
+ size = argmax;
+ if (sysctl(mib, 4, procargs, &size, NULL, 0) == -1) {
+ free(procargs);
+ return NULL; /* Insufficient privileges */
+ }
+
+ // return string and set the length of arguments
+ *argsize = size;
+ return procargs;
+}
+
+
+/* returns the command line as a python list object */
+PyObject*
+psutil_get_arg_list(long pid)
+{
+ char *argstr = NULL;
+ int pos = 0;
+ size_t argsize = 0;
+ PyObject *retlist = Py_BuildValue("[]");
+ PyObject *item = NULL;
+
+ if (pid < 0) {
+ return retlist;
+ }
+
+ argstr = psutil_get_cmd_args(pid, &argsize);
+ if (argstr == NULL) {
+ goto error;
+ }
+
+ // args are returned as a flattened string with \0 separators between
+ // arguments add each string to the list then step forward to the next
+ // separator
+ if (argsize > 0) {
+ while(pos < argsize) {
+ item = Py_BuildValue("s", &argstr[pos]);
+ if (!item)
+ goto error;
+ if (PyList_Append(retlist, item))
+ goto error;
+ Py_DECREF(item);
+ pos = pos + strlen(&argstr[pos]) + 1;
+ }
+ }
+
+ free(argstr);
+ return retlist;
+
+error:
+ Py_XDECREF(item);
+ Py_DECREF(retlist);
+ if (argstr != NULL)
+ free(argstr);
+ return NULL;
+}
+
+
+/*
+ * Return 1 if PID exists in the current process list, else 0.
+ */
+int
+psutil_pid_exists(long pid)
+{
+ int kill_ret;
+ if (pid < 0) {
+ return 0;
+ }
+
+ // if kill returns success of permission denied we know it's a valid PID
+ kill_ret = kill(pid , 0);
+ if ((0 == kill_ret) || (EPERM == errno)) {
+ return 1;
+ }
+
+ // otherwise return 0 for PID not found
+ return 0;
+}
+
+
+/*
+ * Set exception to AccessDenied if pid exists else NoSuchProcess.
+ */
+int
+psutil_raise_ad_or_nsp(pid) {
+ if (psutil_pid_exists(pid) == 0) {
+ NoSuchProcess();
+ }
+ else {
+ AccessDenied();
+ }
+}

View File

@@ -1,23 +0,0 @@
$NetBSD: patch-psutil_arch_netbsd_process__info.h,v 1.1 2013/10/12 13:32:36 wiz Exp $
Port to NetBSD.
--- psutil/arch/netbsd/process_info.h.orig 2013-10-12 13:19:29.000000000 +0000
+++ psutil/arch/netbsd/process_info.h
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Helper functions related to fetching process information. Used by _psutil_netbsd
+ * module methods.
+ */
+
+#include <Python.h>
+
+int psutil_get_proc_list(struct kinfo_proc2 **procList, size_t *procCount);
+char *psutil_get_cmd_args(long pid, size_t *argsize);
+char *psutil_get_cmd_path(long pid, size_t *pathsize);
+int psutil_pid_exists(long pid);
+PyObject* psutil_get_arg_list(long pid);

View File

@@ -1,25 +0,0 @@
$NetBSD: patch-setup.py,v 1.3 2013/12/07 21:25:24 richard Exp $
Port to NetBSD.
--- setup.py.orig 2013-11-20 19:29:05.000000000 +0000
+++ setup.py
@@ -122,6 +122,18 @@ elif sys.platform.startswith("freebsd"):
libraries=["devstat"]),
posix_extension,
]
+# NetBSD
+elif sys.platform.startswith("netbsd"):
+ extensions = [Extension(
+ '_psutil_netbsd',
+ sources = [
+ 'psutil/_psutil_netbsd.c',
+ 'psutil/_psutil_common.c',
+ 'psutil/arch/netbsd/process_info.c'
+ ],
+ libraries=[]),
+ posix_extension,
+ ]
# Linux
elif sys.platform.startswith("linux"):
extensions = [Extension(

View File

@@ -1,15 +0,0 @@
$NetBSD: patch-test_test__psutil.py,v 1.3 2014/04/18 19:58:46 wiz Exp $
Port to NetBSD.
--- test/test_psutil.py.orig 2014-04-08 00:03:00.000000000 +0000
+++ test/test_psutil.py
@@ -87,7 +87,7 @@ if WINDOWS:
WIN_VISTA = (6, 0, 0)
LINUX = sys.platform.startswith("linux")
OSX = sys.platform.startswith("darwin")
-BSD = sys.platform.startswith("freebsd")
+BSD = sys.platform.startswith("freebsd") or sys.platform.startswith("netbsd")
SUNOS = sys.platform.startswith("sunos")
VALID_PROC_STATUSES = [getattr(psutil, x) for x in dir(psutil)
if x.startswith('STATUS_')]