Example #1
0
	def print_helper(self, app, args):
		if app.instances:
			manager = System.package_manager()
			package = manager.provided_by(app)
			if package:
				package.load_info(System.package_manager())

			tr = Tracer(System.package_manager(), Rules, Applications)
			tr.now = self.args.now
			if self.packages:
				tr.specified_packages = self.packages

			try: affected_by = tr.trace_application(app)
			except AccessDenied: affected_by = _("You don't have enough permissions")
			affects = self._affects(app, affected_by)

			view = HelperView()
			view.assign("args", args)
			view.assign("processes", app.instances)
			view.assign("application", app)
			view.assign("package", package)
			view.assign("affected_by", affected_by)
			view.assign("affects", affects)
			view.render()
		else:
			print(_("Application called {0} is not running").format(app.name))
Example #2
0
	def test_helper(self):
		processes = [
			ProcessMock(2, "foo", 1234, ["file1", "file2"]),
			ProcessMock(3, "foo", 5678, ["file2", "file3"]),
		]

		package = Package("foopackage")
		package.modified = None
		package.description = "Foo package description"
		package.category = "categ"
		package.files = ["file1", "file2"]

		a1 = AffectedProcessMock(2)
		a1.packages = set([package])
		affected_by = [a1]

		view = HelperView(self.out)
		view.assign("args", ArgsMock(verbose=2))
		view.assign("processes", processes)
		view.assign("application", Applications.find("foo"))
		view.assign("package", package)
		view.assign("affected_by", affected_by)
		view.assign("affects", None)
		view.render()
		self.assertEquals(self.out.getvalue(), (
			"* foo\n"
			"    Package:     foopackage\n"
			"    Description: Foo package description\n"
			"    Type:        Application\n"
			"    State:       foo has been started by None some-time ago. PID - 2\n"
			"                 foo has been started by None some-time ago. PID - 3\n"
			"\n"
			"    Affected by:\n"
			"        foopackage\n"
			"            file1\n"
			"            file2\n"
		))
Example #3
0
    def test_helper(self):
        processes = [
            ProcessMock(2, "foo", 1234, ["file1", "file2"]),
            ProcessMock(3, "foo", 5678, ["file2", "file3"]),
        ]

        package = Package("foopackage")
        package.modified = None
        package.description = "Foo package description"
        package.category = "categ"
        package.files = ["file1", "file2"]

        a1 = AffectedProcessMock(2)
        a1.packages = set([package])
        affected_by = [a1]

        view = HelperView(self.out)
        view.assign("args", ArgsMock(verbose=2))
        view.assign("processes", processes)
        view.assign("application", Applications.find("foo"))
        view.assign("package", package)
        view.assign("affected_by", affected_by)
        view.assign("affects", None)
        view.render()
        self.assertEquals(self.out.getvalue(), (
            "* foo\n"
            "    Package:     foopackage\n"
            "    Description: Foo package description\n"
            "    Type:        Application\n"
            "    State:       foo has been started by None some-time ago. PID - 2\n"
            "                 foo has been started by None some-time ago. PID - 3\n"
            "\n"
            "    Affected by:\n"
            "        foopackage\n"
            "            file1\n"
            "            file2\n"))
Example #4
0
	def print_helper(self, app_name, args):
		processes = Applications.find(app_name).instances
		if processes:
			manager = System.package_manager()
			package = manager.provided_by(app_name)
			if package:
				package.load_info(System.package_manager())

			tr = Tracer(System.package_manager(), Rules, Applications)
			tr.now = self.args.now
			if self.packages:
				tr.specified_packages = self.packages

			try: affected_by = tr.trace_application(app_name)
			except AccessDenied: affected_by = _("You don't have enough permissions")

			app = Applications.find(app_name)
			affects = self._affects(app, affected_by)

			view = HelperView()
			view.assign("args", args)
			view.assign("processes", processes)
			view.assign("application", app)
			view.assign("package", package)
			view.assign("affected_by", affected_by)
			view.assign("affects", affects)
			view.render()
		else:
			print(_("Application called {0} is not running").format(app_name))