当前位置: 首页>>代码示例>>Python>>正文


Python Window.do_action方法代码示例

本文整理汇总了Python中window.Window.do_action方法的典型用法代码示例。如果您正苦于以下问题:Python Window.do_action方法的具体用法?Python Window.do_action怎么用?Python Window.do_action使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在window.Window的用法示例。


在下文中一共展示了Window.do_action方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: DiskPartitioner

# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import do_action [as 别名]
class DiskPartitioner(object):
    def __init__(self,  maxy, maxx):
        self.menu_items = []

        self.maxx = maxx
        self.maxy = maxy
        self.win_width = 70
        self.win_height = 17

        self.win_starty = (self.maxy - self.win_height) / 2
        self.win_startx = (self.maxx - self.win_width) / 2

        self.menu_starty = self.win_starty + 10

        # initialize the devices
        self.devices = Device.refresh_devices()

        self.items =   [
                            ('Auto-partitioning - use entire disk',  self.guided_partitions, None),
                            ('Manual - not implemented!',  self.manual_partitions, None),
                        ]
        self.menu = Menu(self.menu_starty,  self.maxx, self.items)

        self.window = Window(self.win_height, self.win_width, self.maxy, self.maxx, 'Welcome to the Photon installer', True, self.menu)
        self.window.addstr(0, 0, 'First, we will setup your disks. \n\nYou can: \n\na) use auto-partitioning or\nb) you can do it manually.')

    def guided_partitions(self, params):
        return ActionResult(True, {'guided': True, 'devices': self.devices})

    def manual_partitions(self, params):
        raise NameError('Manual partitioning not implemented')

    def display(self, params):
        return self.window.do_action()
开发者ID:Andrew219,项目名称:photon,代码行数:36,代码来源:diskpartitioner.py

示例2: WindowStringReader

# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import do_action [as 别名]
class WindowStringReader(object):
    def __init__(self, maxy, maxx, height, width, field, confirmation_err_msg,
                 echo_char, accepted_chars, validation_fn, conversion_fn, title,
                 display_string, inputy, install_config, default_string=None,
                 tab_enabled=False):
        self.title = title
        self.display_string = display_string
        self.install_config = install_config
        self.inputy = inputy

        self.width = width
        self.height = height
        self.maxx = maxx
        self.maxy = maxy

        self.startx = (self.maxx - self.width) // 2
        self.starty = (self.maxy - self.height) // 2
        self.tab_enabled = False
        self.can_go_next = True

        self.window = Window(self.height, self.width, self.maxy, self.maxx, self.title,
                             True, tab_enabled=self.tab_enabled,
                             position=1, can_go_next=self.can_go_next, read_text=self.can_go_next)
        self.read_text = ReadText(maxy, maxx, self.window.content_window(), self.inputy,
                                  install_config,
                                  field, confirmation_err_msg, echo_char, accepted_chars,
                                  validation_fn,
                                  conversion_fn, default_string, tab_enabled=self.tab_enabled)
        self.window.set_action_panel(self.read_text)
        self.window.addstr(0, 0, self.display_string)

    def get_user_string(self, params):
        return self.window.do_action()
开发者ID:frapposelli,项目名称:photon,代码行数:35,代码来源:windowstringreader.py

示例3: OSTreeServerSelector

# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import do_action [as 别名]
class OSTreeServerSelector(object):
    def __init__(self,  maxy, maxx, install_config):
        self.install_config = install_config
        win_width = 50
        win_height = 13

        win_starty = (maxy - win_height) / 2
        win_startx = (maxx - win_width) / 2

        menu_starty = win_starty + 3

        ostree_host_menu_items = [
                                        ("Default RPM-OSTree Server", self.set_default_repo_installation, True),
                                        ("Custom RPM-OSTree Server", self.set_default_repo_installation, False)
                                    ]

        host_menu = Menu(menu_starty,  maxx, ostree_host_menu_items)
        self.window = Window(win_height, win_width, maxy, maxx, 'Select OSTree Server', True, host_menu)

    def set_default_repo_installation(self,  is_default_repo ):
        self.install_config['default_repo'] = is_default_repo
        return ActionResult(True, None)

    def display(self, params):
        if self.install_config['type'] == 'ostree_host':
            return self.window.do_action()
        return ActionResult(True, None)
