mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-07-31 05:57:16 +00:00
example: Redirect --help output to stdout/stderr
When --help is requested, print usage() to stdout. When an illegal option is passed, print usage to stderr. Signed-off-by: Philipp Hahn <hahn@univention.de>
This commit is contained in:
parent
08d56e24b0
commit
78adf5099f
@ -469,9 +469,9 @@ def myDomainEventIOErrorCallback(conn, dom, srcpath, devalias, action, opaque):
|
|||||||
def myDomainEventGraphicsCallback(conn, dom, phase, localAddr, remoteAddr, authScheme, subject, opaque):
|
def myDomainEventGraphicsCallback(conn, dom, phase, localAddr, remoteAddr, authScheme, subject, opaque):
|
||||||
print "myDomainEventGraphicsCallback: Domain %s(%s) %d %s" % (dom.name(), dom.ID(), phase, authScheme)
|
print "myDomainEventGraphicsCallback: Domain %s(%s) %d %s" % (dom.name(), dom.ID(), phase, authScheme)
|
||||||
|
|
||||||
def usage():
|
def usage(out=sys.stderr):
|
||||||
print "usage: "+os.path.basename(sys.argv[0])+" [uri]"
|
print >>out, "usage: "+os.path.basename(sys.argv[0])+" [uri]"
|
||||||
print " uri will default to qemu:///system"
|
print >>out, " uri will default to qemu:///system"
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
try:
|
try:
|
||||||
@ -483,7 +483,7 @@ def main():
|
|||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
for o, a in opts:
|
for o, a in opts:
|
||||||
if o in ("-h", "--help"):
|
if o in ("-h", "--help"):
|
||||||
usage()
|
usage(sys.stdout)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
if len(args) >= 1:
|
if len(args) >= 1:
|
||||||
|
Loading…
Reference in New Issue
Block a user