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


Python PartedServer.readline_part_entry方法代码示例

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


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

示例1: find_grub_target

# 需要导入模块: from ubiquity.parted_server import PartedServer [as 别名]
# 或者: from ubiquity.parted_server.PartedServer import readline_part_entry [as 别名]
def find_grub_target():
    # This needs to be somewhat duplicated from grub-installer here because we
    # need to be able to show the user what device GRUB will be installed to
    # well before grub-installer is run.
    try:
        boot = ""
        root = ""
        regain_privileges()
        p = PartedServer()
        for disk in p.disks():
            p.select_disk(disk)
            for part in p.partitions():
                part = part[1]
                if p.has_part_entry(part, "mountpoint"):
                    mp = p.readline_part_entry(part, "mountpoint")
                    if mp == "/boot":
                        boot = disk.replace("=", "/")
                    elif mp == "/":
                        root = disk.replace("=", "/")
        drop_privileges()
        if boot:
            return boot
        elif root:
            return root
        return "(hd0)"
    except Exception, e:
        drop_privileges()
        import syslog

        syslog.syslog("Exception in find_grub_target: " + str(e))
        return "(hd0)"
开发者ID:ericpaulbishop,项目名称:salamander,代码行数:33,代码来源:summary.py

示例2: boot_device

# 需要导入模块: from ubiquity.parted_server import PartedServer [as 别名]
# 或者: from ubiquity.parted_server.PartedServer import readline_part_entry [as 别名]
def boot_device():
    from ubiquity.parted_server import PartedServer

    boot = None
    root = None
    try:
        p = PartedServer()
        for disk in p.disks():
            p.select_disk(disk)
            for part in p.partitions():
                part = part[1]
                if p.has_part_entry(part, 'mountpoint'):
                    mp = p.readline_part_entry(part, 'mountpoint')
                    if mp == '/boot':
                        boot = disk.replace('=', '/')
                    elif mp == '/':
                        root = disk.replace('=', '/')
    except Exception:
        import traceback

        for line in traceback.format_exc().split('\n'):
            syslog.syslog(syslog.LOG_ERR, line)
    if boot:
        return boot
    return root
开发者ID:cesarcifmetal,项目名称:Cnchi,代码行数:27,代码来源:misc.py

示例3: run

# 需要导入模块: from ubiquity.parted_server import PartedServer [as 别名]
# 或者: from ubiquity.parted_server.PartedServer import readline_part_entry [as 别名]
    def run(self, priority, question):
        if self.stashed_auto_mountpoints is None:
            # We need to extract the automatic mountpoints calculated by
            # partman at some point while parted_server is running, so that
            # they can be used later if manual partitioning is selected.
            # This hack is only necessary because the manual partitioner is
            # NIHed rather than being based on partman.
            self.stashed_auto_mountpoints = {}
            parted = PartedServer()
            for disk in parted.disks():
                parted.select_disk(disk)
                for part in parted.partitions():
                    (p_num, p_id, p_size, p_type, p_fs, p_path, p_name) = part
                    if p_fs == 'free':
                        continue
                    if not parted.has_part_entry(p_id, 'method'):
                        continue
                    method = parted.readline_part_entry(p_id, 'method')
                    if method == 'swap':
                        continue
                    elif p_fs == 'hfs' and method == 'newworld':
                        self.stashed_auto_mountpoints[p_path] = 'newworld'
                    elif parted.has_part_entry(p_id, 'acting_filesystem'):
                        mountpoint = parted.readline_part_entry(p_id,
                                                                'mountpoint')
                        self.stashed_auto_mountpoints[p_path] = mountpoint
            self.frontend.set_auto_mountpoints(self.stashed_auto_mountpoints)

        if self.done:
            # user answered confirmation question or selected manual
            # partitioning
            return self.succeeded

        self.current_question = question

        try:
            qtype = self.db.metaget(question, 'Type')
        except debconf.DebconfError:
            qtype = ''

        if question == 'partman-auto/select_disk':
            self.resize_allowed = True
            self.manual_desc = \
                self.description('partman-auto/text/custom_partitioning')
            self.do_nothing_desc = \
                self.description('partman-auto/text/do_nothing_partitioning')
            self.use_biggest_free_desc = \
                self.description('partman-auto/text/use_biggest_free')
            if not self.frontend.set_disk_choices(self.choices(question),
                                                  self.manual_desc):
                # disk selector not implemented; just use first disk
                return self.succeeded

        elif question.endswith('automatically_partition'):
            if self.backup_from_new_size is not None:
                # We backed up from the resize question and now need to
                # carry on down a different (preseeded) path.
                self.preseed(question, self.backup_from_new_size)
                self.backup_from_new_size = None
                self.succeeded = True
                return True

            self.autopartition_question = question
            self.resize_desc = \
                self.description('partman-auto/text/resize_use_free')
            self.manual_desc = \
                self.description('partman-auto/text/custom_partitioning')
            self.do_nothing_desc = \
                self.description('partman-auto/text/do_nothing_partitioning')
            self.use_biggest_free_desc = \
                self.description('partman-auto/text/use_biggest_free')
            choices = self.choices(question)
            if not self.resize_allowed:
                try:
                    del choices[choices.index(self.resize_desc)]
                except ValueError:
                    pass
            self.frontend.set_autopartition_choices(
                choices, self.resize_desc, self.manual_desc, self.do_nothing_desc, self.use_biggest_free_desc)
            if self.resize_desc in choices:
                # The resize option is available, so we need to present the
                # user with an accurate resize slider before passing control
                # to the UI.
                # Don't preseed_as_c, because Perl debconf is buggy in that
                # it doesn't expand variables in the result of METAGET
                # choices-c. All locales have the same variables anyway so
                # it doesn't matter.
                self.preseed(question, self.resize_desc)
                return True

        elif question == 'partman-partitioning/new_size':
            self.backup_from_new_size = None
            self.frontend.set_autopartition_resize_bounds(self.resize_min_size,
                                                          self.resize_max_size)

        elif question.startswith('partman/confirm'):
            if question == 'partman/confirm':
                self.db.set('ubiquity/partman-made-changes', 'true')
            else:
                self.db.set('ubiquity/partman-made-changes', 'false')
