From 8caf5501142701099bab7a8ff1650f2dc7352b7b Mon Sep 17 00:00:00 2001
From: Oleksii Shevchuk
Date: Mon, 20 Mar 2017 18:07:22 +0200
Subject: [PATCH] Fix ps -s output
---
pupy/modules/last.py | 2 +-
pupy/modules/ps.py | 6 +++++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/pupy/modules/last.py b/pupy/modules/last.py
index 09f62172..39c55a1a 100644
--- a/pupy/modules/last.py
+++ b/pupy/modules/last.py
@@ -50,7 +50,7 @@ class LastModule(PupyModule):
if record['end'] == -1:
if record['user'] == 'root':
color = 'lightred'
- elif record['duration'] < 24*60*60:
+ elif record['duration'] < 60*60:
color = 'lightgreen'
elif record['duration'] > 7*24*60*60:
color = 'cyan'
diff --git a/pupy/modules/ps.py b/pupy/modules/ps.py
index 7cbf849a..f17c2f4f 100644
--- a/pupy/modules/ps.py
+++ b/pupy/modules/ps.py
@@ -37,6 +37,9 @@ def gen_colinfo(data):
def gen_columns(record, colinfo):
columns = {}
+ if type(record['cmdline']) is not list:
+ record['cmdline'] = [record['cmdline']]
+
columns['name'] = record.get('name') or '?'
columns['cmdline'] = ' '.join([
x for x in record['cmdline'][1:] if x.strip()
@@ -97,8 +100,9 @@ def print_psinfo(fout, pupyps, data, colinfo, width=80, sections=[]):
) else ( 1 if (y in keys and not x in keys) else cmp(x, y))
for pid, info in data.iteritems():
- fout.write('\n --- PID: {} ---- \n\n'.format(pid))
if sections is not None:
+ fout.write('\n --- PID: {} ---- \n\n'.format(pid))
+
infosecs = {
'general': []
}