summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2017-05-12 18:59:05 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2017-05-12 18:59:05 +0200
commitbb6ffa8b7f2a0865c8ecda05c98f51794fcfef50 (patch)
tree873798ec55ab305e591d2a6077ab5603b026eae3
parente988ae62abf8ea588046312f4935121643691ef7 (diff)
downloadpsutil-bb6ffa8b7f2a0865c8ecda05c98f51794fcfef50.tar.gz
broken links: also inspect C and H files
-rw-r--r--psutil/_psutil_bsd.c10
-rw-r--r--psutil/_psutil_sunos.c4
-rw-r--r--psutil/arch/bsd/freebsd.c4
-rw-r--r--psutil/arch/bsd/freebsd_socks.c3
-rw-r--r--psutil/arch/bsd/openbsd.c3
-rw-r--r--psutil/arch/solaris/v10/ifaddrs.c2
-rwxr-xr-xscripts/internal/check_broken_links.py46
7 files changed, 52 insertions, 20 deletions
diff --git a/psutil/_psutil_bsd.c b/psutil/_psutil_bsd.c
index 43189a21..3fa93d4b 100644
--- a/psutil/_psutil_bsd.c
+++ b/psutil/_psutil_bsd.c
@@ -7,7 +7,7 @@
* Platform-specific module methods for FreeBSD and OpenBSD.
* OpenBSD references:
- * - OpenBSD source code: http://anoncvs.spacehopper.org/openbsd-src/
+ * - OpenBSD source code: https://github.com/openbsd/src
*
* OpenBSD / NetBSD: missing APIs compared to FreeBSD implementation:
* - psutil.net_connections()
@@ -234,13 +234,13 @@ psutil_proc_oneshot_info(PyObject *self, PyObject *args) {
rss = (long)kp.p_vm_rssize * pagesize;
#ifdef PSUTIL_OPENBSD
// VMS, this is how ps determines it on OpenBSD:
- // http://anoncvs.spacehopper.org/openbsd-src/tree/bin/ps/print.c#n461
- // vms
+ // https://github.com/openbsd/src/blob/
+ // 588f7f8c69786211f2d16865c552afb91b1c7cba/bin/ps/print.c#L505
vms = (long)(kp.p_vm_dsize + kp.p_vm_ssize + kp.p_vm_tsize) * pagesize;
#elif PSUTIL_NETBSD
// VMS, this is how top determines it on NetBSD:
- // ftp://ftp.iij.ad.jp/pub/NetBSD/NetBSD-release-6/src/external/bsd/
- // top/dist/machine/m_netbsd.c
+ // https://github.com/IIJ-NetBSD/netbsd-src/blob/master/external/
+ // bsd/top/dist/machine/m_netbsd.c
vms = (long)kp.p_vm_msize * pagesize;
#endif
memtext = (long)kp.p_vm_tsize * pagesize;
diff --git a/psutil/_psutil_sunos.c b/psutil/_psutil_sunos.c
index c205a3ac..422d48c7 100644
--- a/psutil/_psutil_sunos.c
+++ b/psutil/_psutil_sunos.c
@@ -306,7 +306,7 @@ psutil_proc_num_ctx_switches(PyObject *self, PyObject *args) {
* - 'pr_ioch' is a sum of chars read and written, with no distinction
* - 'pr_inblk' and 'pr_oublk', which should be the number of bytes
* read and written, hardly increase and according to:
- * http://www.brendangregg.com/Perf/paper_diskubyp1.pdf
+ * http://www.brendangregg.com/Solaris/paper_diskubyp1.pdf
* ...they should be meaningless anyway.
*
static PyObject*
@@ -326,7 +326,7 @@ proc_io_counters(PyObject* self, PyObject* args) {
// *and* written.
// 'pr_inblk' and 'pr_oublk' should be expressed in blocks of
// 8KB according to:
- // http://www.brendangregg.com/Perf/paper_diskubyp1.pdf (pag. 8)
+ // http://www.brendangregg.com/Solaris/paper_diskubyp1.pdf (pag. 8)
return Py_BuildValue("kkkk",
info.pr_ioch,
info.pr_ioch,
diff --git a/psutil/arch/bsd/freebsd.c b/psutil/arch/bsd/freebsd.c
index 11594b9d..a4569001 100644
--- a/psutil/arch/bsd/freebsd.c
+++ b/psutil/arch/bsd/freebsd.c
@@ -324,8 +324,8 @@ psutil_proc_threads(PyObject *self, PyObject *args) {
// Retrieves all threads used by process returning a list of tuples
// including thread id, user time and system time.
// Thanks to Robert N. M. Watson:
- // http://fxr.googlebit.com/source/usr.bin/procstat/
- // procstat_threads.c?v=8-CURRENT
+ // http://code.metager.de/source/xref/freebsd/usr.bin/procstat/
+ // procstat_threads.c
long pid;
int mib[4];
struct kinfo_proc *kip = NULL;
diff --git a/psutil/arch/bsd/freebsd_socks.c b/psutil/arch/bsd/freebsd_socks.c
index c7a26323..4f36ef11 100644
--- a/psutil/arch/bsd/freebsd_socks.c
+++ b/psutil/arch/bsd/freebsd_socks.c
@@ -202,8 +202,7 @@ psutil_get_pid_from_sock(int sock_hash) {
// Reference:
-// https://gitorious.org/freebsd/freebsd/source/
-// f1d6f4778d2044502209708bc167c05f9aa48615:usr.bin/sockstat/sockstat.c
+// https://github.com/freebsd/freebsd/blob/master/usr.bin/sockstat/sockstat.c
int psutil_gather_inet(int proto, PyObject *py_retlist) {
struct xinpgen *xig, *exig;
struct xinpcb *xip;
diff --git a/psutil/arch/bsd/openbsd.c b/psutil/arch/bsd/openbsd.c
index 8891c461..3b3f4449 100644
--- a/psutil/arch/bsd/openbsd.c
+++ b/psutil/arch/bsd/openbsd.c
@@ -415,7 +415,8 @@ psutil_proc_num_fds(PyObject *self, PyObject *args) {
PyObject *
psutil_proc_cwd(PyObject *self, PyObject *args) {
// Reference:
- // http://anoncvs.spacehopper.org/openbsd-src/tree/bin/ps/print.c#n179
+ // https://github.com/openbsd/src/blob/
+ // 588f7f8c69786211f2d16865c552afb91b1c7cba/bin/ps/print.c#L191
long pid;
struct kinfo_proc kp;
char path[MAXPATHLEN];
diff --git a/psutil/arch/solaris/v10/ifaddrs.c b/psutil/arch/solaris/v10/ifaddrs.c
index 59529e6a..2eb36a3a 100644
--- a/psutil/arch/solaris/v10/ifaddrs.c
+++ b/psutil/arch/solaris/v10/ifaddrs.c
@@ -1,7 +1,7 @@
/* Refrences:
* https://lists.samba.org/archive/samba-technical/2009-February/063079.html
* http://stackoverflow.com/questions/4139405/#4139811
- * https://code.google.com/p/openpgm/source/browse/trunk/openpgm/pgm/getifaddrs.c
+ * https://github.com/steve-o/openpgm/blob/master/openpgm/pgm/getifaddrs.c
*/
#include <string.h>
diff --git a/scripts/internal/check_broken_links.py b/scripts/internal/check_broken_links.py
index 3d1766b3..0ae2b323 100755
--- a/scripts/internal/check_broken_links.py
+++ b/scripts/internal/check_broken_links.py
@@ -55,7 +55,7 @@ HERE = os.path.abspath(os.path.dirname(__file__))
REGEX = re.compile(
r'(?:http|ftp|https)?://'
r'(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+')
-REQUEST_TIMEOUT = 10
+REQUEST_TIMEOUT = 15
# There are some status codes sent by websites on HEAD request.
# Like 503 by Microsoft, and 401 by Apple
# They need to be sent GET request
@@ -87,27 +87,26 @@ def find_urls(s):
return list(set([sanitize_url(x) for x in matches]))
-def parse_rst(filename):
+def parse_rst(fname):
"""Look for links in a .rst file."""
- with open(filename) as f:
+ with open(fname) as f:
text = f.read()
urls = find_urls(text)
# HISTORY file has a lot of dead links.
- if filename == 'HISTORY.rst' and urls:
+ if fname == 'HISTORY.rst' and urls:
urls = [
x for x in urls if
not x.startswith('https://github.com/giampaolo/psutil/issues')]
return urls
-def parse_py(filename):
+def parse_py(fname):
"""Look for links in a .py file."""
- with open(filename) as f:
+ with open(fname) as f:
lines = f.readlines()
urls = set()
for i, line in enumerate(lines):
for url in find_urls(line):
- url = urls[0]
# comment block
if line.lstrip().startswith('# '):
subidx = i + 1
@@ -122,12 +121,45 @@ def parse_py(filename):
return list(urls)
+def parse_c(fname):
+ """Look for links in a .py file."""
+ with open(fname) as f:
+ lines = f.readlines()
+ urls = set()
+ for i, line in enumerate(lines):
+ for url in find_urls(line):
+ # comment block //
+ if line.lstrip().startswith('// '):
+ subidx = i + 1
+ while True:
+ nextline = lines[subidx].strip()
+ if re.match('^// .+', nextline):
+ url += nextline[2:].strip()
+ else:
+ break
+ subidx += 1
+ # comment block /*
+ elif line.lstrip().startswith('* '):
+ subidx = i + 1
+ while True:
+ nextline = lines[subidx].strip()
+ if re.match('^\* .+', nextline):
+ url += nextline[1:].strip()
+ else:
+ break
+ subidx += 1
+ urls.add(url)
+ return list(urls)
+
+
def get_urls(fname):
"""Extracts all URLs available in specified fname."""
if fname.endswith('.rst'):
return parse_rst(fname)
elif fname.endswith('.py'):
return parse_py(fname)
+ elif fname.endswith('.c') or fname.endswith('.h'):
+ return parse_c(fname)
else:
return []