diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2016-09-22 19:34:26 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2016-09-22 19:34:26 +0200 |
commit | c913480621da83b9cc78ade2217a81490142a604 (patch) | |
tree | 04eb18294956bec95685f3a81e10e7f22976f78f | |
parent | ea270f3627f55e3ab305de417573620a83c43455 (diff) | |
download | psutil-c913480621da83b9cc78ade2217a81490142a604.tar.gz |
style changes
-rwxr-xr-x | scripts/disk_usage.py | 1 | ||||
-rwxr-xr-x | scripts/free.py | 1 | ||||
-rwxr-xr-x | scripts/iotop.py | 1 | ||||
-rwxr-xr-x | scripts/killall.py | 4 | ||||
-rwxr-xr-x | scripts/netstat.py | 1 | ||||
-rwxr-xr-x | scripts/nettop.py | 1 | ||||
-rwxr-xr-x | scripts/pidof.py | 1 | ||||
-rwxr-xr-x | scripts/pmap.py | 1 | ||||
-rwxr-xr-x | scripts/procinfo.py | 1 | ||||
-rwxr-xr-x | scripts/procsmem.py | 1 | ||||
-rwxr-xr-x | scripts/ps.py | 1 | ||||
-rwxr-xr-x | scripts/top.py | 12 | ||||
-rwxr-xr-x | scripts/who.py | 1 |
13 files changed, 22 insertions, 5 deletions
diff --git a/scripts/disk_usage.py b/scripts/disk_usage.py index 2bb928c0..37f4da0c 100755 --- a/scripts/disk_usage.py +++ b/scripts/disk_usage.py @@ -58,5 +58,6 @@ def main(): part.fstype, part.mountpoint)) + if __name__ == '__main__': sys.exit(main()) diff --git a/scripts/free.py b/scripts/free.py index 897f006f..82e962ff 100755 --- a/scripts/free.py +++ b/scripts/free.py @@ -37,5 +37,6 @@ def main(): '', '')) + if __name__ == '__main__': main() diff --git a/scripts/iotop.py b/scripts/iotop.py index 200926ed..bb50b6ef 100755 --- a/scripts/iotop.py +++ b/scripts/iotop.py @@ -175,5 +175,6 @@ def main(): except (KeyboardInterrupt, SystemExit): pass + if __name__ == '__main__': main() diff --git a/scripts/killall.py b/scripts/killall.py index b548e7bc..f9cc9201 100755 --- a/scripts/killall.py +++ b/scripts/killall.py @@ -29,4 +29,6 @@ def main(): else: sys.exit(0) -sys.exit(main()) + +if __name__ == '__main__': + main() diff --git a/scripts/netstat.py b/scripts/netstat.py index a5e171bc..1426cd76 100755 --- a/scripts/netstat.py +++ b/scripts/netstat.py @@ -60,5 +60,6 @@ def main(): proc_names.get(c.pid, '?')[:15], )) + if __name__ == '__main__': main() diff --git a/scripts/nettop.py b/scripts/nettop.py index acfa6500..97f80aad 100755 --- a/scripts/nettop.py +++ b/scripts/nettop.py @@ -161,5 +161,6 @@ def main(): except (KeyboardInterrupt, SystemExit): pass + if __name__ == '__main__': main() diff --git a/scripts/pidof.py b/scripts/pidof.py index 8692a315..51e66a45 100755 --- a/scripts/pidof.py +++ b/scripts/pidof.py @@ -49,5 +49,6 @@ def main(): if pids: print(" ".join(pids)) + if __name__ == '__main__': main() diff --git a/scripts/pmap.py b/scripts/pmap.py index f0d53355..16eebb60 100755 --- a/scripts/pmap.py +++ b/scripts/pmap.py @@ -53,5 +53,6 @@ def main(): print("-" * 33) print(templ % ("Total", str(total_rss / 1024) + 'K', '', '')) + if __name__ == '__main__': main() diff --git a/scripts/procinfo.py b/scripts/procinfo.py index 09cc6af4..4afbbb2c 100755 --- a/scripts/procinfo.py +++ b/scripts/procinfo.py @@ -8,6 +8,7 @@ Print detailed information about a process. Author: Giampaolo Rodola' <g.rodola@gmail.com> +$ python scripts/procinfo.py pid 4600 name chrome parent 4554 (bash) diff --git a/scripts/procsmem.py b/scripts/procsmem.py index 494fd6ab..2f2c9183 100755 --- a/scripts/procsmem.py +++ b/scripts/procsmem.py @@ -97,5 +97,6 @@ def main(): print("warning: access denied for %s pids" % (len(ad_pids)), file=sys.stderr) + if __name__ == '__main__': sys.exit(main()) diff --git a/scripts/ps.py b/scripts/ps.py index 8aa3d3f4..b85790d6 100755 --- a/scripts/ps.py +++ b/scripts/ps.py @@ -17,6 +17,7 @@ import time import psutil + PROC_STATUSES_RAW = { psutil.STATUS_RUNNING: "R", psutil.STATUS_SLEEPING: "S", diff --git a/scripts/top.py b/scripts/top.py index 0c99047e..70dbf6c9 100755 --- a/scripts/top.py +++ b/scripts/top.py @@ -14,8 +14,8 @@ $ python scripts/top.py CPU1 [||| ] 7.8% CPU2 [ ] 2.0% CPU3 [||||| ] 13.9% - Mem [||||||||||||||||||| ] 49.8% 4920M/9888M - Swap [ ] 0.0% 0M/0M + Mem [||||||||||||||||||| ] 49.8% 4920M / 9888M + Swap [ ] 0.0% 0M / 0M Processes: 287 (running=1, sleeping=286, zombie=1) Load average: 0.34 0.54 0.46 Uptime: 3 days, 10:16:37 @@ -48,12 +48,14 @@ import psutil # --- curses stuff + def tear_down(): win.keypad(0) curses.nocbreak() curses.echo() curses.endwin() + win = curses.initscr() atexit.register(tear_down) curses.endwin() @@ -75,6 +77,7 @@ def print_line(line, highlight=False): raise else: lineno += 1 + # --- /curses stuff @@ -137,7 +140,7 @@ def print_header(procs_status, num_procs): perc)) mem = psutil.virtual_memory() dashes, empty_dashes = get_dashes(mem.percent) - line = " Mem [%s%s] %5s%% %6s/%s" % ( + line = " Mem [%s%s] %5s%% %6s / %s" % ( dashes, empty_dashes, mem.percent, str(int(mem.used / 1024 / 1024)) + "M", @@ -148,7 +151,7 @@ def print_header(procs_status, num_procs): # swap usage swap = psutil.swap_memory() dashes, empty_dashes = get_dashes(swap.percent) - line = " Swap [%s%s] %5s%% %6s/%s" % ( + line = " Swap [%s%s] %5s%% %6s / %s" % ( dashes, empty_dashes, swap.percent, str(int(swap.used / 1024 / 1024)) + "M", @@ -229,5 +232,6 @@ def main(): except (KeyboardInterrupt, SystemExit): pass + if __name__ == '__main__': main() diff --git a/scripts/who.py b/scripts/who.py index f64c0093..046ec23f 100755 --- a/scripts/who.py +++ b/scripts/who.py @@ -29,5 +29,6 @@ def main(): datetime.fromtimestamp(user.started).strftime("%Y-%m-%d %H:%M"), user.host)) + if __name__ == '__main__': main() |