开发者ID:BillTheBest,项目名称:photon,代码行数:29,代码来源:ostreeserverselector.py

示例4: LinuxSelector

# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import do_action [as 别名]
class LinuxSelector(object):
    def __init__(self, maxy, maxx, install_config):
        self.install_config = install_config
        self.maxx = maxx
        self.maxy = maxy
        self.win_width = 60
        self.win_height = 13

        self.win_starty = (self.maxy - self.win_height) / 2
        self.win_startx = (self.maxx - self.win_width) / 2

        self.menu_starty = self.win_starty + 6

        self.menu_items = []
        self.menu_items.append(("1. Hypervisor optimized", self.set_linux_esx_installation, True))
        self.menu_items.append(("2. Generic", self.set_linux_esx_installation, False))

        self.host_menu = Menu(self.menu_starty, self.maxx, self.menu_items,
                              default_selected=0, tab_enable=False)

        self.window = Window(self.win_height, self.win_width, self.maxy, self.maxx,
                             'Select Linux kernel to install', True, items=[], tab_enabled=False,
                             position=1, can_go_next=True)
        self.window.set_action_panel(self.host_menu)

    def set_linux_esx_installation(self, is_linux_esx):
        self.install_config['install_linux_esx'] = is_linux_esx
        return ActionResult(True, None)

    def display(self, params):
        self.window.addstr(0, 0, 'The installer has detected that you are installing')
        self.window.addstr(1, 0, 'Photon OS on a VMware hypervisor.')
        self.window.addstr(2, 0, 'Which type of Linux kernel would you like to install?')
        return self.window.do_action()
开发者ID:megacoder,项目名称:photon,代码行数:36,代码来源:linuxselector.py

示例5: PackageSelector

# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import do_action [as 别名]
class PackageSelector(object):
    def __init__(self,  maxy, maxx, install_config, options_file):
        self.install_config = install_config
        self.maxx = maxx
        self.maxy = maxy
        self.win_width = 50
        self.win_height = 10

        self.win_starty = (self.maxy - self.win_height) / 2
        self.win_startx = (self.maxx - self.win_width) / 2

        self.menu_starty = self.win_starty + 3

        self.load_package_list(options_file)

        self.window = Window(self.win_height, self.win_width, self.maxy, self.maxx, 'Select Installation', True, self.package_menu)

    @staticmethod
    def get_packages_to_install(options, base_path, config_type):
        package_list = []
        for install_option in options:
            if install_option[0] == config_type:
                if install_option[1]["include"] != "none":
                    for include_type in install_option[1]["include"].split(','):
                        package_list = package_list + PackageSelector.get_packages_to_install(options, base_path, include_type)
                json_wrapper_package_list = JsonWrapper(os.path.join(base_path, install_option[1]["file"]))
                package_list_json = json_wrapper_package_list.read()
                package_list = package_list + package_list_json["packages"]
                break
        return package_list

    def load_package_list(self, options_file):
        json_wrapper_option_list = JsonWrapper(options_file)
        option_list_json = json_wrapper_option_list.read()
        options_sorted = option_list_json.items()

        self.package_menu_items = []
        base_path = os.path.dirname(options_file)
        package_list = []

        for install_option in options_sorted:
            if install_option[1]["visible"] == True:
                package_list = PackageSelector.get_packages_to_install(options_sorted, base_path, install_option[0])
                self.package_menu_items.append((install_option[1]["title"], self.exit_function, [install_option[0], package_list] ))

        self.package_menu = Menu(self.menu_starty,  self.maxx, self.package_menu_items)

    def exit_function(self,  selected_item_params):
        self.install_config['type'] = selected_item_params[0];
        self.install_config['packages'] = selected_item_params[1];
        return ActionResult(True, {'custom': False})

    def custom_packages(self, params):
        return ActionResult(True, {'custom': True})

    def display(self, params):
        return self.window.do_action()
开发者ID:sarchoi,项目名称:photon,代码行数:59,代码来源:packageselector.py

示例6: CustomPackageSelector

# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import do_action [as 别名]
class CustomPackageSelector(object):
    def __init__(self,  maxy, maxx, install_config):
        self.install_config = install_config
        self.menu_items = []

        self.maxx = maxx
        self.maxy = maxy
        self.win_width = 60
        self.win_height = 23

        self.win_starty = (self.maxy - self.win_height) / 2
        self.win_startx = (self.maxx - self.win_width) / 2

        self.menu_starty = self.win_starty + 3
        self.selected_packages = Set([])

        self.load_package_list()

        self.window = Window(self.win_height, self.win_width, self.maxy, self.maxx, 'Select your Packages', True, self.package_menu)

    def load_package_list(self):
        json_wrapper_package_list = JsonWrapper("packages_full.json");
        package_list_json = json_wrapper_package_list.read()

        for package in package_list_json["packages"]:
            self.menu_items.append((package, self.exit_function))
        self.package_menu = Menu(self.menu_starty,  self.maxx, self.menu_items, height = 18, selector_menu = True)


    def exit_function(self,  selected_indexes):
        json_wrapper_package_list = JsonWrapper("packages_minimal.json");
        package_list_json = json_wrapper_package_list.read()
        selected_items = []
        for index in selected_indexes:
            selected_items.append(self.menu_items[index][0])

        self.install_config['packages'] = package_list_json["packages"] + selected_items
        return ActionResult(True, None)

    def display(self, params):
        if (params['custom']):
            return self.window.do_action()
        else:
            return ActionResult(True, None)
开发者ID:BillTheBest,项目名称:photon,代码行数:46,代码来源:custompackageselector.py

示例7: WindowStringReader

# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import do_action [as 别名]
class WindowStringReader(object):
    def __init__(self, maxy, maxx, height, width, ispassword, confirm_password, title, display_string, inputy, install_config):
        self.title = title
        self.display_string = display_string
        self.inputy = inputy

        self.width = width
        self.height = height
        self.maxx = maxx
        self.maxy = maxy

        self.startx = (self.maxx - self.width) / 2
        self.starty = (self.maxy - self.height) / 2

        self.window = Window(self.height, self.width, self.maxy, self.maxx, self.title, True)
        self.read_text = ReadText(maxy, maxx, self.window.content_window(), self.inputy, install_config, ispassword, confirm_password)
        self.window.set_action_panel(self.read_text)
        self.window.addstr(0, 0, self.display_string)

    def get_user_string(self, params):
        return self.window.do_action()
开发者ID:bgrissin,项目名称:photon,代码行数:23,代码来源:windowstringreader.py

示例8: PackageSelector

# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import do_action [as 别名]
class PackageSelector(object):
    def __init__(self,  maxy, maxx, install_config):
        self.install_config = install_config
        self.maxx = maxx
        self.maxy = maxy
        self.win_width = 50
        self.win_height = 10

        self.win_starty = (self.maxy - self.win_height) / 2
        self.win_startx = (self.maxx - self.win_width) / 2

        self.menu_starty = self.win_starty + 3

        self.load_package_list()

        self.window = Window(self.win_height, self.win_width, self.maxy, self.maxx, 'Select Installation', True, self.package_menu)

    def load_package_list(self):
        json_wrapper_package_list = JsonWrapper("package_list.json");
        self.package_list_json = json_wrapper_package_list.read()

        self.package_menu_items =   [
                                        ('1. Photon OS (Micro)', self.exit_function, ['micro', self.package_list_json["micro_packages"]]),
                                        ('2. Photon Container OS (Minimal)', self.exit_function, ['minimal', self.package_list_json["minimal_packages"]]),
                                        ('3. Photon Full OS (All)', self.exit_function, ['full', self.package_list_json["minimal_packages"] + self.package_list_json["optional_packages"]]),
                                        ('4. Photon Custom OS', self.custom_packages, ['custom', None])
                                    ]
        self.package_menu = Menu(self.menu_starty,  self.maxx, self.package_menu_items)

    def exit_function(self,  selected_item_params):
        self.install_config['type'] = selected_item_params[0];
        self.install_config['packages'] = selected_item_params[1];
        return ActionResult(True, {'custom': False})

    def custom_packages(self, params):
        return ActionResult(True, {'custom': True})

    def display(self, params):
        return self.window.do_action()
开发者ID:Andrew219,项目名称:photon,代码行数:41,代码来源:packageselector.py

示例9: License

# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import do_action [as 别名]
class License(object):
    def __init__(self, maxy, maxx):
        self.maxx = maxx
        self.maxy = maxy
        self.win_width = maxx - 4
        self.win_height = maxy - 4

        self.win_starty = (self.maxy - self.win_height) // 2
        self.win_startx = (self.maxx - self.win_width) // 2

        self.text_starty = self.win_starty + 4
        self.text_height = self.win_height - 6
        self.text_width = self.win_width - 6

        self.window = Window(self.win_height, self.win_width, self.maxy, self.maxx,
                             'Welcome to the Photon installer', False)

    def display(self, params):
        accept_decline_items = [('<Accept>', self.accept_function),
                                ('<Cancel>', self.exit_function)]

        title = 'VMWARE 2.0 LICENSE AGREEMENT'
        self.window.addstr(0, (self.win_width - len(title)) // 2, title)
        self.text_pane = TextPane(self.text_starty, self.maxx, self.text_width,
                                  "EULA.txt", self.text_height, accept_decline_items)

        self.window.set_action_panel(self.text_pane)

        return self.window.do_action()


    def accept_function(self):
        return ActionResult(True, None)

    def exit_function(self):
        exit(0)
开发者ID:TiejunChina,项目名称:photon,代码行数:38,代码来源:license.py

示例10: SelectDisk

# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import do_action [as 别名]
class SelectDisk(object):
    def __init__(self,  maxy, maxx, install_config):
        self.install_config = install_config
        self.menu_items = []

        self.maxx = maxx
        self.maxy = maxy
        self.win_width = 70
        self.win_height = 16

        self.win_starty = (self.maxy - self.win_height) / 2
        self.win_startx = (self.maxx - self.win_width) / 2

        self.menu_starty = self.win_starty + 6
        self.menu_height = 5

        self.window = Window(self.win_height, self.win_width, self.maxy, self.maxx, 'Setup your disk', True)
        self.devices = Device.refresh_devices()

    def guided_partitions(self, device_index):
        menu_height = 9
        menu_width = 40
        menu_starty = (self.maxy - menu_height) / 2 + 5
        confrim_window = ConfirmWindow(menu_height, menu_width, self.maxy, self.maxx, menu_starty, 'This will erase the disk.\nAre you sure?')
        confirmed = confrim_window.do_action().result['yes']
        
        if not confirmed:
            return ActionResult(confirmed, None)
        
        #self.install_config['disk'] = self.devices[device_index].path
        #return ActionResult(True, None)
        
        # Do the partitioning
        self.window.clearerror()
        json_ret = subprocess.check_output(['gpartedbin', 'defaultpartitions', self.devices[device_index].path], stderr=open(os.devnull, 'w'))
        json_dct = json.loads(json_ret)
        if json_dct['success']:
            self.install_config['disk'] = json_dct['data']
        else:
            self.window.adderror('Partitioning failed, you may try again')
        return ActionResult(json_dct['success'], None)

    def display(self, params):
        self.window.addstr(0, 0, 'First, we will setup your disks.\n\nWe have detected {0} disks, choose disk to be auto-partitioned:'.format(len(self.devices)))

        self.disk_menu_items = []

        # Fill in the menu items
        for index, device in enumerate(self.devices):
            #if index > 0:
                self.disk_menu_items.append(
                        (
                            '{2} - {1} MB @ {0}'.format(device.path, device.size, device.model), 
                            self.guided_partitions, 
                            index
                        )
                    )

        self.disk_menu = Menu(self.menu_starty,  self.maxx, self.disk_menu_items, self.menu_height)

        self.window.set_action_panel(self.disk_menu)

        return self.window.do_action()
开发者ID:Andrew219,项目名称:photon,代码行数:65,代码来源:selectdisk.py

示例11: PartitionISO

# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import do_action [as 别名]
class PartitionISO(object):
    def __init__(self, maxy, maxx, install_config):
        self.maxx = maxx
        self.maxy = maxy
        self.win_width = maxx - 4
        self.win_height = maxy - 4
        self.install_config = install_config
        self.path_checker = []

        self.win_starty = (self.maxy - self.win_height) // 2
        self.win_startx = (self.maxx - self.win_width) // 2

        self.text_starty = self.win_starty + 4
        self.text_height = self.win_height - 6
        self.text_width = self.win_width - 6
        self.install_config['partitionsnumber'] = 0
        self.devices = Device.refresh_devices_bytes()
        self.has_slash = False
        self.has_remain = False
        self.has_empty = False

        self.disk_size = []
        for index, device in enumerate(self.devices):
            self.disk_size.append((device.path, int(device.size) / 1048576))

        self.window = Window(self.win_height, self.win_width, self.maxy, self.maxx,
                             'Welcome to the Photon installer', False, can_go_next=False)
        Device.refresh_devices()

    def display(self, params):
        if 'skipPrevs' in self.install_config and self.install_config['skipPrevs'] == True:
            self.delete()
            return ActionResult(False, {'goBack':True})
        if 'autopartition' in self.install_config and self.install_config['autopartition'] == True:
            return ActionResult(True, None)
        if ('delete_partition' in self.install_config and
                self.install_config['delete_partition'] == True):
            self.delete()
            self.install_config['delete_partition'] = False

        self.device_index = self.install_config['diskindex']

        self.disk_buttom_items = []
        self.disk_buttom_items.append(('<Next>', self.next))
        self.disk_buttom_items.append(('<Create New>', self.create_function))
        self.disk_buttom_items.append(('<Delete All>', self.delete_function))
        self.disk_buttom_items.append(('<Go Back>', self.go_back))

        self.text_items = []
        self.text_items.append(('Disk', 20))
        self.text_items.append(('Size', 5))
        self.text_items.append(('Type', 5))
        self.text_items.append(('Mountpoint', 20))
        self.table_space = 5

        title = 'Current partitions:\n'
        self.window.addstr(0, (self.win_width - len(title)) // 2, title)

        info = ("Unpartitioned space: " +
                str(self.disk_size[self.device_index][1])+
                " MB, Total size: "+
                str(int(self.devices[self.device_index].size)/ 1048576) + " MB")

        self.text_pane = TextPane(self.text_starty, self.maxx, self.text_width,
                                  "EULA.txt", self.text_height, self.disk_buttom_items,
                                  partition=True, popupWindow=True,
                                  install_config=self.install_config,
                                  text_items=self.text_items, table_space=self.table_space,
                                  default_start=1, info=info,
                                  size_left=str(self.disk_size[self.device_index][1]))

        self.window.set_action_panel(self.text_pane)

        return self.window.do_action()

    def validate_partition(self, pstr):
        if not pstr:
            return ActionResult(False, None)
        sizedata = pstr[0]
        mtdata = pstr[2]
        typedata = pstr[1]
        devicedata = self.devices[self.device_index].path

        #no empty fields unless swap
        if (typedata == 'swap' and
                (len(mtdata) != 0 or len(typedata) == 0 or len(devicedata) == 0)):
            return False, "invalid swap data "

        if (typedata != 'swap' and
                (len(sizedata) == 0 or
                 len(mtdata) == 0 or
                 len(typedata) == 0 or
                 len(devicedata) == 0)):
            if not self.has_empty and mtdata and typedata and devicedata:
                self.has_empty = True
            else:
                return False, "Input cannot be empty"

        if typedata != 'swap' and typedata != 'ext3' and typedata != 'ext4':
            return False, "Invalid type"
#.........这里部分代码省略.........
开发者ID:TiejunChina,项目名称:photon,代码行数:103,代码来源:partitionISO.py

示例12: PackageSelector

# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import do_action [as 别名]
class PackageSelector(object):
    def __init__(self,  maxy, maxx, install_config, options_file):
        self.install_config = install_config
        self.maxx = maxx
        self.maxy = maxy
        self.win_width = 50
        self.win_height = 13

        self.win_starty = (self.maxy - self.win_height) / 2
        self.win_startx = (self.maxx - self.win_width) / 2

        self.menu_starty = self.win_starty + 3

        self.load_package_list(options_file)

        self.window = Window(self.win_height, self.win_width, self.maxy, self.maxx, 'Select Installation', True, self.package_menu)

    @staticmethod
    def get_packages_to_install(options, config_type, output_data_path):
        package_list = []
        for install_option in options:
            if install_option[0] == config_type:               
                for include_type in install_option[1]["include"]:
                    package_list = package_list + PackageSelector.get_packages_to_install(options, include_type, output_data_path)
                json_wrapper_package_list = JsonWrapper(os.path.join(output_data_path, install_option[1]["file"]))
                package_list_json = json_wrapper_package_list.read()
                package_list = package_list + package_list_json["packages"]
                break
        return package_list

    @staticmethod
    def get_additional_files_to_copy_in_iso(options, base_path, config_type):
        additional_files = []
        for install_option in options:
            if install_option[0] == config_type:
                if install_option[1].has_key("additional-files"):
                    additional_files = install_option[1]["additional-files"]
                break
        return additional_files

    def load_package_list(self, options_file):
        json_wrapper_option_list = JsonWrapper(options_file)
        option_list_json = json_wrapper_option_list.read()
        options_sorted = option_list_json.items()

        self.package_menu_items = []
        base_path = os.path.dirname(options_file)
        package_list = []

        default_selected = 0
        visible_options_cnt = 0
        for install_option in options_sorted:
            if install_option[1]["visible"] == True:
                package_list = PackageSelector.get_packages_to_install(options_sorted, install_option[0], base_path)
                additional_files = PackageSelector.get_additional_files_to_copy_in_iso(options_sorted, base_path, install_option[0])
                self.package_menu_items.append((install_option[1]["title"], self.exit_function, [install_option[0], package_list, additional_files] ))
                if install_option[0] == 'minimal':
                    default_selected = visible_options_cnt
                visible_options_cnt = visible_options_cnt + 1


        self.package_menu = Menu(self.menu_starty,  self.maxx, self.package_menu_items, default_selected = default_selected)

    def exit_function(self,  selected_item_params):
        self.install_config['type'] = selected_item_params[0];
        self.install_config['packages'] = selected_item_params[1];
        self.install_config['additional-files'] = selected_item_params[2]
        return ActionResult(True, {'custom': False})

    def custom_packages(self, params):
        return ActionResult(True, {'custom': True})

    def display(self, params):
        return self.window.do_action()
开发者ID:BillTheBest,项目名称:photon,代码行数:76,代码来源:packageselector.py

示例13: SelectDisk

# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import do_action [as 别名]
class SelectDisk(object):
    def __init__(self,  maxy, maxx, install_config):
        self.install_config = install_config
        self.menu_items = []

        self.maxx = maxx
        self.maxy = maxy
        self.win_width = 70
        self.win_height = 16

        self.win_starty = (self.maxy - self.win_height) / 2
        self.win_startx = (self.maxx - self.win_width) / 2

        self.menu_starty = self.win_starty + 6
        self.menu_height = 5
        self.progress_padding = 5
        self.progress_width = self.win_width - self.progress_padding
        self.progress_bar = ProgressBar(self.win_starty + 6, self.win_startx + self.progress_padding / 2, self.progress_width)

        self.window = Window(self.win_height, self.win_width, self.maxy, self.maxx, 'Setup your disk', True)
        self.devices = Device.refresh_devices()

    def guided_partitions(self, device_index):
        menu_height = 9
        menu_width = 40
        menu_starty = (self.maxy - menu_height) / 2 + 5
        confrim_window = ConfirmWindow(menu_height, menu_width, self.maxy, self.maxx, menu_starty, 'This will erase the disk.\nAre you sure?')
        confirmed = confrim_window.do_action().result['yes']

        if not confirmed:
            return ActionResult(confirmed, None)

        self.progress_bar.initialize('Partitioning...')
        self.progress_bar.show()
        self.progress_bar.show_loading('Partitioning')

        # Do the partitioning
        self.window.clearerror()
        partitions_data = modules.commons.partition_disk(self.devices[device_index].path, modules.commons.default_partitions)
        if partitions_data == None:
            self.window.adderror('Partitioning failed, you may try again')
        else:
            self.install_config['disk'] = partitions_data

        self.progress_bar.hide()
        return ActionResult(partitions_data != None, None)

    def display(self, params):
        self.window.addstr(0, 0, 'First, we will setup your disks.\n\nWe have detected {0} disks, choose disk to be auto-partitioned:'.format(len(self.devices)))

        self.disk_menu_items = []

        # Fill in the menu items
        for index, device in enumerate(self.devices):
            #if index > 0:
                self.disk_menu_items.append(
                        (
                            '{2} - {1} @ {0}'.format(device.path, device.size, device.model), 
                            self.guided_partitions, 
                            index
                        )
                    )

        self.disk_menu = Menu(self.menu_starty,  self.maxx, self.disk_menu_items, self.menu_height)

        self.window.set_action_panel(self.disk_menu)
        return self.window.do_action()
开发者ID:BillTheBest,项目名称:photon,代码行数:69,代码来源:selectdisk.py

示例14: SelectDisk

# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import do_action [as 别名]
class SelectDisk(object):
    def __init__(self,  maxy, maxx, install_config):
        self.install_config = install_config
        self.menu_items = []

        self.maxx = maxx
        self.maxy = maxy
        self.win_width = 70
        self.win_height = 16

        self.win_starty = (self.maxy - self.win_height) / 2
        self.win_startx = (self.maxx - self.win_width) / 2

        self.menu_starty = self.win_starty + 6
        self.menu_height = 5
        self.progress_padding = 5
        self.progress_width = self.win_width - self.progress_padding
        self.progress_bar = ProgressBar(self.win_starty + 6, self.win_startx + self.progress_padding / 2, self.progress_width, new_win=True)

        self.disk_buttom_items = []
        self.disk_buttom_items.append(('<Custom>', self.custom_function, False))
        self.disk_buttom_items.append(('<Auto>', self.auto_function, False))

        self.window = Window(self.win_height, self.win_width, self.maxy, self.maxx, 'Select a disk', True, items = self.disk_buttom_items, menu_helper = self.save_index, position = 2, tab_enabled=False)
        self.partition_window = Window(self.win_height, self.win_width, self.maxy, self.maxx, 'Partition', True)
        self.devices = Device.refresh_devices()

    def guided_partitions(self, params):
        if not 'diskindex' in self.install_config:
            return ActionResult(False, None);

        device_index = self.install_config['diskindex']

        menu_height = 9
        menu_width = 40
        menu_starty = (self.maxy - menu_height) / 2 + 5
        self.install_config['delete_partition'] = True
        confrim_window = ConfirmWindow(menu_height, menu_width, self.maxy, self.maxx, menu_starty, 'This will erase the disk.\nAre you sure?')
        confirmed = confrim_window.do_action().result['yes']

        if confirmed == False:
            self.install_config['skipPrevs'] = True
            return ActionResult(False, {'goBack':True})

        self.install_config['skipPrevs'] = False
        self.progress_bar.initialize('Partitioning...')
        self.progress_bar.show()
        self.progress_bar.show_loading('Partitioning')

        # Do the partitioning
        if 'partitionsnumber' in self.install_config:
                if (int(self.install_config['partitionsnumber']) == 0):
                    partitions_data = modules.commons.partition_disk(self.devices[device_index].path, modules.commons.default_partitions)
                else:
                    partitions = []
                    for i in range (int (self.install_config['partitionsnumber'])):
                        if len(self.install_config[str(i)+'partition_info'+str(0)])==0:
                            sizedata=0
                        else:
                            sizedata = int(self.install_config[str(i)+'partition_info'+str(0)])
                        mtdata = self.install_config[str(i)+'partition_info'+str(2)]
                        typedata = self.install_config[str(i)+'partition_info'+str(1)]

                        partitions = partitions + [
                                    {"mountpoint": mtdata, "size": sizedata, "filesystem": typedata},
                                    ]
                    partitions_data = modules.commons.partition_disk(self.devices[device_index].path, partitions)
        else: 
            partitions_data = modules.commons.partition_disk(self.devices[device_index].path, modules.commons.default_partitions)

        if partitions_data == None:
            self.partition_window.adderror('Partitioning failed, you may try again')
        else:
            self.install_config['disk'] = partitions_data

        self.progress_bar.hide()
        return ActionResult(partitions_data != None, None)

    def display(self, params):
        if 'skipPrevs' in self.install_config:
            self.install_config['skipPrevs'] = False
        self.window.addstr(0, 0, 'Please select a disk and a method how to partition it:\nAuto - single partition for /, no swap partition.\nCustom - for customized partitioning')

        self.disk_menu_items = []

        # Fill in the menu items
        for index, device in enumerate(self.devices):
            #if index > 0:
                self.disk_menu_items.append(
                        (
                            '{2} - {1} @ {0}'.format(device.path, device.size, device.model), 
                            self.save_index, 
                            index
                        )
                    )

        self.disk_menu = Menu(self.menu_starty,  self.maxx, self.disk_menu_items, self.menu_height, tab_enable=False)
        self.disk_menu.can_save_sel(True)

        self.window.set_action_panel(self.disk_menu)
#.........这里部分代码省略.........
开发者ID:megacoder,项目名称:photon,代码行数:103,代码来源:selectdisk.py


注:本文中的window.Window.do_action方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。