Displaying 1 result from an estimated 1 matches for "__stderr__".
Did you mean:
__stderr
2017 Aug 07
1
Avoiding console prints by Libvirt Qemu python APIs
...ort libvirt
conn = libvirt.open('qemu:///system')
# Find the application in the virsh domaintry:
sys.stdout = open(os.devnull, "w")
sys.stderr = open(os.devnull, "w")
dom = conn.lookupByName('abcd')
sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__except Exception as e:
syslog.syslog (syslog.LOG_ERR, 'Could not find the domain. ERROR:
%s.' % (e))
sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__
Output:
$ python test.py
libvirt: QEMU Driver error : Domain not found: no domain with matching
name 'abcd'
$
Is...