Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes - #45 Report reboot for new kernels #83

Merged
merged 1 commit into from
May 16, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tracer/resources/tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@

from __future__ import absolute_import

import os
from distutils.version import LooseVersion
from psutil import NoSuchProcess
from tracer.resources.system import System
from tracer.resources.FilenameCleaner import FilenameCleaner
from tracer.resources.processes import AffectedProcess
from tracer.resources.collections import ApplicationsCollection, AffectedProcessesCollection, PackagesCollection
from tracer.resources.exceptions import UnsupportedDistribution
from tracer.resources.applications import Applications, AffectedApplication
from tracer.resources.lang import _


class Tracer(object):
Expand Down Expand Up @@ -119,9 +122,19 @@ def trace_affected(self, user=None):
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())

def _has_updated_kernel(self):
for k_version in next(os.walk('/lib/modules/'))[1]:
if LooseVersion(os.uname()[2]) < LooseVersion(k_version):
return True
return False

def _apply_rules(self, process):
parent = process.parent()
if not parent:
Expand Down