コード例 #1
0
    def _affecting_processes(self,
                             process,
                             packages,
                             affected_process_factory=AffectedProcess):
        collection = AffectedProcessesCollection()
        process_files = process.files
        for package in packages:
            matching_files = set()
            for package_file in self._PACKAGE_MANAGER.package_files(
                    package.name):
                package_file = FilenameCleaner.strip(package_file)
                if not package_file in process_files:
                    continue

                if process.create_time() <= package.modified:
                    matching_files.add(package_file)

            if matching_files:
                aff_pkg = package
                aff_pkg.files = matching_files

                affected = affected_process_factory(process.pid)
                affected.__dict__.update(process.__dict__)
                affected.packages.update([aff_pkg])
                collection.update([affected])
        return collection
コード例 #2
0
class TestFilenameCleaner(TestCase):
    def setUp(self):
        self.cleaner = FilenameCleaner()

    def test_strip(self):
        self.assertEqual("/lib/libdl.so",
                         self.cleaner.strip("/lib/libdl-2.19.so"))
        self.assertEqual("/lib/libncurses.so",
                         self.cleaner.strip("/lib/libncurses.so.5.9"))
        self.assertEqual("/bin/bash", self.cleaner.strip("/bin/bash"))
        self.assertEqual(
            "/usr/share/wicd/curses/wicd-curses.py",
            self.cleaner.strip("/usr/share/wicd/curses/wicd-curses.py"))
        self.assertEqual("/usr/bin/gvim",
                         self.cleaner.strip("/usr/bin/gvim#new (deleted)"))

        self.assertEqual(
            "/usr/lib64/kde4/kded_networkmanagement.so",
            self.cleaner.strip(
                "/usr/lib64/kde4/kded_networkmanagement.so;53c7cd86"))

        self.assertEqual(
            "/usr/lib64/firefox/plugin-container",
            self.cleaner.strip(
                "/usr/lib64/firefox/plugin-container.#prelink#.N3n7Rk (deleted)"
            ))
コード例 #3
0
    def trace_affected(self, user=None):
        """
		Returns collection of applications which uses some files that have been modified
		@TODO This function should be hardly optimized
		"""

        memory = self._memory(user)
        packages = self._modified_packages()

        affected = {}
        found = []
        for package in packages.unique_newest():
            for file in self._PACKAGE_MANAGER.package_files(package.name):

                file = FilenameCleaner.strip(file)
                if not file in memory:
                    continue

                for p in memory[file]:
                    if p.pid in found:
                        continue

                    try:
                        if p.create_time() <= package.modified:
                            found.append(p.pid)
                            p = self._apply_rules(p)
                            a = self._applications.find(p.name())

                            if not a.ignore:
                                if a.name not in affected:
                                    if self._erased and not self._PACKAGE_MANAGER.provided_by(
                                            a.name):
                                        a.type = Applications.TYPES["ERASED"]
                                    affected[a.name] = AffectedApplication(
                                        a._attributes)
                                    affected[
                                        a.
                                        name].affected_instances = AffectedProcessesCollection(
                                        )
                                    self._call_hook(affected[a.name])
                                affected[a.name].affected_instances.append(p)
                    except NoSuchProcess:
                        pass
        if self._has_updated_kernel(
        ) and not self._applications.find('kernel').ignore:
            # Add fake AffectedApplication
            affected['kernel'] = AffectedApplication({
                "name":
                "kernel",
                "type":
                Applications.TYPES["STATIC"],
                "helper":
                _("You will have to reboot your computer")
            })

        return ApplicationsCollection(affected.values())
コード例 #4
0
ファイル: tracer.py プロジェクト: FrostyX/tracer
	def trace_affected(self, user=None):
		"""
		Returns collection of applications which uses some files that have been modified
		@TODO This function should be hardly optimized
		"""

		memory = self._memory(user)
		packages = self._modified_packages()

		affected = {}
		found = []
		for package in packages.unique_newest():
			for file in self._PACKAGE_MANAGER.package_files(package.name):

				file = FilenameCleaner.strip(file)
				if not file in memory:
					continue

				for p in memory[file]:
					if p.pid in found:
						continue

					try:
						if p.create_time() <= package.modified:
							found.append(p.pid)
							p = self._apply_rules(p)
							a = self._applications.find(p.name())

							if not a.ignore:
								if a.name not in affected:
									if self._erased and not self._PACKAGE_MANAGER.provided_by(a.name):
										a.type = Applications.TYPES["ERASED"]
									affected[a.name] = AffectedApplication(a._attributes)
									affected[a.name].affected_instances = AffectedProcessesCollection()
									self._call_hook(affected[a.name])
								affected[a.name].affected_instances.append(p)
					except NoSuchProcess:
						pass
		if self._has_updated_kernel() and not self._applications.find('kernel').ignore:
			# Add fake AffectedApplication
			affected['kernel'] = AffectedApplication({"name": "kernel", "type": Applications.TYPES["STATIC"],
									"helper": _("You will have to reboot your computer")})

		return ApplicationsCollection(affected.values())
