|
2 | 2 | Sebastian Raschka 2014 |
3 | 3 |
|
4 | 4 | watermark.py |
5 | | -version 1.0.2 |
| 5 | +version 1.0.3 |
6 | 6 |
|
7 | 7 |
|
8 | 8 | IPython magic function to print date/time stamps and various system information. |
|
18 | 18 | %watermark |
19 | 19 | |
20 | 20 | 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 |
27 | 31 | 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 |
30 | 34 | prints versions of specified Python modules and |
31 | 35 | 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 | +
|
34 | 40 | Examples: |
35 | 41 |
|
36 | 42 | %watermark -d -t |
37 | 43 | |
38 | 44 | """ |
39 | 45 | import platform |
40 | 46 | from time import strftime |
| 47 | +from socket import gethostname |
41 | 48 | from pkg_resources import get_distribution |
42 | 49 | from multiprocessing import cpu_count |
43 | 50 |
|
@@ -62,14 +69,15 @@ class WaterMark(Magics): |
62 | 69 | @argument('-c', '--custom_time', type=str, help='prints a valid strftime() string') |
63 | 70 | @argument('-v', '--python', action='store_true', help='prints Python and IPython version') |
64 | 71 | @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') |
65 | 73 | @argument('-m', '--machine', action='store_true', help='prints system and machine info') |
66 | 74 | @line_magic |
67 | 75 | def watermark(self, line): |
68 | 76 | """ |
69 | 77 | IPython magic function to print date/time stamps |
70 | 78 | and various system information. |
71 | 79 | |
72 | | - watermark version 1.0.2 |
| 80 | + watermark version 1.0.3 |
73 | 81 | |
74 | 82 | """ |
75 | 83 | self.out = '' |
@@ -101,6 +109,13 @@ def watermark(self, line): |
101 | 109 | self._get_packages(args.packages) |
102 | 110 | if args.machine: |
103 | 111 | self._get_sysinfo() |
| 112 | + if args.hostname: |
| 113 | + space = '' |
| 114 | + if args.machine: |
| 115 | + space = ' ' |
| 116 | + self.out += '\nhost name%s: %s' %(space, gethostname()) |
| 117 | + |
| 118 | + |
104 | 119 |
|
105 | 120 | print(self.out) |
106 | 121 |
|
|