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


Python errorHandler.cb函数代码示例

本文整理汇总了Python中pyanaconda.errors.errorHandler.cb函数的典型用法代码示例。如果您正苦于以下问题:Python cb函数的具体用法?Python cb怎么用?Python cb使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: mountImage

def mountImage(isodir, tree):
    while True:
        if os.path.isfile(isodir):
            image = isodir
        else:
            image = findFirstIsoImage(isodir)
            if image is None:
                exn = MissingImageError()
                if errorHandler.cb(exn) == ERROR_RAISE:
                    raise exn
                else:
                    continue

            image = os.path.normpath("%s/%s" % (isodir, image))

        try:
            blivet.util.mount(image, tree, fstype='iso9660', options="ro")
        except OSError:
            exn = MissingImageError()
            if errorHandler.cb(exn) == ERROR_RAISE:
                raise exn
            else:
                continue
        else:
            break
开发者ID:cyclefusion,项目名称:anaconda,代码行数:25,代码来源:image.py

示例2: unmountCD

def unmountCD(dev):
    if not dev:
        return

    while True:
        try:
            dev.format.unmount()
        except FSError as e:
            log.error("exception in _unmountCD: %s", e)
            exn = MediaUnmountError()
            errorHandler.cb(exn, dev)
        else:
            break
开发者ID:Sabayon,项目名称:anaconda,代码行数:13,代码来源:image.py

示例3: run

    def run(self, chroot):
        """ Run the kickstart script
            @param chroot directory path to chroot into before execution
        """
        if self.inChroot:
            scriptRoot = chroot
        else:
            scriptRoot = "/"

        (fd, path) = tempfile.mkstemp("", "ks-script-", scriptRoot + "/tmp")

        os.write(fd, self.script.encode("utf-8"))
        os.close(fd)
        os.chmod(path, 0o700)

        # Always log stdout/stderr from scripts.  Using --log just lets you
        # pick where it goes.  The script will also be logged to program.log
        # because of execWithRedirect.
        if self.logfile:
            if self.inChroot:
                messages = "%s/%s" % (scriptRoot, self.logfile)
            else:
                messages = self.logfile

            d = os.path.dirname(messages)
            if not os.path.exists(d):
                os.makedirs(d)
        else:
            # Always log outside the chroot, we copy those logs into the
            # chroot later.
            messages = "/tmp/%s.log" % os.path.basename(path)

        with open(messages, "w") as fp:
            rc = util.execWithRedirect(self.interp, ["/tmp/%s" % os.path.basename(path)],
                                       stdout=fp,
                                       root=scriptRoot)

        if rc != 0:
            script_log.error("Error code %s running the kickstart script at line %s", rc, self.lineno)
            if self.errorOnFail:
                err = ""
                with open(messages, "r") as fp:
                    err = "".join(fp.readlines())

                # Show error dialog even for non-interactive
                flags.ksprompt = True

                errorHandler.cb(ScriptError(self.lineno, err))
                util.ipmi_report(IPMI_ABORTED)
                sys.exit(0)
开发者ID:rvykydal,项目名称:anaconda,代码行数:50,代码来源:kickstart.py

示例4: install

    def install(self):
        """ Install the payload. """
        self.pct_lock = Lock()
        self.pct = 0
        threadMgr.add(AnacondaThread(name=THREAD_LIVE_PROGRESS,
                                     target=self.progress))

        cmd = "rsync"
        # preserve: permissions, owners, groups, ACL's, xattrs, times,
        #           symlinks, hardlinks
        # go recursively, include devices and special files, don't cross
        # file system boundaries
        args = ["-pogAXtlHrDx", "--exclude", "/dev/", "--exclude", "/proc/",
                "--exclude", "/sys/", "--exclude", "/run/", "--exclude", "/boot/*rescue*",
                "--exclude", "/etc/machine-id", INSTALL_TREE+"/", ROOT_PATH]
        try:
            rc = iutil.execWithRedirect(cmd, args)
        except (OSError, RuntimeError) as e:
            msg = None
            err = str(e)
            log.error(err)
        else:
            err = None
            msg = "%s exited with code %d" % (cmd, rc)
            log.info(msg)

        if err or rc == 12:
            exn = PayloadInstallError(err or msg)
            if errorHandler.cb(exn) == ERROR_RAISE:
                raise exn

        # Wait for progress thread to finish
        with self.pct_lock:
            self.pct = 100
        threadMgr.wait(THREAD_LIVE_PROGRESS)
