Suppressing the output is useless (fucking C function...)

This commit is contained in:
Joshua Boniface 2018-06-04 01:39:39 -04:00
parent 012f341e75
commit 285b4434b7
1 changed files with 1 additions and 14 deletions

15
pvcf.py
View File

@ -9,8 +9,7 @@ import os, sys, libvirt, uuid
# > lookupByUUID # > lookupByUUID
# This function is a wrapper for libvirt.lookupByUUID which fixes some problems # This function is a wrapper for libvirt.lookupByUUID which fixes some problems
# 1. Takes a text UUID and handles converting it to bytes # 1. Takes a text UUID and handles converting it to bytes
# 2. Disables stdout to avoid stupid printouts # 2. Try's it and returns a sensible value if not
# 3. Try's it and returns a sensible value if not
def lookupByUUID(tuuid): def lookupByUUID(tuuid):
conn = None conn = None
dom = None dom = None
@ -19,12 +18,6 @@ def lookupByUUID(tuuid):
# Convert the text UUID to bytes # Convert the text UUID to bytes
buuid = uuid.UUID(tuuid).bytes buuid = uuid.UUID(tuuid).bytes
# Flush and disable stdout and stderr
sys.stdout.flush()
sys.stderr.flush()
sys.stdout = open(os.devnull, 'w')
sys.stderr = open(os.devnull, 'w')
# Try # Try
try: try:
# Open a libvirt connection # Open a libvirt connection
@ -46,12 +39,6 @@ def lookupByUUID(tuuid):
if conn != None: if conn != None:
conn.close() conn.close()
# Flush and enable stdout and stderr
sys.stdout.flush()
sys.stderr.flush()
sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__
# Return the dom object (or None) # Return the dom object (or None)
return dom return dom