本文整理汇总了Python中window.Window.show_window方法的典型用法代码示例。如果您正苦于以下问题:Python Window.show_window方法的具体用法?Python Window.show_window怎么用?Python Window.show_window使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类window.Window
的用法示例。
在下文中一共展示了Window.show_window方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Installer
# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import show_window [as 别名]
class Installer(object):
def __init__(self, install_config, maxy = 0, maxx = 0, iso_installer = False, tools_path = "../stage", rpm_path = "../stage/RPMS", log_path = "../stage/LOGS", ks_config = None):
self.install_config = install_config
self.ks_config = ks_config
self.iso_installer = iso_installer
self.tools_path = tools_path
self.rpm_path = rpm_path
self.log_path = log_path
self.mount_command = "./mk-mount-disk.sh"
self.prepare_command = "./mk-prepare-system.sh"
self.finalize_command = "./mk-finalize-system.sh"
self.install_package_command = "./mk-install-package.sh"
self.chroot_command = "./mk-run-chroot.sh"
self.setup_grub_command = "./mk-setup-grub.sh"
self.unmount_disk_command = "./mk-unmount-disk.sh"
if self.iso_installer:
self.working_directory = "/mnt/photon-root"
elif 'working_directory' in self.install_config:
self.working_directory = self.install_config['working_directory']
else:
self.working_directory = "/mnt/photon-root"
self.photon_root = self.working_directory + "/photon-chroot";
self.restart_command = "shutdown"
if self.iso_installer:
self.output = open(os.devnull, 'w')
else:
self.output = None
self.install_factor = 3
if self.iso_installer:
#initializing windows
self.maxy = maxy
self.maxx = maxx
self.height = 10
self.width = 75
self.progress_padding = 5
self.progress_width = self.width - self.progress_padding
self.starty = (self.maxy - self.height) / 2
self.startx = (self.maxx - self.width) / 2
self.window = Window(self.height, self.width, self.maxy, self.maxx, 'Installing Photon', False)
self.progress_bar = ProgressBar(self.starty + 3, self.startx + self.progress_padding / 2, self.progress_width)
signal.signal(signal.SIGINT, self.exit_gracefully)
# This will be called if the installer interrupted by Ctrl+C or exception
def exit_gracefully(self, signal, frame):
if self.iso_installer:
self.progress_bar.hide()
self.window.addstr(0, 0, 'Opps, Installer got inturrupted.\n\nPress any key to get to the bash...')
self.window.content_window().getch()
sys.exit(1)
def install(self, params):
try:
return self.unsafe_install(params)
except:
if self.iso_installer:
self.exit_gracefully(None, None)
else:
raise
def unsafe_install(self, params):
if self.iso_installer:
self.window.show_window()
self.progress_bar.initialize('Initializing installation...')
self.progress_bar.show()
self.execute_modules(modules.commons.PRE_INSTALL)
self.initialize_system()
#install packages
for rpm in self.rpms_tobeinstalled:
# We already installed the filesystem in the preparation
if rpm['package'] == 'filesystem':
continue
if self.iso_installer:
self.progress_bar.update_message('Installing {0}...'.format(rpm['package']))
return_value = self.install_package(rpm['package'])
if return_value != 0:
self.exit_gracefully(None, None)
if self.iso_installer:
self.progress_bar.increment(rpm['size'] * self.install_factor)
if self.iso_installer:
self.progress_bar.show_loading('Finalizing installation')
self.finalize_system()
if not self.install_config['iso_system']:
# Execute post installation modules
self.execute_modules(modules.commons.POST_INSTALL)
# install grub
#.........这里部分代码省略.........
示例2: Installer
# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import show_window [as 别名]
class Installer(object):
def __init__(self, install_config, maxy = 0, maxx = 0, iso_installer = False, rpm_path = "../stage/RPMS", log_path = "../stage/LOGS", ks_config = None):
self.install_config = install_config
self.ks_config = ks_config
self.iso_installer = iso_installer
self.rpm_path = rpm_path
self.log_path = log_path
self.mount_command = "./mk-mount-disk.sh"
self.prepare_command = "./mk-prepare-system.sh"
self.finalize_command = "./mk-finalize-system.sh"
self.install_package_command = "./mk-install-package.sh"
self.chroot_command = "./mk-run-chroot.sh"
self.setup_grub_command = "./mk-setup-grub.sh"
self.unmount_disk_command = "./mk-unmount-disk.sh"
if self.iso_installer:
self.working_directory = "/mnt/photon-root"
elif 'working_directory' in self.install_config:
self.working_directory = self.install_config['working_directory']
else:
self.working_directory = "/mnt/photon-root"
self.photon_root = self.working_directory + "/photon-chroot";
self.restart_command = "shutdown"
if self.iso_installer:
self.output = open(os.devnull, 'w')
else:
self.output = None
if self.iso_installer:
#initializing windows
self.maxy = maxy
self.maxx = maxx
self.height = 10
self.width = 75
self.progress_padding = 5
self.progress_width = self.width - self.progress_padding
self.starty = (self.maxy - self.height) / 2
self.startx = (self.maxx - self.width) / 2
self.window = Window(self.height, self.width, self.maxy, self.maxx, 'Installing Photon', False)
self.progress_bar = ProgressBar(self.starty + 3, self.startx + self.progress_padding / 2, self.progress_width)
signal.signal(signal.SIGINT, self.exit_gracefully)
# This will be called if the installer interrupted by Ctrl+C or exception
def exit_gracefully(self, signal, frame):
if self.iso_installer:
self.progress_bar.hide()
self.window.addstr(0, 0, 'Opps, Installer got interrupted.\n\nPress any key to get to the bash...')
self.window.content_window().getch()
modules.commons.dump(modules.commons.LOG_FILE_NAME)
sys.exit(1)
def install(self, params):
try:
return self.unsafe_install(params)
except Exception as inst:
if self.iso_installer:
modules.commons.log(modules.commons.LOG_ERROR, repr(inst))
self.exit_gracefully(None, None)
else:
raise
def unsafe_install(self, params):
if self.iso_installer:
self.window.show_window()
self.progress_bar.initialize('Initializing installation...')
self.progress_bar.show()
#self.rpm_path = "https://dl.bintray.com/vmware/photon_release_1.0_TP2_x86_64"
if self.rpm_path.startswith("https://") or self.rpm_path.startswith("http://"):
cmdoption = 's/baseurl.*/baseurl={}/g'.format(self.rpm_path.replace('/','\/'))
process = subprocess.Popen(['sed', '-i', cmdoption,'/etc/yum.repos.d/photon-iso.repo'])
retval = process.wait()
if retval != 0:
modules.commons.log(modules.commons.LOG_INFO, "Failed to reset repo")
self.exit_gracefully(None, None)
cmdoption = 's/cachedir=\/var/cachedir={}/g'.format(self.photon_root.replace('/','\/'))
process = subprocess.Popen(['sed', '-i', cmdoption,'/etc/tdnf/tdnf.conf'])
retval = process.wait()
if retval != 0:
modules.commons.log(modules.commons.LOG_INFO, "Failed to reset tdnf cachedir")
self.exit_gracefully(None, None)
self.execute_modules(modules.commons.PRE_INSTALL)
self.initialize_system()
if self.iso_installer:
self.get_size_of_packages()
selected_packages = self.install_config['packages']
for package in selected_packages:
self.progress_bar.update_message('Installing {0}...'.format(package))
process = subprocess.Popen(['tdnf', 'install', package, '--installroot', self.photon_root, '--nogpgcheck', '--assumeyes'], stdout=self.output, stderr=subprocess.STDOUT)
retval = process.wait()
# 0 : succeed; 137 : package already installed; 65 : package not found in repo.
if retval != 0 and retval != 137:
#.........这里部分代码省略.........
示例3: Installer
# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import show_window [as 别名]
#.........这里部分代码省略.........
"Skipping module {0} for phase {1}".format(module, phase))
continue
if not hasattr(mod, 'execute'):
modules.commons.log(modules.commons.LOG_ERROR,
"Error: not able to execute module {}".format(module))
continue
mod.execute(self.install_config, self.photon_root)
def _adjust_packages_for_vmware_virt(self):
"""
Install linux_esx on Vmware virtual machine if requested
"""
try:
if self.install_config['install_linux_esx']:
selected_packages = self.install_config['packages']
try:
selected_packages.remove('linux')
except ValueError:
pass
try:
selected_packages.remove('initramfs')
except ValueError:
pass
selected_packages.append('linux-esx')
except KeyError:
pass
def _setup_install_repo(self):
"""
Setup the tdnf repo for installation
"""
if self.install_config['iso_installer']:
self.window.show_window()
self.progress_bar.initialize('Initializing installation...')
self.progress_bar.show()
#self.rpm_path = "https://dl.bintray.com/vmware/photon_release_1.0_TP2_x86_64"
if self.rpm_path.startswith("https://") or self.rpm_path.startswith("http://"):
cmdoption = 's/baseurl.*/baseurl={}/g'.format(self.rpm_path.replace('/', r'\/'))
process = subprocess.Popen(['sed', '-i', cmdoption,
'/etc/yum.repos.d/photon-iso.repo'])
retval = process.wait()
if retval != 0:
modules.commons.log(modules.commons.LOG_INFO, "Failed to reset repo")
self.exit_gracefully(None, None)
cmdoption = (r's/cachedir=\/var/cachedir={}/g'
.format(self.photon_root.replace('/', r'\/')))
process = subprocess.Popen(['sed', '-i', cmdoption, '/etc/tdnf/tdnf.conf'])
retval = process.wait()
if retval != 0:
modules.commons.log(modules.commons.LOG_INFO, "Failed to reset tdnf cachedir")
self.exit_gracefully(None, None)
def _install_packages(self):
"""
Install packages using tdnf or rpm command
"""
if self.install_config['iso_installer']:
self._tdnf_install_packages()
else:
self._rpm_install_packages()
def _tdnf_install_packages(self):
"""
Install packages using tdnf command
示例4: Installer
# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import show_window [as 别名]
class Installer(object):
def __init__(self, install_config, maxy = 0, maxx = 0, iso_installer = False, tools_path = "../stage", rpm_path = "../stage/RPMS", log_path = "../stage/LOGS"):
self.install_config = install_config
self.iso_installer = iso_installer
self.tools_path = tools_path
self.rpm_path = rpm_path
self.log_path = log_path
self.mount_command = "./mk-mount-disk.sh"
self.prepare_command = "./mk-prepare-system.sh"
self.finalize_command = "./mk-finalize-system.sh"
self.install_package_command = "./mk-install-package.sh"
self.chroot_command = "./mk-run-chroot.sh"
self.setup_grub_command = "./mk-setup-grub.sh"
self.unmount_disk_command = "./mk-unmount-disk.sh"
if self.iso_installer:
self.working_directory = "/mnt/photon-root"
elif 'working_directory' in self.install_config:
self.working_directory = self.install_config['working_directory']
else:
self.working_directory = "/mnt/photon-root"
self.photon_root = self.working_directory + "/photon-chroot";
self.restart_command = "shutdown"
self.hostname_file = self.photon_root + "/etc/hostname"
self.hosts_file = self.photon_root + "/etc/hosts"
self.passwd_filename = self.photon_root + "/etc/passwd"
self.shadow_filename = self.photon_root + "/etc/shadow"
self.authorized_keys_dir = self.photon_root + "/root/.ssh"
self.authorized_keys_filename = self.authorized_keys_dir + "/authorized_keys"
self.sshd_config_filename = self.photon_root + "/etc/ssh/sshd_config"
if self.iso_installer:
self.output = open(os.devnull, 'w')
else:
self.output = None
self.install_factor = 3
if self.iso_installer:
#initializing windows
self.maxy = maxy
self.maxx = maxx
self.height = 10
self.width = 75
self.progress_padding = 5
self.progress_width = self.width - self.progress_padding
self.starty = (self.maxy - self.height) / 2
self.startx = (self.maxx - self.width) / 2
self.window = Window(self.height, self.width, self.maxy, self.maxx, 'Installing Photon', False)
self.progress_bar = ProgressBar(self.starty + 3, self.startx + self.progress_padding / 2, self.progress_width)
signal.signal(signal.SIGINT, self.exit_gracefully)
# This will be called if the installer interrupted by Ctrl+C or exception
def exit_gracefully(self, signal, frame):
if self.iso_installer:
self.progress_bar.hide()
self.window.addstr(0, 0, 'Opps, Installer got inturrupted.\n\nPress any key to get to the bash...')
self.window.content_window().getch()
sys.exit(1)
def install(self, params):
try:
return self.unsafe_install(params)
except:
if self.iso_installer:
self.exit_gracefully(None, None)
else:
raise
def unsafe_install(self, params):
if self.iso_installer:
self.window.show_window()
self.progress_bar.initialize('Initializing installation...')
self.progress_bar.show()
self.initialize_system()
#install packages
for rpm in self.rpms_tobeinstalled:
# We already installed the filesystem in the preparation
if rpm['package'] == 'filesystem':
continue
if self.iso_installer:
self.progress_bar.update_message('Installing {0}...'.format(rpm['package']))
return_value = self.install_package(rpm['package'])
if return_value != 0:
self.exit_gracefully(None, None)
if self.iso_installer:
self.progress_bar.increment(rpm['size'] * self.install_factor)
if self.iso_installer:
self.progress_bar.show_loading('Finalizing installation')
self.finalize_system()
if not self.install_config['iso_system']:
#.........这里部分代码省略.........
示例5: Installer
# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import show_window [as 别名]
class Installer(object):
def __init__(self, install_config, maxy = 0, maxx = 0, iso_installer = False, rpm_path = "../stage/RPMS", log_path = "../stage/LOGS", ks_config = None):
self.install_config = install_config
self.ks_config = ks_config
self.iso_installer = iso_installer
self.rpm_path = rpm_path
self.log_path = log_path
self.mount_command = "./mk-mount-disk.sh"
self.prepare_command = "./mk-prepare-system.sh"
self.finalize_command = "./mk-finalize-system.sh"
self.install_package_command = "./mk-install-package.sh"
self.chroot_command = "./mk-run-chroot.sh"
self.setup_grub_command = "./mk-setup-grub.sh"
self.unmount_disk_command = "./mk-unmount-disk.sh"
if self.iso_installer:
self.working_directory = "/mnt/photon-root"
elif 'working_directory' in self.install_config:
self.working_directory = self.install_config['working_directory']
else:
self.working_directory = "/mnt/photon-root"
self.photon_root = self.working_directory + "/photon-chroot";
self.restart_command = "shutdown"
if self.iso_installer:
self.output = open(os.devnull, 'w')
else:
self.output = None
if self.iso_installer:
#initializing windows
self.maxy = maxy
self.maxx = maxx
self.height = 10
self.width = 75
self.progress_padding = 5
self.progress_width = self.width - self.progress_padding
self.starty = (self.maxy - self.height) / 2
self.startx = (self.maxx - self.width) / 2
self.window = Window(self.height, self.width, self.maxy, self.maxx, 'Installing Photon', False)
self.progress_bar = ProgressBar(self.starty + 3, self.startx + self.progress_padding / 2, self.progress_width)
signal.signal(signal.SIGINT, self.exit_gracefully)
# This will be called if the installer interrupted by Ctrl+C or exception
def exit_gracefully(self, signal, frame):
if self.iso_installer:
self.progress_bar.hide()
self.window.addstr(0, 0, 'Opps, Installer got interrupted.\n\nPress any key to get to the bash...')
self.window.content_window().getch()
modules.commons.dump(modules.commons.LOG_ERROR, modules.commons.LOG_FILE_NAME)
sys.exit(1)
def install(self, params):
try:
return self.unsafe_install(params)
except:
if self.iso_installer:
self.exit_gracefully(None, None)
else:
raise
def unsafe_install(self, params):
if self.iso_installer:
self.window.show_window()
self.progress_bar.initialize('Initializing installation...')
self.progress_bar.show()
self.execute_modules(modules.commons.PRE_INSTALL)
self.initialize_system()
#install packages
for rpm in self.rpms_tobeinstalled:
# We already installed the filesystem in the preparation
if rpm['package'] == 'filesystem':
continue
if self.iso_installer:
self.progress_bar.update_message('Installing {0}...'.format(rpm['package']))
return_value = self.install_package(rpm['filename'])
if return_value != 0:
self.exit_gracefully(None, None)
if self.iso_installer:
self.progress_bar.increment(rpm['size'] * self.install_factor)
if self.iso_installer:
self.progress_bar.show_loading('Finalizing installation')
self.finalize_system()
if not self.install_config['iso_system']:
# Execute post installation modules
self.execute_modules(modules.commons.POST_INSTALL)
# install grub
try:
#.........这里部分代码省略.........