开发者ID:akozumpl,项目名称:anaconda,代码行数:35,代码来源:livepayload.py

示例5: turn_on_swap

    def turn_on_swap(self, root_path=""):
        """Activate the system's swap space."""
        for device in self.swap_devices:
            if isinstance(device, FileDevice):
                # set up FileDevices' parents now that they are accessible
                target_dir = "%s/%s" % (root_path, device.path)
                parent = get_containing_device(target_dir, self.devicetree)
                if not parent:
                    log.error("cannot determine which device contains "
                              "directory %s", device.path)
                    device.parents = []
                    self.devicetree._remove_device(device)
                    continue
                else:
                    device.parents = [parent]

            while True:
                if device.status and device.format.status:
                    break
                try:
                    device.setup()
                    device.format.setup()
                except (blockdev.SwapOldError, blockdev.SwapSuspendError,
                        blockdev.SwapUnknownError, blockdev.SwapPagesizeError) as e:
                    log.error("Failed to activate swap on '%s': %s", device.name, str(e))
                    break
                except (StorageError, blockdev.BlockDevError) as e:
                    if error_handler.cb(e) == ERROR_RAISE:
                        raise
                else:
                    break
开发者ID:rvykydal,项目名称:anaconda,代码行数:31,代码来源:fsset.py

示例6: mountImageDirectory

def mountImageDirectory(method, storage):
    # No need to mount it again.
    if os.path.ismount(ISO_DIR):
        return

    if method.method == "harddrive":
        if method.biospart:
            log.warning("biospart support is not implemented")
            devspec = method.biospart
        else:
            devspec = method.partition

        # FIXME: teach DeviceTree.resolveDevice about biospart
        device = storage.devicetree.resolveDevice(devspec)

        while True:
            try:
                device.setup()
                device.format.setup(mountpoint=ISO_DIR)
            except StorageError as e:
                log.error("couldn't mount ISO source directory: %s", e)
                exn = MediaMountError(str(e), device)
                if errorHandler.cb(exn) == ERROR_RAISE:
                    raise exn
    elif method.method.startswith("nfsiso:"):
        # XXX what if we mount it on ISO_DIR and then create a symlink
        #     if there are no isos instead of the remount?

        # mount the specified directory
        path = method.dir
        if method.dir.endswith(".iso"):
            path = os.path.dirname(method.dir)

        url = "%s:%s" % (method.server, path)

        while True:
            try:
                blivet.util.mount(url, ISO_DIR, fstype="nfs", options=method.options)
            except OSError as e:
                log.error("couldn't mount ISO source directory: %s", e)
                exn = MediaMountError(str(e), device)
                if errorHandler.cb(exn) == ERROR_RAISE:
                    raise exn
开发者ID:cyclefusion,项目名称:anaconda,代码行数:43,代码来源:image.py

示例7: setup

    def setup(self, storage, instClass):
        super(LiveImagePayload, self).setup(storage, instClass)

        # Mount the live device and copy from it instead of the overlay at /
        osimg = storage.devicetree.getDeviceByPath(self.data.method.partition)
        if not stat.S_ISBLK(os.stat(osimg.path)[stat.ST_MODE]):
            exn = PayloadSetupError("%s is not a valid block device" % (self.data.method.partition,))
            if errorHandler.cb(exn) == ERROR_RAISE:
                raise exn
        blivet.util.mount(osimg.path, INSTALL_TREE, fstype="auto", options="ro")
