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