Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 #!/usr/bin/env python
3 # Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
7 """
8 A clone of 'who' command; print information about users who are
9 currently logged in.
10 """
12 import sys
13 from datetime import datetime
15 import psutil
16 from psutil._compat import print_
19 def main():
20 users = psutil.get_users()
21 for user in users:
22 print_("%-15s %-15s %s (%s)" % \
23 (user.name,
24 user.terminal or '-',
25 datetime.fromtimestamp(user.started).strftime("%Y-%m-%d %H:%M"),
26 user.host)
27 )
29 if __name__ == '__main__':
30 main()