本文整理汇总了Python中dialog.Dialog.yesno方法的典型用法代码示例。如果您正苦于以下问题:Python Dialog.yesno方法的具体用法?Python Dialog.yesno怎么用?Python Dialog.yesno使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dialog.Dialog
的用法示例。
在下文中一共展示了Dialog.yesno方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import yesno [as 别名]
def main():
while True:
vms = Principal()
ip = vms.get_ip_address(LocalInterface)
result = vms.auth(ip)
token = result.split()[1]
result = vms.procurar(ip, token)
varcontrole = ""
window = Dialog()
if result.split()[0] == "ERR:":
varcontrole = window.yesno("No VMs found. Refresh?")
if varcontrole != 0:
sys.exit(1)
else:
if len(result.split()) > 1:
lista_vms = [(r, '') for r in result.split(' ')]
status, vm = window.menu("VM List", choices=lista_vms)
if status != 0:
sys.exit(1)
else:
vm = result.split()[0]
result = vms.status(vm, token)
if result.split()[0] == "ERR:":
result = vms.ligar(vm, token)
result = vms.conectar(vm, token)
if EnableShutdown:
os.system("shutdown now -h")
sys.exit(1)
示例2: __init__
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import yesno [as 别名]
class UI:
def __init__(self):
from dialog import Dialog
self.d = Dialog()
self.w=0
self.h=0
def message(self, text, title=None):
self.d.infobox( text )
def menu(self, title, subtitle, choices):
return self.d.menu( subtitle, title=title, choices=choices, width=self.w, height=self.h)[1]
def confirm(self, title, question):
return self.d.yesno(question, title=title, width=50, height=5)
示例3: main
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import yesno [as 别名]
def main():
while True:
vms = Principal()
ip = vms.get_ip_address(LocalInterface)
result = vms.auth(ip)
token = result.split()[1]
result = vms.procurar(ip, token)
varcontrole = ""
window = Dialog()
if result.split()[0] == "ERR:":
varcontrole = window.yesno("VM not found. Refresh?")
if varcontrole != 0:
sys.exit(1)
else:
if len(result.split()) > 1:
lista_vms = [(r, '') for r in result.split(' ')]
status, vm = window.menu("VM List", choices=lista_vms)
if status != 0:
sys.exit(1)
else:
vm = result.split()[0]
result = vms.status(vm, token)
if result.split()[0] == "ERR:":
result = vms.ligar(vm, token)
result = vms.conectar(vm, token)
time.sleep(1)
if EnableShutdown:
shutdown = []
if EnableSudo:
shutdown.append("sudo")
shutdown.append("shutdown")
shutdown.append("-h")
shutdown.append("now")
subprocess.call(shutdown)
sys.exit(1)
示例4: pressed
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import yesno [as 别名]
# * 'yesno' example *
# *****************************************************************************
# The 'no_collapse=True' used in the following call tells dialog not to replace
# multiple contiguous spaces in the text string with a single space.
code = d.yesno("""\
The 'yesno' widget allows one to display a text with two buttons beneath, \
which by default are labelled "Yes" and "No".
The return value is not simply True or False: for consistency with \
dialog and the other widgets, the return code allows to distinguish \
between:
OK/Yes Dialog.OK (equal to the string "ok")
Cancel/No Dialog.CANCEL (equal to the string "cancel")
<Escape> Dialog.ESC when the Escape key is pressed
Help Dialog.HELP when help_button=True was passed and the
Help button is pressed (only for 'menu' in
pythondialog 2.x)
Extra Dialog.EXTRA when extra_button=True was passed and the
Extra button is pressed
The DIALOG_ERROR exit status of dialog has no equivalent in this list, \
because pythondialog translates it into an exception.""",
title="'yesno' example", no_collapse=True,
help_button=True)
if code == d.OK:
msg = "You chose the 'OK/Yes' button in the previous dialog."
elif code == d.CANCEL:
msg = "You chose the 'Cancel/No' button in the previous dialog."
示例5: SBoTemplates
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import yesno [as 别名]
#.........这里部分代码省略.........
for line in info:
if line.startswith(text[1]):
self._name = line.split("=")[1].strip()
if line.startswith(text[2]):
self._comment = line.split("=")[1].strip()
if line.startswith(text[3]):
self._exec = line.split("=")[1].strip()
if line.startswith(text[4]):
self._icon = line.split("=")[1].strip()
if line.startswith(text[5]):
self._terminal = line.split("=")[1].strip()
if line.startswith(text[6]):
self._type = line.split("=")[1].strip()
if line.startswith(text[7]):
self._categories = line.split("=")[1].strip()
if line.startswith(text[8]):
self._genericname = line.split("=")[1].strip()
def doinst_sh(self):
"""doinst.sh handler file
"""
os.system("clear")
temp = "\n".join(doinst.splitlines())
pydoc.pipepager(temp, cmd='less -R')
self.filename = "doinst.sh"
self.edit()
self.menu()
def README(self):
"""README handler file
"""
self.filename = "README"
if self.slack_desc_text:
yesno = self.d.yesno("Import description from <slack-desc> file ?")
if yesno == "ok":
self.data = self.slack_desc_text
self.write()
self.edit()
self.menu()
def SlackBuild(self):
"""SlackBuild handler file
"""
self.filename = "{0}.info".format(self.app)
text = ["x", "VERSION="] + (["x"] * 6)
self.__infoFileRead(text) # get version for .info file
self.filename = "{0}.SlackBuild".format(self.app)
if not os.path.isfile(self.pwd + self.filename):
version = self._version.replace('"', '')
height = 20
width = 80
choices = [
("autotools-template", "autotools-template.SlackBuild", False),
("cmake-template", "cmake-template.SlackBuild", False),
("perl-template", "perl-template.SlackBuild", False),
("python-template", "python-template.SlackBuild", False),
("rubygem-template", "rubygem-template.SlackBuild", False)
]
code, tag = self.d.radiolist("{0}".format(self.filename), height,
width, list_height=0, choices=choices)
self.msg = "{0} script created.".format(self.filename)
self.height = 7
self.width = len(self.msg) + 4
if tag == "autotools-template":
self.data = SlackBuilds(
self.app, version, self.year, self.maintainer,
示例6: commandline
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import yesno [as 别名]
def commandline():
TXT_WELCOME_TITLE = 'Yet Another Common Criteria Parser and Checklist Generator!\n\nThis tool helps you to generate a quick workunit checklist.\n\nUse by your own risk'
locale.setlocale(locale.LC_ALL, '')
# You may want to use 'autowidgetsize=True' here (requires pythondialog >= 3.1)
d = Dialog(dialog="dialog")
#d = Dialog(dialog='dialog', autowidgetsize=True)
# Dialog.set_background_title() requires pythondialog 2.13 or later
d.set_background_title(TXT_WELCOME_TITLE)
# For older versions, you can use:
# d.add_persistent_args(["--backtitle", "My little program"])
# In pythondialog 3.x, you can compare the return code to d.OK, Dialog.OK or
# "ok" (same object). In pythondialog 2.x, you have to use d.DIALOG_OK, which
# is deprecated since version 3.0.0.
code = d.yesno(TXT_WELCOME_TITLE,
height="15", width="65", yes_label="OK", no_label="Cancel")
if (code == Dialog.CANCEL or code == Dialog.ESC):
clearquit()
else:
code, tag = d.menu("OK, then you have four options:",
choices=[("(1)", "Parse CC into a Database"),
("(2)", "Export CC"),
("(3)", "Parse and Export"),
("(4)", "Generate Checklist")])
if code == d.OK:
if tag == "(1)":
os.system('clear')
if not (os.path.isfile("doc/cc3R4.xml")):
d.msgbox("Error loading cc3R4.xml",height="10", width="45")
sys.exit(1)
os.system("python CCParser.py -ask doc/cc3R4.xml")
d.msgbox("Generated database in data/ccdb.sqlite3",height="10", width="45")
quit()
elif tag == "(2)":
os.system('clear')
if not (os.path.isfile("data/ccdb.sqlite3")):
d.msgbox("Error loading database. Must run CCParser.py first",height="10", width="45")
sys.exit(1)
os.system("python CChtmlExport.py -ask data/ccdb.sqlite3")
d.msgbox("Generated export in output/",height="10", width="45")
quit()
elif tag == "(3)":
os.system('clear')
if not (os.path.isfile("doc/cc3R4.xml")):
d.msgbox("Error loading cc3R4.xml",height="10", width="45")
sys.exit(1)
os.system("python CCParser.py doc/cc3R4.xml && python CChtmlExport.py -ask data/ccdb.sqlite3")
d.msgbox("Generated database in data/ccdb.sqlite3 and export in output/",height="10", width="75")
quit()
elif tag == "(4)":
if not (os.path.isfile("data/ccdb.sqlite3")):
d.msgbox("Error loading database. Must run CCParser.py first",height="10", width="45")
sys.exit(1)
code, tag = d.menu("Evaluation Assurance Level:",
choices=[("(EAL1)", "Evaluation Assurance Level 1"),
("(EAL2)", "Evaluation Assurance Level 2"),
("(EAL3)", "Evaluation Assurance Level 3"),
("(EAL4)", "Evaluation Assurance Level 4"),
("(EAL5)", "Evaluation Assurance Level 5"),
("(EAL6)", "Evaluation Assurance Level 6"),
("(EAL7)", "Evaluation Assurance Level 7")])
if code == d.OK:
if tag == "(EAL1)": EALSELECTED = "EAL1"
if tag == "(EAL2)": EALSELECTED = "EAL2"
if tag == "(EAL3)": EALSELECTED = "EAL3"
if tag == "(EAL4)": EALSELECTED = "EAL4"
if tag == "(EAL5)": EALSELECTED = "EAL5"
if tag == "(EAL6)": EALSELECTED = "EAL6"
if tag == "(EAL7)": EALSELECTED = "EAL7"
code, tags = d.checklist("Family",
choices=[("ACO_DEV.1", "", False),
("ACO_DEV.2", "", False),
("ACO_DEV.3", "", False),
("ACO_REL.1", "", False),
("ACO_REL.2", "", False),
("ACO_CTT.1", "", False),
("ACO_CTT.2", "", False),
("ACO_VUL.1", "", False),
("ACO_VUL.2", "", False),
("ACO_VUL.3", "", False),
("ADV_ARC.1", "", False),
("ADV_FSP.2", "", False),
("ADV_FSP.3", "", False),
("ADV_FSP.4", "", False),
("ADV_FSP.5", "", False),
("ADV_FSP.6", "", False),
("ADV_IMP.1", "", False),
("ADV_IMP.2", "", False),
("ADV_INT.1", "", False),
#.........这里部分代码省略.........
示例7: randrange
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import yesno [as 别名]
code, tag = d.menu("Choose an option. Charge units are "+chargeUnit.describe()+" and angle units are "+
angleUnit.describe()+".",
choices=[("Help", "show help information"),
("Print", "print the active objects"),
("Add", "add an object"),
("Remove", "remove an object"),
("Test", "test the field at a point"),
("Configure", "set options and modes"),
("Save", "save the active objects"),
("Load", "load objects from a file"),
("Exit", "exit")],
title="Main Menu")
if code != d.OK or tag == "Exit":
if d.yesno("Really quit?") == d.OK:
i = randrange(0, len(exit_messages))
d.msgbox(exit_messages[i])
exit(0)
else:
pass
pass # at least I'm not using goto
else:
if tag == "Help":
d.msgbox("Try adding particles and testing the field strength.")
# maybe add some actually useful help here, I dunno.
elif tag == "Configure":
while code == d.OK: # probably lets people keep configuring after a single change
code, tag = d.menu("Choose a configuration option.",
示例8: here
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import yesno [as 别名]
from dialog import Dialog
# This is almost always a good thing to do at the beginning of your programs.
locale.setlocale(locale.LC_ALL, "")
# You may want to use 'autowidgetsize=True' here (requires pythondialog >= 3.1)
d = Dialog(dialog="dialog")
# Dialog.set_background_title() requires pythondialog 2.13 or later
d.set_background_title("My little program")
# For older versions, you can use:
# d.add_persistent_args(["--backtitle", "My little program"])
# In pythondialog 3.x, you can compare the return code to d.OK, Dialog.OK or
# "ok" (same object). In pythondialog 2.x, you have to use d.DIALOG_OK, which
# is deprecated since version 3.0.0.
if d.yesno("Are you REALLY sure you want to see this?") == d.OK:
d.msgbox("You have been warned...")
# We could put non-empty items here (not only the tag for each entry)
code, tags = d.checklist(
"What sandwich toppings do you like?",
choices=[
("Catsup", "", False),
("Mustard", "", False),
("Pesto", "", False),
("Mayonnaise", "", True),
("Horse radish", "", True),
("Sun-dried tomatoes", "", True),
],
title="Do you prefer ham or spam?",
backtitle="And now, for something " "completely different...",
示例9: open
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import yesno [as 别名]
d.set_background_title("Srchub Installer")
d.msgbox("""This will guide you through installing srchub
Any comments should be directed towards
[email protected]""")
with open('/etc/issue', 'r') as content_file:
issue_file = content_file.read()
if "Debian" in issue_file or "Ubuntu" in issue_file:
distro = "Debian"
else:
code = d.yesno("""This script was designed for Debian/Ubuntu but it seems you are using a different distro.\n
However - you may still attempt to run it if you know what you are doing.\n\n
I recommend canceling and emailing the author and telling them the name of your distro which is:\n """ + issue_file)
if code == d.CANCEL:
exit_msg()
sys.exit()
code, tag = d.menu("Choose carefully:", choices=[
("1", "Install srchub"),
("2", "Install indefero")
])
if code == d.OK:
install_packages()
if tag == "1": # Install srchub
call(["git", "clone", "git://srchub.org/srchub-git.git", "/home/www"])
call(["chown", "www-data:www-data", "-R", "/home/www"])
示例10: echoWrite
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import yesno [as 别名]
#gaugeSocket.send("fff")
echoWrite("fff")
res=readln()
echoWrite("\r\r\r")
time.sleep(1)
res=readln()
echoWrite("\r")
time.sleep(1)
res=readln()
lines=res.splitlines()
#in case the bootloader is active
if len(lines)>0 and lines[len(lines)-1]=="OOBD-Flashloader>":
print "Bootloader active, flashing can start.."
#this is the version for python3: if d.yesno("ok to flash?") == d.OK:
if d.yesno("ok to flash?") == d.DIALOG_OK: #this is for python < 3.0
try:
# ymodem = YMODEM(getc, putc)
echoWrite("1")
print "start transfer - no way back.."
# print 'Modem instance', ymodem
# status = ymodem.send([sys.argv[2]])
status = subprocess.call(['sb', sys.argv[2]], stdin=gaugeSocket, stdout=gaugeSocket)
print 'sent status', status
if status==0:
#start the firmware
gaugeSocket.send("3")
runstatus = 0
except:
示例11: clearquit
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import yesno [as 别名]
code = d.msgbox(text + results['output'])
clearquit()
# some sanity checks here, sudo only
locale.setlocale(locale.LC_ALL, '')
if os.getuid() != 0:
print(Constants.TXT_ERR_ROOT_REQUIRED)
sys.exit(1)
# display available interfaces to configure
interfaces = Interfaces()
d = Dialog(dialog='dialog', autowidgetsize=True)
d.set_background_title(Constants.TXT_BACKGROUND_TITLE)
code = d.yesno(Constants.TXT_WELCOME_TITLE,
height="15", width=65, yes_label="OK", no_label="Cancel")
if (code == Dialog.CANCEL or code == Dialog.ESC):
clearquit()
available_adapters = []
available_iface_list = run_process("ifconfig -a | grep eth")['output']
for line in available_iface_list.splitlines():
elems = line.split(' ', 1)
iface = Iface(elems[0].strip(), elems[1].strip())
available_adapters.append(iface)
choices = []
for adapter in available_adapters:
choices.append((adapter.name, adapter.description))
示例12: extend_column
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import yesno [as 别名]
def extend_column(self, new_field, add=None):
""" We know what is new column, now determine how we should extend it
add - bool if the column should be added to the table; None ask
"""
print("\nWhat column we base {} on?".format(new_field))
g = self.csv.guesses.get_graph()
valid_types = list(g.dijkstra(new_field))
possible_cols = {}
for (i, key), types in self.csv.guesses.field_type.items():
for val in types:
if val in valid_types:
possible_cols[i] = types[val]
break
source_col_i = Dialogue.pickOption(self.csv.get_fields_autodetection(),
title="Searching source for " + new_field,
guesses=sorted(possible_cols, key=possible_cols.get, reverse=True))
dialog = Dialog(autowidgetsize=True)
method = self.csv.guesses.get_best_method(source_col_i, new_field)
if method is None:
# ask how should be treated the column as, even it seems not valid
# list all known methods to compute the desired new_field (e.g. for incident-contact it is: ip, hostname, ...)
choices = [(k, self.csv.guesses.get_description(k)) for k, _ in
sorted(self.csv.guesses.get_graph().dijkstra(new_field, ignore_private=True).items(),
key=lambda v: v[1], reverse=False)] # whois is an internal keyword
if len(choices) == 1 and choices[0][0] == "plaintext":
# if the only method is derivable from a plaintext, no worries that a method
# converting the column type to "plaintext" is not defined; everything's plaintext
method = "plaintext"
elif choices:
title = "Choose the right method\n\nNo known method for making {} from column {} because the column type wasn't identified. How should I treat the column?".format(
new_field, self.csv.fields[source_col_i])
code, method = dialog.menu(title, choices=choices)
if code == "cancel":
return
else:
dialog.msgbox("No known method for making {}. Raise your usecase as an issue at {}.".format(new_field,
Config.PROJECT_SITE))
custom = None
if new_field == "custom": # choose a file with a needed method
while True:
title = "What .py file should be used as custom source?"
code, path = dialog.fselect(os.getcwd(), title=title)
if code != "ok" or not path:
return
module = self.csv.guesses.get_module_from_path(path)
if module:
# inspect the .py file, extract methods and let the user choose one
code, method = dialog.menu("What method should be used in the file {}?".format(path),
choices=[(x, "") for x in dir(module) if not x.startswith("_")])
if code == "cancel":
return
custom = path, method
break
else:
dialog.msgbox("The file {} does not exist or is not a valid .py file.".format(path))
self.csv.settings["add"].append((new_field, source_col_i, method, custom))
self.csv.fields.append(new_field)
if add is None:
if dialog.yesno("New field added: {}\n\nDo you want to include this field as a new column?".format(
new_field)) == "ok":
add = True
if add is True: # or (add is None and input("Do you want to include this field as a new column? [y]/n ") not in ["n","no"]):
self.csv.settings["chosen_cols"].append(len(self.csv.fields) - 1)
# if add is False or (add is None and input("Do you want to include this field as a new column? [y]/n ") in ["n","no"]):
# self.csv.settings["chosen_cols"].append(False)
return len(self.csv.fields) - 1 # + len(self.csv.settings["add"]) - 1
示例13: Dialog
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import yesno [as 别名]
from os.path import expanduser
from dialog import Dialog
from libqtile import confreader
# from libqtile import widget
# from libqtile import layout
locale.setlocale(locale.LC_ALL, '')
d = Dialog(autowidgetsize=True)
# should we start from empty or load some config
default_config = d.yesno("""This is Qtile setup program to prepair config to use Qtile.
Would you like to start from default config or load earlier config?""",
yes_label='Default',
no_label='Load file'
)
if default_config == 'ok':
d.infobox('Config is loading...')
config = confreader.File()
else:
home = expanduser("~")
code, config_file = d.fselect(home)
if code == 'ok':
config = confreader.File(config_file)
d.infobox('Config is loading...')
else:
d.infobox('File has not been loaded. Start gain :)')
示例14: main
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import yesno [as 别名]
def main():
locale.setlocale(locale.LC_ALL, '')
d = Dialog(dialog="dialog", autowidgetsize=True)
d.set_background_title("Programme de support express")
d.msgbox("Bienvenue sur le programme de support technique. Celui-ci vous guidera pour résoudre votre probleme ou la soumettre de maniere correcte !")
code, programme = d.menu("Quel est le programme concerné par le probleme ?:",
choices=[("serveur", "Mon serveur en entier, le soucis est global, ou n'est pas lié à un programme particulier."),
("web", "Mon site web (apache2, nginx, ioncube...)"),
("minecraft", "Un serveur de jeu Minecraft"),
("source", "Un serveur de jeu CS:GO, TF2, ou autre jeu source"),
("vpn", "Un VPN OpenVpn"),
("ssh", "Le SSHd (connexion au serveur avec PuTTy ou équivalent)"),
("bdd", "Une base de données (MySql, phpmyadmin...)"),
("autre", "Autre chose, qui n'est pas expliqué ici")
])
if code == d.OK:
if d.yesno("Le principal, avez vous lu les logs de l'application ou du service ?", yes_label="Bien sur que oui !", no_label="Euh... On peut le faire maintenent ?") == d.OK:
if d.yesno("Et vous n'avez rien trouvé dedans?", yes_label="Sisi, j'ai vu des erreurs", no_label="Vraiment rien trouvé!") == d.OK:
if programme == "minecraft":
if d.yesno("Hum... S'agit t'il d'un trés long message avec des at à quasiment chaque ligne ?", yes_label="Oui, c'est ca !", no_label="Non !") == d.OK:
d.msgbox("C'est une stacktrace. Il doit y avoir le nom d'un ou plusieurs plugins dedans, ainsi que leur version. Essaye de les mettre à jour.")
if d.yesno("La mise à jour et le redémarrage ont-ils résolu le probleme ?", yes_label="Oui, merci !", no_label="Non :'(") == d.OK:
d.msgbox("Dans, ce cas, merci à toi ! :)")
sys.exit(0)
else:
propositionsMessages(d, programme)
else:
d.msgbox("Pas grave, nous allons trouver, alors dit moi :")
code, tag = d.menu("Quel genre de messages ?:",
choices=[("1", "Des messages d'erreurs"),
("2", "Des \"Warnings\""),
("3", "Des messsages que j'ai pas trop compris")
])
tag = int(tag)
if code == d.OK:
if tag == 1:
d.msgbox("Super ! La plupart du boulot est fait ! Essayez d'entrer dans google le message d'erreur en retirant la date, l'heure, les chemins de fichiers et tout autre signe distinctif, puis appliquez les solutions proposées")
if d.yesno("Cela à résolu votre probleme ?", yes_label="Oui, merci beaucoup !", no_label="Malheureusement non !") == d.OK:
d.msgbox("Dans, ce cas, merci à toi ! :)")
sys.exit(0)
else:
propositionsMessages(d, programme)
elif tag == 2:
if d.yesno("Le mieux serait d'entrer ces messages sans trop de signes distinctifs dans google et d'essayer les solutions proposées. Est-ce que cela résout le problème ?", yes_label="Oui, merci beaucoup !", no_label="Malheureusement non !") == d.OK:
d.msgbox("Dans, ce cas, merci à toi ! :)")
sys.exit(0)
else:
propositionsMessages(d, programme)
elif tag == 3:
d.msgbox("Essayez d'entrer dans google le message en retirant la date, l'heure, les chemins de fichiers et tout autre signe distinctif, puis appliquez les solutions proposées")
if d.yesno("Cela à résolu votre probleme ?", yes_label="Oui, merci beaucoup !", no_label="Malheureusement non !") == d.OK:
d.msgbox("Dans, ce cas, merci à toi ! :)")
sys.exit(0)
else:
propositionsMessages(d, programme)
else:
d.msgbox("Si tu ne trouves pas de message particulier, cherche si l'application n'a pas d'autres fichiers de logs. Si ce n'est pas le cas, passe nous voir au support sur IRC")
else:
d.msgbox("Pas de soucis, regardons. Tu dois chercher des lignes contenant des erreurs")
if d.yesno("Connais-tu le chemin vers ces logs ? Je ne connais que ceux par défault, et si tes serveurs sont installés a d'autres endroits, je ne les trouverai pas.", yes_label="Oui, je connais!", no_label="Malheureusement non !") != d.OK:
d.msgbox("Voici les logs, si je les trouves...")
try:
if programme == "serveur":
d.textbox("/var/log/syslog")
elif programme == "web":
d.textbox("/var/log/apache2/error.log")
elif programme == "minecraft":
code, serv = d.inputbox("Quel est le nom du serveur aprés /home/minecraft ? (tapez juste / si il n'y en a pas)", init="/")
d.textbox("/home/minecraft/" + serv + "/logs/latest.log")
elif programme == "source":
d.msgbox("Les logs pour les serveurs source sont dans la console seulement")
elif programme == "vpn":
d.textbox("/var/log/syslog") # oui, ca log dans syslog openvpn :o
elif programme == "sshd":
d.textbox("/var/log/auth.log")
d.textbox("/var/log/messages")
elif programme == "bdd":
d.textbox("/var/log/mysql.log")
else:
d.msgbox("Le mieux serait de chercher ce chemin sur google...")
code, logs = d.inputbox("Quel est ce chemin ?", init="/var/log/[...]")
if code == d.OK:
d.textbox(logs)
else:
d.msgbox("Au revoir è_é!")
sys.exit(2)
except DialogError:
d.msgbox("Je n'ai pas trouvé le fichier :'(. Le mieux serait de chercher ce chemin sur google...")
code, logs = d.inputbox("Quel est ce chemin ?", init="/var/log/[...]")
if code == d.OK:
d.textbox(logs)
else:
d.msgbox("Au revoir è_é!")
sys.exit(2)
else:
code, logs = d.inputbox("Quel est ce chemin ?", init="/var/log/[...]")
if code == d.OK:
d.textbox(logs)
#.........这里部分代码省略.........
示例15:
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import yesno [as 别名]
pass
elif action == "Configure Tool":
data = pickle.load(open("data.p", "rb"))
code, action = d.menu("Configure Tool",
choices=[("Set IP of Proxmox server", ""),
("Set username of Proxmox user to login as", ""),
("Set password of Proxmox user to log in as", "")])
if action == "Set IP of Proxmox server":
code, ip = d.inputbox("Enter IP of Proxmox server:", init=data[1])
elif action == "Set username of Proxmox user to login as":
code, username = d.inputbox("Enter username of SSH user:")
elif action == "Set password of Proxmox user to login as":
code, password = d.inputbox("Enter password of SSH user:")
else:
d.msgbox("Oops. Something went wrong...")
elif action == "Exit Tool":
sys.exit()
elif action == "":
if d.yesno("Are you REALLY sure you want to exit?") == d.OK:
sys.exit()
else:
d.msgbox("Oops. Something went wrong...")
#code, vmid = d.inputbox("Enter VM ID:")
#os.system('sshpass -p \'' + sshpass + '\' ssh ' + sshuser + '@' + ip)