Skip to content

Commit 6c3142a

Browse files
committed
hostid: Add hostid.py
1 parent 2e3e66a commit 6c3142a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/hostid.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/python3
2+
3+
from optparse import OptionParser
4+
5+
6+
def hostid():
7+
# We're not the only ones being lazy here... musl libc's gethostid(3)
8+
# returns zero as well. hostid can arguably be considered as obsolete.
9+
print("00000000")
10+
11+
12+
if __name__ == "__main__":
13+
parser = OptionParser(
14+
usage="Usage: %prog",
15+
description="Print a 32-bit numeric host machine identifier.",
16+
epilog="This implementation gives an all-zero identifier.",
17+
add_help_option=False,
18+
)
19+
parser.add_option("--help", action="help", help="show usage information and exit")
20+
21+
_, args = parser.parse_args()
22+
23+
if args:
24+
parser.error(f"extra operand '{args[0]}'")
25+
26+
hostid()

0 commit comments

Comments
 (0)