22Sebastian Raschka 2014
33
44watermark.py
5- version 1.0.2
5+ version 1.0.3
66
77
88IPython magic function to print date/time stamps and various system information.
1818 %watermark
1919
2020 optional arguments:
21- -d, --date prints current date
22- -n, --datename prints date with abbrv. day and month names
23- -t, --time prints current time
24- -z, --timezone appends the local time zone
25- -u, --updated appends a string "Last updated: "
26- -c CUSTOM_TIME, --custom_time CUSTOM_TIME
21+ -a AUTHOR, --author AUTHOR
22+ prints author name
23+ -e AUTHOR_EMAIL, --author_email AUTHOR_EMAIL
24+ prints author name and link to email address
25+ -d, --date prints current date
26+ -n, --datename prints date with abbrv. day and month names
27+ -t, --time prints current time
28+ -z, --timezone appends the local time zone
29+ -u, --updated appends a string "Last updated: "
30+ -c CUSTOM_TIME, --custom_time CUSTOM_TIME
2731 prints a valid strftime() string
28- -v, --python prints Python and IPython version
29- -p PACKAGES, --packages PACKAGES
32+ -v, --python prints Python and IPython version
33+ -p PACKAGES, --packages PACKAGES
3034 prints versions of specified Python modules and
3135 packages
32- -m, --machine prints system and machine info
33-
36+ -h, --hostname prints the host name
37+ -m, --machine prints system and machine info
38+
39+
3440Examples:
3541
3642 %watermark -d -t
3743
3844"""
3945import platform
4046from time import strftime
47+ from socket import gethostname
4148from pkg_resources import get_distribution
4249from multiprocessing import cpu_count
4350
@@ -62,14 +69,15 @@ class WaterMark(Magics):
6269 @argument ('-c' , '--custom_time' , type = str , help = 'prints a valid strftime() string' )
6370 @argument ('-v' , '--python' , action = 'store_true' , help = 'prints Python and IPython version' )
6471 @argument ('-p' , '--packages' , type = str , help = 'prints versions of specified Python modules and packages' )
72+ @argument ('-h' , '--hostname' , action = 'store_true' , help = 'prints the host name' )
6573 @argument ('-m' , '--machine' , action = 'store_true' , help = 'prints system and machine info' )
6674 @line_magic
6775 def watermark (self , line ):
6876 """
6977 IPython magic function to print date/time stamps
7078 and various system information.
7179
72- watermark version 1.0.2
80+ watermark version 1.0.3
7381
7482 """
7583 self .out = ''
@@ -101,6 +109,13 @@ def watermark(self, line):
101109 self ._get_packages (args .packages )
102110 if args .machine :
103111 self ._get_sysinfo ()
112+ if args .hostname :
113+ space = ''
114+ if args .machine :
115+ space = ' '
116+ self .out += '\n host name%s: %s' % (space , gethostname ())
117+
118+
104119
105120 print (self .out )
106121
0 commit comments