本文整理汇总了Python中dialog.Dialog.add_persistent_args方法的典型用法代码示例。如果您正苦于以下问题:Python Dialog.add_persistent_args方法的具体用法?Python Dialog.add_persistent_args怎么用?Python Dialog.add_persistent_args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dialog.Dialog
的用法示例。
在下文中一共展示了Dialog.add_persistent_args方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Dialog
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import add_persistent_args [as 别名]
#!/usr/bin/env python3
#
# netem-conf - configure NETem parameter
#
import copy
import os
import subprocess
import json
from dialog import Dialog
# minimal config
config = { 'eth0_to_eth1': {}, 'symmetric': True }
# open dialog system
d = Dialog(dialog="dialog", autowidgetsize=True)
d.add_persistent_args(["--no-collapse"])
# configure NETem parameter in linux
def conf_netem(link, dev):
# remove current config
subprocess.call(['sudo', '-S', 'tc', 'qdisc', 'del', 'dev', dev, 'root'],
stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)
# base NETem command line
netem_cmd = ['sudo', '-S', 'tc', 'qdisc', 'add', 'dev', dev]
# configure bandwidth with htb
if config[link].get('bandwidth') is not None:
buffer = max(int(0.3*config[link]['bandwidth']+0.5), 1600)
示例2: Dialog
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import add_persistent_args [as 别名]
#!/usr/bin/env python
import locale
import sys
from dialog import Dialog
import wifi_config_file
import wifi_list
# Set the locale
locale.setlocale(locale.LC_ALL, '')
# Our dialog
d = Dialog(dialog="dialog")
d.add_persistent_args(["--backtitle", "Wifi Config"])
# Defaults
DEFAULT_SSID="robot"
DEFAULT_PASSWORD="oark"
DEFAULT_COUNTRY_CODE="AU"
DEFAULT_CHANNEL=0
DEFAULT_TEXTBOX_HEIGHT=10
DEFAULT_TEXTBOX_WIDTH=30
HW_MODE_G_CUTOFF_CHANNEL=14
COUNTRIES = {'AU': 'Australia',
'CN': 'China',
'US': 'United States'}
示例3: MainApp
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import add_persistent_args [as 别名]
class MainApp(object):
"""
Main App class
"""
def __init__(self):
self.dialog = Dialog(autowidgetsize=True)
self.dialog.add_persistent_args(['--no-mouse'])
self.dialog.set_background_title(
'Python vSphere Client version {}'.format(__version__)
)
self.agent = None
def about(self):
welcome = (
'Welcome to the Python vSphere Client version {}.\n\n'
'PVC is hosted on Github. Please contribute by reporting '
'issues, suggesting features and sending patches using '
'pull requests.\n\n'
'https://github.com/dnaeon/pvc'
)
self.dialog.msgbox(
title='Welcome',
text=welcome.format(__version__)
)
def login(self):
"""
Login to the VMware vSphere host
Returns:
True on successful connect, False otherwise
"""
form_text = (
'Enter IP address or DNS name '
'of the VMware vSphere host you wish '
'to connect to.\n'
)
elements = [
pvc.widget.form.FormElement(label='Hostname'),
pvc.widget.form.FormElement(label='Username'),
pvc.widget.form.FormElement(label='Password', attributes=0x1),
]
form = pvc.widget.form.Form(
dialog=self.dialog,
form_elements=elements,
mixed_form=True,
title='Login Details',
text=form_text,
)
while True:
code, fields = form.display()
if code in (self.dialog.CANCEL, self.dialog.ESC):
return False
if not all(fields.values()):
self.dialog.msgbox(
title='Error',
text='Invalid login details, please try again.\n'
)
continue
self.dialog.infobox(
title='Establishing Connection',
text='Connecting to {} ...'.format(fields['Hostname']),
)
self.agent = VConnector(
host=fields['Hostname'],
user=fields['Username'],
pwd=fields['Password'],
)
try:
self.agent.connect()
text = '{} - {} - Python vSphere Client version {}'
background_title = text.format(
self.agent.host,
self.agent.si.content.about.fullName,
__version__
)
self.dialog.set_background_title(background_title)
return True
except Exception as e:
if isinstance(e, pyVmomi.vim.MethodFault):
msg = e.msg
else:
msg = e
self.dialog.msgbox(
title='Login failed',
text='Failed to login to {}\n\n{}\n'.format(self.agent.host, msg)
)
def disconnect(self):
#.........这里部分代码省略.........
示例4: Dialog
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import add_persistent_args [as 别名]
# | |_|_| |_| |_| .__/ \___/|_| \__| |
# | |_| |
# +----------------------------------------------------------------------+
# | |
# '----------------------------------------------------------------------'
import os, sys, pprint, locale, dialog
from dialog import Dialog
sys.path.insert(0, './api')
locale.setlocale(locale.LC_ALL, '')
from base64 import b64encode, b64decode
config_dir = os.path.expanduser('~') + "/.always-backup/"
d = Dialog(dialog="dialog")
d.add_persistent_args(["--backtitle", "Always Backup Configuration"])
#.
#Source: https://gist.github.com/ldx/5005528
def decode_dropbox_key(key):
key, secret = key.split('|')
key = b64decode(key)
key = [ord(x) for x in key]
secret = b64decode(secret)
s = range(256)
y = 0
for x in xrange(256):
y = (y + s[len(key)] + key[x % len(key)]) % 256
s[x], s[y] = s[y], s[x]
x = y = 0
示例5: main
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import add_persistent_args [as 别名]
def main():
dialog = Dialog()
dialog.add_persistent_args(["--backtitle", "ZiNC is Not a Cloud. v%s" % __version__])
repos = settings.repos
process_repos(dialog, repos)