qubes-bug-report: remove trailing spaces

QubesOS/qubes-issues#901
This commit is contained in:
Marek Marczykowski-Górecki 2016-05-17 20:31:24 +02:00
parent b1e368da43
commit 692254fcbf
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -23,7 +23,7 @@ def is_program_installed_in_qube( program, qube_name ):
return is_installed return is_installed
#this function requires virsh #this function requires virsh
#domstate only works for Xen domU (guests) #domstate only works for Xen domU (guests)
def is_qube_running( qube_name ): def is_qube_running( qube_name ):
runs = False runs = False
@ -58,37 +58,37 @@ def get_qube_packages( qube_name ):
pass #do nothing pass #do nothing
else: else:
content += "**No packages listed, because Qube " + qube_name + " was not running**\n\n" content += "**No packages listed, because Qube " + qube_name + " was not running**\n\n"
return content
return content
def get_dom0_packages(): def get_dom0_packages():
content = create_heading( "Dom0 Packages", 2 ) content = create_heading( "Dom0 Packages", 2 )
out = subprocess.check_output([ "rpm", "-qa", "qubes-*" ]) out = subprocess.check_output([ "rpm", "-qa", "qubes-*" ])
out = out.decode('utf-8') out = out.decode('utf-8')
content += wrap_code( out ) content += wrap_code( out )
return content return content
def wrap_code( text ): def wrap_code( text ):
code = "~~~\n" + text + "~~~\n\n" code = "~~~\n" + text + "~~~\n\n"
return code return code
def create_heading( heading, level ): def create_heading( heading, level ):
heading = heading + "\n\n" heading = heading + "\n\n"
if 1 == level: if 1 == level:
heading = "# " + heading heading = "# " + heading
elif 2 == level: elif 2 == level:
heading = "## " + heading heading = "## " + heading
else: else:
heading = "### " + heading heading = "### " + heading
return heading return heading
def get_log_file_content( qube_name ): def get_log_file_content( qube_name ):
@ -110,10 +110,10 @@ def get_log_file_content( qube_name ):
def get_qube_prefs( qube_name ): def get_qube_prefs( qube_name ):
qube_prefs = subprocess.check_output([ "qvm-prefs", qube_name ]) qube_prefs = subprocess.check_output([ "qvm-prefs", qube_name ])
qube_prefs = qube_prefs.decode('utf-8') qube_prefs = qube_prefs.decode('utf-8')
content = create_heading( "Qube Prefs", 2 ) content = create_heading( "Qube Prefs", 2 )
content += wrap_code( qube_prefs ) content += wrap_code( qube_prefs )
return content return content
@ -128,7 +128,7 @@ def report( qube_name ):
content_text += get_dom0_packages() content_text += get_dom0_packages()
content_text += get_log_file_content( qube_name ) content_text += get_log_file_content( qube_name )
content_text += get_qube_packages( qube_name ) content_text += get_qube_packages( qube_name )
report = template.format( title=title_text, content=content_text ) report = template.format( title=title_text, content=content_text )
@ -148,10 +148,10 @@ def send_report( dest_qube, file_path):
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
print( "Error while starting: " + dest_qube, file = sys.stderr ) print( "Error while starting: " + dest_qube, file = sys.stderr )
try: try:
subprocess.check_call([ "qvm-move-to-vm", dest_qube, file_path ]) subprocess.check_call([ "qvm-move-to-vm", dest_qube, file_path ])
except subprocess.calledProcessError: except subprocess.calledProcessError:
print( "Moving file bug-report failed", file = sys.stderr ) print( "Moving file bug-report failed", file = sys.stderr )
def get_log_file( log_file ): def get_log_file( log_file ):
@ -161,12 +161,12 @@ def get_log_file( log_file ):
with open( log_file ) as log: with open( log_file ) as log:
data = log.read() data = log.read()
return data return data
def qube_exist( qube_name ): def qube_exist( qube_name ):
exists = True exists = True
try: try:
#calls: qvm-check --quiet vmanme #calls: qvm-check --quiet vmanme
subprocess.check_call([ "qvm-check", "--quiet", qube_name ]) subprocess.check_call([ "qvm-check", "--quiet", qube_name ])
@ -174,7 +174,7 @@ def qube_exist( qube_name ):
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
exists = False exists = False
return exists return exists
def get_report_file_path( qube_name ): def get_report_file_path( qube_name ):
@ -218,11 +218,11 @@ def main():
else: else:
print ( "Destination VM does not exist" ) print ( "Destination VM does not exist" )
exit(1) exit(1)
else: else:
print( "VM does not exist" ) print( "VM does not exist" )
exit(1) exit(1)
#calls the main function -> program start point #calls the main function -> program start point
main() main()