Skip to content

Commit

Permalink
fix #1855 doc
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Oct 19, 2020
1 parent b6815b6 commit ba083a0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
5 changes: 4 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2398,7 +2398,10 @@ Kill process tree
if include_parent:
children.append(parent)
for p in children:
p.send_signal(sig)
try:
p.send_signal(sig)
except psutil.NoSuchProcess:
pass
gone, alive = psutil.wait_procs(children, timeout=timeout,
callback=on_terminate)
return (gone, alive)
Expand Down
26 changes: 17 additions & 9 deletions scripts/internal/print_downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
LIMIT = 100
GITHUB_SCRIPT_URL = "https://github.com/giampaolo/psutil/blob/master/" \
"scripts/internal/pypistats.py"
LAST_UPDATE = None
bytes_billed = 0


Expand Down Expand Up @@ -57,23 +58,28 @@ def query(cmd):


def top_packages():
return query("pypinfo --all --json --days %s --limit %s '' project" % (
global LAST_UPDATE
ret = query("pypinfo --all --json --days %s --limit %s '' project" % (
DAYS, LIMIT))
LAST_UPDATE = ret['last_update']
return [(x['project'], x['download_count']) for x in ret['rows']]


def ranking():
data = top_packages()
for i, line in enumerate(data['rows'], 1):
if line['project'] == PKGNAME:
i = 1
for name, downloads in data:
if name == PKGNAME:
return i
i += 1
raise ValueError("can't find %s" % PKGNAME)


def downloads():
data = top_packages()
for line in data['rows']:
if line['project'] == PKGNAME:
return line['download_count']
for name, downloads in data:
if name == PKGNAME:
return downloads
raise ValueError("can't find %s" % PKGNAME)


Expand Down Expand Up @@ -123,16 +129,18 @@ def print_markdown_table(title, left, rows):


def main():
downs = downloads()

print("# Download stats")
print("")
s = "psutil download statistics of the last %s days (last update " % DAYS
s += "*%s*).\n" % top_packages()['last_update']
s += "*%s*).\n" % LAST_UPDATE
s += "Generated via [pypistats.py](%s) script.\n" % GITHUB_SCRIPT_URL
print(s)

data = [
{'what': 'Per month', 'download_count': downloads()},
{'what': 'Per day', 'download_count': int(downloads() / 30)},
{'what': 'Per month', 'download_count': downs},
{'what': 'Per day', 'download_count': int(downs / 30)},
{'what': 'PYPI ranking', 'download_count': ranking()}
]
print_markdown_table('Overview', 'what', data)
Expand Down

0 comments on commit ba083a0

Please sign in to comment.