Example #1
0
	def __init__(self, path):
		''' The constructor needs the path to the repo database file '''
		Msg.process(_('Loading repo database:'), path)

		try:
			self.repo = Repo(path)
		except Exception as e:
			Msg.error(str(e))
			LocalRepo.shutdown(True)
Example #2
0
	def restore(self):
		''' Try to restore the database file '''
		Msg.process(_('Restoring database'))

		try:
			self.repo.restore_db()
			return True
		except Exception as e:
			Msg.error(str(e))
			return False
Example #3
0
	def info(self, names):
		''' Print all available info of specified packages '''
		for name in names:
			if not self.repo.has_package(name):
				Msg.error(_('Package does not exist:'), name)
				return False

			Msg.process(_('Package information:'), name)
			Msg.info(str(self.repo.package(name)))

		return True
Example #4
0
    def info(self, names):
        ''' Print all available info of specified packages '''
        for name in names:
            if not self.repo.has_package(name):
                Msg.error(_('Package does not exist:'), name)
                return False

            Msg.process(_('Package information:'), name)
            Msg.info(str(self.repo.package(name)))

        return True
Example #5
0
	def check(self):
		''' Run an integrity check '''
		Msg.info(_('{0} packages found').format(self.repo.size))
		Msg.process(_('Running integrity check'))
		errors = self.repo.check()

		if not errors:
			Msg.info(_('No errors found'))
			return True

		for e in errors:
			Msg.error(e)

		return True
Example #6
0
    def check(self):
        ''' Run an integrity check '''
        Msg.info(_('{0} packages found').format(self.repo.size))
        Msg.process(_('Running integrity check'))
        errors = self.repo.check()

        if not errors:
            Msg.info(_('No errors found'))
            return True

        for e in errors:
            Msg.error(e)

        return True
Example #7
0
	def check(self):
		''' Run an integrity check '''
		Msg.info(str(self.repo.size), 'packages found')
		Msg.process('Running integrity check')
		errors = self.repo.check()

		if not errors:
			Msg.info('No errors found')
			return True

		for e in errors:
			Msg.error(e)

		return True
Example #8
0
	def remove(self, names):
		''' Remove packages from the repo '''
		bad = [name for name in names if not self.repo.has_package(name)]

		if bad:
			Msg.error(_('Packages do not exist:'), ', '.join(bad))
			return False

		Msg.process(_('Removing packages:'), ', '.join(names))

		try:
			self.repo.remove(names)
			return True
		except Exception as e:
			Msg.error(str(e))
			return False
Example #9
0
    def remove(self, names):
        ''' Remove packages from the repo '''
        bad = [name for name in names if not self.repo.has_package(name)]

        if bad:
            Msg.error(_('Packages do not exist:'), ', '.join(bad))
            return False

        Msg.process(_('Removing packages:'), ', '.join(names))

        try:
            self.repo.remove(names)
            return True
        except Exception as e:
            Msg.error(str(e))
            return False
Example #10
0
	def aur_add(self, names):
		''' Download, make and add packages from the AUR '''
		Msg.process(_('Retrieving package info from the AUR'))

		try:
			pkgs = Aur.packages(names)
		except Exception as e:
			Msg.error(str(e))
			return False

		for pkg in pkgs.values():
			if self.repo.has_package(pkg['name']):
				Msg.error(_('Package is already in the repo:'), pkg['name'])
				return False

			if not self.add([pkg['uri']]):
				return False

		return True
Example #11
0
    def aur_add(self, names):
        ''' Download, make and add packages from the AUR '''
        Msg.process(_('Retrieving package info from the AUR'))

        try:
            pkgs = Aur.packages(names)
        except Exception as e:
            Msg.error(str(e))
            return False

        for pkg in pkgs.values():
            if self.repo.has_package(pkg['name']):
                Msg.error(_('Package is already in the repo:'), pkg['name'])
                return False

            if not self.add([pkg['uri']]):
                return False

        return True
Example #12
0
	def aur_upgrade(self):
		''' Upgrades all packages from the AUR '''
		Msg.info(_('{0} packages found').format(self.repo.size))

		if self.repo.size is 0:
			Msg.info(_('Nothing to do'))
			return True

		Msg.process(_('Retrieving package info from the AUR'))

		try:
			pkgs = Aur.packages(self.repo.packages)
		except Exception as e:
			Msg.error(str(e))
			return False

		Msg.info(_('{0} packages found').format(len(pkgs)))
		Msg.process(_('Checking for updates'))
		updates = []

		for name in (pkg for pkg in pkgs if self.repo.has_package(pkg)):
			if pkgs[name]['version'] > self.repo.package(name).version:
				updates.append(pkgs[name])

		if not updates:
			Msg.info(_('All packages are up to date'))
			return True

		for pkg in updates:
			Msg.result('{0} ({1} -> {2})'.format(pkg['name'],
			                                     self.repo.package(pkg['name']).version,
			                                     pkg['version']))

		if not Msg.yes(_('Upgrade')):
			Msg.info(_('Bye'))
			return True

		return self.add([pkg['uri'] for pkg in updates], True)
Example #13
0
    def aur_upgrade(self):
        ''' Upgrades all packages from the AUR '''
        Msg.info(_('{0} packages found').format(self.repo.size))

        if self.repo.size is 0:
            Msg.info(_('Nothing to do'))
            return True

        Msg.process(_('Retrieving package info from the AUR'))

        try:
            pkgs = Aur.packages(self.repo.packages)
        except Exception as e:
            Msg.error(str(e))
            return False

        Msg.info(_('{0} packages found').format(len(pkgs)))
        Msg.process(_('Checking for updates'))
        updates = []

        for name in (pkg for pkg in pkgs if self.repo.has_package(pkg)):
            if pkgs[name]['version'] > self.repo.package(name).version:
                updates.append(pkgs[name])

        if not updates:
            Msg.info(_('All packages are up to date'))
            return True

        for pkg in updates:
            Msg.result('{0} ({1} -> {2})'.format(
                pkg['name'],
                self.repo.package(pkg['name']).version, pkg['version']))

        if not Msg.yes(_('Upgrade')):
            Msg.info(_('Bye'))
            return True

        return self.add([pkg['uri'] for pkg in updates], True)
Example #14
0
	def add(self, paths, upgrade=False):
		''' Add packages to the repo '''
		for path in paths:
			Msg.process(_('Making a new package'))

			try:
				pkg = Package.forge(path)

				if upgrade:
					Msg.process(_('Upgrading package:'), pkg.name)
					self.repo.upgrade(pkg)
				else:
					Msg.process(_('Adding package to the repo:'), pkg.name)
					self.repo.add(pkg)
			except Exception as e:
				Msg.error(str(e))
				return False

		return True
Example #15
0
    def add(self, paths, upgrade=False):
        ''' Add packages to the repo '''
        for path in paths:
            Msg.process(_('Making a new package'))

            try:
                pkg = Package.forge(path)

                if upgrade:
                    Msg.process(_('Upgrading package:'), pkg.name)
                    self.repo.upgrade(pkg)
                else:
                    Msg.process(_('Adding package to the repo:'), pkg.name)
                    self.repo.add(pkg)
            except Exception as e:
                Msg.error(str(e))
                return False

        return True