diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2015-08-06 11:37:21 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2015-08-06 11:37:21 +0200 |
commit | bf7ce346d8a1ffb4fa499a2a8d70bdcfc3b2b77e (patch) | |
tree | 11a19af53767e8574c3852f7f3f5f446e9c3cc05 | |
parent | cb5a5fa06fb25690e1117079535c2d60207efe80 (diff) | |
download | psutil-bf7ce346d8a1ffb4fa499a2a8d70bdcfc3b2b77e.tar.gz |
C styling
-rw-r--r-- | psutil/_psutil_bsd.c | 99 | ||||
-rw-r--r-- | psutil/_psutil_linux.c | 27 | ||||
-rw-r--r-- | psutil/_psutil_osx.c | 93 | ||||
-rw-r--r-- | psutil/_psutil_posix.c | 9 | ||||
-rw-r--r-- | psutil/_psutil_sunos.c | 48 | ||||
-rw-r--r-- | psutil/_psutil_windows.c | 123 |
6 files changed, 133 insertions, 266 deletions
diff --git a/psutil/_psutil_bsd.c b/psutil/_psutil_bsd.c index 7b6e5617..97eddc63 100644 --- a/psutil/_psutil_bsd.c +++ b/psutil/_psutil_bsd.c @@ -110,8 +110,7 @@ psutil_raise_ad_or_nsp(long pid) { * Return a Python list of all the PIDs running on the system. */ static PyObject * -psutil_pids(PyObject *self, PyObject *args) -{ +psutil_pids(PyObject *self, PyObject *args) { kinfo_proc *proclist = NULL; kinfo_proc *orig_address = NULL; size_t num_processes; @@ -157,8 +156,7 @@ error: * seconds since the epoch. */ static PyObject * -psutil_boot_time(PyObject *self, PyObject *args) -{ +psutil_boot_time(PyObject *self, PyObject *args) { // fetch sysctl "kern.boottime" static int request[2] = { CTL_KERN, KERN_BOOTTIME }; struct timeval boottime; @@ -176,8 +174,7 @@ psutil_boot_time(PyObject *self, PyObject *args) * Return process name from kinfo_proc as a Python string. */ static PyObject * -psutil_proc_name(PyObject *self, PyObject *args) -{ +psutil_proc_name(PyObject *self, PyObject *args) { long pid; struct kinfo_proc kp; if (! PyArg_ParseTuple(args, "l", &pid)) @@ -194,8 +191,7 @@ psutil_proc_name(PyObject *self, PyObject *args) * http://fxr.googlebit.com/source/usr.bin/procstat/procstat_bin.c?v=8-CURRENT */ static PyObject * -psutil_proc_exe(PyObject *self, PyObject *args) -{ +psutil_proc_exe(PyObject *self, PyObject *args) { long pid; char pathname[PATH_MAX]; int error; @@ -230,8 +226,7 @@ psutil_proc_exe(PyObject *self, PyObject *args) * Return process cmdline as a Python list of cmdline arguments. */ static PyObject * -psutil_proc_cmdline(PyObject *self, PyObject *args) -{ +psutil_proc_cmdline(PyObject *self, PyObject *args) { long pid; PyObject *arglist = NULL; @@ -253,8 +248,7 @@ psutil_proc_cmdline(PyObject *self, PyObject *args) * Return process parent pid from kinfo_proc as a Python integer. */ static PyObject * -psutil_proc_ppid(PyObject *self, PyObject *args) -{ +psutil_proc_ppid(PyObject *self, PyObject *args) { long pid; struct kinfo_proc kp; if (! PyArg_ParseTuple(args, "l", &pid)) @@ -269,8 +263,7 @@ psutil_proc_ppid(PyObject *self, PyObject *args) * Return process status as a Python integer. */ static PyObject * -psutil_proc_status(PyObject *self, PyObject *args) -{ +psutil_proc_status(PyObject *self, PyObject *args) { long pid; struct kinfo_proc kp; if (! PyArg_ParseTuple(args, "l", &pid)) @@ -286,8 +279,7 @@ psutil_proc_status(PyObject *self, PyObject *args) * as a Python tuple. */ static PyObject * -psutil_proc_uids(PyObject *self, PyObject *args) -{ +psutil_proc_uids(PyObject *self, PyObject *args) { long pid; struct kinfo_proc kp; if (! PyArg_ParseTuple(args, "l", &pid)) @@ -306,8 +298,7 @@ psutil_proc_uids(PyObject *self, PyObject *args) * as a Python tuple. */ static PyObject * -psutil_proc_gids(PyObject *self, PyObject *args) -{ +psutil_proc_gids(PyObject *self, PyObject *args) { long pid; struct kinfo_proc kp; if (! PyArg_ParseTuple(args, "l", &pid)) @@ -326,8 +317,7 @@ psutil_proc_gids(PyObject *self, PyObject *args) * as a Python tuple. */ static PyObject * -psutil_proc_tty_nr(PyObject *self, PyObject *args) -{ +psutil_proc_tty_nr(PyObject *self, PyObject *args) { long pid; struct kinfo_proc kp; if (! PyArg_ParseTuple(args, "l", &pid)) @@ -342,8 +332,7 @@ psutil_proc_tty_nr(PyObject *self, PyObject *args) * Return the number of context switches performed by process as a tuple. */ static PyObject * -psutil_proc_num_ctx_switches(PyObject *self, PyObject *args) -{ +psutil_proc_num_ctx_switches(PyObject *self, PyObject *args) { long pid; struct kinfo_proc kp; if (! PyArg_ParseTuple(args, "l", &pid)) @@ -360,8 +349,7 @@ psutil_proc_num_ctx_switches(PyObject *self, PyObject *args) * Return number of threads used by process as a Python integer. */ static PyObject * -psutil_proc_num_threads(PyObject *self, PyObject *args) -{ +psutil_proc_num_threads(PyObject *self, PyObject *args) { long pid; struct kinfo_proc kp; if (! PyArg_ParseTuple(args, "l", &pid)) @@ -380,8 +368,7 @@ psutil_proc_num_threads(PyObject *self, PyObject *args) * procstat_threads.c?v=8-CURRENT */ static PyObject * -psutil_proc_threads(PyObject *self, PyObject *args) -{ +psutil_proc_threads(PyObject *self, PyObject *args) { long pid; int mib[4]; struct kinfo_proc *kip = NULL; @@ -458,8 +445,7 @@ error: * Return a Python tuple (user_time, kernel_time) */ static PyObject * -psutil_proc_cpu_times(PyObject *self, PyObject *args) -{ +psutil_proc_cpu_times(PyObject *self, PyObject *args) { long pid; double user_t, sys_t; struct kinfo_proc kp; @@ -479,8 +465,7 @@ psutil_proc_cpu_times(PyObject *self, PyObject *args) * XXX this could be shared with OSX */ static PyObject * -psutil_cpu_count_logical(PyObject *self, PyObject *args) -{ +psutil_cpu_count_logical(PyObject *self, PyObject *args) { int mib[2]; int ncpu; size_t len; @@ -501,8 +486,7 @@ psutil_cpu_count_logical(PyObject *self, PyObject *args) * physical CPU cores in the system. */ static PyObject * -psutil_cpu_count_phys(PyObject *self, PyObject *args) -{ +psutil_cpu_count_phys(PyObject *self, PyObject *args) { void *topology = NULL; size_t size = 0; PyObject *py_str; @@ -535,8 +519,7 @@ error: * seconds since the epoch. */ static PyObject * -psutil_proc_create_time(PyObject *self, PyObject *args) -{ +psutil_proc_create_time(PyObject *self, PyObject *args) { long pid; struct kinfo_proc kp; if (! PyArg_ParseTuple(args, "l", &pid)) @@ -552,8 +535,7 @@ psutil_proc_create_time(PyObject *self, PyObject *args) * seconds since the epoch. */ static PyObject * -psutil_proc_io_counters(PyObject *self, PyObject *args) -{ +psutil_proc_io_counters(PyObject *self, PyObject *args) { long pid; struct kinfo_proc kp; if (! PyArg_ParseTuple(args, "l", &pid)) @@ -573,8 +555,7 @@ psutil_proc_io_counters(PyObject *self, PyObject *args) * Return extended memory info for a process as a Python tuple. */ static PyObject * -psutil_proc_memory_info(PyObject *self, PyObject *args) -{ +psutil_proc_memory_info(PyObject *self, PyObject *args) { long pid; struct kinfo_proc kp; if (! PyArg_ParseTuple(args, "l", &pid)) @@ -594,8 +575,7 @@ psutil_proc_memory_info(PyObject *self, PyObject *args) * Return virtual memory usage statistics. */ static PyObject * -psutil_virtual_mem(PyObject *self, PyObject *args) -{ +psutil_virtual_mem(PyObject *self, PyObject *args) { unsigned int total, active, inactive, wired, cached, free; size_t size = sizeof(total); struct vmtotal vm; @@ -653,8 +633,7 @@ error: * Return swap memory stats (see 'swapinfo' cmdline tool) */ static PyObject * -psutil_swap_mem(PyObject *self, PyObject *args) -{ +psutil_swap_mem(PyObject *self, PyObject *args) { kvm_t *kd; struct kvm_swap kvmsw[1]; unsigned int swapin, swapout, nodein, nodeout; @@ -700,8 +679,7 @@ sbn_error: * Return a Python tuple representing user, kernel and idle CPU times */ static PyObject * -psutil_cpu_times(PyObject *self, PyObject *args) -{ +psutil_cpu_times(PyObject *self, PyObject *args) { long cpu_time[CPUSTATES]; size_t size; @@ -738,8 +716,7 @@ psutil_cpu_times(PyObject *self, PyObject *args) * https://github.com/giampaolo/psutil/issues/595 */ static PyObject * -psutil_proc_open_files(PyObject *self, PyObject *args) -{ +psutil_proc_open_files(PyObject *self, PyObject *args) { long pid; int i, cnt; struct kinfo_file *freep = NULL; @@ -790,8 +767,7 @@ error: * Return files opened by process as a list of (path, fd) tuples */ static PyObject * -psutil_proc_num_fds(PyObject *self, PyObject *args) -{ +psutil_proc_num_fds(PyObject *self, PyObject *args) { long pid; int cnt; @@ -818,8 +794,7 @@ psutil_proc_num_fds(PyObject *self, PyObject *args) * Return process current working directory. */ static PyObject * -psutil_proc_cwd(PyObject *self, PyObject *args) -{ +psutil_proc_cwd(PyObject *self, PyObject *args) { long pid; PyObject *path = NULL; struct kinfo_file *freep = NULL; @@ -997,8 +972,7 @@ static int PSUTIL_CONN_NONE = 128; * Return connections opened by process. */ static PyObject * -psutil_proc_connections(PyObject *self, PyObject *args) -{ +psutil_proc_connections(PyObject *self, PyObject *args) { long pid; int i, cnt; @@ -1158,8 +1132,7 @@ error: * Return a Python list of tuple representing per-cpu times */ static PyObject * -psutil_per_cpu_times(PyObject *self, PyObject *args) -{ +psutil_per_cpu_times(PyObject *self, PyObject *args) { static int maxcpus; int mib[2]; int ncpu; @@ -1237,8 +1210,7 @@ void remove_spaces(char *str) { * 'procstat' cmdline utility has been used as an example. */ static PyObject * -psutil_proc_memory_maps(PyObject *self, PyObject *args) -{ +psutil_proc_memory_maps(PyObject *self, PyObject *args) { long pid; int ptrwidth; int i, cnt; @@ -1349,8 +1321,7 @@ error: * for all partitions mounted on the system. */ static PyObject * -psutil_disk_partitions(PyObject *self, PyObject *args) -{ +psutil_disk_partitions(PyObject *self, PyObject *args) { int num; int i; long len; @@ -1456,8 +1427,7 @@ error: * Return a Python list of named tuples with overall network I/O information */ static PyObject * -psutil_net_io_counters(PyObject *self, PyObject *args) -{ +psutil_net_io_counters(PyObject *self, PyObject *args) { char *buf = NULL, *lim, *next; struct if_msghdr *ifm; int mib[6]; @@ -1547,8 +1517,7 @@ error: * Return a Python dict of tuples for disk I/O information */ static PyObject * -psutil_disk_io_counters(PyObject *self, PyObject *args) -{ +psutil_disk_io_counters(PyObject *self, PyObject *args) { int i; struct statinfo stats; @@ -1618,8 +1587,7 @@ error: * Return currently connected users as a list of tuples. */ static PyObject * -psutil_users(PyObject *self, PyObject *args) -{ +psutil_users(PyObject *self, PyObject *args) { PyObject *ret_list = PyList_New(0); PyObject *tuple = NULL; @@ -2071,8 +2039,7 @@ error: * Reference: http://sources.freebsd.org/RELENG_9/src/usr.bin/cpuset/cpuset.c */ static PyObject * -psutil_proc_cpu_affinity_set(PyObject *self, PyObject *args) -{ +psutil_proc_cpu_affinity_set(PyObject *self, PyObject *args) { long pid; int i; int seq_len; diff --git a/psutil/_psutil_linux.c b/psutil/_psutil_linux.c index ec541fc0..342d844d 100644 --- a/psutil/_psutil_linux.c +++ b/psutil/_psutil_linux.c @@ -82,8 +82,7 @@ ioprio_set(int which, int who, int ioprio) * Return a (ioclass, iodata) Python tuple representing process I/O priority. */ static PyObject * -psutil_proc_ioprio_get(PyObject *self, PyObject *args) -{ +psutil_proc_ioprio_get(PyObject *self, PyObject *args) { long pid; int ioprio, ioclass, iodata; if (! PyArg_ParseTuple(args, "l", &pid)) @@ -103,8 +102,7 @@ psutil_proc_ioprio_get(PyObject *self, PyObject *args) * or 0. iodata goes from 0 to 7 depending on ioclass specified. */ static PyObject * -psutil_proc_ioprio_set(PyObject *self, PyObject *args) -{ +psutil_proc_ioprio_set(PyObject *self, PyObject *args) { long pid; int ioprio, ioclass, iodata; int retval; @@ -127,8 +125,7 @@ psutil_proc_ioprio_set(PyObject *self, PyObject *args) * 'soft' and 'hard' args must be provided. */ static PyObject * -psutil_linux_prlimit(PyObject *self, PyObject *args) -{ +psutil_linux_prlimit(PyObject *self, PyObject *args) { long pid; int ret, resource; struct rlimit old, new; @@ -186,8 +183,7 @@ psutil_linux_prlimit(PyObject *self, PyObject *args) * mount point and filesystem type */ static PyObject * -psutil_disk_partitions(PyObject *self, PyObject *args) -{ +psutil_disk_partitions(PyObject *self, PyObject *args) { FILE *file = NULL; struct mntent *entry; PyObject *py_retlist = PyList_New(0); @@ -237,8 +233,7 @@ error: * A wrapper around sysinfo(), return system memory usage statistics. */ static PyObject * -psutil_linux_sysinfo(PyObject *self, PyObject *args) -{ +psutil_linux_sysinfo(PyObject *self, PyObject *args) { struct sysinfo info; if (sysinfo(&info) != 0) @@ -264,8 +259,7 @@ psutil_linux_sysinfo(PyObject *self, PyObject *args) #ifdef CPU_ALLOC static PyObject * -psutil_proc_cpu_affinity_get(PyObject *self, PyObject *args) -{ +psutil_proc_cpu_affinity_get(PyObject *self, PyObject *args) { int cpu, ncpus, count, cpucount_s; long pid; size_t setsize; @@ -331,8 +325,7 @@ error: * Alternative implementation in case CPU_ALLOC is not defined. */ static PyObject * -psutil_proc_cpu_affinity_get(PyObject *self, PyObject *args) -{ +psutil_proc_cpu_affinity_get(PyObject *self, PyObject *args) { cpu_set_t cpuset; unsigned int len = sizeof(cpu_set_t); long pid; @@ -373,8 +366,7 @@ error: * Set process CPU affinity; expects a bitmask */ static PyObject * -psutil_proc_cpu_affinity_set(PyObject *self, PyObject *args) -{ +psutil_proc_cpu_affinity_set(PyObject *self, PyObject *args) { cpu_set_t cpu_set; size_t len; long pid; @@ -428,8 +420,7 @@ error: * Return currently connected users as a list of tuples. */ static PyObject * -psutil_users(PyObject *self, PyObject *args) -{ +psutil_users(PyObject *self, PyObject *args) { PyObject *ret_list = PyList_New(0); PyObject *tuple = NULL; PyObject *user_proc = NULL; diff --git a/psutil/_psutil_osx.c b/psutil/_psutil_osx.c index 3ebf8ff2..d884ea24 100644 --- a/psutil/_psutil_osx.c +++ b/psutil/_psutil_osx.c @@ -69,8 +69,7 @@ psutil_sys_vminfo(vm_statistics_data_t *vmstat) * Return a Python list of all the PIDs running on the system. */ static PyObject * -psutil_pids(PyObject *self, PyObject *args) -{ +psutil_pids(PyObject *self, PyObject *args) { kinfo_proc *proclist = NULL; kinfo_proc *orig_address = NULL; size_t num_processes; @@ -116,8 +115,7 @@ error: * Return process name from kinfo_proc as a Python string. */ static PyObject * -psutil_proc_name(PyObject *self, PyObject *args) -{ +psutil_proc_name(PyObject *self, PyObject *args) { long pid; struct kinfo_proc kp; if (! PyArg_ParseTuple(args, "l", &pid)) @@ -132,8 +130,7 @@ psutil_proc_name(PyObject *self, PyObject *args) * Return process current working directory. */ static PyObject * -psutil_proc_cwd(PyObject *self, PyObject *args) -{ +psutil_proc_cwd(PyObject *self, PyObject *args) { long pid; struct proc_vnodepathinfo pathinfo; @@ -153,8 +150,7 @@ psutil_proc_cwd(PyObject *self, PyObject *args) * Return path of the process executable. */ static PyObject * -psutil_proc_exe(PyObject *self, PyObject *args) -{ +psutil_proc_exe(PyObject *self, PyObject *args) { long pid; char buf[PATH_MAX]; int ret; @@ -176,8 +172,7 @@ psutil_proc_exe(PyObject *self, PyObject *args) * Return process cmdline as a Python list of cmdline arguments. */ static PyObject * -psutil_proc_cmdline(PyObject *self, PyObject *args) -{ +psutil_proc_cmdline(PyObject *self, PyObject *args) { long pid; PyObject *arglist = NULL; @@ -194,8 +189,7 @@ psutil_proc_cmdline(PyObject *self, PyObject *args) * Return process parent pid from kinfo_proc as a Python integer. */ static PyObject * -psutil_proc_ppid(PyObject *self, PyObject *args) -{ +psutil_proc_ppid(PyObject *self, PyObject *args) { long pid; struct kinfo_proc kp; if (! PyArg_ParseTuple(args, "l", &pid)) @@ -210,8 +204,7 @@ psutil_proc_ppid(PyObject *self, PyObject *args) * Return process real uid from kinfo_proc as a Python integer. */ static PyObject * -psutil_proc_uids(PyObject *self, PyObject *args) -{ +psutil_proc_uids(PyObject *self, PyObject *args) { long pid; struct kinfo_proc kp; if (! PyArg_ParseTuple(args, "l", &pid)) @@ -229,8 +222,7 @@ psutil_proc_uids(PyObject *self, PyObject *args) * Return process real group id from ki_comm as a Python integer. */ static PyObject * -psutil_proc_gids(PyObject *self, PyObject *args) -{ +psutil_proc_gids(PyObject *self, PyObject *args) { long pid; struct kinfo_proc kp; if (! PyArg_ParseTuple(args, "l", &pid)) @@ -248,8 +240,7 @@ psutil_proc_gids(PyObject *self, PyObject *args) * Return process controlling terminal number as an integer. */ static PyObject * -psutil_proc_tty_nr(PyObject *self, PyObject *args) -{ +psutil_proc_tty_nr(PyObject *self, PyObject *args) { long pid; struct kinfo_proc kp; if (! PyArg_ParseTuple(args, "l", &pid)) @@ -265,8 +256,7 @@ psutil_proc_tty_nr(PyObject *self, PyObject *args) * 'procstat' cmdline utility has been used as an example. */ static PyObject * -psutil_proc_memory_maps(PyObject *self, PyObject *args) -{ +psutil_proc_memory_maps(PyObject *self, PyObject *args) { char buf[PATH_MAX]; char addr_str[34]; char perms[8]; @@ -406,8 +396,7 @@ error: * XXX this could be shared with BSD. */ static PyObject * -psutil_cpu_count_logical(PyObject *self, PyObject *args) -{ +psutil_cpu_count_logical(PyObject *self, PyObject *args) { int mib[2]; int ncpu; size_t len; @@ -426,8 +415,7 @@ psutil_cpu_count_logical(PyObject *self, PyObject *args) * Return the number of physical CPUs in the system. */ static PyObject * -psutil_cpu_count_phys(PyObject *self, PyObject *args) -{ +psutil_cpu_count_phys(PyObject *self, PyObject *args) { int num; size_t size = sizeof(int); @@ -444,8 +432,7 @@ psutil_cpu_count_phys(PyObject *self, PyObject *args) * Return a Python tuple (user_time, kernel_time) */ static PyObject * -psutil_proc_cpu_times(PyObject *self, PyObject *args) -{ +psutil_proc_cpu_times(PyObject *self, PyObject *args) { long pid; struct proc_taskinfo pti; @@ -464,8 +451,7 @@ psutil_proc_cpu_times(PyObject *self, PyObject *args) * seconds since the epoch. */ static PyObject * -psutil_proc_create_time(PyObject *self, PyObject *args) -{ +psutil_proc_create_time(PyObject *self, PyObject *args) { long pid; struct kinfo_proc kp; if (! PyArg_ParseTuple(args, "l", &pid)) @@ -480,8 +466,7 @@ psutil_proc_create_time(PyObject *self, PyObject *args) * Return extended memory info about a process. */ static PyObject * -psutil_proc_memory_info(PyObject *self, PyObject *args) -{ +psutil_proc_memory_info(PyObject *self, PyObject *args) { long pid; struct proc_taskinfo pti; @@ -508,8 +493,7 @@ psutil_proc_memory_info(PyObject *self, PyObject *args) * Return number of threads used by process as a Python integer. */ static PyObject * -psutil_proc_num_threads(PyObject *self, PyObject *args) -{ +psutil_proc_num_threads(PyObject *self, PyObject *args) { long pid; struct proc_taskinfo pti; @@ -525,8 +509,7 @@ psutil_proc_num_threads(PyObject *self, PyObject *args) * Return the number of context switches performed by process. */ static PyObject * -psutil_proc_num_ctx_switches(PyObject *self, PyObject *args) -{ +psutil_proc_num_ctx_switches(PyObject *self, PyObject *args) { long pid; struct proc_taskinfo pti; @@ -545,8 +528,7 @@ psutil_proc_num_ctx_switches(PyObject *self, PyObject *args) * Return system virtual memory stats */ static PyObject * -psutil_virtual_mem(PyObject *self, PyObject *args) -{ +psutil_virtual_mem(PyObject *self, PyObject *args) { int mib[2]; uint64_t total; @@ -584,8 +566,7 @@ psutil_virtual_mem(PyObject *self, PyObject *args) * Return stats about swap memory. */ static PyObject * -psutil_swap_mem(PyObject *self, PyObject *args) -{ +psutil_swap_mem(PyObject *self, PyObject *args) { int mib[2]; size_t size; struct xsw_usage totals; @@ -619,8 +600,7 @@ psutil_swap_mem(PyObject *self, PyObject *args) * Return a Python tuple representing user, kernel and idle CPU times */ static PyObject * -psutil_cpu_times(PyObject *self, PyObject *args) -{ +psutil_cpu_times(PyObject *self, PyObject *args) { mach_msg_type_number_t count = HOST_CPU_LOAD_INFO_COUNT; kern_return_t error; host_cpu_load_info_data_t r_load; @@ -648,8 +628,7 @@ psutil_cpu_times(PyObject *self, PyObject *args) * Return a Python list of tuple representing per-cpu times */ static PyObject * -psutil_per_cpu_times(PyObject *self, PyObject *args) -{ +psutil_per_cpu_times(PyObject *self, PyObject *args) { natural_t cpu_count; processor_info_array_t info_array; mach_msg_type_number_t info_count; @@ -713,8 +692,7 @@ error: * seconds since the epoch. */ static PyObject * -psutil_boot_time(PyObject *self, PyObject *args) -{ +psutil_boot_time(PyObject *self, PyObject *args) { // fetch sysctl "kern.boottime" static int request[2] = { CTL_KERN, KERN_BOOTTIME }; struct timeval result; @@ -735,8 +713,7 @@ psutil_boot_time(PyObject *self, PyObject *args) * for all partitions mounted on the system. */ static PyObject * -psutil_disk_partitions(PyObject *self, PyObject *args) -{ +psutil_disk_partitions(PyObject *self, PyObject *args) { int num; int i; long len; @@ -857,8 +834,7 @@ error: * Return process status as a Python integer. */ static PyObject * -psutil_proc_status(PyObject *self, PyObject *args) -{ +psutil_proc_status(PyObject *self, PyObject *args) { long pid; struct kinfo_proc kp; if (! PyArg_ParseTuple(args, "l", &pid)) @@ -873,8 +849,7 @@ psutil_proc_status(PyObject *self, PyObject *args) * Return process threads */ static PyObject * -psutil_proc_threads(PyObject *self, PyObject *args) -{ +psutil_proc_threads(PyObject *self, PyObject *args) { long pid; int err, j, ret; kern_return_t kr; @@ -984,8 +959,7 @@ error: * - /usr/include/sys/proc_info.h */ static PyObject * -psutil_proc_open_files(PyObject *self, PyObject *args) -{ +psutil_proc_open_files(PyObject *self, PyObject *args) { long pid; int pidinfo_result; int iterations; @@ -1101,8 +1075,7 @@ static int PSUTIL_CONN_NONE = 128; * - /usr/include/sys/proc_info.h */ static PyObject * -psutil_proc_connections(PyObject *self, PyObject *args) -{ +psutil_proc_connections(PyObject *self, PyObject *args) { long pid; int pidinfo_result; int iterations; @@ -1309,8 +1282,7 @@ error: * Return number of file descriptors opened by process. */ static PyObject * -psutil_proc_num_fds(PyObject *self, PyObject *args) -{ +psutil_proc_num_fds(PyObject *self, PyObject *args) { long pid; int pidinfo_result; int num; @@ -1343,8 +1315,7 @@ psutil_proc_num_fds(PyObject *self, PyObject *args) * Return a Python list of named tuples with overall network I/O information */ static PyObject * -psutil_net_io_counters(PyObject *self, PyObject *args) -{ +psutil_net_io_counters(PyObject *self, PyObject *args) { char *buf = NULL, *lim, *next; struct if_msghdr *ifm; int mib[6]; @@ -1431,8 +1402,7 @@ error: * Return a Python dict of tuples for disk I/O information */ static PyObject * -psutil_disk_io_counters(PyObject *self, PyObject *args) -{ +psutil_disk_io_counters(PyObject *self, PyObject *args) { CFDictionaryRef parent_dict; CFDictionaryRef props_dict; CFDictionaryRef stats_dict; @@ -1606,8 +1576,7 @@ error: * Return currently connected users as a list of tuples. */ static PyObject * -psutil_users(PyObject *self, PyObject *args) -{ +psutil_users(PyObject *self, PyObject *args) { struct utmpx *utx; PyObject *ret_list = PyList_New(0); PyObject *tuple = NULL; diff --git a/psutil/_psutil_posix.c b/psutil/_psutil_posix.c index 21ef3fc9..284f7fc5 100644 --- a/psutil/_psutil_posix.c +++ b/psutil/_psutil_posix.c @@ -37,8 +37,7 @@ * Given a PID return process priority as a Python integer. */ static PyObject * -psutil_posix_getpriority(PyObject *self, PyObject *args) -{ +psutil_posix_getpriority(PyObject *self, PyObject *args) { long pid; int priority; errno = 0; @@ -56,8 +55,7 @@ psutil_posix_getpriority(PyObject *self, PyObject *args) * Given a PID and a value change process priority. */ static PyObject * -psutil_posix_setpriority(PyObject *self, PyObject *args) -{ +psutil_posix_setpriority(PyObject *self, PyObject *args) { long pid; int priority; int retval; @@ -396,8 +394,7 @@ int psutil_get_nic_speed(int ifm_active) { * http://www.i-scream.org/libstatgrab/ */ static PyObject * -psutil_net_if_stats(PyObject *self, PyObject *args) -{ +psutil_net_if_stats(PyObject *self, PyObject *args) { char *nic_name; int sock = 0; int ret; diff --git a/psutil/_psutil_sunos.c b/psutil/_psutil_sunos.c index 0cb6978f..191b1e0f 100644 --- a/psutil/_psutil_sunos.c +++ b/psutil/_psutil_sunos.c @@ -81,8 +81,7 @@ psutil_file_to_struct(char *path, void *fstruct, size_t size) * as a Python tuple. */ static PyObject * -psutil_proc_basic_info(PyObject *self, PyObject *args) -{ +psutil_proc_basic_info(PyObject *self, PyObject *args) { int pid; char path[100]; psinfo_t info; @@ -109,8 +108,7 @@ psutil_proc_basic_info(PyObject *self, PyObject *args) * Return process name and args as a Python tuple. */ static PyObject * -psutil_proc_name_and_args(PyObject *self, PyObject *args) -{ +psutil_proc_name_and_args(PyObject *self, PyObject *args) { int pid; char path[100]; psinfo_t info; @@ -128,8 +126,7 @@ psutil_proc_name_and_args(PyObject *self, PyObject *args) * Return process user and system CPU times as a Python tuple. */ static PyObject * -psutil_proc_cpu_times(PyObject *self, PyObject *args) -{ +psutil_proc_cpu_times(PyObject *self, PyObject *args) { int pid; char path[100]; pstatus_t info; @@ -150,8 +147,7 @@ psutil_proc_cpu_times(PyObject *self, PyObject *args) * Return process uids/gids as a Python tuple. */ static PyObject * -psutil_proc_cred(PyObject *self, PyObject *args) -{ +psutil_proc_cred(PyObject *self, PyObject *args) { int pid; char path[100]; prcred_t info; @@ -171,8 +167,7 @@ psutil_proc_cred(PyObject *self, PyObject *args) * Return process uids/gids as a Python tuple. */ static PyObject * -psutil_proc_num_ctx_switches(PyObject *self, PyObject *args) -{ +psutil_proc_num_ctx_switches(PyObject *self, PyObject *args) { int pid; char path[100]; prusage_t info; @@ -228,8 +223,7 @@ proc_io_counters(PyObject* self, PyObject* args) * Return information about a given process thread. */ static PyObject * -psutil_proc_query_thread(PyObject *self, PyObject *args) -{ +psutil_proc_query_thread(PyObject *self, PyObject *args) { int pid, tid; char path[100]; lwpstatus_t info; @@ -249,8 +243,7 @@ psutil_proc_query_thread(PyObject *self, PyObject *args) * Return information about system virtual memory. */ static PyObject * -psutil_swap_mem(PyObject *self, PyObject *args) -{ +psutil_swap_mem(PyObject *self, PyObject *args) { // XXX (arghhh!) // total/free swap mem: commented out as for some reason I can't // manage to get the same results shown by "swap -l", despite the @@ -345,8 +338,7 @@ psutil_swap_mem(PyObject *self, PyObject *args) * Return users currently connected on the system. */ static PyObject * -psutil_users(PyObject *self, PyObject *args) -{ +psutil_users(PyObject *self, PyObject *args) { struct utmpx *ut; PyObject *ret_list = PyList_New(0); PyObject *tuple = NULL; @@ -391,8 +383,7 @@ error: * mount point and filesystem type. */ static PyObject * -psutil_disk_partitions(PyObject *self, PyObject *args) -{ +psutil_disk_partitions(PyObject *self, PyObject *args) { FILE *file; struct mnttab mt; PyObject *py_retlist = PyList_New(0); @@ -437,8 +428,7 @@ error: * Return system-wide CPU times. */ static PyObject * -psutil_per_cpu_times(PyObject *self, PyObject *args) -{ +psutil_per_cpu_times(PyObject *self, PyObject *args) { kstat_ctl_t *kc; kstat_t *ksp; cpu_stat_t cs; @@ -490,8 +480,7 @@ error: * Return disk IO statistics. */ static PyObject * -psutil_disk_io_counters(PyObject *self, PyObject *args) -{ +psutil_disk_io_counters(PyObject *self, PyObject *args) { kstat_ctl_t *kc; kstat_t *ksp; kstat_io_t kio; @@ -549,8 +538,7 @@ error: * Return process memory mappings. */ static PyObject * -psutil_proc_memory_maps(PyObject *self, PyObject *args) -{ +psutil_proc_memory_maps(PyObject *self, PyObject *args) { int pid; int fd = -1; char path[100]; @@ -684,8 +672,7 @@ error: * Return a list of tuples for network I/O statistics. */ static PyObject * -psutil_net_io_counters(PyObject *self, PyObject *args) -{ +psutil_net_io_counters(PyObject *self, PyObject *args) { kstat_ctl_t *kc = NULL; kstat_t *ksp; kstat_named_t *rbytes, *wbytes, *rpkts, *wpkts, *ierrs, *oerrs; @@ -796,8 +783,7 @@ static int PSUTIL_CONN_NONE = 128; * cmd-inet/usr.bin/netstat/netstat.c */ static PyObject * -psutil_net_connections(PyObject *self, PyObject *args) -{ +psutil_net_connections(PyObject *self, PyObject *args) { long pid; int sd = 0; mib2_tcpConnEntry_t *tp = NULL; @@ -1082,8 +1068,7 @@ error: static PyObject * -psutil_boot_time(PyObject *self, PyObject *args) -{ +psutil_boot_time(PyObject *self, PyObject *args) { float boot_time = 0.0; struct utmpx *ut; @@ -1108,8 +1093,7 @@ psutil_boot_time(PyObject *self, PyObject *args) * Return the number of physical CPU cores on the system. */ static PyObject * -psutil_cpu_count_phys(PyObject *self, PyObject *args) -{ +psutil_cpu_count_phys(PyObject *self, PyObject *args) { kstat_ctl_t *kc; kstat_t *ksp; int ncpus = 0; diff --git a/psutil/_psutil_windows.c b/psutil/_psutil_windows.c index 3e0f7a7c..02fd50ce 100644 --- a/psutil/_psutil_windows.c +++ b/psutil/_psutil_windows.c @@ -188,8 +188,7 @@ psutil_get_nic_addresses() { * since the epoch. */ static PyObject * -psutil_boot_time(PyObject *self, PyObject *args) -{ +psutil_boot_time(PyObject *self, PyObject *args) { double uptime; time_t pt; FILETIME fileTime; @@ -225,8 +224,7 @@ psutil_boot_time(PyObject *self, PyObject *args) * Return 1 if PID exists in the current process list, else 0. */ static PyObject * -psutil_pid_exists(PyObject *self, PyObject *args) -{ +psutil_pid_exists(PyObject *self, PyObject *args) { long pid; int status; @@ -244,8 +242,7 @@ psutil_pid_exists(PyObject *self, PyObject *args) * Return a Python list of all the PIDs running on the system. */ static PyObject * -psutil_pids(PyObject *self, PyObject *args) -{ +psutil_pids(PyObject *self, PyObject *args) { DWORD *proclist = NULL; DWORD numberOfReturnedPIDs; DWORD i; @@ -284,8 +281,7 @@ error: * Kill a process given its PID. */ static PyObject * -psutil_proc_kill(PyObject *self, PyObject *args) -{ +psutil_proc_kill(PyObject *self, PyObject *args) { HANDLE hProcess; long pid; @@ -322,8 +318,7 @@ psutil_proc_kill(PyObject *self, PyObject *args) * Wait for process to terminate and return its exit code. */ static PyObject * -psutil_proc_wait(PyObject *self, PyObject *args) -{ +psutil_proc_wait(PyObject *self, PyObject *args) { HANDLE hProcess; DWORD ExitCode; DWORD retVal; @@ -382,8 +377,7 @@ psutil_proc_wait(PyObject *self, PyObject *args) * Return a Python tuple (user_time, kernel_time) */ static PyObject * -psutil_proc_cpu_times(PyObject *self, PyObject *args) -{ +psutil_proc_cpu_times(PyObject *self, PyObject *args) { long pid; HANDLE hProcess; FILETIME ftCreate, ftExit, ftKernel, ftUser; @@ -433,8 +427,7 @@ psutil_proc_cpu_times(PyObject *self, PyObject *args) * seconds since the epoch. */ static PyObject * -psutil_proc_create_time(PyObject *self, PyObject *args) -{ +psutil_proc_create_time(PyObject *self, PyObject *args) { long pid; long long unix_time; DWORD exitCode; @@ -502,8 +495,7 @@ psutil_proc_create_time(PyObject *self, PyObject *args) * Return the number of logical CPUs. */ static PyObject * -psutil_cpu_count_logical(PyObject *self, PyObject *args) -{ +psutil_cpu_count_logical(PyObject *self, PyObject *args) { SYSTEM_INFO system_info; system_info.dwNumberOfProcessors = 0; @@ -519,8 +511,7 @@ psutil_cpu_count_logical(PyObject *self, PyObject *args) * Return the number of physical CPU cores. */ static PyObject * -psutil_cpu_count_phys(PyObject *self, PyObject *args) -{ +psutil_cpu_count_phys(PyObject *self, PyObject *args) { LPFN_GLPI glpi; DWORD rc; PSYSTEM_LOGICAL_PROCESSOR_INFORMATION buffer = NULL; @@ -683,8 +674,7 @@ psutil_proc_name(PyObject *self, PyObject *args) { * Return process memory information as a Python tuple. */ static PyObject * -psutil_proc_memory_info(PyObject *self, PyObject *args) -{ +psutil_proc_memory_info(PyObject *self, PyObject *args) { HANDLE hProcess; DWORD pid; #if (_WIN32_WINNT >= 0x0501) // Windows XP with SP2 @@ -751,8 +741,7 @@ psutil_proc_memory_info(PyObject *self, PyObject *args) * Alternative implementation of the one above but bypasses ACCESS DENIED. */ static PyObject * -psutil_proc_memory_info_2(PyObject *self, PyObject *args) -{ +psutil_proc_memory_info_2(PyObject *self, PyObject *args) { DWORD pid; PSYSTEM_PROCESS_INFORMATION process; PVOID buffer; @@ -806,8 +795,7 @@ psutil_proc_memory_info_2(PyObject *self, PyObject *args) * in bytes. */ static PyObject * -psutil_virtual_mem(PyObject *self, PyObject *args) -{ +psutil_virtual_mem(PyObject *self, PyObject *args) { MEMORYSTATUSEX memInfo; memInfo.dwLength = sizeof(MEMORYSTATUSEX); @@ -829,8 +817,7 @@ psutil_virtual_mem(PyObject *self, PyObject *args) * sum of the designated times across all processors. */ static PyObject * -psutil_cpu_times(PyObject *self, PyObject *args) -{ +psutil_cpu_times(PyObject *self, PyObject *args) { float idle, kernel, user, system; FILETIME idle_time, kernel_time, user_time; @@ -856,8 +843,7 @@ psutil_cpu_times(PyObject *self, PyObject *args) * Same as above but for all system CPUs. */ static PyObject * -psutil_per_cpu_times(PyObject *self, PyObject *args) -{ +psutil_per_cpu_times(PyObject *self, PyObject *args) { float idle, kernel, user; typedef DWORD (_stdcall * NTQSI_PROC) (int, PVOID, ULONG, PULONG); NTQSI_PROC NtQuerySystemInformation; @@ -950,8 +936,7 @@ error: */ static PyObject * -psutil_proc_cwd(PyObject *self, PyObject *args) -{ +psutil_proc_cwd(PyObject *self, PyObject *args) { long pid; HANDLE processHandle = NULL; PVOID pebAddress; @@ -1152,8 +1137,7 @@ psutil_proc_suspend_or_resume(DWORD pid, int suspend) static PyObject * -psutil_proc_suspend(PyObject *self, PyObject *args) -{ +psutil_proc_suspend(PyObject *self, PyObject *args) { long pid; int suspend = 1; @@ -1166,8 +1150,7 @@ psutil_proc_suspend(PyObject *self, PyObject *args) static PyObject * -psutil_proc_resume(PyObject *self, PyObject *args) -{ +psutil_proc_resume(PyObject *self, PyObject *args) { long pid; int suspend = 0; @@ -1180,8 +1163,7 @@ psutil_proc_resume(PyObject *self, PyObject *args) static PyObject * -psutil_proc_threads(PyObject *self, PyObject *args) -{ +psutil_proc_threads(PyObject *self, PyObject *args) { HANDLE hThread; THREADENTRY32 te32 = {0}; long pid; @@ -1286,8 +1268,7 @@ error: static PyObject * -psutil_proc_open_files(PyObject *self, PyObject *args) -{ +psutil_proc_open_files(PyObject *self, PyObject *args) { long pid; HANDLE processHandle; DWORD access = PROCESS_DUP_HANDLE | PROCESS_QUERY_INFORMATION; @@ -1313,8 +1294,7 @@ psutil_proc_open_files(PyObject *self, PyObject *args) If no match is found return an empty string. */ static PyObject * -psutil_win32_QueryDosDevice(PyObject *self, PyObject *args) -{ +psutil_win32_QueryDosDevice(PyObject *self, PyObject *args) { LPCTSTR lpDevicePath; TCHAR d = TEXT('A'); TCHAR szBuff[5]; @@ -1341,8 +1321,7 @@ psutil_win32_QueryDosDevice(PyObject *self, PyObject *args) * Return process username as a "DOMAIN//USERNAME" string. */ static PyObject * -psutil_proc_username(PyObject *self, PyObject *args) -{ +psutil_proc_username(PyObject *self, PyObject *args) { long pid; HANDLE processHandle; HANDLE tokenHandle; @@ -1463,8 +1442,7 @@ psutil_proc_username(PyObject *self, PyObject *args) * Return a list of network connections opened by a process */ static PyObject * -psutil_net_connections(PyObject *self, PyObject *args) -{ +psutil_net_connections(PyObject *self, PyObject *args) { static long null_address[4] = { 0, 0, 0, 0 }; unsigned long pid; @@ -1903,8 +1881,7 @@ error: * Get process priority as a Python integer. */ static PyObject * -psutil_proc_priority_get(PyObject *self, PyObject *args) -{ +psutil_proc_priority_get(PyObject *self, PyObject *args) { long pid; DWORD priority; HANDLE hProcess; @@ -1930,8 +1907,7 @@ psutil_proc_priority_get(PyObject *self, PyObject *args) * Set process priority. */ static PyObject * -psutil_proc_priority_set(PyObject *self, PyObject *args) -{ +psutil_proc_priority_set(PyObject *self, PyObject *args) { long pid; int priority; int retval; @@ -1962,8 +1938,7 @@ psutil_proc_priority_set(PyObject *self, PyObject *args) * Get process IO priority as a Python integer. */ static PyObject * -psutil_proc_io_priority_get(PyObject *self, PyObject *args) -{ +psutil_proc_io_priority_get(PyObject *self, PyObject *args) { long pid; HANDLE hProcess; PULONG IoPriority; @@ -1995,8 +1970,7 @@ psutil_proc_io_priority_get(PyObject *self, PyObject *args) * Set process IO priority. */ static PyObject * -psutil_proc_io_priority_set(PyObject *self, PyObject *args) -{ +psutil_proc_io_priority_set(PyObject *self, PyObject *args) { long pid; int prio; HANDLE hProcess; @@ -2036,8 +2010,7 @@ psutil_proc_io_priority_set(PyObject *self, PyObject *args) * Return a Python tuple referencing process I/O counters. */ static PyObject * -psutil_proc_io_counters(PyObject *self, PyObject *args) -{ +psutil_proc_io_counters(PyObject *self, PyObject *args) { DWORD pid; HANDLE hProcess; IO_COUNTERS IoCounters; @@ -2065,8 +2038,7 @@ psutil_proc_io_counters(PyObject *self, PyObject *args) * Return process CPU affinity as a bitmask */ static PyObject * -psutil_proc_cpu_affinity_get(PyObject *self, PyObject *args) -{ +psutil_proc_cpu_affinity_get(PyObject *self, PyObject *args) { DWORD pid; HANDLE hProcess; DWORD_PTR proc_mask; @@ -2096,8 +2068,7 @@ psutil_proc_cpu_affinity_get(PyObject *self, PyObject *args) * Set process CPU affinity */ static PyObject * -psutil_proc_cpu_affinity_set(PyObject *self, PyObject *args) -{ +psutil_proc_cpu_affinity_set(PyObject *self, PyObject *args) { DWORD pid; HANDLE hProcess; DWORD dwDesiredAccess = \ @@ -2132,8 +2103,7 @@ psutil_proc_cpu_affinity_set(PyObject *self, PyObject *args) * suspended status. */ static PyObject * -psutil_proc_is_suspended(PyObject *self, PyObject *args) -{ +psutil_proc_is_suspended(PyObject *self, PyObject *args) { DWORD pid; ULONG i; PSYSTEM_PROCESS_INFORMATION process; @@ -2161,8 +2131,7 @@ psutil_proc_is_suspended(PyObject *self, PyObject *args) * Return path's disk total and free as a Python tuple. */ static PyObject * -psutil_disk_usage(PyObject *self, PyObject *args) -{ +psutil_disk_usage(PyObject *self, PyObject *args) { BOOL retval; ULARGE_INTEGER _, total, free; char *path; @@ -2200,8 +2169,7 @@ return_: * Return a Python list of named tuples with overall network I/O information */ static PyObject * -psutil_net_io_counters(PyObject *self, PyObject *args) -{ +psutil_net_io_counters(PyObject *self, PyObject *args) { char ifname[MAX_PATH]; DWORD dwRetVal = 0; MIB_IFROW *pIfRow = NULL; @@ -2282,8 +2250,7 @@ error: * Return a Python dict of tuples for disk I/O information */ static PyObject * -psutil_disk_io_counters(PyObject *self, PyObject *args) -{ +psutil_disk_io_counters(PyObject *self, PyObject *args) { DISK_PERFORMANCE_WIN_2008 diskPerformance; DWORD dwSize; HANDLE hDevice = NULL; @@ -2384,8 +2351,7 @@ static char *psutil_get_drive_type(int type) * (drive_letter, drive_letter, type, "") */ static PyObject * -psutil_disk_partitions(PyObject *self, PyObject *args) -{ +psutil_disk_partitions(PyObject *self, PyObject *args) { DWORD num_bytes; char drive_strings[255]; char *drive_letter = drive_strings; @@ -2505,8 +2471,7 @@ error: * Return a Python dict of tuples for disk I/O information */ static PyObject * -psutil_users(PyObject *self, PyObject *args) -{ +psutil_users(PyObject *self, PyObject *args) { HANDLE hServer = NULL; LPTSTR buffer_user = NULL; LPTSTR buffer_addr = NULL; @@ -2664,8 +2629,7 @@ error: * Return the number of handles opened by process. */ static PyObject * -psutil_proc_num_handles(PyObject *self, PyObject *args) -{ +psutil_proc_num_handles(PyObject *self, PyObject *args) { DWORD pid; HANDLE hProcess; DWORD handleCount; @@ -2699,8 +2663,7 @@ psutil_proc_num_handles(PyObject *self, PyObject *args) * - io counters (fallback) */ static PyObject * -psutil_proc_info(PyObject *self, PyObject *args) -{ +psutil_proc_info(PyObject *self, PyObject *args) { DWORD pid; PSYSTEM_PROCESS_INFORMATION process; PVOID buffer; @@ -2790,8 +2753,7 @@ static char *get_region_protection_string(ULONG protection) * Return a list of process's memory mappings. */ static PyObject * -psutil_proc_memory_maps(PyObject *self, PyObject *args) -{ +psutil_proc_memory_maps(PyObject *self, PyObject *args) { DWORD pid; HANDLE hProcess = NULL; MEMORY_BASIC_INFORMATION basicInfo; @@ -2861,8 +2823,7 @@ error: * Return a {pid:ppid, ...} dict for all running processes. */ static PyObject * -psutil_ppid_map(PyObject *self, PyObject *args) -{ +psutil_ppid_map(PyObject *self, PyObject *args) { PyObject *pid = NULL; PyObject *ppid = NULL; PyObject *py_retdict = PyDict_New(); @@ -2911,8 +2872,7 @@ error: */ static PyObject * -psutil_net_if_addrs(PyObject *self, PyObject *args) -{ +psutil_net_if_addrs(PyObject *self, PyObject *args) { unsigned int i = 0; ULONG family; PCTSTR intRet; @@ -3062,8 +3022,7 @@ error: 'full duplex') */ static PyObject * -psutil_net_if_stats(PyObject *self, PyObject *args) -{ +psutil_net_if_stats(PyObject *self, PyObject *args) { int i; DWORD dwSize = 0; DWORD dwRetVal = 0; |