开发者ID:akozumpl,项目名称:anaconda,代码行数:10,代码来源:livepayload.py

示例8: install

    def install(self, args=None):
        buf = util.execWithCapture("zipl", [], root=util.getSysroot())
        for line in buf.splitlines():
            if line.startswith("Preparing boot device: "):
                # Output here may look like:
                #     Preparing boot device: dasdb (0200).
                #     Preparing boot device: dasdl.
                # We want to extract the device name and pass that.
                name = re.sub(r".+?: ", "", line)
                self.stage1_name = re.sub(r"(\s\(.+\))?\.$", "", name)
            # a limitation of s390x is that the kernel parameter list must not
            # exceed 896 bytes; there is nothing we can do about this, so just
            # catch the error and show it to the user instead of crashing
            elif line.startswith("Error: The length of the parameters "):
                errorHandler.cb(ZIPLError(line))

        if not self.stage1_name:
            raise BootLoaderError("could not find IPL device")

        # do the reipl
        util.reIPL(self.stage1_name)
开发者ID:rvykydal,项目名称:anaconda,代码行数:21,代码来源:zipl.py

示例9: install

    def install(self):
        """ Install the payload if it is a tar.
            Otherwise fall back to rsync of INSTALL_TREE
        """
        # If it doesn't look like a tarfile use the super's install()
        if not self.is_tarfile:
            super(LiveImageKSPayload, self).install()
            return

        # Use 2x the archive's size to estimate the size of the install
        # This is used to drive the progress display
        self.source_size = os.stat(self.image_path)[stat.ST_SIZE] * 2

        self.pct_lock = Lock()
        self.pct = 0
        threadMgr.add(AnacondaThread(name=THREAD_LIVE_PROGRESS,
                                     target=self.progress))

        cmd = "tar"
        # preserve: ACL's, xattrs, and SELinux context
        args = ["--selinux", "--acls", "--xattrs", "--xattrs-include", "*",
                "--exclude", "/dev/", "--exclude", "/proc/",
                "--exclude", "/sys/", "--exclude", "/run/", "--exclude", "/boot/*rescue*",
                "--exclude", "/etc/machine-id", "-xaf", self.image_path, "-C", iutil.getSysroot()]
        try:
            rc = iutil.execWithRedirect(cmd, args)
        except (OSError, RuntimeError) as e:
            msg = None
            err = str(e)
            log.error(err)
        else:
            err = None
            msg = "%s exited with code %d" % (cmd, rc)
            log.info(msg)

        if err:
            exn = PayloadInstallError(err or msg)
            if errorHandler.cb(exn) == ERROR_RAISE:
                raise exn

        # Wait for progress thread to finish
        with self.pct_lock:
            self.pct = 100
        threadMgr.wait(THREAD_LIVE_PROGRESS)

        # Live needs to create the rescue image before bootloader is written
        for kernel in self.kernelVersionList:
            log.info("Generating rescue image for %s", kernel)
            iutil.execInSysroot("new-kernel-pkg",
                                ["--rpmposttrans", kernel])
开发者ID:marmarek,项目名称:qubes-installer-qubes-os,代码行数:50,代码来源:livepayload.py

示例10: cryptPassword

def cryptPassword(password, algo=None):
    salts = {'md5': crypt.METHOD_MD5,
             'sha256': crypt.METHOD_SHA256,
             'sha512': crypt.METHOD_SHA512}

    if algo not in salts:
        algo = 'sha512'

    cryptpw = crypt.crypt(password, salts[algo])
    if cryptpw is None:
        exn = PasswordCryptError(algo=algo)
        if errorHandler.cb(exn) == ERROR_RAISE:
            raise exn

    return cryptpw
开发者ID:dougsland,项目名称:anaconda,代码行数:15,代码来源:users.py