コード例 #5
0
ファイル: tracer.py プロジェクト: ignatenkobrain/tracer
    def trace_affected(self, user=None):
        """
		Returns collection of applications which uses some files that have been modified
		@TODO This function should be hardly optimized
		"""

        memory = self._memory(user)
        packages = self._modified_packages()

        affected = {}
        found = []
        for package in packages.unique_newest():
            for file in self._PACKAGE_MANAGER.package_files(package.name):

                file = FilenameCleaner.strip(file)
                if not file in memory:
                    continue

                for p in memory[file]:
                    if p.pid in found:
                        continue

                    try:
                        if p.create_time() <= package.modified:
                            found.append(p.pid)
                            p = self._apply_rules(p)
                            a = self._applications.find(p.name())

                            if a.name not in affected:
                                if self._erased and not self._PACKAGE_MANAGER.provided_by(
                                        a.name):
                                    a.type = Applications.TYPES["ERASED"]
                                affected[a.name] = a
                                affected[
                                    a.
                                    name].affected_instances = AffectedProcessesCollection(
                                    )
                                self._call_hook(a)
                            affected[a.name].affected_instances.append(p)
                    except NoSuchProcess:
                        pass

        return ApplicationsCollection(affected.values())
コード例 #6
0
class TestFilenameCleaner(TestCase):
	def setUp(self):
		self.cleaner = FilenameCleaner()

	def test_strip(self):
		self.assertEqual("/lib/libdl.so", self.cleaner.strip("/lib/libdl-2.19.so"))
		self.assertEqual("/lib/libncurses.so", self.cleaner.strip("/lib/libncurses.so.5.9"))
		self.assertEqual("/bin/bash", self.cleaner.strip("/bin/bash"))
		self.assertEqual("/usr/share/wicd/curses/wicd-curses.py", self.cleaner.strip("/usr/share/wicd/curses/wicd-curses.py"))
		self.assertEqual("/usr/bin/gvim", self.cleaner.strip("/usr/bin/gvim#new (deleted)"))

		self.assertEqual("/usr/lib64/kde4/kded_networkmanagement.so",
			self.cleaner.strip("/usr/lib64/kde4/kded_networkmanagement.so;53c7cd86")
		)

		self.assertEqual("/usr/lib64/firefox/plugin-container",
			 self.cleaner.strip("/usr/lib64/firefox/plugin-container.#prelink#.N3n7Rk (deleted)")
		)
コード例 #7
0
ファイル: tracer.py プロジェクト: FrostyX/tracer
	def _affecting_processes(self, process, packages, affected_process_factory=AffectedProcess):
		collection = AffectedProcessesCollection()
		process_files = process.files
		for package in packages:
			matching_files = set()
			for package_file in self._PACKAGE_MANAGER.package_files(package.name):
				package_file = FilenameCleaner.strip(package_file)
				if not package_file in process_files:
					continue

				if process.create_time() <= package.modified:
					matching_files.add(package_file)

			if matching_files:
				aff_pkg = package
				aff_pkg.files = matching_files

				affected = affected_process_factory(process.pid)
				affected.__dict__.update(process.__dict__)
				affected.packages.update([aff_pkg])
				collection.update([affected])
		return collection
コード例 #8
0
ファイル: tracer.py プロジェクト: tsujamin/tracer
	def trace_affected(self, user=None):
		"""
		Returns collection of applications which uses some files that have been modified
		@TODO This function should be hardly optimized
		"""

		memory = self._memory(user)
		packages = self._modified_packages()

		affected = {}
		found = []
		for package in packages.unique_newest():
			for file in self._PACKAGE_MANAGER.package_files(package.name):

				file = FilenameCleaner.strip(file)
				if not file in memory:
					continue

				for p in memory[file]:
					if p.pid in found:
						continue

					try:
						if p.create_time() <= package.modified:
							found.append(p.pid)
							p = self._apply_rules(p)
							a = self._applications.find(p.name())

							if a.name not in affected:
								if self._erased and not self._PACKAGE_MANAGER.provided_by(a.name):
									a.type = Applications.TYPES["ERASED"]
								affected[a.name] = a
								affected[a.name].affected_instances = AffectedProcessesCollection()
								self._call_hook(a)
							affected[a.name].affected_instances.append(p)
					except NoSuchProcess:
						pass

		return ApplicationsCollection(affected.values())
コード例 #9
0
	def setUp(self):
		self.cleaner = FilenameCleaner()
コード例 #10
0
 def setUp(self):
     self.cleaner = FilenameCleaner()