本文整理汇总了Python中dialog.Dialog.passwordbox方法的典型用法代码示例。如果您正苦于以下问题:Python Dialog.passwordbox方法的具体用法?Python Dialog.passwordbox怎么用?Python Dialog.passwordbox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dialog.Dialog
的用法示例。
在下文中一共展示了Dialog.passwordbox方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WindowsInstallApp
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import passwordbox [as 别名]
#.........这里部分代码省略.........
if not self.test_network():
self.configure_network()
source_items = [
('Network Filesystem (NFS)', MenuItem(self.prepare_nfs_source)),
('Windows Share (SMB/CIFS)', MenuItem(self.prepare_smb_source)),
#('Network Block Device (NBD)', MenuItem()),
('SCP/SFTP (SSH)', MenuItem(self.prepare_sshfs_source)),
('Block Device (USB, CD/DVD, etc.)', self.prepare_blk_source),
('---', MenuItem(separator=True)),
('OTHER (Path)', MenuItem(self.prepare_fs_source)),
]
try:
Menu(self.d, source_items, 'Select Installation Source', ret=None).run()
self.select_source()
except FailedInstallStep: raise
except subprocess.CalledProcessError:
self.d.msgbox('Mount Failed. Please retry the installation source selection step')
def prepare_nfs_source(self):
code, path = self.d.inputbox('Enter an NFS server or share',
init=self.config.get('source', 'default_nfs', fallback=''), width=40)
mount(path, self.source_dir, force=True, mkdir=True)
def prepare_smb_source(self):
code, path = self.d.inputbox(
'Enter an SMB share path in the format \'[email protected]//server/share\'', width=40)
user, passwd, cred = '', '', ''
if '@' in path:
user, path = path.split('@')
code, passwd = self.d.passwordbox(
'Enter the share password, if applicable', width=40)
cred = 'password={},'.format(passwd)
if user: cred += 'username={},'.format(user)
mount(path, self.source_dir, options=cred, force=True, mkdir=True, fs_type='cifs')
def prepare_fs_source(self):
code, path = self.d.inputbox('Enter a UNIX path', width=40)
mount(path, self.source_dir, force=True, mkdir=True, bind=True)
def prepare_sshfs_source(self):
code, path = self.d.inputbox('Enter an SSHFS path, in the format [email protected]:/', width=40)
code, passwd = self.d.passwordbox('Enter the password', width=40)
try: os.makedirs(self.source_dir)
except FileExistsError: pass
if mountpoint(self.source_dir): unmount(self.source_dir)
disable_hostkey_check = ['-o', 'StrictHostKeyChecking=no']
call = ['sshfs', path, self.source_dir, '-o', 'password_stdin']
call += disable_hostkey_check
p = subprocess.Popen(call, stdin=subprocess.PIPE, stdout=open('/dev/null', 'w'))
p.communicate(input=passwd.encode('UTF-8'))
if p.returncode != 0: raise subprocess.CalledProcessError
def prepare_blk_source(self):
code, path = self.d.inputbox('Enter a block device path', width=40)
mount(path, self.source_dir, force=True, mkdir=True)