示例11: setup

    def setup(self, storage, instClass):
        """ Check the availability and size of the image.
        """
        # This is on purpose, we don't want to call LiveImagePayload's setup method.
        ImagePayload.setup(self, storage, instClass)

        if self.data.method.url.startswith("file://"):
            error = self._setup_file_image()
        else:
            error = self._setup_url_image()

        if error:
            exn = PayloadInstallError(str(error))
            if errorHandler.cb(exn) == ERROR_RAISE:
                raise exn

        log.debug("liveimg size is %s", self._min_size)
开发者ID:marmarek,项目名称:qubes-installer-qubes-os,代码行数:17,代码来源:livepayload.py

示例12: setup

    def setup(self, storage, instClass):
        super(LiveImagePayload, self).setup(storage, instClass)

        # Mount the live device and copy from it instead of the overlay at /
        osimg = storage.devicetree.getDeviceByPath(self.data.method.partition)
        if not stat.S_ISBLK(os.stat(osimg.path)[stat.ST_MODE]):
            exn = PayloadSetupError("%s is not a valid block device" % (self.data.method.partition,))
            if errorHandler.cb(exn) == ERROR_RAISE:
                raise exn
        rc = blivet.util.mount(osimg.path, INSTALL_TREE, fstype="auto", options="ro")
        if rc != 0:
            raise PayloadInstallError("Failed to mount the install tree")

        # Grab the kernel version list now so it's available after umount
        self._updateKernelVersionList()

        source = iutil.eintr_retry_call(os.statvfs, INSTALL_TREE)
        self.source_size = source.f_frsize * (source.f_blocks - source.f_bfree)
开发者ID:KosiehBarter,项目名称:anaconda,代码行数:18,代码来源:livepayload.py

示例13: turn_on_filesystems

def turn_on_filesystems(storage, callbacks=None):
    """Perform installer-specific activation of storage configuration.

    :param storage: the storage object
    :type storage: :class:`~.storage.InstallerStorage`
    :param callbacks: callbacks to be invoked when actions are executed
    :type callbacks: return value of the :func:`blivet.callbacks.create_new_callbacks_register`
    """
    storage.devicetree.teardown_all()

    try:
        storage.do_it(callbacks)
        _setup_bootable_devices(storage)
        storage.dump_state("final")
    except (FSResizeError, FormatResizeError) as e:
        if error_handler.cb(e) == ERROR_RAISE:
            raise

    storage.turn_on_swap()
开发者ID:rvykydal,项目名称:anaconda,代码行数:19,代码来源:installation.py

示例14: cryptPassword

def cryptPassword(password, algo=None):
    salts = {"md5": "$1$", "sha256": "$5$", "sha512": "$6$"}
    saltlen = 2

    if algo is None:
        algo = "sha512"

    if algo == "md5" or algo == "sha256" or algo == "sha512":
        saltlen = 16

    saltstr = salts[algo]

    for _i in range(saltlen):
        saltstr = saltstr + random.choice(string.ascii_letters + string.digits + "./")

    cryptpw = crypt.crypt(password, saltstr)
    if cryptpw is None:
        exn = PasswordCryptError(algo=algo)
        if errorHandler.cb(exn) == ERROR_RAISE:
            raise exn

    return cryptpw
开发者ID:rtruxal,项目名称:anaconda,代码行数:22,代码来源:users.py

示例15: install_boot_loader

def install_boot_loader(storage):
    """Do the final write of the boot loader.

    :param storage: an instance of the storage
    """
    log.debug("Installing the boot loader.")

    stage1_device = storage.bootloader.stage1_device
    log.info("boot loader stage1 target device is %s", stage1_device.name)

    stage2_device = storage.bootloader.stage2_device
    log.info("boot loader stage2 target device is %s", stage2_device.name)

    # FIXME: do this from elsewhere?
    storage.bootloader.set_boot_args(storage)

    try:
        storage.bootloader.write()
    except BootLoaderError as e:
        log.error("bootloader.write failed: %s", e)
        if errorHandler.cb(e) == ERROR_RAISE:
            raise
开发者ID:rvykydal,项目名称:anaconda,代码行数:22,代码来源:installation.py


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