2011-09-10 21:28:28 +02:00
|
|
|
#
|
|
|
|
# question.py - Internal helper class for sponsor-patch
|
|
|
|
#
|
|
|
|
# Copyright (C) 2011, Benjamin Drung <bdrung@ubuntu.com>
|
|
|
|
#
|
|
|
|
# Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
# purpose with or without fee is hereby granted, provided that the above
|
|
|
|
# copyright notice and this permission notice appear in all copies.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
2011-12-21 22:09:53 +01:00
|
|
|
from ubuntutools.question import Question, YesNoQuestion
|
|
|
|
|
2017-05-01 00:20:03 +02:00
|
|
|
|
2011-12-21 22:09:53 +01:00
|
|
|
def ask_for_ignoring_or_fixing():
|
|
|
|
"""Ask the user to resolve an issue manually or ignore it.
|
|
|
|
|
|
|
|
Returns false if the user want to fix the issue and returns true if the user
|
|
|
|
want to ignore the issue.
|
|
|
|
"""
|
|
|
|
|
|
|
|
question = Question(["yes", "ignore", "no"])
|
|
|
|
answer = question.ask("Do you want to resolve this issue manually", "yes")
|
|
|
|
if answer == "no":
|
|
|
|
user_abort()
|
|
|
|
return answer == "ignore"
|
2011-09-10 21:28:28 +02:00
|
|
|
|
2017-05-01 00:20:03 +02:00
|
|
|
|
2011-09-10 21:28:28 +02:00
|
|
|
def ask_for_manual_fixing():
|
2011-12-21 22:09:53 +01:00
|
|
|
"""Ask the user to resolve an issue manually."""
|
|
|
|
|
2023-01-30 19:45:36 +01:00
|
|
|
answer = YesNoQuestion().ask("Do you want to resolve this issue manually", "yes")
|
2011-09-10 21:28:28 +02:00
|
|
|
if answer == "no":
|
|
|
|
user_abort()
|
|
|
|
|
2017-05-01 00:20:03 +02:00
|
|
|
|
2011-09-10 21:28:28 +02:00
|
|
|
def user_abort():
|
2011-12-21 22:09:53 +01:00
|
|
|
"""Print abort and quit the program."""
|
|
|
|
|
2014-12-18 20:52:51 +00:00
|
|
|
print("User abort.")
|
2011-09-10 21:28:28 +02:00
|
|
|
sys.exit(2)
|