How to use the pyalpm.error function in pyalpm

To help you get started, we’ve selected a few pyalpm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github archlinux / pyalpm / test / test_transaction.py View on Github external
def test_commit_error(transaction):
    with raises(error) as excinfo:
        transaction.commit()
    assert 'transaction failed' in str(excinfo.value)
github archlinux / pyalpm / test / test_handle.py View on Github external
def test_set_pkgreason(handle, package):
    with raises(pyalpm.error) as excinfo:
        handle.set_pkgreason(package, -1)
    assert 'failed setting install reason' in str(excinfo.value)
github archlinux / pyalpm / pycman / transaction.py View on Github external
def finalize(t):
	"Commit a transaction"
	try:
		t.prepare()
		t.commit()
	except pyalpm.error:
		traceback.print_exc()
		t.release()
		return False
	t.release()
	return True
github Antergos / Cnchi / src / pacman / original / transaction.py View on Github external
def t_finalize(t):
	ConfDialog.hide()
	try:
		t.prepare()
	except pyalpm.error:
		ErrorDialog.format_secondary_text(traceback.format_exc())
		response = ErrorDialog.run()
		if response:
			ErrorDialog.hide()
		t.release()
		t_lock = False
	try:
		t.commit()
	except pyalpm.error:
		ErrorDialog.format_secondary_text(traceback.format_exc())
		response = ErrorDialog.run()
		if response:
			ErrorDialog.hide()
	ProgressWindow.hide()
github lahwaacz / archweb_manpages / finder.py View on Github external
def refresh(self):
        try:
            logger.info("Syncing pacman database (x86_64)...")
            self._refresh_sync_db(self.sync_db)
        except pyalpm.error:
            logger.exception("Failed to sync pacman database.")
            raise
github Antergos / Cnchi / src / pacman / pac.py View on Github external
transaction = self.handle.init_transaction(
                nodeps=options.get('nodeps', False),
                dbonly=options.get('dbonly', False),
                force=options.get('force', False),
                needed=options.get('needed', False),
                alldeps=(options.get('mode', None) ==
                         pyalpm.PKG_REASON_DEPEND),
                allexplicit=(options.get('mode', None) ==
                             pyalpm.PKG_REASON_EXPLICIT),
                cascade=options.get('cascade', False),
                nosave=options.get('nosave', False),
                recurse=(options.get('recursive', 0) > 0),
                recurseall=(options.get('recursive', 0) > 1),
                unneeded=options.get('unneeded', False),
                downloadonly=options.get('downloadonly', False))
        except pyalpm.error as pyalpm_error:
            logging.error("Can't init alpm transaction: %s", pyalpm_error)
        return transaction
github Antergos / Cnchi / src / installation / process.py View on Github external
self.pkg.packages, self.down.metalinks)
        except subprocess.CalledProcessError as process_error:
            txt = "Error running command {0}: {1}".format(
                process_error.cmd,
                process_error.output)
            logging.error(txt)
            exc_type, exc_value, exc_traceback = sys.exc_info()
            trace = traceback.format_exception(
                exc_type, exc_value, exc_traceback)
            for line in trace:
                logging.error(line.rstrip())
            txt = _("Error running command {0}: {1}").format(
                process_error.cmd,
                process_error.output)
            self.events.add_fatal(txt)
        except (misc.InstallError, pyalpm.error,
                KeyboardInterrupt, TypeError,
                AttributeError, OSError, IOError) as install_error:
            logging.error(install_error)
            exc_type, exc_value, exc_traceback = sys.exc_info()
            trace = traceback.format_exception(
                exc_type, exc_value, exc_traceback)
            for line in trace:
                logging.error(line.rstrip())
            self.events.add_fatal(install_error)
github lahwaacz / wiki-scripts / update-package-templates.py View on Github external
def refresh(self):
        try:
            logger.info("Syncing AUR packages...")
            self.aurpkgs_refresh(self.aurpkgs_url)
            logger.info("Syncing pacman database...")
            self.pacdb_refresh(self.pacdb)
            return True
        except requests.exceptions.RequestException:
            logger.exception("Failed to download %s" % self.aurpkgs_url)
            return False
        except pyalpm.error:
            logger.exception("Failed to sync pacman database.")
            return False
github Antergos / Cnchi / src / download / download.py View on Github external
self.events.add('percent', 0)
        self.events.add(
            'info', _('Creating the list of packages to download...'))
        processed_packages = 0
        total_packages = len(self.package_names)

        self.metalinks = {}

        try:
            pacman = pac.Pac(
                conf_path=self.pacman_conf_file,
                callback_queue=self.events.queue)
            if pacman is None:
                return False
        except pyalpm.error as ex:
            self.metalinks = None
            template = "Can't initialize pyalpm. " \
                "An exception of type {0} occured. Arguments:\n{1!r}"
            message = template.format(type(ex).__name__, ex.args)
            logging.error(message)
            return False

        try:
            for package_name in self.package_names:
                metalink = ml.create(pacman, package_name,
                                     self.pacman_conf_file)
                if metalink is None:
                    txt = "Error creating metalink for package %s. Installation will stop"
                    logging.error(txt, package_name)
                    txt = _("Error creating metalink for package {}. "
                            "Installation will stop").format(package_name)
github Antergos / Cnchi / cnchi / installation / process.py View on Github external
def run(self):
        """ Calls run_installation and takes care of exceptions """

        try:
            self.run_installation()
        except subprocess.CalledProcessError as process_error:
            exc_type, exc_value, exc_traceback = sys.exc_info()
            trace = repr(traceback.format_exception(exc_type, exc_value, exc_traceback))
            logging.error(_("Error running command %s"), process_error.cmd)
            logging.error(_("Output: %s"), process_error.output)
            logging.error(trace)
            self.queue_fatal_event(process_error.output)
        except (
                InstallError, pyalpm.error, KeyboardInterrupt, TypeError, AttributeError, OSError,
                IOError) as install_error:
            exc_type, exc_value, exc_traceback = sys.exc_info()
            trace = repr(traceback.format_exception(exc_type, exc_value, exc_traceback))
            logging.error(install_error)
            logging.error(trace)
            self.queue_fatal_event(install_error)