mirror of
https://github.com/rasbt/python_reference.git
synced 2024-11-23 20:11:13 +00:00
prints host name via -h
This commit is contained in:
parent
5739472a48
commit
54e530cf5b
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"metadata": {
|
||||
"name": "",
|
||||
"signature": "sha256:0b017c7b1bd605534beb62287fd7916407f3782284c44ee02093a73e4a9896a8"
|
||||
"signature": "sha256:9c5a9f291a08a3d3ea3459178cdaf482808d62014c15f3542116e57632436f7e"
|
||||
},
|
||||
"nbformat": 3,
|
||||
"nbformat_minor": 0,
|
||||
|
@ -198,6 +198,7 @@
|
|||
" -p PACKAGES, --packages PACKAGES\n",
|
||||
" prints versions of specified Python modules and\n",
|
||||
" packages\n",
|
||||
" -h, --hostname prints the host name\n",
|
||||
" -m, --machine prints system and machine info\n",
|
||||
"</pre>"
|
||||
]
|
||||
|
@ -432,7 +433,14 @@
|
|||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 12
|
||||
"prompt_number": 3
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"<br>"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Sebastian Raschka 2014
|
||||
|
||||
watermark.py
|
||||
version 1.0.2
|
||||
version 1.0.3
|
||||
|
||||
|
||||
IPython magic function to print date/time stamps and various system information.
|
||||
|
@ -18,18 +18,24 @@ Usage:
|
|||
%watermark
|
||||
|
||||
optional arguments:
|
||||
-d, --date prints current date
|
||||
-n, --datename prints date with abbrv. day and month names
|
||||
-t, --time prints current time
|
||||
-z, --timezone appends the local time zone
|
||||
-u, --updated appends a string "Last updated: "
|
||||
-c CUSTOM_TIME, --custom_time CUSTOM_TIME
|
||||
-a AUTHOR, --author AUTHOR
|
||||
prints author name
|
||||
-e AUTHOR_EMAIL, --author_email AUTHOR_EMAIL
|
||||
prints author name and link to email address
|
||||
-d, --date prints current date
|
||||
-n, --datename prints date with abbrv. day and month names
|
||||
-t, --time prints current time
|
||||
-z, --timezone appends the local time zone
|
||||
-u, --updated appends a string "Last updated: "
|
||||
-c CUSTOM_TIME, --custom_time CUSTOM_TIME
|
||||
prints a valid strftime() string
|
||||
-v, --python prints Python and IPython version
|
||||
-p PACKAGES, --packages PACKAGES
|
||||
-v, --python prints Python and IPython version
|
||||
-p PACKAGES, --packages PACKAGES
|
||||
prints versions of specified Python modules and
|
||||
packages
|
||||
-m, --machine prints system and machine info
|
||||
-h, --hostname prints the host name
|
||||
-m, --machine prints system and machine info
|
||||
|
||||
|
||||
Examples:
|
||||
|
||||
|
@ -38,6 +44,7 @@ Examples:
|
|||
"""
|
||||
import platform
|
||||
from time import strftime
|
||||
from socket import gethostname
|
||||
from pkg_resources import get_distribution
|
||||
from multiprocessing import cpu_count
|
||||
|
||||
|
@ -62,6 +69,7 @@ class WaterMark(Magics):
|
|||
@argument('-c', '--custom_time', type=str, help='prints a valid strftime() string')
|
||||
@argument('-v', '--python', action='store_true', help='prints Python and IPython version')
|
||||
@argument('-p', '--packages', type=str, help='prints versions of specified Python modules and packages')
|
||||
@argument('-h', '--hostname', action='store_true', help='prints the host name')
|
||||
@argument('-m', '--machine', action='store_true', help='prints system and machine info')
|
||||
@line_magic
|
||||
def watermark(self, line):
|
||||
|
@ -69,7 +77,7 @@ class WaterMark(Magics):
|
|||
IPython magic function to print date/time stamps
|
||||
and various system information.
|
||||
|
||||
watermark version 1.0.2
|
||||
watermark version 1.0.3
|
||||
|
||||
"""
|
||||
self.out = ''
|
||||
|
@ -101,6 +109,13 @@ class WaterMark(Magics):
|
|||
self._get_packages(args.packages)
|
||||
if args.machine:
|
||||
self._get_sysinfo()
|
||||
if args.hostname:
|
||||
space = ''
|
||||
if args.machine:
|
||||
space = ' '
|
||||
self.out += '\nhost name%s: %s' %(space, gethostname())
|
||||
|
||||
|
||||
|
||||
print(self.out)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user