#.........这里部分代码省略.........
开发者ID:guadalinex-archive,项目名称:guadalinex-v4,代码行数:103,代码来源:partman_auto.py

示例4: progress_stop

# 需要导入模块: from ubiquity.parted_server import PartedServer [as 别名]
# 或者: from ubiquity.parted_server.PartedServer import readline_part_entry [as 别名]
    def progress_stop(self, progress_title):
        ret = super(PartmanCommit, self).progress_stop(progress_title)

        if (progress_title == 'partman/progress/init/title' and
            self.manual_input):
            partitions = {}
            parted = PartedServer()
            for disk in parted.disks():
                parted.select_disk(disk)
                for part in parted.partitions():
                    (p_num, p_id, p_size, p_type, p_fs, p_path, p_name) = part
                    partitions[p_path] = (disk, p_id)

            mountpoints = self.frontend.get_mountpoints()
            for device in partitions:
                (disk, p_id) = partitions[device]
                parted.select_disk(disk)
                if device in mountpoints:
                    (path, format, fstype, flags) = mountpoints[device]
                    if path == 'swap':
                        parted.write_part_entry(p_id, 'method', 'swap\n')
                        if format:
                            parted.write_part_entry(p_id, 'format', '')
                        else:
                            parted.remove_part_entry(p_id, 'format')
                        parted.remove_part_entry(p_id, 'use_filesystem')
                    else:
                        if (fstype == 'hfs' and
                            flags is not None and 'boot' in flags):
                            parted.write_part_entry(
                                p_id, 'method', 'newworld\n')
                            parted.write_part_entry(
                                p_id, 'filesystem', 'newworld')
                            parted.remove_part_entry(p_id, 'format')
                            path = None
                        elif format:
                            parted.write_part_entry(p_id, 'method', 'format\n')
                            parted.write_part_entry(p_id, 'format', '')
                            if fstype is None:
                                if parted.has_part_entry(
                                        p_id, 'detected_filesystem'):
                                    fstype = parted.readline_part_entry(
                                        p_id, 'detected_filesystem')
                                else:
                                    # TODO cjwatson 2006-09-27: Why don't we
                                    # know the filesystem type? Fortunately,
                                    # we have an explicit indication from
                                    # the user that it's OK to format this
                                    # filesystem.
                                    fstype = 'ext3'
                            parted.write_part_entry(p_id, 'filesystem', fstype)
                            parted.remove_part_entry(p_id, 'options')
                            parted.mkdir_part_entry(p_id, 'options')
                        else:
                            parted.write_part_entry(p_id, 'method', 'keep\n')
                            parted.remove_part_entry(p_id, 'format')
                            if fstype is not None:
                                parted.write_part_entry(
                                    p_id, 'detected_filesystem', fstype)
                        parted.write_part_entry(p_id, 'use_filesystem', '')
                        if path is not None:
                            parted.write_part_entry(p_id, 'mountpoint', path)
                        else:
                            parted.remove_part_entry(p_id, 'mountpoint')
                elif (parted.has_part_entry(p_id, 'method') and
                      parted.readline_part_entry(p_id, 'method') == 'newworld'):
                    # Leave existing newworld boot partitions alone.
                    pass
                else:
                    parted.remove_part_entry(p_id, 'method')
                    parted.remove_part_entry(p_id, 'format')
                    parted.remove_part_entry(p_id, 'use_filesystem')

        return ret
开发者ID:guadalinex-archive,项目名称:guadalinex-v4,代码行数:76,代码来源:partman_commit.py


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